Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: display token logos from CoW Protocol correctly #3244

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -40,14 +40,29 @@ function getTokenLogoURI(address: string, chainId: SupportedChainId = SupportedC

const currencyLogoCache = new Map<string, Array<string>>()

const COW_PROTOCOL_REPO = 'cowprotocol/token-lists'
function getLogoURI(currency: Currency | null): string | null {
if (!currency) return null

const logoURI = (currency as Currency & { logoURI: string }).logoURI

if (!logoURI) return null

// Always lowercase logo URI if it's from CoW Protocol repo
// Because CoW Protocol repo has all logos in lowercase
if (logoURI.includes(COW_PROTOCOL_REPO)) return logoURI.toLowerCase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a permanent or temporal solution?


return logoURI
}

// TODO: must be refactored
export default function useCurrencyLogoURIs(currency?: Currency | null): string[] {
const currencyAddress = currency ? (currency.isNative ? NATIVE_CURRENCY_BUY_ADDRESS : currency.address) : null
// There is a modification of Token in useDetectNativeToken()
const externalLogo = useProxyTokenLogo(currency?.chainId, currencyAddress)
const cacheKey = `${currencyAddress}|${currency?.chainId}`
const cached = currencyLogoCache.get(cacheKey)
const logoURI = currency ? (currency as Currency & { logoURI: string }).logoURI : null
const logoURI = getLogoURI(currency || null)
const imageOverride = currency?.isToken ? ADDRESS_IMAGE_OVERRIDE[currency.address] : null

if (cached) {