fix(@desktop/wallet): Wrong Password error should not be handled in the SendModal

fixes #8527
This commit is contained in:
Khushboo Mehta 2022-11-30 19:57:00 +01:00 committed by Khushboo-dev-cpp
parent c3dbe66e02
commit 0c7442d696
11 changed files with 63 additions and 54 deletions

View File

@ -20,6 +20,8 @@ logScope:
include ../../../../../app_service/common/json_utils
const cancelledRequest* = "cancelled"
# Shouldn't be public ever, user only within this module.
type TmpSendEnsTransactionDetails = object
ensUsername: string
@ -359,10 +361,14 @@ method setPrefferedEnsUsername*(self: Module, ensUsername: string) =
self.controller.setPreferredName(ensUsername)
method onUserAuthenticated*(self: Module, password: string) =
if self.tmpSendEnsTransactionDetails.isRegistration:
self.registerEns(password)
elif self.tmpSendEnsTransactionDetails.isRelease:
self.releaseEns(password)
elif self.tmpSendEnsTransactionDetails.isSetPubKey:
self.setPubKey(password)
if password.len == 0:
let response = %* {"success": false, "result": cancelledRequest}
self.view.emitTransactionWasSentSignal($response)
else:
if self.tmpSendEnsTransactionDetails.isRegistration:
self.registerEns(password)
elif self.tmpSendEnsTransactionDetails.isRelease:
self.releaseEns(password)
elif self.tmpSendEnsTransactionDetails.isSetPubKey:
self.setPubKey(password)

View File

@ -11,6 +11,8 @@ import ../../../../app_service/service/wallet_account/service as wallet_account_
export io_interface
const cancelledRequest* = "cancelled"
# Shouldn't be public ever, user only within this module.
type TmpBuyStickersTransactionDetails = object
packId: string
@ -101,21 +103,25 @@ method authenticateAndBuy*(self: Module, packId: string, address: string, gas: s
##################################
method onUserAuthenticated*(self: Module, password: string) =
let responseTuple = self.controller.buy(
self.tmpBuyStickersTransactionDetails.packId,
self.tmpBuyStickersTransactionDetails.address,
self.tmpBuyStickersTransactionDetails.gas,
self.tmpBuyStickersTransactionDetails.gasPrice,
self.tmpBuyStickersTransactionDetails.maxPriorityFeePerGas,
self.tmpBuyStickersTransactionDetails.maxFeePerGas,
password,
self.tmpBuyStickersTransactionDetails.eip1559Enabled
)
let response = responseTuple.response
let success = responseTuple.success
if success:
self.view.stickerPacks.updateStickerPackInList(self.tmpBuyStickersTransactionDetails.packId, false, true)
self.view.transactionWasSent($(%*{"success": success, "result": response}))
if password.len == 0:
let response = %* {"success": false, "error": cancelledRequest}
self.view.transactionWasSent($response)
else:
let responseTuple = self.controller.buy(
self.tmpBuyStickersTransactionDetails.packId,
self.tmpBuyStickersTransactionDetails.address,
self.tmpBuyStickersTransactionDetails.gas,
self.tmpBuyStickersTransactionDetails.gasPrice,
self.tmpBuyStickersTransactionDetails.maxPriorityFeePerGas,
self.tmpBuyStickersTransactionDetails.maxFeePerGas,
password,
self.tmpBuyStickersTransactionDetails.eip1559Enabled
)
let response = responseTuple.response
let success = responseTuple.success
if success:
self.view.stickerPacks.updateStickerPackInList(self.tmpBuyStickersTransactionDetails.packId, false, true)
self.view.transactionWasSent($(%*{"success": success, "result": response}))
method getInstalledStickerPacks*(self: Module): Table[string, StickerPackDto] =
self.controller.getInstalledStickerPacks()

View File

@ -1,4 +1,4 @@
import NimQml, stint
import NimQml, stint, json
import ./io_interface, ./view, ./controller
import ../io_interface as delegate_interface
@ -10,6 +10,8 @@ import ../../../../../app_service/service/network/service as network_service
export io_interface
const cancelledRequest* = "cancelled"
# Shouldn't be public ever, user only within this module.
type TmpSendTransactionDetails = object
fromAddr: string
@ -135,9 +137,13 @@ method authenticateAndTransfer*(self: Module, from_addr: string, to_addr: string
##################################
method onUserAuthenticated*(self: Module, password: string) =
self.controller.transfer(self.tmpSendTransactionDetails.fromAddr, self.tmpSendTransactionDetails.toAddr,
self.tmpSendTransactionDetails.tokenSymbol, self.tmpSendTransactionDetails.value, self.tmpSendTransactionDetails.uuid,
self.tmpSendTransactionDetails.priority, self.tmpSendTransactionDetails.selectedRoutes, password)
if password.len == 0:
let response = %* {"uuid": self.tmpSendTransactionDetails.uuid, "success": false, "error": cancelledRequest}
self.view.transactionWasSent($response)
else:
self.controller.transfer(self.tmpSendTransactionDetails.fromAddr, self.tmpSendTransactionDetails.toAddr,
self.tmpSendTransactionDetails.tokenSymbol, self.tmpSendTransactionDetails.value, self.tmpSendTransactionDetails.uuid,
self.tmpSendTransactionDetails.priority, self.tmpSendTransactionDetails.selectedRoutes, password)
method transactionWasSent*(self: Module, result: string) =
self.view.transactionWasSent(result)

View File

@ -150,8 +150,7 @@ Item {
try {
let response = JSON.parse(txResult)
if (!response.success) {
if (Utils.isInvalidPasswordMessage(response.result)) {
releaseEnsModal.setSendTxError()
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
return
}
releaseEnsModal.sendingError.text = response.result

View File

@ -101,8 +101,7 @@ Item {
try {
let response = JSON.parse(txResult)
if (!response.success) {
if (Utils.isInvalidPasswordMessage(response.result)) {
releaseEnsModal.setSendTxError()
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
return
}
releaseEnsModal.sendingError.text = response.result

View File

@ -90,8 +90,7 @@ Item {
try {
let response = JSON.parse(txResult)
if (!response.success) {
if (Utils.isInvalidPasswordMessage(response.result)) {
buyEnsModal.setSendTxError()
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
return
}
buyEnsModal.sendingError.text = response.result

View File

@ -69,7 +69,6 @@ StatusDialog {
}
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
d.sendTxError = false
if(!!popup.selectedAccount && !!assetSelector.selectedAsset) {
popup.isLoading = true
let amount = parseFloat(amountToSendInput.text) * Math.pow(10, assetSelector.selectedAsset.decimals)
@ -79,11 +78,6 @@ StatusDialog {
}
})
function setSendTxError() {
d.sendTxError = true
d.sendTxErrorString = qsTr("Wrong password")
}
QtObject {
id: d
readonly property double maxFiatBalance: assetSelector.selectedAsset ? assetSelector.selectedAsset.totalBalance: 0
@ -102,8 +96,7 @@ StatusDialog {
property string resolvedENSAddress
readonly property string uuid: Utils.uuid()
property bool isPendingTx: false
property bool sendTxError: false
property string sendTxErrorString
property var preferredChainIds: []
property Timer waitTimer: Timer {
interval: 1000
@ -195,13 +188,14 @@ StatusDialog {
Rectangle {
Layout.preferredWidth: parent.width
Layout.preferredHeight: assetAndAmmountSelector.height + Style.current.padding
Layout.preferredHeight: assetAndAmmountSelector.height + Style.current.halfPadding
color: Theme.palette.baseColor3
z: 100
layer.enabled: scrollView.contentY > 0
layer.effect: DropShadow {
verticalOffset: 2
radius: 16
verticalOffset: 0
radius: 8
samples: 17
color: Theme.palette.dropShadow
}
@ -226,11 +220,11 @@ StatusDialog {
StatusListItemTag {
height: 22
width: childrenRect.width
title: d.sendTxError ? d.sendTxErrorString : d.maxFiatBalance > 0 ? qsTr("Max: %1").arg(LocaleUtils.numberToLocaleString(d.maxFiatBalance)) : qsTr("No balances active")
title: d.maxFiatBalance > 0 ? qsTr("Max: %1").arg(LocaleUtils.numberToLocaleString(d.maxFiatBalance)) : qsTr("No balances active")
closeButtonVisible: false
titleText.font.pixelSize: 12
color: d.errorMode || d.sendTxError ? Theme.palette.dangerColor2 : Theme.palette.primaryColor3
titleText.color: d.errorMode || d.sendTxError ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
color: d.errorMode ? Theme.palette.dangerColor2 : Theme.palette.primaryColor3
titleText.color: d.errorMode ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
}
}
Item {
@ -532,9 +526,7 @@ StatusDialog {
if (response.uuid !== d.uuid) return
if (!response.success) {
if (Utils.isInvalidPasswordMessage(response.error)) {
d.sendTxError = true
d.sendTxErrorString = qsTr("Wrong password")
if (response.error.includes(Constants.walletSection.cancelledMessage)) {
return
}
sendingError.text = response.error

View File

@ -193,8 +193,7 @@ Item {
try {
let response = JSON.parse(txResult)
if (!response.success) {
if (Utils.isInvalidPasswordMessage(response.result)) {
buyStickersModal.setSendTxError()
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
return
}
buyStickersModal.sendingError.text = response.result

View File

@ -106,8 +106,7 @@ ModalPopup {
try {
let response = JSON.parse(txResult)
if (!response.success) {
if (Utils.isInvalidPasswordMessage(response.result)) {
buyStickersPackModal.setSendTxError()
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
return
}
buyStickersPackModal.sendingError.text = response.result

View File

@ -121,10 +121,10 @@ Item {
spacing: 12
StatusBaseText {
Layout.alignment: Qt.AlignRight
Layout.maximumWidth: 70
Layout.maximumWidth: 100
font.pixelSize: 10
color: Theme.palette.baseColor1
text: selectedAccount.address
text: StatusQUtils.Utils.elideText(selectedAccount.address, 6, 4).toUpperCase()
elide: Text.ElideMiddle
}
Repeater {

View File

@ -715,4 +715,8 @@ QtObject {
StickersBuy,
Bridge
}
readonly property QtObject walletSection: QtObject {
readonly property string cancelledMessage: "cancelled"
}
}