Commit f15e5725 authored by Jordan Frankfurt's avatar Jordan Frankfurt Committed by GitHub

fix: token list load issue WEB-2083 (#6019)

parent 83c8393f
......@@ -9,8 +9,12 @@ class TokenLogoLookupTable {
initialize() {
const dict: { [key: string]: string[] | undefined } = {}
DEFAULT_LIST_OF_LISTS.forEach((list) =>
store.getState().lists.byUrl[list].current?.tokens.forEach((token) => {
DEFAULT_LIST_OF_LISTS.forEach((list) => {
const listData = store.getState().lists.byUrl[list]
if (!listData) {
return
}
listData.current?.tokens.forEach((token) => {
if (token.logoURI) {
const lowercaseAddress = token.address.toLowerCase()
const currentEntry = dict[lowercaseAddress + ':' + token.chainId]
......@@ -21,7 +25,7 @@ class TokenLogoLookupTable {
}
}
})
)
})
this.dict = dict
this.initialized = true
}
......
......@@ -112,7 +112,7 @@ export function useSearchInactiveTokenLists(search: string | undefined, minResul
const result: WrappedTokenInfo[] = []
const addressSet: { [address: string]: true } = {}
for (const url of inactiveUrls) {
const list = lists[url].current
const list = lists[url]?.current
if (!list) continue
for (const tokenInfo of list.tokens) {
if (tokenInfo.chainId === chainId && tokenFilter(tokenInfo)) {
......
import { DEFAULT_LIST_OF_LISTS } from './../constants/lists'
const DEFAULT_LIST_PRIORITIES = DEFAULT_LIST_OF_LISTS.reduce<{ [listUrl: string]: number }>((memo, listUrl, index) => {
memo[listUrl] = index + 1
return memo
}, {})
const DEFAULT_LIST_PRIORITIES = DEFAULT_LIST_OF_LISTS.reduce(
(acc, listUrl, index) => ({
...acc,
[listUrl]: index + 1,
}),
{}
) as Record<string, number>
// use ordering of default list of lists to assign priority
export default function sortByListPriority(urlA: string, urlB: string) {
if (DEFAULT_LIST_PRIORITIES[urlA] && DEFAULT_LIST_PRIORITIES[urlB]) {
return DEFAULT_LIST_PRIORITIES[urlA] - DEFAULT_LIST_PRIORITIES[urlB]
}
return 0
const A = DEFAULT_LIST_PRIORITIES[urlA]
const B = DEFAULT_LIST_PRIORITIES[urlB]
if (!A) return 0
if (!B) return 0
return A - B
}
......@@ -4,6 +4,9 @@ import { CHAIN_NAME_TO_CHAIN_ID } from 'graphql/data/util'
export function getNativeTokenDBAddress(chain: Chain): string | undefined {
const pageChainId = CHAIN_NAME_TO_CHAIN_ID[chain]
if (pageChainId === undefined) {
return undefined
}
switch (chain) {
case Chain.Celo:
case Chain.Polygon:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment