Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix faucet fiat #2398

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion assets/config/cfg.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"HUF": "Ft",
"SEK": "kr",
"KMD": "KMD",
"DOGE": "Ð",
"ETH": "⟠",
"ETH_ALT": "Ξ",
"BTC": "₿",
"BTC_ALT": "฿",
"LTC": "Ł"
Expand Down Expand Up @@ -92,6 +95,7 @@
"USD",
"BTC",
"KMD",
"LTC"
"LTC",
"DOGE"
]
}
2 changes: 1 addition & 1 deletion src/core/atomicdex/api/faucet/faucet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>(), .status = resp_body_json.at("Status").get<std::string>()};
.message = resp_body_json.at("result")["message"].get<std::string>(), .status = resp_body_json.at("status").get<std::string>()};
}
//! request error.
return faucet::api::claim_result{.message = resp_body, .status = "Request Error"};
Expand Down
19 changes: 18 additions & 1 deletion src/core/atomicdex/pages/qt.settings.page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down Expand Up @@ -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]));
}

}
}
}
Expand Down
14 changes: 11 additions & 3 deletions src/core/atomicdex/services/price/global.provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@
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);
Expand All @@ -452,10 +453,17 @@
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)

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-debug

use of undeclared identifier 'm_config'

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-debug

use of undeclared identifier 'm_config'

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-release

use of undeclared identifier 'm_config'

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / ubuntu-release

use of undeclared identifier 'm_config'

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / windows-debug

use of undeclared identifier 'm_config'

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / windows-release

use of undeclared identifier 'm_config'

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / osx-debug

use of undeclared identifier 'm_config'

Check failure on line 456 in src/core/atomicdex/services/price/global.provider.cpp

View workflow job for this annotation

GitHub Actions / osx-release

use of undeclared identifier 'm_config'
{
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;
Expand Down
13 changes: 13 additions & 0 deletions src/core/atomicdex/utilities/global.utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,19 @@ namespace atomic_dex::utils
return logo_path;
}

int8_t
get_index_str(std::vector<std::string> 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)
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/atomicdex/utilities/global.utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string> vec, std::string val);
std::vector<std::string> coin_cfg_to_ticker_cfg(std::vector<coin_config_t> in);

} // namespace atomic_dex::utils
Loading