Skip to content

Commit

Permalink
fix:icon
Browse files Browse the repository at this point in the history
  • Loading branch information
constwz committed Oct 25, 2023
1 parent 1b54a88 commit f7ba683
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "safe-wallet-web",
"homepage": "https://github.com/safe-global/safe-wallet-web",
"license": "GPL-3.0",
"type": "module",
"version": "1.19.1",
"scripts": {
"dev": "next dev",
Expand All @@ -18,7 +19,7 @@
"routes": "node scripts/generate-routes.js > src/config/routes.ts && prettier -w src/config/routes.ts && cat src/config/routes.ts",
"css-vars": "ts-node-esm ./scripts/css-vars.ts > ./src/styles/vars.css && prettier -w src/styles/vars.css",
"generate-types": "typechain --target ethers-v5 --out-dir src/types/contracts ./node_modules/@safe-global/safe-deployments/dist/assets/**/*.json ./node_modules/@safe-global/safe-modules-deployments/dist/assets/**/*.json ./node_modules/@openzeppelin/contracts/build/contracts/ERC20.json ./node_modules/@openzeppelin/contracts/build/contracts/ERC721.json",
"after-install": "yarn patch-package && yarn generate-types",
"after-install": "yarn patch-package && yarn generate-types && yarn css-vars",
"postinstall": "yarn after-install",
"analyze": "cross-env ANALYZE=true yarn build",
"cypress:open": "cross-env TZ=UTC cypress open --e2e",
Expand Down Expand Up @@ -132,10 +133,5 @@
"typescript": "4.9.4",
"typescript-plugin-css-modules": "^4.2.2",
"webpack": "^5.88.2"
},
"tsconfig": {
"compilerOptions": {
"esModuleInterop": true
}
}
}
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

0 comments on commit f7ba683

Please sign in to comment.