@@ -31,7 +31,7 @@ import { formatAmount } from 'utils/formatInfoNumbers'
31
31
32
32
import isUndefinedOrNull from '@pancakeswap/utils/isUndefinedOrNull'
33
33
import truncateHash from '@pancakeswap/utils/truncateHash'
34
- import { atom , useAtomValue } from 'jotai'
34
+ import { useAtomValue } from 'jotai'
35
35
import { atomFamily } from 'jotai/utils'
36
36
import isEqual from 'lodash/isEqual'
37
37
import { ChainLinkSupportChains , multiChainId , multiChainScan } from 'state/info/constant'
@@ -42,6 +42,7 @@ import { getTokenNameAlias, getTokenSymbolAlias } from 'utils/getTokenAlias'
42
42
import { CurrencyLogo } from 'views/Info/components/CurrencyLogo'
43
43
import useCMCLink from 'views/Info/hooks/useCMCLink'
44
44
import { chainNames } from '@pancakeswap/chains'
45
+ import { atomWithAsyncRetry } from 'utils/atomWithAsyncRetry'
45
46
import BarChart from '../components/BarChart/alt'
46
47
import { LocalLoader } from '../components/Loader'
47
48
import Percent from '../components/Percent'
@@ -92,10 +93,13 @@ interface TokenQueryResponse {
92
93
}
93
94
94
95
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
+ } ,
99
103
} )
100
104
} , isEqual )
101
105
0 commit comments