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

fix:token icon #3

Merged
merged 2 commits into from
Oct 25, 2023
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
17 changes: 16 additions & 1 deletion src/components/common/TokenIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ import css from './styles.module.css'

const FALLBACK_ICON = '/images/common/token-placeholder.svg'

const CUSTOM_LOGO_MAP: Record<string, string> = {
BNB: `https://www.bnbchainlist.org/static/images/rsz_bnb.svg`,
TCBNB: `https://www.bnbchainlist.org/static/images/rsz_bnb.svg`,
BTC: `https://raw.githubusercontent.com/bnb-chain/opbnb-bridge-tokens/main/data/BTCB/logo.svg`,
BTCB: `https://raw.githubusercontent.com/bnb-chain/opbnb-bridge-tokens/main/data/BTCB/logo.svg`,
USDT: `https://raw.githubusercontent.com/bnb-chain/opbnb-bridge-tokens/main/data/USDT/logo.svg`,
FDUSD: `https://raw.githubusercontent.com/bnb-chain/opbnb-bridge-tokens/main/data/FDUSD/logo.jpeg`,
ETH: `https://raw.githubusercontent.com/bnb-chain/opbnb-bridge-tokens/main/data/ETH/logo.svg`,
}

const TokenIcon = ({
logoUri,
tokenSymbol,
Expand All @@ -15,9 +25,14 @@ const TokenIcon = ({
size?: number
fallbackSrc?: string
}): ReactElement => {
let logoURL = logoUri
if (tokenSymbol && CUSTOM_LOGO_MAP[tokenSymbol]) {
logoURL = CUSTOM_LOGO_MAP[tokenSymbol]
}

return (
<ImageFallback
src={logoUri}
src={logoURL}
alt={tokenSymbol}
fallbackSrc={fallbackSrc || FALLBACK_ICON}
height={size}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useChainId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const useChainId = (): string => {
const walletChainId =
wallet?.chainId && configs.some(({ chainId }) => chainId === wallet.chainId) ? wallet.chainId : undefined

return urlChainId || walletChainId || session.lastChainId || defaultChainId
return defaultChainId || urlChainId || walletChainId || session.lastChainId
}

export default useChainId
Loading