From 28272948ec0d596c31a6ac30bbd2f2c1b796e6b4 Mon Sep 17 00:00:00 2001 From: Kevin Peters Date: Thu, 12 Sep 2024 14:36:22 -0500 Subject: [PATCH 1/2] search tokens by address --- .../views/v2/Bridge/AssetPicker/TokenList.tsx | 33 ++++++++++--------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx b/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx index e7b5c0d71..6de2d5f7b 100644 --- a/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx +++ b/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx @@ -179,31 +179,34 @@ const TokenList = (props: Props) => { filterFn={(token, query) => { if (query.length === 0) return true; + const chain = props.selectedChainConfig.key; + // Exclude frankenstein tokens with no balance const balance = Number(balances?.[token.key]?.balance); - if ( - isFrankensteinToken(token, props.selectedChainConfig.key) && - !balance - ) { + if (isFrankensteinToken(token, chain) && !balance) { return false; } // Exclude wormhole-wrapped tokens with no balance - if ( - props.isSource && - isWrappedToken(token, props.selectedChainConfig.key) && - !balance - ) { + if (props.isSource && isWrappedToken(token, chain) && !balance) { return false; } const queryLC = query.toLowerCase(); - return Boolean( - token.symbol?.toLowerCase().includes(queryLC) || - getDisplayName(token, props.selectedChainConfig.key) - .toLowerCase() - .includes(queryLC), - ); + + const symbolMatch = token.symbol?.toLowerCase().includes(queryLC); + + const displayNameMatch = getDisplayName(token, chain) + .toLowerCase() + .includes(queryLC); + + const tokenAddress = isWrappedToken(token, chain) + ? getTokenBridgeWrappedTokenAddressSync(token, chain)?.toString() + : token.tokenId?.address; + + const tokenAddressMatch = tokenAddress?.toLowerCase().includes(queryLC); + + return Boolean(symbolMatch || displayNameMatch || tokenAddressMatch); }} renderFn={(token: TokenConfig) => { const balance = balances?.[token.key]?.balance; From f368c1ce6b611bf3d76da824d3778ceb9be28f4b Mon Sep 17 00:00:00 2001 From: Kevin Peters Date: Mon, 16 Sep 2024 09:03:00 -0500 Subject: [PATCH 2/2] return sooner --- .../src/views/v2/Bridge/AssetPicker/TokenList.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx b/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx index 6de2d5f7b..d1f6493de 100644 --- a/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx +++ b/wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx @@ -195,18 +195,21 @@ const TokenList = (props: Props) => { const queryLC = query.toLowerCase(); const symbolMatch = token.symbol?.toLowerCase().includes(queryLC); + if (symbolMatch) return true; const displayNameMatch = getDisplayName(token, chain) .toLowerCase() .includes(queryLC); + if (displayNameMatch) return true; const tokenAddress = isWrappedToken(token, chain) ? getTokenBridgeWrappedTokenAddressSync(token, chain)?.toString() : token.tokenId?.address; const tokenAddressMatch = tokenAddress?.toLowerCase().includes(queryLC); + if (tokenAddressMatch) return true; - return Boolean(symbolMatch || displayNameMatch || tokenAddressMatch); + return false; }} renderFn={(token: TokenConfig) => { const balance = balances?.[token.key]?.balance;