diff --git a/src/app/modules/main/profile_section/ens_usernames/module.nim b/src/app/modules/main/profile_section/ens_usernames/module.nim index 6a0265da51..3d3edf902f 100644 --- a/src/app/modules/main/profile_section/ens_usernames/module.nim +++ b/src/app/modules/main/profile_section/ens_usernames/module.nim @@ -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) diff --git a/src/app/modules/main/stickers/module.nim b/src/app/modules/main/stickers/module.nim index 40e0c14a76..817d302496 100644 --- a/src/app/modules/main/stickers/module.nim +++ b/src/app/modules/main/stickers/module.nim @@ -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() diff --git a/src/app/modules/main/wallet_section/transactions/module.nim b/src/app/modules/main/wallet_section/transactions/module.nim index 5f7fca7633..69774216ea 100644 --- a/src/app/modules/main/wallet_section/transactions/module.nim +++ b/src/app/modules/main/wallet_section/transactions/module.nim @@ -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) diff --git a/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml b/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml index ec385c7095..efd748e589 100644 --- a/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsDetailsView.qml @@ -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 diff --git a/ui/app/AppLayouts/Profile/views/EnsSearchView.qml b/ui/app/AppLayouts/Profile/views/EnsSearchView.qml index 16a3f2a0d6..2277ad7abd 100644 --- a/ui/app/AppLayouts/Profile/views/EnsSearchView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsSearchView.qml @@ -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 diff --git a/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml b/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml index 0db874877f..38e87d9bd0 100644 --- a/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml +++ b/ui/app/AppLayouts/Profile/views/EnsTermsAndConditionsView.qml @@ -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 diff --git a/ui/imports/shared/popups/SendModal.qml b/ui/imports/shared/popups/SendModal.qml index 42cecd71be..9ddee79805 100644 --- a/ui/imports/shared/popups/SendModal.qml +++ b/ui/imports/shared/popups/SendModal.qml @@ -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 diff --git a/ui/imports/shared/status/StatusStickerMarket.qml b/ui/imports/shared/status/StatusStickerMarket.qml index 77c9579726..077d405fb1 100644 --- a/ui/imports/shared/status/StatusStickerMarket.qml +++ b/ui/imports/shared/status/StatusStickerMarket.qml @@ -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 diff --git a/ui/imports/shared/status/StatusStickerPackClickPopup.qml b/ui/imports/shared/status/StatusStickerPackClickPopup.qml index 82ac6639b9..8f283116af 100644 --- a/ui/imports/shared/status/StatusStickerPackClickPopup.qml +++ b/ui/imports/shared/status/StatusStickerPackClickPopup.qml @@ -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 diff --git a/ui/imports/shared/views/NetworkCardsComponent.qml b/ui/imports/shared/views/NetworkCardsComponent.qml index 415c027390..3b374ce4ab 100644 --- a/ui/imports/shared/views/NetworkCardsComponent.qml +++ b/ui/imports/shared/views/NetworkCardsComponent.qml @@ -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 { diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index 81cac269d3..8dfb343f23 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -715,4 +715,8 @@ QtObject { StickersBuy, Bridge } + + readonly property QtObject walletSection: QtObject { + readonly property string cancelledMessage: "cancelled" + } }