Fix wownero rate + bug fixes.

- Fix wownero rates on offers page.
- Fix wownero USD price on wallet/wallets page.
- Set dark mode as default.
- Fix tooltips.
- Fix JS errors.
This commit is contained in:
gerlofvanek
2024-06-11 23:29:53 +02:00
committed by tecnovert
parent 34d94760a3
commit 64165e387e
5 changed files with 240 additions and 229 deletions

View File

@@ -223,17 +223,37 @@ const coinNameToSymbol = {
};
const getUsdValue = (cryptoValue, coinSymbol) => {
return fetch(`https://min-api.cryptocompare.com/data/price?fsym=${coinSymbol}&tsyms=USD`)
let apiUrl;
if (coinSymbol === 'WOW') {
apiUrl = `https://api.coingecko.com/api/v3/simple/price?ids=wownero&vs_currencies=usd`;
} else {
apiUrl = `https://min-api.cryptocompare.com/data/price?fsym=${coinSymbol}&tsyms=USD`;
}
return fetch(apiUrl)
.then(response => response.json())
.then(data => {
const exchangeRate = data.USD;
if (!isNaN(exchangeRate)) {
return {
usdValue: cryptoValue * exchangeRate,
btcValue: cryptoValue / exchangeRate
};
if (coinSymbol === 'WOW') {
const exchangeRate = data.wownero.usd;
if (!isNaN(exchangeRate)) {
return {
usdValue: cryptoValue * exchangeRate,
btcValue: cryptoValue / exchangeRate
};
} else {
throw new Error(`Invalid exchange rate for ${coinSymbol}`);
}
} else {
throw new Error(`Invalid exchange rate for ${coinSymbol}`);
const exchangeRate = data.USD;
if (!isNaN(exchangeRate)) {
return {
usdValue: cryptoValue * exchangeRate,
btcValue: cryptoValue / exchangeRate
};
} else {
throw new Error(`Invalid exchange rate for ${coinSymbol}`);
}
}
});
};