fix: initialize wallet paths and types, and disable deletion of non-watch accounts

This commit is contained in:
Richard Ramos 2020-12-08 11:07:20 -04:00 committed by Iuri Matias
parent 92bd8a1b96
commit 239b95e9a2
4 changed files with 7 additions and 4 deletions

View File

@ -281,7 +281,7 @@ proc saveAccount*(account: GeneratedAccount, password: string, color: string, ac
}]
])
result = DerivedAccount(address: address, publicKey: publicKey)
result = DerivedAccount(address: address, publicKey: publicKey, derivationPath: derivationPath)
except:
error "Error storing the new account. Bad password?"
raise

View File

@ -34,6 +34,7 @@ type GasPricePrediction* = object
type DerivedAccount* = object
publicKey*: string
address*: string
derivationPath*: string
type MultiAccounts* = object
whisper* {.serializedFieldName(PATH_WHISPER).}: DerivedAccount

View File

@ -188,9 +188,9 @@ proc populateAccount*(self: WalletModel, walletAccount: var WalletAccount, balan
walletAccount.realFiatBalance = 0.0
updateBalance(walletAccount, self.getDefaultCurrency(), refreshCache)
proc newAccount*(self: WalletModel, name: string, address: string, iconColor: string, balance: string, publicKey: string): WalletAccount =
proc newAccount*(self: WalletModel, walletType: string, derivationPath: string, name: string, address: string, iconColor: string, balance: string, publicKey: string): WalletAccount =
var assets: seq[Asset] = self.generateAccountConfiguredAssets(address)
var account = WalletAccount(name: name, address: address, iconColor: iconColor, balance: fmt"{balance} {self.defaultCurrency}", assetList: assets, realFiatBalance: 0.0, publicKey: publicKey)
var account = WalletAccount(name: name, path: derivationPath, walletType: walletType, address: address, iconColor: iconColor, balance: fmt"{balance} {self.defaultCurrency}", assetList: assets, realFiatBalance: 0.0, publicKey: publicKey)
updateBalance(account, self.getDefaultCurrency())
account
@ -226,7 +226,7 @@ proc addNewGeneratedAccount(self: WalletModel, generatedAccount: GeneratedAccoun
try:
generatedAccount.name = accountName
var derivedAccount: DerivedAccount = status_accounts.saveAccount(generatedAccount, password, color, accountType, isADerivedAccount, walletIndex)
var account = self.newAccount(accountName, derivedAccount.address, color, fmt"0.00 {self.defaultCurrency}", derivedAccount.publicKey)
var account = self.newAccount(accountType, derivedAccount.derivationPath, accountName, derivedAccount.address, color, fmt"0.00 {self.defaultCurrency}", derivedAccount.publicKey)
self.accounts.add(account)
self.events.emit("newAccountAdded", AccountArgs(account: account))
except Exception as e:

View File

@ -85,6 +85,7 @@ ModalPopup {
TextWithLabel {
id: pathText
visible: currentAccount.walletType !== Constants.watchWalletType && currentAccount.walletType !== Constants.keyWalletType
//% "Derivation path"
label: qsTrId("derivation-path")
text: currentAccount.path
@ -106,6 +107,7 @@ ModalPopup {
footer: Item {
anchors.fill: parent
StyledButton {
visible: currentAccount.walletType === Constants.watchWalletType
anchors.top: parent.top
anchors.right: saveBtn.left
anchors.rightMargin: Style.current.padding