fix(@desktop/keycard): keypair is not registered for newly created keycard users
Fixes: #7899
This commit is contained in:
parent
43011645f2
commit
7a73452706
|
@ -1,4 +1,4 @@
|
|||
import NimQml, chronicles
|
||||
import NimQml, sequtils, sugar, chronicles
|
||||
|
||||
import ../../app_service/service/general/service as general_service
|
||||
import ../../app_service/service/keychain/service as keychain_service
|
||||
|
@ -30,6 +30,7 @@ import ../../app_service/service/devices/service as devices_service
|
|||
import ../../app_service/service/mailservers/service as mailservers_service
|
||||
import ../../app_service/service/gif/service as gif_service
|
||||
import ../../app_service/service/ens/service as ens_service
|
||||
import ../../app_service/common/account_constants
|
||||
|
||||
import ../modules/startup/module as startup_module
|
||||
import ../modules/main/module as main_module
|
||||
|
@ -44,6 +45,7 @@ logScope:
|
|||
|
||||
type
|
||||
AppController* = ref object of RootObj
|
||||
storeKeyPair: bool
|
||||
statusFoundation: StatusFoundation
|
||||
notificationsManager*: NotificationsManager
|
||||
|
||||
|
@ -101,6 +103,7 @@ proc buildAndRegisterUserProfile(self: AppController)
|
|||
# Startup Module Delegate Interface
|
||||
proc startupDidLoad*(self: AppController)
|
||||
proc userLoggedIn*(self: AppController)
|
||||
proc storeKeyPairForNewKeycardUser*(self: AppController)
|
||||
|
||||
# Main Module Delegate Interface
|
||||
proc mainDidLoad*(self: AppController)
|
||||
|
@ -113,6 +116,7 @@ proc connect(self: AppController) =
|
|||
|
||||
proc newAppController*(statusFoundation: StatusFoundation): AppController =
|
||||
result = AppController()
|
||||
result.storeKeyPair = false
|
||||
result.statusFoundation = statusFoundation
|
||||
|
||||
# Preparing settings service to be exposed later as global QObject
|
||||
|
@ -400,3 +404,25 @@ proc buildAndRegisterUserProfile(self: AppController) =
|
|||
singletonInstance.userProfile.setCurrentUserStatus(currentUserStatus.statusType.int)
|
||||
|
||||
singletonInstance.engine.setRootContextProperty("userProfile", self.userProfileVariant)
|
||||
|
||||
if self.storeKeyPair and singletonInstance.userProfile.getIsKeycardUser():
|
||||
let allAccounts = self.walletAccountService.fetchAccounts()
|
||||
let defaultWalletAccounts = allAccounts.filter(a =>
|
||||
a.walletType == WalletTypeDefaultStatusAccount and
|
||||
a.path == account_constants.PATH_DEFAULT_WALLET and
|
||||
not a.isChat and
|
||||
a.isWallet
|
||||
)
|
||||
if defaultWalletAccounts.len == 0:
|
||||
error "default wallet account was not generated"
|
||||
return
|
||||
let defaultWalletAddress = defaultWalletAccounts[0].address
|
||||
let keyPair = KeyPairDto(keycardUid: self.keycardService.getLastReceivedKeycardData().flowEvent.instanceUID,
|
||||
keycardName: displayName,
|
||||
keycardLocked: false,
|
||||
accountsAddresses: @[defaultWalletAddress],
|
||||
keyUid: loggedInAccount.keyUid)
|
||||
discard self.walletAccountService.addMigratedKeyPair(keyPair)
|
||||
|
||||
proc storeKeyPairForNewKeycardUser*(self: AppController) =
|
||||
self.storeKeyPair = true
|
|
@ -10,6 +10,7 @@ import ../../../app_service/service/accounts/service as accounts_service
|
|||
import ../../../app_service/service/keychain/service as keychain_service
|
||||
import ../../../app_service/service/profile/service as profile_service
|
||||
import ../../../app_service/service/keycard/service as keycard_service
|
||||
import ../../../app_service/common/account_constants
|
||||
|
||||
import ../shared_modules/keycard_popup/io_interface as keycard_shared_module
|
||||
|
||||
|
@ -77,6 +78,7 @@ proc newController*(delegate: io_interface.AccessInterface,
|
|||
|
||||
# Forward declaration
|
||||
proc cleanTmpData*(self: Controller)
|
||||
proc storeMetadataForNewKeycardUser(self: Controller)
|
||||
|
||||
proc disconnectKeychain*(self: Controller) =
|
||||
for id in self.keychainConnectionIds:
|
||||
|
@ -319,6 +321,8 @@ proc storeImportedAccountAndLogin*(self: Controller, storeToKeychain: bool) =
|
|||
proc storeKeycardAccountAndLogin*(self: Controller, storeToKeychain: bool) =
|
||||
if self.importMnemonic():
|
||||
let accountId = self.getImportedAccount().id
|
||||
self.delegate.storeKeyPairForNewKeycardUser()
|
||||
self.storeMetadataForNewKeycardUser()
|
||||
self.setupAccount(accountId, storeToKeychain, keycardUsage = true)
|
||||
else:
|
||||
error "an error ocurred while importing mnemonic"
|
||||
|
@ -419,6 +423,10 @@ proc runRecoverAccountFlow*(self: Controller, seedPhraseLength = 0, seedPhrase =
|
|||
self.cancelCurrentFlow() # before running into any flow we're making sure that the previous flow is canceled
|
||||
self.keycardService.startRecoverAccountFlow(seedPhraseLength, seedPhrase, puk, factoryReset)
|
||||
|
||||
proc runStoreMetadataFlow*(self: Controller, cardName: string, pin: string, walletPaths: seq[string]) =
|
||||
self.cancelCurrentFlow()
|
||||
self.keycardService.startStoreMetadataFlow(cardName, pin, walletPaths)
|
||||
|
||||
proc resumeCurrentFlow*(self: Controller) =
|
||||
self.keycardService.resumeCurrentFlow()
|
||||
|
||||
|
@ -451,3 +459,8 @@ proc buildSeedPhrasesFromIndexes*(self: Controller, seedPhraseIndexes: seq[int])
|
|||
|
||||
proc generateRandomPUK*(self: Controller): string =
|
||||
return self.keycardService.generateRandomPUK()
|
||||
|
||||
proc storeMetadataForNewKeycardUser(self: Controller) =
|
||||
## Stores metadata, default Status account only, to the keycard for a newly created keycard user.
|
||||
let paths = @[account_constants.PATH_DEFAULT_WALLET]
|
||||
self.runStoreMetadataFlow(self.getDisplayName(), self.getPin(), paths)
|
|
@ -133,8 +133,12 @@ method setKeycardData*(self: AccessInterface, value: string) {.base.} =
|
|||
method runFactoryResetPopup*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method storeKeyPairForNewKeycardUser*(self: AccessInterface) {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
# This way (using concepts) is used only for the modules managed by AppController
|
||||
type
|
||||
DelegateInterface* = concept c
|
||||
c.startupDidLoad()
|
||||
c.userLoggedIn()
|
||||
c.storeKeyPairForNewKeycardUser()
|
||||
|
|
|
@ -352,3 +352,6 @@ method onSharedKeycarModuleFlowTerminated*[T](self: Module[T], lastStepInTheCurr
|
|||
if lastStepInTheCurrentFlow:
|
||||
self.controller.cleanTmpData()
|
||||
self.view.setCurrentStartupState(newWelcomeState(FlowType.General, nil))
|
||||
|
||||
method storeKeyPairForNewKeycardUser*[T](self: Module[T]) =
|
||||
self.delegate.storeKeyPairForNewKeycardUser()
|
|
@ -27,7 +27,7 @@ StatusListItem {
|
|||
|
||||
signal keyPairSelected()
|
||||
|
||||
color: root.keyPairCardLocked? Theme.palette.dangerColor3 : Style.current.grey
|
||||
color: root.keyPairCardLocked? Theme.palette.dangerColor3 : Theme.palette.baseColor2
|
||||
title: root.keyPairName
|
||||
statusListItemTitleAside.textFormat: Text.RichText
|
||||
statusListItemTitleAside.visible: !!statusListItemTitleAside.text
|
||||
|
@ -38,7 +38,7 @@ StatusListItem {
|
|||
}
|
||||
if (root.keyPairCardLocked) {
|
||||
let label = qsTr("Keycard Locked")
|
||||
t += `<font color="${Theme.palette.dangerColor1}" size="5">${label}</font>`
|
||||
t += ` <font color="${Theme.palette.dangerColor1}" size="5">${label}</font>`
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ Rectangle {
|
|||
property string keyPairDerivedFrom: ""
|
||||
property string keyPairAccounts: ""
|
||||
|
||||
color: Style.current.grey
|
||||
color: Theme.palette.baseColor2
|
||||
radius: Style.current.halfPadding
|
||||
implicitWidth: 448
|
||||
implicitHeight: 198
|
||||
|
|
|
@ -23,7 +23,7 @@ StatusListItem {
|
|||
|
||||
signal keycardSelected()
|
||||
|
||||
color: root.keycardLocked? Theme.palette.dangerColor3 : Style.current.grey
|
||||
color: root.keycardLocked? Theme.palette.dangerColor3 : Theme.palette.baseColor2
|
||||
title: root.keycardName
|
||||
statusListItemTitleAside.textFormat: Text.RichText
|
||||
statusListItemTitleAside.visible: !!statusListItemTitleAside.text
|
||||
|
@ -34,7 +34,7 @@ StatusListItem {
|
|||
}
|
||||
if (root.keycardLocked) {
|
||||
let label = qsTr("Keycard Locked")
|
||||
t += `<font color="${Theme.palette.dangerColor1}" size="5">${label}</font>`
|
||||
t += ` <font color="${Theme.palette.dangerColor1}" size="5">${label}</font>`
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue