mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-14 00:27:40 +00:00
fix(@desktop/wallet): Wrong Password error should not be handled in the SendModal
fixes #8527
This commit is contained in:
parent
c3dbe66e02
commit
0c7442d696
@ -20,6 +20,8 @@ logScope:
|
|||||||
|
|
||||||
include ../../../../../app_service/common/json_utils
|
include ../../../../../app_service/common/json_utils
|
||||||
|
|
||||||
|
const cancelledRequest* = "cancelled"
|
||||||
|
|
||||||
# Shouldn't be public ever, user only within this module.
|
# Shouldn't be public ever, user only within this module.
|
||||||
type TmpSendEnsTransactionDetails = object
|
type TmpSendEnsTransactionDetails = object
|
||||||
ensUsername: string
|
ensUsername: string
|
||||||
@ -359,10 +361,14 @@ method setPrefferedEnsUsername*(self: Module, ensUsername: string) =
|
|||||||
self.controller.setPreferredName(ensUsername)
|
self.controller.setPreferredName(ensUsername)
|
||||||
|
|
||||||
method onUserAuthenticated*(self: Module, password: string) =
|
method onUserAuthenticated*(self: Module, password: string) =
|
||||||
if self.tmpSendEnsTransactionDetails.isRegistration:
|
if password.len == 0:
|
||||||
self.registerEns(password)
|
let response = %* {"success": false, "result": cancelledRequest}
|
||||||
elif self.tmpSendEnsTransactionDetails.isRelease:
|
self.view.emitTransactionWasSentSignal($response)
|
||||||
self.releaseEns(password)
|
else:
|
||||||
elif self.tmpSendEnsTransactionDetails.isSetPubKey:
|
if self.tmpSendEnsTransactionDetails.isRegistration:
|
||||||
self.setPubKey(password)
|
self.registerEns(password)
|
||||||
|
elif self.tmpSendEnsTransactionDetails.isRelease:
|
||||||
|
self.releaseEns(password)
|
||||||
|
elif self.tmpSendEnsTransactionDetails.isSetPubKey:
|
||||||
|
self.setPubKey(password)
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ import ../../../../app_service/service/wallet_account/service as wallet_account_
|
|||||||
|
|
||||||
export io_interface
|
export io_interface
|
||||||
|
|
||||||
|
const cancelledRequest* = "cancelled"
|
||||||
|
|
||||||
# Shouldn't be public ever, user only within this module.
|
# Shouldn't be public ever, user only within this module.
|
||||||
type TmpBuyStickersTransactionDetails = object
|
type TmpBuyStickersTransactionDetails = object
|
||||||
packId: string
|
packId: string
|
||||||
@ -101,21 +103,25 @@ method authenticateAndBuy*(self: Module, packId: string, address: string, gas: s
|
|||||||
##################################
|
##################################
|
||||||
|
|
||||||
method onUserAuthenticated*(self: Module, password: string) =
|
method onUserAuthenticated*(self: Module, password: string) =
|
||||||
let responseTuple = self.controller.buy(
|
if password.len == 0:
|
||||||
self.tmpBuyStickersTransactionDetails.packId,
|
let response = %* {"success": false, "error": cancelledRequest}
|
||||||
self.tmpBuyStickersTransactionDetails.address,
|
self.view.transactionWasSent($response)
|
||||||
self.tmpBuyStickersTransactionDetails.gas,
|
else:
|
||||||
self.tmpBuyStickersTransactionDetails.gasPrice,
|
let responseTuple = self.controller.buy(
|
||||||
self.tmpBuyStickersTransactionDetails.maxPriorityFeePerGas,
|
self.tmpBuyStickersTransactionDetails.packId,
|
||||||
self.tmpBuyStickersTransactionDetails.maxFeePerGas,
|
self.tmpBuyStickersTransactionDetails.address,
|
||||||
password,
|
self.tmpBuyStickersTransactionDetails.gas,
|
||||||
self.tmpBuyStickersTransactionDetails.eip1559Enabled
|
self.tmpBuyStickersTransactionDetails.gasPrice,
|
||||||
)
|
self.tmpBuyStickersTransactionDetails.maxPriorityFeePerGas,
|
||||||
let response = responseTuple.response
|
self.tmpBuyStickersTransactionDetails.maxFeePerGas,
|
||||||
let success = responseTuple.success
|
password,
|
||||||
if success:
|
self.tmpBuyStickersTransactionDetails.eip1559Enabled
|
||||||
self.view.stickerPacks.updateStickerPackInList(self.tmpBuyStickersTransactionDetails.packId, false, true)
|
)
|
||||||
self.view.transactionWasSent($(%*{"success": success, "result": response}))
|
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] =
|
method getInstalledStickerPacks*(self: Module): Table[string, StickerPackDto] =
|
||||||
self.controller.getInstalledStickerPacks()
|
self.controller.getInstalledStickerPacks()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import NimQml, stint
|
import NimQml, stint, json
|
||||||
|
|
||||||
import ./io_interface, ./view, ./controller
|
import ./io_interface, ./view, ./controller
|
||||||
import ../io_interface as delegate_interface
|
import ../io_interface as delegate_interface
|
||||||
@ -10,6 +10,8 @@ import ../../../../../app_service/service/network/service as network_service
|
|||||||
|
|
||||||
export io_interface
|
export io_interface
|
||||||
|
|
||||||
|
const cancelledRequest* = "cancelled"
|
||||||
|
|
||||||
# Shouldn't be public ever, user only within this module.
|
# Shouldn't be public ever, user only within this module.
|
||||||
type TmpSendTransactionDetails = object
|
type TmpSendTransactionDetails = object
|
||||||
fromAddr: string
|
fromAddr: string
|
||||||
@ -135,9 +137,13 @@ method authenticateAndTransfer*(self: Module, from_addr: string, to_addr: string
|
|||||||
##################################
|
##################################
|
||||||
|
|
||||||
method onUserAuthenticated*(self: Module, password: string) =
|
method onUserAuthenticated*(self: Module, password: string) =
|
||||||
self.controller.transfer(self.tmpSendTransactionDetails.fromAddr, self.tmpSendTransactionDetails.toAddr,
|
if password.len == 0:
|
||||||
self.tmpSendTransactionDetails.tokenSymbol, self.tmpSendTransactionDetails.value, self.tmpSendTransactionDetails.uuid,
|
let response = %* {"uuid": self.tmpSendTransactionDetails.uuid, "success": false, "error": cancelledRequest}
|
||||||
self.tmpSendTransactionDetails.priority, self.tmpSendTransactionDetails.selectedRoutes, password)
|
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) =
|
method transactionWasSent*(self: Module, result: string) =
|
||||||
self.view.transactionWasSent(result)
|
self.view.transactionWasSent(result)
|
||||||
|
@ -150,8 +150,7 @@ Item {
|
|||||||
try {
|
try {
|
||||||
let response = JSON.parse(txResult)
|
let response = JSON.parse(txResult)
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
if (Utils.isInvalidPasswordMessage(response.result)) {
|
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
|
||||||
releaseEnsModal.setSendTxError()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
releaseEnsModal.sendingError.text = response.result
|
releaseEnsModal.sendingError.text = response.result
|
||||||
|
@ -101,8 +101,7 @@ Item {
|
|||||||
try {
|
try {
|
||||||
let response = JSON.parse(txResult)
|
let response = JSON.parse(txResult)
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
if (Utils.isInvalidPasswordMessage(response.result)) {
|
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
|
||||||
releaseEnsModal.setSendTxError()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
releaseEnsModal.sendingError.text = response.result
|
releaseEnsModal.sendingError.text = response.result
|
||||||
|
@ -90,8 +90,7 @@ Item {
|
|||||||
try {
|
try {
|
||||||
let response = JSON.parse(txResult)
|
let response = JSON.parse(txResult)
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
if (Utils.isInvalidPasswordMessage(response.result)) {
|
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
|
||||||
buyEnsModal.setSendTxError()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
buyEnsModal.sendingError.text = response.result
|
buyEnsModal.sendingError.text = response.result
|
||||||
|
@ -69,7 +69,6 @@ StatusDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
|
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
|
||||||
d.sendTxError = false
|
|
||||||
if(!!popup.selectedAccount && !!assetSelector.selectedAsset) {
|
if(!!popup.selectedAccount && !!assetSelector.selectedAsset) {
|
||||||
popup.isLoading = true
|
popup.isLoading = true
|
||||||
let amount = parseFloat(amountToSendInput.text) * Math.pow(10, assetSelector.selectedAsset.decimals)
|
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 {
|
QtObject {
|
||||||
id: d
|
id: d
|
||||||
readonly property double maxFiatBalance: assetSelector.selectedAsset ? assetSelector.selectedAsset.totalBalance: 0
|
readonly property double maxFiatBalance: assetSelector.selectedAsset ? assetSelector.selectedAsset.totalBalance: 0
|
||||||
@ -102,8 +96,7 @@ StatusDialog {
|
|||||||
property string resolvedENSAddress
|
property string resolvedENSAddress
|
||||||
readonly property string uuid: Utils.uuid()
|
readonly property string uuid: Utils.uuid()
|
||||||
property bool isPendingTx: false
|
property bool isPendingTx: false
|
||||||
property bool sendTxError: false
|
property var preferredChainIds: []
|
||||||
property string sendTxErrorString
|
|
||||||
|
|
||||||
property Timer waitTimer: Timer {
|
property Timer waitTimer: Timer {
|
||||||
interval: 1000
|
interval: 1000
|
||||||
@ -195,13 +188,14 @@ StatusDialog {
|
|||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
Layout.preferredWidth: parent.width
|
Layout.preferredWidth: parent.width
|
||||||
Layout.preferredHeight: assetAndAmmountSelector.height + Style.current.padding
|
Layout.preferredHeight: assetAndAmmountSelector.height + Style.current.halfPadding
|
||||||
color: Theme.palette.baseColor3
|
color: Theme.palette.baseColor3
|
||||||
|
z: 100
|
||||||
|
|
||||||
layer.enabled: scrollView.contentY > 0
|
layer.enabled: scrollView.contentY > 0
|
||||||
layer.effect: DropShadow {
|
layer.effect: DropShadow {
|
||||||
verticalOffset: 2
|
verticalOffset: 0
|
||||||
radius: 16
|
radius: 8
|
||||||
samples: 17
|
samples: 17
|
||||||
color: Theme.palette.dropShadow
|
color: Theme.palette.dropShadow
|
||||||
}
|
}
|
||||||
@ -226,11 +220,11 @@ StatusDialog {
|
|||||||
StatusListItemTag {
|
StatusListItemTag {
|
||||||
height: 22
|
height: 22
|
||||||
width: childrenRect.width
|
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
|
closeButtonVisible: false
|
||||||
titleText.font.pixelSize: 12
|
titleText.font.pixelSize: 12
|
||||||
color: d.errorMode || d.sendTxError ? Theme.palette.dangerColor2 : Theme.palette.primaryColor3
|
color: d.errorMode ? Theme.palette.dangerColor2 : Theme.palette.primaryColor3
|
||||||
titleText.color: d.errorMode || d.sendTxError ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
|
titleText.color: d.errorMode ? Theme.palette.dangerColor1 : Theme.palette.primaryColor1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Item {
|
Item {
|
||||||
@ -532,9 +526,7 @@ StatusDialog {
|
|||||||
if (response.uuid !== d.uuid) return
|
if (response.uuid !== d.uuid) return
|
||||||
|
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
if (Utils.isInvalidPasswordMessage(response.error)) {
|
if (response.error.includes(Constants.walletSection.cancelledMessage)) {
|
||||||
d.sendTxError = true
|
|
||||||
d.sendTxErrorString = qsTr("Wrong password")
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
sendingError.text = response.error
|
sendingError.text = response.error
|
||||||
|
@ -193,8 +193,7 @@ Item {
|
|||||||
try {
|
try {
|
||||||
let response = JSON.parse(txResult)
|
let response = JSON.parse(txResult)
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
if (Utils.isInvalidPasswordMessage(response.result)) {
|
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
|
||||||
buyStickersModal.setSendTxError()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
buyStickersModal.sendingError.text = response.result
|
buyStickersModal.sendingError.text = response.result
|
||||||
|
@ -106,8 +106,7 @@ ModalPopup {
|
|||||||
try {
|
try {
|
||||||
let response = JSON.parse(txResult)
|
let response = JSON.parse(txResult)
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
if (Utils.isInvalidPasswordMessage(response.result)) {
|
if (response.result.includes(Constants.walletSection.cancelledMessage)) {
|
||||||
buyStickersPackModal.setSendTxError()
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
buyStickersPackModal.sendingError.text = response.result
|
buyStickersPackModal.sendingError.text = response.result
|
||||||
|
@ -121,10 +121,10 @@ Item {
|
|||||||
spacing: 12
|
spacing: 12
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
Layout.alignment: Qt.AlignRight
|
Layout.alignment: Qt.AlignRight
|
||||||
Layout.maximumWidth: 70
|
Layout.maximumWidth: 100
|
||||||
font.pixelSize: 10
|
font.pixelSize: 10
|
||||||
color: Theme.palette.baseColor1
|
color: Theme.palette.baseColor1
|
||||||
text: selectedAccount.address
|
text: StatusQUtils.Utils.elideText(selectedAccount.address, 6, 4).toUpperCase()
|
||||||
elide: Text.ElideMiddle
|
elide: Text.ElideMiddle
|
||||||
}
|
}
|
||||||
Repeater {
|
Repeater {
|
||||||
|
@ -715,4 +715,8 @@ QtObject {
|
|||||||
StickersBuy,
|
StickersBuy,
|
||||||
Bridge
|
Bridge
|
||||||
}
|
}
|
||||||
|
|
||||||
|
readonly property QtObject walletSection: QtObject {
|
||||||
|
readonly property string cancelledMessage: "cancelled"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user