From b7898b163be2785ee71b824eb043c4c696e328af Mon Sep 17 00:00:00 2001 From: foxier25 Date: Wed, 30 Oct 2024 19:30:22 -0500 Subject: [PATCH] draft: use token list from cdn --- src/components/SearchModal/CurrencySearch.tsx | 1 + src/constants/lists.ts | 3 ++- src/hooks/Tokens.ts | 1 + src/hooks/useFetchListCallback.ts | 10 +++++----- src/state/lists/hooks.ts | 2 ++ 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/SearchModal/CurrencySearch.tsx b/src/components/SearchModal/CurrencySearch.tsx index aa3c665e6..6b22fd682 100644 --- a/src/components/SearchModal/CurrencySearch.tsx +++ b/src/components/SearchModal/CurrencySearch.tsx @@ -117,6 +117,7 @@ export function CurrencySearch({ onlyShowCurrenciesWithBalance, ] ) + const isLoading = Boolean(balancesAreLoading && !tokenLoaderTimerElapsed) const filteredSortedTokens = useSortTokensByQuery(debouncedQuery, sortedTokens) diff --git a/src/constants/lists.ts b/src/constants/lists.ts index c0cbf90fe..3df117809 100644 --- a/src/constants/lists.ts +++ b/src/constants/lists.ts @@ -15,7 +15,8 @@ const WRAPPED_LIST = 'wrapped.tokensoft.eth' export const OPTIMISM_LIST = 'https://static.optimism.io/optimism.tokenlist.json' export const ARBITRUM_LIST = 'https://bridge.arbitrum.io/token-list-42161.json' export const CELO_LIST = 'https://celo-org.github.io/celo-token-list/celo.tokenlist.json' -export const LUX_LIST = 'tokens-lux' +// export const LUX_LIST = 'tokens-lux' +export const LUX_LIST = 'https://cdn.lux.network/exchange/tokens-lux/tokens.json' export const UNSUPPORTED_LIST_URLS: string[] = [BA_LIST, UNI_UNSUPPORTED_LIST] diff --git a/src/hooks/Tokens.ts b/src/hooks/Tokens.ts index 36db93648..d7adb80cc 100644 --- a/src/hooks/Tokens.ts +++ b/src/hooks/Tokens.ts @@ -29,6 +29,7 @@ function useTokensFromMap(tokenMap: TokenAddressMap): { [address: string]: Token export function useAllTokens(): { [address: string]: Token } { const allTokens = useCombinedActiveList() + // console.log("alltokens = ", allTokens); const tokensFromMap = useTokensFromMap(allTokens) const userAddedTokens = useUserAddedTokens() return useMemo(() => { diff --git a/src/hooks/useFetchListCallback.ts b/src/hooks/useFetchListCallback.ts index 79423c9b4..b17667333 100644 --- a/src/hooks/useFetchListCallback.ts +++ b/src/hooks/useFetchListCallback.ts @@ -6,7 +6,7 @@ import getTokenList from 'lib/hooks/useTokenList/fetchTokenList' import resolveENSContentHash from 'lib/utils/resolveENSContentHash' import { useCallback } from 'react' import { useAppDispatch } from 'state/hooks' -import { TOKENS_LUX_LIST } from 'tokens-lux/tokens' +// import { TOKENS_LUX_LIST } from 'tokens-lux/tokens' import { fetchTokenList } from '../state/lists/actions' @@ -22,10 +22,10 @@ export function useFetchListCallback(): ( async (listUrl: string, sendDispatch = true, skipValidation?: boolean) => { const requestId = nanoid() sendDispatch && dispatch(fetchTokenList.pending({ requestId, url: listUrl })) - if(listUrl === "tokens-lux") { - dispatch(fetchTokenList.fulfilled({ url: listUrl, tokenList: TOKENS_LUX_LIST, requestId })); - return TOKENS_LUX_LIST; - } + // if(listUrl === "tokens-lux") { + // dispatch(fetchTokenList.fulfilled({ url: listUrl, tokenList: TOKENS_LUX_LIST, requestId })); + // return TOKENS_LUX_LIST; + // } return getTokenList( listUrl, (ensName: string) => resolveENSContentHash(ensName, RPC_PROVIDERS[SupportedChainId.MAINNET]), diff --git a/src/state/lists/hooks.ts b/src/state/lists/hooks.ts index 3e25f42de..9159686cf 100644 --- a/src/state/lists/hooks.ts +++ b/src/state/lists/hooks.ts @@ -45,6 +45,7 @@ function combineMaps(map1: TokenAddressMap, map2: TokenAddressMap): TokenAddress // merge tokens contained within lists from urls function useCombinedTokenMapFromUrls(urls: string[] | undefined): TokenAddressMap { const lists = useAllLists() + console.log("lists = ",lists); return useMemo(() => { if (!urls) return {} return ( @@ -69,6 +70,7 @@ function useCombinedTokenMapFromUrls(urls: string[] | undefined): TokenAddressMa // get all the tokens from active lists, combine with local default tokens export function useCombinedActiveList(): TokenAddressMap { const activeTokens = useCombinedTokenMapFromUrls(DEFAULT_ACTIVE_LIST_URLS) + // console.log("activeTokens = ", activeTokens); return activeTokens }