fix(@desktop/wallet): fix for SwapSignModal has wrong value

fixes #15605
This commit is contained in:
Khushboo Mehta 2024-07-17 18:03:36 +02:00 committed by Khushboo-dev-cpp
parent fd3b76115f
commit 4b30b12fee
4 changed files with 20 additions and 3 deletions

View File

@ -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"

View File

@ -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")

View File

@ -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

View File

@ -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)