diff --git a/src/app/modules/main/profile_section/keycard/controller.nim b/src/app/modules/main/profile_section/keycard/controller.nim index 0b7e429e21..c79f736200 100644 --- a/src/app/modules/main/profile_section/keycard/controller.nim +++ b/src/app/modules/main/profile_section/keycard/controller.nim @@ -123,4 +123,10 @@ proc getKeypairs*(self: Controller): seq[wallet_account_service.KeypairDto] = return self.walletAccountService.getKeypairs() proc getKeypairByKeyUid*(self: Controller, keyUid: string): wallet_account_service.KeypairDto = - return self.walletAccountService.getKeypairByKeyUid(keyUid) \ No newline at end of file + return self.walletAccountService.getKeypairByKeyUid(keyUid) + +proc remainingKeypairCapacity*(self: Controller): int = + return self.walletAccountService.remainingKeypairCapacity() + +proc remainingAccountCapacity*(self: Controller): int = + return self.walletAccountService.remainingAccountCapacity() \ No newline at end of file diff --git a/src/app/modules/main/profile_section/keycard/io_interface.nim b/src/app/modules/main/profile_section/keycard/io_interface.nim index 86235a20ff..834fcd46ac 100644 --- a/src/app/modules/main/profile_section/keycard/io_interface.nim +++ b/src/app/modules/main/profile_section/keycard/io_interface.nim @@ -100,6 +100,12 @@ method onKeycardUidUpdated*(self: AccessInterface, keycardUid: string, keycardNe method prepareKeycardDetailsModel*(self: AccessInterface, keyUid: string) {.base.} = raise newException(ValueError, "No implementation available") +method remainingKeypairCapacity*(self: AccessInterface): int {.base.} = + raise newException(ValueError, "No implementation available") + +method remainingAccountCapacity*(self: AccessInterface): int {.base.} = + raise newException(ValueError, "No implementation available") + # View Delegate Interface # Delegate for the view must be declared here due to use of QtObject and multi diff --git a/src/app/modules/main/profile_section/keycard/module.nim b/src/app/modules/main/profile_section/keycard/module.nim index c0de31b981..1fa7ceaf31 100644 --- a/src/app/modules/main/profile_section/keycard/module.nim +++ b/src/app/modules/main/profile_section/keycard/module.nim @@ -415,3 +415,9 @@ method prepareKeycardDetailsModel*(self: Module, keyUid: string) = continue items.add(item) self.view.createModelAndSetKeycardDetailsItems(items) + +method remainingKeypairCapacity*(self: Module): int = + return self.controller.remainingKeypairCapacity() + +method remainingAccountCapacity*(self: Module): int = + return self.controller.remainingAccountCapacity() \ No newline at end of file diff --git a/src/app/modules/main/profile_section/keycard/view.nim b/src/app/modules/main/profile_section/keycard/view.nim index c7e452aced..1ad696c111 100644 --- a/src/app/modules/main/profile_section/keycard/view.nim +++ b/src/app/modules/main/profile_section/keycard/view.nim @@ -131,3 +131,9 @@ QtObject: proc prepareKeycardDetailsModel*(self: View, keyUid: string) {.slot.} = self.delegate.prepareKeycardDetailsModel(keyUid) + + proc remainingKeypairCapacity*(self: View): int {.slot.} = + return self.delegate.remainingKeypairCapacity() + + proc remainingAccountCapacity*(self: View): int {.slot.} = + return self.delegate.remainingAccountCapacity() diff --git a/src/app/modules/shared_modules/keycard_popup/controller.nim b/src/app/modules/shared_modules/keycard_popup/controller.nim index 4c90c89c9c..b4d92a0a23 100644 --- a/src/app/modules/shared_modules/keycard_popup/controller.nim +++ b/src/app/modules/shared_modules/keycard_popup/controller.nim @@ -836,6 +836,9 @@ proc getTotalCurrencyBalance*(self: Controller, address: string, chainIds: seq[i proc parseCurrencyValueByTokensKey*(self: Controller, tokensKey: string, amountInt: UInt256): float64 = return self.walletAccountService.parseCurrencyValueByTokensKey(tokensKey, amountInt) +proc remainingAccountCapacity*(self: Controller): int = + return self.walletAccountService.remainingAccountCapacity() + # Keep this function at the end of the file. # There's a bug in Nim: https://github.com/nim-lang/Nim/issues/23002 # that blocks us from enabling back the warning pragma. diff --git a/src/app/modules/shared_modules/keycard_popup/io_interface.nim b/src/app/modules/shared_modules/keycard_popup/io_interface.nim index dfbff6b66c..a8299d3380 100644 --- a/src/app/modules/shared_modules/keycard_popup/io_interface.nim +++ b/src/app/modules/shared_modules/keycard_popup/io_interface.nim @@ -239,5 +239,8 @@ method getPin*(self: AccessInterface): string {.base.} = method onTokensRebuilt*(self: AccessInterface, accountAddresses: seq[string], accountTokens: seq[GroupedTokenItem]) {.base.} = raise newException(ValueError, "No implementation available") +method remainingAccountCapacity*(self: AccessInterface): int {.base.} = + raise newException(ValueError, "No implementation available") + type DelegateInterface* = concept c diff --git a/src/app/modules/shared_modules/keycard_popup/module.nim b/src/app/modules/shared_modules/keycard_popup/module.nim index f8098eb409..f8d0dac2ce 100644 --- a/src/app/modules/shared_modules/keycard_popup/module.nim +++ b/src/app/modules/shared_modules/keycard_popup/module.nim @@ -799,4 +799,7 @@ method keychainObtainedDataSuccess*[T](self: Module[T], data: string) = else: self.view.setCurrentState(newBiometricsPinInvalidState(self.runningFlow, nil)) +method remainingAccountCapacity*[T](self: Module[T]): int = + return self.controller.remainingAccountCapacity() + {.pop.} diff --git a/src/app/modules/shared_modules/keycard_popup/view.nim b/src/app/modules/shared_modules/keycard_popup/view.nim index 1aeb5cb8ca..60492d70fb 100644 --- a/src/app/modules/shared_modules/keycard_popup/view.nim +++ b/src/app/modules/shared_modules/keycard_popup/view.nim @@ -247,4 +247,7 @@ QtObject: return self.delegate.migratingProfileKeyPair() proc getSigningPhrase*(self: View): string {.slot.} = - return self.delegate.getSigningPhrase() \ No newline at end of file + return self.delegate.getSigningPhrase() + + proc remainingAccountCapacity*(self: View): int {.slot.} = + return self.delegate.remainingAccountCapacity() diff --git a/ui/app/AppLayouts/Profile/stores/KeycardStore.qml b/ui/app/AppLayouts/Profile/stores/KeycardStore.qml index ce83537580..3a2d855bb5 100644 --- a/ui/app/AppLayouts/Profile/stores/KeycardStore.qml +++ b/ui/app/AppLayouts/Profile/stores/KeycardStore.qml @@ -61,4 +61,12 @@ QtObject { function prepareKeycardDetailsModel(keyUid) { root.keycardModule.prepareKeycardDetailsModel(keyUid) } + + function remainingKeypairCapacity() { + return root.keycardModule.remainingKeypairCapacity() + } + + function remainingAccountCapacity() { + return root.keycardModule.remainingAccountCapacity() + } } diff --git a/ui/app/AppLayouts/Profile/views/keycard/MainView.qml b/ui/app/AppLayouts/Profile/views/keycard/MainView.qml index fb14e3f65f..8145148ab7 100644 --- a/ui/app/AppLayouts/Profile/views/keycard/MainView.qml +++ b/ui/app/AppLayouts/Profile/views/keycard/MainView.qml @@ -7,6 +7,7 @@ import StatusQ.Core.Theme 0.1 import StatusQ.Controls 0.1 import StatusQ.Components 0.1 import StatusQ.Popups 0.1 +import StatusQ.Popups.Dialog 0.1 import utils 1.0 import shared.panels 1.0 @@ -128,6 +129,14 @@ ColumnLayout { } ] onClicked: { + if (root.keycardStore.remainingKeypairCapacity() === 0) { + Global.openPopup(limitWarningComponent) + return + } + if (root.keycardStore.remainingAccountCapacity() === 0) { + Global.openPopup(limitWarningComponent, {accountsWarning: true}) + return + } root.keycardStore.runCreateNewKeycardWithNewSeedPhrasePopup() } } @@ -143,6 +152,14 @@ ColumnLayout { } ] onClicked: { + if (root.keycardStore.remainingKeypairCapacity() === 0) { + Global.openPopup(limitWarningComponent) + return + } + if (root.keycardStore.remainingAccountCapacity() === 0) { + Global.openPopup(limitWarningComponent, {accountsWarning: true}) + return + } root.keycardStore.runImportOrRestoreViaSeedPhrasePopup() } } @@ -158,6 +175,14 @@ ColumnLayout { } ] onClicked: { + if (root.keycardStore.remainingKeypairCapacity() === 0) { + Global.openPopup(limitWarningComponent) + return + } + if (root.keycardStore.remainingAccountCapacity() === 0) { + Global.openPopup(limitWarningComponent, {accountsWarning: true}) + return + } root.keycardStore.runImportFromKeycardToAppPopup() } } @@ -198,4 +223,25 @@ ColumnLayout { root.keycardStore.runFactoryResetPopup() } } + + Component { + id: limitWarningComponent + + StatusDialog { + id: dialog + + property bool accountsWarning: false + + title: dialog.accountsWarning? Constants.walletConstants.maxNumberOfAccountsTitle : Constants.walletConstants.maxNumberOfKeypairsTitle + + StatusBaseText { + anchors.fill: parent + font.pixelSize: Constants.keycard.general.fontSize2 + color: Theme.palette.directColor1 + text: dialog.accountsWarning? Constants.walletConstants.maxNumberOfAccountsContent : Constants.walletConstants.maxNumberOfKeypairsContent + } + + standardButtons: Dialog.Ok + } + } } diff --git a/ui/imports/shared/popups/keycard/KeycardPopup.qml b/ui/imports/shared/popups/keycard/KeycardPopup.qml index 3cc74744f1..7593e5d0af 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopup.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopup.qml @@ -2,7 +2,9 @@ import QtQuick 2.14 import QtQuick.Controls 2.14 import StatusQ.Core 0.1 +import StatusQ.Controls 0.1 import StatusQ.Popups 0.1 +import StatusQ.Popups.Dialog 0.1 import utils 1.0 @@ -69,6 +71,9 @@ StatusModal { onCancelBtnClicked: { root.close(); } + onAccountLimitWarning: { + limitPopup.active = true + } } onClosed: { @@ -105,6 +110,30 @@ StatusModal { sharedKeycardModule: root.sharedKeycardModule emojiPopup: root.emojiPopup onPrimaryButtonEnabledChanged: d.primaryButtonEnabled = primaryButtonEnabled + + Loader { + id: limitPopup + active: false + asynchronous: true + + sourceComponent: StatusDialog { + width: root.width - 2*Style.current.padding + + title: Constants.walletConstants.maxNumberOfAccountsTitle + + StatusBaseText { + anchors.fill: parent + text: Constants.walletConstants.maxNumberOfAccountsContent + wrapMode: Text.WordWrap + } + + standardButtons: Dialog.Ok + + onClosed: { + limitPopup.active = false + } + } + } } } diff --git a/ui/imports/shared/popups/keycard/KeycardPopupDetails.qml b/ui/imports/shared/popups/keycard/KeycardPopupDetails.qml index 7e628ad54f..ea78f3fd55 100644 --- a/ui/imports/shared/popups/keycard/KeycardPopupDetails.qml +++ b/ui/imports/shared/popups/keycard/KeycardPopupDetails.qml @@ -14,6 +14,7 @@ QtObject { property bool primaryButtonEnabled: false signal cancelBtnClicked() + signal accountLimitWarning() // disables action buttons (back, cancel, primary, secondary) and close button (upper right "X" button) as well readonly property bool disableActionPopupButtons: { @@ -620,6 +621,17 @@ QtObject { } onClicked: { + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardNewSeedPhrase || + root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardOldSeedPhrase) { + + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.manageKeycardAccounts && + !!root.sharedKeycardModule.keyPairForProcessing && + root.sharedKeycardModule.remainingAccountCapacity() === root.sharedKeycardModule.keyPairForProcessing.accounts.count) { + root.accountLimitWarning() + return + } + } + root.sharedKeycardModule.currentState.doSecondaryAction() } }, @@ -1259,6 +1271,9 @@ QtObject { case Constants.keycardSharedFlow.importFromKeycard: switch (root.sharedKeycardModule.currentState.stateType) { + case Constants.keycardSharedState.keycardMetadataDisplay: + return root.sharedKeycardModule.keyPairHelper.accounts.count <= root.sharedKeycardModule.remainingAccountCapacity() + case Constants.keycardSharedState.manageKeycardAccounts: return root.primaryButtonEnabled } @@ -1423,6 +1438,16 @@ QtObject { } onClicked: { + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardNewSeedPhrase || + root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardOldSeedPhrase) { + + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.manageKeycardAccounts && + !!root.sharedKeycardModule.keyPairForProcessing && + root.sharedKeycardModule.remainingAccountCapacity() - root.sharedKeycardModule.keyPairForProcessing.accounts.count < 0) { + root.accountLimitWarning() + return + } + } root.sharedKeycardModule.currentState.doPrimaryAction() } } diff --git a/ui/imports/shared/popups/keycard/states/KeycardInit.qml b/ui/imports/shared/popups/keycard/states/KeycardInit.qml index ef4ab7ba8b..8c239b2cd9 100644 --- a/ui/imports/shared/popups/keycard/states/KeycardInit.qml +++ b/ui/imports/shared/popups/keycard/states/KeycardInit.qml @@ -177,382 +177,379 @@ Item { Layout.fillWidth: true Layout.fillHeight: true } - } - Loader { - id: loader - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - anchors.leftMargin: Style.current.xlPadding - anchors.rightMargin: Style.current.xlPadding + Loader { + id: loader + Layout.preferredWidth: parent.width - 2*Style.current.xlPadding + Layout.alignment: Qt.AlignHCenter - active: { - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) { - if((root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader && !d.hideKeyPair) || - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard && !d.hideKeyPair) || - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted && !d.hideKeyPair) || - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard && !d.hideKeyPair) || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - return true + active: { + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) { + if((root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader && !d.hideKeyPair) || + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard && !d.hideKeyPair) || + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted && !d.hideKeyPair) || + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard && !d.hideKeyPair) || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + return true + } } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardNewSeedPhrase) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhrase || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseFailure) { - return true + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardNewSeedPhrase) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhrase || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseFailure) { + return true + } } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardOldSeedPhrase) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhrase || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseFailure || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { - return true + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardOldSeedPhrase) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhrase || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseFailure || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { + return true + } } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.importFromKeycard) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardFailure || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { - return true + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.importFromKeycard) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardFailure || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { + return true + } } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.factoryReset) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - return true + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.factoryReset) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + return true + } + if(!!root.sharedKeycardModule.keyPairForProcessing && + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard)) + return true } - if(!!root.sharedKeycardModule.keyPairForProcessing && - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard)) - return true - } - if (d.authenticationOrSigning && - !!root.sharedKeycardModule.keyPairForProcessing && - root.sharedKeycardModule.keyPairForProcessing.name !== "") { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsReadyToSign || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinFailed || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinInvalid || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) { - return true + if (d.authenticationOrSigning && + !!root.sharedKeycardModule.keyPairForProcessing && + root.sharedKeycardModule.keyPairForProcessing.name !== "") { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsReadyToSign || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinFailed || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinInvalid || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) { + return true + } } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - return true + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + return true + } } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard && !d.hideKeyPair) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameFailure) - return true - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPin && !d.hideKeyPair) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) - return true - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPuk && !d.hideKeyPair) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) - return true - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changePairingCode && !d.hideKeyPair) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) - return true - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.createCopyOfAKeycard && !d.hideKeyPair) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.removeKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyToKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardFailure || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardSuccess) - return true - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromKeycardToApp) { - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToApp || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToApp || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { - return true + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard && !d.hideKeyPair) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameFailure) + return true } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromAppToKeycard) { - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { - return true + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPin && !d.hideKeyPair) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) + return true } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPuk && !d.hideKeyPair) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) + return true + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changePairingCode && !d.hideKeyPair) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) + return true + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.createCopyOfAKeycard && !d.hideKeyPair) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.removeKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyToKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardFailure || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardSuccess) + return true + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromKeycardToApp) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToApp || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToApp || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { + return true + } + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromAppToKeycard) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { + return true + } + } + + return false } - return false - } - - sourceComponent: { - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) { - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + sourceComponent: { + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycard) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return keyPairForProcessingComponent + } + return unknownKeyPairCompontnt + } + if ((root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader && !d.hideKeyPair) || + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard && !d.hideKeyPair) || + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted && !d.hideKeyPair) || + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard && !d.hideKeyPair) || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { return keyPairForProcessingComponent } - return unknownKeyPairCompontnt } - if ((root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader && !d.hideKeyPair) || - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard && !d.hideKeyPair) || - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted && !d.hideKeyPair) || - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard && !d.hideKeyPair) || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { - return keyPairForProcessingComponent - } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardNewSeedPhrase) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardNewSeedPhrase) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return keyPairForProcessingComponent + } + return unknownKeyPairCompontnt + } + + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhrase || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseFailure) { + return keyPairForProcessingComponent + } + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardOldSeedPhrase) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return keyPairForProcessingComponent + } + return unknownKeyPairCompontnt + } + + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhrase || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseFailure || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { + return keyPairForProcessingComponent + } + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.importFromKeycard) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return keyPairForProcessingComponent + } + return unknownKeyPairCompontnt + } + + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardFailure || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { + return keyPairForProcessingComponent + } + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.factoryReset) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return keyPairForProcessingComponent + } + return unknownKeyPairCompontnt + } + if(!!root.sharedKeycardModule.keyPairForProcessing && + (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard)) + return keyPairForProcessingComponent + } + if (d.authenticationOrSigning) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsReadyToSign || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinFailed || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinInvalid || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) { + return keyPairForProcessingComponent + } + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return keyPairForProcessingComponent + } + return unknownKeyPairCompontnt + } + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameFailure) { + return keyPairForProcessingComponent + } + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) + return keyPairForProcessingComponent + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPin) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) + return keyPairForProcessingComponent + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPuk) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) + return keyPairForProcessingComponent + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changePairingCode) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) + return keyPairForProcessingComponent + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.createCopyOfAKeycard) { + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.removeKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyToKeycard) { + if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { + return keyPairForProcessingComponent + } + return unknownKeyPairCompontnt + } + if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardFailure || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardSuccess) + return keyPairForProcessingComponent + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromKeycardToApp) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToApp || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToApp || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { + return keyPairForProcessingComponent + } + } + if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromAppToKeycard) { + if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || + root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { return keyPairForProcessingComponent } - return unknownKeyPairCompontnt } - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhrase || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountNewSeedPhraseFailure) { - return keyPairForProcessingComponent - } + return undefined } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.setupNewKeycardOldSeedPhrase) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { - return keyPairForProcessingComponent - } - return unknownKeyPairCompontnt - } - - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhrase || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.creatingAccountOldSeedPhraseFailure || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { - return keyPairForProcessingComponent - } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.importFromKeycard) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { - return keyPairForProcessingComponent - } - return unknownKeyPairCompontnt - } - - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.importingFromKeycardFailure || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.seedPhraseAlreadyInUse) { - return keyPairForProcessingComponent - } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.factoryReset) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { - return keyPairForProcessingComponent - } - return unknownKeyPairCompontnt - } - if(!!root.sharedKeycardModule.keyPairForProcessing && - (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard)) - return keyPairForProcessingComponent - } - if (d.authenticationOrSigning) { - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardEmpty || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsReadyToSign || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinFailed || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinInvalid || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) { - return keyPairForProcessingComponent - } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay) { - if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { - return keyPairForProcessingComponent - } - return unknownKeyPairCompontnt - } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.renameKeycard) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardRenameFailure) { - return keyPairForProcessingComponent - } - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) - return keyPairForProcessingComponent - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPin) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) - return keyPairForProcessingComponent - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changeKeycardPuk) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) - return keyPairForProcessingComponent - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.changePairingCode) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) - return keyPairForProcessingComponent - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.createCopyOfAKeycard) { - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardMetadataDisplay || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.removeKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyToKeycard) { - if (root.sharedKeycardModule.keyPairStoredOnKeycardIsKnown) { - return keyPairForProcessingComponent - } - return unknownKeyPairCompontnt - } - if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardFailure || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.copyingKeycardSuccess) - return keyPairForProcessingComponent - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromKeycardToApp) { - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToApp || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToApp || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { - return keyPairForProcessingComponent - } - } - if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.migrateFromAppToKeycard) { - if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migrateKeypairToKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.pluginReader || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.recognizedKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPinRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPukRetriesReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.maxPairingSlotsReached || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.migratingKeypairToKeycard || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateSuccess || - root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keyPairMigrateFailure) { - return keyPairForProcessingComponent - } - } - - return undefined } } @@ -1232,7 +1229,12 @@ Item { } PropertyChanges { target: message - text: "" + text: root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.importFromKeycard && + root.sharedKeycardModule.keyPairHelper.accounts.count > root.sharedKeycardModule.remainingAccountCapacity()? + qsTr("Adding these accounts will exceed the limit of 20.\nRemove some already added accounts to be able to import a new ones.") + : "" + font.pixelSize: Constants.keycard.general.fontSize2 + color: Theme.palette.dangerColor1 } }, State {