From 4b30b12feecb9c063aa9aa08d22dd5311713096e Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Wed, 17 Jul 2024 18:03:36 +0200 Subject: [PATCH] fix(@desktop/wallet): fix for SwapSignModal has wrong value fixes #15605 --- storybook/pages/SwapSignModalPage.qml | 3 +++ storybook/qmlTests/tests/tst_SwapSignModal.qml | 11 ++++++++++- ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml | 2 ++ .../AppLayouts/Wallet/popups/swap/SwapSignModal.qml | 7 +++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/storybook/pages/SwapSignModalPage.qml b/storybook/pages/SwapSignModalPage.qml index f46ca9498e..87ead2dd69 100644 --- a/storybook/pages/SwapSignModalPage.qml +++ b/storybook/pages/SwapSignModalPage.qml @@ -8,6 +8,7 @@ import Storybook 1.0 import Models 1.0 import AppLayouts.Wallet.popups.swap 1.0 +import shared.stores 1.0 import utils 1.0 @@ -74,6 +75,8 @@ SplitView { modal: false closePolicy: Popup.NoAutoClose + currencyStore: CurrenciesStore{} + fromTokenSymbol: ctrlFromSymbol.text fromTokenAmount: ctrlFromAmount.text fromTokenContractAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F" diff --git a/storybook/qmlTests/tests/tst_SwapSignModal.qml b/storybook/qmlTests/tests/tst_SwapSignModal.qml index 255a50816d..098b032221 100644 --- a/storybook/qmlTests/tests/tst_SwapSignModal.qml +++ b/storybook/qmlTests/tests/tst_SwapSignModal.qml @@ -8,6 +8,7 @@ import Models 1.0 import StatusQ.Core.Utils 0.1 as SQUtils import AppLayouts.Wallet.popups.swap 1.0 +import shared.stores 1.0 import utils 1.0 @@ -16,11 +17,18 @@ Item { width: 600 height: 400 + QtObject { + id: d + readonly property var currencyStore: CurrenciesStore{} + } + Component { id: componentUnderTest SwapSignModal { anchors.centerIn: parent + currencyStore: d.currencyStore + fromTokenSymbol: "DAI" fromTokenAmount: "100.07" fromTokenContractAddress: "0x6B175474E89094C44Da98b954EedeAC495271d0F" @@ -95,7 +103,8 @@ Item { // title & subtitle compare(controlUnderTest.title, qsTr("Sign Swap")) - compare(controlUnderTest.subtitle, qsTr("1000.1235 SNT to 1.42 %2").arg(data.toTokenSymbol)) // subtitle rounded amounts + compare(controlUnderTest.subtitle, qsTr("%1 to %2").arg(d.currencyStore.formatCurrencyAmount(controlUnderTest.fromTokenAmount, controlUnderTest.fromTokenSymbol)) + .arg(d.currencyStore.formatCurrencyAmount(controlUnderTest.toTokenAmount, controlUnderTest.toTokenSymbol))) // info box const headerText = findChild(controlUnderTest.contentItem, "headerText") diff --git a/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml b/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml index d4b2091d2c..6f1aad7200 100644 --- a/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml +++ b/ui/app/AppLayouts/Wallet/popups/swap/SwapModal.qml @@ -472,6 +472,8 @@ StatusDialog { SwapSignModal { destroyOnClose: true + currencyStore: root.swapAdaptor.currencyStore + loginType: root.swapAdaptor.selectedAccount.migratedToKeycard ? Constants.LoginType.Keycard : root.loginType feesLoading: root.swapAdaptor.swapProposalLoading diff --git a/ui/app/AppLayouts/Wallet/popups/swap/SwapSignModal.qml b/ui/app/AppLayouts/Wallet/popups/swap/SwapSignModal.qml index c41be3a4cd..448cc62b3c 100644 --- a/ui/app/AppLayouts/Wallet/popups/swap/SwapSignModal.qml +++ b/ui/app/AppLayouts/Wallet/popups/swap/SwapSignModal.qml @@ -18,6 +18,8 @@ import utils 1.0 SignTransactionModalBase { id: root + required property var currencyStore + required property string fromTokenSymbol required property string fromTokenAmount required property string fromTokenContractAddress @@ -45,8 +47,9 @@ SignTransactionModalBase { title: qsTr("Sign Swap") //: e.g. (swap) 100 DAI to 100 USDT - subtitle: qsTr("%1 %2 to %3 %4").arg(formatBigNumber(fromTokenAmount, 4)).arg(fromTokenSymbol) // FIXME get the correct number of decimals to display from the "symbol" - .arg(formatBigNumber(toTokenAmount, 4)).arg(toTokenSymbol) + subtitle: qsTr("%1 to %2") + .arg(root.currencyStore.formatCurrencyAmount(fromTokenAmount, fromTokenSymbol)) + .arg(root.currencyStore.formatCurrencyAmount(toTokenAmount, toTokenSymbol)) gradientColor: Utils.setColorAlpha(root.accountColor, 0.05) // 5% of wallet color fromImageSource: Constants.tokenIcon(root.fromTokenSymbol)