From 1e221dba9319c1b7d393ce8c07ad168eb02276c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arda=20Nak=C4=B1=C5=9F=C3=A7=C4=B1?= Date: Fri, 19 Aug 2022 12:05:09 +0300 Subject: [PATCH] Sync testnet to main (#236) * Sync development to testnet (#221) * Amount validity check update * Airdrop fund and register subtitle fix (#219) * Fix subtitles for airdrop register & fund * Typo fix * Native token airdrop support (#220) * Add token selection UI to airdrop create page * Fix native token logic on airdrop create * Add new method for funding in merkle airdrop contract * Update airdrop props * Use correct funding method based on airdrop token * Implement native token logic on claim page * Fix client error on website load * Update instantiate message with native token * Fix balance error on website load Co-authored-by: Serkan Reis * Merge development to testnet (#226) * Amount validity check update * Airdrop fund and register subtitle fix (#219) * Fix subtitles for airdrop register & fund * Typo fix * Native token airdrop support (#220) * Add token selection UI to airdrop create page * Fix native token logic on airdrop create * Add new method for funding in merkle airdrop contract * Update airdrop props * Use correct funding method based on airdrop token * Implement native token logic on claim page * Fix client error on website load * Update instantiate message with native token * Fix balance error on website load * Manage (burn or withdraw) remaining funds for an expired airdrop (#223) * Feature: Terra airdrop support (#224) * Sync development to testnet (#205) * Remove comment * Update testnet chain id * Merge development to testnet (#214) * Remove comment * Update testnet chain id * Typo fixes (#208) * Changed "swiss knife" to "Swiss Army knife" * Removed unnecessary and unconventional "as" before "Smart Contract Dashboard" * Capitalized first letter of "Airdrops" and "Create Airdrop" page names, changed reference to Create Airdrop page to mention the page name * Sign and verify placeholder (#207) * add placeholders for sign and verify * Fix signature placeholder * fix placeholder * update testnet explorer * Add features to keplr config * The utility function isValidAccountsFile() now includes a check for duplicate addresses * Json formatted execute operation entry changed (#206) * Json formatted execute operation entry turned into form like formatted entry * Minor fixs * Minor fixes * Minor fixes * Walletless query (#212) * Wallet.tsx client turned into cosmwasmclient when not initialised * Minor fix * Minor fixes Co-authored-by: Lyte Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com> Co-authored-by: Highlander-Maker Co-authored-by: Furkan Kaymak Co-authored-by: Serkan Reis Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com> * Bump version * Add terra related logic (#2) * Add terra related logic to whitelist processing * Set terra airdrop flag on airdrop creation * Update airdrop props * Add terra related logic to merkle contract helpers * Add terra logic to claim page * Update logic * Show claim button for all terra airdrops * Include signature in Terra airdrop claim messages * Revert "Include signature in Terra airdrop claim messages" This reverts commit ecaed19eeb3237d51bade2a0704a101fbf8a8be4. * Include "sig_info" in Terra airdrop claim messages (#4) * Include signature in Terra airdrop claim messages * Remove txSigner from burn message on merkle airdrop * Remove unused code * Add comments for later on Co-authored-by: findolor * Add hrp field * Setup redirects and fix manage page error * Refactor claim page terra airdrop logic Co-authored-by: Lyte Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com> Co-authored-by: Highlander-Maker Co-authored-by: Furkan Kaymak Co-authored-by: Serkan Reis Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com> * Revert "Merge branch 'testnet' into development" This reverts commit f370b816415cc988df5e2ed8eb033204dc9d7834, reversing changes made to c94efb393cec1f6da4d855e796293ab884d752df. * Remove txSigner from claim method in airdrop helpers Co-authored-by: Serkan Reis Co-authored-by: Lyte Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com> Co-authored-by: Highlander-Maker Co-authored-by: Furkan Kaymak Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com> * Sync development to testnet (#235) * Amount validity check update * Airdrop fund and register subtitle fix (#219) * Fix subtitles for airdrop register & fund * Typo fix * Native token airdrop support (#220) * Add token selection UI to airdrop create page * Fix native token logic on airdrop create * Add new method for funding in merkle airdrop contract * Update airdrop props * Use correct funding method based on airdrop token * Implement native token logic on claim page * Fix client error on website load * Update instantiate message with native token * Fix balance error on website load * Manage (burn or withdraw) remaining funds for an expired airdrop (#223) * Feature: Terra airdrop support (#224) * Sync development to testnet (#205) * Remove comment * Update testnet chain id * Merge development to testnet (#214) * Remove comment * Update testnet chain id * Typo fixes (#208) * Changed "swiss knife" to "Swiss Army knife" * Removed unnecessary and unconventional "as" before "Smart Contract Dashboard" * Capitalized first letter of "Airdrops" and "Create Airdrop" page names, changed reference to Create Airdrop page to mention the page name * Sign and verify placeholder (#207) * add placeholders for sign and verify * Fix signature placeholder * fix placeholder * update testnet explorer * Add features to keplr config * The utility function isValidAccountsFile() now includes a check for duplicate addresses * Json formatted execute operation entry changed (#206) * Json formatted execute operation entry turned into form like formatted entry * Minor fixs * Minor fixes * Minor fixes * Walletless query (#212) * Wallet.tsx client turned into cosmwasmclient when not initialised * Minor fix * Minor fixes Co-authored-by: Lyte Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com> Co-authored-by: Highlander-Maker Co-authored-by: Furkan Kaymak Co-authored-by: Serkan Reis Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com> * Bump version * Add terra related logic (#2) * Add terra related logic to whitelist processing * Set terra airdrop flag on airdrop creation * Update airdrop props * Add terra related logic to merkle contract helpers * Add terra logic to claim page * Update logic * Show claim button for all terra airdrops * Include signature in Terra airdrop claim messages * Revert "Include signature in Terra airdrop claim messages" This reverts commit ecaed19eeb3237d51bade2a0704a101fbf8a8be4. * Include "sig_info" in Terra airdrop claim messages (#4) * Include signature in Terra airdrop claim messages * Remove txSigner from burn message on merkle airdrop * Remove unused code * Add comments for later on Co-authored-by: findolor * Add hrp field * Setup redirects and fix manage page error * Refactor claim page terra airdrop logic Co-authored-by: Lyte Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com> Co-authored-by: Highlander-Maker Co-authored-by: Furkan Kaymak Co-authored-by: Serkan Reis Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com> * Revert "Merge branch 'testnet' into development" This reverts commit f370b816415cc988df5e2ed8eb033204dc9d7834, reversing changes made to c94efb393cec1f6da4d855e796293ab884d752df. * Remove txSigner from claim method in airdrop helpers * Get correct token balance based on token type (#233) * Custom decimal on denom conversion (#234) * Add decimal parameter to denom conversion * Add custom decimals to conversion method * Change contract parameter to be recipient for cw20 execute send (#232) Co-authored-by: Serkan Reis Co-authored-by: Lyte Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com> Co-authored-by: Highlander-Maker Co-authored-by: Furkan Kaymak Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com> Co-authored-by: Serkan Reis Co-authored-by: Lyte Co-authored-by: Highlander <68139321+Highlander-maker@users.noreply.github.com> Co-authored-by: Highlander-Maker Co-authored-by: Furkan Kaymak Co-authored-by: name-user1 <101495985+name-user1@users.noreply.github.com> --- pages/airdrops/[address]/claim.tsx | 32 +++++++++++++++--------------- pages/airdrops/fund.tsx | 8 +++++--- pages/airdrops/manage.tsx | 9 ++++++--- utils/contracts/cw20/execute.ts | 8 ++++---- utils/convertDenomToReadable.ts | 4 ++-- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/pages/airdrops/[address]/claim.tsx b/pages/airdrops/[address]/claim.tsx index 5df0bc92..2c4a646d 100644 --- a/pages/airdrops/[address]/claim.tsx +++ b/pages/airdrops/[address]/claim.tsx @@ -166,21 +166,21 @@ const ClaimAirdropPage: NextPage = () => { }, [contractAddress, wallet.address, wallet.initialized, wallets[0]?.terraAddress]) useEffect(() => { - setBalance(Number(wallet.balance[0]?.amount)) - }, [wallet.balance]) + if (cw20TokenAddress) { + if (!cw20BaseContract) return - useEffect(() => { - if (!cw20BaseContract || !cw20TokenAddress) return + const contractMessages = cw20BaseContract.use(cw20TokenAddress) - const contractMessages = cw20BaseContract.use(cw20TokenAddress) - - contractMessages - ?.balance(wallet.address) - .then((data: string) => { - setBalance(parseInt(data)) - }) - .catch(console.error) - }, [cw20TokenAddress, wallet.address]) + contractMessages + ?.balance(wallet.address) + .then((data: string) => { + setBalance(parseInt(data)) + }) + .catch(console.error) + } else { + setBalance(Number(wallet.balance[0]?.amount)) + } + }, [cw20TokenAddress, wallet.address, wallet.balance]) useEffect(() => { if (!cw20BaseContract || !cw20TokenAddress) return @@ -281,7 +281,7 @@ const ClaimAirdropPage: NextPage = () => {
juno - {convertDenomToReadable(amount)} {cw20TokenInfo?.symbol} + {convertDenomToReadable(amount, cw20TokenInfo?.decimals)} {cw20TokenInfo?.symbol}
@@ -293,10 +293,10 @@ const ClaimAirdropPage: NextPage = () => { {cw20TokenAddress} - {convertDenomToReadable(amount)} {cw20TokenInfo?.symbol} + {convertDenomToReadable(amount, cw20TokenInfo?.decimals)} {cw20TokenInfo?.symbol} - {convertDenomToReadable(balance)} {cw20TokenInfo?.symbol} + {convertDenomToReadable(balance, cw20TokenInfo?.decimals)} {cw20TokenInfo?.symbol}
{JSON.stringify(proofs, null, 2)}
diff --git a/pages/airdrops/fund.tsx b/pages/airdrops/fund.tsx index 463a1ac9..6c7062ee 100644 --- a/pages/airdrops/fund.tsx +++ b/pages/airdrops/fund.tsx @@ -50,6 +50,7 @@ const FundAirdropPage: NextPage = () => { const [balance, setBalance] = useState(null) const [target, setTarget] = useState(null) const [denom, setDenom] = useState(null) + const [decimals, setDecimals] = useState(6) const [method, setMethod] = useState('mint') @@ -78,6 +79,7 @@ const FundAirdropPage: NextPage = () => { setTarget(_target) setAmount(needed < 0 ? '0' : needed.toString()) setDenom(_denom) + setDecimals(data.decimals) }) .catch((err: any) => { toast.error(err.message, { @@ -207,7 +209,7 @@ const FundAirdropPage: NextPage = () => { {balance ? ( <> - {convertDenomToReadable(target)} + {convertDenomToReadable(target, decimals)} ) : ( '...' @@ -216,7 +218,7 @@ const FundAirdropPage: NextPage = () => { {balance ? ( <> - {convertDenomToReadable(balance)} + {convertDenomToReadable(balance, decimals)} ) : ( '...' @@ -225,7 +227,7 @@ const FundAirdropPage: NextPage = () => { {target && balance ? ( <> - {convertDenomToReadable(amount)} + {convertDenomToReadable(amount, decimals)} ) : ( '...' diff --git a/pages/airdrops/manage.tsx b/pages/airdrops/manage.tsx index ec907433..2234dd71 100644 --- a/pages/airdrops/manage.tsx +++ b/pages/airdrops/manage.tsx @@ -38,6 +38,8 @@ const ManageAirdropPage: NextPage = () => { const [balance, setBalance] = useState(null) const [target, setTarget] = useState(null) const [denom, setDenom] = useState(null) + const [decimals, setDecimals] = useState(6) + const [recipientAddress, setRecipientAddress] = useState(null) const [isExpired, setIsExpired] = useState(false) @@ -69,6 +71,7 @@ const ManageAirdropPage: NextPage = () => { setTarget(_target) setAmount(needed < 0 ? '0' : needed.toString()) setDenom(_denom) + setDecimals(data.decimals) }) .catch((err: any) => { toast.error(err.message, { @@ -266,7 +269,7 @@ const ManageAirdropPage: NextPage = () => { {balance ? ( <> - {convertDenomToReadable(target)} + {convertDenomToReadable(target, decimals)} ) : ( '...' @@ -275,7 +278,7 @@ const ManageAirdropPage: NextPage = () => { {balance ? ( <> - {convertDenomToReadable(balance)} + {convertDenomToReadable(balance, decimals)} ) : ( '...' @@ -284,7 +287,7 @@ const ManageAirdropPage: NextPage = () => { {target && balance ? ( <> - {convertDenomToReadable(amount)} + {convertDenomToReadable(amount, decimals)} ) : ( '...' diff --git a/utils/contracts/cw20/execute.ts b/utils/contracts/cw20/execute.ts index f1e3cbfb..409af52e 100644 --- a/utils/contracts/cw20/execute.ts +++ b/utils/contracts/cw20/execute.ts @@ -102,7 +102,7 @@ export type DispatchExecuteArgs = { | { type: Select<'decrease-allowance'>; recipient: string; amount: string } | { type: Select<'transfer'>; recipient: string; amount: string } | { type: Select<'transfer-from'>; owner: string; recipient: string; amount: string } - | { type: Select<'send'>; contract: string; amount: string; msg: any } + | { type: Select<'send'>; recipient: string; amount: string; msg: any } | { type: Select<'send-from'>; owner: string; recipient: string; amount: string; msg: any } | { type: Select<'update-marketing'>; project: string; description: string; marketing: string } | { type: Select<'update-logo'>; logo: { url: string } } @@ -138,7 +138,7 @@ export const dispatchExecute = async (args: DispatchExecuteArgs) => { return messages.transferFrom(txSigner, args.owner, args.recipient, args.amount.toString()) } case 'send': { - return messages.send(txSigner, args.contract, args.amount.toString(), args.msg) + return messages.send(txSigner, args.recipient, args.amount.toString(), args.msg) } case 'send-from': { return messages.sendFrom(txSigner, args.owner, args.recipient, args.amount.toString(), args.msg) @@ -188,8 +188,8 @@ export const previewExecutePayload = (args: DispatchExecuteArgs) => { return messages()?.transferFrom(contract, owner, recipient, amount.toString()) } case 'send': { - const { contract, amount, msg } = args - return messages()?.send(contract, contract, amount.toString(), msg) + const { contract, recipient, amount, msg } = args + return messages()?.send(contract, recipient, amount.toString(), msg) } case 'send-from': { const { contract, amount, msg, owner, recipient } = args diff --git a/utils/convertDenomToReadable.ts b/utils/convertDenomToReadable.ts index f31f5ab4..1ad24bec 100644 --- a/utils/convertDenomToReadable.ts +++ b/utils/convertDenomToReadable.ts @@ -1,3 +1,3 @@ -export const convertDenomToReadable = (amount: string | number | null) => { - return Number(amount) / 1000000 +export const convertDenomToReadable = (amount: string | number | null, decimal = 6) => { + return Number(amount) / Math.pow(10, decimal) }