Skip to content

Commit

Permalink
Merge pull request #308 from clams-tech/release/2.5.4
Browse files Browse the repository at this point in the history
Release 2.5.4
  • Loading branch information
johngribbin authored Jan 6, 2025
2 parents 7957fc9 + fdb101a commit c1d5d9c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 28 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "remote",
"version": "2.5.3",
"version": "2.5.4",
"scripts": {
"dev": "vite dev",
"dev-https": "vite dev --mode https",
Expand Down
24 changes: 1 addition & 23 deletions src/lib/@types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export type Tile =
| 'channels'
| 'offers'
| 'forwards'
// | 'accounting'
// | 'charts'
// | 'trades'
| 'settings'
| 'plugins'

Expand Down Expand Up @@ -49,26 +46,7 @@ export enum BitcoinDenomination {
// https://www.statista.com/statistics/1189498/share-of-global-payments-by-currency/
export enum FiatDenomination {
'none' = 'none',
'usd' = 'usd',
'eur' = 'eur',
'gbp' = 'gbp',
'cny' = 'cny',
'jpy' = 'jpy',
'cad' = 'cad',
'aud' = 'aud',
'hkd' = 'hkd',
'sgd' = 'sgd',
'sek' = 'sek',
'chf' = 'chf',
'thb' = 'thb',
'pln' = 'pln',
'nok' = 'nok',
'myr' = 'myr',
'dkk' = 'dkk',
'zar' = 'zar',
'nzd' = 'nzd',
'mxn' = 'mxn',
'rub' = 'rub'
'usd' = 'usd'
}

export type Denomination = BitcoinDenomination | FiatDenomination
Expand Down
16 changes: 12 additions & 4 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,18 @@ export async function getBitcoinExchangeRate(
}

try {
const result = await fetch(`${API_URL}/exchange-rates?currency=${currency}`).then(res =>
res.json()
)
return result
const result = await fetch('https://api.coincap.io/v2/rates/bitcoin').then(res => res.json())

const rateUsd = parseFloat(result?.data?.rateUsd || '0')

if (isNaN(rateUsd) || rateUsd <= 0) {
throw new Error(`Invalid ${currency} rate received from API`)
}

return {
none: 0,
usd: rateUsd
}
} catch (error) {
log.warn(`Could not get exchange rate for currency: ${currency} `)
return null
Expand Down

0 comments on commit c1d5d9c

Please sign in to comment.