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

Show canonical tokens even when wallet is not connected #2712

Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions wormhole-connect/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,12 @@ export const isWrappedToken = (token: TokenConfig, chain: Chain) => {
return token.nativeChain !== chain;
};

// Canonical tokens may be Wormhole-wrapped tokens that are canonical on the chain
// e.g., Wormhole-wrapped Ethereum USDC is canonical on Sui
export const isCanonicalToken = (token: TokenConfig, chain: Chain) => {
return token.key === 'USDCeth' && chain === 'Sui';
kev1n-peters marked this conversation as resolved.
Show resolved Hide resolved
};

export const millisToHumanString = (ts: number): string => {
if (ts > 60000) {
const minutes = Math.ceil(ts / 60000);
Expand Down
17 changes: 15 additions & 2 deletions wormhole-connect/src/views/v2/Bridge/AssetPicker/TokenList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import type { ChainConfig, TokenConfig } from 'config/types';
import type { WalletData } from 'store/wallet';
import SearchableList from 'views/v2/Bridge/AssetPicker/SearchableList';
import TokenItem from 'views/v2/Bridge/AssetPicker/TokenItem';
import { getDisplayName, isFrankensteinToken, isWrappedToken } from 'utils';
import {
getDisplayName,
isCanonicalToken,
isFrankensteinToken,
isWrappedToken,
} from 'utils';
import { getTokenBridgeWrappedTokenAddressSync } from 'utils/sdkv2';

const useStyles = makeStyles()((theme) => ({
Expand Down Expand Up @@ -89,9 +94,11 @@ const TokenList = (props: Props) => {
}

// Exclude wormhole-wrapped tokens with no balance
// unless it's canonical
if (
props.isSource &&
isWrappedToken(tokenConfig, selectedChainConfig.key) &&
!isCanonicalToken(tokenConfig, selectedChainConfig.key) &&
!balance
) {
return;
Expand Down Expand Up @@ -209,7 +216,13 @@ const TokenList = (props: Props) => {
}

// Exclude wormhole-wrapped tokens with no balance
if (props.isSource && isWrappedToken(token, chain) && !balance) {
// unless it's canonical
if (
props.isSource &&
isWrappedToken(token, chain) &&
!isCanonicalToken(token, chain) &&
!balance
) {
return false;
}

Expand Down
Loading