feat(@desktop/wallet): removing wallet account without an authentication

Closes: #10569
This commit is contained in:
Sale Djenic 2023-05-04 16:34:00 +02:00 committed by saledjenic
parent 399eb75eb0
commit 5122815df8
27 changed files with 77 additions and 219 deletions

View File

@ -57,7 +57,7 @@ proc init*(self: Controller) =
let args = KeycardActivityArgs(e)
if not args.success:
return
self.delegate.onKeycardsSynchronized()
self.delegate.rebuildKeycardsList()
self.events.on(SIGNAL_KEYCARD_LOCKED) do(e: Args):
let args = KeycardActivityArgs(e)
@ -85,6 +85,12 @@ proc init*(self: Controller) =
let args = WalletAccountUpdated(e)
self.delegate.onWalletAccountUpdated(args.account)
self.events.on(SIGNAL_WALLET_ACCOUNT_SAVED) do(e: Args):
self.delegate.rebuildKeycardsList()
self.events.on(SIGNAL_WALLET_ACCOUNT_DELETED) do(e: Args):
self.delegate.rebuildKeycardsList()
proc getAllMigratedKeyPairs*(self: Controller): seq[KeyPairDto] =
return self.walletAccountService.getAllMigratedKeyPairs()

View File

@ -66,7 +66,7 @@ method runCreateNewPairingCodePopup*(self: AccessInterface, keyUid: string) {.ba
method onLoggedInUserImageChanged*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onKeycardsSynchronized*(self: AccessInterface) {.base.} =
method rebuildKeycardsList*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onNewKeycardSet*(self: AccessInterface, keyPair: KeyPairDto) {.base.} =

View File

@ -220,14 +220,20 @@ proc buildKeycardItem(self: Module, walletAccounts: seq[WalletAccountDto], keyPa
# if there are more then one keycard for a single keypair we don't want to add the same keypair more than once
continue
knownAccounts.add(account)
if knownAccounts.len == 0:
return nil
var item = initKeycardItem(keycardUid = keyPair.keycardUid,
keyUid = keyPair.keyUid,
pubKey = knownAccounts[0].publicKey,
pubKey = "",
locked = keyPair.keycardLocked,
name = keyPair.keycardName,
derivedFrom = knownAccounts[0].derivedfrom)
name = keyPair.keycardName)
if knownAccounts.len == 0:
if reason == BuildItemReason.MainView:
return nil
item.setPairType(KeyPairType.SeedImport.int)
item.setIcon("keycard")
else:
item.setPubKey(knownAccounts[0].publicKey)
item.setDerivedFrom(knownAccounts[0].derivedfrom)
for ka in knownAccounts:
var icon = ""
if ka.walletType == WalletTypeDefaultStatusAccount:
@ -277,7 +283,8 @@ method onLoggedInUserImageChanged*(self: Module) =
return
self.view.keycardDetailsModel().setImage(singletonInstance.userProfile.getPubKey(), singletonInstance.userProfile.getIcon())
method onKeycardsSynchronized*(self: Module) =
method rebuildKeycardsList*(self: Module) =
self.view.setKeycardItems(@[])
self.buildKeycardList()
method onNewKeycardSet*(self: Module, keyPair: KeyPairDto) =

View File

@ -3,35 +3,24 @@ import ../../../../../../app_service/service/wallet_account/service as wallet_ac
import ../../../../shared_modules/keycard_popup/io_interface as keycard_shared_module
import ../../../../../core/eventemitter
const UNIQUE_PROFILE_SECTION_ACCOUNTS_MODULE_AUTH_IDENTIFIER* = "ProfileSection-AccountsModule-Authentication"
type
Controller* = ref object of RootObj
delegate: io_interface.AccessInterface
events: EventEmitter
walletAccountService: wallet_account_service.Service
proc newController*(
delegate: io_interface.AccessInterface,
events: EventEmitter,
walletAccountService: wallet_account_service.Service,
): Controller =
result = Controller()
result.delegate = delegate
result.events = events
result.walletAccountService = walletAccountService
proc delete*(self: Controller) =
discard
proc init*(self: Controller) =
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED) do(e: Args):
let args = SharedKeycarModuleArgs(e)
if args.uniqueIdentifier != UNIQUE_PROFILE_SECTION_ACCOUNTS_MODULE_AUTH_IDENTIFIER:
return
self.delegate.onUserAuthenticated(args.pin, args.password, args.keyUid, args.keycardUid)
discard
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
return self.walletAccountService.getWalletAccounts()
@ -39,13 +28,8 @@ proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAcco
proc updateAccount*(self: Controller, address: string, accountName: string, color: string, emoji: string) =
discard self.walletAccountService.updateWalletAccount(address, accountName, color, emoji)
proc deleteAccount*(self: Controller, address: string, password = "", keyUid = "", keycardUid = "") =
self.walletAccountService.deleteAccount(address, password, keyUid, keycardUid)
proc authenticateKeyPair*(self: Controller, keyUid = "") =
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_PROFILE_SECTION_ACCOUNTS_MODULE_AUTH_IDENTIFIER,
keyUid: keyUid)
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
proc deleteAccount*(self: Controller, address: string) =
self.walletAccountService.deleteAccount(address)
proc getMigratedKeyPairByKeyUid*(self: Controller, keyUid: string): seq[KeyPairDto] =
return self.walletAccountService.getMigratedKeyPairByKeyUid(keyUid)

View File

@ -16,7 +16,7 @@ method isLoaded*(self: AccessInterface): bool {.base.} =
method syncKeycard*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method deleteAccount*(self: AccessInterface, keyUid: string, address: string) {.base.} =
method deleteAccount*(self: AccessInterface, address: string) {.base.} =
raise newException(ValueError, "No implementation available")
method refreshWalletAccounts*(self: AccessInterface) {.base.} =
@ -31,11 +31,5 @@ method updateAccount*(self: AccessInterface, address: string, accountName: strin
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method authenticateUser*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onUserAuthenticated*(self: AccessInterface, pin: string, password: string, keyUid: string, keycardUid: string) {.base.} =
raise newException(ValueError, "No implementation available")
method getModuleAsVariant*(self: AccessInterface): QVariant {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -11,19 +11,6 @@ import ../../../../../../app_service/service/network/service as network_service
export io_interface
# TODO: remove it completely if after wallet settings part refactore this is not needed.
type
AuthenticationReason {.pure.} = enum
DeleteAccountAuthentication = 0
# TODO: remove it completely if after wallet settings part refactore this is not needed.
type WalletAccountDetails = object
address: string
path: string
addressAccountIsDerivedFrom: string
publicKey: string
keyUid: string
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
@ -33,8 +20,6 @@ type
controller: Controller
moduleLoaded: bool
walletAccountService: wallet_account_service.Service
processingWalletAccount: WalletAccountDetails
authentiactionReason: AuthenticationReason
proc newModule*(
delegate: delegate_interface.AccessInterface,
@ -48,9 +33,8 @@ proc newModule*(
result.walletAccountService = walletAccountService
result.view = newView(result)
result.viewVariant = newQVariant(result.view)
result.controller = controller.newController(result, events, walletAccountService)
result.controller = controller.newController(result, walletAccountService)
result.moduleLoaded = false
result.authentiactionReason = AuthenticationReason.DeleteAccountAuthentication
method delete*(self: Module) =
self.view.delete
@ -106,29 +90,5 @@ method viewDidLoad*(self: Module) =
method updateAccount*(self: Module, address: string, accountName: string, color: string, emoji: string) =
self.controller.updateAccount(address, accountName, color, emoji)
proc authenticateActivityForKeyUid(self: Module, keyUid: string, reason: AuthenticationReason) =
self.authentiactionReason = reason
let keyPair = self.controller.getMigratedKeyPairByKeyUid(keyUid)
let keyPairMigratedToKeycard = keyPair.len > 0
if keyPairMigratedToKeycard:
self.controller.authenticateKeyPair(keyUid)
else:
self.processingWalletAccount.keyUid = singletonInstance.userProfile.getKeyUid()
self.controller.authenticateKeyPair()
method deleteAccount*(self: Module, keyUid: string, address: string) =
let accountDto = self.controller.getWalletAccount(address)
if accountDto.walletType == WalletTypeWatch:
self.controller.deleteAccount(address)
return
self.processingWalletAccount = WalletAccountDetails(keyUid: keyUid, address: address)
self.authenticateActivityForKeyUid(keyUid, AuthenticationReason.DeleteAccountAuthentication)
method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid: string, keycardUid: string) =
if self.authentiactionReason == AuthenticationReason.DeleteAccountAuthentication:
if self.processingWalletAccount.keyUid != keyUid:
error "cannot resolve key uid of an account being deleted", keyUid=keyUid
return
if password.len == 0:
return
self.controller.deleteAccount(self.processingWalletAccount.address, password, keyUid, keycardUid)
method deleteAccount*(self: Module, address: string) =
self.controller.deleteAccount(address)

View File

@ -44,5 +44,5 @@ QtObject:
proc onUpdatedAccount*(self: View, account: Item) =
self.accounts.onUpdatedAccount(account)
proc deleteAccount*(self: View, keyUid: string, address: string) {.slot.} =
self.delegate.deleteAccount(keyUid, address)
proc deleteAccount*(self: View, address: string) {.slot.} =
self.delegate.deleteAccount(address)

View File

@ -5,31 +5,23 @@ import ../../../../../app_service/service/network/service as network_service
import ../../../../../app_service/service/currency/service as currency_service
import ../../../../../app_service/service/currency/dto as currency_dto
import ../../../../global/global_singleton
import ../../../shared_modules/keycard_popup/io_interface as keycard_shared_module
import ../../../../core/eventemitter
const UNIQUE_WALLET_SECTION_ACCOUNTS_MODULE_AUTH_IDENTIFIER* = "WalletSection-AccountsModule-Authentication"
type
Controller* = ref object of RootObj
delegate: io_interface.AccessInterface
events: EventEmitter
walletAccountService: wallet_account_service.Service
networkService: network_service.Service
currencyService: currency_service.Service
proc newController*(
delegate: io_interface.AccessInterface,
events: EventEmitter,
walletAccountService: wallet_account_service.Service,
networkService: network_service.Service,
currencyService: currency_service.Service,
): Controller =
result = Controller()
result.delegate = delegate
result.events = events
result.walletAccountService = walletAccountService
result.networkService = networkService
result.currencyService = currencyService
@ -38,22 +30,13 @@ proc delete*(self: Controller) =
discard
proc init*(self: Controller) =
self.events.on(SIGNAL_SHARED_KEYCARD_MODULE_USER_AUTHENTICATED) do(e: Args):
let args = SharedKeycarModuleArgs(e)
if args.uniqueIdentifier != UNIQUE_WALLET_SECTION_ACCOUNTS_MODULE_AUTH_IDENTIFIER:
return
self.delegate.onUserAuthenticated(args.pin, args.password, args.keyUid, args.keycardUid)
discard
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
return self.walletAccountService.getWalletAccounts()
proc deleteAccount*(self: Controller, address: string, password = "", keyUid = "", keycardUid = "") =
self.walletAccountService.deleteAccount(address, password, keyUid, keycardUid)
proc authenticateKeyPair*(self: Controller, keyUid = "") =
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_WALLET_SECTION_ACCOUNTS_MODULE_AUTH_IDENTIFIER,
keyUid: keyUid)
self.events.emit(SIGNAL_SHARED_KEYCARD_MODULE_AUTHENTICATE_USER, data)
proc deleteAccount*(self: Controller, address: string) =
self.walletAccountService.deleteAccount(address)
proc getEnabledChainIds*(self: Controller): seq[int] =
return self.networkService.getNetworks().filter(n => n.enabled).map(n => n.chainId)

View File

@ -13,7 +13,7 @@ method load*(self: AccessInterface) {.base.} =
method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method deleteAccount*(self: AccessInterface, keyUid: string, address: string) {.base.} =
method deleteAccount*(self: AccessInterface, address: string) {.base.} =
raise newException(ValueError, "No implementation available")
method refreshWalletAccounts*(self: AccessInterface) {.base.} =
@ -26,10 +26,4 @@ method updateAccount*(self: AccessInterface, address: string, accountName: strin
# Delegate for the view must be declared here due to use of QtObject and multi
# inheritance, which is not well supported in Nim.
method viewDidLoad*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method authenticateUser*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method onUserAuthenticated*(self: AccessInterface, pin: string, password: string, keyUid: string, keycardUid: string) {.base.} =
raise newException(ValueError, "No implementation available")
raise newException(ValueError, "No implementation available")

View File

@ -14,19 +14,6 @@ import ../../../shared_modules/keycard_popup/io_interface as keycard_shared_modu
export io_interface
# TODO: remove it completely if after wallet settings part refactore this is not needed.
type
AuthenticationReason {.pure.} = enum
DeleteAccountAuthentication = 0
# TODO: remove it completely if after wallet settings part refactore this is not needed.
type WalletAccountDetails = object
address: string
path: string
addressAccountIsDerivedFrom: string
publicKey: string
keyUid: string
type
Module* = ref object of io_interface.AccessInterface
delegate: delegate_interface.AccessInterface
@ -35,8 +22,6 @@ type
controller: Controller
moduleLoaded: bool
walletAccountService: wallet_account_service.Service
processingWalletAccount: WalletAccountDetails
authentiactionReason: AuthenticationReason
proc newModule*(
delegate: delegate_interface.AccessInterface,
@ -50,9 +35,8 @@ proc newModule*(
result.events = events
result.walletAccountService = walletAccountService
result.view = newView(result)
result.controller = controller.newController(result, events, walletAccountService, networkService, currencyService)
result.controller = controller.newController(result, walletAccountService, networkService, currencyService)
result.moduleLoaded = false
result.authentiactionReason = AuthenticationReason.DeleteAccountAuthentication
method delete*(self: Module) =
self.view.delete
@ -123,32 +107,8 @@ method viewDidLoad*(self: Module) =
self.moduleLoaded = true
self.delegate.accountsModuleDidLoad()
proc authenticateActivityForKeyUid(self: Module, keyUid: string, reason: AuthenticationReason) =
self.authentiactionReason = reason
let keyPair = self.controller.getMigratedKeyPairByKeyUid(keyUid)
let keyPairMigratedToKeycard = keyPair.len > 0
if keyPairMigratedToKeycard:
self.controller.authenticateKeyPair(keyUid)
else:
self.processingWalletAccount.keyUid = singletonInstance.userProfile.getKeyUid()
self.controller.authenticateKeyPair()
method deleteAccount*(self: Module, keyUid: string, address: string) =
let accountDto = self.controller.getWalletAccount(address)
if accountDto.walletType == WalletTypeWatch:
self.controller.deleteAccount(address)
return
self.processingWalletAccount = WalletAccountDetails(keyUid: keyUid, address: address)
self.authenticateActivityForKeyUid(keyUid, AuthenticationReason.DeleteAccountAuthentication)
method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid: string, keycardUid: string) =
if self.authentiactionReason == AuthenticationReason.DeleteAccountAuthentication:
if self.processingWalletAccount.keyUid != keyUid:
error "cannot resolve key uid of an account being deleted", keyUid=keyUid
return
if password.len == 0:
return
self.controller.deleteAccount(self.processingWalletAccount.address, password, keyUid, keycardUid)
method deleteAccount*(self: Module, address: string) =
self.controller.deleteAccount(address)
method updateAccount*(self: Module, address: string, accountName: string, color: string, emoji: string) =
self.controller.updateAccount(address, accountName, color, emoji)

View File

@ -40,8 +40,8 @@ QtObject:
proc setItems*(self: View, items: seq[Item]) =
self.accounts.setItems(items)
proc deleteAccount*(self: View, keyUid: string, address: string) {.slot.} =
self.delegate.deleteAccount(keyUid, address)
proc deleteAccount*(self: View, address: string) {.slot.} =
self.delegate.deleteAccount(address)
proc updateAccount(self: View, address: string, accountName: string, color: string, emoji: string) {.slot.} =
self.delegate.updateAccount(address, accountName, color, emoji)

View File

@ -14,9 +14,6 @@ method load*(self: AccessInterface) {.base.} =
method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method deleteAccount*(self: AccessInterface, keyUid: string, address: string) {.base.} =
raise newException(ValueError, "No implementation available")
method refreshWalletAccounts*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -380,12 +380,12 @@ proc verifyPassword*(self: Controller, password: string): bool =
return
return self.accountsService.verifyPassword(password)
proc convertSelectedKeyPairToKeycardAccount*(self: Controller, password: string) =
proc convertSelectedKeyPairToKeycardAccount*(self: Controller, keycardUid: string, password: string) =
if not serviceApplicable(self.accountsService):
return
let acc = self.accountsService.createAccountFromMnemonic(self.getSeedPhrase(), includeEncryption = true)
singletonInstance.localAccountSettings.setStoreToKeychainValue(LS_VALUE_NOT_NOW)
self.accountsService.convertToKeycardAccount(currentPassword = password,
self.accountsService.convertToKeycardAccount(keycardUid, currentPassword = password,
newPassword = acc.derivedAccounts.encryption.publicKey)
proc getConvertingProfileSuccess*(self: Controller): bool =
@ -631,7 +631,7 @@ proc addMigratedKeyPair*(self: Controller, keyPair: KeyPairDto) =
return
if not serviceApplicable(self.accountsService):
return
self.walletAccountService.addMigratedKeyPairAsync(keyPair, self.getPassword())
self.walletAccountService.addMigratedKeyPairAsync(keyPair)
proc removeMigratedAccountsForKeycard*(self: Controller, keyUid: string, keycardUid: string, accountsToRemove: seq[string]) =
if not serviceApplicable(self.walletAccountService):

View File

@ -26,7 +26,8 @@ proc doMigration(self: MigratingKeyPairState, controller: Controller) =
proc doConversion(self: MigratingKeyPairState, controller: Controller) =
let password = controller.getPassword()
controller.convertSelectedKeyPairToKeycardAccount(password)
let selectedKeyPairDto = controller.getSelectedKeyPairDto()
controller.convertSelectedKeyPairToKeycardAccount(selectedKeyPairDto.keycardUid, password)
proc runStoreMetadataFlow(self: MigratingKeyPairState, controller: Controller) =
let selectedKeyPairDto = controller.getSelectedKeyPairDto()
@ -48,12 +49,6 @@ method executePreSecondaryStateCommand*(self: MigratingKeyPairState, controller:
let password = controller.getPassword()
self.authenticationOk = controller.verifyPassword(password)
if self.authenticationOk:
self.doMigration(controller)
return
if not self.addingMigratedKeypairDone:
self.addingMigratedKeypairDone = true
self.addingMigratedKeypairOk = controller.getAddingMigratedKeypairSuccess()
if self.addingMigratedKeypairOk:
self.doConversion(controller)
return
if not self.profileConversionDone:
@ -70,9 +65,12 @@ method executePreSecondaryStateCommand*(self: MigratingKeyPairState, controller:
method getNextSecondaryState*(self: MigratingKeyPairState, controller: Controller): State =
if self.flowType == FlowType.SetupNewKeycard:
if controller.getSelectedKeyPairIsProfile() and self.authenticationDone and not self.authenticationOk or
self.addingMigratedKeypairDone and not self.addingMigratedKeypairOk or
self.profileConversionDone and not self.profileConversionOk:
if controller.getSelectedKeyPairIsProfile():
if self.authenticationDone and not self.authenticationOk or
self.profileConversionDone and not self.profileConversionOk:
return createState(StateType.KeyPairMigrateFailure, self.flowType, nil)
else:
if self.addingMigratedKeypairDone and not self.addingMigratedKeypairOk:
return createState(StateType.KeyPairMigrateFailure, self.flowType, nil)
method resolveKeycardNextState*(self: MigratingKeyPairState, keycardFlowType: string, keycardEvent: KeycardEvent,

View File

@ -6,6 +6,7 @@ type
ConvertToKeycardAccountTaskArg* = ref object of QObjectTaskArg
accountDataJson: JsonNode
settingsJson: JsonNode
keycardUid: string
hashedCurrentPassword: string
newPassword: string
@ -13,7 +14,7 @@ const convertToKeycardAccountTask*: Task = proc(argEncoded: string) {.gcsafe, ni
let arg = decode[ConvertToKeycardAccountTaskArg](argEncoded)
try:
let response = status_account.convertToKeycardAccount(arg.accountDataJson, arg.settingsJson,
arg.hashedCurrentPassword, arg.newPassword)
arg.keycardUid, arg.hashedCurrentPassword, arg.newPassword)
arg.finish(response)
except Exception as e:
error "error converting profile keypair: ", message = e.msg

View File

@ -766,7 +766,7 @@ QtObject:
error "error: ", procName="loginAccountKeycard", errName = e.name, errDesription = e.msg
return e.msg
proc convertToKeycardAccount*(self: Service, currentPassword: string, newPassword: string) =
proc convertToKeycardAccount*(self: Service, keycardUid, currentPassword: string, newPassword: string) =
var accountDataJson = %* {
"key-uid": self.getLoggedInAccount().keyUid,
"kdfIterations": KDF_ITERATIONS
@ -787,6 +787,7 @@ QtObject:
slot: "onConvertToKeycardAccount",
accountDataJson: accountDataJson,
settingsJson: settingsJson,
keycardUid: keycardUid,
hashedCurrentPassword: hashedCurrentPassword,
newPassword: newPassword
)

View File

@ -91,8 +91,7 @@ const prepareTokensTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
type
AddMigratedKeyPairTaskArg* = ref object of QObjectTaskArg
keyPair: KeyPairDto
password: string
keyPair: KeyPairDto
const addMigratedKeyPairTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[AddMigratedKeyPairTaskArg](argEncoded)
@ -101,8 +100,7 @@ const addMigratedKeyPairTask*: Task = proc(argEncoded: string) {.gcsafe, nimcall
arg.keyPair.keycardUid,
arg.keyPair.keycardName,
arg.keyPair.keyUid,
arg.keyPair.accountsAddresses,
arg.password
arg.keyPair.accountsAddresses
)
let success = responseHasNoErrors("addMigratedKeyPairOrAddAccountsIfKeyPairIsAdded", response)
let responseJson = %*{

View File

@ -465,25 +465,13 @@ QtObject:
error "error: ", procName="getRandomMnemonic", errName=e.name, errDesription=e.msg
return ""
proc deleteAccount*(self: Service, address: string, password: string, keyUid: string, keycardUid: string) =
proc deleteAccount*(self: Service, address: string) =
try:
let isKeycardAccount = keycardUid.len > 0
var finalPassword = password
if not isKeycardAccount:
finalPassword = utils.hashPassword(password)
let response = status_go_accounts.deleteAccount(address, finalPassword)
let response = status_go_accounts.deleteAccount(address)
if not response.error.isNil:
error "status-go error", procName="deleteAccount", errCode=response.error.code, errDesription=response.error.message
return
self.removeAccountFromLocalStoreAndNotify(address)
if isKeycardAccount:
self.removeMigratedAccountsForKeycard(keyUid, keycardUid, @[address])
let accounts = self.getAccountsByKeyUID(keyUID)
if accounts.len == 0:
let allKnownKeycards = self.getAllKnownKeycards()
for kc in allKnownKeycards:
if kc.keyUid == keyUid:
self.removeMigratedAccountsForKeycard(kc.keyUid, kc.keycardUid, kc.accountsAddresses)
except Exception as e:
error "error: ", procName="deleteAccount", errName = e.name, errDesription = e.msg
@ -691,18 +679,12 @@ QtObject:
return 0.0
proc addMigratedKeyPairAsync*(self: Service, keyPair: KeyPairDto, password = "") =
# Providing a password corresponding local keystore file will be removed as well, though
# in some contexts we just need to add keypair to the db, so password is not needed.
var hashedPassword = ""
if password.len > 0:
hashedPassword = utils.hashPassword(password)
proc addMigratedKeyPairAsync*(self: Service, keyPair: KeyPairDto) =
let arg = AddMigratedKeyPairTaskArg(
tptr: cast[ByteAddress](addMigratedKeyPairTask),
vptr: cast[ByteAddress](self.vptr),
slot: "onMigratedKeyPairAdded",
keyPair: keyPair,
password: hashedPassword
keyPair: keyPair
)
self.threadpool.start(arg)
@ -728,16 +710,13 @@ QtObject:
error "error handilng migrated keypair response", errDesription=e.msg
self.emitAddKeycardAddAccountsChange(success = false, KeyPairDto())
proc addMigratedKeyPair*(self: Service, keyPair: KeyPairDto, password = ""): bool =
# Providing a password corresponding local keystore file will be removed as well, though
# in some contexts we just need to add keypair to the db, so password is not needed.
proc addMigratedKeyPair*(self: Service, keyPair: KeyPairDto): bool =
try:
let response = backend.addMigratedKeyPairOrAddAccountsIfKeyPairIsAdded(
keyPair.keycardUid,
keyPair.keycardName,
keyPair.keyUid,
keyPair.accountsAddresses,
password
keyPair.accountsAddresses
)
result = responseHasNoErrors("addMigratedKeyPair", response)
if result:

View File

@ -25,8 +25,8 @@ proc getAccountsByKeyUID*(keyUid: string): RpcResponse[JsonNode] {.raises: [Exce
let payload = %* [keyUid]
return core.callPrivateRPC("accounts_getAccountsByKeyUID", payload)
proc deleteAccount*(address: string, password: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [address, password]
proc deleteAccount*(address: string): RpcResponse[JsonNode] {.raises: [Exception].} =
let payload = %* [address]
return core.callPrivateRPC("accounts_deleteAccount", payload)
## Adds a new account and creates a Keystore file if password is provided, otherwise it only creates a new account. Notifies paired devices.
@ -312,10 +312,10 @@ proc saveAccountAndLoginWithKeycard*(chatKey, password: string, account, subacco
error "error doing rpc request", methodName = "saveAccountAndLogin", exception=e.msg
raise newException(RpcException, e.msg)
proc convertToKeycardAccount*(account: JsonNode, settings: JsonNode, password: string, newPassword: string):
proc convertToKeycardAccount*(account: JsonNode, settings: JsonNode, keycardUid: string, password: string, newPassword: string):
RpcResponse[JsonNode] {.raises: [Exception].} =
try:
let response = status_go.convertToKeycardAccount($account, $settings, password, newPassword)
let response = status_go.convertToKeycardAccount($account, $settings, keycardUid, password, newPassword)
result.result = Json.decode(response, JsonNode)
except RpcException as e:

View File

@ -193,7 +193,6 @@ rpc(addMigratedKeyPairOrAddAccountsIfKeyPairIsAdded, "accounts"):
keyPairName: string
keyUid: string
accountAddresses: seq[string]
password: string
rpc(removeMigratedAccountsForKeycard, "accounts"):
keycardUid: string

View File

@ -23,8 +23,8 @@ QtObject {
property var accounts: Global.appIsReady? accountsModule.accounts : null
function deleteAccount(keyUid, address) {
return accountsModule.deleteAccount(keyUid, address)
function deleteAccount(address) {
return accountsModule.deleteAccount(address)
}
function updateAccount(address, accountName, color, emoji) {

View File

@ -161,7 +161,7 @@ Item {
onConfirmButtonClicked: {
confirmationPopup.close();
root.goBack();
root.walletStore.deleteAccount(root.account.keyUid, root.account.address);
root.walletStore.deleteAccount(root.account.address);
}
}

View File

@ -132,8 +132,8 @@ QtObject {
walletSection.setFilterAddress(address)
}
function deleteAccount(keyUid, address) {
return walletSectionAccounts.deleteAccount(keyUid, address)
function deleteAccount(address) {
return walletSectionAccounts.deleteAccount(address)
}
function updateCurrentAccount(address, accountName, color, emoji) {

View File

@ -88,7 +88,6 @@ Rectangle {
width: 400
simple: removeAccountConfirmation.simple
accountKeyUid: removeAccountConfirmation.accountKeyUid
accountName: removeAccountConfirmation.accountName
accountAddress: removeAccountConfirmation.accountAddress
accountDerivationPath: removeAccountConfirmation.accountDerivationPath
@ -99,7 +98,7 @@ Rectangle {
onRemoveAccount: {
close()
RootStore.deleteAccount(keyUid, address)
RootStore.deleteAccount(address)
}
}
@ -303,7 +302,6 @@ Rectangle {
onDeleteAccountClicked: {
removeAccountConfirmation.simple = model.walletType === Constants.watchWalletType || model.walletType === Constants.keyWalletType
removeAccountConfirmation.accountKeyUid = model.keyUid
removeAccountConfirmation.accountName = model.name
removeAccountConfirmation.accountAddress = model.address
removeAccountConfirmation.accountDerivationPath = model.path

View File

@ -14,12 +14,11 @@ StatusModal {
id: root
required property bool simple
required property string accountKeyUid
required property string accountName
required property string accountAddress
required property string accountDerivationPath
signal removeAccount(string keyUid, string address)
signal removeAccount(string address)
header.title: qsTr("Remove %1").arg(root.accountName)
focus: visible
@ -34,7 +33,7 @@ StatusModal {
if (!root.simple && !derivationPathWritten.checked) {
return
}
root.removeAccount(root.accountKeyUid, root.accountAddress)
root.removeAccount(root.accountAddress)
}
}

@ -1 +1 @@
Subproject commit 534c04dc737f681ef49207e1f183e9fc53647fd5
Subproject commit 934096fe3f3ffb3478d6aaac1a775f75abded0a6

2
vendor/status-go vendored

@ -1 +1 @@
Subproject commit c5a8b40d9c8b7a0104ea9894b07eb3ca42b530af
Subproject commit 31144ed5a38589fd129945b634f54e800b39645a