diff --git a/src/__swaps__/screens/Swap/resources/search/search.ts b/src/__swaps__/screens/Swap/resources/search/search.ts index e41d96abed2..0d8db87465f 100644 --- a/src/__swaps__/screens/Swap/resources/search/search.ts +++ b/src/__swaps__/screens/Swap/resources/search/search.ts @@ -11,7 +11,6 @@ import { Contract } from '@ethersproject/contracts'; import { useQuery } from '@tanstack/react-query'; import qs from 'qs'; import { parseTokenSearch } from './utils'; -import { RainbowToken } from '@/entities'; import { getProvider } from '@/handlers/web3'; import { erc20ABI } from '@/references'; @@ -65,7 +64,7 @@ type TokenSearchAllNetworksQueryKey = ReturnType => { +const getImportedAsset = async (searchQuery: string, chainId: number = ChainId.mainnet): Promise => { if (isAddress(searchQuery)) { const provider = getProvider({ chainId }); const tokenContract = new Contract(searchQuery, erc20ABI, provider); @@ -83,10 +82,10 @@ const getImportedAsset = async (searchQuery: string, chainId: number = ChainId.m chainId, address, decimals, - favorite: false, highLiquidity: false, isRainbowCurated: false, isVerified: false, + mainnetAddress: address, name, networks: { [chainId]: { @@ -95,16 +94,15 @@ const getImportedAsset = async (searchQuery: string, chainId: number = ChainId.m }, }, symbol, - network: useBackendNetworksStore.getState().getChainsName()[chainId], uniqueId, - } as RainbowToken, + } as SearchAsset, ]; } catch (e) { - logger.warn('[useSearchCurrencyList]: error getting token data', { error: (e as Error).message }); - return null; + logger.warn('[getImportedAsset]: error getting imported token data', { error: (e as Error).message }); + return []; } } - return null; + return []; }; async function tokenSearchQueryFunction({ @@ -179,7 +177,8 @@ async function tokenSearchQueryFunctionAllNetworks({ queryKey: [{ query }] }: Qu return parseTokenSearch(tokenSearch.data.data); } - return []; + const result = await getImportedAsset(query); + return result; } else { const tokenSearch = await tokenSearchHttp.get<{ data: SearchAsset[] }>(url); return parseTokenSearch(tokenSearch.data.data);