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

Widget UI 6 #3220

Closed
wants to merge 62 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
48af810
chore: fix cosmos CI (#3163)
shoom3301 Sep 28, 2023
93674f5
feat(permit): quote by order type (#3155)
alfetopito Sep 28, 2023
0b66ae7
refactor: removed unused code (#3157)
shoom3301 Sep 28, 2023
802f288
feat: update approve button color (#3169)
fairlighteth Sep 29, 2023
ce8671f
chore(release): hotfix 1.47.1 Merge pull request #3171 from cowprotoc…
anxolin Sep 29, 2023
cb26ea5
chore(main): release 1.47.1
shoom3301 Sep 29, 2023
9b384ef
Merge branch 'main' into develop
anxolin Sep 29, 2023
1e87615
Merge pull request #3172 from cowprotocol/release-please--branches--m…
anxolin Sep 29, 2023
d5b69cd
feat(tokens): new UI component for token select modal (#3166)
shoom3301 Sep 30, 2023
4b3fbc0
feat: remove walletConnect v1 and use v2 by default (#3156)
shoom3301 Oct 2, 2023
6c2c253
feat(tokens): new UI for tokens management (#3174)
shoom3301 Oct 2, 2023
488c926
refactor: remove unused hooks (#3175)
shoom3301 Oct 2, 2023
57637ef
refactor: remove unused code (#3181)
shoom3301 Oct 4, 2023
ed53662
feat(permit): modals SWAP (#3158)
alfetopito Oct 5, 2023
70e5653
feat(permit): modals LIMIT (#3164)
alfetopito Oct 5, 2023
e902e36
feat(permit): refactor permit caching (#3183)
alfetopito Oct 5, 2023
4481465
chore: simplify menu (#3206)
anxolin Oct 11, 2023
f4700d9
feat(permit): allowance warning (#3184)
alfetopito Oct 11, 2023
5de0df4
refactor(permit): refactor checkIsTokenPermittable (#3204)
alfetopito Oct 11, 2023
11d7e7c
Merge remote-tracking branch 'origin/release/1.48.0' into develop
alfetopito Oct 12, 2023
30565eb
feat: widget configurator app
fairlighteth Oct 12, 2023
29e5178
feat(permit): disable permit for SC wallets (#3213)
alfetopito Oct 12, 2023
a11703f
Merge remote-tracking branch 'origin/release/1.48.0' into develop
alfetopito Oct 12, 2023
64c8533
feat: widget configurator app
fairlighteth Oct 12, 2023
d0b064e
feat: widget configurator app
fairlighteth Oct 12, 2023
6c39e14
feat: widget configurator app
fairlighteth Oct 12, 2023
8638950
feat: widget configurator app
fairlighteth Oct 12, 2023
790abd0
feat: widget configurator app
fairlighteth Oct 13, 2023
b4f9f37
fix: remove legacy code (#3225)
anxolin Oct 16, 2023
99df6d2
fix(swap): handle errors from order posting API (#3224)
shoom3301 Oct 16, 2023
79cb48a
fix(permit): improve permittable detection (#3226)
alfetopito Oct 16, 2023
dede0d0
fix(eth-flow): update refund info for expired orders (#3222)
shoom3301 Oct 16, 2023
65c6f00
feat: widget configurator app
fairlighteth Oct 16, 2023
527108a
Merge branch 'develop' into widget-ui-6
fairlighteth Oct 16, 2023
a133ca5
feat: widget configurator app
fairlighteth Oct 16, 2023
9523c14
chore(release): 1.48.0 - Merge pull request #3203 from cowprotocol/re…
alfetopito Oct 16, 2023
0a4a592
chore(main): release 1.48.0 (#3229)
shoom3301 Oct 16, 2023
384701c
Merge remote-tracking branch 'origin/main' into develop
alfetopito Oct 16, 2023
4f4b7d5
fix(wc): add back patch which fixes WC path issue (#3230)
alfetopito Oct 16, 2023
aad09c6
fix(swap): don't crash app when token decimals eq 0 (#3228)
shoom3301 Oct 17, 2023
409e60e
chore(main): release 1.48.1 (#3233)
shoom3301 Oct 17, 2023
9c1f2f1
fix(swap): don't reset swap form on recipient ens input (#3234)
shoom3301 Oct 17, 2023
250da7a
Merge branch 'main' of https://github.com/cowprotocol/cowswap into de…
shoom3301 Oct 17, 2023
3ee3f3f
chore(main): release 1.48.2 (#3235)
shoom3301 Oct 17, 2023
9d54b0a
fix: display trade menu item badge (#3236)
shoom3301 Oct 18, 2023
1717cf9
chore(main): release 1.48.3 (#3238)
shoom3301 Oct 18, 2023
b61920a
Merge branch 'main' of https://github.com/cowprotocol/cowswap into de…
shoom3301 Oct 18, 2023
8de7cfc
fix(permit): add support for usdc mainnet (#3231)
alfetopito Oct 18, 2023
298e46e
chore(main): release 1.48.4 (#3239)
shoom3301 Oct 18, 2023
f5a92b5
Merge remote-tracking branch 'origin/main' into develop
alfetopito Oct 18, 2023
e69af4d
feat: deploy to IPFS (#3237)
anxolin Oct 18, 2023
5ed0800
Merge branch 'main' into develop
anxolin Oct 18, 2023
0abd19e
refactor: extract AccountElement and AccountModalState
shoom3301 Oct 18, 2023
caaf980
fix: display token logos from CoW Protocol correctly (#3244)
shoom3301 Oct 18, 2023
878afbb
chore(main): release 1.48.5 (#3246)
shoom3301 Oct 18, 2023
7810c75
Merge branch 'main' of https://github.com/cowprotocol/cowswap into de…
shoom3301 Oct 18, 2023
d958d0f
fix(permit): usdc limit orders warning (#3247)
alfetopito Oct 18, 2023
80cb391
chore(main): release 1.48.6 (#3249)
shoom3301 Oct 18, 2023
ce3e1b3
Merge remote-tracking branch 'origin/main' into develop
alfetopito Oct 18, 2023
c7e94e0
Merge branch 'develop' of https://github.com/cowprotocol/cowswap into…
shoom3301 Oct 19, 2023
3e78f09
chore: update yarn.lock
shoom3301 Oct 19, 2023
7f5b699
chore: fix code style
shoom3301 Oct 19, 2023
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
90 changes: 90 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,95 @@
# Changelog

## [1.48.6](https://github.com/cowprotocol/cowswap/compare/v1.48.5...v1.48.6) (2023-10-18)


### Bug Fixes

* **permit:** usdc limit orders warning ([#3247](https://github.com/cowprotocol/cowswap/issues/3247)) ([d958d0f](https://github.com/cowprotocol/cowswap/commit/d958d0fefb6f18418fb596b75b872e5b381d915d))

## [1.48.5](https://github.com/cowprotocol/cowswap/compare/v1.48.4...v1.48.5) (2023-10-18)


### Features

* deploy to IPFS ([#3237](https://github.com/cowprotocol/cowswap/issues/3237)) ([e69af4d](https://github.com/cowprotocol/cowswap/commit/e69af4d7140e384180c98b4c5175b341a2e9a542))


### Bug Fixes

* display token logos from CoW Protocol correctly ([#3244](https://github.com/cowprotocol/cowswap/issues/3244)) ([caaf980](https://github.com/cowprotocol/cowswap/commit/caaf9800da89e1df21cdffe2afc4eaa98260d0c3))

## [1.48.4](https://github.com/cowprotocol/cowswap/compare/v1.48.3...v1.48.4) (2023-10-18)


### Bug Fixes

* **permit:** add support for usdc mainnet ([#3231](https://github.com/cowprotocol/cowswap/issues/3231)) ([8de7cfc](https://github.com/cowprotocol/cowswap/commit/8de7cfc51e2324f75b968aee015a2488d4dd2ba9))

## [1.48.3](https://github.com/cowprotocol/cowswap/compare/v1.48.2...v1.48.3) (2023-10-18)


### Bug Fixes

* display trade menu item badge ([#3236](https://github.com/cowprotocol/cowswap/issues/3236)) ([9d54b0a](https://github.com/cowprotocol/cowswap/commit/9d54b0acc8fd1af409776d005a2858647db817c6))

## [1.48.2](https://github.com/cowprotocol/cowswap/compare/v1.48.1...v1.48.2) (2023-10-17)


### Bug Fixes

* **swap:** don't reset swap form on recipient ens input ([#3234](https://github.com/cowprotocol/cowswap/issues/3234)) ([9c1f2f1](https://github.com/cowprotocol/cowswap/commit/9c1f2f1b13597a4af5600c1c915bd59ecf14f578))

## [1.48.1](https://github.com/cowprotocol/cowswap/compare/v1.48.0...v1.48.1) (2023-10-17)


### Bug Fixes

* **swap:** don't crash app when token decimals eq 0 ([#3228](https://github.com/cowprotocol/cowswap/issues/3228)) ([aad09c6](https://github.com/cowprotocol/cowswap/commit/aad09c6b71c1c0a8dabb1f3ea85292bed332dbc7))
* **wc:** add back patch which fixes WC path issue ([#3230](https://github.com/cowprotocol/cowswap/issues/3230)) ([4f4b7d5](https://github.com/cowprotocol/cowswap/commit/4f4b7d56e1cf806d52f09875f95c0afa15a06985))

## [1.48.0](https://github.com/cowprotocol/cowswap/compare/v1.47.1...v1.48.0) (2023-10-16)


### Features

* **permit:** allowance warning ([#3184](https://github.com/cowprotocol/cowswap/issues/3184)) ([f4700d9](https://github.com/cowprotocol/cowswap/commit/f4700d9ac34bf281f6efb9bcbc60bebacb8ac68f))
* **permit:** disable permit for SC wallets ([#3213](https://github.com/cowprotocol/cowswap/issues/3213)) ([29e5178](https://github.com/cowprotocol/cowswap/commit/29e5178a4c15eb56568f5da0d0a30990a47bc76f))
* **permit:** modals LIMIT ([#3164](https://github.com/cowprotocol/cowswap/issues/3164)) ([70e5653](https://github.com/cowprotocol/cowswap/commit/70e56534eaa17456e42e2ba30541537e44d76c78))
* **permit:** modals SWAP ([#3158](https://github.com/cowprotocol/cowswap/issues/3158)) ([ed53662](https://github.com/cowprotocol/cowswap/commit/ed53662eedec3fb4ce3d880c9303df701f5059c1))
* **permit:** refactor permit caching ([#3183](https://github.com/cowprotocol/cowswap/issues/3183)) ([e902e36](https://github.com/cowprotocol/cowswap/commit/e902e36d6d6320dfa1649a448a834df49f115ce4))
* remove walletConnect v1 and use v2 by default ([#3156](https://github.com/cowprotocol/cowswap/issues/3156)) ([4b3fbc0](https://github.com/cowprotocol/cowswap/commit/4b3fbc0f6de2f89235cc69fdc6e7eaefb9bd12b6))
* **tokens:** new UI component for token select modal ([#3166](https://github.com/cowprotocol/cowswap/issues/3166)) ([d5b69cd](https://github.com/cowprotocol/cowswap/commit/d5b69cd4716d1a77e94a4ecba808186e96ef4794))
* **tokens:** new UI for tokens management ([#3174](https://github.com/cowprotocol/cowswap/issues/3174)) ([6c2c253](https://github.com/cowprotocol/cowswap/commit/6c2c2535a11707ad1cc30aa17bd003863d832faa))


### Bug Fixes

* **eth-flow:** update refund info for expired orders ([#3222](https://github.com/cowprotocol/cowswap/issues/3222)) ([dede0d0](https://github.com/cowprotocol/cowswap/commit/dede0d0431511ad1b1ed0548f6d42f881b0f95e0))
* **permit:** improve permittable detection ([#3226](https://github.com/cowprotocol/cowswap/issues/3226)) ([79cb48a](https://github.com/cowprotocol/cowswap/commit/79cb48aa9cd21689d64e13fe57044c4f345c4118))
* **swap:** handle errors from order posting API ([#3224](https://github.com/cowprotocol/cowswap/issues/3224)) ([99df6d2](https://github.com/cowprotocol/cowswap/commit/99df6d2ca9fd5040624977f385e03b2442587c15))

## [1.47.1](https://github.com/cowprotocol/cowswap/compare/v1.47.0...v1.47.1) (2023-09-29)


### Features

* allow to change rpc nodes ([#3160](https://github.com/cowprotocol/cowswap/issues/3160)) ([b9b4be2](https://github.com/cowprotocol/cowswap/commit/b9b4be24ece99ddef83f351d47cc86a9ac3ff5da))
* **orders-table:** approve order token from allowance warn tooltip ([#3144](https://github.com/cowprotocol/cowswap/issues/3144)) ([aa943bf](https://github.com/cowprotocol/cowswap/commit/aa943bf06ab2ba3bb3040bae96106b4463f1283a))
* update approve button color ([#3169](https://github.com/cowprotocol/cowswap/issues/3169)) ([802f288](https://github.com/cowprotocol/cowswap/commit/802f288379329d6a526933be988e6669020bb872))


### Bug Fixes

* don't fetch tokens list ens hashes ([#3152](https://github.com/cowprotocol/cowswap/issues/3152)) ([49989f9](https://github.com/cowprotocol/cowswap/commit/49989f987e729749c17c64984ca3338f774198f9))
* fix bad import ([8546bbc](https://github.com/cowprotocol/cowswap/commit/8546bbc6e792cd913511c87ecfa3ab7453648ce6))
* **twap:** approve infinite amount ([#3141](https://github.com/cowprotocol/cowswap/issues/3141)) ([c5ab768](https://github.com/cowprotocol/cowswap/commit/c5ab768f85a0a463accaf436114fdcab7b538d80))


### Miscellaneous Chores

* **release:** hotfix 1.47.1 Merge pull request [#3171](https://github.com/cowprotocol/cowswap/issues/3171) from cowprotocol/hotfix/1.47.1 ([ce8671f](https://github.com/cowprotocol/cowswap/commit/ce8671fe3705f79a0bb73729855dfd59bbd48b52))

## [1.47.0](https://github.com/cowprotocol/cowswap/compare/v1.47.0-RC.0...v1.47.0) (2023-09-11)


Expand Down
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/cosmos.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"fixtureFileSuffix": "cosmos",
"watchDirs": ["src"],
"port": 5001,
"exportPath": "./public/cosmos",
"exportPath": "../../build/cosmos",
"publicUrl": "./",
"plugins": ["react-cosmos-plugin-vite"],
"vite": {
Expand Down
24 changes: 12 additions & 12 deletions apps/cowswap-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
"author": "",
"license": "ISC",
"scripts": {
"ipfs:build": "nx exec -- cross-env PUBLIC_URL=\".\" yarn build",
"ipfs:publish": "nx exec -- ipfs-deploy build -p pinata -O",
"patch-package": "nx exec -- patch-package",
"i18n": "nx exec -- yarn i18n:compile",
"i18n:compile": "yarn i18n:extract && lingui compile",
"i18n:extract": "cross-env NODE_ENV=development lingui extract --locale en-US",
"i18n:pseudo": "lingui extract --locale pseudo && lingui compile",
"postinstall": "yarn i18n",
"cosmos:clear": "nx exec -- rm -rf ./public/cosmos",
"cosmos:run": "nx exec -- yarn _cosmos:run ",
"cosmos:export": "nx exec -- cross-env NODE_ENV=development cosmos-export",
"_cosmos:run": "yarn cosmos:clear && cosmos"
"ipfs:build": "cross-env PUBLIC_URL=\".\" yarn build",
"ipfs:publish": "npx ipfs-deploy build -p pinata -O",
"patch-package": "npx patch-package",
"i18n": "yarn run i18n:compile",
"i18n:compile": "yarn run i18n:extract && npx lingui compile",
"i18n:extract": "cross-env NODE_ENV=development npx lingui extract --locale en-US",
"i18n:pseudo": "npx lingui extract --locale pseudo && lingui compile",
"postinstall": "yarn run i18n",
"cosmos:clear": "rm -rf ./public/cosmos",
"cosmos:run": "yarn run _cosmos:run",
"cosmos:export": "cross-env NODE_ENV=development npx cosmos-export",
"_cosmos:run": "yarn cosmos:clear && npx cosmos"
},
"browser": {
"crypto": false
Expand Down
14 changes: 4 additions & 10 deletions apps/cowswap-frontend/src/api/gnosisProtocol/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
CowEnv,
EnrichedOrder,
NativePriceResponse,
OrderBookApiError,
OrderKind,
OrderQuoteRequest,
OrderQuoteResponse,
Expand All @@ -25,9 +24,11 @@ import { LegacyFeeQuoteParams as FeeQuoteParams } from 'legacy/state/price/types

import { getAppData } from 'modules/appData'

import { ApiErrorCodes, ApiErrorObject } from 'api/gnosisProtocol/errors/OperatorError'
import { ApiErrorCodes } from 'api/gnosisProtocol/errors/OperatorError'
import GpQuoteError, { GpQuoteErrorDetails, mapOperatorErrorToQuoteError } from 'api/gnosisProtocol/errors/QuoteError'

import { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

function getProfileUrl(): Partial<Record<ChainId, string>> {
if (isLocal || isDev || isPr || isBarn) {
return {
Expand Down Expand Up @@ -165,7 +166,7 @@ export async function getQuote(params: FeeQuoteParams): Promise<OrderQuoteRespon
}

return orderBookApi.getQuote(quoteParams, { chainId }).catch((error) => {
if (isOrderbookTypedError(error)) {
if (getIsOrderBookTypedError(error)) {
const errorObject = mapOperatorErrorToQuoteError(error.body)

return Promise.reject(errorObject ? new GpQuoteError(errorObject) : error)
Expand All @@ -175,13 +176,6 @@ export async function getQuote(params: FeeQuoteParams): Promise<OrderQuoteRespon
})
}

export type OrderbookTypedError = OrderBookApiError<ApiErrorObject>

function isOrderbookTypedError(e: any): e is OrderbookTypedError {
const error = e as OrderbookTypedError
return error.body.errorType !== undefined && error.body.description !== undefined
}

export async function getOrder(chainId: ChainId, orderId: string, env?: CowEnv): Promise<EnrichedOrder | null> {
const contextOverride = {
chainId,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { OrderBookApiError } from '@cowprotocol/cow-sdk'

import { ApiErrorObject } from './errors/OperatorError'

export type OrderBookTypedError = OrderBookApiError<ApiErrorObject>

export function getIsOrderBookTypedError(e: any): e is OrderBookTypedError {
const error = e as OrderBookTypedError
return error.body.errorType !== undefined && error.body.description !== undefined
}
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/api/gnosisProtocol/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as realApi from './api'
import * as mockApi from './mock'

export type { UnsupportedToken, OrderID } from './api'
export { getIsOrderBookTypedError } from './getIsOrderBookTypedError'

const useMock = process.env.REACT_APP_MOCK === 'true'

Expand Down
2 changes: 1 addition & 1 deletion apps/cowswap-frontend/src/assets/icon/wallet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions apps/cowswap-frontend/src/common/constants/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export enum UI {
ICON_SIZE_NORMAL = '--cow-icon-size-normal',
ICON_SIZE_SMALL = '--cow-icon-size-small',
ICON_SIZE_XSMALL = '--cow-icon-size-xsmall',
ICON_SIZE_LARGE = '--cow-icon-size-large',
ICON_COLOR_NORMAL = '--cow-icon-color-normal',

// States
Expand Down
15 changes: 15 additions & 0 deletions apps/cowswap-frontend/src/common/containers/PermitModal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { useMemo } from 'react'

import { Identicon, useWalletInfo } from '@cowprotocol/wallet'

import { PermitModal as Pure, PermitModalProps } from '../../pure/PermitModal'

export type PermitModalContainerProps = Omit<PermitModalProps, 'icon'>

export function PermitModal(props: PermitModalContainerProps) {
const { account } = useWalletInfo()

const icon = useMemo(() => (account ? <Identicon account={account} size={80} /> : undefined), [account])

return <Pure {...props} icon={icon} />
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { useIsSmartContractWallet } from '@cowprotocol/wallet'

import { useFeatureFlags } from './useFeatureFlags'

export function useIsPermitEnabled(chainId: SupportedChainId | undefined): boolean {
const isSmartContractWallet = useIsSmartContractWallet()
const { permitEnabledMainnet, permitEnabledGoerli, permitEnabledGnosis } = useFeatureFlags()

// Permit is only available for EOAs
if (isSmartContractWallet) {
return false
}

switch (chainId) {
case SupportedChainId.MAINNET:
return !!permitEnabledMainnet
Expand Down
25 changes: 0 additions & 25 deletions apps/cowswap-frontend/src/common/hooks/useOrdersPanel.ts

This file was deleted.

4 changes: 2 additions & 2 deletions apps/cowswap-frontend/src/common/hooks/useZeroApprove.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSetAtom } from 'jotai'
import { useCallback } from 'react'

import { useIsSafeWallet, walletConnectConnection } from '@cowprotocol/wallet'
import { useIsSafeWallet, walletConnectConnectionV2 } from '@cowprotocol/wallet'
import SafeApiKit from '@safe-global/api-kit'
import { SafeMultisigTransactionResponse } from '@safe-global/safe-core-sdk-types'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
Expand Down Expand Up @@ -44,7 +44,7 @@ export function useZeroApprove(currency: Currency) {
const amountToApprove = CurrencyAmount.fromRawAmount(currency, 0)
const approveCallback = useApproveCallback(amountToApprove, spender)
const safeApiKit = useSafeApiKit()
const isWalletConnect = useIsActiveWallet(walletConnectConnection)
const isWalletConnect = useIsActiveWallet(walletConnectConnectionV2)
const isSafeWallet = useIsSafeWallet()

return useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()

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) {
Expand Down
Loading
Loading