fix: introduce validation for required address requests in tx previews
Closes: #1203 #1204
This commit is contained in:
parent
a7058681fe
commit
7a4cc9227e
|
@ -60,6 +60,17 @@ ModalPopup {
|
|||
anchors.topMargin: 19
|
||||
icon.rotation: root.isRequested ? -90 : 90
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: addressRequiredInfo
|
||||
anchors.right: selectRecipient.right
|
||||
anchors.bottom: selectRecipient.top
|
||||
anchors.bottomMargin: -Style.current.padding
|
||||
text: qsTr("Address request required")
|
||||
color: Style.current.danger
|
||||
visible: addressRequiredValidator.isWarn
|
||||
}
|
||||
|
||||
RecipientSelector {
|
||||
id: selectRecipient
|
||||
accounts: walletModel.accounts
|
||||
|
@ -71,6 +82,9 @@ ModalPopup {
|
|||
anchors.top: separator.bottom
|
||||
anchors.topMargin: 10
|
||||
width: stack.width
|
||||
onSelectedRecipientChanged: {
|
||||
addressRequiredValidator.address = root.isRequested ? selectFromAccount.selectedAccount.address : selectRecipient.selectedRecipient.address
|
||||
}
|
||||
reset: function() {
|
||||
isValid = true
|
||||
}
|
||||
|
@ -110,6 +124,7 @@ ModalPopup {
|
|||
toAccount: root.isRequested ? selectFromAccount.selectedAccount : selectRecipient.selectedRecipient
|
||||
asset: txtAmount.selectedAsset
|
||||
amount: { "value": txtAmount.selectedAmount, "fiatValue": txtAmount.selectedFiatAmount }
|
||||
toWarn: addressRequiredValidator.isWarn
|
||||
currency: walletModel.defaultCurrency
|
||||
reset: function() {
|
||||
fromAccount = Qt.binding(function() {
|
||||
|
@ -127,28 +142,10 @@ ModalPopup {
|
|||
}
|
||||
}
|
||||
|
||||
SVGImage {
|
||||
width: 16
|
||||
height: 16
|
||||
visible: warningText.visible
|
||||
source: "../../../../img/warning.svg"
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.bottom: warningText.top
|
||||
anchors.bottomMargin: 4
|
||||
}
|
||||
|
||||
StyledText {
|
||||
id: warningText
|
||||
visible: !root.isRequested
|
||||
//% "You need to request the recipient’s address first.\nAssets won’t be sent yet."
|
||||
text: qsTrId("you-need-to-request-the-recipient-s-address-first--nassets-won-t-be-sent-yet-")
|
||||
color: Style.current.danger
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
AddressRequiredValidator {
|
||||
id: addressRequiredValidator
|
||||
anchors.bottom: parent.bottom
|
||||
|
||||
anchors.bottomMargin: Style.current.padding
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ ModalPopup {
|
|||
property alias transactionSigner: transactionSigner
|
||||
|
||||
property var sendTransaction: function(selectedGasLimit, selectedGasPrice, enteredPassword) {
|
||||
let responseStr = walletModel.sendTransaction(root.selectedAccount.address,
|
||||
root.selectedRecipient.address,
|
||||
let responseStr = walletModel.sendTransaction(selectFromAccount.selectedAccount.address,
|
||||
selectRecipient.selectedRecipient.address,
|
||||
root.selectedAsset.address,
|
||||
root.selectedAmount,
|
||||
selectedGasLimit,
|
||||
|
@ -28,17 +28,6 @@ ModalPopup {
|
|||
enteredPassword,
|
||||
stack.uuid)
|
||||
|
||||
let response = JSON.parse(responseStr)
|
||||
|
||||
if (response.error) {
|
||||
if (response.result.includes("could not decrypt key with given password")){
|
||||
//% "Wrong password"
|
||||
transactionSigner.validationError = qsTrId("wrong-password")
|
||||
return
|
||||
}
|
||||
sendingError.text = response.result
|
||||
return sendingError.open()
|
||||
}
|
||||
root.close()
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
import QtQuick 2.13
|
||||
import QtQuick.Controls 2.13
|
||||
import QtQuick.Layouts 1.13
|
||||
import "../imports"
|
||||
import "./status"
|
||||
|
||||
Column {
|
||||
id: root
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
spacing: 5
|
||||
|
||||
visible: !isValid || isWarn
|
||||
|
||||
property bool isValid: true
|
||||
property bool isWarn: address == Constants.zeroAddress
|
||||
property alias errorMessage: txtValidationError.text
|
||||
property string address: ""
|
||||
|
||||
SVGImage {
|
||||
id: imgExclamation
|
||||
width: 13.33
|
||||
height: 13.33
|
||||
sourceSize.height: height * 2
|
||||
sourceSize.width: width * 2
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "../app/img/exclamation_outline.svg"
|
||||
}
|
||||
StyledText {
|
||||
id: txtValidationError
|
||||
//% "You need to request the recipient’s address first.\nAssets won’t be sent yet."
|
||||
text: qsTrId("you-need-to-request-the-recipient-s-address-first--nassets-won-t-be-sent-yet-")
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
wrapMode: Text.WordWrap
|
||||
font.pixelSize: 13
|
||||
height: 18
|
||||
color: Style.current.danger
|
||||
}
|
||||
}
|
|
@ -23,8 +23,10 @@ Item {
|
|||
// Creates a mouse area around the "network fee". When clicked, triggers
|
||||
// the "gasClicked" signal
|
||||
property bool isGasEditable: false
|
||||
property bool isValid: fromValid && gasValid
|
||||
property bool isValid: toValid && fromValid && gasValid
|
||||
property bool fromValid: true
|
||||
property bool toValid: true
|
||||
property bool toWarn: false
|
||||
property bool gasValid: true
|
||||
|
||||
function resetInternal() {
|
||||
|
@ -119,6 +121,9 @@ Item {
|
|||
}
|
||||
LabelValueRow {
|
||||
id: itmTo
|
||||
function needsRightPadding() {
|
||||
return !root.toValid || root.toWarn
|
||||
}
|
||||
//% "Recipient"
|
||||
label: qsTrId("recipient")
|
||||
states: [
|
||||
|
@ -251,11 +256,24 @@ Item {
|
|||
StatusImageIdenticon {
|
||||
id: idtToContact
|
||||
visible: false
|
||||
anchors.right: parent.right
|
||||
anchors.right: toInvalid.visible ? toInvalid.left : parent.right
|
||||
anchors.rightMargin: toInvalid.visible ? Style.current.halfPadding : 0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
width: 32
|
||||
height: 32
|
||||
}
|
||||
SVGImage {
|
||||
id: toInvalid
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.right: parent.right
|
||||
width: 13.33
|
||||
height: 13.33
|
||||
sourceSize.height: height * 2
|
||||
sourceSize.width: width * 2
|
||||
fillMode: Image.PreserveAspectFit
|
||||
source: "../app/img/exclamation_outline.svg"
|
||||
visible: !root.toValid || root.toWarn
|
||||
}
|
||||
}
|
||||
LabelValueRow {
|
||||
id: itmAsset
|
||||
|
|
Loading…
Reference in New Issue