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

Debug/crash wip #3

Draft
wants to merge 14 commits into
base: dev
Choose a base branch
from
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ FetchContent_Declare(
)

FetchContent_Declare(jl777-coins
URL https://github.com/KomodoPlatform/coins/archive/master.zip)
URL https://github.com/KomodoPlatform/coins/archive/add/tendermint-coins.zip)

#FetchContent_Declare(adex-generics-coins
# URL https://github.com/KomodoPlatform/komodo-wallet-desktop/archive/main.zip)
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/AddressField.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.15

DefaultTextField {
DexTextField {
readonly property int max_length: 50

validator: RegExpValidator {
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/AmountField.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.15

DefaultTextField
DexTextField
{
validator: RegExpValidator
{
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/AmountFloatField.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.15

DefaultTextField
DexTextField
{
validator: RegExpValidator
{
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/AmountIntField.qml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import QtQuick 2.15

DefaultTextField
DexTextField
{
property bool allowFloat: false
validator: RegExpValidator
Expand Down
8 changes: 0 additions & 8 deletions atomic_defi_design/Dex/Components/DefaultTextField.qml

This file was deleted.

2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/DexSweetComboBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ComboBox
{
anchors.rightMargin: 5

DefaultTextField
DexTextField
{
id: input_coin_filter
placeholderText: qsTr("Search")
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/SearchField.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Rectangle
}
}

DefaultTextField
DexTextField
{
id: _textField

Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/TextFieldWithTitle.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ColumnLayout
}
}

DefaultTextField
DexTextField
{
id: input_field

Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Components/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Rectangle 1.0 DefaultRectangle.qml
ScrollView 1.0 DefaultScrollView.qml
SearchField 1.0 SearchField.qml
Text 1.0 DefaultText.qml
TextField 1.0 DefaultTextField.qml
TextField 1.0 DexTextField.qml
TextFieldWithTitle 1.0 TextFieldWithTitle.qml
ToolTip 1.0 DefaultTooltip.qml
UserIcon 1.0 UserIcon.qml
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Screens/Startup/WalletsView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ SetupPage
visible: wallet_count > 0

// Searchbar
DefaultTextField
DexTextField
{
id: wallet_search
visible: wallet_count > 5
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Settings/RecoverSeedModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ MultipageModal

HorizontalLine { Layout.fillWidth: true }

DefaultTextField
DexTextField
{
visible: coinsList.visible
enabled: coinsList.enabled
Expand Down
36 changes: 31 additions & 5 deletions atomic_defi_design/Dex/Wallet/SendModal.qml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ MultipageModal

function getCryptoAmount() { return _preparePage.cryptoSendMode ? input_amount.text : equivalentAmount.value }

function prepareSendCoin(address, amount, with_fees, fees_amount, is_special_token, gas_limit, gas_price, memo="") {
function prepareSendCoin(address, amount, with_fees, fees_amount, is_special_token, gas_limit, gas_price, memo="", ibc_source_channel="") {
let max = parseFloat(current_ticker_infos.balance) === parseFloat(amount)
// Save for later check
async_param_max = max
Expand All @@ -60,7 +60,7 @@ MultipageModal
gas_price,
gas_limit: gas_limit === "" ? 0 : parseInt(gas_limit)
}
api_wallet_page.send(address, amount, max, with_fees, fees_info, memo)
api_wallet_page.send(address, amount, max, with_fees, fees_info, memo, ibc_source_channel)
}

function sendCoin() {
Expand Down Expand Up @@ -263,7 +263,7 @@ MultipageModal
color: input_address.background.color
radius: input_address.background.radius

DefaultTextField
DexTextField
{
id: input_address

Expand Down Expand Up @@ -567,7 +567,7 @@ MultipageModal
color: input_memo.background.color
radius: input_memo.background.radius

DefaultTextField
DexTextField
{
id: input_memo

Expand All @@ -579,6 +579,31 @@ MultipageModal
}
}

// IBC channel ID
DefaultRectangle
{
visible: (["TENDERMINT", "TENDERMINTTOKEN"].includes(current_ticker_infos.type))
enabled: !root.is_send_busy

Layout.preferredWidth: 500
Layout.preferredHeight: 44
Layout.alignment: Qt.AlignHCenter

color: input_memo.background.color
radius: input_memo.background.radius

DexTextField
{
id: input_ibc_channel_id

width: 470
height: 44
placeholderText: qsTr("Enter IBC channel ID")
forceFocus: true
font: DexTypo.body3
}
}

ColumnLayout
{
visible: General.getCustomFeeType(current_ticker_infos)
Expand Down Expand Up @@ -786,7 +811,8 @@ MultipageModal
General.isSpecialToken(current_ticker_infos),
input_custom_fees_gas.text,
input_custom_fees_gas_price.text,
input_memo.text
input_memo.text,
input_ibc_channel_id.text
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion atomic_defi_design/Dex/Wallet/SendModalContactList.qml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MultipageModal
titleText: qsTr("Select a contact with an %1 address").arg(ticker)

// Searchbar
DefaultTextField
DexTextField
{
Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ namespace atomic_dex
{
SPDLOG_DEBUG("on_fiat_rate_updated");
this->dispatcher_.trigger<update_portfolio_values>();
// this->dispatcher_.trigger<current_currency_changed>();
this->dispatcher_.trigger<current_currency_changed>();
}

void
Expand Down
102 changes: 81 additions & 21 deletions src/core/atomicdex/api/checksum/checksum.api.cpp
Original file line number Diff line number Diff line change
@@ -1,41 +1,101 @@
//! 3rdParty
#include <nlohmann/json.hpp>
#include <optional>

//! Project
#include "checksum.api.hpp"

namespace atomic_dex::checksum::api
{
const auto api_client = std::make_unique<web::http::client::http_client>(FROM_STD_STR(DEX_CHECKSUM_API_URL));

pplx::task<std::string>

// Helper function for platform-specific file identifiers
std::string get_platform_file_identifier()
{
#ifdef __APPLE__
return "osx.dmg";
#elif __linux__
return "linux.AppImage";
#elif _WIN32
return "windows.zip";
#else
return "";
#endif
}

pplx::task<std::optional<std::string>>
get_latest_checksum()
{
return api_client->request(web::http::methods::GET)
.then([](web::http::http_response resp)
.then([](web::http::http_response resp) -> std::optional<std::string>
{
if (resp.status_code() != 200)
{
return TO_STD_STR(resp.extract_string(true).get());
SPDLOG_ERROR("Failed to fetch checksum. HTTP status: {}", resp.status_code());
return std::nullopt;
}

const auto json_answer = nlohmann::json::parse(TO_STD_STR(resp.extract_string(true).get()));

for (auto it = json_answer.begin(); it != json_answer.end(); ++it)

// Cache the response body to avoid multiple calls to extract_string
std::string body = TO_STD_STR(resp.extract_string(true).get());

try
{
if (it.key().find(
#ifdef __APPLE__
"osx.dmg"
#elif __linux__
"linux.AppImage"
#elif _WIN32
"windows.zip"
#endif
) != std::string::npos)
return it.value().get<std::string>();
SPDLOG_DEBUG("Checksum API response: {}", body);
const auto json_answer = nlohmann::json::parse(body);

std::string platform_identifier = get_platform_file_identifier();

if (platform_identifier.empty())
{
SPDLOG_ERROR("Unknown platform! Unable to fetch the correct checksum.");
return std::nullopt;
}

// Look for the platform-specific checksum
for (const auto& item : json_answer.items())
{
if (item.key().find(platform_identifier) != std::string::npos)
{
SPDLOG_DEBUG("Found checksum for platform: {}", item.key());
return item.value().get<std::string>();
}
}

SPDLOG_WARN("Valid checksum not found in the response.");
return std::nullopt;
}
catch (const nlohmann::json::exception& e)
{
SPDLOG_ERROR("JSON parsing error: {}", e.what());
return std::nullopt;
}
catch (const std::exception& e)
{
SPDLOG_ERROR("Exception while processing checksum: {}", e.what());
return std::nullopt;
}
})
.then([](pplx::task<std::optional<std::string>> previous_task) -> std::optional<std::string>
{
try
{
return previous_task.get(); // Get the result of the task, or throw if it failed
}
catch (const web::http::http_exception& e)
{
SPDLOG_ERROR("HTTP exception in get_latest_checksum: {}", e.what());
return std::nullopt;
}
catch (const std::exception& e)
{
SPDLOG_ERROR("Standard exception in get_latest_checksum: {}", e.what());
return std::nullopt;
}
catch (...)
{
SPDLOG_ERROR("Unknown exception in get_latest_checksum.");
return std::nullopt;
}

return std::string{"Valid checksum not found!"};
});
}
}
}
2 changes: 1 addition & 1 deletion src/core/atomicdex/api/checksum/checksum.api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
namespace atomic_dex::checksum::api
{
// Returns the checksum of the latest
[[nodiscard]] pplx::task<std::string>
[[nodiscard]] pplx::task<std::optional<std::string>>
get_latest_checksum();
}
12 changes: 0 additions & 12 deletions src/core/atomicdex/api/kdf/balance_info.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions src/core/atomicdex/api/kdf/balance_info.hpp

This file was deleted.

Loading
Loading