From de257bc22c67c9ffd54b81ce5c9ac7b4fd43a4d8 Mon Sep 17 00:00:00 2001 From: Chase Moran Date: Wed, 15 Sep 2021 16:00:41 -0400 Subject: [PATCH] bridge_ui: eth token picker refreshes, & exclude 0 balance tokens Change-Id: I0518106640e42dcd4aa1690f5855bd124043cbb1 --- .../components/TokenSelectors/SolanaSourceTokenSelector.tsx | 4 ++++ bridge_ui/src/hooks/useGetSourceParsedTokenAccounts.ts | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bridge_ui/src/components/TokenSelectors/SolanaSourceTokenSelector.tsx b/bridge_ui/src/components/TokenSelectors/SolanaSourceTokenSelector.tsx index 662e40ffe..d78fa2db6 100644 --- a/bridge_ui/src/components/TokenSelectors/SolanaSourceTokenSelector.tsx +++ b/bridge_ui/src/components/TokenSelectors/SolanaSourceTokenSelector.tsx @@ -233,6 +233,10 @@ export default function SolanaSourceTokenSelector( const filteredOptions = useMemo(() => { return props.accounts.filter((x) => { //TODO, do a better check which likely involves supply or checking masterEdition. + const zeroBalance = x.amount === "0"; + if (zeroBalance) { + return false; + } const isNFT = x.decimals === 0 && metaplex.data?.get(x.mintKey)?.data?.uri; return nft ? isNFT : !isNFT; diff --git a/bridge_ui/src/hooks/useGetSourceParsedTokenAccounts.ts b/bridge_ui/src/hooks/useGetSourceParsedTokenAccounts.ts index b000ef021..f96785da5 100644 --- a/bridge_ui/src/hooks/useGetSourceParsedTokenAccounts.ts +++ b/bridge_ui/src/hooks/useGetSourceParsedTokenAccounts.ts @@ -214,6 +214,7 @@ const getEthereumAccountsCovalent = async ( item.contract_ticker_symbol && item.contract_address && item.balance && + item.balance !== "0" && (nft ? item.supports_erc?.includes("erc721") : item.supports_erc?.includes("erc20")) @@ -416,7 +417,7 @@ function useGetAvailableTokens(nft: boolean = false) { // const nftTestWallet2 = "0x98ed231428088eb440e8edb5cc8d66dcf913b86e"; let cancelled = false; const walletAddress = signerAddress; - if (walletAddress && lookupChain === CHAIN_ID_ETH && !tokenAccounts.data) { + if (walletAddress && lookupChain === CHAIN_ID_ETH && !covalent) { //TODO less cancel !cancelled && setCovalentLoading(true); !cancelled && @@ -477,7 +478,7 @@ function useGetAvailableTokens(nft: boolean = false) { cancelled = true; }; } - }, [lookupChain, provider, signerAddress, dispatch, nft, tokenAccounts.data]); + }, [lookupChain, provider, signerAddress, dispatch, nft, covalent]); //Terra accounts load //At present, we don't have any mechanism for doing this.