Skip to content

Commit 86ef63a

Browse files
committed
fix: Crash v3 info token page
1 parent bc24f50 commit 86ef63a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

Diff for: apps/web/src/views/V3Info/views/TokenPage.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import { formatAmount } from 'utils/formatInfoNumbers'
3131

3232
import isUndefinedOrNull from '@pancakeswap/utils/isUndefinedOrNull'
3333
import truncateHash from '@pancakeswap/utils/truncateHash'
34-
import { atom, useAtomValue } from 'jotai'
34+
import { useAtomValue } from 'jotai'
3535
import { atomFamily } from 'jotai/utils'
3636
import isEqual from 'lodash/isEqual'
3737
import { ChainLinkSupportChains, multiChainId, multiChainScan } from 'state/info/constant'
@@ -42,6 +42,7 @@ import { getTokenNameAlias, getTokenSymbolAlias } from 'utils/getTokenAlias'
4242
import { CurrencyLogo } from 'views/Info/components/CurrencyLogo'
4343
import useCMCLink from 'views/Info/hooks/useCMCLink'
4444
import { chainNames } from '@pancakeswap/chains'
45+
import { atomWithAsyncRetry } from 'utils/atomWithAsyncRetry'
4546
import BarChart from '../components/BarChart/alt'
4647
import { LocalLoader } from '../components/Loader'
4748
import Percent from '../components/Percent'
@@ -92,10 +93,13 @@ interface TokenQueryResponse {
9293
}
9394

9495
const tokenPageDataAtom = atomFamily((params: TokenPageParams) => {
95-
return atom(async () => {
96-
const resp = await fetch(`/api/token/v3/${params.chain || 'bsc'}/${params.address}`)
97-
const json = await resp.json()
98-
return json as TokenQueryResponse
96+
return atomWithAsyncRetry({
97+
asyncFn: async () => {
98+
const resp = await fetch(`/api/token/v3/${params.chain || 'bsc'}/${params.address}`)
99+
if (!resp.ok) throw new Error('Fetch error')
100+
const json = await resp.json()
101+
return json as TokenQueryResponse
102+
},
99103
})
100104
}, isEqual)
101105

0 commit comments

Comments
 (0)