From 2f2b6ca04481e9beecfac83d230c4c045412676d Mon Sep 17 00:00:00 2001 From: skylarbarrera Date: Thu, 8 Feb 2024 17:20:48 -0500 Subject: [PATCH] swaps: fix curated tokens --- src/hooks/useSwapCurrencyList.ts | 21 ++++++++++++++------- src/screens/CurrencySelectModal.tsx | 2 +- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/hooks/useSwapCurrencyList.ts b/src/hooks/useSwapCurrencyList.ts index de8f9c3873f..44bb4c9916e 100644 --- a/src/hooks/useSwapCurrencyList.ts +++ b/src/hooks/useSwapCurrencyList.ts @@ -118,14 +118,14 @@ const useSwapCurrencyList = (searchQuery: string, searchChainId = MAINNET_CHAINI return (tokens || []) .map(token => { token.address = token.networks?.[activeChainId]?.address || token.address; - if (activeChainId !== MAINNET_CHAINID) { - const network = crosschainNetwork || ethereumUtils.getNetworkFromChainId(searchChainId); - token.network = network; - if (token.networks[MAINNET_CHAINID]) { - token.mainnet_address = token.networks[MAINNET_CHAINID].address; - } - token.uniqueId = getUniqueId(token.address, network); + + const network = crosschainNetwork || ethereumUtils.getNetworkFromChainId(searchChainId); + token.network = network; + if (token.networks[MAINNET_CHAINID]) { + token.mainnet_address = token.networks[MAINNET_CHAINID].address; } + token.uniqueId = getUniqueId(token.address, network); + return token; }) .filter(({ address }) => !isFavorite(address)); @@ -152,6 +152,13 @@ const useSwapCurrencyList = (searchQuery: string, searchChainId = MAINNET_CHAINI return -1; } return bIsRanked ? 1 : name1?.localeCompare(name2); + }) + .map(token => { + return { + ...token, + network: Network.mainnet, + uniqueId: getUniqueId(token.address, Network.mainnet), + }; }); }, [curatedMap, favoriteAddresses]); diff --git a/src/screens/CurrencySelectModal.tsx b/src/screens/CurrencySelectModal.tsx index 5c8b79b7471..f89136b3510 100644 --- a/src/screens/CurrencySelectModal.tsx +++ b/src/screens/CurrencySelectModal.tsx @@ -359,7 +359,7 @@ export default function CurrencySelectModal() { newAsset = { ...newAsset, decimals: item?.networks?.[currentChainId]?.decimals || item.decimals, - address: item?.networks?.[currentChainId]?.address, + address: item?.address || item?.networks?.[currentChainId]?.address, network: getNetworkFromChainId(currentChainId), }; }