feat: add RUB and BRL currencies, make settings currency dropdown dynamic

This commit is contained in:
2026-02-08 10:30:00 +01:00
parent 3bf0ab3963
commit 0c9bef405f
2 changed files with 18 additions and 9 deletions

View File

@@ -13,7 +13,9 @@ const CURRENCY_SYMBOLS = {
USD: '$',
GBP: '£',
CHF: 'CHF',
JPY: '¥'
JPY: '¥',
RUB: '₽',
BRL: 'R$'
}
const CACHE_DURATION = 60 * 60 * 1000 // 60 minutes (CoinGecko free tier is strict)
@@ -90,7 +92,7 @@ async function fetchRates() {
lastRequestTime = Date.now()
try {
const currencies = 'eur,usd,gbp,chf,jpy'
const currencies = 'eur,usd,gbp,chf,jpy,rub,brl'
const response = await fetch(`${COINGECKO_API}?ids=monero&vs_currencies=${currencies}`)
// Handle rate limit response
@@ -111,7 +113,9 @@ async function fetchRates() {
USD: data.monero.usd,
GBP: data.monero.gbp,
CHF: data.monero.chf,
JPY: data.monero.jpy
JPY: data.monero.jpy,
RUB: data.monero.rub,
BRL: data.monero.brl
}
// Update cache
@@ -135,7 +139,9 @@ function getDefaultRates() {
USD: 165,
GBP: 130,
CHF: 145,
JPY: 24000
JPY: 24000,
RUB: 15000,
BRL: 850
}
}
@@ -266,7 +272,7 @@ export function formatFiat(amount, currency) {
}).format(amount)
// Symbol before or after amount
if (['EUR', 'GBP', 'USD'].includes(currency)) {
if (['EUR', 'GBP', 'USD', 'BRL'].includes(currency)) {
return `${symbol} ${formatted}`
}
return `${formatted} ${symbol}`
@@ -284,7 +290,7 @@ export function getCurrencySymbol(currency) {
/**
* List of supported currencies
*/
export const SUPPORTED_CURRENCIES = ['XMR', 'EUR', 'CHF', 'USD', 'GBP', 'JPY']
export const SUPPORTED_CURRENCIES = ['XMR', 'EUR', 'CHF', 'USD', 'GBP', 'JPY', 'RUB', 'BRL']
export default {
getXmrRates,