Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search tokens by address #2587

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 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,37 @@ 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);
kev1n-peters marked this conversation as resolved.
Show resolved Hide resolved
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 false;
}}
renderFn={(token: TokenConfig) => {
const balance = balances?.[token.key]?.balance;
Expand Down
Loading