File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
packages/checkout/sdk/src/api/blockscout Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -107,12 +107,22 @@ export class Blockscout {
107107
108108 const response = await this . httpClient . get ( url ) ; // success if 2XX response otherwise throw error
109109
110+ // Normalize the data by ensuring address field is always present
111+ // Map address_hash to address if address is not present
112+ const normalizedItems = response . data ?. items ?. map ( ( item : BlockscoutToken ) => {
113+ const normalizedToken = { ...item . token } ;
114+ if ( ! normalizedToken . address && ( normalizedToken as any ) . address_hash ) {
115+ normalizedToken . address = ( normalizedToken as any ) . address_hash ;
116+ }
117+ return { ...item , token : normalizedToken } ;
118+ } ) || [ ] ;
119+
110120 // To get around an issue with native tokens being an ERC-20, there is the need
111121 // to remove IMX from `resp` and add it back in using getNativeTokenByWalletAddress.
112122 // This has affected some of the early wallets, and it might not be an issue in mainnet
113123 // however, let's enforce it.
114124 const data = {
115- items : response . data ?. items ? .filter (
125+ items : normalizedItems . filter (
116126 ( token : BlockscoutToken ) => token . token . address && token . token . address !== this . nativeToken . address ,
117127 ) ,
118128 // eslint-disable-next-line @typescript-eslint/naming-convention
You can’t perform that action at this time.
0 commit comments