From 9cb075c79bdc013494cbbecd3cb9e2f12e4e2e29 Mon Sep 17 00:00:00 2001 From: okjodom Date: Mon, 18 Nov 2024 15:00:20 +0300 Subject: [PATCH] fix: select proper currency types --- apps/swap/src/fx/fx.service.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/swap/src/fx/fx.service.ts b/apps/swap/src/fx/fx.service.ts index aa32cb3..a242f18 100644 --- a/apps/swap/src/fx/fx.service.ts +++ b/apps/swap/src/fx/fx.service.ts @@ -8,6 +8,7 @@ import { Currency, CustomStore, mapToSupportedCurrency, + SupportedCurrencyType, } from '@bitsacco/common'; interface CurrencyApiResponse { @@ -36,8 +37,8 @@ export class FxService { } async getExchangeRate( - baseCurrency: Currency, - targetCurrency: Currency, + baseCurrency: SupportedCurrencyType, + targetCurrency: SupportedCurrencyType, ): Promise { const cacheKey = `${baseCurrency}-${targetCurrency}`; @@ -73,7 +74,7 @@ export class FxService { const response = await firstValueFrom( this.httpService .get( - `https://api.currencyapi.com/v3/latest?apikey=${api_key}&base_currency=${mapToSupportedCurrency(baseCurrency)}¤cies=${mapToSupportedCurrency(targetCurrency)}`, + `https://api.currencyapi.com/v3/latest?apikey=${api_key}&base_currency=${baseCurrency}¤cies=${targetCurrency}`, { headers: { 'Content-Type': 'application/json', @@ -100,7 +101,7 @@ export class FxService { baseCurrency: Currency, targetCurrency: Currency, ) { - const rate = await this.getExchangeRate(baseCurrency, targetCurrency); + const rate = await this.getExchangeRate(mapToSupportedCurrency(baseCurrency), mapToSupportedCurrency(targetCurrency)); return 1 / rate; } }