From e0ddba782dfbfe7de82fabb01761eed61feae198 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 12 Aug 2024 15:53:55 +0800 Subject: [PATCH 01/17] update version to 0.8.0 --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/workflows/atomicdex-desktop-cd.yml | 2 +- .github/workflows/atomicdex-desktop-ci.yml | 2 +- CMakeLists.txt | 2 +- cmake/project.metadata.cmake | 2 +- src/core/atomicdex/constants/dex.constants.hpp | 12 +----------- src/core/atomicdex/version/version.hpp | 8 ++++---- vcpkg.json | 2 +- 8 files changed, 11 insertions(+), 21 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 623343db29..c83aeedff8 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -26,7 +26,7 @@ Please describe what you expected to happen. **Operating Environment(s):** - OS: [e.g. Windows/OSX/Linux. If Linux, include distro. ] - OS version: [e.g. 7/10/11, 10.13/10.15, 18.04/20.04 ] - - Komodo Wallet Desktop Version: [e.g. 0.7.2] + - Komodo Wallet Desktop Version: [e.g. 0.8.0] - Build branch: [e.g. master/dev] diff --git a/.github/workflows/atomicdex-desktop-cd.yml b/.github/workflows/atomicdex-desktop-cd.yml index f5050b8e31..18d8bc396b 100644 --- a/.github/workflows/atomicdex-desktop-cd.yml +++ b/.github/workflows/atomicdex-desktop-cd.yml @@ -9,7 +9,7 @@ env: DEX_PROJECT_NAME: "komodo-wallet" DEX_DISPLAY_NAME: "Komodo Wallet" DEX_COMPANY: "KomodoPlatform" - DEX_VERSION: "0.7.2" + DEX_VERSION: "0.8.0" DEX_WEBSITE: "https://atomicdex.io/" jobs: diff --git a/.github/workflows/atomicdex-desktop-ci.yml b/.github/workflows/atomicdex-desktop-ci.yml index 45c8fa9ec1..6446916b4a 100644 --- a/.github/workflows/atomicdex-desktop-ci.yml +++ b/.github/workflows/atomicdex-desktop-ci.yml @@ -17,7 +17,7 @@ env: DEX_PROJECT_NAME: "komodo-wallet" DEX_DISPLAY_NAME: "Komodo Wallet" DEX_COMPANY: "KomodoPlatform" - DEX_VERSION: "0.7.2" + DEX_VERSION: "0.8.0" DEX_WEBSITE: "https://atomicdex.io/" VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/b/vcpkg_cache VCPKG_BINARY_SOURCES: clear;x-gha,readwrite diff --git a/CMakeLists.txt b/CMakeLists.txt index 35f69d82e0..9f3c1ca020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,7 @@ include(vcpkg_prerequisites) include(qt_prerequisites) include(cfg_hash) -project(${DEX_PROJECT_NAME} LANGUAGES CXX VERSION 0.7.2) +project(${DEX_PROJECT_NAME} LANGUAGES CXX VERSION 0.8.0) message(STATUS "${PROJECT_NAME} is version ${PROJECT_VERSION}") include(cmake_default_options) diff --git a/cmake/project.metadata.cmake b/cmake/project.metadata.cmake index e15cabe5e2..b799e8dbfd 100644 --- a/cmake/project.metadata.cmake +++ b/cmake/project.metadata.cmake @@ -7,7 +7,7 @@ set(DEX_DISPLAY_NAME "Komodo Wallet") set(DEX_MAINTENANCE_TOOL_NAME "Komodo Wallet Maintenance Tool") set(DEX_COMPANY "KomodoPlatform") set(DEX_WEBSITE "https://atomicdex.io/") -set(DEX_VERSION "0.7.2") +set(DEX_VERSION "0.8.0") set(DEX_SUPPORT_PAGE "https://support.komodoplatform.com/support/home") set(DEX_DISCORD "https://komodoplatform.com/discord") set(DEX_TWITTER "https://twitter.com/AtomicDEX") diff --git a/src/core/atomicdex/constants/dex.constants.hpp b/src/core/atomicdex/constants/dex.constants.hpp index 99ed0c8c23..e9a8cc18bf 100644 --- a/src/core/atomicdex/constants/dex.constants.hpp +++ b/src/core/atomicdex/constants/dex.constants.hpp @@ -11,8 +11,7 @@ namespace atomic_dex g_primary_dex_coin, g_second_primary_dex_coin, "BTC-segwit", - "DGB-segwit", - "VOTE2024", + "DGB-segwit" }; inline const std::vector g_faucet_coins{ "DOC", @@ -21,12 +20,7 @@ namespace atomic_dex "IRISTEST", }; inline const std::vector g_vote_coins{ - "KIP0002", - "KIP0003", - "KIP0004", - "VOTE2024", }; - inline const std::vector g_wallet_only_coins{ "ARRR-BEP20", "RBTC", @@ -34,10 +28,6 @@ namespace atomic_dex "PAXG-ERC20", "USDT-ERC20", "XPM", - "KIP0002", - "KIP0003", - "KIP0004", - "VOTE2024", "ATOM" }; } diff --git a/src/core/atomicdex/version/version.hpp b/src/core/atomicdex/version/version.hpp index 55dd6fcdd0..921a490787 100644 --- a/src/core/atomicdex/version/version.hpp +++ b/src/core/atomicdex/version/version.hpp @@ -21,24 +21,24 @@ namespace atomic_dex constexpr const char* get_version() { - return "0.7.2-beta"; + return "0.8.0-beta"; } constexpr int get_num_version() noexcept { - return 72; + return 80; } constexpr const char* get_raw_version() { - return "0.7.2"; + return "0.8.0"; } constexpr const char* get_precedent_raw_version() { - return "0.7.1"; + return "0.7.2"; } } // namespace atomic_dex diff --git a/vcpkg.json b/vcpkg.json index 6d6777bd47..d53535cd46 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,6 +1,6 @@ { "name": "komodo-wallet-desktop", - "version-string": "0.7.2", + "version-string": "0.8.0", "dependencies": [ "entt", "boost-multiprecision", From 182582b86485eadac45e12069fe2585341af5542 Mon Sep 17 00:00:00 2001 From: smk762 Date: Sat, 17 Aug 2024 22:49:18 +0800 Subject: [PATCH 02/17] Fix pro view order form overflow --- atomic_defi_design/Dex/Components/DexTextField.qml | 2 ++ .../Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml | 6 ++++-- atomic_defi_design/Dex/Wallet/SendResult.qml | 2 +- atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/atomic_defi_design/Dex/Components/DexTextField.qml b/atomic_defi_design/Dex/Components/DexTextField.qml index 1764675b85..1aafddd2e2 100644 --- a/atomic_defi_design/Dex/Components/DexTextField.qml +++ b/atomic_defi_design/Dex/Components/DexTextField.qml @@ -10,6 +10,8 @@ TextField property alias left_text: left_text.text_value property alias right_text: right_text.text_value + property alias left_fontsize: left_text.font.pixelSize + property alias right_fontsize: right_text.font.pixelSize property alias radius: background.radius property color backgroundColor: Dex.CurrentTheme.textFieldBackgroundColor property color backgroundColorActive: Dex.CurrentTheme.textFieldActiveBackgroundColor diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index 1cc7440e66..c8f99ff257 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -103,7 +103,8 @@ ColumnLayout id: input_price left_text: qsTr("Price") - right_text: right_ticker + right_text: General.coinWithoutSuffix(right_ticker) + right_fontsize: 10 enabled: !(API.app.trading_pg.preferred_order.price !== undefined) color: enabled ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.foregroundColor2 text: backend_price ? backend_price : General.formatDouble(API.app.trading_pg.cex_price) @@ -167,7 +168,8 @@ ColumnLayout height: 36 radius: 18 left_text: sell_mode ? qsTr("Send") : qsTr("Receive") - right_text: left_ticker + right_text: General.coinWithoutSuffix(left_ticker) + right_fontsize: 10 placeholderText: "0" text: API.app.trading_pg.volume onTextChanged: { diff --git a/atomic_defi_design/Dex/Wallet/SendResult.qml b/atomic_defi_design/Dex/Wallet/SendResult.qml index 8ac93c37a5..c7db8ebd8f 100644 --- a/atomic_defi_design/Dex/Wallet/SendResult.qml +++ b/atomic_defi_design/Dex/Wallet/SendResult.qml @@ -16,7 +16,7 @@ MultipageModalContent property string custom_amount property alias tx_hash: tx_hash.text_value - titleText: qsTr("Transaction Complete!") + titleText: qsTr("Transaction Broadcast!") // Transaction Hash TitleText diff --git a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml index ab69b7cba4..35bad4fb0d 100644 --- a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml +++ b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml @@ -124,7 +124,7 @@ MultipageModal TextEditWithTitle { title: qsTr("Date") - text: !details ? "" : details.timestamp === 0 ? qsTr("Unconfirmed"): details.date + text: !details ? "" : details.timestamp === 0 ? qsTr("Awaiting confirmation"): details.timestamp label.font.pixelSize: 13 } From 3ed4128468e2515d8c81ceb24e7354a09ad1b234 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 19 Aug 2024 14:04:23 +0800 Subject: [PATCH 03/17] extend privacy mode redaction to more areas --- .../Dex/Components/DexLabel.qml | 5 +- .../Dex/Components/PairItemBadge.qml | 35 ++++++------ atomic_defi_design/Dex/Constants/General.qml | 29 ++++++---- .../Dex/Exchange/ProView/DexComboBoxLine.qml | 4 +- .../ProView/PlaceOrderForm/OrderForm.qml | 8 +-- .../ProView/TradingInfo/OrderLine.qml | 46 ++++++++-------- .../ProView/TradingInfo/OrdersPage.qml | 3 +- .../Dex/Exchange/Trade/SimpleView/List.qml | 33 +++++++----- .../Trade/SimpleView/SubCoinSelector.qml | 2 + .../Dex/Exchange/Trade/SimpleView/Trade.qml | 54 ++++++++++--------- 10 files changed, 122 insertions(+), 97 deletions(-) diff --git a/atomic_defi_design/Dex/Components/DexLabel.qml b/atomic_defi_design/Dex/Components/DexLabel.qml index ef6694978d..77d8bc4d00 100644 --- a/atomic_defi_design/Dex/Components/DexLabel.qml +++ b/atomic_defi_design/Dex/Components/DexLabel.qml @@ -20,13 +20,10 @@ Text } } + text: privacy && Dex.General.privacy_mode ? Dex.General.privacy_text : text_value font: monospace ? Dex.DexTypo.monoSmall : Dex.DexTypo.body2 - color: enabled ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.textDisabledColor - - text: privacy && Dex.General.privacy_mode ? Dex.General.privacy_text : text_value wrapMode: Text.WordWrap - onLinkActivated: Qt.openUrlExternally(link) linkColor: color } diff --git a/atomic_defi_design/Dex/Components/PairItemBadge.qml b/atomic_defi_design/Dex/Components/PairItemBadge.qml index ceeaa3c0b0..5ceab63666 100644 --- a/atomic_defi_design/Dex/Components/PairItemBadge.qml +++ b/atomic_defi_design/Dex/Components/PairItemBadge.qml @@ -30,7 +30,8 @@ DexRectangle Layout.leftMargin: 10 Layout.rightMargin: 20 - Dex.Text{ + DexLabel + { anchors.bottom: parent.top anchors.bottomMargin: 5 anchors.horizontalCenter: parent.horizontalCenter @@ -46,6 +47,7 @@ DexRectangle Layout.leftMargin: 20 Layout.rightMargin: 20 + // Coin Icon Dex.Image { id: icon @@ -58,49 +60,46 @@ DexRectangle Layout.topMargin: 0 Layout.bottomMargin: 0 } + + // ColumnLayout { spacing: 2 Layout.alignment: Qt.AlignVCenter - Dex.Text + DexLabel { Layout.preferredWidth: parent.width - 15 - text_value: `${ticker}   ${fullname}` - font.pixelSize: Style.textSizeSmall3 + font: Dex.DexTypo.body2 elide: Text.ElideRight wrapMode: Text.NoWrap } - Dex.Text + DexLabel { id: middle_line - property string coin_value: amount - text: coin_value + text_value: coin_value Layout.fillWidth: true elide: Text.ElideRight - color: Dex.CurrentTheme.foregroundColor - font: DexTypo.body2 wrapMode: Label.NoWrap - ToolTip.text: coin_value - Component.onCompleted: font.pixelSize = 11.5 + font: DexTypo.body3 + ToolTip.text: text_value + privacy: true } - Dex.Text + DexLabel { id: bottom_line - property string fiat_value: General.getFiatText(amount, ticker) - text: fiat_value + text_value: fiat_value Layout.fillWidth: true elide: Text.ElideRight - color: Dex.CurrentTheme.foregroundColor - font: DexTypo.body2 + font: DexTypo.body3 wrapMode: Label.NoWrap - ToolTip.text: fiat_value - Component.onCompleted: font.pixelSize = 11.5 + ToolTip.text: text_value + privacy: true } } } diff --git a/atomic_defi_design/Dex/Constants/General.qml b/atomic_defi_design/Dex/Constants/General.qml index 8f626296f7..251c19456d 100644 --- a/atomic_defi_design/Dex/Constants/General.qml +++ b/atomic_defi_design/Dex/Constants/General.qml @@ -419,6 +419,14 @@ QtObject { } function getFeesDetail(fees) { + if (privacy_mode) { + return [ + {"label": privacy_text}, + {"label": privacy_text}, + {"label": privacy_text}, + {"label": privacy_text} + ] + } return [ {"label": qsTr("Taker tx fee: "), "fee": fees.base_transaction_fees, "ticker": fees.base_transaction_fees_ticker}, {"label": qsTr("Dex tx fee: "), "fee": fees.fee_to_send_taker_fee, "ticker": fees.fee_to_send_taker_fee_ticker}, @@ -435,6 +443,10 @@ QtObject { } function getSimpleFromPlaceholder(selectedTicker, selectedOrder, sell_ticker_balance) { + if (privacy_mode) + { + return "0" + } if (sell_ticker_balance == 0) { return qsTr("%1 balance is zero").arg(selectedTicker) @@ -489,6 +501,7 @@ QtObject { } function getTxExplorerURL(ticker, txid, add_0x=true) { + if (privacy_mode) return '' if(txid !== '') { const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker) const txid_prefix = (add_0x && coin_info.is_erc_family) ? '0x' : '' @@ -497,6 +510,7 @@ QtObject { } function getAddressExplorerURL(ticker, address) { + if (privacy_mode) return '' if(address !== '') { const coin_info = API.app.portfolio_pg.global_cfg_mdl.get_coin_info(ticker) return coin_info.explorer_url + addressTxUri(coin_info) + address @@ -505,12 +519,14 @@ QtObject { } function viewTxAtExplorer(ticker, txid, add_0x=true) { + if (privacy_mode) return '' if(txid !== '') { Qt.openUrlExternally(getTxExplorerURL(ticker, txid, add_0x)) } } function viewAddressAtExplorer(ticker, address) { + if (privacy_mode) return '' if(address !== '') { Qt.openUrlExternally(getAddressExplorerURL(ticker, address)) } @@ -555,6 +571,7 @@ QtObject { } function convertUsd(v) { + if (privacy_mode) return '' let rate = API.app.get_rate_conversion("USD", API.app.settings_pg.current_currency) let value = parseFloat(v) / parseFloat(rate) @@ -566,6 +583,7 @@ QtObject { } function formatFiat(received, amount, fiat, precision=2) { + if (privacy_mode) return '' if (precision == 2 && fiat == "BTC") { precision = 8 } @@ -575,6 +593,7 @@ QtObject { } function formatPercent(value, show_prefix=true) { + if (privacy_mode) return '' let prefix = '' if(value > 0) prefix = '+ ' else if(value < 0) { @@ -619,6 +638,7 @@ QtObject { } function formatCrypto(received, amount, ticker, fiat_amount, fiat, precision, trail_zeros) { + if (privacy_mode) return '' return diffPrefix(received) + ticker + " " + formatDouble(amount, precision, trail_zeros) + (fiat_amount ? " (" + formatFiat("", fiat_amount, fiat) + ")" : "") } @@ -777,15 +797,10 @@ QtObject { } function feeText(trade_info, base_ticker, has_info_icon=true, has_limited_space=false) { - - if(!trade_info || !trade_info.trading_fee) return "" - const tx_fee = txFeeText(trade_info, base_ticker, has_info_icon, has_limited_space) const trading_fee = tradingFeeText(trade_info, base_ticker, has_info_icon) const minimum_amount = minimumtradingFeeText(trade_info, base_ticker, has_info_icon) - - return tx_fee + "\n" + trading_fee +"
"+minimum_amount } @@ -804,13 +819,9 @@ QtObject { } function txFeeText(trade_info, base_ticker, has_info_icon=true, has_limited_space=false) { - if(!trade_info || !trade_info.trading_fee) return "" - const has_parent_coin_fees = hasParentCoinFees(trade_info) - var info = qsTr('%1 Transaction Fee'.arg(trade_info.base_transaction_fees_ticker))+': '+ trade_info.base_transaction_fees + " (%1)".arg(getFiatText(trade_info.base_transaction_fees, trade_info.base_transaction_fees_ticker, has_info_icon)) - if (has_parent_coin_fees) { info = info+"
"+qsTr('%1 Transaction Fee'.arg(trade_info.rel_transaction_fees_ticker))+': '+ trade_info.rel_transaction_fees + " (%1)".arg(getFiatText(trade_info.rel_transaction_fees, trade_info.rel_transaction_fees_ticker, has_info_icon)) } diff --git a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml index 0d8269efb9..1c8f41a332 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml @@ -88,8 +88,9 @@ RowLayout { id: middle_line - property string coin_value: !details ? "" : details.balance + property string coin_value: !details ? "" : Dex.General.privacy_mode ? Dex.General.privacy_text : details.balance text: coin_value + privacy: true Layout.fillWidth: true elide: Text.ElideRight color: Dex.CurrentTheme.foregroundColor @@ -112,6 +113,7 @@ RowLayout font: DexTypo.body2 wrapMode: Label.NoWrap ToolTip.text: fiat_value + privacy: true Component.onCompleted: font.pixelSize = 11 } } diff --git a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml index 1cc7440e66..5ad87b5310 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/PlaceOrderForm/OrderForm.qml @@ -174,6 +174,7 @@ ColumnLayout setVolume(text) reset_fees_state() } + enabled: !General.privacy_mode } OrderFormSubfield @@ -204,9 +205,9 @@ ColumnLayout left_label: "25%" middle_label: "50%" right_label: qsTr("Max") - left_tooltip_text: qsTr("Swap 25% of your tradable balance.") - middle_tooltip_text: qsTr("Swap 50% of your tradable balance.") - right_tooltip_text: qsTr("Swap 100% of your tradable balance.") + left_tooltip_text: General.privacy_mode ? qsTr("Diasble privacy mode to trade") : qsTr("Swap 25% of your tradable balance.") + middle_tooltip_text: General.privacy_mode ? qsTr("Diasble privacy mode to trade") : qsTr("Swap 50% of your tradable balance.") + right_tooltip_text: General.privacy_mode ? qsTr("Diasble privacy mode to trade") : qsTr("Swap 100% of your tradable balance.") } } @@ -419,6 +420,7 @@ ColumnLayout radius: 16 text: API.app.trading_pg.maker_mode ? qsTr("CREATE MAKER SWAP") : qsTr("START TAKER SWAP") font.weight: Font.Medium + enabled: !General.privacy_mode } } } \ No newline at end of file diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml index 87d5456f62..91eb121226 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderLine.qml @@ -49,7 +49,7 @@ FloatingBackground Layout.preferredWidth: 24 Layout.alignment: Qt.AlignCenter - DefaultText + DexLabel { id: statusText anchors.centerIn: parent @@ -86,34 +86,34 @@ FloatingBackground clip: true - DefaultText + DexLabel { id: baseAmountLabel anchors.left: parent.left anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: + text_value: { - if (!details) return + if (!details) return BigNumber.config({ DECIMAL_PLACES: 6 }) return new BigNumber(details.base_amount).toString(10) } - privacy: is_placed_order + privacy: true elide: Text.ElideRight maximumLineCount: 1 } - DefaultText + DexLabel { anchors.left: baseAmountLabel.right anchors.leftMargin: 3 anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: !details ? "" : "(%1 %2)".arg(details.base_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) - privacy: is_placed_order + text_value: !details ? "" : "(%1 %2)".arg(details.base_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) + privacy: true elide: Text.ElideRight maximumLineCount: 1 } @@ -128,14 +128,14 @@ FloatingBackground iconSize: 18 } - DefaultText + DexLabel { anchors.right: relAmountInCurrCurrency.left anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: + text_value: { if (!details) return @@ -143,12 +143,12 @@ FloatingBackground return new BigNumber(details.rel_amount).toString(10) } - privacy: is_placed_order + privacy: true elide: Text.ElideRight maximumLineCount: 1 } - DefaultText + DexLabel { id: relAmountInCurrCurrency @@ -156,8 +156,8 @@ FloatingBackground anchors.verticalCenter: parent.verticalCenter font.pixelSize: 12 - text: !details ? "" : "(%1 %2)".arg(details.rel_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) - privacy: is_placed_order + text_value: !details ? "" : "(%1 %2)".arg(details.rel_amount_current_currency).arg(API.app.settings_pg.current_fiat_sign) + privacy: true elide: Text.ElideRight maximumLineCount: 1 } @@ -181,7 +181,7 @@ FloatingBackground source: General.coinIcon(!details ? atomic_app_primary_coin : details.base_coin ?? atomic_app_primary_coin) } - DefaultText + DexLabel { anchors.left: baseIcon.right anchors.leftMargin: 2 @@ -189,13 +189,13 @@ FloatingBackground font.weight: Font.Bold font.pixelSize: 12 - text: !details ? "" : details.base_coin - privacy: is_placed_order + text_value: !details ? "" : details.base_coin + privacy: true elide: Text.ElideRight maximumLineCount: 1 } - DefaultText + DexLabel { visible: clickable @@ -209,7 +209,7 @@ FloatingBackground color: Dex.CurrentTheme.foregroundColor2 } - DefaultText + DexLabel { anchors.right: relCoin.left anchors.rightMargin: 2 @@ -217,8 +217,8 @@ FloatingBackground font.weight: Font.Bold font.pixelSize: 12 - text: !details ? "" : details.rel_coin - privacy: is_placed_order + text_value: !details ? "" : details.rel_coin + privacy: true elide: Text.ElideRight maximumLineCount: 1 } @@ -244,7 +244,7 @@ FloatingBackground Layout.preferredWidth: 24 Layout.alignment: Qt.AlignCenter - DefaultText + DexLabel { anchors.centerIn: parent @@ -255,7 +255,7 @@ FloatingBackground DefaultTooltip { - contentItem: DefaultText + contentItem: DexLabel { text_value: qsTr("Funds are recoverable") font.pixelSize: Style.textSizeSmall4 diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml index 3629b41dae..ab0e0968f7 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrdersPage.qml @@ -132,6 +132,7 @@ Item { radius: 7 label.font: DexTypo.body2 text: qsTr("Export CSV") + enabled: list_model.length > 0 && ! General.privacy_mode onClicked: { export_csv_dialog.folder = General.os_file_prefix + API.app.settings_pg.get_export_folder() @@ -142,10 +143,10 @@ Item { DefaultButton { visible: !root.is_history && list_model.length > 0 - enabled: list_model.length > 0 Layout.preferredHeight: 29 radius: 7 label.font: DexTypo.body2 + enabled: list_model.length > 0 && ! General.privacy_mode text: qsTr("Cancel All") iconSource: Qaterial.Icons.close onClicked: API.app.trading_pg.orders.cancel_order(list_model_proxy.get_filtered_ids()) diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml index c9ea3a02df..e48f670aad 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml @@ -27,8 +27,6 @@ DexListView delegate: ClipRRect { property var details: model - readonly property bool is_placed_order: !details ? false : - details.order_id !== '' property bool expanded: order_list_view.currentIndex === index @@ -78,7 +76,7 @@ DexListView height: width anchors.centerIn: parent running: !isSwapDone(details.order_status) && Qt.platform.os != "osx" - DefaultText + DexLabel { anchors.centerIn: parent font.pixelSize: getStatusFontSize(details.order_status) @@ -105,13 +103,13 @@ DexListView anchors.verticalCenter: parent.verticalCenter } - DefaultText + DexLabel { id: base_amount text_value: !details ? "" : General.formatCrypto("", details.base_amount, details.base_coin).replace(" ","
") font: rel_amount.font - privacy: is_placed_order + privacy: true anchors.verticalCenter: parent.verticalCenter } } @@ -150,7 +148,7 @@ DexListView height: width anchors.verticalCenter: parent.verticalCenter } - DefaultText + DexLabel { id: rel_amount text_value: !details ? "" : @@ -162,7 +160,7 @@ DexListView weight: Font.Normal }) anchors.verticalCenter: parent.verticalCenter - privacy: is_placed_order + privacy: true } } @@ -196,6 +194,7 @@ DexListView verticalAlignment: Label.AlignVCenter text: !details ? "" : General.formatCrypto("", details.base_amount, details.base_coin) + privacy: true } DexLabel { @@ -205,6 +204,7 @@ DexListView horizontalAlignment: Text.AlignRight text: !details ? "" : General.formatCrypto("", details.rel_amount, details.rel_coin) + privacy: true } } @@ -215,20 +215,22 @@ DexListView anchors.horizontalCenter: parent.horizontalCenter height: 20 opacity: .6 - DefaultText + DexLabel { Layout.fillWidth: true - Layout.fillHeight: true + Layout.fillHeight: true verticalAlignment: Label.AlignVCenter - text: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.base_amount_current_currency) + text_value: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.base_amount_current_currency) + privacy: true } - DefaultText + DexLabel { Layout.fillWidth: true Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Text.AlignRight - text: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.rel_amount_current_currency) + text_value: "%1 %2".arg(API.app.settings_pg.current_currency).arg(details.rel_amount_current_currency) + privacy: true } } @@ -244,7 +246,8 @@ DexListView Layout.fillWidth: true Layout.fillHeight: true verticalAlignment: Label.AlignVCenter - text: !details ? "" : details.date?? "" + text_value: !details ? "" : details.date?? "" + privacy: true } Item { @@ -269,6 +272,7 @@ DexListView anchors.verticalCenter: parent.verticalCenter text: "Refund " color: Qaterial.Colors.amber + privacy: true } } MouseArea @@ -283,9 +287,10 @@ DexListView contentItem: ColumnLayout { - DefaultText { + DexLabel { text_value: qsTr("Funds are recoverable") font.pixelSize: Constants.Style.textSizeSmall4 + privacy: true } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml index bf1938c322..852291ca5f 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/SubCoinSelector.qml @@ -174,6 +174,7 @@ DexListView text_value: model.balance.replace(" ","") font.pixelSize: 14 wrapMode: Text.NoWrap + privacy: true } DexLabel @@ -184,6 +185,7 @@ DexListView text_value: "%1".arg(General.getFiatText(model.balance, model.ticker, false)) font.pixelSize: 14 wrapMode: Text.NoWrap + privacy: true } } } diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml index 6a92ed7e0e..0eccd7fdbb 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/Trade.qml @@ -160,7 +160,7 @@ ClipRRect // Trade Card opacity: .85 } - DefaultText // Description + DexLabel // Description { anchors.topMargin: 10 font.pixelSize: Constants.Style.textSizeSmall4 @@ -231,7 +231,7 @@ ClipRRect // Trade Card radius: 20 visible: !coinSelectorSimplified.visible && has_coins_with_balance - DefaultText // From Text + DexLabel // From Text { id: _fromTitle anchors.top: parent.top @@ -242,7 +242,7 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall4 } - Text // Tradable Balance + DexLabel // Tradable Balance { readonly property int _maxWidth: 140 @@ -252,10 +252,11 @@ ClipRRect // Trade Card anchors.verticalCenter: _fromTitle.verticalCenter anchors.right: parent.right anchors.rightMargin: 17 - text: qsTr("%1").arg(max_trade_volume) // This is slow to appear + text_value: qsTr("%1").arg(max_trade_volume) // This is slow to appear font.pixelSize: Constants.Style.textSizeSmall2 elide: Text.ElideRight color: DexTheme.foregroundColorLightColor1 + privacy: true DefaultImage { @@ -282,6 +283,10 @@ ClipRRect // Trade Card visible: parent.containsMouse text: { + if (General.privacy_mode) + { + return qsTr("Balance: ") + qsTr("****") + } let balance = Constants.API.app.portfolio_pg.portfolio_mdl.coin_balance(selectedTicker); return qsTr("Balance: ") + Constants.API.app.portfolio_pg.portfolio_mdl.coin_balance(selectedTicker) + ' (' + parent.parent.text + ' tradable)' } @@ -300,7 +305,7 @@ ClipRRect // Trade Card AmountField // Amount { id: _fromValue - enabled: sell_ticker_balance == 0 ? false : waiting_for_sell_coin_info ? false : true + enabled: sell_ticker_balance == 0 ? false : waiting_for_sell_coin_info ? false : General.privacy_mode ? false : true anchors.bottom: parent.bottom anchors.bottomMargin: 19 anchors.left: parent.left @@ -329,7 +334,7 @@ ClipRRect // Trade Card Component.onCompleted: text = "" } - Text // Amount In Fiat + DexLabel // Amount In Fiat { enabled: _fromValue.text visible: enabled @@ -340,7 +345,8 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall1 color: DexTheme.foregroundColor opacity: .9 - text: enabled ? Constants.General.getFiatText(_fromValue.text, selectedTicker) : "" + text_value: enabled ? Constants.General.getFiatText(_fromValue.text, selectedTicker) : "" + privacy: true } Rectangle // Select ticker button @@ -387,7 +393,7 @@ ClipRRect // Trade Card source: Constants.General.coinIcon(selectedTicker) } - DefaultText + DexLabel { id: _selectedTickerText @@ -403,7 +409,7 @@ ClipRRect // Trade Card wrapMode: Text.NoWrap - DefaultText + DexLabel { id: _selectedTickerTypeText @@ -432,16 +438,13 @@ ClipRRect // Trade Card ClickableText // MAX Button { id: _maxClickableLabel - anchors.right: _selectTickerBut.left anchors.rightMargin: 10 anchors.verticalCenter: _selectTickerBut.verticalCenter - visible: selectedTicker !== "" - text: qsTr("MAX") color: Dex.CurrentTheme.foregroundColor2 - + enabled: !General.privacy_mode onClicked: _fromValue.text = max_trade_volume } @@ -464,7 +467,7 @@ ClipRRect // Trade Card && !coinSelectorSimplified.visible && has_coins_with_balance - DefaultText + DexLabel { anchors.fill: parent anchors.leftMargin: 17 @@ -487,7 +490,7 @@ ClipRRect // Trade Card background: Rectangle { color: swap_from_card.color} } - DefaultText // Amount In Fiat + DexLabel // Amount In Fiat { enabled: parseFloat(_toValue.text) > 0 && _toValue.text != "" anchors.top: _toValue.bottom @@ -533,7 +536,7 @@ ClipRRect // Trade Card } // When no order is currently selected. - DefaultText + DexLabel { id: _bestOrderNoTickerText @@ -567,7 +570,7 @@ ClipRRect // Trade Card } // Ticker (When a best order is currently selected) - DefaultText + DexLabel { id: _bestOrderTickerText @@ -584,7 +587,7 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall2 wrapMode: Text.NoWrap - DefaultText + DexLabel { id: _bestOrderTickerTypeText @@ -623,14 +626,14 @@ ClipRRect // Trade Card && !coinSelectorSimplified.visible && has_coins_with_balance - DefaultText + DexLabel { Layout.rightMargin: 120 font.pixelSize: Constants.Style.textSizeSmall3 text: qsTr("Price") } - DefaultText + DexLabel { Layout.alignment: Qt.AlignRight font.pixelSize: Constants.Style.textSizeSmall3 @@ -714,7 +717,10 @@ ClipRRect // Trade Card function getAlert() { - console.log("_fromValue.text: " + _fromValue.text) + if (Constants.General.privacy_mode) + { + return qsTr("Disable privacy mode to trade.") + } var right_ticker = Constants.API.app.trading_pg.market_pairs_mdl.right_selected_coin var base_ticker = Constants.API.app.trading_pg.market_pairs_mdl.base_selected_coin var rel_ticker = Constants.API.app.trading_pg.market_pairs_mdl.rel_selected_coin @@ -932,7 +938,7 @@ ClipRRect // Trade Card anchors.fill: parent } - DefaultText + DexLabel { anchors.centerIn: parent text: qsTr("Calculating fee estimate... ") @@ -959,7 +965,7 @@ ClipRRect // Trade Card Component.onCompleted: _feesCard.height += 10 Component.onDestruction: _feesCard.height -= 10 - DefaultText + DexLabel { Layout.alignment: Qt.AlignLeft Layout.leftMargin: 10 @@ -967,7 +973,7 @@ ClipRRect // Trade Card font.pixelSize: Constants.Style.textSizeSmall3 } - DefaultText + DexLabel { Layout.alignment: Qt.AlignRight Layout.rightMargin: 10 From cc205b14c7896c66a500a32ca910161ab5e56159 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 19 Aug 2024 14:09:59 +0800 Subject: [PATCH 04/17] text -> text_value --- .../Dex/Exchange/ProView/DexComboBoxLine.qml | 7 +++---- .../Exchange/ProView/TradingInfo/OrderModal.qml | 16 ++++++++-------- .../Dex/Exchange/Trade/SimpleView/List.qml | 6 ++---- .../Dex/Wallet/TransactionDetailsModal.qml | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml index 1c8f41a332..0e83f5af8d 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/DexComboBoxLine.qml @@ -87,9 +87,8 @@ RowLayout Dex.Text { id: middle_line - - property string coin_value: !details ? "" : Dex.General.privacy_mode ? Dex.General.privacy_text : details.balance - text: coin_value + property string coin_value: !details ? "" : details.balance + text_value: coin_value privacy: true Layout.fillWidth: true elide: Text.ElideRight @@ -106,7 +105,7 @@ RowLayout property string fiat_value: !details ? "" : General.formatFiat("", details.main_currency_balance, API.app.settings_pg.current_currency) - text: fiat_value + text_value: fiat_value Layout.fillWidth: true elide: Text.ElideRight color: Dex.CurrentTheme.foregroundColor diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml index df4d38f8a7..43de518cc4 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml @@ -165,9 +165,9 @@ MultipageModal { Layout.fillWidth: true title: qsTr("Swap ID") - text: !details ? "" : details.order_id + text_value: !details ? "" : details.order_id label.font.pixelSize: 13 - visible: text !== '' + visible: text_value !== '' copy: true privacy: true onCopyNotificationTitle: qsTr("Swap ID") @@ -178,11 +178,11 @@ MultipageModal { Layout.fillWidth: true title: !details ? "" : details.is_maker ? qsTr("Maker Payment Sent Transaction ID") : qsTr("Maker Payment Spent Transaction ID") - text: !details ? "" : details.maker_payment_id + text_value: !details ? "" : details.maker_payment_id label.font.pixelSize: 12 - visible: text !== '' + visible: text_value !== '' copy: true - linkURL: text !== '' ? General.getTxExplorerURL(details.is_maker ? details.base_coin : details.rel_coin, details.maker_payment_id) : '' + linkURL: text_value !== '' ? General.getTxExplorerURL(details.is_maker ? details.base_coin : details.rel_coin, details.maker_payment_id) : '' privacy: true onCopyNotificationTitle: qsTr("Maker Payment TXID") } @@ -192,13 +192,13 @@ MultipageModal { Layout.fillWidth: true title: !details ? "" : details.is_maker ? qsTr("Taker Payment Spent Transaction ID") : qsTr("Taker Payment Sent Transaction ID") - text: !details ? "" : details.taker_payment_id + text_value: !details ? "" : details.taker_payment_id label.font.pixelSize: 12 - visible: text !== '' + visible: text_value !== '' copy: true privacy: true onCopyNotificationTitle: qsTr("Taker Payment TXID") - linkURL: text !== '' ? General.getTxExplorerURL(details.is_maker ? details.rel_coin : details.base_coin, details.taker_payment_id) : '' + linkURL: text_value !== '' ? General.getTxExplorerURL(details.is_maker ? details.rel_coin : details.base_coin, details.taker_payment_id) : '' } // Error ID diff --git a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml index e48f670aad..c900b3ca17 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/SimpleView/List.qml @@ -192,7 +192,7 @@ DexListView Layout.fillWidth: true Layout.fillHeight: true verticalAlignment: Label.AlignVCenter - text: !details ? "" : + text_value: !details ? "" : General.formatCrypto("", details.base_amount, details.base_coin) privacy: true } @@ -202,7 +202,7 @@ DexListView Layout.fillHeight: true verticalAlignment: Label.AlignVCenter horizontalAlignment: Text.AlignRight - text: !details ? "" : + text_value: !details ? "" : General.formatCrypto("", details.rel_amount, details.rel_coin) privacy: true } @@ -272,7 +272,6 @@ DexListView anchors.verticalCenter: parent.verticalCenter text: "Refund " color: Qaterial.Colors.amber - privacy: true } } MouseArea @@ -290,7 +289,6 @@ DexListView DexLabel { text_value: qsTr("Funds are recoverable") font.pixelSize: Constants.Style.textSizeSmall4 - privacy: true } } } diff --git a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml index ab69b7cba4..fe2e75c2f7 100644 --- a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml +++ b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml @@ -80,7 +80,7 @@ MultipageModal TextEditWithTitle { title: qsTr("Amount") - text: !details ? "" : General.formatCrypto(!details.am_i_sender, details.amount, api_wallet_page.ticker, details.amount_fiat, API.app.settings_pg.current_currency) + text_value: !details ? "" : General.formatCrypto(!details.am_i_sender, details.amount, api_wallet_page.ticker, details.amount_fiat, API.app.settings_pg.current_currency) value_color: !details ? "white" : details.am_i_sender ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor privacy: true label.font.pixelSize: 13 @@ -90,7 +90,7 @@ MultipageModal TextEditWithTitle { title: qsTr("Fees") - text: !details ? "" : General.formatCrypto(parseFloat(details.fees) < 0, Math.abs(parseFloat(details.fees)), current_ticker_infos.fee_ticker, details.fees_amount_fiat, API.app.settings_pg.current_currency) + text_value: !details ? "" : General.formatCrypto(parseFloat(details.fees) < 0, Math.abs(parseFloat(details.fees)), current_ticker_infos.fee_ticker, details.fees_amount_fiat, API.app.settings_pg.current_currency) value_color: !details ? "white" : parseFloat(details.fees) > 0 ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor privacy: true label.font.pixelSize: 13 From 1b415db4adfceae939fc5399b43519910fa17b90 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 19 Aug 2024 16:08:03 +0800 Subject: [PATCH 05/17] disable orderbooks in privacy mode --- .../Exchange/ProView/TradingInfo/OrderModal.qml | 16 ++++++++-------- .../Exchange/Trade/OrderBook/ListDelegate.qml | 5 +++++ .../Dex/Wallet/TransactionDetailsModal.qml | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml index 43de518cc4..df4d38f8a7 100644 --- a/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml +++ b/atomic_defi_design/Dex/Exchange/ProView/TradingInfo/OrderModal.qml @@ -165,9 +165,9 @@ MultipageModal { Layout.fillWidth: true title: qsTr("Swap ID") - text_value: !details ? "" : details.order_id + text: !details ? "" : details.order_id label.font.pixelSize: 13 - visible: text_value !== '' + visible: text !== '' copy: true privacy: true onCopyNotificationTitle: qsTr("Swap ID") @@ -178,11 +178,11 @@ MultipageModal { Layout.fillWidth: true title: !details ? "" : details.is_maker ? qsTr("Maker Payment Sent Transaction ID") : qsTr("Maker Payment Spent Transaction ID") - text_value: !details ? "" : details.maker_payment_id + text: !details ? "" : details.maker_payment_id label.font.pixelSize: 12 - visible: text_value !== '' + visible: text !== '' copy: true - linkURL: text_value !== '' ? General.getTxExplorerURL(details.is_maker ? details.base_coin : details.rel_coin, details.maker_payment_id) : '' + linkURL: text !== '' ? General.getTxExplorerURL(details.is_maker ? details.base_coin : details.rel_coin, details.maker_payment_id) : '' privacy: true onCopyNotificationTitle: qsTr("Maker Payment TXID") } @@ -192,13 +192,13 @@ MultipageModal { Layout.fillWidth: true title: !details ? "" : details.is_maker ? qsTr("Taker Payment Spent Transaction ID") : qsTr("Taker Payment Sent Transaction ID") - text_value: !details ? "" : details.taker_payment_id + text: !details ? "" : details.taker_payment_id label.font.pixelSize: 12 - visible: text_value !== '' + visible: text !== '' copy: true privacy: true onCopyNotificationTitle: qsTr("Taker Payment TXID") - linkURL: text_value !== '' ? General.getTxExplorerURL(details.is_maker ? details.rel_coin : details.base_coin, details.taker_payment_id) : '' + linkURL: text !== '' ? General.getTxExplorerURL(details.is_maker ? details.rel_coin : details.base_coin, details.taker_payment_id) : '' } // Error ID diff --git a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml index 03819d17fe..8667ff4694 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/OrderBook/ListDelegate.qml @@ -45,6 +45,10 @@ Item { if (mouse_area.containsMouse) { + if (General.privacy_mode) + { + return qsTr("Orderbook is disabled in privacy mode") + } if (API.app.trading_pg.maker_mode) { return qsTr("Orderbook is disabled while creating maker orders") @@ -109,6 +113,7 @@ Item // Populate form with selected order onClicked: { + if (General.privacy_mode) return if (is_mine) return if (API.app.trading_pg.maker_mode) return diff --git a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml index fe2e75c2f7..ab69b7cba4 100644 --- a/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml +++ b/atomic_defi_design/Dex/Wallet/TransactionDetailsModal.qml @@ -80,7 +80,7 @@ MultipageModal TextEditWithTitle { title: qsTr("Amount") - text_value: !details ? "" : General.formatCrypto(!details.am_i_sender, details.amount, api_wallet_page.ticker, details.amount_fiat, API.app.settings_pg.current_currency) + text: !details ? "" : General.formatCrypto(!details.am_i_sender, details.amount, api_wallet_page.ticker, details.amount_fiat, API.app.settings_pg.current_currency) value_color: !details ? "white" : details.am_i_sender ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor privacy: true label.font.pixelSize: 13 @@ -90,7 +90,7 @@ MultipageModal TextEditWithTitle { title: qsTr("Fees") - text_value: !details ? "" : General.formatCrypto(parseFloat(details.fees) < 0, Math.abs(parseFloat(details.fees)), current_ticker_infos.fee_ticker, details.fees_amount_fiat, API.app.settings_pg.current_currency) + text: !details ? "" : General.formatCrypto(parseFloat(details.fees) < 0, Math.abs(parseFloat(details.fees)), current_ticker_infos.fee_ticker, details.fees_amount_fiat, API.app.settings_pg.current_currency) value_color: !details ? "white" : parseFloat(details.fees) > 0 ? Dex.CurrentTheme.warningColor : Dex.CurrentTheme.okColor privacy: true label.font.pixelSize: 13 From 1b146a4ddeff5a15269fadc91c787e23ee2dd706 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 19 Aug 2024 16:43:54 +0800 Subject: [PATCH 06/17] rename kdf DB path to retain prior history --- src/core/atomicdex/services/kdf/kdf.service.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/core/atomicdex/services/kdf/kdf.service.cpp b/src/core/atomicdex/services/kdf/kdf.service.cpp index 741a21fdea..6c7e654afb 100644 --- a/src/core/atomicdex/services/kdf/kdf.service.cpp +++ b/src/core/atomicdex/services/kdf/kdf.service.cpp @@ -2227,6 +2227,17 @@ namespace atomic_dex .passphrase = std::move(passphrase), .rpc_password = std::move(rpcpass) == "" ? std::move(atomic_dex::gen_random_password()) : std::move(rpcpass) }; + + auto dbdir = std::filesystem::path(cfg.dbdir); + auto old_dbdir = std::filesystem::path(utils::get_atomic_dex_data_folder() / "mm2" / "DB"); + if (not std::filesystem::exists(dbdir)) + { + if (std::filesystem::exists(old_dbdir)) + { + std::filesystem::rename(old_dbdir, dbdir); + } + } + kdf::set_system_manager(m_system_manager); kdf::set_rpc_password(cfg.rpc_password); json json_cfg; From a3db7f3eaaa229ac307f6a27c1b59b076b5c5b25 Mon Sep 17 00:00:00 2001 From: smk762 Date: Mon, 19 Aug 2024 18:30:29 +0800 Subject: [PATCH 07/17] fix nim build error --- .github/workflows/atomicdex-desktop-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/atomicdex-desktop-ci.yml b/.github/workflows/atomicdex-desktop-ci.yml index 45c8fa9ec1..8263413217 100644 --- a/.github/workflows/atomicdex-desktop-ci.yml +++ b/.github/workflows/atomicdex-desktop-ci.yml @@ -160,6 +160,7 @@ jobs: echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV export CHOOSENIM_CHOOSE_VERSION=1.6.2 curl https://nim-lang.org/choosenim/init.sh > choosenim.sh + sed -i.bak 's|https://github.com/nim-lang/choosenim/releases/download/|https://github.com/dom96/choosenim/releases/download/|g' choosenim.sh chmod +x choosenim.sh ./choosenim.sh -y export PATH=/home/runner/.nimble/bin:$PATH @@ -171,6 +172,7 @@ jobs: echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV export CHOOSENIM_CHOOSE_VERSION=1.6.2 curl https://nim-lang.org/choosenim/init.sh > choosenim.sh + sed -i.bak 's|https://github.com/nim-lang/choosenim/releases/download/|https://github.com/dom96/choosenim/releases/download/|g' choosenim.sh chmod +x choosenim.sh ./choosenim.sh -y export PATH=/Users/runner/.nimble/bin:$PATH From 179b578d0fea38babd5a112b414e5a3e38b16170 Mon Sep 17 00:00:00 2001 From: smk762 Date: Tue, 20 Aug 2024 02:33:01 +0800 Subject: [PATCH 08/17] use parent folder --- src/core/atomicdex/services/kdf/kdf.service.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/atomicdex/services/kdf/kdf.service.cpp b/src/core/atomicdex/services/kdf/kdf.service.cpp index 6c7e654afb..71469bd2e3 100644 --- a/src/core/atomicdex/services/kdf/kdf.service.cpp +++ b/src/core/atomicdex/services/kdf/kdf.service.cpp @@ -2228,13 +2228,13 @@ namespace atomic_dex .rpc_password = std::move(rpcpass) == "" ? std::move(atomic_dex::gen_random_password()) : std::move(rpcpass) }; - auto dbdir = std::filesystem::path(cfg.dbdir); - auto old_dbdir = std::filesystem::path(utils::get_atomic_dex_data_folder() / "mm2" / "DB"); - if (not std::filesystem::exists(dbdir)) + auto dbdir_parent = std::filesystem::path(utils::get_atomic_dex_data_folder() / "kdf"); + auto old_dbdir_parent = std::filesystem::path(utils::get_atomic_dex_data_folder() / "mm2"); + if (not std::filesystem::exists(dbdir_parent)) { - if (std::filesystem::exists(old_dbdir)) + if (std::filesystem::exists(old_dbdir_parent)) { - std::filesystem::rename(old_dbdir, dbdir); + std::filesystem::rename(old_dbdir_parent, dbdir_parent); } } From f72e91d98e931765905c95d1fb021ff0acf7249d Mon Sep 17 00:00:00 2001 From: smk762 Date: Tue, 20 Aug 2024 02:34:36 +0800 Subject: [PATCH 09/17] use parent folders --- src/core/atomicdex/services/kdf/kdf.service.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/atomicdex/services/kdf/kdf.service.cpp b/src/core/atomicdex/services/kdf/kdf.service.cpp index 6c7e654afb..71469bd2e3 100644 --- a/src/core/atomicdex/services/kdf/kdf.service.cpp +++ b/src/core/atomicdex/services/kdf/kdf.service.cpp @@ -2228,13 +2228,13 @@ namespace atomic_dex .rpc_password = std::move(rpcpass) == "" ? std::move(atomic_dex::gen_random_password()) : std::move(rpcpass) }; - auto dbdir = std::filesystem::path(cfg.dbdir); - auto old_dbdir = std::filesystem::path(utils::get_atomic_dex_data_folder() / "mm2" / "DB"); - if (not std::filesystem::exists(dbdir)) + auto dbdir_parent = std::filesystem::path(utils::get_atomic_dex_data_folder() / "kdf"); + auto old_dbdir_parent = std::filesystem::path(utils::get_atomic_dex_data_folder() / "mm2"); + if (not std::filesystem::exists(dbdir_parent)) { - if (std::filesystem::exists(old_dbdir)) + if (std::filesystem::exists(old_dbdir_parent)) { - std::filesystem::rename(old_dbdir, dbdir); + std::filesystem::rename(old_dbdir_parent, dbdir_parent); } } From d999356e78922fb0ccd830c1d6a81dd836d462d2 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 22 Aug 2024 01:14:41 +0800 Subject: [PATCH 10/17] add timesync service --- .../sync/timesync.checker.service.cpp | 116 ++++++++++++++++++ .../sync/timesync.checker.service.hpp | 60 +++++++++ 2 files changed, 176 insertions(+) create mode 100644 src/core/atomicdex/services/sync/timesync.checker.service.cpp create mode 100644 src/core/atomicdex/services/sync/timesync.checker.service.hpp diff --git a/src/core/atomicdex/services/sync/timesync.checker.service.cpp b/src/core/atomicdex/services/sync/timesync.checker.service.cpp new file mode 100644 index 0000000000..b74efa0927 --- /dev/null +++ b/src/core/atomicdex/services/sync/timesync.checker.service.cpp @@ -0,0 +1,116 @@ +/****************************************************************************** + * Copyright © 2013-2024 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. * + * * + ******************************************************************************/ + +#include +#include "atomicdex/services/sync/timesync.checker.service.hpp" +#include "atomicdex/utilities/cpprestsdk.utilities.hpp" + +namespace +{ + constexpr const char* g_timesync_endpoint = "https://worldtimeapi.org"; + web::http::client::http_client_config g_timesync_cfg{[]() + { + web::http::client::http_client_config cfg; + cfg.set_validate_certificates(false); + cfg.set_timeout(std::chrono::seconds(5)); + return cfg; + }()}; + t_http_client_ptr g_timesync_client = std::make_unique(FROM_STD_STR(g_timesync_endpoint), g_timesync_cfg); + pplx::cancellation_token_source g_synctoken_source; + + pplx::task + async_fetch_timesync() + { + web::http::http_request req; + req.set_method(web::http::methods::GET); + req.set_request_uri(FROM_STD_STR("api/timezone/UTC")); + SPDLOG_INFO("req: {}", TO_STD_STR(req.to_string())); + return g_timesync_client->request(req, g_synctoken_source.get_token()); + } + + bool get_timesync_info_rpc(web::http::http_response resp_http) + { + using namespace std::string_literals; + nlohmann::json resp; + bool sync_ok = false; + std::string resp_str = TO_STD_STR(resp_http.extract_string(true).get()); + if (resp_http.status_code() != 200) + { + SPDLOG_ERROR("Cannot reach the endpoint [{}]: {}", g_timesync_endpoint); + } + else + { + resp = nlohmann::json::parse(resp_str); + int8_t epoch_ts = resp["unixtime"]; + int8_t current_ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + int8_t ts_diff = epoch_ts - current_ts; + if (abs(ts_diff) < 60) + { + sync_ok = true; + } + SPDLOG_WARN("TIME SYNC STATUS [{}]", sync_ok); + } + return sync_ok; + } +} // namespace + + +namespace atomic_dex +{ + timesync_checker_service::timesync_checker_service(entt::registry& registry, QObject* parent) : QObject(parent), system(registry) + { + m_timesync_clock = std::chrono::high_resolution_clock::now(); + fetch_timesync_info(); + } + + void timesync_checker_service::update() + { + using namespace std::chrono_literals; + + const auto now = std::chrono::high_resolution_clock::now(); + const auto s = std::chrono::duration_cast(now - m_timesync_clock); + if (s >= 1min) + { + fetch_timesync_info(); + m_timesync_clock = std::chrono::high_resolution_clock::now(); + } + } + + void timesync_checker_service::fetch_timesync_info() + { + if (is_timesync_fetching) + return; + is_timesync_fetching = true; + emit isTimesyncFetchingChanged(); + async_fetch_timesync() + .then([this](web::http::http_response resp) { + + this->m_timesync_info = get_timesync_info_rpc(resp); + is_timesync_fetching = false; + emit isTimesyncFetchingChanged(); + emit timesyncInfoChanged(); + }) + .then(&handle_exception_pplx_task); + } + + bool timesync_checker_service::get_timesync_info() const + { + return *m_timesync_info; + } + +} // namespace atomic_dex + + diff --git a/src/core/atomicdex/services/sync/timesync.checker.service.hpp b/src/core/atomicdex/services/sync/timesync.checker.service.hpp new file mode 100644 index 0000000000..e3ccb86eea --- /dev/null +++ b/src/core/atomicdex/services/sync/timesync.checker.service.hpp @@ -0,0 +1,60 @@ +/****************************************************************************** + * Copyright © 2013-2024 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 + +#include +#include + +#include + +namespace atomic_dex +{ + class timesync_checker_service final : public QObject, public ag::ecs::pre_update_system + { + Q_OBJECT + + Q_PROPERTY(QVariant timesyncInfo READ get_timesync_info NOTIFY timesyncInfoChanged) + Q_PROPERTY(bool isTimesyncFetching READ get_is_timesync_fetching NOTIFY isTimesyncFetchingChanged) + + using t_timesync_time_point = std::chrono::high_resolution_clock::time_point; + using t_bool_synchronized = boost::synchronized_value; + + t_bool_synchronized m_timesync_info; + t_timesync_time_point m_timesync_clock; + t_bool_synchronized is_timesync_fetching; + + void fetch_timesync_info(); + + public: + explicit timesync_checker_service(entt::registry& registry, QObject* parent = nullptr); + ~timesync_checker_service() final = default; + + void update() final; + + [[nodiscard]] bool get_timesync_info() const; + [[nodiscard]] bool get_is_timesync_fetching() const noexcept { return *is_timesync_fetching; } + + signals: + void timesyncInfoChanged(); + void isTimesyncFetchingChanged(); + }; +} // namespace atomic_dex + +REFL_AUTO(type(atomic_dex::timesync_checker_service)) From c20f43adbdd8488ebd5e4d934b478b1be5683873 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 22 Aug 2024 01:15:07 +0800 Subject: [PATCH 11/17] include timesync service --- src/app/app.cpp | 15 ++++++++++++++- src/app/app.hpp | 4 ++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app/app.cpp b/src/app/app.cpp index 8036d57e47..f2bf63ef11 100644 --- a/src/app/app.cpp +++ b/src/app/app.cpp @@ -44,6 +44,7 @@ #include "atomicdex/services/price/komodo_prices/komodo.prices.provider.hpp" #include "atomicdex/services/price/coingecko/coingecko.wallet.charts.hpp" #include "atomicdex/services/price/orderbook.scanner.service.hpp" +#include "atomicdex/services/sync/timesync.checker.service.hpp" namespace { @@ -498,6 +499,7 @@ namespace atomic_dex system_manager_.create_system(system_manager_); system_manager_.create_system(); system_manager_.create_system(); + system_manager_.create_system(); system_manager_.create_system(system_manager_); system_manager_.create_system(system_manager_); system_manager_.create_system( @@ -910,7 +912,18 @@ namespace atomic_dex } } // namespace atomic_dex -//! update checker +//! time sync checker +namespace atomic_dex +{ + timesync_checker_service* application::get_timesync_checker_service() const + { + auto ptr = const_cast(std::addressof(system_manager_.get_system())); + assert(ptr != nullptr); + return ptr; + } +} // namespace atomic_dex + +//! zcash_params checker namespace atomic_dex { zcash_params_service* application::get_zcash_params_service() const diff --git a/src/app/app.hpp b/src/app/app.hpp index e6d26b7fd1..6e1e93a9fe 100644 --- a/src/app/app.hpp +++ b/src/app/app.hpp @@ -50,6 +50,7 @@ #include "atomicdex/services/price/global.provider.hpp" #include "atomicdex/services/update/update.checker.service.hpp" #include "atomicdex/services/update/zcash.params.service.hpp" +#include "atomicdex/services/sync/timesync.checker.service.hpp" #include "atomicdex/utilities/qt.utilities.hpp" namespace ag = antara::gaming; @@ -75,6 +76,7 @@ namespace atomic_dex Q_PROPERTY(settings_page* settings_pg READ get_settings_page NOTIFY settingsPageChanged) Q_PROPERTY(qt_wallet_manager* wallet_mgr READ get_wallet_mgr NOTIFY walletMgrChanged) Q_PROPERTY(update_checker_service* updateCheckerService READ get_update_checker_service NOTIFY updateCheckerServiceChanged) + Q_PROPERTY(timesync_checker_service* timesyncCheckerService READ get_timesync_checker_service NOTIFY timesyncCheckerServiceChanged) Q_PROPERTY(zcash_params_service* zcash_params READ get_zcash_params_service NOTIFY zcashParamsServiceChanged) //! Private function @@ -135,6 +137,7 @@ namespace atomic_dex qt_wallet_manager* get_wallet_mgr() const; internet_service_checker* get_internet_checker() const; update_checker_service* get_update_checker_service() const; + timesync_checker_service* get_timesync_checker_service() const; [[nodiscard]] zcash_params_service* get_zcash_params_service() const; exporter_service* get_exporter_service() const; @@ -180,6 +183,7 @@ namespace atomic_dex void walletPageChanged(); void ordersChanged(); void updateCheckerServiceChanged(); + void timesyncCheckerServiceChanged(); void zcashParamsServiceChanged(); void tradingPageChanged(); void settingsPageChanged(); From 90b1d025b9a045db9f391fb446b2b80dd13e2560 Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 22 Aug 2024 21:03:09 +0800 Subject: [PATCH 12/17] add tooltip and default to portoflio when dex disabled --- .../Dex/Exchange/Trade/FeeIcon.qml | 4 +-- atomic_defi_design/Dex/Sidebar/Center.qml | 24 ++++++++++++- .../Dex/Sidebar/FigurativeLine.qml | 11 ++++++ .../sync/timesync.checker.service.cpp | 34 ++++++++++--------- .../sync/timesync.checker.service.hpp | 4 +-- 5 files changed, 56 insertions(+), 21 deletions(-) diff --git a/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml b/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml index a5f65a9ba9..883e5e13d1 100644 --- a/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml +++ b/atomic_defi_design/Dex/Exchange/Trade/FeeIcon.qml @@ -24,12 +24,12 @@ DefaultText { visible: mouse_area.containsMouse contentItem: ColumnLayout { - DefaultText { + DexLabel { id: tx_fee_text text_value: General.txFeeText(trade_info, base, false) font.pixelSize: Style.textSizeSmall4 } - DefaultText { + DexLabel { text_value: General.tradingFeeText(trade_info, base, false) font.pixelSize: tx_fee_text.font.pixelSize } diff --git a/atomic_defi_design/Dex/Sidebar/Center.qml b/atomic_defi_design/Dex/Sidebar/Center.qml index 89ab94df97..a3e2586d90 100644 --- a/atomic_defi_design/Dex/Sidebar/Center.qml +++ b/atomic_defi_design/Dex/Sidebar/Center.qml @@ -15,6 +15,25 @@ MouseArea height: lineHeight * 5 hoverEnabled: true + Connections + { + target: API.app.timesyncCheckerService + + function onTimesyncInfoChanged() + { + if (!API.app.timesyncCheckerService.timesyncInfo) + { + _dexLine.timesyncInfo = false + if (currentLineType === Main.LineType.DEX) currentLineType = Main.LineType.Portfolio + root.lineSelected(Main.LineType.Portfolio); + } + else + { + _dexLine.timesyncInfo = true + } + } + } + Connections { target: parent.parent @@ -84,12 +103,15 @@ MouseArea FigurativeLine { id: _dexLine + property var timesyncInfo: API.app.timesyncCheckerService.timesyncInfo Layout.fillWidth: true type: Main.LineType.DEX + label.color: timesyncInfo ? Dex.CurrentTheme.foregroundColor : Dex.CurrentTheme.textDisabledColor label.text: qsTr("DEX") // isExpanded ? qsTr("DEX") : "" icon.source: General.image_path + "menu-exchange-white.svg" - onClicked: lineSelected(type) + onClicked: timesyncInfo ? lineSelected(type) : null + disabled_tt_text: timesyncInfo ? "" : qsTr("DEX is disabled due to system clock synchronization issues. Please check your device time settings.") } FigurativeLine diff --git a/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml b/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml index 540ca6e11b..a747a36e7f 100644 --- a/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml +++ b/atomic_defi_design/Dex/Sidebar/FigurativeLine.qml @@ -1,12 +1,14 @@ import QtQuick 2.12 import "../Components" +import "../Constants" import Dex.Themes 1.0 as Dex // FigurativeLine acts the same as Line but contains a figurative icon on the left of its label Line { property alias icon: _icon + property string disabled_tt_text: "" DefaultImage { @@ -26,4 +28,13 @@ Line currentLineType === type && type != Main.LineType.Support ? Dex.CurrentTheme.sidebarLineTextSelected : Dex.CurrentTheme.foregroundColor } + + DexTooltip + { + visible: mouseArea.containsMouse && disabled_tt_text + delay: 500 + timeout: 5000 + text: disabled_tt_text + font.pixelSize: Style.textSizeSmall4 + } } diff --git a/src/core/atomicdex/services/sync/timesync.checker.service.cpp b/src/core/atomicdex/services/sync/timesync.checker.service.cpp index b74efa0927..2909368a4e 100644 --- a/src/core/atomicdex/services/sync/timesync.checker.service.cpp +++ b/src/core/atomicdex/services/sync/timesync.checker.service.cpp @@ -37,7 +37,6 @@ namespace web::http::http_request req; req.set_method(web::http::methods::GET); req.set_request_uri(FROM_STD_STR("api/timezone/UTC")); - SPDLOG_INFO("req: {}", TO_STD_STR(req.to_string())); return g_timesync_client->request(req, g_synctoken_source.get_token()); } @@ -54,14 +53,13 @@ namespace else { resp = nlohmann::json::parse(resp_str); - int8_t epoch_ts = resp["unixtime"]; - int8_t current_ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); - int8_t ts_diff = epoch_ts - current_ts; + int64_t epoch_ts = resp["unixtime"]; + int64_t current_ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + int64_t ts_diff = epoch_ts - current_ts; if (abs(ts_diff) < 60) { sync_ok = true; } - SPDLOG_WARN("TIME SYNC STATUS [{}]", sync_ok); } return sync_ok; } @@ -73,42 +71,46 @@ namespace atomic_dex timesync_checker_service::timesync_checker_service(entt::registry& registry, QObject* parent) : QObject(parent), system(registry) { m_timesync_clock = std::chrono::high_resolution_clock::now(); - fetch_timesync_info(); + m_timesync_status = true; + fetch_timesync_status(); } void timesync_checker_service::update() { using namespace std::chrono_literals; - const auto now = std::chrono::high_resolution_clock::now(); - const auto s = std::chrono::duration_cast(now - m_timesync_clock); - if (s >= 1min) + int64_t m_timesync_clock_ts = std::chrono::duration_cast(m_timesync_clock.time_since_epoch()).count(); + int64_t now_ts = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); + int64_t ts_diff = now_ts - m_timesync_clock_ts; + if (abs(ts_diff) >= 60) { - fetch_timesync_info(); + fetch_timesync_status(); m_timesync_clock = std::chrono::high_resolution_clock::now(); } } - void timesync_checker_service::fetch_timesync_info() + void timesync_checker_service::fetch_timesync_status() { if (is_timesync_fetching) + { return; + } is_timesync_fetching = true; emit isTimesyncFetchingChanged(); async_fetch_timesync() .then([this](web::http::http_response resp) { - - this->m_timesync_info = get_timesync_info_rpc(resp); - is_timesync_fetching = false; - emit isTimesyncFetchingChanged(); + this->m_timesync_status = get_timesync_info_rpc(resp); emit timesyncInfoChanged(); }) .then(&handle_exception_pplx_task); + is_timesync_fetching = false; + emit isTimesyncFetchingChanged(); + } bool timesync_checker_service::get_timesync_info() const { - return *m_timesync_info; + return *m_timesync_status; } } // namespace atomic_dex diff --git a/src/core/atomicdex/services/sync/timesync.checker.service.hpp b/src/core/atomicdex/services/sync/timesync.checker.service.hpp index e3ccb86eea..54b3f73bf5 100644 --- a/src/core/atomicdex/services/sync/timesync.checker.service.hpp +++ b/src/core/atomicdex/services/sync/timesync.checker.service.hpp @@ -36,11 +36,11 @@ namespace atomic_dex using t_timesync_time_point = std::chrono::high_resolution_clock::time_point; using t_bool_synchronized = boost::synchronized_value; - t_bool_synchronized m_timesync_info; + t_bool_synchronized m_timesync_status; t_timesync_time_point m_timesync_clock; t_bool_synchronized is_timesync_fetching; - void fetch_timesync_info(); + void fetch_timesync_status(); public: explicit timesync_checker_service(entt::registry& registry, QObject* parent = nullptr); From f21317a0ab84e4fc16b0d04bf1139815901cd66b Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 22 Aug 2024 22:23:50 +0800 Subject: [PATCH 13/17] revert nim sed workaround --- .github/workflows/atomicdex-desktop-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/atomicdex-desktop-ci.yml b/.github/workflows/atomicdex-desktop-ci.yml index 29d2968258..6446916b4a 100644 --- a/.github/workflows/atomicdex-desktop-ci.yml +++ b/.github/workflows/atomicdex-desktop-ci.yml @@ -160,7 +160,6 @@ jobs: echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV export CHOOSENIM_CHOOSE_VERSION=1.6.2 curl https://nim-lang.org/choosenim/init.sh > choosenim.sh - sed -i.bak 's|https://github.com/nim-lang/choosenim/releases/download/|https://github.com/dom96/choosenim/releases/download/|g' choosenim.sh chmod +x choosenim.sh ./choosenim.sh -y export PATH=/home/runner/.nimble/bin:$PATH @@ -172,7 +171,6 @@ jobs: echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV export CHOOSENIM_CHOOSE_VERSION=1.6.2 curl https://nim-lang.org/choosenim/init.sh > choosenim.sh - sed -i.bak 's|https://github.com/nim-lang/choosenim/releases/download/|https://github.com/dom96/choosenim/releases/download/|g' choosenim.sh chmod +x choosenim.sh ./choosenim.sh -y export PATH=/Users/runner/.nimble/bin:$PATH From 08ffc35865fb5657e6408450e8e78639a174411f Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 22 Aug 2024 22:46:12 +0800 Subject: [PATCH 14/17] use static script pinned to nim 0.8.4 --- .github/workflows/atomicdex-desktop-ci.yml | 8 +- ci_tools_atomic_dex/ci_scripts/choosenim.sh | 196 ++++++++++++++++++++ 2 files changed, 198 insertions(+), 6 deletions(-) create mode 100755 ci_tools_atomic_dex/ci_scripts/choosenim.sh diff --git a/.github/workflows/atomicdex-desktop-ci.yml b/.github/workflows/atomicdex-desktop-ci.yml index 6446916b4a..87af63785f 100644 --- a/.github/workflows/atomicdex-desktop-ci.yml +++ b/.github/workflows/atomicdex-desktop-ci.yml @@ -159,9 +159,7 @@ jobs: export SHELL=/bin/bash echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV export CHOOSENIM_CHOOSE_VERSION=1.6.2 - curl https://nim-lang.org/choosenim/init.sh > choosenim.sh - chmod +x choosenim.sh - ./choosenim.sh -y + ./ci_tools_atomic_dex/ci_scripts/choosenim.sh -y export PATH=/home/runner/.nimble/bin:$PATH chmod +x /home/runner/.choosenim/toolchains/nim-1.6.2/bin/* @@ -170,9 +168,7 @@ jobs: run: | echo "CHOOSENIM_CHOOSE_VERSION=1.6.2" >> $GITHUB_ENV export CHOOSENIM_CHOOSE_VERSION=1.6.2 - curl https://nim-lang.org/choosenim/init.sh > choosenim.sh - chmod +x choosenim.sh - ./choosenim.sh -y + ./ci_tools_atomic_dex/ci_scripts/choosenim.sh -y export PATH=/Users/runner/.nimble/bin:$PATH chmod +x /Users/runner/.choosenim/toolchains/nim-1.6.2/bin/* diff --git a/ci_tools_atomic_dex/ci_scripts/choosenim.sh b/ci_tools_atomic_dex/ci_scripts/choosenim.sh new file mode 100755 index 0000000000..b255b48ab1 --- /dev/null +++ b/ci_tools_atomic_dex/ci_scripts/choosenim.sh @@ -0,0 +1,196 @@ +#!/bin/sh +# Copyright 2017 Dominik Picheta and Nim developers. +# +# Licensed under the BSD-3-Clause license. +# +# This script performs some platform detection, downloads the latest version +# of choosenim and initiates its installation. + +set -u +set -e + + +url_prefix="https://github.com/dom96/choosenim/releases/download/" + +temp_prefix="${TMPDIR:-/tmp}" + +CHOOSE_VERSION="${CHOOSENIM_CHOOSE_VERSION:-stable}" + +need_tty=yes +debug="" + +has_curl() { + command -v curl >/dev/null 2>&1 +} + +has_wget() { + command -v wget >/dev/null 2>&1 +} + +install() { + get_platform || return 1 + local platform=$RET_VAL + local stable_version=0.8.4 + local filename="choosenim-$stable_version"_"$platform" + local url="$url_prefix"v"$stable_version/$filename" + local ext="" + + case $platform in + *macosx_amd64* | *linux_amd64* ) + ;; + *windows_amd64* ) + # Download ZIP for Windows + local ext=".exe" + local filename="$filename$ext" + local url="$url$ext" + ;; + * ) + say_err "Sorry, your platform ($platform) is not supported by choosenim." + say_err "You will need to install Nim using an alternative method." + say_err "See the following link for more info: https://nim-lang.org/install.html" + exit 1 + ;; + esac + + say "Downloading $filename" + if has_curl; then + curl -sSfL "$url" -o "$temp_prefix/$filename" + elif has_wget; then + wget -qO "$temp_prefix/$filename" "$url" + fi + chmod +x "$temp_prefix/$filename" + + if [ "$need_tty" = "yes" ]; then + # The installer is going to want to ask for confirmation by + # reading stdin. This script was piped into `sh` though and + # doesn't have stdin to pass to its children. Instead we're going + # to explicitly connect /dev/tty to the installer's stdin. + if [ ! -t 1 ]; then + err "Unable to run interactively. Run with -y to accept defaults." + fi + + # Install Nim from desired channel. + "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall ${debug} < /dev/tty + else + "$temp_prefix/$filename" $CHOOSE_VERSION --firstInstall -y ${debug} + fi + + # Copy choosenim binary to Nimble bin. + local nimbleBinDir=`"$temp_prefix/$filename" --getNimbleBin` + cp "$temp_prefix/$filename" "$nimbleBinDir/choosenim$ext" + say "ChooseNim installed in $nimbleBinDir" + say "You must now ensure that the Nimble bin dir is in your PATH." + if [ "$platform" != "windows_amd64" ]; then + say "Place the following line in the ~/.profile or ~/.bashrc file." + say " export PATH=$nimbleBinDir:\$PATH" + case "${SHELL:=sh}" in + *fish*) + say "Running fish shell?" + say "set -ga fish_user_paths $nimbleBinDir" + ;; + esac + fi +} + +get_platform() { + # Get OS/CPU info and store in a `myos` and `mycpu` variable. + local ucpu=`uname -m` + local uos=`uname` + local ucpu=`echo $ucpu | tr "[:upper:]" "[:lower:]"` + local uos=`echo $uos | tr "[:upper:]" "[:lower:]"` + + case $uos in + *linux* ) + local myos="linux" + ;; + *dragonfly* ) + local myos="freebsd" + ;; + *freebsd* ) + local myos="freebsd" + ;; + *openbsd* ) + local myos="openbsd" + ;; + *netbsd* ) + local myos="netbsd" + ;; + *darwin* ) + local myos="macosx" + if [ "$HOSTTYPE" = "x86_64" ] ; then + local ucpu="amd64" + fi + if [ "$HOSTTYPE" = "arm64" ] ; then + # TODO: We don't have arm binaries for choosenim so far, rely on Rosetta. + local ucpu="amd64" + fi + ;; + *aix* ) + local myos="aix" + ;; + *solaris* | *sun* ) + local myos="solaris" + ;; + *haiku* ) + if has_curl; then + stable_version=`curl -sSfL https://nim-lang.org/choosenim/stable` + elif has_wget; then + stable_version=`wget -qO - https://nim-lang.org/choosenim/stable` + fi + err "unknown operating system: $uos" + ;; + esac + + case $ucpu in + *i386* | *i486* | *i586* | *i686* | *bepc* | *i86pc* ) + local mycpu="i386" ;; + *amd*64* | *x86-64* | *x86_64* ) + local mycpu="amd64" ;; + *sparc*|*sun* ) + local mycpu="sparc" + if [ "$(isainfo -b)" = "64" ]; then + local mycpu="sparc64" + fi + ;; + *ppc64* ) + local mycpu="powerpc64" ;; + *power*|*ppc* ) + local mycpu="powerpc" ;; + *mips* ) + local mycpu="mips" ;; + *arm*|*armv6l* ) + local mycpu="arm" ;; + *aarch64* ) + local mycpu="arm64" ;; + *) + err "unknown processor: $ucpu" + ;; + esac + + RET_VAL="$myos"_"$mycpu" +} + +say() { + echo "choosenim-init: $1" +} + +say_err() { + say "Error: $1" >&2 +} + +err() { + say_err "$1" + exit 1 +} + + +# check if we have to use /dev/tty to prompt the user +while getopts "dy" opt; do + case "$opt" in + y) need_tty=no + ;; + d) debug="--debug" + esac +done + +install From 45effc175db4c285ea21aa1591b90a1c8c9e525a Mon Sep 17 00:00:00 2001 From: smk762 Date: Thu, 22 Aug 2024 23:42:54 +0800 Subject: [PATCH 15/17] update binaries url --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f3c1ca020..6fe4e988fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,13 +60,13 @@ endif () ##! We fetch our dependencies if (APPLE) FetchContent_Declare(kdf - URL https://sdk.devbuilds.komodo.earth/main/kdf_35e9239-mac-x86-64.zip) + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.1.0-beta/mm2-35e923949-Darwin-Release.zip) elseif (UNIX AND NOT APPLE) FetchContent_Declare(kdf - URL https://sdk.devbuilds.komodo.earth/main/kdf_35e9239-linux-x86-64.zip) + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.1.0-beta/mm2-35e923949-Linux-Release.zip) else () FetchContent_Declare(kdf - URL https://sdk.devbuilds.komodo.earth/main/kdf_35e9239-win-x86-64.zip) + URL https://github.com/KomodoPlatform/komodo-defi-framework/releases/download/v2.1.0-beta/mm2-35e923949-Win64.zip) endif () #FetchContent_Declare(qmaterial URL https://github.com/KomodoPlatform/Qaterial/archive/last-clang-working-2.zip) From 8ea79d5316f422dfd06910dbd40f5e61bb20c3c1 Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 23 Aug 2024 00:17:08 +0800 Subject: [PATCH 16/17] handle binary name change --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fe4e988fd..49fa003f6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,12 +89,12 @@ FetchContent_MakeAvailable(kdf jl777-coins qmaterial) if (UNIX) 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/kdf/coins COPYONLY) - configure_file(${kdf_SOURCE_DIR}/kdf ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/kdf/${DEX_API} COPYONLY) + configure_file(${kdf_SOURCE_DIR}/mm2 ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/kdf/${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_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/kdf/coins COPYONLY) - configure_file(${kdf_SOURCE_DIR}/kdf.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/${DEX_API}.exe COPYONLY) + configure_file(${kdf_SOURCE_DIR}/mm2.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/${DEX_API}.exe COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/msvcp140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/msvcp140.dll COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/vcruntime140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/vcruntime140.dll COPYONLY) endif () From 5583759d42375f2c73dee3a7bcb3c1d15f25861e Mon Sep 17 00:00:00 2001 From: smk762 Date: Fri, 23 Aug 2024 00:17:59 +0800 Subject: [PATCH 17/17] handle binary name change --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fe4e988fd..49fa003f6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,12 +89,12 @@ FetchContent_MakeAvailable(kdf jl777-coins qmaterial) if (UNIX) 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/kdf/coins COPYONLY) - configure_file(${kdf_SOURCE_DIR}/kdf ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/kdf/${DEX_API} COPYONLY) + configure_file(${kdf_SOURCE_DIR}/mm2 ${CMAKE_CURRENT_SOURCE_DIR}/assets/tools/kdf/${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_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/kdf/coins COPYONLY) - configure_file(${kdf_SOURCE_DIR}/kdf.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/${DEX_API}.exe COPYONLY) + configure_file(${kdf_SOURCE_DIR}/mm2.exe ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/${DEX_API}.exe COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/msvcp140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/msvcp140.dll COPYONLY) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ci_tools_atomic_dex/windows_misc/vcruntime140.dll ${CMAKE_BINARY_DIR}/bin/assets/tools/kdf/vcruntime140.dll COPYONLY) endif ()