feat: checksum validation added to adding watch only address
Fixes: #15779
This commit is contained in:
parent
822410f6b6
commit
fdd743a817
|
@ -250,4 +250,7 @@ proc getNumOfAddressesToGenerateForKeypair*(self: Controller, keyUid: string): i
|
||||||
return self.walletAccountService.getNumOfAddressesToGenerateForKeypair(keyUid)
|
return self.walletAccountService.getNumOfAddressesToGenerateForKeypair(keyUid)
|
||||||
|
|
||||||
proc resolveSuggestedPathForKeypair*(self: Controller, keyUid: string): string =
|
proc resolveSuggestedPathForKeypair*(self: Controller, keyUid: string): string =
|
||||||
return self.walletAccountService.resolveSuggestedPathForKeypair(keyUid)
|
return self.walletAccountService.resolveSuggestedPathForKeypair(keyUid)
|
||||||
|
|
||||||
|
proc isChecksumValidForAddress*(self: Controller, address: string): bool =
|
||||||
|
return self.walletAccountService.isChecksumValidForAddress(address)
|
|
@ -107,6 +107,9 @@ method removingSavedAddressConfirmed*(self: AccessInterface, address: string) {.
|
||||||
method savedAddressDeleted*(self: AccessInterface, address: string, errorMsg: string) {.base.} =
|
method savedAddressDeleted*(self: AccessInterface, address: string, errorMsg: string) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method isChecksumValidForAddress*(self: AccessInterface, address: string): bool {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
type
|
type
|
||||||
DelegateInterface* = concept c
|
DelegateInterface* = concept c
|
||||||
c.onAddAccountModuleLoaded()
|
c.onAddAccountModuleLoaded()
|
||||||
|
|
|
@ -736,4 +736,7 @@ method buildNewSeedPhraseKeypairAndAddItToOrigin*[T](self: Module[T]) =
|
||||||
derivedFrom = genAcc.address)
|
derivedFrom = genAcc.address)
|
||||||
self.setItemForSelectedOrigin(item)
|
self.setItemForSelectedOrigin(item)
|
||||||
|
|
||||||
|
method isChecksumValidForAddress*[T](self: Module[T], address: string): bool =
|
||||||
|
return self.controller.isChecksumValidForAddress(address)
|
||||||
|
|
||||||
{.pop.}
|
{.pop.}
|
||||||
|
|
|
@ -362,4 +362,7 @@ QtObject:
|
||||||
self.delegate.removingSavedAddressConfirmed(address)
|
self.delegate.removingSavedAddressConfirmed(address)
|
||||||
|
|
||||||
proc removingSavedAddressRejected*(self: View) {.slot.} =
|
proc removingSavedAddressRejected*(self: View) {.slot.} =
|
||||||
self.setDisablePopup(false)
|
self.setDisablePopup(false)
|
||||||
|
|
||||||
|
proc isChecksumValidForAddress*(self: View, address: string): bool {.slot.} =
|
||||||
|
return self.delegate.isChecksumValidForAddress(address)
|
|
@ -20,6 +20,16 @@ Column {
|
||||||
addressInput.reset()
|
addressInput.reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QtObject {
|
||||||
|
id: d
|
||||||
|
|
||||||
|
property bool incorrectChecksum: false
|
||||||
|
|
||||||
|
function checkIfAddressChecksumIsValid(address) {
|
||||||
|
d.incorrectChecksum = !root.store.isChecksumValidForAddress(address)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
StatusInput {
|
StatusInput {
|
||||||
id: addressInput
|
id: addressInput
|
||||||
objectName: "AddAccountPopup-WatchOnlyAddress"
|
objectName: "AddAccountPopup-WatchOnlyAddress"
|
||||||
|
@ -29,14 +39,27 @@ Column {
|
||||||
label: qsTr("Ethereum address or ENS name")
|
label: qsTr("Ethereum address or ENS name")
|
||||||
placeholderText: qsTr("Type or paste ETH address")
|
placeholderText: qsTr("Type or paste ETH address")
|
||||||
input.multiline: true
|
input.multiline: true
|
||||||
input.rightComponent: StatusButton {
|
input.rightComponent: Row {
|
||||||
anchors.verticalCenter: parent.verticalCenter
|
spacing: 8
|
||||||
borderColor: Theme.palette.primaryColor1
|
|
||||||
size: StatusBaseButton.Size.Tiny
|
StatusIconWithTooltip {
|
||||||
text: qsTr("Paste")
|
visible: d.incorrectChecksum
|
||||||
onClicked: {
|
icon: "warning"
|
||||||
addressInput.text = ""
|
width: 20
|
||||||
addressInput.input.edit.paste()
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
validators: [
|
validators: [
|
||||||
|
@ -46,8 +69,11 @@ Column {
|
||||||
]
|
]
|
||||||
|
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
|
d.incorrectChecksum = false
|
||||||
if (addressInput.valid) {
|
if (addressInput.valid) {
|
||||||
root.store.changeWatchOnlyAccountAddressPostponed(text.trim())
|
const trimmedText = text.trim()
|
||||||
|
root.store.changeWatchOnlyAccountAddressPostponed(trimmedText)
|
||||||
|
d.checkIfAddressChecksumIsValid(trimmedText)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
root.store.cleanWatchOnlyAccountAddress()
|
root.store.cleanWatchOnlyAccountAddress()
|
||||||
|
|
|
@ -155,6 +155,10 @@ BasePopupStore {
|
||||||
root.addAccountModule.startScanningForActivity()
|
root.addAccountModule.startScanningForActivity()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isChecksumValidForAddress(address) {
|
||||||
|
return root.addAccountModule.isChecksumValidForAddress(address)
|
||||||
|
}
|
||||||
|
|
||||||
validSeedPhrase: function(seedPhrase) {
|
validSeedPhrase: function(seedPhrase) {
|
||||||
return root.addAccountModule.validSeedPhrase(seedPhrase)
|
return root.addAccountModule.validSeedPhrase(seedPhrase)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue