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