Skip to content

Commit 8b42300

Browse files
committed
process correctly
1 parent 7988a93 commit 8b42300

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

  • packages/checkout/widgets-lib/src/context/crypto-fiat-context

packages/checkout/widgets-lib/src/context/crypto-fiat-context/CryptoFiat.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff 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+
4651
async 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

0 commit comments

Comments
 (0)