Commit 167cc695 authored by eddie's avatar eddie Committed by GitHub

fix: stop showing the token logos from different chains as a fallback (#5761)

parent e175bff7
...@@ -13,11 +13,11 @@ class TokenLogoLookupTable { ...@@ -13,11 +13,11 @@ class TokenLogoLookupTable {
store.getState().lists.byUrl[list].current?.tokens.forEach((token) => { store.getState().lists.byUrl[list].current?.tokens.forEach((token) => {
if (token.logoURI) { if (token.logoURI) {
const lowercaseAddress = token.address.toLowerCase() const lowercaseAddress = token.address.toLowerCase()
const currentEntry = dict[lowercaseAddress] const currentEntry = dict[lowercaseAddress + ':' + token.chainId]
if (currentEntry) { if (currentEntry) {
currentEntry.push(token.logoURI) currentEntry.push(token.logoURI)
} else { } else {
dict[lowercaseAddress] = [token.logoURI] dict[lowercaseAddress + ':' + token.chainId] = [token.logoURI]
} }
} }
}) })
...@@ -25,13 +25,14 @@ class TokenLogoLookupTable { ...@@ -25,13 +25,14 @@ class TokenLogoLookupTable {
this.dict = dict this.dict = dict
this.initialized = true this.initialized = true
} }
getIcons(address?: string | null) { getIcons(address?: string | null, chainId: number | null = 1) {
if (!address) return undefined if (!address) return undefined
if (!this.initialized) { if (!this.initialized) {
this.initialize() this.initialize()
} }
return this.dict[address.toLowerCase()]
return this.dict[address.toLowerCase() + ':' + chainId]
} }
} }
......
...@@ -66,7 +66,7 @@ export default function useAssetLogoSource( ...@@ -66,7 +66,7 @@ export default function useAssetLogoSource(
} }
// Parses and stores logo sources from tokenlists if assets repo url fails // Parses and stores logo sources from tokenlists if assets repo url fails
if (!fallbackSrcs) { if (!fallbackSrcs) {
const uris = TokenLogoLookupTable.getIcons(address) ?? [] const uris = TokenLogoLookupTable.getIcons(address, chainId) ?? []
if (backupImg) uris.push(backupImg) if (backupImg) uris.push(backupImg)
const tokenListIcons = prioritizeLogoSources(parseLogoSources(uris)) const tokenListIcons = prioritizeLogoSources(parseLogoSources(uris))
...@@ -75,7 +75,7 @@ export default function useAssetLogoSource( ...@@ -75,7 +75,7 @@ export default function useAssetLogoSource(
} else { } else {
setCurrent(fallbackSrcs.find((src) => !BAD_SRCS[src])) setCurrent(fallbackSrcs.find((src) => !BAD_SRCS[src]))
} }
}, [current, fallbackSrcs, address, backupImg]) }, [current, fallbackSrcs, address, chainId, backupImg])
return [current, nextSrc] return [current, nextSrc]
} }
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