@DEX_DISPLAY_NAME@
- 0.5.7.2
+ @DEX_VERSION@
@DEX_DISPLAY_NAME@ Installer
@DEX_WEBSITE@
@DEX_COMPANY@
diff --git a/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/installscript.qs.in b/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/installscript.qs.in
index 204713cb6d..106dd0af5e 100644
--- a/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/installscript.qs.in
+++ b/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/installscript.qs.in
@@ -1,12 +1,12 @@
function Component()
{
-
-}
+ // installer.gainAdminRights();
+ component.loaded.connect(this, this.installerLoaded);
+}
Component.prototype.createOperations = function()
{
component.createOperations();
-
if (installer.value("os") === "win") {
// Start Menu Shortcut
component.addOperation("CreateShortcut",
@@ -32,4 +32,48 @@ Component.prototype.createOperations = function()
"iconPath=@DEX_ICON_DIR@", "iconId=0",
"description=Start @DEX_MAINTENANCE_TOOL_NAME@");
}
+}
+
+Component.prototype.installerLoaded = function()
+{
+ installer.setDefaultPageVisible(QInstaller.TargetDirectory, false);
+ installer.addWizardPage(component, "TargetWidget", QInstaller.TargetDirectory);
+
+ targetDirectoryPage = gui.pageWidgetByObjectName("DynamicTargetWidget");
+ targetDirectoryPage.windowTitle = "Choose Installation Directory";
+ targetDirectoryPage.description.setText("Please select where the app will be installed:");
+ targetDirectoryPage.targetDirectory.textChanged.connect(this, this.targetDirectoryChanged);
+ targetDirectoryPage.targetDirectory.setText(installer.value("TargetDir"));
+ targetDirectoryPage.targetChooser.released.connect(this, this.targetChooserClicked);
+
+ gui.pageById(QInstaller.ComponentSelection).entered.connect(this, this.componentSelectionPageEntered);
+}
+
+Component.prototype.targetChooserClicked = function()
+{
+ var dir = QFileDialog.getExistingDirectory("", targetDirectoryPage.targetDirectory.text);
+ targetDirectoryPage.targetDirectory.setText(dir);
+}
+
+Component.prototype.targetDirectoryChanged = function()
+{
+ var dir = targetDirectoryPage.targetDirectory.text;
+ if (installer.fileExists(dir) && installer.fileExists(dir + "/maintenancetool.exe")) {
+ targetDirectoryPage.warning.setText("Existing installation detected and will be overwritten.
");
+ }
+ else if (installer.fileExists(dir)) {
+ targetDirectoryPage.warning.setText("Installing in existing directory. It will be wiped on uninstallation.
");
+ }
+ else {
+ targetDirectoryPage.warning.setText("");
+ }
+ installer.setValue("TargetDir", dir);
+}
+
+Component.prototype.componentSelectionPageEntered = function()
+{
+ var dir = installer.value("TargetDir");
+ if (installer.fileExists(dir) && installer.fileExists(dir + "/maintenancetool.exe")) {
+ installer.execute(dir + "/maintenancetool.exe", ["purge", "-c"]);
+ }
}
\ No newline at end of file
diff --git a/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/package.xml.in b/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/package.xml.in
index 57bb3278f8..090e2c430f 100644
--- a/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/package.xml.in
+++ b/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/package.xml.in
@@ -2,11 +2,14 @@
${DEX_DISPLAY_NAME}
Install ${DEX_DISPLAY_NAME}.
- 0.5.7.2
- 2023-03-04
+ ${DEX_VERSION}
+ 2023-11-06
true
+
+ targetwidget.ui
+
diff --git a/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/targetwidget.ui b/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/targetwidget.ui
new file mode 100644
index 0000000000..6237332046
--- /dev/null
+++ b/ci_tools_atomic_dex/installer/windows/packages/com.komodoplatform.atomicdex/meta/targetwidget.ui
@@ -0,0 +1,113 @@
+
+
+ TargetWidget
+
+
+
+ 0
+ 0
+ 491
+ 190
+
+
+
+
+ 0
+ 0
+
+
+
+
+ 491
+ 190
+
+
+
+ Form
+
+
+ -
+
+
+
+
+
+
+ -
+
+
-
+
+
+ true
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+ 0
+ 0
+
+
+
+ ...
+
+
+
+
+
+ -
+
+
+ 0
+
+
-
+
+
+ true
+
+
+ TextLabel
+
+
+
+ -
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
+
+
+ -
+
+
+ Qt::Vertical
+
+
+
+ 20
+ 122
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/cmake/install/macos/dex_install.cmake b/cmake/install/macos/dex_install.cmake
index 7eb09e6edd..8b27af7e9b 100644
--- a/cmake/install/macos/dex_install.cmake
+++ b/cmake/install/macos/dex_install.cmake
@@ -1,11 +1,13 @@
if (APPLE)
message(STATUS "ICON ->>>> ${ICON}")
+ message(STATUS "PROJECT_NAME ->>>> ${PROJECT_NAME}")
+ message(STATUS "DEX_VERSION ->>>> ${DEX_VERSION}")
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "${PROJECT_NAME}"
RESOURCE ${ICON}
MACOSX_BUNDLE_ICON_FILE dex-logo
- MACOSX_BUNDLE_SHORT_VERSION_STRING 0.5.7.2
- MACOSX_BUNDLE_LONG_VERSION_STRING 0.5.7.2
+ MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION}
+ MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION}
MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/cmake/MacOSXBundleInfo.plist.in")
add_custom_command(TARGET ${PROJECT_NAME}
POST_BUILD COMMAND
diff --git a/cmake/project.metadata.cmake b/cmake/project.metadata.cmake
index ba3ba0ee1b..52fa2fe95c 100644
--- a/cmake/project.metadata.cmake
+++ b/cmake/project.metadata.cmake
@@ -7,6 +7,7 @@ set(DEX_DISPLAY_NAME "AtomicDEX Desktop")
set(DEX_MAINTENANCE_TOOL_NAME "AtomicDEX Maintenance Tool")
set(DEX_COMPANY "KomodoPlatform")
set(DEX_WEBSITE "https://atomicdex.io/")
+set(DEX_VERSION "0.5.8")
set(DEX_SUPPORT_PAGE "https://support.komodoplatform.com/support/home")
set(DEX_DISCORD "https://komodoplatform.com/discord")
set(DEX_TWITTER "https://twitter.com/AtomicDEX")
@@ -15,7 +16,7 @@ set(DEX_SECOND_PRIMARY_COIN "KMD")
option(DISABLE_GEOBLOCKING "Enable to disable geoblocking (for dev purpose)" OFF)
set(DEX_REPOSITORY_OWNER ${DEX_COMPANY})
set(DEX_REPOSITORY_NAME "atomicDEX-Desktop")
-set(DEX_CHECKSUM_API_URL "https://komodo.live/static/checksum.json")
+set(DEX_CHECKSUM_API_URL "https://komodo.earth/static/checksum.json")
if (APPLE)
set(DEX_APPDATA_FOLDER "AtomicDex Desktop")
else ()
@@ -47,6 +48,9 @@ endif ()
if (DEFINED ENV{DEX_WEBSITE})
set(DEX_WEBSITE $ENV{DEX_WEBSITE})
endif ()
+if (DEFINED ENV{DEX_VERSION})
+ set(DEX_VERSION $ENV{DEX_VERSION})
+endif ()
if (DEFINED ENV{PROJECT_ROOT})
set(PROJECT_ROOT $ENV{PROJECT_ROOT})
else ()
@@ -67,6 +71,7 @@ message(STATUS "CMAKE_BUILD_TYPE --> ${CMAKE_BUILD_TYPE}")
message(STATUS "DEX_PROJECT_NAME --> ${DEX_PROJECT_NAME}")
message(STATUS "DEX_DISPLAY_NAME --> ${DEX_DISPLAY_NAME}")
message(STATUS "DEX_COMPANY --> ${DEX_COMPANY}")
+message(STATUS "DEX_VERSION --> ${DEX_VERSION}")
message(STATUS "DEX_WEBSITE --> ${DEX_WEBSITE}")
message(STATUS "CMAKE_SOURCE_DIR --> ${CMAKE_SOURCE_DIR}")
message(STATUS "PROJECT_ROOT --> ${PROJECT_ROOT}")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 531c27e8d6..5d33a981a0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -17,7 +17,7 @@ DEX_NEW_LIB(core INTERFACE
DEX_API="${DEX_API}" DEX_RPC="${DEX_RPC}" DEX_RPCPORT="${DEX_RPCPORT}" DEX_NAME="${DEX_DISPLAY_NAME}" DEX_WEBSITE_URL="${DEX_WEBSITE}"
DEX_SUPPORT_URL="${DEX_SUPPORT_PAGE}" DEX_DISCORD_URL="${DEX_DISCORD}" DEX_TWITTER_URL="${DEX_TWITTER}"
DEX_PRIMARY_COIN="${DEX_PRIMARY_COIN}" DEX_SECOND_PRIMARY_COIN="${DEX_SECOND_PRIMARY_COIN}" #DEX_COMMON_DATA_FOLDER="${DEX_COMMON_DATA_FOLDER}"
- DEX_PROJECT_NAME="${DEX_PROJECT_NAME}" DEX_COMPANY_NAME="${DEX_COMPANY_NAME}"
+ DEX_PROJECT_NAME="${DEX_PROJECT_NAME}" DEX_COMPANY_NAME="${DEX_COMPANY_NAME}" DEX_VERSION="${DEX_VERSION}"
DEX_REPOSITORY_OWNER="${DEX_REPOSITORY_OWNER}" DEX_REPOSITORY_NAME="${DEX_REPOSITORY_NAME}"
DEX_CHECKSUM_API_URL="${DEX_CHECKSUM_API_URL}" DEX_APPDATA_FOLDER="${DEX_APPDATA_FOLDER}"
INTERFACE_DEFS
diff --git a/src/app/app.cpp b/src/app/app.cpp
index 08b233e43b..d7cd93d9a7 100644
--- a/src/app/app.cpp
+++ b/src/app/app.cpp
@@ -44,7 +44,6 @@
#include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp"
#include "atomicdex/services/price/coingecko/coingecko.wallet.charts.hpp"
#include "atomicdex/services/price/coinpaprika/coinpaprika.provider.hpp"
-#include "atomicdex/services/price/oracle/band.provider.hpp"
#include "atomicdex/services/price/orderbook.scanner.service.hpp"
namespace
@@ -181,6 +180,8 @@ namespace atomic_dex
bool application::has_coins_with_balance()
{
+ // TODO: Does this ignore test coins?
+ // Simple view on fresh wallet with only test coins from faucet returns `no tradable assets`
auto* portfolio_page = get_portfolio_page();
auto* portfolio_mdl = portfolio_page->get_portfolio();
auto portfolio_data = portfolio_mdl->get_underlying_data();
@@ -499,8 +500,7 @@ namespace atomic_dex
system_manager_.create_system(system_manager_, this);
system_manager_.create_system(system_manager_, settings_page_system.get_cfg());
system_manager_.create_system(system_manager_);
- system_manager_.create_system();
- // system_manager_.create_system(system_manager_);
+ //system_manager_.create_system(system_manager_);
//system_manager_.create_system(system_manager_);
system_manager_.create_system();
system_manager_.create_system();
diff --git a/src/core/atomicdex/api/faucet/faucet.cpp b/src/core/atomicdex/api/faucet/faucet.cpp
index 2fb699ceb1..06e2e44cb3 100644
--- a/src/core/atomicdex/api/faucet/faucet.cpp
+++ b/src/core/atomicdex/api/faucet/faucet.cpp
@@ -23,7 +23,7 @@
namespace
{
- constexpr const char* g_faucet_api_endpoint = "https://faucet.komodo.live/faucet/";
+ constexpr const char* g_faucet_api_endpoint = "https://faucet.komodo.earth/faucet/";
const auto g_faucet_api_client = std::make_unique(FROM_STD_STR(g_faucet_api_endpoint));
} // namespace
diff --git a/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp b/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp
index e596de60c7..02bd2b109a 100644
--- a/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp
+++ b/src/core/atomicdex/api/komodo_prices/komodo.prices.cpp
@@ -10,7 +10,7 @@
namespace
{
- constexpr const char* g_komodo_prices_endpoint = "https://prices.komodo.live:1313";
+ constexpr const char* g_komodo_prices_endpoint = "https://prices.komodo.earth:1313";
constexpr const char* g_komodo_prices_endpoint_fallback = "https://prices.cipig.net:1717";
web::http::client::http_client_config g_komodo_prices_cfg{[]()
diff --git a/src/core/atomicdex/api/mm2/enable_slp_rpc.cpp b/src/core/atomicdex/api/mm2/enable_slp_rpc.cpp
index 314005d743..82f1524d94 100644
--- a/src/core/atomicdex/api/mm2/enable_slp_rpc.cpp
+++ b/src/core/atomicdex/api/mm2/enable_slp_rpc.cpp
@@ -19,7 +19,6 @@ namespace atomic_dex::mm2
void from_json(const nlohmann::json& j, enable_slp_rpc_result& in)
{
- j.at("token_id").get_to(in.token_id);
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);
diff --git a/src/core/atomicdex/api/mm2/mm2.client.cpp b/src/core/atomicdex/api/mm2/mm2.client.cpp
index 93d2bf52ad..d2190d63c4 100644
--- a/src/core/atomicdex/api/mm2/mm2.client.cpp
+++ b/src/core/atomicdex/api/mm2/mm2.client.cpp
@@ -28,6 +28,8 @@
#include "atomicdex/constants/dex.constants.hpp"
#include "rpc.hpp"
#include "rpc.tx.history.hpp"
+#include "rpc2.enable_tendermint_token.hpp"
+#include "rpc2.enable_tendermint_with_assets.hpp"
namespace
{
@@ -160,6 +162,8 @@ namespace atomic_dex::mm2
template void mm2_client::process_rpc_async(const std::function&);
template void mm2_client::process_rpc_async(const std::function&);
template void mm2_client::process_rpc_async(const std::function&);
+ template void mm2_client::process_rpc_async(const std::function&);
+ template void mm2_client::process_rpc_async(const std::function&);
template void mm2_client::process_rpc_async(const std::function&);
template void mm2_client::process_rpc_async(const std::function&);
@@ -192,11 +196,11 @@ namespace atomic_dex::mm2
template
TAnswer
- mm2_client::process_rpc(TRequest&& request, std::string rpc_command)
+ mm2_client::process_rpc(TRequest&& request, std::string rpc_command, bool is_v2)
{
SPDLOG_DEBUG("Processing rpc call: {}", rpc_command);
- nlohmann::json json_data = mm2::template_request(rpc_command);
+ nlohmann::json json_data = mm2::template_request(rpc_command, is_v2);
mm2::to_json(json_data, request);
@@ -211,6 +215,12 @@ namespace atomic_dex::mm2
return rpc_process_answer(resp, rpc_command);
}
+ t_enable_z_coin_cancel_answer
+ mm2_client::rpc_enable_z_coin_cancel(t_enable_z_coin_cancel_request&& request)
+ {
+ return process_rpc(std::forward(request), "task::enable_z_coin::cancel", true);
+ }
+
t_disable_coin_answer
mm2_client::rpc_disable_coin(t_disable_coin_request&& request)
{
diff --git a/src/core/atomicdex/api/mm2/mm2.client.hpp b/src/core/atomicdex/api/mm2/mm2.client.hpp
index 22f9a94c89..26a6b92672 100644
--- a/src/core/atomicdex/api/mm2/mm2.client.hpp
+++ b/src/core/atomicdex/api/mm2/mm2.client.hpp
@@ -11,6 +11,7 @@
#include "rpc.disable.hpp"
#include "rpc.recover.funds.hpp"
#include "rpc.hpp"
+#include "rpc2.task.enable_z_coin.cancel.hpp"
namespace atomic_dex::mm2
{
@@ -35,12 +36,13 @@ namespace atomic_dex::mm2
//! Synced
template
- TAnswer process_rpc(TRequest&& request, std::string rpc_command);
+ TAnswer process_rpc(TRequest&& request, std::string rpc_command, bool is_v2 = false);
template
RpcReturnType rpc_process_answer(const web::http::http_response& resp, const std::string& rpc_command);
- t_disable_coin_answer rpc_disable_coin(t_disable_coin_request&& request);
- t_recover_funds_of_swap_answer rpc_recover_funds(t_recover_funds_of_swap_request&& request);
+ t_disable_coin_answer rpc_disable_coin(t_disable_coin_request&& request);
+ t_recover_funds_of_swap_answer rpc_recover_funds(t_recover_funds_of_swap_request&& request);
+ t_enable_z_coin_cancel_answer rpc_enable_z_coin_cancel(t_enable_z_coin_cancel_request&& request);
};
} // namespace atomic_dex
\ No newline at end of file
diff --git a/src/core/atomicdex/api/mm2/mm2.cpp b/src/core/atomicdex/api/mm2/mm2.cpp
index d889bd07d1..4f8baa3321 100644
--- a/src/core/atomicdex/api/mm2/mm2.cpp
+++ b/src/core/atomicdex/api/mm2/mm2.cpp
@@ -26,8 +26,8 @@
#include "atomicdex/api/mm2/rpc.recover.funds.hpp"
#include "atomicdex/api/mm2/rpc.trade.preimage.hpp"
#include "atomicdex/api/mm2/rpc.validate.address.hpp"
-#include "atomicdex/api/mm2/rpc.withdraw.hpp"
-#include "atomicdex/api/mm2/rpc2.withdraw_status.hpp"
+#include "atomicdex/api/mm2/rpc2.withdraw.hpp"
+#include "atomicdex/api/mm2/rpc2.task.withdraw.status.hpp"
#include "atomicdex/api/mm2/rpc.recover.funds.hpp"
#include "atomicdex/pages/qt.settings.page.hpp"
#include "atomicdex/services/price/global.provider.hpp"
diff --git a/src/core/atomicdex/api/mm2/mm2.hpp b/src/core/atomicdex/api/mm2/mm2.hpp
index ae8c9f170d..4c55afafe8 100644
--- a/src/core/atomicdex/api/mm2/mm2.hpp
+++ b/src/core/atomicdex/api/mm2/mm2.hpp
@@ -34,7 +34,7 @@ namespace ag = antara::gaming;
namespace atomic_dex::mm2
{
- inline constexpr const char* g_etherscan_proxy_endpoint = "https://komodo.live:3334";
+ inline constexpr const char* g_etherscan_proxy_endpoint = "https://komodo.earth:3334";
inline std::unique_ptr g_etherscan_proxy_http_client{
std::make_unique(FROM_STD_STR(g_etherscan_proxy_endpoint))};
inline std::unique_ptr g_qtum_proxy_http_client{
diff --git a/src/core/atomicdex/api/mm2/orderbook.order.contents.cpp b/src/core/atomicdex/api/mm2/orderbook.order.contents.cpp
index 7c066603fd..0da85f01c7 100644
--- a/src/core/atomicdex/api/mm2/orderbook.order.contents.cpp
+++ b/src/core/atomicdex/api/mm2/orderbook.order.contents.cpp
@@ -32,6 +32,15 @@ namespace atomic_dex::mm2
{
j.at("coin").get_to(contents.coin);
+ if (contents.coin.find("-segwit") != std::string::npos)
+ {
+ std::string uuid = j["uuid"];
+ contents.uuid = uuid + "-segwit";
+ }
+ else
+ {
+ j.at("uuid").get_to(contents.uuid);
+ }
if (j.at("address").contains("address_data"))
{
j.at("address").at("address_data").get_to(contents.address);
@@ -40,9 +49,7 @@ namespace atomic_dex::mm2
{
contents.address = "Shielded";
}
-
j.at("pubkey").get_to(contents.pubkey);
- j.at("uuid").get_to(contents.uuid);
j.at("is_mine").get_to(contents.is_mine);
j.at("price").at("decimal").get_to(contents.price);
diff --git a/src/core/atomicdex/api/mm2/rpc.electrum.cpp b/src/core/atomicdex/api/mm2/rpc.electrum.cpp
index dfea39b95b..9ac193efba 100644
--- a/src/core/atomicdex/api/mm2/rpc.electrum.cpp
+++ b/src/core/atomicdex/api/mm2/rpc.electrum.cpp
@@ -37,8 +37,14 @@ namespace atomic_dex::mm2
if (cfg.coin_type == CoinType::QRC20)
{
- j["swap_contract_address"] = cfg.is_testnet ? cfg.testnet_qrc_swap_contract_address : cfg.mainnet_qrc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.testnet_fallback_qrc_swap_contract_address : cfg.mainnet_fallback_qrc_swap_contract_address;
+ if (cfg.swap_contract_address.has_value())
+ {
+ j["swap_contract_address"] = cfg.swap_contract_address.value();
+ }
+ if (cfg.fallback_swap_contract_address.has_value())
+ {
+ j["fallback_swap_contract_address"] = cfg.fallback_swap_contract_address.value();
+ }
}
if (cfg.bchd_urls.has_value()) {
diff --git a/src/core/atomicdex/api/mm2/rpc.electrum.hpp b/src/core/atomicdex/api/mm2/rpc.electrum.hpp
index 1960e56ec3..86dc73d6ac 100644
--- a/src/core/atomicdex/api/mm2/rpc.electrum.hpp
+++ b/src/core/atomicdex/api/mm2/rpc.electrum.hpp
@@ -32,14 +32,12 @@ namespace atomic_dex::mm2
CoinType coin_type;
bool is_testnet{false};
bool with_tx_history{true};
- const std::string testnet_qrc_swap_contract_address{"0xba8b71f3544b93e2f681f996da519a98ace0107a"};
- const std::string testnet_fallback_qrc_swap_contract_address{testnet_qrc_swap_contract_address};
- const std::string mainnet_qrc_swap_contract_address{"0x2f754733acd6d753731c00fee32cb484551cc15d"};
- const std::string mainnet_fallback_qrc_swap_contract_address{mainnet_qrc_swap_contract_address};
+ std::optional swap_contract_address{std::nullopt};
+ std::optional fallback_swap_contract_address{std::nullopt};
std::optional address_format;
std::optional merge_params;
- std::optional> bchd_urls;
- std::optional allow_slp_unsafe_conf;
+ std::optional> bchd_urls;
+ std::optional allow_slp_unsafe_conf;
};
struct electrum_answer
diff --git a/src/core/atomicdex/api/mm2/rpc.enable.cpp b/src/core/atomicdex/api/mm2/rpc.enable.cpp
index 0722bb9c23..a553a8c85b 100644
--- a/src/core/atomicdex/api/mm2/rpc.enable.cpp
+++ b/src/core/atomicdex/api/mm2/rpc.enable.cpp
@@ -28,125 +28,40 @@ namespace atomic_dex::mm2
to_json(nlohmann::json& j, const enable_request& cfg)
{
j["coin"] = cfg.coin_name;
-
switch (cfg.coin_type)
{
case CoinType::ERC20:
{
j["gas_station_url"] = cfg.gas_station_url;
- j["urls"] = cfg.urls;
- j["swap_contract_address"] = cfg.is_testnet ? cfg.erc_testnet_swap_contract_address : cfg.erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.erc_testnet_fallback_swap_contract_address : cfg.erc_fallback_swap_contract_address;
- break;
}
case CoinType::Matic:
{
- j["gas_station_url"] = cfg.is_testnet ? cfg.testnet_matic_gas_station_url : cfg.matic_gas_station_url;
- j["gas_station_decimals"] = cfg.matic_gas_station_decimals;
- j["urls"] = cfg.urls;
- j["swap_contract_address"] = cfg.is_testnet ? cfg.matic_erc_testnet_swap_contract_address : cfg.matic_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.matic_erc_testnet_fallback_swap_contract_address : cfg.matic_erc_fallback_swap_contract_address;
- break;
- }
- case CoinType::Optimism:
- {
- j["urls"] = cfg.urls;
- j["swap_contract_address"] = cfg.optimism_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.optimism_erc_fallback_swap_contract_address;
- break;
- }
- case CoinType::Arbitrum:
- {
- j["urls"] = cfg.urls;
- j["swap_contract_address"] = cfg.arbitrum_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.arbitrum_erc_fallback_swap_contract_address;
- break;
- }
- case CoinType::BEP20:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.bnb_testnet_swap_contract_address : cfg.bnb_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.bnb_testnet_fallback_swap_contract_address : cfg.bnb_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::AVX20:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.avax_erc_testnet_swap_contract_address : cfg.avax_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.avax_erc_testnet_fallback_swap_contract_address : cfg.avax_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::FTM20:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.ftm_erc_testnet_swap_contract_address : cfg.ftm_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.ftm_erc_testnet_fallback_swap_contract_address : cfg.ftm_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::HRC20:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.one_erc_testnet_swap_contract_address : cfg.one_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.one_erc_testnet_fallback_swap_contract_address : cfg.one_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::Ubiq:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.ubiq_erc_testnet_swap_contract_address : cfg.ubiq_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.ubiq_erc_testnet_fallback_swap_contract_address : cfg.ubiq_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::KRC20:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.krc_erc_testnet_swap_contract_address : cfg.krc_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.krc_erc_testnet_fallback_swap_contract_address : cfg.krc_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::Moonriver:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.movr_erc_testnet_swap_contract_address : cfg.movr_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.movr_erc_testnet_fallback_swap_contract_address : cfg.movr_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::Moonbeam:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.glmr_erc_testnet_swap_contract_address : cfg.glmr_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.glmr_erc_testnet_fallback_swap_contract_address : cfg.glmr_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::HecoChain:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.hco_erc_testnet_swap_contract_address : cfg.hco_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.hco_erc_testnet_fallback_swap_contract_address : cfg.hco_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::SmartBCH:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.sbch_erc_testnet_swap_contract_address : cfg.sbch_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.sbch_erc_testnet_fallback_swap_contract_address : cfg.sbch_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::EthereumClassic:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.etc_erc_testnet_swap_contract_address : cfg.etc_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.etc_erc_testnet_fallback_swap_contract_address : cfg.etc_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
- }
- case CoinType::RSK:
- {
- j["swap_contract_address"] = cfg.is_testnet ? cfg.rsk_erc_testnet_swap_contract_address : cfg.rsk_erc_swap_contract_address;
- j["fallback_swap_contract"] = cfg.is_testnet ? cfg.rsk_erc_testnet_fallback_swap_contract_address : cfg.rsk_erc_fallback_swap_contract_address;
- j["urls"] = cfg.urls;
- break;
+ if (cfg.is_testnet)
+ {
+ if (cfg.testnet_matic_gas_station_url.has_value())
+ {
+ j["gas_station_url"] = cfg.testnet_matic_gas_station_url.value();
+ }
+ }
+ else
+ {
+ if (cfg.matic_gas_station_url.has_value())
+ {
+ j["gas_station_url"] = cfg.matic_gas_station_url.value();
+ }
+ }
+ if (cfg.matic_gas_station_decimals.has_value())
+ {
+ j["gas_station_decimals"] = cfg.matic_gas_station_decimals.value();
+ }
}
default:
+ j["urls"] = cfg.urls;
+ j["swap_contract_address"] = cfg.swap_contract_address;
+ if (cfg.fallback_swap_contract_address.has_value())
+ {
+ j["fallback_swap_contract"] = cfg.fallback_swap_contract_address.value();
+ }
break;
}
diff --git a/src/core/atomicdex/api/mm2/rpc.enable.hpp b/src/core/atomicdex/api/mm2/rpc.enable.hpp
index 2b7d3274e3..9d5a14486d 100644
--- a/src/core/atomicdex/api/mm2/rpc.enable.hpp
+++ b/src/core/atomicdex/api/mm2/rpc.enable.hpp
@@ -17,6 +17,7 @@
#pragma once
//! Deps
+#include
#include
//! Project Headers
@@ -27,76 +28,18 @@ namespace atomic_dex::mm2
//! Only for erc 20
struct enable_request
{
- std::string coin_name;
- std::vector urls;
- CoinType coin_type;
- bool is_testnet{false};
- const std::string erc_swap_contract_address{"0x24ABE4c71FC658C91313b6552cd40cD808b3Ea80"};
- const std::string erc_testnet_swap_contract_address{"0x6b5A52217006B965BB190864D62dc3d270F7AaFD"};
- const std::string erc_fallback_swap_contract_address{"0x8500AFc0bc5214728082163326C2FF0C73f4a871"};
- const std::string erc_testnet_fallback_swap_contract_address{"0x7Bc1bBDD6A0a722fC9bffC49c921B685ECB84b94"};
- const std::string etc_erc_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string etc_erc_testnet_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string etc_erc_fallback_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string etc_erc_testnet_fallback_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string ubiq_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string ubiq_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string ubiq_erc_testnet_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string ubiq_erc_testnet_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string krc_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string krc_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string krc_erc_testnet_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string krc_erc_testnet_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string movr_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string movr_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string movr_erc_testnet_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string movr_erc_testnet_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string glmr_erc_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string glmr_erc_fallback_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string glmr_erc_testnet_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string glmr_erc_testnet_fallback_swap_contract_address{"0x6d9ce4BD298DE38bAfEFD15f5C6f5c95313B1d94"};
- const std::string hco_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string hco_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string hco_erc_testnet_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string hco_erc_testnet_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string avax_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string avax_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string avax_erc_testnet_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string avax_erc_testnet_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string one_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string one_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string one_erc_testnet_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string one_erc_testnet_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string ftm_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string ftm_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string ftm_erc_testnet_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string ftm_erc_testnet_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string matic_erc_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string matic_erc_fallback_swap_contract_address{"0x9130b257D37A52E52F21054c4DA3450c72f595CE"};
- const std::string matic_erc_testnet_swap_contract_address{"0x73c1Dd989218c3A154C71Fc08Eb55A24Bd2B3A10"};
- const std::string matic_erc_testnet_fallback_swap_contract_address{"0x73c1Dd989218c3A154C71Fc08Eb55A24Bd2B3A10"};
- const std::string optimism_erc_swap_contract_address{"0x9130b257d37a52e52f21054c4da3450c72f595ce"};
- const std::string optimism_erc_fallback_swap_contract_address{"0x9130b257d37a52e52f21054c4da3450c72f595ce"};
- const std::string arbitrum_erc_swap_contract_address{"0x9130b257d37a52e52f21054c4da3450c72f595ce"};
- const std::string arbitrum_erc_fallback_swap_contract_address{"0x9130b257d37a52e52f21054c4da3450c72f595ce"};
- const std::string sbch_erc_swap_contract_address{"0x25bF2AAB8749AD2e4360b3e0B738f3Cd700C4D68"};
- const std::string sbch_erc_fallback_swap_contract_address{"0x25bF2AAB8749AD2e4360b3e0B738f3Cd700C4D68"};
- const std::string sbch_erc_testnet_swap_contract_address{"0x25bF2AAB8749AD2e4360b3e0B738f3Cd700C4D68"};
- const std::string sbch_erc_testnet_fallback_swap_contract_address{"0x25bF2AAB8749AD2e4360b3e0B738f3Cd700C4D68"};
- const std::string rsk_erc_swap_contract_address{"0x6D9CE4bD298de38Bafefd15F5C6F5c95313B1d94"};
- const std::string rsk_erc_fallback_swap_contract_address{"0x6D9CE4bD298de38Bafefd15F5C6F5c95313B1d94"};
- const std::string rsk_erc_testnet_swap_contract_address{"0x6D9CE4bD298de38Bafefd15F5C6F5c95313B1d94"};
- const std::string rsk_erc_testnet_fallback_swap_contract_address{"0x6D9CE4bD298de38Bafefd15F5C6F5c95313B1d94"};
- const std::string bnb_testnet_swap_contract_address{"0xcCD17C913aD7b772755Ad4F0BDFF7B34C6339150"};
- const std::string bnb_swap_contract_address{"0xeDc5b89Fe1f0382F9E4316069971D90a0951DB31"};
- const std::string bnb_fallback_swap_contract_address{bnb_swap_contract_address};
- const std::string bnb_testnet_fallback_swap_contract_address{bnb_testnet_swap_contract_address};
- const std::size_t matic_gas_station_decimals{9};
- std::string gas_station_url{"https://ethgasstation.info/json/ethgasAPI.json"};
- std::string matic_gas_station_url{"https://gasstation-mainnet.matic.network/"};
- std::string testnet_matic_gas_station_url{"https://gasstation-mumbai.matic.today/"};
- std::string type; ///< QRC-20 ?
- bool with_tx_history{true};
+ std::string coin_name;
+ std::vector urls;
+ CoinType coin_type;
+ bool is_testnet{false};
+ const std::string swap_contract_address;
+ std::optional fallback_swap_contract_address{std::nullopt};
+ std::optional matic_gas_station_decimals{9};
+ std::string gas_station_url{"https://ethgasstation.info/json/ethgasAPI.json"};
+ std::optional matic_gas_station_url{std::nullopt};
+ std::optional testnet_matic_gas_station_url{std::nullopt};
+ std::optional type; ///< QRC-20 ?
+ bool with_tx_history{true};
};
void to_json(nlohmann::json& j, const enable_request& cfg);
diff --git a/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_token.cpp b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_token.cpp
new file mode 100644
index 0000000000..d20efa4132
--- /dev/null
+++ b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_token.cpp
@@ -0,0 +1,25 @@
+#include
+
+#include "rpc2.enable_tendermint_token.hpp"
+
+namespace atomic_dex::mm2
+{
+ void to_json(nlohmann::json& j, const enable_tendermint_token_rpc_request& request)
+ {
+ j["ticker"] = request.ticker;
+ if (request.activation_params.required_confirmations)
+ {
+ j["activation_params"]["required_confirmations"] = *request.activation_params.required_confirmations;
+ }
+ else
+ {
+ j["activation_params"] = nlohmann::json::object();
+ }
+ }
+
+ 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>(in.balances);
+ }
+}
\ No newline at end of file
diff --git a/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_token.hpp b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_token.hpp
new file mode 100644
index 0000000000..1f8845ed1f
--- /dev/null
+++ b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_token.hpp
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * Copyright © 2013-2022 The Komodo Platform Developers. *
+ * *
+ * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
+ * the top-level directory of this distribution for the individual copyright *
+ * holder information and the developer policies on copyright and licensing. *
+ * *
+ * Unless otherwise agreed in a custom licensing agreement, no part of the *
+ * Komodo Platform software, including this file may be copied, modified, *
+ * propagated or distributed except according to the terms contained in the *
+ * LICENSE file *
+ * *
+ * Removal or modification of this copyright notice is prohibited. *
+ * *
+ ******************************************************************************/
+
+#pragma once
+
+#include
+
+#include //> nlohmann::json
+
+#include "rpc.hpp"
+#include "balance_info.hpp"
+
+namespace atomic_dex::mm2
+{
+ struct enable_tendermint_token_rpc
+ {
+ static constexpr auto endpoint = "enable_tendermint_token";
+ static constexpr bool is_v2 = true;
+
+ struct expected_request_type
+ {
+ std::string ticker;
+ struct { std::optional required_confirmations; } activation_params;
+ };
+
+ struct expected_result_type
+ {
+ std::string platform_coin;
+ std::unordered_map balances;
+ };
+
+ using expected_error_type = rpc_basic_error_type;
+
+ expected_request_type request;
+ std::optional result;
+ std::optional error;
+ };
+
+ using enable_tendermint_token_rpc_request = enable_tendermint_token_rpc::expected_request_type;
+ using enable_tendermint_token_rpc_result = enable_tendermint_token_rpc::expected_result_type;
+ using enable_tendermint_token_rpc_error = enable_tendermint_token_rpc::expected_error_type;
+
+ void to_json(nlohmann::json& j, const enable_tendermint_token_rpc_request& request);
+ void from_json(const nlohmann::json& j, enable_tendermint_token_rpc_result& in);
+}
\ No newline at end of file
diff --git a/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_with_assets.cpp b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_with_assets.cpp
new file mode 100644
index 0000000000..b924bbe656
--- /dev/null
+++ b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_with_assets.cpp
@@ -0,0 +1,39 @@
+#include
+
+#include "rpc2.enable_tendermint_with_assets.hpp"
+
+namespace atomic_dex::mm2
+{
+ void to_json(nlohmann::json& j, const enable_tendermint_with_assets_request_rpc& in)
+ {
+ j["ticker"] = in.ticker;
+ j["rpc_urls"] = in.rpc_urls;
+ j["tx_history"] = in.tx_history;
+ j["tokens_params"] = in.tokens_params;
+ if (in.required_confirmations.has_value())
+ j["required_confirmations"] = in.required_confirmations.value();
+ if (in.requires_notarization.has_value())
+ j["requires_notarization"] = in.requires_notarization.value();
+ }
+
+ void to_json(nlohmann::json& j, const enable_tendermint_with_assets_request_rpc::tendermint_token_request_t& in)
+ {
+ j["ticker"] = in.ticker;
+ if (in.required_confirmations)
+ j["required_confirmations"] = in.required_confirmations.value();
+ }
+
+ void from_json(const nlohmann::json& json, enable_tendermint_with_assets_result_rpc& out)
+ {
+ out.address = json["address"];
+ out.current_block = json["current_block"];
+ out.tendermint_balances_infos = json["balance"].get();
+ out.tendermint_token_balances_infos = json["tokens_balances"].get();
+ }
+
+ void from_json(const nlohmann::json& json, enable_tendermint_with_assets_result_rpc::tendermint_balance_infos_t& out)
+ {
+ out.balances.spendable = json["spendable"];
+ out.balances.unspendable = json["unspendable"];
+ }
+}
\ No newline at end of file
diff --git a/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_with_assets.hpp b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_with_assets.hpp
new file mode 100644
index 0000000000..c65408658f
--- /dev/null
+++ b/src/core/atomicdex/api/mm2/rpc2.enable_tendermint_with_assets.hpp
@@ -0,0 +1,60 @@
+#pragma once
+
+#include
+
+#include "rpc.hpp"
+#include "balance_info.hpp"
+#include "atomicdex/config/electrum.cfg.hpp"
+
+namespace atomic_dex::mm2
+{
+ struct enable_tendermint_with_assets_rpc
+ {
+ static constexpr auto endpoint = "enable_tendermint_with_assets";
+ static constexpr bool is_v2 = true;
+
+ struct expected_request_type
+ {
+ struct tendermint_token_request_t
+ {
+ std::string ticker;
+ std::optional required_confirmations;
+ };
+
+ std::string ticker;
+ std::vector rpc_urls;
+ bool tx_history{true};
+ std::vector tokens_params;
+ std::optional required_confirmations;
+ std::optional requires_notarization;
+ };
+
+ struct expected_result_type
+ {
+ struct tendermint_balance_infos_t
+ {
+ balance_info balances;
+ };
+
+ std::string address;
+ std::size_t current_block;
+ tendermint_balance_infos_t tendermint_balances_infos;
+ std::unordered_map tendermint_token_balances_infos;
+ };
+
+ using expected_error_type = rpc_basic_error_type;
+
+ expected_request_type request;
+ std::optional result;
+ std::optional error;
+ };
+
+ using enable_tendermint_with_assets_request_rpc = enable_tendermint_with_assets_rpc::expected_request_type;
+ using enable_tendermint_with_assets_result_rpc = enable_tendermint_with_assets_rpc::expected_result_type;
+ using enable_tendermint_with_assets_error_rpc = enable_tendermint_with_assets_rpc::expected_error_type;
+
+ void to_json(nlohmann::json& j, const enable_tendermint_with_assets_request_rpc& in);
+ void to_json(nlohmann::json& j, const enable_tendermint_with_assets_request_rpc::tendermint_token_request_t& in);
+ void from_json(const nlohmann::json& json, enable_tendermint_with_assets_result_rpc& out);
+ void from_json(const nlohmann::json& json, enable_tendermint_with_assets_result_rpc::tendermint_balance_infos_t& out);
+}
\ No newline at end of file
diff --git a/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.cancel.cpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.cancel.cpp
new file mode 100644
index 0000000000..1c2a90f384
--- /dev/null
+++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.cancel.cpp
@@ -0,0 +1,53 @@
+/******************************************************************************
+ * Copyright © 2013-2022 The Komodo Platform Developers. *
+ * *
+ * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
+ * the top-level directory of this distribution for the individual copyright *
+ * holder information and the developer policies on copyright and licensing. *
+ * *
+ * Unless otherwise agreed in a custom licensing agreement, no part of the *
+ * Komodo Platform software, including this file may be copied, modified, *
+ * propagated or distributed except according to the terms contained in the *
+ * LICENSE file *
+ * *
+ * Removal or modification of this copyright notice is prohibited. *
+ * *
+ ******************************************************************************/
+
+//! Deps
+#include
+
+//! Project Headers
+#include "atomicdex/api/mm2/rpc2.task.enable_z_coin.cancel.hpp"
+
+//! Implementation 2.0 RPC [enable_z_coin_cancel]
+namespace atomic_dex::mm2
+{
+ //! Serialization
+ void to_json(nlohmann::json& j, const enable_z_coin_cancel_request& request)
+ {
+ j["params"]["task_id"] = request.task_id;
+ }
+
+ //! Deserialization
+ void from_json(const nlohmann::json& j, enable_z_coin_cancel_answer_success& answer)
+ {
+ answer.result = j.at("result").get();
+ }
+
+ void
+ from_json(const nlohmann::json& j, enable_z_coin_cancel_answer& answer)
+ {
+ if (j.count("error") >= 1)
+ {
+ answer.error = j;
+ }
+ else
+ {
+ if (j.contains("result") && j.contains("mmrpc") && j.at("mmrpc").get() == "2.0")
+ {
+ answer.result = j.get();
+ }
+ }
+ }
+} // namespace atomic_dex::mm2
diff --git a/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.cancel.hpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.cancel.hpp
new file mode 100644
index 0000000000..fa6976dfc3
--- /dev/null
+++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.cancel.hpp
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * Copyright © 2013-2022 The Komodo Platform Developers. *
+ * *
+ * See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
+ * the top-level directory of this distribution for the individual copyright *
+ * holder information and the developer policies on copyright and licensing. *
+ * *
+ * Unless otherwise agreed in a custom licensing agreement, no part of the *
+ * Komodo Platform software, including this file may be copied, modified, *
+ * propagated or distributed except according to the terms contained in the *
+ * LICENSE file *
+ * *
+ * Removal or modification of this copyright notice is prohibited. *
+ * *
+ ******************************************************************************/
+
+#pragma once
+
+// Std Headers
+#include
+
+// Deps Headers
+#include
+
+//! Project Headers
+#include "generic.error.hpp"
+
+namespace atomic_dex::mm2
+{
+ struct enable_z_coin_cancel_request
+ {
+ int task_id;
+ };
+
+ void to_json(nlohmann::json& j, const enable_z_coin_cancel_request& request);
+
+ struct enable_z_coin_cancel_answer_success
+ {
+ std::string result;
+ };
+
+ void from_json(const nlohmann::json& j, enable_z_coin_cancel_answer_success& answer);
+
+ struct enable_z_coin_cancel_answer
+ {
+ std::optional result;
+ std::optional error;
+ std::string raw_result; ///< internal
+ int rpc_result_code; ///< internal
+ };
+
+ void from_json(const nlohmann::json& j, enable_z_coin_cancel_answer& answer);
+}
+
+namespace atomic_dex
+{
+ using t_enable_z_coin_cancel_request = mm2::enable_z_coin_cancel_request;
+ using t_enable_z_coin_cancel_answer = mm2::enable_z_coin_cancel_answer;
+ using t_enable_z_coin_cancel_answer_success = mm2::enable_z_coin_cancel_answer_success;
+} // namespace atomic_dex
\ No newline at end of file
diff --git a/src/core/atomicdex/api/mm2/rpc2.init_z_coin.cpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.cpp
similarity index 88%
rename from src/core/atomicdex/api/mm2/rpc2.init_z_coin.cpp
rename to src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.cpp
index 6c61b672eb..c349150d4a 100644
--- a/src/core/atomicdex/api/mm2/rpc2.init_z_coin.cpp
+++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.cpp
@@ -18,13 +18,13 @@
#include
//! Project Headers
-#include "atomicdex/api/mm2/rpc2.init_z_coin.hpp"
+#include "atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp"
-//! Implementation 2.0 RPC [init_z_coin]
+//! Implementation 2.0 RPC [enable_z_coin]
namespace atomic_dex::mm2
{
//! Serialization
- void to_json(nlohmann::json& j, const init_z_coin_request& request)
+ void to_json(nlohmann::json& j, const enable_z_coin_request& request)
{
j["params"]["ticker"] = request.coin_name;
j["params"]["activation_params"]["mode"]["rpc"] = "Light";
@@ -34,7 +34,7 @@ namespace atomic_dex::mm2
}
//! Deserialization
- void from_json(const nlohmann::json& j, init_z_coin_answer& answer)
+ void from_json(const nlohmann::json& j, enable_z_coin_answer& answer)
{
j.at("task_id").get_to(answer.task_id);
}
diff --git a/src/core/atomicdex/api/mm2/rpc2.init_z_coin.hpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp
similarity index 85%
rename from src/core/atomicdex/api/mm2/rpc2.init_z_coin.hpp
rename to src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp
index d7fe101369..a0e953fd8c 100644
--- a/src/core/atomicdex/api/mm2/rpc2.init_z_coin.hpp
+++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp
@@ -28,7 +28,7 @@
namespace atomic_dex::mm2
{
- struct init_z_coin_request
+ struct enable_z_coin_request
{
std::string coin_name;
std::vector servers;
@@ -38,17 +38,17 @@ namespace atomic_dex::mm2
bool with_tx_history{false}; // Not yet in API
};
- struct init_z_coin_answer
+ struct enable_z_coin_answer
{
int task_id;
};
- void to_json(nlohmann::json& j, const init_z_coin_request& request);
- void from_json(const nlohmann::json& j, init_z_coin_answer& answer);
+ void to_json(nlohmann::json& j, const enable_z_coin_request& request);
+ void from_json(const nlohmann::json& j, enable_z_coin_answer& answer);
}
namespace atomic_dex
{
- using t_init_z_coin_request = mm2::init_z_coin_request;
- using t_init_z_coin_answer = mm2::init_z_coin_answer;
+ using t_enable_z_coin_request = mm2::enable_z_coin_request;
+ using t_enable_z_coin_answer = mm2::enable_z_coin_answer;
} // namespace atomic_dex
diff --git a/src/core/atomicdex/api/mm2/rpc2.init_z_coin_status.cpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.status.cpp
similarity index 75%
rename from src/core/atomicdex/api/mm2/rpc2.init_z_coin_status.cpp
rename to src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.status.cpp
index ded987e419..eff12d0753 100644
--- a/src/core/atomicdex/api/mm2/rpc2.init_z_coin_status.cpp
+++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.status.cpp
@@ -18,19 +18,20 @@
#include
//! Project Headers
-#include "atomicdex/api/mm2/rpc2.init_z_coin_status.hpp"
+#include "atomicdex/api/mm2/rpc2.task.enable_z_coin.status.hpp"
-//! Implementation 2.0 RPC [init_z_coin_status]
+//! Implementation 2.0 RPC [enable_z_coin_status]
namespace atomic_dex::mm2
{
//! Serialization
- void to_json(nlohmann::json& j, const init_z_coin_status_request& request)
+ void to_json(nlohmann::json& j, const enable_z_coin_status_request& request)
{
j["params"]["task_id"] = request.task_id;
+ j["params"]["forget_if_finished"] = false;
}
//! Deserialization
- void from_json(const nlohmann::json& j, init_z_coin_status_answer_success& answer)
+ void from_json(const nlohmann::json& j, enable_z_coin_status_answer_success& answer)
{
j.at("result").at("status").get_to(answer.status); // [InProgress, Ready]
j.at("result").at("details").get_to(answer.details);
@@ -48,21 +49,21 @@ namespace atomic_dex::mm2
if (j.at("result").at("details").contains("result"))
{
- answer.coin = j.at("result").at("details").at("result").at("ticker").get();
- answer.current_block = j.at("result").at("details").at("result").at("current_block").get();
+ answer.coin = j.at("result").at("details").at("ticker").get();
+ answer.current_block = j.at("result").at("details").at("current_block").get();
- if (j.at("result").at("details").at("result").contains("wallet_balance"))
+ if (j.at("result").at("details").contains("wallet_balance"))
{
- answer.wallet_type = j.at("result").at("details").at("result").at("wallet_balance").at("wallet_type").get();
- answer.address = j.at("result").at("details").at("result").at("wallet_balance").at("address").get();
- answer.spendable_balance = j.at("result").at("details").at("result").at("wallet_balance").at("balance").at("spendable").get();
- answer.unspendable_balance = j.at("result").at("details").at("result").at("wallet_balance").at("balance").at("unspendable").get();
+ answer.wallet_type = j.at("result").at("details").at("wallet_balance").at("wallet_type").get();
+ answer.address = j.at("result").at("details").at("wallet_balance").at("address").get();
+ answer.spendable_balance = j.at("result").at("details").at("wallet_balance").at("balance").at("spendable").get();
+ answer.unspendable_balance = j.at("result").at("details").at("wallet_balance").at("balance").at("unspendable").get();
}
}
}
void
- from_json(const nlohmann::json& j, init_z_coin_status_answer& answer)
+ from_json(const nlohmann::json& j, enable_z_coin_status_answer& answer)
{
if (j.count("error") >= 1)
{
@@ -72,7 +73,7 @@ namespace atomic_dex::mm2
{
if (j.contains("result") && j.contains("mmrpc") && j.at("mmrpc").get() == "2.0")
{
- answer.result = j.at("result").get();
+ answer.result = j.at("result").get();
}
}
}
diff --git a/src/core/atomicdex/api/mm2/rpc2.init_z_coin_status.hpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.status.hpp
similarity index 75%
rename from src/core/atomicdex/api/mm2/rpc2.init_z_coin_status.hpp
rename to src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.status.hpp
index 845c5e6356..e55735448f 100644
--- a/src/core/atomicdex/api/mm2/rpc2.init_z_coin_status.hpp
+++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.status.hpp
@@ -27,14 +27,14 @@
namespace atomic_dex::mm2
{
- struct init_z_coin_status_request
+ struct enable_z_coin_status_request
{
int task_id;
};
- void to_json(nlohmann::json& j, const init_z_coin_status_request& request);
+ void to_json(nlohmann::json& j, const enable_z_coin_status_request& request);
- struct init_z_coin_status_answer_success
+ struct enable_z_coin_status_answer_success
{
std::string status{"disabled"};
std::string details{"N/A"};
@@ -48,22 +48,22 @@ namespace atomic_dex::mm2
std::optional unspendable_balance;
};
- void from_json(const nlohmann::json& j, init_z_coin_status_answer_success& answer);
+ void from_json(const nlohmann::json& j, enable_z_coin_status_answer_success& answer);
- struct init_z_coin_status_answer
+ struct enable_z_coin_status_answer
{
- std::optional result;
+ std::optional result;
std::optional error;
std::string raw_result; ///< internal
int rpc_result_code; ///< internal
};
- void from_json(const nlohmann::json& j, init_z_coin_status_answer& answer);
+ void from_json(const nlohmann::json& j, enable_z_coin_status_answer& answer);
}
namespace atomic_dex
{
- using t_init_z_coin_status_request = mm2::init_z_coin_status_request;
- using t_init_z_coin_status_answer = mm2::init_z_coin_status_answer;
- using t_init_z_coin_status_answer_success = mm2::init_z_coin_status_answer_success;
+ using t_enable_z_coin_status_request = mm2::enable_z_coin_status_request;
+ using t_enable_z_coin_status_answer = mm2::enable_z_coin_status_answer;
+ using t_enable_z_coin_status_answer_success = mm2::enable_z_coin_status_answer_success;
} // namespace atomic_dex
diff --git a/src/core/atomicdex/api/mm2/rpc2.init_withdraw.cpp b/src/core/atomicdex/api/mm2/rpc2.task.withdraw.init.cpp
similarity index 82%
rename from src/core/atomicdex/api/mm2/rpc2.init_withdraw.cpp
rename to src/core/atomicdex/api/mm2/rpc2.task.withdraw.init.cpp
index b42ca76fb2..29d44086fe 100644
--- a/src/core/atomicdex/api/mm2/rpc2.init_withdraw.cpp
+++ b/src/core/atomicdex/api/mm2/rpc2.task.withdraw.init.cpp
@@ -18,20 +18,20 @@
#include
//! Project Headers
-#include "atomicdex/api/mm2/rpc2.init_withdraw.hpp"
+#include "atomicdex/api/mm2/rpc2.task.withdraw.init.hpp"
-//! Implementation 2.0 RPC [init_withdraw]
+//! Implementation 2.0 RPC [withdraw_init]
namespace atomic_dex::mm2
{
void
- to_json(nlohmann::json& j, const init_withdraw_fees& request)
+ to_json(nlohmann::json& j, const withdraw_init_fees& request)
{
j["type"] = request.type;
j["amount"] = request.amount.value();
}
//! Serialization
- void to_json(nlohmann::json& j, const init_withdraw_request& request)
+ void to_json(nlohmann::json& j, const withdraw_init_request& request)
{
nlohmann::json obj = nlohmann::json::object();
@@ -40,6 +40,10 @@ namespace atomic_dex::mm2
obj["params"]["amount"] = request.amount;
obj["params"]["max"] = request.max;
+ if (request.memo.has_value())
+ {
+ obj["params"]["memo"] = request.memo.value();
+ }
if (request.fees.has_value())
{
obj["params"]["fee"] = request.fees.value();
@@ -48,7 +52,7 @@ namespace atomic_dex::mm2
}
//! Deserialization
- void from_json(const nlohmann::json& j, init_withdraw_answer& answer)
+ void from_json(const nlohmann::json& j, withdraw_init_answer& answer)
{
j.at("task_id").get_to(answer.task_id);
}
diff --git a/src/core/atomicdex/api/mm2/rpc2.init_withdraw.hpp b/src/core/atomicdex/api/mm2/rpc2.task.withdraw.init.hpp
similarity index 76%
rename from src/core/atomicdex/api/mm2/rpc2.init_withdraw.hpp
rename to src/core/atomicdex/api/mm2/rpc2.task.withdraw.init.hpp
index 2f214f6de9..88558fd1cd 100644
--- a/src/core/atomicdex/api/mm2/rpc2.init_withdraw.hpp
+++ b/src/core/atomicdex/api/mm2/rpc2.task.withdraw.init.hpp
@@ -24,33 +24,34 @@
namespace atomic_dex::mm2
{
- struct init_withdraw_fees
+ struct withdraw_init_fees
{
std::string type; ///< UtxoFixed, UtxoPerKbyte, EthGas, Qrc20Gas
std::optional amount; ///< Utxo only
};
- struct init_withdraw_request
+ struct withdraw_init_request
{
std::string coin;
std::string to;
std::string amount;
- std::optional fees{std::nullopt}; ///< ignored if std::nullopt
+ std::optional fees{std::nullopt}; ///< ignored if std::nullopt
+ std::optional memo; ///< memo for zhtlc
bool max{false};
};
- struct init_withdraw_answer
+ struct withdraw_init_answer
{
int task_id;
};
- void to_json(nlohmann::json& j, const init_withdraw_request& request);
- void from_json(const nlohmann::json& j, init_withdraw_answer& answer);
+ void to_json(nlohmann::json& j, const withdraw_init_request& request);
+ void from_json(const nlohmann::json& j, withdraw_init_answer& answer);
}
namespace atomic_dex
{
- using t_init_withdraw_request = mm2::init_withdraw_request;
- using t_init_withdraw_fees = mm2::init_withdraw_fees;
- using t_init_withdraw_answer = mm2::init_withdraw_answer;
+ using t_withdraw_init_request = mm2::withdraw_init_request;
+ using t_withdraw_init_fees = mm2::withdraw_init_fees;
+ using t_withdraw_init_answer = mm2::withdraw_init_answer;
} // namespace atomic_dex
diff --git a/src/core/atomicdex/api/mm2/rpc2.withdraw_status.cpp b/src/core/atomicdex/api/mm2/rpc2.task.withdraw.status.cpp
similarity index 90%
rename from src/core/atomicdex/api/mm2/rpc2.withdraw_status.cpp
rename to src/core/atomicdex/api/mm2/rpc2.task.withdraw.status.cpp
index c38d5cfbe0..9df0b7b0af 100644
--- a/src/core/atomicdex/api/mm2/rpc2.withdraw_status.cpp
+++ b/src/core/atomicdex/api/mm2/rpc2.task.withdraw.status.cpp
@@ -18,7 +18,7 @@
#include
//! Project Headers
-#include "atomicdex/api/mm2/rpc2.withdraw_status.hpp"
+#include "atomicdex/api/mm2/rpc2.task.withdraw.status.hpp"
//! Implementation 2.0 RPC [withdraw_status]
namespace atomic_dex::mm2
@@ -27,6 +27,7 @@ namespace atomic_dex::mm2
void to_json(nlohmann::json& j, const withdraw_status_request& request)
{
j["params"]["task_id"] = request.task_id;
+ j["params"]["forget_if_finished"] = false;
}
//! Deserialization
@@ -38,7 +39,7 @@ namespace atomic_dex::mm2
}
else
{
- answer.result = j.at("result").at("details").at("result").get();
+ answer.result = j.at("result").at("details").get();
}
}
} // namespace atomic_dex::mm2
diff --git a/src/core/atomicdex/api/mm2/rpc2.withdraw_status.hpp b/src/core/atomicdex/api/mm2/rpc2.task.withdraw.status.hpp
similarity index 100%
rename from src/core/atomicdex/api/mm2/rpc2.withdraw_status.hpp
rename to src/core/atomicdex/api/mm2/rpc2.task.withdraw.status.hpp
diff --git a/src/core/atomicdex/api/mm2/rpc.withdraw.cpp b/src/core/atomicdex/api/mm2/rpc2.withdraw.cpp
similarity index 66%
rename from src/core/atomicdex/api/mm2/rpc.withdraw.cpp
rename to src/core/atomicdex/api/mm2/rpc2.withdraw.cpp
index a37bd5c91d..cdf6ccf902 100644
--- a/src/core/atomicdex/api/mm2/rpc.withdraw.cpp
+++ b/src/core/atomicdex/api/mm2/rpc2.withdraw.cpp
@@ -6,7 +6,7 @@
#include
//! Our Headers
-#include "rpc.withdraw.hpp"
+#include "rpc2.withdraw.hpp"
namespace atomic_dex::mm2
{
@@ -41,22 +41,19 @@ namespace atomic_dex::mm2
{
nlohmann::json obj = nlohmann::json::object();
- obj["coin"] = cfg.coin;
- obj["amount"] = cfg.amount;
- obj["to"] = cfg.to;
- obj["max"] = cfg.max;
- if (cfg.fees.has_value())
- {
- obj["fee"] = cfg.fees.value();
- }
- if (j.contains("mmrpc") && j.at("mmrpc").get() == "2.0")
+ obj["params"]["coin"] = cfg.coin;
+ obj["params"]["amount"] = cfg.amount;
+ obj["params"]["to"] = cfg.to;
+ obj["params"]["max"] = cfg.max;
+ if (cfg.memo.has_value())
{
- j["params"] = obj;
+ obj["params"]["memo"] = cfg.memo.value();
}
- else
+ if (cfg.fees.has_value())
{
- j.update(obj);
+ obj["params"]["fee"] = cfg.fees.value();
}
+ j.update(obj);
}
void
@@ -68,14 +65,7 @@ namespace atomic_dex::mm2
}
else
{
- if (j.contains("result") && j.contains("mmrpc") && j.at("mmrpc").get() == "2.0")
- {
- answer.result = j.at("result").get();
- }
- else
- {
- answer.result = j.get();
- }
+ answer.result = j.at("result").get();
}
}
} // namespace atomic_dex::mm2
\ No newline at end of file
diff --git a/src/core/atomicdex/api/mm2/rpc.withdraw.hpp b/src/core/atomicdex/api/mm2/rpc2.withdraw.hpp
similarity index 95%
rename from src/core/atomicdex/api/mm2/rpc.withdraw.hpp
rename to src/core/atomicdex/api/mm2/rpc2.withdraw.hpp
index d424c7c825..51b9a687d8 100644
--- a/src/core/atomicdex/api/mm2/rpc.withdraw.hpp
+++ b/src/core/atomicdex/api/mm2/rpc2.withdraw.hpp
@@ -28,6 +28,7 @@ namespace atomic_dex::mm2
std::string to; ///< coins will be withdraw to this address
std::string amount; ///< ignored if max is true
std::optional fees{std::nullopt}; ///< ignored if std::nullopt
+ std::optional memo; ///< memo for tendermint
bool max{false};
};
diff --git a/src/core/atomicdex/api/mm2/transaction.data.cpp b/src/core/atomicdex/api/mm2/transaction.data.cpp
index 54dbf4b2e8..fd140e4667 100644
--- a/src/core/atomicdex/api/mm2/transaction.data.cpp
+++ b/src/core/atomicdex/api/mm2/transaction.data.cpp
@@ -18,6 +18,14 @@ namespace atomic_dex::mm2
j.at("total_fee").get_to(cfg.total_fee);
}
+ void from_json(const nlohmann::json& j, fee_tendermint_coin& cfg)
+ {
+ j.at("coin").get_to(cfg.coin);
+ j.at("type").get_to(cfg.type);
+ j.at("amount").get_to(cfg.amount);
+ j.at("gas_limit").get_to(cfg.gas_limit);
+ }
+
void from_json(const nlohmann::json& j, fee_qrc_coin& cfg)
{
j.at("coin").get_to(cfg.coin);
@@ -78,6 +86,20 @@ namespace atomic_dex::mm2
cfg.confirmations = j.at("confirmations").get();
}
+ // API returns null if no memo
+ if (j.contains("memo"))
+ {
+ try
+ {
+ cfg.memo = j.at("memo").get();
+ }
+ catch (const std::exception& ex)
+ {
+ cfg.memo = "";
+ //SPDLOG_ERROR("Error parsing memo: {}", ex.what());
+ }
+ }
+
if (cfg.from.empty())
{
if (cfg.coin == "FIRO")
@@ -90,6 +112,11 @@ namespace atomic_dex::mm2
}
}
+ if (j.contains("transaction_type"))
+ {
+ cfg.transaction_type = j.at("transaction_type").get();
+ }
+
// transaction_fee only in ZHTLC response
if (j.contains("transaction_fee"))
{
diff --git a/src/core/atomicdex/api/mm2/transaction.data.hpp b/src/core/atomicdex/api/mm2/transaction.data.hpp
index 9882c9a532..a39f64b9fd 100644
--- a/src/core/atomicdex/api/mm2/transaction.data.hpp
+++ b/src/core/atomicdex/api/mm2/transaction.data.hpp
@@ -25,6 +25,16 @@ namespace atomic_dex::mm2
void from_json(const nlohmann::json& j, fee_erc_coin& cfg);
+ struct fee_tendermint_coin
+ {
+ std::string type;
+ std::string coin;
+ std::string amount;
+ std::size_t gas_limit;
+ };
+
+ void from_json(const nlohmann::json& j, fee_erc_coin& cfg);
+
struct fee_qrc_coin
{
std::string coin;
@@ -38,9 +48,10 @@ namespace atomic_dex::mm2
struct fees_data
{
- std::optional normal_fees; ///< btc, kmd based coins
- std::optional erc_fees; ///< eth based coins
- std::optional qrc_fees; // Qtum based coin
+ std::optional normal_fees; ///< btc, kmd based coins
+ std::optional erc_fees; ///< eth based coins
+ std::optional qrc_fees; // Qtum based coin
+ std::optional tendermint_fees; // Qtum based coin
};
void from_json(const nlohmann::json& j, fees_data& cfg);
@@ -48,21 +59,23 @@ namespace atomic_dex::mm2
struct transaction_data
{
std::size_t timestamp;
+ std::string tx_hex;
+ std::string tx_hash;
std::vector from;
std::vector to;
- fees_data fee_details;
- std::size_t block_height;
- std::string coin;
+ std::string total_amount{"0"};
std::string spent_by_me;
std::string received_by_me;
std::string my_balance_change;
- std::string total_amount{"0"};
- std::string tx_hash;
- std::string tx_hex;
- std::string timestamp_as_date; ///< human readeable timestamp
+ std::size_t block_height;
+ fees_data fee_details;
+ std::string coin;
std::optional transaction_fee;
std::optional internal_id;
std::optional confirmations;
+ std::optional transaction_type;
+ std::optional memo;
+ std::string timestamp_as_date; ///< human readeable timestamp
};
void from_json(const nlohmann::json& j, transaction_data& cfg);
diff --git a/src/core/atomicdex/config/app.cfg.cpp b/src/core/atomicdex/config/app.cfg.cpp
index c4b25502cb..d60580bb58 100644
--- a/src/core/atomicdex/config/app.cfg.cpp
+++ b/src/core/atomicdex/config/app.cfg.cpp
@@ -48,6 +48,7 @@ namespace
config_json_data["current_fiat_sign"] = config.current_fiat_sign;
config_json_data["available_signs"] = config.available_currency_signs;
config_json_data["notification_enabled"] = config.notification_enabled;
+ config_json_data["spamfilter_enabled"] = config.spamfilter_enabled;
file.close();
@@ -71,6 +72,15 @@ namespace atomic_dex
j.at("available_signs").get_to(config.available_currency_signs);
j.at("current_fiat_sign").get_to(config.current_fiat_sign);
j.at("notification_enabled").get_to(config.notification_enabled);
+
+ if (j.contains("spamfilter_enabled"))
+ {
+ j.at("spamfilter_enabled").get_to(config.spamfilter_enabled);
+ }
+ else
+ {
+ config.spamfilter_enabled = true;
+ }
}
void
@@ -83,6 +93,16 @@ namespace atomic_dex
}
}
+ void
+ change_spamfilter_status(cfg& config, bool is_enabled)
+ {
+ if (config.spamfilter_enabled != is_enabled)
+ {
+ config.spamfilter_enabled = is_enabled;
+ upgrade_cfg(config);
+ }
+ }
+
cfg
load_cfg()
{
diff --git a/src/core/atomicdex/config/app.cfg.hpp b/src/core/atomicdex/config/app.cfg.hpp
index 3edd54cfa6..e5286d9095 100644
--- a/src/core/atomicdex/config/app.cfg.hpp
+++ b/src/core/atomicdex/config/app.cfg.hpp
@@ -31,12 +31,14 @@ namespace atomic_dex
std::vector available_fiat;
std::vector possible_currencies;
bool notification_enabled;
+ bool spamfilter_enabled{false};
};
void from_json(const nlohmann::json& j, cfg& config);
void change_currency(cfg& config, const std::string& new_currency);
void change_fiat(cfg& config, const std::string& new_fiat);
void change_notification_status(cfg& config, bool is_enabled);
+ void change_spamfilter_status(cfg& config, bool is_enabled);
[[nodiscard]] bool is_this_currency_a_fiat(const cfg& config, const std::string& currency);
cfg load_cfg();
std::string retrieve_sign_from_ticker(const cfg& config, const std::string& currency);
diff --git a/src/core/atomicdex/config/coins.cfg.cpp b/src/core/atomicdex/config/coins.cfg.cpp
index e688c3293d..6ec8039b6b 100644
--- a/src/core/atomicdex/config/coins.cfg.cpp
+++ b/src/core/atomicdex/config/coins.cfg.cpp
@@ -23,7 +23,8 @@
namespace
{
- CoinType get_coin_type_from_str(const std::string& coin_type)
+ CoinType
+ get_coin_type_from_str(const std::string& coin_type)
{
if (coin_type == "QRC-20")
{
@@ -33,6 +34,10 @@ namespace
{
return CoinType::ERC20;
}
+ if (coin_type == "EWT")
+ {
+ return CoinType::EWT;
+ }
if (coin_type == "UTXO")
{
return CoinType::UTXO;
@@ -105,6 +110,14 @@ namespace
{
return CoinType::RSK;
}
+ if (coin_type == "TENDERMINT")
+ {
+ return CoinType::TENDERMINT;
+ }
+ if (coin_type == "TENDERMINTTOKEN")
+ {
+ return CoinType::TENDERMINTTOKEN;
+ }
if (coin_type == "ZHTLC")
{
return CoinType::ZHTLC;
@@ -113,18 +126,25 @@ namespace
return CoinType::Invalid;
// throw std::invalid_argument{"Undefined given coin type."};
}
-}
+} // namespace
namespace atomic_dex
{
- bool is_wallet_only(std::string ticker)
+ bool
+ is_wallet_only(std::string ticker)
{
return std::any_of(g_wallet_only_coins.begin(), g_wallet_only_coins.end(), [ticker](std::string x) { return ticker == x; });
}
- bool is_default_coin(std::string ticker)
+ bool
+ is_default_coin(std::string ticker)
{
return std::any_of(g_default_coins.begin(), g_default_coins.end(), [ticker](std::string x) { return ticker == x; });
}
+ bool
+ is_faucet_coin(std::string ticker)
+ {
+ return std::any_of(g_faucet_coins.begin(), g_faucet_coins.end(), [ticker](std::string x) { return ticker == x; });
+ }
void
from_json(const nlohmann::json& j, coin_config& cfg)
@@ -135,28 +155,27 @@ namespace atomic_dex
cfg.coin_type = get_coin_type_from_str(cfg.type);
j.at("active").get_to(cfg.active);
j.at("explorer_url").get_to(cfg.explorer_url);
-
+ cfg.has_memos = false;
cfg.gui_ticker = j.contains("gui_coin") ? j.at("gui_coin").get() : cfg.ticker;
+ cfg.parent_coin = j.contains("parent_coin") ? j.at("parent_coin").get() : cfg.ticker;
cfg.minimal_claim_amount = cfg.is_claimable ? j.at("minimal_claim_amount").get() : "0";
cfg.coinpaprika_id = j.contains("coinpaprika_id") ? j.at("coinpaprika_id").get() : "test-coin";
cfg.coingecko_id = j.contains("coingecko_id") ? j.at("coingecko_id").get() : "test-coin";
- cfg.livecoinwatch_id = j.contains("livecoinwatch_id") ? j.at("livecoinwatch_id").get() : "test-coin";
+ cfg.livecoinwatch_id = j.contains("livecoinwatch_id") ? j.at("livecoinwatch_id").get() : "test-coin";
cfg.is_claimable = j.count("is_claimable") > 0;
cfg.is_custom_coin = j.contains("is_custom_coin") ? j.at("is_custom_coin").get() : false;
cfg.is_testnet = j.contains("is_testnet") ? j.at("is_testnet").get() : false;
cfg.wallet_only = is_wallet_only(cfg.ticker) ? is_wallet_only(cfg.ticker) : j.contains("wallet_only") ? j.at("wallet_only").get() : false;
cfg.default_coin = is_default_coin(cfg.ticker);
+ cfg.is_faucet_coin = is_faucet_coin(cfg.ticker);
if (j.contains("other_types"))
{
std::vector other_types;
-
+
j.at("other_types").get_to(other_types);
cfg.other_types = std::set();
- for (const auto& other_type : other_types)
- {
- cfg.other_types->emplace(get_coin_type_from_str(other_type));
- }
+ for (const auto& other_type: other_types) { cfg.other_types->emplace(get_coin_type_from_str(other_type)); }
}
if (j.contains("utxo_merge"))
{
@@ -182,12 +201,19 @@ namespace atomic_dex
if (j.contains("nodes"))
{
// Todo: this is bad, we are using 2 times the required memory. Something can be improved here.
- cfg.urls = j.at("nodes").get>();
+ cfg.urls = j.at("nodes").get>();
cfg.eth_family_urls = std::vector();
cfg.eth_family_urls.value().reserve(cfg.urls.value().size());
- for (const auto& url : cfg.urls.value())
+ for (const auto& url: cfg.urls.value()) { cfg.eth_family_urls->push_back(url.url); }
+ }
+ if (j.contains("rpc_urls"))
+ {
+ auto rpc_urls_obj = j.at("rpc_urls").get>();
+ std::vector rpc_urls_list;
+ cfg.rpc_urls = rpc_urls_list;
+ for (const auto& url : rpc_urls_obj)
{
- cfg.eth_family_urls->push_back(url.url);
+ cfg.rpc_urls->push_back(url.url);
}
}
if (j.contains("allow_slp_unsafe_conf"))
@@ -198,17 +224,11 @@ namespace atomic_dex
if (j.contains("light_wallet_d_servers"))
{
cfg.z_urls = j.at("light_wallet_d_servers").get>();
- }
- if (j.contains("is_segwit_on"))
- {
- cfg.segwit = true;
- j.at("is_segwit_on").get_to(cfg.is_segwit_on);
- SPDLOG_INFO("coin: {} support segwit with current_segwit mode: {}", cfg.ticker, cfg.is_segwit_on);
- }
- if (j.contains("alias_ticker"))
+ } if (j.contains("alias_ticker"))
{
cfg.alias_ticker = j.at("alias_ticker").get();
}
+ // Explorer url suffixes
if (j.contains("explorer_tx_url"))
{
j.at("explorer_tx_url").get_to(cfg.tx_uri);
@@ -217,6 +237,33 @@ namespace atomic_dex
{
j.at("explorer_address_url").get_to(cfg.address_url);
}
+ // Swap contract addresses
+ if (j.contains("swap_contract_address"))
+ {
+ cfg.swap_contract_address = j["swap_contract_address"];
+ }
+ if (j.contains("fallback_swap_contract_address"))
+ {
+ cfg.fallback_swap_contract_address = j["fallback_swap_contract_address"];
+ }
+ // Gas station urls
+ if (j.contains("gas_station_url"))
+ {
+ cfg.gas_station_url = j.at("gas_station_url").get();
+ }
+ if (j.contains("matic_gas_station_url"))
+ {
+ cfg.matic_gas_station_url = j.at("matic_gas_station_url").get();
+ }
+ if (j.contains("testnet_matic_gas_station_url"))
+ {
+ cfg.testnet_matic_gas_station_url = j.at("testnet_matic_gas_station_url").get();
+ }
+ if (j.contains("matic_gas_station_decimals"))
+ {
+ cfg.matic_gas_station_decimals = j.at("matic_gas_station_decimals").get();
+ }
+
switch (cfg.coin_type)
{
@@ -249,6 +296,11 @@ namespace atomic_dex
cfg.fees_ticker = "ETH-ARB20";
cfg.is_erc_family = true;
break;
+ case CoinType::EWT:
+ cfg.has_parent_fees_ticker = true;
+ cfg.fees_ticker = "EWT";
+ cfg.is_erc_family = true;
+ break;
case CoinType::AVX20:
cfg.has_parent_fees_ticker = true;
cfg.fees_ticker = cfg.is_testnet.value() ? "AVAXT" : "AVAX";
@@ -308,10 +360,21 @@ namespace atomic_dex
cfg.has_parent_fees_ticker = true;
cfg.fees_ticker = cfg.is_testnet.value() ? "tBCH" : "BCH";
break;
+ case CoinType::TENDERMINT:
+ cfg.has_parent_fees_ticker = true;
+ cfg.fees_ticker = cfg.parent_coin;
+ cfg.has_memos = true;
+ break;
+ case CoinType::TENDERMINTTOKEN:
+ cfg.has_parent_fees_ticker = true;
+ cfg.fees_ticker = cfg.parent_coin;
+ cfg.has_memos = true;
+ break;
case CoinType::ZHTLC:
cfg.has_parent_fees_ticker = false;
cfg.is_zhtlc_family = true;
cfg.fees_ticker = cfg.ticker;
+ cfg.has_memos = true;
break;
case CoinType::Invalid:
cfg.has_parent_fees_ticker = false;
@@ -324,13 +387,12 @@ namespace atomic_dex
}
}
- void print_coins(std::vector coins)
+ void
+ print_coins(std::vector coins)
{
std::stringstream ss;
ss << "[";
- for (auto&& coin: coins) {
- ss << coin.ticker << " ";
- }
+ for (auto&& coin: coins) { ss << coin.ticker << " "; }
ss << "]";
SPDLOG_INFO("{}", ss.str());
}
diff --git a/src/core/atomicdex/config/coins.cfg.hpp b/src/core/atomicdex/config/coins.cfg.hpp
index 4ec95f07dc..e1e2f7c348 100644
--- a/src/core/atomicdex/config/coins.cfg.hpp
+++ b/src/core/atomicdex/config/coins.cfg.hpp
@@ -33,49 +33,59 @@ namespace atomic_dex
struct coin_config
{
static constexpr const char* erc_gas_stations = "https://ethgasstation.info/json/ethgasAPI.json";
- static constexpr const char* matic_gas_stations = "https://gasstation-mainnet.matic.network/";
+ std::optional matic_gas_stations{std::nullopt};
using electrum_servers = std::vector;
using nodes = std::vector;
+ using url_list = std::vector;
using eth_family_url_list = std::vector;
using bchd_url_list = std::vector;
using light_wallet_d_servers = std::vector; ///< For ZHTLC
- std::string ticker;
- std::optional alias_ticker{std::nullopt};
- std::string gui_ticker; ///< Ticker displayed in the gui
- std::string name; ///< nice name
- std::optional utxo_merge{false};
- std::optional allow_slp_unsafe_conf;
- std::optional urls;
- std::optional eth_family_urls;
- std::optional bchd_urls;
- std::optional electrum_urls;
- std::optional z_urls;
- bool is_claimable{false};
- std::string minimal_claim_amount{"0"};
- bool currently_enabled{false};
- bool active{false};
- std::string coinpaprika_id{"test-coin"};
- std::string coingecko_id{"test-coin"};
- std::string livecoinwatch_id{"test-coin"};
- bool is_custom_coin{false};
- std::string type;
- std::optional> other_types;
- std::string explorer_url; ///< usefull for transaction, take this url and append transaction id
- std::string tx_uri{"tx/"};
- std::string address_url{"address/"};
- std::optional custom_backup;
- nlohmann::json activation_status;
- std::optional is_testnet{false}; ///< True if testnet (tBTC, tQTUM, QRC-20 on testnet, tETH)
- CoinType coin_type;
- bool checked{false};
- bool wallet_only{false};
- bool has_parent_fees_ticker{false}; ///< True if parent fees is different from current ticker eg: ERC20 tokens
- std::string fees_ticker;
- bool segwit{false};
- bool is_segwit_on{false};
- bool is_erc_family{false};
- bool is_zhtlc_family{false};
- bool default_coin{false};
+ std::string ticker;
+ std::string gui_ticker; ///< Ticker displayed in the gui
+ std::string name; ///< nice name
+ std::string parent_coin;
+ std::string fees_ticker;
+ std::string type;
+ std::string coinpaprika_id{"test-coin"};
+ std::string coingecko_id{"test-coin"};
+ std::string livecoinwatch_id{"test-coin"};
+ std::string explorer_url;
+ std::string tx_uri{"tx/"};
+ std::string address_url{"address/"};
+ std::string minimal_claim_amount{"0"};
+ CoinType coin_type;
+ nlohmann::json activation_status;
+ bool segwit{false};
+ bool active{false};
+ bool checked{false};
+ bool wallet_only{false};
+ bool is_claimable{false};
+ bool has_memos{false};
+ bool is_custom_coin{false};
+ bool is_faucet_coin{false};
+ bool currently_enabled{false};
+ bool has_parent_fees_ticker{false}; ///< True if parent fees is different from current ticker eg: ERC20 tokens
+ bool is_erc_family{false};
+ bool is_zhtlc_family{false};
+ bool default_coin{false};
+ std::optional alias_ticker{std::nullopt};
+ std::optional allow_slp_unsafe_conf;
+ std::optional is_testnet{false}; ///< True if testnet (tBTC, tQTUM, QRC-20 on testnet, tETH)
+ std::optional utxo_merge{false};
+ std::optional swap_contract_address{std::nullopt};
+ std::optional fallback_swap_contract_address{std::nullopt};
+ std::optional gas_station_url{std::nullopt};
+ std::optional matic_gas_station_url{std::nullopt};
+ std::optional testnet_matic_gas_station_url{std::nullopt};
+ std::optional matic_gas_station_decimals{std::nullopt};
+ std::optional custom_backup;
+ std::optional> other_types;
+ std::optional electrum_urls;
+ std::optional urls;
+ std::optional rpc_urls;
+ std::optional z_urls;
+ std::optional eth_family_urls;
+ std::optional bchd_urls;
};
void from_json(const nlohmann::json& j, coin_config& cfg);
@@ -83,4 +93,5 @@ namespace atomic_dex
void print_coins(std::vector