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

Wallet enabling rework #1232

Merged
merged 22 commits into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e06a0f0
feat(mm2): Add more log to mm2.service.cpp
Aug 31, 2021
326370e
Merge remote-tracking branch 'origin/dev' into wallet_enabling_rework
Aug 31, 2021
122afd7
feat(wallet): Log when status changed
Aug 31, 2021
87c79f6
feat(app): Load frontend app on another wallet status
Aug 31, 2021
85b9009
feat(mm2): Do not trigger coin_enabled event
Aug 31, 2021
d0b95d0
feat(portfolio): Disable balance update events
Aug 31, 2021
ebac85f
Merge branch 'dev' of https://github.com/KomodoPlatform/atomicDEX-Des…
Milerius Sep 1, 2021
644097f
feat(batch): try a single batch solution for enabling
Milerius Sep 1, 2021
5abd8e1
feat(batch_balance_and_tx): move the batch_balance above
Milerius Sep 1, 2021
0319f13
feat(mm2_service): simplify balance batch
Milerius Sep 1, 2021
c590b74
feat(mm2_service): simplify balance batch
Milerius Sep 1, 2021
45f3a45
feat(mm2_service): simplify balance batch
Milerius Sep 1, 2021
3e18fec
feat(dashboard): Set pages' loader asynchronous
Sep 1, 2021
dce11b7
fix(dashboard): "Show only coins with balance" also affected wallet page
Sep 1, 2021
a0a90e9
feat(enabling): remove duplicata error
Milerius Sep 1, 2021
0223f03
Merge remote-tracking branch 'origin/wallet_enabling_rework' into wal…
Milerius Sep 1, 2021
54a5d89
feat(enabling): remove balance error spam log
Milerius Sep 1, 2021
23c4d58
feat(enabling): use the answer as a balance answer
Milerius Sep 1, 2021
4e0e10d
feat(batch_error): don't throw batch error anymore
Milerius Sep 1, 2021
07d850d
feat(batch_error): don't process answer if res is false
Milerius Sep 1, 2021
70fe7db
feat(batch_error): don't process answer if res is true*
Milerius Sep 1, 2021
9bcff45
feat(withdraw): better error management for send/broadcast
Milerius Sep 1, 2021
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
2 changes: 2 additions & 0 deletions atomic_defi_design/qml/Portfolio/Portfolio.qml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ Item {
text: qsTr("Show only coins with balance") + " <b>%1</b>".arg(qsTr("(%1/%2)").arg(coinsList.innerList.count).arg(portfolio_mdl.length))
checked: portfolio_coins.with_balance
onCheckedChanged: portfolio_coins.with_balance = checked

Component.onDestruction: portfolio_coins.with_balance = false
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion atomic_defi_design/qml/Screens/Dashboard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ Item {

anchors.fill: parent
transformOrigin: Item.Center
asynchronous: true

sourceComponent: {
switch (current_page) {
Expand Down Expand Up @@ -399,4 +400,4 @@ Item {
return qsTr(event_name)
}
}
}
}
4 changes: 2 additions & 2 deletions atomic_defi_design/qml/Screens/InitialLoading.qml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SetupPage {
readonly property string current_status: API.app.wallet_mgr.initial_loading_status

onCurrent_statusChanged: {
if (current_status === "complete")
if (current_status === "enabling_coins")
onLoaded()
}

Expand Down Expand Up @@ -47,4 +47,4 @@ SetupPage {
current_status === "enabling_coins" ? qsTr("Enabling assets") : qsTr("Getting ready")) + "..."
}
}
}
}
2 changes: 1 addition & 1 deletion src/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ namespace atomic_dex
if (coin_info.has_parent_fees_ticker && coin_info.ticker != coin_info.fees_ticker)
{
auto coin_parent_info = mm2.get_coin_info(coin_info.fees_ticker);
if (extra_coins.insert(coin_parent_info.ticker).second)
if (!coin_parent_info.currently_enabled && !coin_parent_info.active && extra_coins.insert(coin_parent_info.ticker).second)
{
SPDLOG_INFO("Adding extra coin: {} to enable", coin_parent_info.ticker);
}
Expand Down
1 change: 1 addition & 0 deletions src/core/atomicdex/managers/qt.wallet.manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ namespace atomic_dex
{
this->m_current_status = std::move(status);
emit onStatusChanged();
SPDLOG_INFO("Set status: {}", m_current_status.toStdString());
}

bool
Expand Down
25 changes: 16 additions & 9 deletions src/core/atomicdex/models/qt.portfolio.model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "atomicdex/utilities/global.utilities.hpp"
#include "atomicdex/utilities/qt.utilities.hpp"
#include "qt.portfolio.model.hpp"
#include "atomicdex/managers/qt.wallet.manager.hpp"

namespace atomic_dex
{
Expand Down Expand Up @@ -135,10 +136,11 @@ namespace atomic_dex
auto&& [prev_balance, new_balance, is_change_b] = update_value(BalanceRole, balance, idx, *this);
const QString display = QString::fromStdString(coin.ticker) + " (" + balance + ")";
update_value(Display, display, idx, *this);
if (is_change_b)
{
balance_update_handler(prev_balance.toString(), new_balance.toString(), QString::fromStdString(ticker));
}
// Not a good way to trigger notification, use websocket instead in the future. New was of enabling coins is not compatible.
// if (is_change_b && m_system_manager.has_system<qt_wallet_manager>() && m_system_manager.get_system<qt_wallet_manager>().get_status() == "complete")
// {
// balance_update_handler(prev_balance.toString(), new_balance.toString(), QString::fromStdString(ticker));
// }
QJsonArray trend = nlohmann_json_array_to_qt_json_array(coingecko.get_ticker_historical(ticker));
update_value(Trend7D, trend, idx, *this);
// SPDLOG_DEBUG("updated currency values of: {}", ticker);
Expand All @@ -153,9 +155,13 @@ namespace atomic_dex
bool
portfolio_model::update_balance_values(const std::vector<std::string>& tickers)
{
//SPDLOG_INFO("update_balance_values");
SPDLOG_INFO("update_balance_values");
for (auto&& ticker: tickers)
{
if (ticker.empty())
{
return false;
}
if (m_ticker_registry.find(ticker) == m_ticker_registry.end())
{
SPDLOG_WARN("ticker: {} not inserted yet in the model, skipping", ticker);
Expand Down Expand Up @@ -185,10 +191,11 @@ namespace atomic_dex
update_value(Display, display, idx, *this);
QString change24_h = retrieve_change_24h(coingecko, coin, *m_config, m_system_manager);
update_value(Change24H, change24_h, idx, *this);
if (is_change_b)
{
balance_update_handler(prev_balance.toString(), new_balance.toString(), QString::fromStdString(ticker));
}
// Not a good way to trigger notification, use websocket instead in the future. New was of enabling coins is not compatible.
// if (is_change_b && m_system_manager.has_system<qt_wallet_manager>() && m_system_manager.get_system<qt_wallet_manager>().get_status() == "complete")
// {
// balance_update_handler(prev_balance.toString(), new_balance.toString(), QString::fromStdString(ticker));
// }
QJsonArray trend = nlohmann_json_array_to_qt_json_array(coingecko.get_ticker_historical(ticker));
update_value(Trend7D, trend, idx, *this);
if (ticker == mm2_system.get_current_ticker() && (is_change_b || is_change_mc || is_change_mcpfo))
Expand Down
1 change: 1 addition & 0 deletions src/core/atomicdex/pages/qt.portfolio.page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ namespace atomic_dex
void
portfolio_page::initialize_portfolio(const std::vector<std::string>& tickers)
{
SPDLOG_INFO("initialize_portfolio with tickers: {}", fmt::join(tickers, ", "));
m_portfolio_mdl->initialize_portfolio(tickers);
m_global_cfg_mdl->update_status(tickers, true);
}
Expand Down
31 changes: 29 additions & 2 deletions src/core/atomicdex/pages/qt.wallet.page.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,8 +566,22 @@ namespace atomic_dex
this->set_send_busy(false);
};

auto error_functor = [this](pplx::task<void> previous_task) {
try
{
previous_task.wait();
}
catch (const std::exception& e)
{
SPDLOG_ERROR("error caught in send: {}", e.what());
auto error_json = QJsonObject({{"error_code", 500}, {"error_message", QString::fromStdString(e.what())}});
this->set_rpc_send_data(error_json);
this->set_send_busy(false);
}
};

//! Process
mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task);
mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor);
}

void
Expand Down Expand Up @@ -645,7 +659,20 @@ namespace atomic_dex
this->set_broadcast_busy(false);
};

mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(&handle_exception_pplx_task);
auto error_functor = [this](pplx::task<void> previous_task) {
try
{
previous_task.wait();
}
catch (const std::exception& e)
{
SPDLOG_ERROR("error caught in broadcast finished: {}", e.what());
this->set_rpc_broadcast_data(QString::fromStdString(e.what()));
this->set_broadcast_busy(false);
}
};

mm2_system.get_mm2_client().async_rpc_batch_standalone(batch).then(answer_functor).then(error_functor);
}

void
Expand Down
Loading