diff --git a/src/app/profile/views/ens_manager.nim b/src/app/profile/views/ens_manager.nim index 1face164f3..ac73fabe8e 100644 --- a/src/app/profile/views/ens_manager.nim +++ b/src/app/profile/views/ens_manager.nim @@ -210,7 +210,7 @@ QtObject: var success: bool let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0") try: - result = registerUsernameEstimateGas(ensUsername, address, pubKey) + result = registerUsernameEstimateGas(ensUsername, address, pubKey, success) except: result = 380000 @@ -219,33 +219,26 @@ QtObject: let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0") let response = registerUsername(username, pubKey, address, gas, gasPrice, password, success) result = $(%* { "result": %response, "success": %success }) + if success: self.transactionWasSent(response) - - # TODO: handle transaction failure var ensUsername = formatUsername(username, true) self.pendingUsernames.incl(ensUsername) self.add ensUsername - except RpcException as e: - result = $(%* { "error": %* { "message": %e.msg }}) - proc setPubKeyGasEstimate(self: EnsManager, ensUsername: string, address: string): int {.slot.} = + var success: bool let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0") - try: - result = setPubKeyEstimateGas(ensUsername, address, pubKey) - except: + result = setPubKeyEstimateGas(ensUsername, address, pubKey, success) + if not success: result = 80000 proc setPubKey(self: EnsManager, username: string, address: string, gas: string, gasPrice: string, password: string): string {.slot.} = - try: - let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0") - let response = setPubKey(username, pubKey, address, gas, gasPrice, password) - result = $(%* { "result": %response }) + var success: bool + let pubKey = status_settings.getSetting[string](Setting.PublicKey, "0x0") + let response = setPubKey(username, pubKey, address, gas, gasPrice, password, success) + result = $(%* { "result": %response, "success": %success }) + if success: self.transactionWasSent(response) - - # TODO: handle transaction failure self.pendingUsernames.incl(username) - self.add username - except RpcException as e: - result = $(%* { "error": %* { "message": %e.msg }}) + self.add username \ No newline at end of file diff --git a/src/status/ens.nim b/src/status/ens.nim index ce3d0411f7..a1de77c8d9 100644 --- a/src/status/ens.nim +++ b/src/status/ens.nim @@ -190,7 +190,7 @@ proc registerUsername*(username, pubKey, address, gas, gasPrice, password: stri if success: trackPendingTransaction(result, address, $sntContract.address, PendingTransactionType.RegisterENS, username & domain) -proc setPubKeyEstimateGas*(username: string, address: string, pubKey: string): int = +proc setPubKeyEstimateGas*(username: string, address: string, pubKey: string, success: var bool): int = var hash = namehash(username) hash.removePrefix("0x") @@ -205,12 +205,13 @@ proc setPubKeyEstimateGas*(username: string, address: string, pubKey: string): i var tx = transactions.buildTokenTransaction(parseAddress(address), parseAddress(resolverAddress), "", "") try: - let response = resolverContract.methods["setPubkey"].estimateGas(tx, setPubkey) - result = fromHex[int](response) + let response = resolverContract.methods["setPubkey"].estimateGas(tx, setPubkey, success) + if success: + result = fromHex[int](response) except RpcException as e: raise -proc setPubKey*(username, pubKey, address, gas, gasPrice, password: string): string = +proc setPubKey*(username, pubKey, address, gas, gasPrice, password: string, success: var bool): string = var hash = namehash(username) hash.removePrefix("0x") @@ -225,8 +226,9 @@ proc setPubKey*(username, pubKey, address, gas, gasPrice, password: string): str var tx = transactions.buildTokenTransaction(parseAddress(address), parseAddress(resolverAddress), gas, gasPrice) try: - result = resolverContract.methods["setPubkey"].send(tx, setPubkey, password) - trackPendingTransaction(result, $address, resolverAddress, PendingTransactionType.SetPubKey, username) + result = resolverContract.methods["setPubkey"].send(tx, setPubkey, password, success) + if success: + trackPendingTransaction(result, $address, resolverAddress, PendingTransactionType.SetPubKey, username) except RpcException as e: raise diff --git a/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml b/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml index 0e91dc5c83..282d60a06f 100644 --- a/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml +++ b/ui/app/AppLayouts/Profile/Sections/Ens/RegisterENSModal.qml @@ -21,16 +21,6 @@ ModalPopup { icon: StandardIcon.Critical standardButtons: StandardButton.Ok } - property MessageDialog sendingSuccess: MessageDialog { - id: sendingSuccess - //% "Success sending the transaction" - title: qsTrId("success-sending-the-transaction") - icon: StandardIcon.NoIcon - standardButtons: StandardButton.Ok - onAccepted: { - root.close() - } - } onClosed: { stack.reset() @@ -56,8 +46,8 @@ ModalPopup { usernameRegistered(username); //% "Transaction sent to the blockchain. You can watch the progress on Etherscan: %2%1" - sendingSuccess.text = qsTrId("transaction-sent-to-the-blockchain--you-can-watch-the-progress-on-etherscan---2-1").arg(response.result).arg(walletModel.etherscanLink) - sendingSuccess.open() + // sendingSuccess.text = qsTrId("transaction-sent-to-the-blockchain--you-can-watch-the-progress-on-etherscan---2-1").arg(response.result).arg(walletModel.etherscanLink) + // sendingSuccess.open() } TransactionStackView { diff --git a/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml b/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml index 06dd13d987..3bf231ecd1 100644 --- a/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml +++ b/ui/app/AppLayouts/Profile/Sections/Ens/SetPubKeyModal.qml @@ -31,7 +31,7 @@ ModalPopup { transactionSigner.enteredPassword) let response = JSON.parse(responseStr) - if (response.error) { + if (!response.success) { if (response.error.message.includes("could not decrypt key with given password")){ transactionSigner.validationError = qsTr("Wrong password") return diff --git a/ui/shared/ToastMessage.qml b/ui/shared/ToastMessage.qml index ce279abcbd..3e2990621b 100644 --- a/ui/shared/ToastMessage.qml +++ b/ui/shared/ToastMessage.qml @@ -12,6 +12,7 @@ Popup { //% "View on Etherscan" readonly property string defaultLinkText: qsTrId("view-on-etherscan") property string link: "https://etherscan.io/" + property string linkText: qsTrId("view-on-etherscan") id: root closePolicy: Popup.NoAutoClose diff --git a/vendor/nim-confutils b/vendor/nim-confutils new file mode 160000 index 0000000000..39456fa3d5 --- /dev/null +++ b/vendor/nim-confutils @@ -0,0 +1 @@ +Subproject commit 39456fa3d5b637053b616e50a8350b2b932a1d4c