From fadad5f4f6dfd2d4f11b0d00a5f969667d4bcf00 Mon Sep 17 00:00:00 2001 From: Sale Djenic Date: Wed, 23 Aug 2023 09:09:50 +0200 Subject: [PATCH] fix(@desktop/wallet): importing keypairs at the account level (navigating into an account page in Wallet settings) (point 8) Point 8 of #11968 --- .../keypair_import/io_interface.nim | 1 + .../shared_modules/keypair_import/module.nim | 4 +- .../AppLayouts/Profile/views/WalletView.qml | 3 ++ .../Profile/views/wallet/AccountView.qml | 45 +++++++++++++++++++ ui/imports/utils/Constants.qml | 9 ++-- 5 files changed, 57 insertions(+), 5 deletions(-) diff --git a/src/app/modules/shared_modules/keypair_import/io_interface.nim b/src/app/modules/shared_modules/keypair_import/io_interface.nim index 21920a02e9..77826f01e5 100644 --- a/src/app/modules/shared_modules/keypair_import/io_interface.nim +++ b/src/app/modules/shared_modules/keypair_import/io_interface.nim @@ -5,6 +5,7 @@ import app_service/service/wallet_account/dto/derived_address_dto type ImportKeypairModuleMode* {.pure.}= enum SelectKeypair = 1 + SelectImportMethod ImportViaSeedPhrase ImportViaPrivateKey ImportViaQr diff --git a/src/app/modules/shared_modules/keypair_import/module.nim b/src/app/modules/shared_modules/keypair_import/module.nim index 619756119c..52ccb9ce59 100644 --- a/src/app/modules/shared_modules/keypair_import/module.nim +++ b/src/app/modules/shared_modules/keypair_import/module.nim @@ -79,7 +79,9 @@ method load*[T](self: Module[T], keyUid: string, mode: ImportKeypairModuleMode) self.closeKeypairImportPopup() return self.view.setSelectedKeypairItem(keypairItem) - if mode == ImportKeypairModuleMode.ImportViaPrivateKey: + if mode == ImportKeypairModuleMode.SelectImportMethod: + self.view.setCurrentState(newSelectImportMethodState(nil)) + elif mode == ImportKeypairModuleMode.ImportViaPrivateKey: self.view.setCurrentState(newImportPrivateKeyState(nil)) elif mode == ImportKeypairModuleMode.ImportViaSeedPhrase: self.view.setCurrentState(newImportSeedPhraseState(nil)) diff --git a/ui/app/AppLayouts/Profile/views/WalletView.qml b/ui/app/AppLayouts/Profile/views/WalletView.qml index 37940fc122..db7e0df853 100644 --- a/ui/app/AppLayouts/Profile/views/WalletView.qml +++ b/ui/app/AppLayouts/Profile/views/WalletView.qml @@ -184,6 +184,9 @@ SettingsContentBase { removeKeypairPopup.accounts= keyPair.accounts removeKeypairPopup.active = true } + onRunImportMissingKeypairFlow: { + root.walletStore.runKeypairImportPopup(keyPair.keyUid, Constants.keypairImportPopup.mode.selectImportMethod) + } } DappPermissionsView { diff --git a/ui/app/AppLayouts/Profile/views/wallet/AccountView.qml b/ui/app/AppLayouts/Profile/views/wallet/AccountView.qml index b5bd7187ef..2b0bf2df2a 100644 --- a/ui/app/AppLayouts/Profile/views/wallet/AccountView.qml +++ b/ui/app/AppLayouts/Profile/views/wallet/AccountView.qml @@ -25,6 +25,7 @@ ColumnLayout { signal goBack signal runRenameKeypairFlow() signal runRemoveKeypairFlow() + signal runImportMissingKeypairFlow() property var account property var keyPair @@ -78,6 +79,50 @@ ColumnLayout { } } + Rectangle { + Layout.fillWidth: true + Layout.topMargin: Style.current.bigPadding + Layout.preferredHeight: childrenRect.height + visible: !!root.keyPair && root.keyPair.operability === Constants.keypair.operability.nonOperable + radius: Style.current.radius + border.width: 1 + border.color: Theme.palette.directColor8 + color: Theme.palette.transparent + + ColumnLayout { + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: Style.current.padding + anchors.rightMargin: Style.current.padding + spacing: Style.current.halfPadding + + StatusBaseText { + Layout.fillWidth: true + Layout.topMargin: Style.current.padding + text: qsTr("Import keypair to use this account") + color: Theme.palette.warningColor1 + } + + StatusBaseText { + Layout.fillWidth: true + wrapMode: Text.WordWrap + text: qsTr("This account was added to one of your synced devices. To use this account you will first need import the associated keypair to this device.") + } + + StatusButton { + Layout.alignment: Qt.AlignLeft + Layout.bottomMargin: Style.current.padding + text: qsTr("Import keypair") + type: StatusBaseButton.Type.Warning + icon.name: "download" + onClicked: { + root.runImportMissingKeypairFlow() + } + } + } + } + + StatusBaseText { Layout.topMargin: Style.current.bigPadding text: qsTr("Account details") diff --git a/ui/imports/utils/Constants.qml b/ui/imports/utils/Constants.qml index b3183e7f6e..d5153e402e 100644 --- a/ui/imports/utils/Constants.qml +++ b/ui/imports/utils/Constants.qml @@ -748,10 +748,11 @@ QtObject { readonly property QtObject mode: QtObject { readonly property int selectKeypair: 1 - readonly property int importViaSeedPhrase: 2 - readonly property int importViaPrivateKey: 3 - readonly property int importViaQr: 4 - readonly property int exportKeypairQr: 5 + readonly property int selectImportMethod: 2 + readonly property int importViaSeedPhrase: 3 + readonly property int importViaPrivateKey: 4 + readonly property int importViaQr: 5 + readonly property int exportKeypairQr: 6 } readonly property QtObject state: QtObject {