feat(@desktop/wallet): re-add adding watch only address to wallet
fixes #5471
This commit is contained in:
parent
dbc16329c0
commit
d9d7a54f84
|
@ -199,6 +199,9 @@ StatusModal {
|
||||||
case AdvancedAddAccountView.AddAccountType.ImportPrivateKey:
|
case AdvancedAddAccountView.AddAccountType.ImportPrivateKey:
|
||||||
errMessage = RootStore.addAccountsFromPrivateKey(advancedSelection.expandableItem.privateKey, passwordInput.text, accountNameInput.text, colorSelectionGrid.selectedColor, accountNameInput.input.icon.emoji)
|
errMessage = RootStore.addAccountsFromPrivateKey(advancedSelection.expandableItem.privateKey, passwordInput.text, accountNameInput.text, colorSelectionGrid.selectedColor, accountNameInput.input.icon.emoji)
|
||||||
break
|
break
|
||||||
|
case AdvancedAddAccountView.AddAccountType.WatchOnly:
|
||||||
|
errMessage = RootStore.addWatchOnlyAccount(advancedSelection.expandableItem.watchAddress, accountNameInput.text, colorSelectionGrid.selectedColor, accountNameInput.input.icon.emoji)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
errMessage = RootStore.generateNewAccount(passwordInput.text, accountNameInput.text, colorSelectionGrid.selectedColor, accountNameInput.input.icon.emoji)
|
errMessage = RootStore.generateNewAccount(passwordInput.text, accountNameInput.text, colorSelectionGrid.selectedColor, accountNameInput.input.icon.emoji)
|
||||||
|
|
|
@ -19,14 +19,17 @@ ColumnLayout {
|
||||||
property alias privateKey: privateKey.text
|
property alias privateKey: privateKey.text
|
||||||
property int addAccountType: AdvancedAddAccountView.AddAccountType.GenerateNew
|
property int addAccountType: AdvancedAddAccountView.AddAccountType.GenerateNew
|
||||||
property string mnemonicText: getSeedPhraseString()
|
property string mnemonicText: getSeedPhraseString()
|
||||||
|
property alias watchAddress: addressInput.text
|
||||||
property string errorString: ""
|
property string errorString: ""
|
||||||
property bool isValid: addAccountType === AdvancedAddAccountView.AddAccountType.ImportSeedPhrase ? grid.isValid :
|
property bool isValid: addAccountType === AdvancedAddAccountView.AddAccountType.ImportSeedPhrase ? grid.isValid :
|
||||||
addAccountType === AdvancedAddAccountView.AddAccountType.ImportPrivateKey ? (privateKey.text !== "" && privateKey.valid) : true
|
addAccountType === AdvancedAddAccountView.AddAccountType.ImportPrivateKey ? (privateKey.text !== "" && privateKey.valid) :
|
||||||
|
advancedSection.addAccountType === AdvancedAddAccountView.AddAccountType.WatchOnly ? (addressInput.text !== "" && addressInput.valid) : true
|
||||||
|
|
||||||
enum AddAccountType {
|
enum AddAccountType {
|
||||||
GenerateNew,
|
GenerateNew,
|
||||||
ImportSeedPhrase,
|
ImportSeedPhrase,
|
||||||
ImportPrivateKey
|
ImportPrivateKey,
|
||||||
|
WatchOnly
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
@ -36,6 +39,8 @@ ColumnLayout {
|
||||||
addAccountType = AdvancedAddAccountView.AddAccountType.GenerateNew
|
addAccountType = AdvancedAddAccountView.AddAccountType.GenerateNew
|
||||||
privateKey.text = ""
|
privateKey.text = ""
|
||||||
privateKey.reset()
|
privateKey.reset()
|
||||||
|
addressInput.text = ""
|
||||||
|
addressInput.reset()
|
||||||
for(var i = 0; i < grid.model; i++) {
|
for(var i = 0; i < grid.model; i++) {
|
||||||
if(grid.itemAtIndex(i)) {
|
if(grid.itemAtIndex(i)) {
|
||||||
grid.itemAtIndex(i).textEdit.text = ""
|
grid.itemAtIndex(i).textEdit.text = ""
|
||||||
|
@ -76,6 +81,10 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
return errorString === ""
|
return errorString === ""
|
||||||
}
|
}
|
||||||
|
else if(advancedSection.addAccountType === AdvancedAddAccountView.AddAccountType.WatchOnly) {
|
||||||
|
return addressInput.valid
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +138,8 @@ ColumnLayout {
|
||||||
append({"name": qsTr("Import new Seed Phrase"), "iconName": "seed-phrase", "enabled": true})
|
append({"name": qsTr("Import new Seed Phrase"), "iconName": "seed-phrase", "enabled": true})
|
||||||
//% "Import new Private Key"
|
//% "Import new Private Key"
|
||||||
append({"name": qsTr("Import new Private Key"), "iconName": "password", "enabled": true})
|
append({"name": qsTr("Import new Private Key"), "iconName": "password", "enabled": true})
|
||||||
|
//% "Import new Private Key"
|
||||||
|
append({"name": qsTrId("add-a-watch-account"), "iconName": "show", "enabled": true})
|
||||||
selectedItem.title = Qt.binding(function() {return get(select.currentIndex).name})
|
selectedItem.title = Qt.binding(function() {return get(select.currentIndex).name})
|
||||||
selectedItem.icon.name = Qt.binding(function() {return get(select.currentIndex).iconName})
|
selectedItem.icon.name = Qt.binding(function() {return get(select.currentIndex).iconName})
|
||||||
selectedItem.tagsModel = Qt.binding(function() {return get(select.currentIndex).accountsModel})
|
selectedItem.tagsModel = Qt.binding(function() {return get(select.currentIndex).accountsModel})
|
||||||
|
@ -157,6 +168,7 @@ ColumnLayout {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
advancedSection.addAccountType = (index === 2) ? AdvancedAddAccountView.AddAccountType.ImportSeedPhrase :
|
advancedSection.addAccountType = (index === 2) ? AdvancedAddAccountView.AddAccountType.ImportSeedPhrase :
|
||||||
(index === 3) ? AdvancedAddAccountView.AddAccountType.ImportPrivateKey :
|
(index === 3) ? AdvancedAddAccountView.AddAccountType.ImportPrivateKey :
|
||||||
|
(index === 4) ? AdvancedAddAccountView.AddAccountType.WatchOnly :
|
||||||
AdvancedAddAccountView.AddAccountType.GenerateNew
|
AdvancedAddAccountView.AddAccountType.GenerateNew
|
||||||
select.currentIndex = index
|
select.currentIndex = index
|
||||||
select.selectMenu.close()
|
select.selectMenu.close()
|
||||||
|
@ -315,11 +327,32 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StatusInput {
|
||||||
|
id: addressInput
|
||||||
|
visible: advancedSection.addAccountType === AdvancedAddAccountView.AddAccountType.WatchOnly && advancedSection.visible
|
||||||
|
//% "Enter address..."
|
||||||
|
input.placeholderText: qsTrId("enter-address...")
|
||||||
|
//% "Account address"
|
||||||
|
label: qsTrId("wallet-key-title")
|
||||||
|
validators: [
|
||||||
|
StatusAddressValidator {
|
||||||
|
//% "This needs to be a valid address (starting with 0x)"
|
||||||
|
errorMessage: qsTrId("this-needs-to-be-a-valid-address-(starting-with-0x)")
|
||||||
|
},
|
||||||
|
StatusMinLengthValidator {
|
||||||
|
//% "You need to enter an address"
|
||||||
|
errorMessage: qsTrId("you-need-to-enter-an-address")
|
||||||
|
minLength: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
Layout.margins: Style.current.padding
|
Layout.margins: Style.current.padding
|
||||||
Layout.preferredWidth: parent.width
|
Layout.preferredWidth: parent.width
|
||||||
spacing: Style.current.bigPadding
|
spacing: Style.current.bigPadding
|
||||||
|
visible: advancedSection.addAccountType !== AdvancedAddAccountView.AddAccountType.WatchOnly &&
|
||||||
|
advancedSection.addAccountType !== AdvancedAddAccountView.AddAccountType.ImportPrivateKey
|
||||||
StatusSelect {
|
StatusSelect {
|
||||||
Layout.preferredWidth: 213
|
Layout.preferredWidth: 213
|
||||||
//% "Origin"
|
//% "Origin"
|
||||||
|
|
Loading…
Reference in New Issue