diff --git a/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx b/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx index 5fe2d01ba..cd016d65c 100644 --- a/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx +++ b/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx @@ -97,9 +97,9 @@ const TokenList = (props: Props) => { if ( props.selectedToken && props.selectedToken!.chain === props.selectedChainConfig.key && - !tokenSet.has(props.selectedToken.key) + !tokenSet.has(props.selectedToken.address.toString()) ) { - tokenSet.add(props.selectedToken.key); + tokenSet.add(props.selectedToken.address.toString()); tokens.push(props.selectedToken); } @@ -108,8 +108,8 @@ const TokenList = (props: Props) => { const searchResult = props.tokenList?.find( (t) => t.address.toString().toLowerCase() === searchQuery.toLowerCase(), ); - if (searchResult) { - tokenSet.add(searchResult.key); + if (searchResult && !tokenSet.has(searchResult.address.toString())) { + tokenSet.add(searchResult.address.toString()); tokens.push(searchResult); } @@ -147,20 +147,23 @@ const TokenList = (props: Props) => { // Third: Add the native gas token if ( nativeToken && - nativeToken.key !== props.selectedToken?.key && - !tokenSet.has(nativeToken.key) + nativeToken.address.toString() !== + props.selectedToken?.address.toString() && + !tokenSet.has(nativeToken.address.toString()) ) { - tokenSet.add(nativeToken.key); + tokenSet.add(nativeToken.address.toString()); tokens.push(nativeToken); } // Fourth: Add tokens with a balances in the connected wallet Object.entries(balances).forEach(([key, val]) => { if (val?.balance && sdkAmount.units(val.balance) > 0n) { - const tokenConfig = props.tokenList?.find((t) => t.key === key); + const tokenConfig = props.tokenList?.find( + (t) => t.address.toString() === key, + ); - if (tokenConfig && !tokenSet.has(tokenConfig.key)) { - tokenSet.add(tokenConfig.key); + if (tokenConfig && !tokenSet.has(tokenConfig.address.toString())) { + tokenSet.add(tokenConfig.address.toString()); tokens.push(tokenConfig); } } @@ -171,7 +174,7 @@ const TokenList = (props: Props) => { if (!props.isSource || !props.wallet?.address) { props.tokenList?.forEach((t) => { // Check if previously added - if (tokenSet.has(t.key)) { + if (tokenSet.has(t.address.toString())) { return; } @@ -189,7 +192,7 @@ const TokenList = (props: Props) => { return; } - tokenSet.add(t.key); + tokenSet.add(t.address.toString()); tokens.push(t); }); }