fix(@desktop/wallet): a few wallet account related issues fixed
- index was not returned properly because of case sensitive address comparison - delete account was not done properly for keycard accounts - after login the app was asking for store to keychain even it was a test environment
This commit is contained in:
parent
713b145653
commit
2fae4cdaf1
|
@ -349,6 +349,8 @@ proc connectKeychain(self: AppController) =
|
|||
self.keychainConnectionIds.add(handlerId)
|
||||
|
||||
proc checkForStoringPasswordToKeychain(self: AppController) =
|
||||
if singletonInstance.localAppSettings.getTestEnvironment():
|
||||
return
|
||||
## This proc is used to store pass/pin depends on user's selection during onboarding flow.
|
||||
let account = self.accountsService.getLoggedInAccount()
|
||||
let value = singletonInstance.localAccountSettings.getStoreToKeychainValue()
|
||||
|
|
|
@ -47,8 +47,8 @@ proc init*(self: Controller) =
|
|||
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
||||
return self.walletAccountService.getWalletAccounts()
|
||||
|
||||
proc deleteAccount*(self: Controller, address: string, password = "") =
|
||||
self.walletAccountService.deleteAccount(address, password)
|
||||
proc deleteAccount*(self: Controller, address: string, password = "", doPasswordHashing = false) =
|
||||
self.walletAccountService.deleteAccount(address, password, doPasswordHashing)
|
||||
|
||||
proc authenticateKeyPair*(self: Controller, keyUid = "") =
|
||||
let data = SharedKeycarModuleAuthenticationArgs(uniqueIdentifier: UNIQUE_WALLET_SECTION_ACCOUNTS_MODULE_AUTH_IDENTIFIER,
|
||||
|
|
|
@ -149,13 +149,8 @@ proc authenticateActivityForKeyUid(self: Module, keyUid: string, reason: Authent
|
|||
if keyPairMigratedToKeycard:
|
||||
self.controller.authenticateKeyPair(keyUid)
|
||||
else:
|
||||
if singletonInstance.userProfile.getIsKeycardUser():
|
||||
## We're here in case the keypair we're conducting an action for is not migrated to a keycard, but
|
||||
## profile keypair is migrated, then we're authenticating profile keypair (logged in user).
|
||||
self.processingWalletAccount.keyUid = singletonInstance.userProfile.getKeyUid()
|
||||
self.controller.authenticateKeyPair(singletonInstance.userProfile.getKeyUid())
|
||||
else:
|
||||
self.controller.authenticateKeyPair()
|
||||
self.processingWalletAccount.keyUid = singletonInstance.userProfile.getKeyUid()
|
||||
self.controller.authenticateKeyPair()
|
||||
|
||||
method deleteAccount*(self: Module, keyUid: string, address: string) =
|
||||
let accountDto = self.controller.getWalletAccount(address)
|
||||
|
@ -170,10 +165,7 @@ method onUserAuthenticated*(self: Module, pin: string, password: string, keyUid:
|
|||
if self.processingWalletAccount.keyUid != keyUid:
|
||||
error "cannot resolve key uid of an account being deleted", keyUid=keyUid
|
||||
return
|
||||
if pin.len == PINLengthForStatusApp:
|
||||
# keycard keypair authentication
|
||||
self.controller.deleteAccount(self.processingWalletAccount.address)
|
||||
self.tryKeycardSync(keyUid, pin)
|
||||
elif password.len > 0:
|
||||
# regular keypair authentication
|
||||
self.controller.deleteAccount(self.processingWalletAccount.address, password)
|
||||
if password.len == 0:
|
||||
return
|
||||
let doPasswordHashing = pin.len != PINLengthForStatusApp
|
||||
self.controller.deleteAccount(self.processingWalletAccount.address, password, doPasswordHashing)
|
|
@ -37,6 +37,9 @@ proc delete*(self: Controller) =
|
|||
proc init*(self: Controller) =
|
||||
discard
|
||||
|
||||
proc getWalletAccounts*(self: Controller): seq[wallet_account_service.WalletAccountDto] =
|
||||
return self.walletAccountService.getWalletAccounts()
|
||||
|
||||
proc getWalletAccount*(self: Controller, accountIndex: int): wallet_account_service.WalletAccountDto =
|
||||
return self.walletAccountService.getWalletAccount(accountIndex)
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ QtObject:
|
|||
proc getIndex*(self: Service, address: string): int =
|
||||
let accounts = self.getWalletAccounts()
|
||||
for i in 0 ..< accounts.len:
|
||||
if(accounts[i].address == address):
|
||||
if cmpIgnoreCase(accounts[i].address, address) == 0:
|
||||
return i
|
||||
|
||||
proc startWallet(self: Service) =
|
||||
|
@ -423,12 +423,12 @@ QtObject:
|
|||
error "error: ", procName="getRandomMnemonic", errName=e.name, errDesription=e.msg
|
||||
return ""
|
||||
|
||||
proc deleteAccount*(self: Service, address: string, password = "") =
|
||||
proc deleteAccount*(self: Service, address: string, password: string, doPasswordHashing: bool) =
|
||||
try:
|
||||
var hashedPassword = ""
|
||||
if password.len > 0:
|
||||
hashedPassword = utils.hashPassword(password)
|
||||
discard status_go_accounts.deleteAccount(address, hashedPassword)
|
||||
var finalPassword = password
|
||||
if doPasswordHashing:
|
||||
finalPassword = utils.hashPassword(password)
|
||||
discard status_go_accounts.deleteAccount(address, finalPassword)
|
||||
let accountDeleted = self.removeAccount(address)
|
||||
self.events.emit(SIGNAL_WALLET_ACCOUNT_DELETED, AccountDeleted(account: accountDeleted))
|
||||
except Exception as e:
|
||||
|
|
Loading…
Reference in New Issue