File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
packages/checkout/sdk/src/client Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,10 @@ describe('Blockscout', () => {
110110 const token = BlockscoutTokenType . ERC20 ;
111111 const client = new Blockscout ( { chainId : ChainId . IMTBL_ZKEVM_TESTNET } ) ;
112112
113- await client . getTokensByWalletAddress ( { walletAddress : '0x1234567890' , tokenType : token } ) ;
114- await client . getTokensByWalletAddress ( { walletAddress : '0x1234567890' , tokenType : token } ) ;
113+ const precache = await client . getTokensByWalletAddress ( { walletAddress : '0x1234567890' , tokenType : token } ) ;
114+ const cached = await client . getTokensByWalletAddress ( { walletAddress : '0x1234567890' , tokenType : token } ) ;
115+
116+ expect ( cached ) . toEqual ( precache ) ;
115117
116118 expect ( mockedAxios . get ) . toHaveBeenNthCalledWith (
117119 1 ,
@@ -278,8 +280,10 @@ describe('Blockscout', () => {
278280
279281 const client = new Blockscout ( { chainId : ChainId . IMTBL_ZKEVM_TESTNET } ) ;
280282
281- await client . getNativeTokenByWalletAddress ( { walletAddress : '0x1234567890' } ) ;
282- await client . getNativeTokenByWalletAddress ( { walletAddress : '0x1234567890' } ) ;
283+ const precache = await client . getNativeTokenByWalletAddress ( { walletAddress : '0x1234567890' } ) ;
284+ const cached = await client . getNativeTokenByWalletAddress ( { walletAddress : '0x1234567890' } ) ;
285+
286+ expect ( cached ) . toEqual ( precache ) ;
283287
284288 expect ( mockedAxios . get ) . toHaveBeenNthCalledWith (
285289 1 ,
Original file line number Diff line number Diff line change @@ -100,8 +100,8 @@ export class Blockscout {
100100 if ( params . nextPage ) url += `&${ new URLSearchParams ( params . nextPage as Record < string , string > ) } ` ;
101101
102102 // Cache response data to prevent unnecessary requests
103- const cached = this . getCache ( url ) as AxiosResponse ;
104- if ( cached && cached . status < 400 ) return Promise . resolve ( cached . data ) ;
103+ const cached = this . getCache ( url ) ;
104+ if ( cached ) return Promise . resolve ( cached ) ;
105105
106106 const response = await Blockscout . makeHttpRequest ( url ) ;
107107 if ( response . status >= 400 ) {
@@ -146,8 +146,8 @@ export class Blockscout {
146146 const url = `${ this . url } /api/v2/addresses/${ params . walletAddress } ` ;
147147
148148 // Cache response data to prevent unnecessary requests
149- const cached = this . getCache ( url ) as AxiosResponse ;
150- if ( cached && cached . status < 400 ) return Promise . resolve ( cached . data ) ;
149+ const cached = this . getCache ( url ) ;
150+ if ( cached ) return Promise . resolve ( cached ) ;
151151
152152 const response = await Blockscout . makeHttpRequest ( url ) ;
153153 if ( response . status >= 400 ) {
You can’t perform that action at this time.
0 commit comments