Skip to content

Commit c1d5d9c

Browse files
authored
Merge pull request #308 from clams-tech/release/2.5.4
Release 2.5.4
2 parents 7957fc9 + fdb101a commit c1d5d9c

File tree

3 files changed

+14
-28
lines changed

3 files changed

+14
-28
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "remote",
3-
"version": "2.5.3",
3+
"version": "2.5.4",
44
"scripts": {
55
"dev": "vite dev",
66
"dev-https": "vite dev --mode https",

src/lib/@types/settings.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ export type Tile =
1313
| 'channels'
1414
| 'offers'
1515
| 'forwards'
16-
// | 'accounting'
17-
// | 'charts'
18-
// | 'trades'
1916
| 'settings'
2017
| 'plugins'
2118

@@ -49,26 +46,7 @@ export enum BitcoinDenomination {
4946
// https://www.statista.com/statistics/1189498/share-of-global-payments-by-currency/
5047
export enum FiatDenomination {
5148
'none' = 'none',
52-
'usd' = 'usd',
53-
'eur' = 'eur',
54-
'gbp' = 'gbp',
55-
'cny' = 'cny',
56-
'jpy' = 'jpy',
57-
'cad' = 'cad',
58-
'aud' = 'aud',
59-
'hkd' = 'hkd',
60-
'sgd' = 'sgd',
61-
'sek' = 'sek',
62-
'chf' = 'chf',
63-
'thb' = 'thb',
64-
'pln' = 'pln',
65-
'nok' = 'nok',
66-
'myr' = 'myr',
67-
'dkk' = 'dkk',
68-
'zar' = 'zar',
69-
'nzd' = 'nzd',
70-
'mxn' = 'mxn',
71-
'rub' = 'rub'
49+
'usd' = 'usd'
7250
}
7351

7452
export type Denomination = BitcoinDenomination | FiatDenomination

src/lib/utils.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,18 @@ export async function getBitcoinExchangeRate(
5353
}
5454

5555
try {
56-
const result = await fetch(`${API_URL}/exchange-rates?currency=${currency}`).then(res =>
57-
res.json()
58-
)
59-
return result
56+
const result = await fetch('https://api.coincap.io/v2/rates/bitcoin').then(res => res.json())
57+
58+
const rateUsd = parseFloat(result?.data?.rateUsd || '0')
59+
60+
if (isNaN(rateUsd) || rateUsd <= 0) {
61+
throw new Error(`Invalid ${currency} rate received from API`)
62+
}
63+
64+
return {
65+
none: 0,
66+
usd: rateUsd
67+
}
6068
} catch (error) {
6169
log.warn(`Could not get exchange rate for currency: ${currency} `)
6270
return null

0 commit comments

Comments
 (0)