()
| 61 | } |
| 62 | |
| 63 | async function fetchFiatRates(): Promise<Record<string, number>> { |
| 64 | const response = await fetch('https://open.er-api.com/v6/latest/USD') |
| 65 | if (!response.ok) { |
| 66 | throw new Error( |
| 67 | `Currency rates request failed with status ${response.status}`, |
| 68 | ) |
| 69 | } |
| 70 | |
| 71 | const data = (await response.json()) as CurrencyRatesApiResponse |
| 72 | if (data.result !== 'success' || !data.rates) { |
| 73 | throw new Error('Currency rates response is invalid') |
| 74 | } |
| 75 | |
| 76 | return data.rates |
| 77 | } |
| 78 | |
| 79 | async function fetchCryptoRates(): Promise<Record<string, number>> { |
| 80 | const ids = Object.values(CRYPTO_IDS).join(',') |
no outgoing calls
no test coverage detected