File tree Expand file tree Collapse file tree
packages/checkout/widgets-lib/src/context/crypto-fiat-context Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,16 +43,28 @@ export const getCryptoToFiatConversion = async (
4343 }
4444} ;
4545
46+ type TokenPriceResponse = {
47+ // eslint-disable-next-line @typescript-eslint/naming-convention
48+ result : { symbol : string ; usd_price : string } [ ] ;
49+ } ;
50+
4651async function getUSDConversionsForAll ( environment : Environment ) {
4752 const apiUrl = `${ IMMUTABLE_API_BASE_URL [ environment ] } /checkout/v1/token-prices` ;
48- const response = await axios . get ( apiUrl ) ;
53+ const response = await axios . get < TokenPriceResponse > ( apiUrl ) ;
4954
5055 const { data } = response ;
5156
5257 const result : CryptoFiatConvertReturn = { } ;
53- for ( const token of data ) {
54- result [ token . symbol ] = { usd : token . usd_price } ;
58+ const tokens = data . result || [ ] ;
59+ for ( const token of tokens ) {
60+ result [ token . symbol . toLowerCase ( ) ] = { usd : + token . usd_price } ;
5561 }
62+
63+ // if the result has wimx, then add imx to the result
64+ if ( result . wimx ) {
65+ result . imx = result . wimx ;
66+ }
67+
5668 return result ;
5769}
5870
You can’t perform that action at this time.
0 commit comments