Mark mnemonic as shown on revealing it to the user (#12947)

This commit is contained in:
Roman Volosovskyi 2023-12-06 16:24:10 +01:00 committed by GitHub
parent 7ee3b0bb57
commit b819bdb574
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 0 deletions

View File

@ -86,6 +86,9 @@ proc getMnemonic*(self: Controller): string =
proc removeMnemonic*(self: Controller) =
self.privacyService.removeMnemonic()
proc mnemonicWasShown*(self: Controller) =
self.settingsService.mnemonicWasShown()
proc getMnemonicWordAtIndex*(self: Controller, index: int): string =
return self.privacyService.getMnemonicWordAtIndex(index)

View File

@ -34,6 +34,9 @@ method getMnemonic*(self: AccessInterface): string {.base.} =
method removeMnemonic*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method mnemonicWasShown*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method getMnemonicWordAtIndex*(self: AccessInterface, index: int): string {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -75,6 +75,9 @@ method getMnemonic*(self: Module): string =
method removeMnemonic*(self: Module) =
self.controller.removeMnemonic()
method mnemonicWasShown*(self: Module) =
self.controller.mnemonicWasShown()
method getMnemonicWordAtIndex*(self: Module, index: int): string =
return self.controller.getMnemonicWordAtIndex(index)

View File

@ -41,6 +41,9 @@ QtObject:
proc removeMnemonic*(self: View) {.slot.} =
self.delegate.removeMnemonic()
proc mnemonicWasShown*(self: View) {.slot.} =
self.delegate.mnemonicWasShown()
proc getMnemonicWordAtIndex*(self: View, index: int): string {.slot.} =
return self.delegate.getMnemonicWordAtIndex(index)

View File

@ -102,6 +102,9 @@ QtObject:
data.success = false
error "error: ", procName="removeMnemonic", errDesription = "an error occurred removing mnemonic"
proc mnemonicWasShown*(self: Service) =
self.settingsService.mnemonicWasShown()
proc getMnemonicWordAtIndex*(self: Service, index: int): string =
let mnemonic = self.settingsService.getMnemonic()
if(mnemonic.len == 0):

View File

@ -1000,3 +1000,9 @@ QtObject:
proc getProfileMigrationNeeded*(self: Service): bool =
self.settings.profileMigrationNeeded
proc mnemonicWasShown*(self: Service) =
let response = status_settings.mnemonicWasShown()
if(not response.error.isNil):
error "error saving mnemonic was shown setting: ", errDescription = response.error.message
return

View File

@ -101,3 +101,6 @@ proc addOrReplaceSocialLinks*(value: JsonNode): RpcResponse[JsonNode] {.raises:
proc getSocialLinks*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_getSocialLinks")
proc mnemonicWasShown*(): RpcResponse[JsonNode] {.raises: [Exception].} =
return core.callPrivateRPC("settings_mnemonicWasShown")

View File

@ -130,6 +130,7 @@ StatusStackModal {
ConfirmSeedPhrasePanel {
id: confirmSeedPhrase
seedPhrase: root.privacyStore.getMnemonic().split(" ")
privacyStore: root.privacyStore
},
BackupSeedStepBase {
id: confirmFirstWord

View File

@ -14,6 +14,7 @@ BackupSeedStepBase {
property var seedPhrase: []
property bool hideSeed: true
property var privacyStore
titleText: qsTr("Write down your 12-word seed phrase to keep offline")
@ -68,6 +69,7 @@ BackupSeedStepBase {
icon.name: "view"
text: qsTr("Reveal seed phrase")
onClicked: {
privacyStore.mnemonicWasShown();
hideSeed = false;
}
}

View File

@ -40,4 +40,8 @@ QtObject {
function backupData() {
return root.privacyModule.backupData()
}
function mnemonicWasShown() {
root.privacyModule.mnemonicWasShown()
}
}