Skip to content

Commit

Permalink
search tokens by address
Browse files Browse the repository at this point in the history
  • Loading branch information
kev1n-peters committed Sep 16, 2024
1 parent 9672d52 commit 2827294
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2827294

Please sign in to comment.