diff --git a/assets/config/cfg.json b/assets/config/cfg.json index 55e9f57757..fef919e6a1 100644 --- a/assets/config/cfg.json +++ b/assets/config/cfg.json @@ -41,6 +41,9 @@ "HUF": "Ft", "SEK": "kr", "KMD": "KMD", + "DOGE": "Ð", + "ETH": "⟠", + "ETH_ALT": "Ξ", "BTC": "₿", "BTC_ALT": "฿", "LTC": "Ł" @@ -92,6 +95,7 @@ "USD", "BTC", "KMD", - "LTC" + "LTC", + "DOGE" ] } \ No newline at end of file diff --git a/src/core/atomicdex/api/faucet/faucet.cpp b/src/core/atomicdex/api/faucet/faucet.cpp index 7f9d5567ae..085a5caf88 100644 --- a/src/core/atomicdex/api/faucet/faucet.cpp +++ b/src/core/atomicdex/api/faucet/faucet.cpp @@ -53,7 +53,7 @@ namespace atomic_dex::faucet::api auto resp_body_json = nlohmann::json::parse(resp_body); return faucet::api::claim_result{ - .message = resp_body_json.at("Result")["Message"].get(), .status = resp_body_json.at("Status").get()}; + .message = resp_body_json.at("result")["message"].get(), .status = resp_body_json.at("status").get()}; } //! request error. return faucet::api::claim_result{.message = resp_body, .status = "Request Error"}; diff --git a/src/core/atomicdex/pages/qt.settings.page.cpp b/src/core/atomicdex/pages/qt.settings.page.cpp index 4145591125..9ff8af5085 100644 --- a/src/core/atomicdex/pages/qt.settings.page.cpp +++ b/src/core/atomicdex/pages/qt.settings.page.cpp @@ -257,6 +257,12 @@ namespace atomic_dex void settings_page::set_current_currency(const QString& current_currency) { + if (m_config.possible_currencies.empty()) + { + SPDLOG_ERROR("m_config.possible_currencies are empty!"); + return; + } + bool can_proceed = true; std::string reason = ""; if (atomic_dex::is_this_currency_a_fiat(m_config, current_currency.toStdString())) @@ -293,7 +299,18 @@ namespace atomic_dex { if (!reason.empty()) { - SPDLOG_ERROR("cannot change currency for reason: {}", reason); + SPDLOG_WARN("Cannot change currency to {} for reason: {}", current_currency.toStdString(), reason); + // Try next in line + int8_t selected_idx = utils::get_index_str(m_config.possible_currencies, current_currency.toStdString()); + if (selected_idx < m_config.possible_currencies.size() - 1) + { + set_current_currency(QString::fromStdString(m_config.possible_currencies[selected_idx + 1])); + } + else + { + set_current_currency(QString::fromStdString(m_config.possible_currencies[0])); + } + } } } diff --git a/src/core/atomicdex/services/price/global.provider.cpp b/src/core/atomicdex/services/price/global.provider.cpp index d5d4bbe7e8..57dda1cf29 100644 --- a/src/core/atomicdex/services/price/global.provider.cpp +++ b/src/core/atomicdex/services/price/global.provider.cpp @@ -443,6 +443,7 @@ namespace atomic_dex bool already_send = false; const auto first_id = mm2.get_coin_info(g_primary_dex_coin).coinpaprika_id; const auto second_id = mm2.get_coin_info(g_second_primary_dex_coin).coinpaprika_id; + if (!first_id.empty()) { refresh_other_coins_rates(first_id, g_primary_dex_coin, false, 0); @@ -452,10 +453,17 @@ namespace atomic_dex refresh_other_coins_rates(second_id, g_second_primary_dex_coin, with_update, 0); already_send = true; } - if (g_primary_dex_coin != "BTC" && g_second_primary_dex_coin != "BTC") + for (auto&& coin: m_config.possible_currencies) { - const auto third_id = mm2.get_coin_info("BTC").coinpaprika_id; - refresh_other_coins_rates(third_id, "BTC", !already_send, 0); + if (g_primary_dex_coin != coin && g_second_primary_dex_coin != coin) + { + refresh_other_coins_rates( + mm2.get_coin_info(coin).coinpaprika_id, + coin, + !already_send, + 0 + ); + } } SPDLOG_INFO("Successfully retrieving rate after {} try", nb_try); nb_try = 0; diff --git a/src/core/atomicdex/utilities/global.utilities.cpp b/src/core/atomicdex/utilities/global.utilities.cpp index 91d9550f6b..e045d9e469 100644 --- a/src/core/atomicdex/utilities/global.utilities.cpp +++ b/src/core/atomicdex/utilities/global.utilities.cpp @@ -251,6 +251,19 @@ namespace atomic_dex::utils return logo_path; } + int8_t + get_index_str(std::vector vec, std::string val) + { + auto it = find(vec.begin(), vec.end(), val); + if (it != vec.end()) + { + int index = it - vec.begin(); + return index; + } + else { + return -1; + } + } std::string retrieve_main_ticker(const std::string& ticker, bool segwit_only, bool exclude_segwit) { diff --git a/src/core/atomicdex/utilities/global.utilities.hpp b/src/core/atomicdex/utilities/global.utilities.hpp index 14f9753c66..64137e613c 100644 --- a/src/core/atomicdex/utilities/global.utilities.hpp +++ b/src/core/atomicdex/utilities/global.utilities.hpp @@ -98,7 +98,7 @@ namespace atomic_dex::utils void to_eth_checksum(std::string& address); void json_keys(nlohmann::json j); - + int8_t get_index_str(std::vector vec, std::string val); std::vector coin_cfg_to_ticker_cfg(std::vector in); } // namespace atomic_dex::utils