2024-10-15 19:26:12 +00:00
|
|
|
|
import QtQuick 2.15
|
2022-08-31 17:09:07 +00:00
|
|
|
|
|
2023-08-29 14:22:41 +00:00
|
|
|
|
import StatusQ.Core 0.1
|
2024-10-15 19:26:12 +00:00
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-08-29 14:22:41 +00:00
|
|
|
|
|
2022-08-31 17:09:07 +00:00
|
|
|
|
import utils 1.0
|
2023-03-22 15:48:44 +00:00
|
|
|
|
import shared.panels 1.0 as SharedPanels
|
2022-08-31 17:09:07 +00:00
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
property var sharedKeycardModule
|
|
|
|
|
|
|
|
|
|
signal validation(bool result)
|
|
|
|
|
|
|
|
|
|
QtObject {
|
|
|
|
|
id: d
|
|
|
|
|
|
|
|
|
|
property bool wrongSeedPhrase: root.sharedKeycardModule.keycardData & Constants.predefinedKeycardData.wrongSeedPhrase
|
|
|
|
|
onWrongSeedPhraseChanged: {
|
2023-03-22 15:48:44 +00:00
|
|
|
|
seedPhrase.setWrongSeedPhraseMessage(wrongSeedPhrase? qsTr("The phrase you’ve entered does not match this Keycard’s seed phrase") : "")
|
2022-08-31 17:09:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2023-08-29 14:22:41 +00:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: title
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
|
anchors.topMargin: Theme.padding
|
|
|
|
|
anchors.leftMargin: Theme.xlPadding
|
|
|
|
|
anchors.rightMargin: Theme.xlPadding
|
2023-08-29 14:22:41 +00:00
|
|
|
|
visible: text != ""
|
|
|
|
|
font.pixelSize: Constants.keycard.general.fontSize1
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
|
SharedPanels.EnterSeedPhrase {
|
|
|
|
|
id: seedPhrase
|
2023-08-29 14:22:41 +00:00
|
|
|
|
anchors.top: title.visible? title.bottom : parent.top
|
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
|
anchors.topMargin: Theme.xlPadding
|
|
|
|
|
anchors.bottomMargin: Theme.halfPadding
|
|
|
|
|
anchors.leftMargin: Theme.xlPadding
|
|
|
|
|
anchors.rightMargin: Theme.xlPadding
|
2022-08-31 17:09:07 +00:00
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
|
isSeedPhraseValid: function(mnemonic) {
|
|
|
|
|
return root.sharedKeycardModule.validSeedPhrase(mnemonic)
|
2022-08-31 17:09:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
|
onSeedPhraseUpdated: {
|
|
|
|
|
if (valid) {
|
|
|
|
|
root.sharedKeycardModule.setSeedPhrase(seedPhrase)
|
2022-08-31 17:09:07 +00:00
|
|
|
|
}
|
2023-03-22 15:48:44 +00:00
|
|
|
|
root.validation(valid)
|
2022-08-31 17:09:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-22 15:48:44 +00:00
|
|
|
|
onSubmitSeedPhrase: {
|
|
|
|
|
root.sharedKeycardModule.currentState.doPrimaryAction()
|
2022-08-31 17:09:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
states: [
|
|
|
|
|
State {
|
|
|
|
|
name: Constants.keycardSharedState.enterSeedPhrase
|
|
|
|
|
when: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterSeedPhrase
|
2023-08-29 14:22:41 +00:00
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: title
|
|
|
|
|
text: {
|
|
|
|
|
switch (root.sharedKeycardModule.currentState.flowType) {
|
|
|
|
|
case Constants.keycardSharedFlow.migrateFromKeycardToApp:
|
2024-06-07 13:29:09 +00:00
|
|
|
|
return qsTr("Enter seed phrase for %1 key pair").arg(root.sharedKeycardModule.keyPairForProcessing.name)
|
2023-08-29 14:22:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-31 17:09:07 +00:00
|
|
|
|
},
|
|
|
|
|
State {
|
|
|
|
|
name: Constants.keycardSharedState.wrongSeedPhrase
|
|
|
|
|
when: root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongSeedPhrase
|
2023-08-29 14:22:41 +00:00
|
|
|
|
PropertyChanges {
|
|
|
|
|
target: title
|
|
|
|
|
text: {
|
|
|
|
|
switch (root.sharedKeycardModule.currentState.flowType) {
|
|
|
|
|
case Constants.keycardSharedFlow.migrateFromKeycardToApp:
|
2024-06-07 13:29:09 +00:00
|
|
|
|
return qsTr("Enter seed phrase for %1 key pair").arg(root.sharedKeycardModule.keyPairForProcessing.name)
|
2023-08-29 14:22:41 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ""
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-31 17:09:07 +00:00
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|