2023-03-22 15:48:44 +00:00
|
|
|
import QtQuick 2.14
|
|
|
|
import QtQuick.Controls 2.14
|
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Controls.Validators 0.1
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
|
|
|
|
import "../stores"
|
2023-08-04 12:41:57 +00:00
|
|
|
import "../../common"
|
2023-03-22 15:48:44 +00:00
|
|
|
|
|
|
|
Column {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property AddAccountStore store
|
|
|
|
|
|
|
|
function reset() {
|
|
|
|
addressInput.reset()
|
|
|
|
}
|
|
|
|
|
2024-07-30 13:01:16 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
property bool incorrectChecksum: false
|
|
|
|
|
|
|
|
function checkIfAddressChecksumIsValid(address) {
|
|
|
|
d.incorrectChecksum = !root.store.isChecksumValidForAddress(address)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
StatusInput {
|
|
|
|
id: addressInput
|
2023-04-13 10:27:56 +00:00
|
|
|
objectName: "AddAccountPopup-WatchOnlyAddress"
|
2023-03-22 15:48:44 +00:00
|
|
|
width: parent.width
|
|
|
|
maximumHeight: Constants.addAccountPopup.itemHeight
|
|
|
|
minimumHeight: Constants.addAccountPopup.itemHeight
|
|
|
|
label: qsTr("Ethereum address or ENS name")
|
2023-05-02 14:19:55 +00:00
|
|
|
placeholderText: qsTr("Type or paste ETH address")
|
2023-03-22 15:48:44 +00:00
|
|
|
input.multiline: true
|
2024-07-30 13:01:16 +00:00
|
|
|
input.rightComponent: Row {
|
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
StatusIconWithTooltip {
|
|
|
|
visible: d.incorrectChecksum
|
|
|
|
icon: "warning"
|
|
|
|
width: 20
|
|
|
|
height: 20
|
|
|
|
color: Theme.palette.warningColor1
|
|
|
|
tooltipText: qsTr("Checksum of the entered address is incorrect")
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
borderColor: Theme.palette.primaryColor1
|
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
text: qsTr("Paste")
|
|
|
|
onClicked: {
|
|
|
|
addressInput.text = ""
|
|
|
|
addressInput.input.edit.paste()
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
validators: [
|
|
|
|
StatusAddressOrEnsValidator {
|
|
|
|
errorMessage: qsTr("Please enter a valid Ethereum address or ENS name")
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
|
|
|
onTextChanged: {
|
2024-07-30 13:01:16 +00:00
|
|
|
d.incorrectChecksum = false
|
2023-03-22 15:48:44 +00:00
|
|
|
if (addressInput.valid) {
|
2024-07-30 13:01:16 +00:00
|
|
|
const trimmedText = text.trim()
|
|
|
|
root.store.changeWatchOnlyAccountAddressPostponed(trimmedText)
|
|
|
|
d.checkIfAddressChecksumIsValid(trimmedText)
|
2023-03-22 15:48:44 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
root.store.cleanWatchOnlyAccountAddress()
|
|
|
|
}
|
|
|
|
|
|
|
|
onKeyPressed: {
|
2023-08-04 12:41:57 +00:00
|
|
|
root.store.submitPopup(event)
|
2023-03-22 15:48:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
AddressDetails {
|
|
|
|
width: parent.width
|
|
|
|
addressDetailsItem: root.store.watchOnlyAccAddress
|
|
|
|
defaultMessage: qsTr("You will need to import your seed phrase or use your Keycard to transact with this account")
|
|
|
|
defaultMessageCondition: addressInput.text === "" || !addressInput.valid
|
|
|
|
}
|
|
|
|
}
|