diff --git a/main.qml b/main.qml index d58955b413..919423e67f 100644 --- a/main.qml +++ b/main.qml @@ -105,7 +105,9 @@ ApplicationWindow { // {provider name: {ticker: price_api_url}} // API response schema depends on the provider // fiat currencies also hard coded in SettingsLayout.qml - property var fiatPriceAPIs: ["usd", "eur"].reduce(function(obj, x) { + property var fiatPriceAPIs: ["usd", "eur", "aed", "ars", "aud", "bdt", "bhd", "brl", "cad", "chf", "clp", "cny", "czk", "gbp", "hkd", + "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", + "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xau"].reduce(function(obj, x) { const key = `xmr${x}`; // e.g. xmrusd const xUp = x.toUpperCase(); // e.g. usd -> USD obj["kraken"][key] = `https://api.kraken.com/0/public/Ticker?pair=XMR${xUp}`; @@ -1153,20 +1155,21 @@ ApplicationWindow { appWindow.fiatApiError("Kraken API has error(s)"); return; } - // currency is of the form xmr[a-Z]+. Replaces only starting XMR - var key = `${currency}`.replace("xmr", "xxmrz").toUpperCase(); + // i.e. xmr[a-z]+ -> XXMRZ[A-Z]+ + var key = `XXMRZ${currency.substring(3)}`; var ticker = resp.result[key]["c"][0]; return ticker; } else if(url.startsWith("https://api.coingecko.com/api/v3/")){ - // i.e. xmr[a-Z]+ -> [a-Z]+ - var key = currency.replace("xmr", ""); + // i.e. xmr[a-zz]+ -> [a-z]+ + var key = currency.substring(3); if(!resp.hasOwnProperty("monero") || !resp["monero"].hasOwnProperty(key)){ appWindow.fiatApiError("Coingecko API has error(s)"); return; } return resp["monero"][key]; } else if(url.startsWith("https://min-api.cryptocompare.com/data/")){ - var key = currency.replace("xmr", "").toUpperCase(); + // i.e. xmr[a-z]+ -> [A-Z]+ + var key = currency.substring(3).toUpperCase(); if(!resp.hasOwnProperty(key)){ appWindow.fiatApiError("cryptocompare API has error(s)"); return; @@ -1245,7 +1248,7 @@ ApplicationWindow { } function fiatApiCurrencySymbol() { - return persistentSettings.fiatPriceCurrency.replace("xmr", "").toUpperCase(); + return persistentSettings.fiatPriceCurrency.substring(3).toUpperCase(); } function fiatApiConvertToFiat(amount) { @@ -2152,7 +2155,6 @@ ApplicationWindow { console.log("close accepted"); // Close wallet non async on exit daemonManager.exit(); - closeWallet(Qt.quit); } diff --git a/pages/settings/SettingsLayout.qml b/pages/settings/SettingsLayout.qml index cc4ee3b0ad..68ea10c190 100644 --- a/pages/settings/SettingsLayout.qml +++ b/pages/settings/SettingsLayout.qml @@ -290,7 +290,9 @@ Rectangle { id: fiatPriceCurrencyModel // from https://agateau.com/2018/working-around-listmodel-limitations/ Component.onCompleted: { - ["usd", "eur"].forEach(el => { + ["usd", "eur", "aed", "ars", "aud", "bdt", "bhd", "brl", "cad", "chf", "clp", "cny", "czk", "gbp", "hkd", + "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", + "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar", "xau"].forEach(el => { append({ data: `xmr${el}`, column1: el.toUpperCase()