Skip to content

Commit

Permalink
Merge pull request #5 from KomodoPlatform/add/ibc-channel-input
Browse files Browse the repository at this point in the history
Add/ibc channel input
  • Loading branch information
smk762 authored Nov 13, 2024
2 parents 9022079 + 48b385f commit aa64c2f
Show file tree
Hide file tree
Showing 37 changed files with 148 additions and 137 deletions.
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
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.

7 changes: 4 additions & 3 deletions src/core/atomicdex/api/kdf/kdf.client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,26 @@ namespace
json_req.insert(json_req.end(), json_data);
}
request.set_body(json_req.dump());
// SPDLOG_DEBUG("request: {}", json_req.dump());
return request;
}

template <atomic_dex::kdf::rpc Rpc>
Rpc process_rpc_answer(const web::http::http_response& answer)
{
std::string body = TO_STD_STR(answer.extract_string(true).get());
// SPDLOG_DEBUG("body: {}", body);
// SPDLOG_INFO("body: {}", body);
nlohmann::json json_answer;
Rpc rpc;
try
{
json_answer = nlohmann::json::parse(body);
// SPDLOG_DEBUG("rpc answer: {}", json_answer.dump(4));
// SPDLOG_DEBUG("json_answer: {}", json_answer.dump(4));
}
catch (const nlohmann::json::parse_error& error)
{
SPDLOG_ERROR("rpc answer error: {}", error.what());
// SPDLOG_DEBUG("body: {}", body);
}

if (Rpc::is_v2)
Expand All @@ -103,7 +105,6 @@ namespace
SPDLOG_DEBUG("rpc2 answer: error");
rpc.error = json_answer.get<typename Rpc::expected_error_type>();
rpc.raw_result = json_answer.dump();
SPDLOG_DEBUG("rpc.raw_result: {}", rpc.raw_result);
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "atomicdex/config/electrum.cfg.hpp"
#include "atomicdex/api/kdf/address_format.hpp"
#include "atomicdex/api/kdf/balance_info.hpp"
#include "atomicdex/api/kdf/balance_infos.hpp"
#include "atomicdex/api/kdf/rpc.hpp"
#include "atomicdex/api/kdf/utxo_merge_params.hpp"

Expand Down Expand Up @@ -65,13 +65,13 @@ namespace atomic_dex::kdf
{
derivation_method_t derivation_method;
std::string pubkey;
balance_info balances;
balance_infos balances;
};
struct slp_address_infos_t
{
derivation_method_t derivation_method;
std::string pubkey;
std::unordered_map<std::string, balance_info> balances;
std::unordered_map<std::string, balance_infos> balances;
};

std::size_t current_block;
Expand Down
2 changes: 1 addition & 1 deletion src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ namespace atomic_dex::kdf
{
j.at("platform_coin").get_to(in.platform_coin);
j.at("required_confirmations").get_to(in.required_confirmations);
j.at("balances").get_to<std::unordered_map<std::string, balance_info>>(in.balances);
j.at("balances").get_to<std::unordered_map<std::string, balance_infos>>(in.balances);
}
}
4 changes: 2 additions & 2 deletions src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_erc20.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <nlohmann/json_fwd.hpp> //> nlohmann::json
#include "atomicdex/api/kdf/rpc.hpp"
#include "atomicdex/api/kdf/balance_info.hpp"
#include "atomicdex/api/kdf/balance_infos.hpp"

namespace atomic_dex::kdf
{
Expand All @@ -40,7 +40,7 @@ namespace atomic_dex::kdf
{
std::string platform_coin;
int required_confirmations;
std::unordered_map<std::string, balance_info> balances;
std::unordered_map<std::string, balance_infos> balances;
};

using expected_error_type = rpc_basic_error_type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <vector>

#include "atomicdex/api/kdf/rpc.hpp"
#include "atomicdex/api/kdf/balance_info.hpp"
#include "atomicdex/api/kdf/balance_infos.hpp"
#include "atomicdex/config/enable.cfg.hpp"
#include "atomicdex/constants/qt.coins.enums.hpp"

Expand Down Expand Up @@ -60,13 +60,13 @@ namespace atomic_dex::kdf
{
derivation_method_t derivation_method;
std::string pubkey;
balance_info balances;
balance_infos balances;
};
struct erc20_address_infos_t
{
derivation_method_t derivation_method;
std::string pubkey;
std::unordered_map<std::string, balance_info> balances;
std::unordered_map<std::string, balance_infos> balances;
};

std::size_t current_block;
Expand Down
2 changes: 1 addition & 1 deletion src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ namespace atomic_dex::kdf
j.at("platform_coin").get_to(in.platform_coin);
j.at("required_confirmations").get_to(in.required_confirmations);
j.at("token_id").get_to(in.token_id);
j.at("balances").get_to<std::unordered_map<std::string, balance_info>>(in.balances);
j.at("balances").get_to<std::unordered_map<std::string, balance_infos>>(in.balances);
}
}
4 changes: 2 additions & 2 deletions src/core/atomicdex/api/kdf/rpc_v2/rpc2.enable_slp_rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <nlohmann/json_fwd.hpp> //> nlohmann::json

#include "atomicdex/api/kdf/rpc.hpp"
#include "atomicdex/api/kdf/balance_info.hpp"
#include "atomicdex/api/kdf/balance_infos.hpp"

namespace atomic_dex::kdf
{
Expand All @@ -43,7 +43,7 @@ namespace atomic_dex::kdf
std::string token_id;
std::string platform_coin;
int required_confirmations;
std::unordered_map<std::string, balance_info> balances;
std::unordered_map<std::string, balance_infos> balances;
};

using expected_error_type = rpc_basic_error_type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ namespace atomic_dex::kdf
void from_json(const nlohmann::json& j, enable_tendermint_token_rpc_result& in)
{
j.at("platform_coin").get_to(in.platform_coin);
j.at("balances").get_to<std::unordered_map<std::string, balance_info>>(in.balances);
j.at("balances").get_to<std::unordered_map<std::string, balance_infos>>(in.balances);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <nlohmann/json_fwd.hpp> //> nlohmann::json

#include "atomicdex/api/kdf/rpc.hpp"
#include "atomicdex/api/kdf/balance_info.hpp"
#include "atomicdex/api/kdf/balance_infos.hpp"

namespace atomic_dex::kdf
{
Expand All @@ -40,15 +40,15 @@ namespace atomic_dex::kdf
struct expected_result_type
{
std::string platform_coin;
std::unordered_map<std::string, balance_info> balances;
std::unordered_map<std::string, balance_infos> balances;
};

using expected_error_type = rpc_basic_error_type;

expected_request_type request;
std::optional<expected_result_type> result;
std::optional<expected_error_type> error;
std::string raw_result;
std::string raw_result;
};

using enable_tendermint_token_rpc_request = enable_tendermint_token_rpc::expected_request_type;
Expand Down
Loading

0 comments on commit aa64c2f

Please sign in to comment.