Skip to content

Commit

Permalink
draft: use token list from cdn
Browse files Browse the repository at this point in the history
  • Loading branch information
foxier25 committed Oct 31, 2024
1 parent 513f2df commit b7898b1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/components/SearchModal/CurrencySearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function CurrencySearch({
onlyShowCurrenciesWithBalance,
]
)

const isLoading = Boolean(balancesAreLoading && !tokenLoaderTimerElapsed)

const filteredSortedTokens = useSortTokensByQuery(debouncedQuery, sortedTokens)
Expand Down
3 changes: 2 additions & 1 deletion src/constants/lists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
1 change: 1 addition & 0 deletions src/hooks/Tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down
10 changes: 5 additions & 5 deletions src/hooks/useFetchListCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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]),
Expand Down
2 changes: 2 additions & 0 deletions src/state/lists/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
}

Expand Down

0 comments on commit b7898b1

Please sign in to comment.