diff --git a/shared/constants/network.ts b/shared/constants/network.ts index 8e7ad1a2354a..18a0ab087d69 100644 --- a/shared/constants/network.ts +++ b/shared/constants/network.ts @@ -144,6 +144,61 @@ export const CHAIN_IDS = { CRONOS: '0x19', GNOSIS: '0x64', ZKSYNC_ERA: '0x144', + TEST_ETH: '0x539', +} as const; + +const CHAINLIST_CHAIN_IDS_MAP = { + ...CHAIN_IDS, + SCROLL: '0x82750', + ZORA_MAINNET: '0x76adf1', + TAIKO_JOLNIR_L2_MAINNET: '0x28c5f', + POLYGON_ZKEVM: '0x44d', + FANTOM_OPERA: '0xfa', + CELO_MAINNET: '0xa4ec', + ARBITRUM_NOVA: '0xa4ba', + MANTLE: '0x1388', + CORE_BLOCKCHAIN_MAINNET: '0x45c', + MANTA_PACIFIC_MAINNET: '0xa9', + PULSECHAIN_MAINNET: '0x171', + FUSE_GOLD_MAINNET: '0x7a', + KAVA_EVM: '0x8ae', + DFK_CHAIN: '0xd2af', + HARMONY_MAINNET_SHARD_0: '0x63564c40', + PGN_PUBLIC_GOODS_NETWORK: '0x1a8', + LIGHTLINK_PHOENIX_MAINNET: '0x762', + NEAR_AURORA_MAINNET: '0x4e454152', + KROMA_MAINNET: '0xff', + NEBULA_MAINNET: '0x585eb4b1', + KLAYTN_MAINNET_CYPRESS: '0x2019', + ENDURANCE_SMART_CHAIN_MAINNET: '0x288', + CRONOS_MAINNET_BETA: '0x19', + FLARE_MAINNET: '0xe', + KCC_MAINNET: '0x141', + SHARDEUM_SPHINX_1X: '0x1f92', + ETHEREUM_CLASSIC_MAINNET: '0x3d', + HAQQ_NETWORK: '0x2be3', + SHARDEUM_LIBERTY_2X: '0x1f91', + BLACKFORT_EXCHANGE_NETWORK: '0x1387', + CONFLUX_ESPACE: '0x406', + FUSE_MAINNET: '0x7a', + CANTO: '0x1e14', + SHIB_MAINNET: '0x1b', + OKXCHAIN_MAINNET: '0x42', + ZKATANA: '0x133e40', + DEXALOT_SUBNET: '0x6984c', + ASTAR: '0x250', + EVMOS: '0x2329', + BAHAMUT_MAINNET: '0x142d', + SONGBIRD_CANARY_NETWORK: '0x13', + STEP_NETWORK: '0x4d2', + VELAS_EVM_MAINNET: '0x6a', + Q_MAINNET: '0x8a71', + TELOS_EVM_MAINNET: '0x28', + TENET: '0x617', + DOGECHAIN_MAINNET: '0x7d0', + OASYS_MAINNET: '0xf8', + HUOBI_ECO_CHAIN_MAINNET: '0x80', + ACALA_NETWORK: '0x313', } as const; /** @@ -218,13 +273,72 @@ export const CURRENCY_SYMBOLS = { USDC: 'USDC', USDT: 'USDT', WETH: 'WETH', - OPTIMISM: 'OP', + OPTIMISM: 'ETH', CRONOS: 'CRO', GLIMMER: 'GLMR', MOONRIVER: 'MOVR', ONE: 'ONE', } as const; +const CHAINLIST_CURRENCY_SYMBOLS_MAP = { + ...CURRENCY_SYMBOLS, + BASE: 'ETH', + LINEA_MAINNET: 'ETH', + OPBNB: 'BNB', + ZKSYNC_ERA: 'ETH', + SCROLL: 'ETH', + ZORA_MAINNET: 'ETH', + TAIKO_JOLNIR_L2_MAINNET: 'ETH', + POLYGON_ZKEVM: 'ETH', + FANTOM_OPERA: 'FTM', + CELO_MAINNET: 'CELO', + ARBITRUM_NOVA: 'ETH', + MANTLE: 'MNT', + CORE_BLOCKCHAIN_MAINNET: 'CORE', + MANTA_PACIFIC_MAINNET: 'ETH', + PULSECHAIN_MAINNET: 'PLS', + MOONBEAM: 'GLMR', + FUSE_GOLD_MAINNET: 'FUSE', + KAVA_EVM: 'KAVA', + DFK_CHAIN: 'JEWEL', + HARMONY_MAINNET_SHARD_0: 'ONE', + PGN_PUBLIC_GOODS_NETWORK: 'ETH', + LIGHTLINK_PHOENIX_MAINNET: 'ETH', + NEAR_AURORA_MAINNET: 'ETH', + KROMA_MAINNET: 'ETH', + NEBULA_MAINNET: 'sFUEL', + KLAYTN_MAINNET_CYPRESS: 'KLAY', + ENDURANCE_SMART_CHAIN_MAINNET: 'ACE', + CRONOS_MAINNET_BETA: 'CRO', + FLARE_MAINNET: 'FLR', + KCC_MAINNET: 'KCS', + SHARDEUM_SPHINX_1X: 'SHM', + ETHEREUM_CLASSIC_MAINNET: 'ETC', + HAQQ_NETWORK: 'ISLM', + SHARDEUM_LIBERTY_2X: 'SHM', + BLACKFORT_EXCHANGE_NETWORK: 'BXN', + CONFLUX_ESPACE: 'CFX', + FUSE_MAINNET: 'FUSE', + CANTO: 'CANTO', + SHIB_MAINNET: 'SHIB', + OKXCHAIN_MAINNET: 'OKT', + ZKATANA: 'ETH', + DEXALOT_SUBNET: 'ALOT', + ASTAR: 'ASTR', + EVMOS: 'EVMOS', + BAHAMUT_MAINNET: 'FTN', + SONGBIRD_CANARY_NETWORK: 'SGB', + STEP_NETWORK: 'FITFI', + VELAS_EVM_MAINNET: 'VLX', + Q_MAINNET: 'Q', + TELOS_EVM_MAINNET: 'TLOS', + TENET: 'TENET', + DOGECHAIN_MAINNET: 'DOGE', + OASYS_MAINNET: 'OAS', + HUOBI_ECO_CHAIN_MAINNET: 'HT', + ACALA_NETWORK: 'ACA', +} as const; + export const ETH_TOKEN_IMAGE_URL = './images/eth_logo.png'; export const LINEA_GOERLI_TOKEN_IMAGE_URL = './images/linea-logo-testnet.png'; export const LINEA_MAINNET_TOKEN_IMAGE_URL = './images/linea-logo-mainnet.png'; @@ -343,6 +457,120 @@ export const NETWORK_TO_NAME_MAP = { [CHAIN_IDS.LOCALHOST]: LOCALHOST_DISPLAY_NAME, } as const; +export const CHAIN_ID_TO_CURRENCY_SYMBOL_MAP = { + [CHAINLIST_CHAIN_IDS_MAP.AVALANCHE]: CHAINLIST_CURRENCY_SYMBOLS_MAP.AVALANCHE, + [CHAINLIST_CHAIN_IDS_MAP.BSC]: CHAINLIST_CURRENCY_SYMBOLS_MAP.BNB, + [CHAINLIST_CHAIN_IDS_MAP.BASE]: CHAINLIST_CURRENCY_SYMBOLS_MAP.BASE, + [CHAINLIST_CHAIN_IDS_MAP.ARBITRUM]: CHAINLIST_CURRENCY_SYMBOLS_MAP.ARBITRUM, + [CHAINLIST_CHAIN_IDS_MAP.LINEA_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.LINEA_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.MAINNET]: CHAINLIST_CURRENCY_SYMBOLS_MAP.ETH, + [CHAINLIST_CHAIN_IDS_MAP.OPBNB]: CHAINLIST_CURRENCY_SYMBOLS_MAP.OPBNB, + [CHAINLIST_CHAIN_IDS_MAP.OPTIMISM]: CHAINLIST_CURRENCY_SYMBOLS_MAP.OPTIMISM, + [CHAINLIST_CHAIN_IDS_MAP.POLYGON]: CHAINLIST_CURRENCY_SYMBOLS_MAP.MATIC, + [CHAINLIST_CHAIN_IDS_MAP.ZKSYNC_ERA]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.ZKSYNC_ERA, + [CHAINLIST_CHAIN_IDS_MAP.GOERLI]: + TEST_NETWORK_TICKER_MAP[NETWORK_TYPES.GOERLI], + [CHAINLIST_CHAIN_IDS_MAP.SEPOLIA]: + TEST_NETWORK_TICKER_MAP[NETWORK_TYPES.SEPOLIA], + [CHAINLIST_CHAIN_IDS_MAP.LINEA_GOERLI]: + TEST_NETWORK_TICKER_MAP[NETWORK_TYPES.LINEA_GOERLI], + [CHAINLIST_CHAIN_IDS_MAP.SCROLL]: CHAINLIST_CURRENCY_SYMBOLS_MAP.SCROLL, + [CHAINLIST_CHAIN_IDS_MAP.ZORA_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.ZORA_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.TAIKO_JOLNIR_L2_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.TAIKO_JOLNIR_L2_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.POLYGON_ZKEVM]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.POLYGON_ZKEVM, + [CHAINLIST_CHAIN_IDS_MAP.FANTOM_OPERA]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.FANTOM_OPERA, + [CHAINLIST_CHAIN_IDS_MAP.CELO_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.CELO_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.ARBITRUM_NOVA]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.ARBITRUM_NOVA, + [CHAINLIST_CHAIN_IDS_MAP.MANTLE]: CHAINLIST_CURRENCY_SYMBOLS_MAP.MANTLE, + [CHAINLIST_CHAIN_IDS_MAP.GNOSIS]: CHAINLIST_CURRENCY_SYMBOLS_MAP.GNOSIS, + [CHAINLIST_CHAIN_IDS_MAP.CORE_BLOCKCHAIN_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.CORE_BLOCKCHAIN_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.MANTA_PACIFIC_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.MANTA_PACIFIC_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.PULSECHAIN_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.PULSECHAIN_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.MOONBEAM]: CHAINLIST_CURRENCY_SYMBOLS_MAP.MOONBEAM, + [CHAINLIST_CHAIN_IDS_MAP.FUSE_GOLD_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.FUSE_GOLD_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.KAVA_EVM]: CHAINLIST_CURRENCY_SYMBOLS_MAP.KAVA_EVM, + [CHAINLIST_CHAIN_IDS_MAP.DFK_CHAIN]: CHAINLIST_CURRENCY_SYMBOLS_MAP.DFK_CHAIN, + [CHAINLIST_CHAIN_IDS_MAP.HARMONY_MAINNET_SHARD_0]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.HARMONY_MAINNET_SHARD_0, + [CHAINLIST_CHAIN_IDS_MAP.PGN_PUBLIC_GOODS_NETWORK]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.PGN_PUBLIC_GOODS_NETWORK, + [CHAINLIST_CHAIN_IDS_MAP.LIGHTLINK_PHOENIX_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.LIGHTLINK_PHOENIX_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.NEAR_AURORA_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.NEAR_AURORA_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.KROMA_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.KROMA_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.NEBULA_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.NEBULA_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.KLAYTN_MAINNET_CYPRESS]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.KLAYTN_MAINNET_CYPRESS, + [CHAINLIST_CHAIN_IDS_MAP.MOONRIVER]: CHAINLIST_CURRENCY_SYMBOLS_MAP.MOONRIVER, + [CHAINLIST_CHAIN_IDS_MAP.ENDURANCE_SMART_CHAIN_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.ENDURANCE_SMART_CHAIN_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.CRONOS_MAINNET_BETA]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.CRONOS_MAINNET_BETA, + [CHAINLIST_CHAIN_IDS_MAP.FLARE_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.FLARE_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.KCC_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.KCC_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.SHARDEUM_SPHINX_1X]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.SHARDEUM_SPHINX_1X, + [CHAINLIST_CHAIN_IDS_MAP.ETHEREUM_CLASSIC_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.ETHEREUM_CLASSIC_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.HAQQ_NETWORK]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.HAQQ_NETWORK, + [CHAINLIST_CHAIN_IDS_MAP.SHARDEUM_LIBERTY_2X]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.SHARDEUM_LIBERTY_2X, + [CHAINLIST_CHAIN_IDS_MAP.BLACKFORT_EXCHANGE_NETWORK]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.BLACKFORT_EXCHANGE_NETWORK, + [CHAINLIST_CHAIN_IDS_MAP.CONFLUX_ESPACE]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.CONFLUX_ESPACE, + [CHAINLIST_CHAIN_IDS_MAP.FUSE_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.FUSE_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.CANTO]: CHAINLIST_CURRENCY_SYMBOLS_MAP.CANTO, + [CHAINLIST_CHAIN_IDS_MAP.SHIB_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.SHIB_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.OKXCHAIN_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.OKXCHAIN_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.ZKATANA]: CHAINLIST_CURRENCY_SYMBOLS_MAP.ZKATANA, + [CHAINLIST_CHAIN_IDS_MAP.DEXALOT_SUBNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.DEXALOT_SUBNET, + [CHAINLIST_CHAIN_IDS_MAP.ASTAR]: CHAINLIST_CURRENCY_SYMBOLS_MAP.ASTAR, + [CHAINLIST_CHAIN_IDS_MAP.EVMOS]: CHAINLIST_CURRENCY_SYMBOLS_MAP.EVMOS, + [CHAINLIST_CHAIN_IDS_MAP.BAHAMUT_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.BAHAMUT_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.SONGBIRD_CANARY_NETWORK]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.SONGBIRD_CANARY_NETWORK, + [CHAINLIST_CHAIN_IDS_MAP.STEP_NETWORK]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.STEP_NETWORK, + [CHAINLIST_CHAIN_IDS_MAP.VELAS_EVM_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.VELAS_EVM_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.Q_MAINNET]: CHAINLIST_CURRENCY_SYMBOLS_MAP.Q_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.TELOS_EVM_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.TELOS_EVM_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.TENET]: CHAINLIST_CURRENCY_SYMBOLS_MAP.TENET, + [CHAINLIST_CHAIN_IDS_MAP.DOGECHAIN_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.DOGECHAIN_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.OASYS_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.OASYS_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.HUOBI_ECO_CHAIN_MAINNET]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.HUOBI_ECO_CHAIN_MAINNET, + [CHAINLIST_CHAIN_IDS_MAP.ACALA_NETWORK]: + CHAINLIST_CURRENCY_SYMBOLS_MAP.ACALA_NETWORK, +} as const; + export const CHAIN_ID_TO_TYPE_MAP = { [CHAIN_IDS.MAINNET]: NETWORK_TYPES.MAINNET, [CHAIN_IDS.GOERLI]: NETWORK_TYPES.GOERLI, @@ -385,15 +613,15 @@ export const CHAIN_ID_TO_ETHERS_NETWORK_NAME_MAP = { [CHAIN_IDS.LINEA_MAINNET]: NETWORK_TYPES.LINEA_MAINNET, } as const; -export const NATIVE_CURRENCY_TOKEN_IMAGE_MAP = { - [CURRENCY_SYMBOLS.ETH]: ETH_TOKEN_IMAGE_URL, - [CURRENCY_SYMBOLS.TEST_ETH]: TEST_ETH_TOKEN_IMAGE_URL, - [CURRENCY_SYMBOLS.BNB]: BNB_TOKEN_IMAGE_URL, - [CURRENCY_SYMBOLS.MATIC]: MATIC_TOKEN_IMAGE_URL, - [CURRENCY_SYMBOLS.AVALANCHE]: AVAX_TOKEN_IMAGE_URL, - [CURRENCY_SYMBOLS.OPTIMISM]: OPTIMISM_TOKEN_IMAGE_URL, - [CURRENCY_SYMBOLS.CELO]: CELO_TOKEN_IMAGE_URL, - [CURRENCY_SYMBOLS.GNOSIS]: GNOSIS_TOKEN_IMAGE_URL, +export const CHAIN_ID_TOKEN_IMAGE_MAP = { + [CHAIN_IDS.MAINNET]: ETH_TOKEN_IMAGE_URL, + [CHAIN_IDS.TEST_ETH]: TEST_ETH_TOKEN_IMAGE_URL, + [CHAIN_IDS.BSC]: BNB_TOKEN_IMAGE_URL, + [CHAIN_IDS.POLYGON]: MATIC_TOKEN_IMAGE_URL, + [CHAIN_IDS.AVALANCHE]: AVAX_TOKEN_IMAGE_URL, + [CHAIN_IDS.OPTIMISM]: OPTIMISM_TOKEN_IMAGE_URL, + [CHAIN_IDS.CELO]: CELO_TOKEN_IMAGE_URL, + [CHAIN_IDS.GNOSIS]: GNOSIS_TOKEN_IMAGE_URL, } as const; export const INFURA_BLOCKED_KEY = 'countryBlocked'; diff --git a/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap b/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap index 55f9a20757e8..ec4e56c9772d 100644 --- a/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap +++ b/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap @@ -105,11 +105,7 @@ exports[`AccountListItem renders AccountListItem component and shows account nam
- ETH logo + E
- ETH logo + E
- ETH logo + E
- ETH logo + E
- ETH logo + E
- ETH logo + E
{ // Expect the hook to return true when the native symbol matches the ticker expect(result.result.current).toBe(true); - expect(spyFetch).toHaveBeenCalled(); + expect(spyFetch).not.toHaveBeenCalled(); }); it('should return the correct value when the native symbol does not match the ticker', async () => { @@ -75,7 +75,7 @@ describe('useNativeTokenFiatAmount', () => { await act(async () => { result = renderHook(() => - useIsOriginalNativeTokenSymbol('0x1', 'ETH', 'mainnet'), + useIsOriginalNativeTokenSymbol('0x13a', 'FIL', 'mainnet'), ); }); @@ -97,7 +97,7 @@ describe('useNativeTokenFiatAmount', () => { await act(async () => { result = renderHook(() => - useIsOriginalNativeTokenSymbol('0x1', 'ETH', 'mainnet'), + useIsOriginalNativeTokenSymbol('0x13a', 'FIL', 'mainnet'), ); }); @@ -106,7 +106,7 @@ describe('useNativeTokenFiatAmount', () => { expect(spyFetch).toHaveBeenCalled(); }); - it('should return the correct symbol from build Network', async () => { + it('should return the correct value when the chainId is in the CHAIN_ID_TO_CURRENCY_SYMBOL_MAP', async () => { useSelector.mockImplementation(generateUseSelectorRouter(true)); // Mock the safeChainsList response with a different native symbol @@ -128,14 +128,46 @@ describe('useNativeTokenFiatAmount', () => { await act(async () => { result = renderHook(() => - useIsOriginalNativeTokenSymbol('0x1', 'GoerliETH', 'goerli'), + useIsOriginalNativeTokenSymbol('0x5', 'GoerliETH', 'goerli'), ); }); - + // expect this to pass because the chainId is in the CHAIN_ID_TO_CURRENCY_SYMBOL_MAP expect(result.result.current).toBe(true); + // expect that the chainlist API was not called expect(spyFetch).not.toHaveBeenCalled(); }); + it('should return the correct value when the chainId is not in the CHAIN_ID_TO_CURRENCY_SYMBOL_MAP', async () => { + useSelector.mockImplementation(generateUseSelectorRouter(true)); + // Mock the safeChainsList response + const safeChainsList = [ + { + chainId: 314, + nativeCurrency: { + symbol: 'FIL', + }, + }, + ]; + + // Mock the fetchWithCache function to return the safeChainsList + const spyFetch = jest + .spyOn(fetchWithCacheModule, 'default') + .mockResolvedValue(safeChainsList); + + let result; + + await act(async () => { + result = renderHook(() => + useIsOriginalNativeTokenSymbol('0x13a', 'FIL', 'mainnet'), + ); + }); + + // Expect the hook to return true when the native symbol matches the ticker + expect(result.result.current).toBe(true); + // Expect the chainslist API to have been called + expect(spyFetch).toHaveBeenCalled(); + }); + it('should return true if chain safe validation is disabled', async () => { useSelector.mockImplementation(generateUseSelectorRouter(false)); // Mock the safeChainsList response with a different native symbol diff --git a/ui/selectors/selectors.js b/ui/selectors/selectors.js index ef14673829f5..09cb7628c3f0 100644 --- a/ui/selectors/selectors.js +++ b/ui/selectors/selectors.js @@ -13,7 +13,6 @@ import { TransactionStatus } from '@metamask/transaction-controller'; import { addHexPrefix } from '../../app/scripts/lib/util'; import { TEST_CHAINS, - NATIVE_CURRENCY_TOKEN_IMAGE_MAP, BUYABLE_CHAINS_MAP, MAINNET_DISPLAY_NAME, BSC_DISPLAY_NAME, @@ -33,6 +32,7 @@ import { LINEA_MAINNET_DISPLAY_NAME, LINEA_MAINNET_TOKEN_IMAGE_URL, CHAIN_ID_TO_NETWORK_IMAGE_URL_MAP, + CHAIN_ID_TOKEN_IMAGE_MAP, } from '../../shared/constants/network'; import { WebHIDConnectedStatuses, @@ -66,7 +66,6 @@ import { STATIC_MAINNET_TOKEN_LIST } from '../../shared/constants/tokens'; import { DAY } from '../../shared/constants/time'; import { TERMS_OF_USE_LAST_UPDATED } from '../../shared/constants/terms'; import { - getNativeCurrency, getProviderConfig, getConversionRate, isNotEIP1559Network, @@ -945,8 +944,8 @@ export function getIsBuyableChain(state) { return Object.keys(BUYABLE_CHAINS_MAP).includes(chainId); } export function getNativeCurrencyImage(state) { - const nativeCurrency = getNativeCurrency(state)?.toUpperCase(); - return NATIVE_CURRENCY_TOKEN_IMAGE_MAP[nativeCurrency]; + const chainId = getCurrentChainId(state); + return CHAIN_ID_TOKEN_IMAGE_MAP[chainId]; } export function getNextSuggestedNonce(state) {