Using formatIconUrlWithProxy to get the iconUrl proxy of swap token (#15562)

feature/default_network_editable
Niranjana Binoy 2 years ago committed by GitHub
parent aac5a45bec
commit 4512a9e151
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      package.json
  2. 22
      ui/hooks/useTokensToSearch.js
  3. 8
      yarn.lock

@ -123,7 +123,7 @@
"@keystonehq/metamask-airgapped-keyring": "0.2.1",
"@material-ui/core": "^4.11.0",
"@metamask/contract-metadata": "^1.31.0",
"@metamask/controllers": "^30.1.0",
"@metamask/controllers": "^30.3.0",
"@metamask/design-tokens": "^1.9.0",
"@metamask/eth-ledger-bridge-keyring": "^0.13.0",
"@metamask/eth-token-tracker": "^4.0.0",
@ -299,8 +299,8 @@
"browser-util-inspect": "^0.2.0",
"browserify": "^16.5.1",
"chalk": "^3.0.0",
"chokidar": "^3.5.3",
"chromedriver": "^103.0.0",
"chokidar": "^3.5.3",
"concurrently": "^5.2.0",
"copy-webpack-plugin": "^6.0.3",
"cross-spawn": "^7.0.3",

@ -2,6 +2,7 @@ import { useMemo } from 'react';
import { shallowEqual, useSelector } from 'react-redux';
import BigNumber from 'bignumber.js';
import { isEqual, uniqBy } from 'lodash';
import { formatIconUrlWithProxy } from '@metamask/controllers';
import { getTokenFiatAmount } from '../helpers/utils/token-util';
import {
getTokenExchangeRates,
@ -16,6 +17,16 @@ import { getSwapsTokens } from '../ducks/swaps/swaps';
import { isSwapsDefaultTokenSymbol } from '../../shared/modules/swaps.utils';
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
import { TOKEN_BUCKET_PRIORITY } from '../../shared/constants/swaps';
import {
ETH_SYMBOL,
MATIC_SYMBOL,
BNB_SYMBOL,
AVALANCHE_SYMBOL,
MAINNET_CHAIN_ID,
BSC_CHAIN_ID,
POLYGON_CHAIN_ID,
AVALANCHE_CHAIN_ID,
} from '../../shared/constants/network';
import { useEqualityCheck } from './useEqualityCheck';
export function getRenderableTokenData(
@ -55,8 +66,15 @@ export function getRenderableTokenData(
)
: '';
const usedIconUrl =
iconUrl || tokenList[address?.toLowerCase()]?.iconUrl || token?.image;
const tokenIconUrl =
(symbol === ETH_SYMBOL && chainId === MAINNET_CHAIN_ID) ||
(symbol === BNB_SYMBOL && chainId === BSC_CHAIN_ID) ||
(symbol === MATIC_SYMBOL && chainId === POLYGON_CHAIN_ID) ||
(symbol === AVALANCHE_SYMBOL && chainId === AVALANCHE_CHAIN_ID)
? iconUrl
: formatIconUrlWithProxy({ chainId, tokenAddress: address || '' });
const usedIconUrl = tokenIconUrl || token?.image;
return {
...token,
primaryLabel: symbol,

@ -2873,10 +2873,10 @@
resolved "https://registry.yarnpkg.com/@metamask/contract-metadata/-/contract-metadata-1.35.0.tgz#2bf2b8f2b6fdbd5132f0bcfa594b6c02dc71c42e"
integrity sha512-zfZKwLFOVrQS8vTFoeoNCG9JhqmK4oyembGiGVVpUAYD9BHVZnd9WpicGoUC07ROXLEyQuAK9AJZNBtqwwzfEQ==
"@metamask/controllers@^30.0.0", "@metamask/controllers@^30.1.0":
version "30.1.0"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-30.1.0.tgz#157d0afca156f1f37a89fbb864c4ee5c64d23af0"
integrity sha512-480mQafsYKbl0q7YgV820mrPCUtWgLLVH/s8ozNT6/ZVX3sBU0FBhNKeCalewhn0HRfMRnLe8pvHCKIH30k/0w==
"@metamask/controllers@^30.0.0", "@metamask/controllers@^30.3.0":
version "30.3.0"
resolved "https://registry.yarnpkg.com/@metamask/controllers/-/controllers-30.3.0.tgz#64ad8be538b75226a14f667db05c4ca02c75533f"
integrity sha512-6KtRIEBAcXeF/ozsP2I7T7hFv1X0mf30ygWcgApKdQEYXAERAaBz0S9ENC8OsFULUj5MFPBfUKIDaeGNOq6MvQ==
dependencies:
"@ethereumjs/common" "^2.3.1"
"@ethereumjs/tx" "^3.2.1"

Loading…
Cancel
Save