feat(@desktop/wallet): new add account modal - amends

Closes: #10020
This commit is contained in:
Sale Djenic 2023-03-24 15:03:47 +01:00 committed by saledjenic
parent c45154c066
commit 51058d9065
7 changed files with 79 additions and 28 deletions

View File

@ -77,7 +77,7 @@ method load*[T](self: Module[T]) =
self.view.setCurrentState(newMainState(nil))
var items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
excludeAlreadyMigratedPairs = false)
excludeAlreadyMigratedPairs = false, excludePrivateKeyKeypairs = true)
if items.len == 0:
error "list of identified keypairs is empty, but it must have at least a profile keypair"
return

View File

@ -11,7 +11,7 @@ logScope:
topics = "shared-keypairs"
proc buildKeyPairsList*(allWalletAccounts: seq[WalletAccountDto], allMigratedKeypairs: seq[KeyPairDto],
excludeAlreadyMigratedPairs: bool): seq[KeyPairItem] =
excludeAlreadyMigratedPairs: bool, excludePrivateKeyKeypairs: bool): seq[KeyPairItem] =
let keyPairMigrated = proc(keyUid: string): bool =
result = false
for kp in allMigratedKeypairs:
@ -63,7 +63,7 @@ proc buildKeyPairsList*(allWalletAccounts: seq[WalletAccountDto], allMigratedKey
item.addAccount(newKeyPairAccountItem(ga.name, ga.path, ga.address, ga.publicKey, ga.emoji, ga.color, icon = "", balance = 0.0))
items.add(item)
continue
if a.walletType == WalletTypeKey and not containsItemWithKeyUid(items, a.keyUid):
if a.walletType == WalletTypeKey and not excludePrivateKeyKeypairs and not containsItemWithKeyUid(items, a.keyUid):
var item = newKeyPairItem(keyUid = a.keyUid,
pubKey = a.publicKey,
locked = false,

View File

@ -393,7 +393,7 @@ method onKeycardResponse*[T](self: Module[T], keycardFlowType: string, keycardEv
proc prepareKeyPairItemForAuthentication[T](self: Module[T], keyUid: string) =
var item = newKeyPairItem()
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
excludeAlreadyMigratedPairs = false)
excludeAlreadyMigratedPairs = false, excludePrivateKeyKeypairs = false)
for it in items:
if it.getKeyUid() == keyUid:
item = it
@ -415,7 +415,7 @@ method setKeyPairForProcessing*[T](self: Module[T], item: KeyPairItem) =
method prepareKeyPairForProcessing*[T](self: Module[T], keyUid: string, keycardUid = "") =
var item = newKeyPairItem()
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
excludeAlreadyMigratedPairs = false)
excludeAlreadyMigratedPairs = false, excludePrivateKeyKeypairs = false)
for it in items:
if it.getKeyUid() == keyUid:
item = it
@ -446,7 +446,7 @@ method runFlow*[T](self: Module[T], flowToRun: FlowType, keyUid = "", bip44Path
return
if flowToRun == FlowType.SetupNewKeycard:
let items = keypairs.buildKeyPairsList(self.controller.getWalletAccounts(), self.controller.getAllMigratedKeyPairs(),
excludeAlreadyMigratedPairs = true)
excludeAlreadyMigratedPairs = true, excludePrivateKeyKeypairs = false)
self.view.createKeyPairModel(items)
self.view.setCurrentState(newSelectExistingKeyPairState(flowToRun, nil))
self.controller.readyToDisplayPopup()

View File

@ -0,0 +1,37 @@
import QtQuick 2.14
import QtQuick.Controls 2.14
import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1
import StatusQ.Controls 0.1
import utils 1.0
Column {
id: root
property var addressDetailsItem
property bool addressResolved: true
spacing: Style.current.halfPadding
StatusBaseText {
text: qsTr("Public address of private key")
font.pixelSize: Constants.addAccountPopup.labelFontSize1
}
StatusInput {
width: parent.width
input.edit.enabled: false
text: root.addressDetailsItem.address
input.background.color: "transparent"
input.background.border.color: Theme.palette.baseColor2
}
AddressDetails {
width: parent.width
addressDetailsItem: root.addressDetailsItem
defaultMessage: ""
defaultMessageCondition: !root.addressResolved
}
}

View File

@ -104,31 +104,34 @@ Item {
}
}
Column {
StatusInput {
width: privKeyInput.width
maximumHeight: Constants.addAccountPopup.importPrivateKeyWarningHeight
minimumHeight: Constants.addAccountPopup.importPrivateKeyWarningHeight
visible: !d.addressResolved
multiline: true
leftPadding: Style.current.padding
font.pixelSize: Constants.addAccountPopup.labelFontSize2
text: qsTr("New addresses cannot be derived from an account imported from a private key. Import using a seed phrase if you wish to derive addresses.")
input.edit.enabled: false
input.enabled: false
input.background.color: "transparent"
input.background.border.color: Theme.palette.baseColor2
input.leftComponent: StatusIcon {
icon: "info"
height: 20
width: 20
color: Theme.palette.baseColor1
}
}
AddressWithAddressDetails {
width: parent.width
spacing: Style.current.halfPadding
visible: d.addressResolved
StatusBaseText {
text: qsTr("Public address of private key")
font.pixelSize: Constants.addAccountPopup.labelFontSize1
}
StatusInput {
width: parent.width
input.edit.enabled: false
text: root.store.privateKeyAccAddress.address
input.enabled: false
input.background.color: "transparent"
input.background.border.color: Theme.palette.baseColor2
}
AddressDetails {
width: parent.width
addressDetailsItem: root.store.privateKeyAccAddress
defaultMessage: ""
defaultMessageCondition: !d.addressResolved
}
addressDetailsItem: root.store.privateKeyAccAddress
addressResolved: d.addressResolved
}
StatusModalDivider {

View File

@ -171,10 +171,20 @@ Item {
store: root.store
}
AddressWithAddressDetails {
id: addressWithDetails
Layout.fillWidth: true
Layout.margins: Style.current.padding
spacing: Style.current.halfPadding
visible: root.store.selectedOrigin.pairType === Constants.addAccountPopup.keyPairType.privateKeyImport
addressDetailsItem: root.store.privateKeyAccAddress
}
Loader {
Layout.preferredHeight: Style.current.padding
Layout.fillWidth: true
visible: derivationPathSection.visible
visible: derivationPathSection.visible || addressWithDetails.visible
sourceComponent: spacer
}
}

View File

@ -613,6 +613,7 @@ QtObject {
readonly property int contentHeight1: 554
readonly property int contentHeight2: 642
readonly property int itemHeight: 64
readonly property int importPrivateKeyWarningHeight: 86
readonly property int labelFontSize1: 15
readonly property int labelFontSize2: 13
readonly property int footerButtonsHeight: 44