Skip to content

Commit

Permalink
fix(@desktop/wallet): unable to add account
Browse files Browse the repository at this point in the history
Fixes adding account modal, which was broken due to incomplete
`SelectGeneratedAccount` enum change.
  • Loading branch information
saledjenic authored and alaibe committed Feb 1, 2023
1 parent 4fb35c3 commit c0d761a
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions ui/app/AppLayouts/Wallet/views/AdvancedAddAccountView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "../panels"
ColumnLayout {
id: advancedSection

property int addAccountType: SelectGeneratedAccount.AddAccountType.GenerateNew
property int addAccountType: Constants.AddAccountType.GenerateNew
property string selectedKeyUid: RootStore.defaultSelectedKeyUid
property bool selectedKeyUidMigratedToKeycard: RootStore.defaultSelectedKeyUidMigratedToKeycard
property string selectedAddress: ""
Expand All @@ -29,9 +29,9 @@ ColumnLayout {
property string pathSubFix: ""
property string completePath: path + "/" + pathSubFix
property alias watchAddress: addressInput.text
property bool isValid: addAccountType === SelectGeneratedAccount.AddAccountType.ImportSeedPhrase ? importSeedPhrasePanel.isValid :
addAccountType === SelectGeneratedAccount.AddAccountType.ImportPrivateKey ? (importPrivateKeyPanel.text !== "" && importPrivateKeyPanel.valid) :
addAccountType === SelectGeneratedAccount.AddAccountType.WatchOnly ? (addressInput.text !== "" && addressInput.valid) : true
property bool isValid: addAccountType === Constants.AddAccountType.ImportSeedPhrase ? importSeedPhrasePanel.isValid :
addAccountType === Constants.AddAccountType.ImportPrivateKey ? (importPrivateKeyPanel.text !== "" && importPrivateKeyPanel.valid) :
addAccountType === Constants.AddAccountType.WatchOnly ? (addressInput.text !== "" && addressInput.valid) : true

signal calculateDerivedPath()
signal enterPressed()
Expand All @@ -58,23 +58,23 @@ ColumnLayout {
}

function validate() {
if(addAccountType === SelectGeneratedAccount.AddAccountType.ImportSeedPhrase) {
if(addAccountType === Constants.AddAccountType.ImportSeedPhrase) {
// validate mnemonic
return importSeedPhrasePanel.validate()
}
else if(addAccountType === SelectGeneratedAccount.AddAccountType.ImportPrivateKey) {
else if(addAccountType === Constants.AddAccountType.ImportPrivateKey) {
// validate privateKey
return importPrivateKeyPanel.validateMe()
}
else if(addAccountType === SelectGeneratedAccount.AddAccountType.WatchOnly) {
else if(addAccountType === Constants.AddAccountType.WatchOnly) {
return addressInput.valid
}

return true
}

onPathChanged: {
if(addAccountType === SelectGeneratedAccount.AddAccountType.ImportSeedPhrase) {
if(addAccountType === Constants.AddAccountType.ImportSeedPhrase) {
if(importSeedPhrasePanel.isValid) {
calculateDerivedPath()
}
Expand All @@ -88,7 +88,7 @@ ColumnLayout {
// reset derviedAccountsList
derivedAddressesPanel.reset()

if(addAccountType === SelectGeneratedAccount.AddAccountType.ImportSeedPhrase) {
if(addAccountType === Constants.AddAccountType.ImportSeedPhrase) {
if(importSeedPhrasePanel.isValid) {
calculateDerivedPath()
}
Expand All @@ -112,15 +112,15 @@ ColumnLayout {

ImportPrivateKeyPanel {
id: importPrivateKeyPanel
visible: advancedSection.addAccountType === SelectGeneratedAccount.AddAccountType.ImportPrivateKey && advancedSection.visible
visible: advancedSection.addAccountType === Constants.AddAccountType.ImportPrivateKey && advancedSection.visible
}

ImportSeedPhrasePanel {
id: importSeedPhrasePanel
Layout.preferredWidth: parent.width
Layout.preferredHeight: visible ? importSeedPhrasePanel.preferredHeight: 0
Layout.leftMargin: (Style.current.halfPadding/4)
visible: advancedSection.addAccountType === SelectGeneratedAccount.AddAccountType.ImportSeedPhrase && advancedSection.visible
visible: advancedSection.addAccountType === Constants.AddAccountType.ImportSeedPhrase && advancedSection.visible
onMnemonicStringChanged: {
advancedSection.mnemonicText = mnemonicString
if(isValid) {
Expand All @@ -132,7 +132,7 @@ ColumnLayout {

StatusInput {
id: addressInput
visible: advancedSection.addAccountType === SelectGeneratedAccount.AddAccountType.WatchOnly && advancedSection.visible
visible: advancedSection.addAccountType === Constants.AddAccountType.WatchOnly && advancedSection.visible
placeholderText: qsTr("Enter address...")
label: qsTr("Account address")
validators: [
Expand All @@ -150,8 +150,8 @@ ColumnLayout {
Layout.fillWidth: true
Layout.rightMargin: 2
spacing: Style.current.bigPadding
visible: advancedSection.addAccountType !== SelectGeneratedAccount.AddAccountType.ImportPrivateKey &&
advancedSection.addAccountType !== SelectGeneratedAccount.AddAccountType.WatchOnly
visible: advancedSection.addAccountType !== Constants.AddAccountType.ImportPrivateKey &&
advancedSection.addAccountType !== Constants.AddAccountType.WatchOnly
DerivationPathsPanel {
id: derivationPathsPanel
Layout.preferredWidth: ((parent.width - (Style.current.bigPadding/2))/2)
Expand Down

0 comments on commit c0d761a

Please sign in to comment.