mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-02-22 06:52:41 +01:00
FIX: #5619
This commit is contained in:
parent
1e5048a4a7
commit
881b20a802
2 changed files with 30 additions and 0 deletions
|
@ -9,6 +9,7 @@ export const FiatUnitSource = {
|
|||
Exir: 'Exir',
|
||||
wazirx: 'wazirx',
|
||||
Bitstamp: 'Bitstamp',
|
||||
BNR: 'BNR',
|
||||
} as const;
|
||||
|
||||
const RateExtractors = {
|
||||
|
@ -74,7 +75,30 @@ const RateExtractors = {
|
|||
if (!(rate >= 0)) throw new Error(`Could not update rate from Bitstamp for ${ticker}: data is wrong`);
|
||||
return rate;
|
||||
},
|
||||
BNR: async (): Promise<number> => {
|
||||
try {
|
||||
const response = await fetch('https://www.bnr.ro/nbrfxrates.xml');
|
||||
const xmlData = await response.text();
|
||||
|
||||
const targetCurrency = 'USD';
|
||||
|
||||
const pattern = new RegExp(`<Rate currency="${targetCurrency}">([\\d.]+)<\\/Rate>`);
|
||||
|
||||
const matches = xmlData.match(pattern);
|
||||
|
||||
if (matches && matches[1]) {
|
||||
const ronExchangeRate = parseFloat(matches[1]);
|
||||
|
||||
if (!isNaN(ronExchangeRate) && ronExchangeRate > 0) {
|
||||
return ronExchangeRate;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error(`Could not find a valid exchange rate for ${targetCurrency}`);
|
||||
} catch (error: any) {
|
||||
throw new Error(`Could not fetch RON exchange rate: ${error.message}`);
|
||||
}
|
||||
},
|
||||
Yadio: async (ticker: string): Promise<number> => {
|
||||
let json;
|
||||
try {
|
||||
|
|
|
@ -245,6 +245,12 @@
|
|||
"source": "CoinDesk",
|
||||
"symbol": "ر.ق."
|
||||
},
|
||||
"RON": {
|
||||
"endPointKey": "RON",
|
||||
"locale": "ro-RO",
|
||||
"source": "BNR",
|
||||
"symbol": "lei"
|
||||
},
|
||||
"RUB": {
|
||||
"endPointKey": "RUB",
|
||||
"locale": "ru-RU",
|
||||
|
|
Loading…
Add table
Reference in a new issue