From d707f748f399bb3f4e062dd0ac4adc52d04aa7d2 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 21 Sep 2023 12:40:56 +0800 Subject: [PATCH 1/2] add "use date" toogle --- CMakeLists.txt | 6 ++--- .../Dex/Settings/SettingModal.qml | 22 +++++++++++++++++++ src/app/main.prerequisites.hpp | 1 + .../api/mm2/rpc2.task.enable_z_coin.init.cpp | 5 ++++- .../api/mm2/rpc2.task.enable_z_coin.init.hpp | 2 +- src/core/atomicdex/pages/qt.settings.page.cpp | 9 ++++++-- src/core/atomicdex/pages/qt.settings.page.hpp | 2 ++ .../atomicdex/services/mm2/mm2.service.cpp | 19 +++++++++++----- 8 files changed, 54 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2266087583..49f7aae673 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,13 +60,13 @@ endif () ##! We fetch our dependencies if (APPLE) FetchContent_Declare(mm2 - URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v1.0.7-beta/mm2-79f620559-Darwin-Release.zip) + URL https://sdk.devbuilds.komodo.earth/dev/mm2_bd69fbd-mac-x86-64.zip) elseif (UNIX AND NOT APPLE) FetchContent_Declare(mm2 - URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v1.0.7-beta/mm2-79f620559-Linux-Release.zip) + URL https://sdk.devbuilds.komodo.earth/dev/mm2_bd69fbd-linux-x86-64.zip) else () FetchContent_Declare(mm2 - URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v1.0.7-beta/mm2-79f620559-Win64.zip) + URL https://sdk.devbuilds.komodo.earth/dev/mm2_bd69fbd-win-x86-64.zip) endif () #FetchContent_Declare(qmaterial URL https://github.com/KomodoPlatform/Qaterial/archive/last-clang-working-2.zip) diff --git a/atomic_defi_design/Dex/Settings/SettingModal.qml b/atomic_defi_design/Dex/Settings/SettingModal.qml index b4a1dd3d83..98778cada9 100644 --- a/atomic_defi_design/Dex/Settings/SettingModal.qml +++ b/atomic_defi_design/Dex/Settings/SettingModal.qml @@ -317,9 +317,31 @@ Qaterial.Dialog Item { Layout.fillWidth: true } + DefaultCheckBox + { + id: use_sync_date_checkbox + + spacing: 2 + + label.wrapMode: Label.NoWrap + label.font.pixelSize: 14 + text: qsTr("use date sync") + textColor: Dex.CurrentTheme.foregroundColor2 + Component.onCompleted: checked = API.app.settings_pg.get_use_sync_date() + onToggled: { + atomic_settings2.setValue( + "UseSyncDate", + checked + ) + } + } + + Item { Layout.fillWidth: true } + DatePicker { id: sync_date + enabled: use_sync_date_checkbox.checked titleText: qsTr("Sync Date") minimumDate: default_min_date maximumDate: default_max_date diff --git a/src/app/main.prerequisites.hpp b/src/app/main.prerequisites.hpp index 1cf9cc9d09..1a57f1b0ba 100644 --- a/src/app/main.prerequisites.hpp +++ b/src/app/main.prerequisites.hpp @@ -347,6 +347,7 @@ handle_settings(QSettings& settings) create_settings_functor("2FA", 0); create_settings_functor("MaximumNbCoinsEnabled", 50); create_settings_functor("PirateSyncDate", timestamp); + create_settings_functor("UseSyncDate", false); create_settings_functor("DefaultTradingMode", TradingMode::Simple); create_settings_functor("FontMode", QQuickWindow::TextRenderType::QtTextRendering); } diff --git a/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.cpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.cpp index a4eadae928..3b826d086f 100644 --- a/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.cpp +++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.cpp @@ -28,7 +28,10 @@ namespace atomic_dex::mm2 { j["params"]["ticker"] = request.coin_name; j["params"]["activation_params"]["mode"]["rpc"] = "Light"; - j["params"]["activation_params"]["mode"]["rpc_data"]["sync_params"]["height"] = request.sync_height; + if (request.sync_height.has_value()) + { + j["params"]["activation_params"]["mode"]["rpc_data"]["sync_params"]["height"] = request.sync_height.value(); + } j["params"]["activation_params"]["mode"]["rpc_data"]["electrum_servers"] = request.servers; j["params"]["activation_params"]["mode"]["rpc_data"]["light_wallet_d_servers"] = request.z_urls; j["params"]["activation_params"]["scan_blocks_per_iteration"] = 5000; diff --git a/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp index 7fa02c2f92..c20bfc5b10 100644 --- a/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp +++ b/src/core/atomicdex/api/mm2/rpc2.task.enable_z_coin.init.hpp @@ -34,7 +34,7 @@ namespace atomic_dex::mm2 std::vector servers; std::vector z_urls; CoinType coin_type; - int sync_height{0}; + std::optional sync_height; bool is_testnet{false}; bool with_tx_history{false}; // Not yet in API }; diff --git a/src/core/atomicdex/pages/qt.settings.page.cpp b/src/core/atomicdex/pages/qt.settings.page.cpp index c1767dae3a..eff63c2949 100644 --- a/src/core/atomicdex/pages/qt.settings.page.cpp +++ b/src/core/atomicdex/pages/qt.settings.page.cpp @@ -79,6 +79,11 @@ namespace atomic_dex { void settings_page::update() {} } // Getters|Setters namespace atomic_dex { + bool settings_page::get_use_sync_date() const + { + QSettings& settings = entity_registry_.ctx(); + return settings.value("UseSyncDate").toBool(); + } int settings_page::get_pirate_sync_date() const { QSettings& settings = entity_registry_.ctx(); @@ -108,10 +113,10 @@ namespace atomic_dex return height; } - void settings_page::set_pirate_sync_date(int new_timestamp) + void settings_page::set_pirate_sync_date(int new_value) { QSettings& settings = entity_registry_.ctx(); - settings.setValue("PirateSyncDate", new_timestamp); + settings.setValue("UseSyncDate", new_value); settings.sync(); } diff --git a/src/core/atomicdex/pages/qt.settings.page.hpp b/src/core/atomicdex/pages/qt.settings.page.hpp index 50035ca337..bd2bbaf947 100644 --- a/src/core/atomicdex/pages/qt.settings.page.hpp +++ b/src/core/atomicdex/pages/qt.settings.page.hpp @@ -81,6 +81,7 @@ namespace atomic_dex [[nodiscard]] QString get_current_currency_sign() const; [[nodiscard]] QString get_current_fiat_sign() const; [[nodiscard]] QString get_current_fiat() const; + void set_use_sync_date(int new_value); void set_pirate_sync_date(int new_timestamp); [[nodiscard]] bool is_notification_enabled() const; void set_notification_enabled(bool is_enabled); @@ -109,6 +110,7 @@ namespace atomic_dex Q_INVOKABLE [[nodiscard]] bool is_this_ticker_present_in_raw_cfg(const QString& ticker) const; Q_INVOKABLE [[nodiscard]] bool is_this_ticker_present_in_normal_cfg(const QString& ticker) const; Q_INVOKABLE [[nodiscard]] QString get_custom_coins_icons_path() const; + Q_INVOKABLE [[nodiscard]] bool get_use_sync_date() const; Q_INVOKABLE [[nodiscard]] int get_pirate_sync_date() const; Q_INVOKABLE [[nodiscard]] int get_pirate_sync_height(int sync_date, int checkpoint_height, int checkpoint_blocktime) const; Q_INVOKABLE void process_token_add(const QString& contract_address, const QString& coingecko_id, const QString& icon_filepath, CoinType coin_type); diff --git a/src/core/atomicdex/services/mm2/mm2.service.cpp b/src/core/atomicdex/services/mm2/mm2.service.cpp index b60eceee82..3ac6c47978 100644 --- a/src/core/atomicdex/services/mm2/mm2.service.cpp +++ b/src/core/atomicdex/services/mm2/mm2.service.cpp @@ -1403,23 +1403,32 @@ namespace atomic_dex auto request_functor = [this](coin_config coin_info) -> std::pair> { const auto& settings_system = m_system_manager.get_system(); - int sync_date = settings_system.get_pirate_sync_date(); - int sync_height = settings_system.get_pirate_sync_height(sync_date, coin_info.checkpoint_height, coin_info.checkpoint_blocktime); - + t_enable_z_coin_request request{ .coin_name = coin_info.ticker, .servers = coin_info.electrum_urls.value_or(get_electrum_server_from_token(coin_info.ticker)), .z_urls = coin_info.z_urls.value_or(std::vector{}), .coin_type = coin_info.coin_type, - .sync_height = sync_height, .is_testnet = coin_info.is_testnet.value_or(false), .with_tx_history = false}; // Tx history not yet ready for ZHTLC + bool use_date = settings_system.get_use_sync_date(); + SPDLOG_INFO("use_date: {}", use_date); + if (use_date) + { + int sync_date = settings_system.get_pirate_sync_date(); + int sync_height = settings_system.get_pirate_sync_height( + sync_date, + coin_info.checkpoint_height, + coin_info.checkpoint_blocktime + ); + request.sync_height = sync_height; + } nlohmann::json j = mm2::template_request("task::enable_z_coin::init", true); mm2::to_json(j, request); nlohmann::json batch = nlohmann::json::array(); batch.push_back(j); - // SPDLOG_INFO("ZHTLC request: {}", batch.dump(4)); + SPDLOG_INFO("ZHTLC request: {}", batch.dump(4)); return {batch, {coin_info.ticker}}; }; From b1d08f78571dd1d9e5652ae22feb9b3d511259d3 Mon Sep 17 00:00:00 2001 From: smk762 Date: Wed, 11 Oct 2023 15:26:19 +0800 Subject: [PATCH 2/2] update api and coins --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49f7aae673..047db9be7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,13 +60,13 @@ endif () ##! We fetch our dependencies if (APPLE) FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/dev/mm2_bd69fbd-mac-x86-64.zip) + URL https://sdk.devbuilds.komodo.earth/dev/mm2_a9f606d-mac-x86-64.zip) elseif (UNIX AND NOT APPLE) FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/dev/mm2_bd69fbd-linux-x86-64.zip) + URL https://sdk.devbuilds.komodo.earth/dev/mm2_a9f606d-linux-x86-64.zip) else () FetchContent_Declare(mm2 - URL https://sdk.devbuilds.komodo.earth/dev/mm2_bd69fbd-win-x86-64.zip) + URL https://sdk.devbuilds.komodo.earth/dev/mm2_a9f606d-win-x86-64.zip) endif () #FetchContent_Declare(qmaterial URL https://github.com/KomodoPlatform/Qaterial/archive/last-clang-working-2.zip) @@ -78,7 +78,7 @@ FetchContent_Declare( ) FetchContent_Declare(jl777-coins - URL https://github.com/KomodoPlatform/coins/archive/ssl-only-coins-config.zip) + URL https://github.com/KomodoPlatform/coins/archive/master.zip) #FetchContent_Declare(adex-generics-coins # URL https://github.com/KomodoPlatform/komodo-wallet-desktop/archive/main.zip) @@ -87,12 +87,12 @@ FetchContent_MakeAvailable(mm2 jl777-coins qmaterial) ##! Configure our needs. if (UNIX) - configure_file(${jl777-coins_SOURCE_DIR}/utils/coins_config.json ${CMAKE_CURRENT_SOURCE_DIR}/assets/config/${PROJECT_VERSION}-coins.json COPYONLY) + configure_file(${jl777-coins_SOURCE_DIR}/utils/coins_config_tcp.json ${CMAKE_CURRENT_SOURCE_DIR}/assets/config/${PROJECT_VERSION}-coins.json COPYONLY) configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/mm2/coins COPYONLY) configure_file(${mm2_SOURCE_DIR}/mm2 ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/mm2/${DEX_API} COPYONLY) file(COPY ${jl777-coins_SOURCE_DIR}/icons/ DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/atomic_defi_design/assets/images/coins/) else () - configure_file(${jl777-coins_SOURCE_DIR}/utils/coins_config.json ${CMAKE_BINARY_DIR}/bin/assets/config/${PROJECT_VERSION}-coins.json COPYONLY) + configure_file(${jl777-coins_SOURCE_DIR}/utils/coins_config_tcp.json ${CMAKE_BINARY_DIR}/bin/assets/config/${PROJECT_VERSION}-coins.json COPYONLY) configure_file(${jl777-coins_SOURCE_DIR}/coins ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/coins COPYONLY) configure_file(${mm2_SOURCE_DIR}/mm2.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/${DEX_API}.exe COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/msvcp140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/mm2/msvcp140.dll COPYONLY)