mirror of
https://github.com/status-im/status-desktop.git
synced 2025-01-18 10:32:53 +00:00
fix: initialize wallet paths and types, and disable deletion of non-watch accounts
This commit is contained in:
parent
92bd8a1b96
commit
239b95e9a2
@ -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:
|
except:
|
||||||
error "Error storing the new account. Bad password?"
|
error "Error storing the new account. Bad password?"
|
||||||
raise
|
raise
|
||||||
|
@ -34,6 +34,7 @@ type GasPricePrediction* = object
|
|||||||
type DerivedAccount* = object
|
type DerivedAccount* = object
|
||||||
publicKey*: string
|
publicKey*: string
|
||||||
address*: string
|
address*: string
|
||||||
|
derivationPath*: string
|
||||||
|
|
||||||
type MultiAccounts* = object
|
type MultiAccounts* = object
|
||||||
whisper* {.serializedFieldName(PATH_WHISPER).}: DerivedAccount
|
whisper* {.serializedFieldName(PATH_WHISPER).}: DerivedAccount
|
||||||
|
@ -188,9 +188,9 @@ proc populateAccount*(self: WalletModel, walletAccount: var WalletAccount, balan
|
|||||||
walletAccount.realFiatBalance = 0.0
|
walletAccount.realFiatBalance = 0.0
|
||||||
updateBalance(walletAccount, self.getDefaultCurrency(), refreshCache)
|
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 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())
|
updateBalance(account, self.getDefaultCurrency())
|
||||||
account
|
account
|
||||||
|
|
||||||
@ -226,7 +226,7 @@ proc addNewGeneratedAccount(self: WalletModel, generatedAccount: GeneratedAccoun
|
|||||||
try:
|
try:
|
||||||
generatedAccount.name = accountName
|
generatedAccount.name = accountName
|
||||||
var derivedAccount: DerivedAccount = status_accounts.saveAccount(generatedAccount, password, color, accountType, isADerivedAccount, walletIndex)
|
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.accounts.add(account)
|
||||||
self.events.emit("newAccountAdded", AccountArgs(account: account))
|
self.events.emit("newAccountAdded", AccountArgs(account: account))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -85,6 +85,7 @@ ModalPopup {
|
|||||||
|
|
||||||
TextWithLabel {
|
TextWithLabel {
|
||||||
id: pathText
|
id: pathText
|
||||||
|
visible: currentAccount.walletType !== Constants.watchWalletType && currentAccount.walletType !== Constants.keyWalletType
|
||||||
//% "Derivation path"
|
//% "Derivation path"
|
||||||
label: qsTrId("derivation-path")
|
label: qsTrId("derivation-path")
|
||||||
text: currentAccount.path
|
text: currentAccount.path
|
||||||
@ -106,6 +107,7 @@ ModalPopup {
|
|||||||
footer: Item {
|
footer: Item {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
StyledButton {
|
StyledButton {
|
||||||
|
visible: currentAccount.walletType === Constants.watchWalletType
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.right: saveBtn.left
|
anchors.right: saveBtn.left
|
||||||
anchors.rightMargin: Style.current.padding
|
anchors.rightMargin: Style.current.padding
|
||||||
|
Loading…
x
Reference in New Issue
Block a user