2022-03-07 10:33:38 +01:00
|
|
|
|
import QtQuick 2.13
|
2023-07-18 11:10:48 +02:00
|
|
|
|
import QtQuick.Layouts 1.13
|
2022-07-28 22:56:44 +02:00
|
|
|
|
|
2022-03-07 10:33:38 +01:00
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
import StatusQ.Components 0.1
|
2023-07-18 11:10:48 +02:00
|
|
|
|
import StatusQ.Core 0.1
|
2022-03-07 10:33:38 +01:00
|
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-07-18 11:10:48 +02:00
|
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
|
|
|
|
|
|
|
|
|
import AppLayouts.Wallet 1.0
|
2022-07-28 22:56:44 +02:00
|
|
|
|
|
|
|
|
|
import shared.popups 1.0
|
2023-07-18 11:10:48 +02:00
|
|
|
|
import shared.panels 1.0
|
|
|
|
|
import utils 1.0
|
2022-03-07 10:33:38 +01:00
|
|
|
|
|
2022-03-10 18:01:17 +01:00
|
|
|
|
import "../../popups"
|
2023-07-18 11:10:48 +02:00
|
|
|
|
import "../../controls"
|
2022-03-07 10:33:38 +01:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
ColumnLayout {
|
2022-03-07 10:33:38 +01:00
|
|
|
|
id: root
|
2023-07-14 14:06:41 +02:00
|
|
|
|
|
2022-03-07 10:33:38 +01:00
|
|
|
|
signal goBack
|
|
|
|
|
|
2023-04-17 13:36:40 +02:00
|
|
|
|
property var account
|
2023-07-18 11:10:48 +02:00
|
|
|
|
property var keyPair
|
|
|
|
|
property var walletStore
|
|
|
|
|
property var emojiPopup
|
|
|
|
|
property string userProfilePublicKey
|
2022-03-07 10:33:38 +01:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
QtObject {
|
|
|
|
|
id: d
|
|
|
|
|
property bool watchOnlyAccount: keyPair && keyPair.pairType === Constants.keycard.keyPairType.watchOnly
|
|
|
|
|
property bool privateKeyAccount: keyPair && keyPair.pairType === Constants.keycard.keyPairType.privateKeyImport
|
|
|
|
|
}
|
2022-03-07 10:33:38 +01:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
spacing: 0
|
2022-07-19 15:45:27 +02:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.preferredWidth: parent.width
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.fillWidth: true
|
2022-03-10 18:01:17 +01:00
|
|
|
|
spacing: Style.current.smallPadding
|
2023-07-18 11:10:48 +02:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
id: accountName
|
|
|
|
|
objectName: "walletAccountViewAccountName"
|
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
|
text: root.account ? root.account.name : ""
|
|
|
|
|
font.weight: Font.Bold
|
|
|
|
|
font.pixelSize: 28
|
|
|
|
|
color: root.account ? Utils.getColorForId(root.account.colorId) : Theme.palette.directColor1
|
|
|
|
|
}
|
|
|
|
|
StatusEmoji {
|
2022-03-07 10:33:38 +01:00
|
|
|
|
id: accountImage
|
2022-08-10 11:23:06 +02:00
|
|
|
|
objectName: "walletAccountViewAccountImage"
|
2023-07-18 11:10:48 +02:00
|
|
|
|
Layout.preferredWidth: 28
|
|
|
|
|
Layout.preferredHeight: 28
|
|
|
|
|
emojiId: StatusQUtils.Emoji.iconId(root.account && root.account.emoji ? root.account.emoji : "", StatusQUtils.Emoji.size.big) || ""
|
2022-03-10 18:01:17 +01:00
|
|
|
|
}
|
2023-07-18 11:10:48 +02:00
|
|
|
|
}
|
|
|
|
|
StatusButton {
|
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
objectName: "walletAccountViewEditAccountButton"
|
|
|
|
|
text: qsTr("Edit account")
|
|
|
|
|
icon.name: "edit_pencil"
|
|
|
|
|
onClicked: Global.openPopup(renameAccountModalComponent)
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-03 14:51:47 +02:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
StatusBaseText {
|
|
|
|
|
Layout.topMargin: Style.current.bigPadding
|
|
|
|
|
text: qsTr("Account details")
|
|
|
|
|
font.pixelSize: 15
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
}
|
2022-08-03 14:51:47 +02:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
Rectangle {
|
|
|
|
|
Layout.topMargin: Style.current.halfPadding
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: childrenRect.height
|
|
|
|
|
radius: Style.current.radius
|
|
|
|
|
border.width: 1
|
|
|
|
|
border.color: Theme.palette.directColor8
|
|
|
|
|
color: Theme.palette.transparent
|
2022-08-03 14:51:47 +02:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
ColumnLayout {
|
|
|
|
|
width: parent.width
|
|
|
|
|
spacing: 0
|
|
|
|
|
WalletAccountDetailsListItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Balance")
|
|
|
|
|
subTitle: root.account && root.account.balance ? LocaleUtils.currencyAmountToLocaleString(root.account.balance): ""
|
|
|
|
|
}
|
|
|
|
|
Separator {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
|
}
|
|
|
|
|
WalletAccountDetailsListItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Address")
|
|
|
|
|
subTitle: {
|
|
|
|
|
let address = root.account && root.account.address ? root.account.address: ""
|
|
|
|
|
d.watchOnlyAccount ? address : WalletUtils.colorizedChainPrefix(walletStore.getAllNetworksSupportedPrefix()) + address
|
2022-03-07 10:33:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-18 11:10:48 +02:00
|
|
|
|
Separator {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
|
}
|
|
|
|
|
StatusBaseText {
|
|
|
|
|
text: qsTr("Keypair")
|
|
|
|
|
Layout.leftMargin: 16
|
|
|
|
|
Layout.topMargin: 12
|
|
|
|
|
font.pixelSize: 13
|
|
|
|
|
color: Theme.palette.baseColor1
|
|
|
|
|
visible: !d.watchOnlyAccount
|
|
|
|
|
}
|
|
|
|
|
WalletAccountDetailsKeypairItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
keyPair: root.keyPair
|
|
|
|
|
visible: !d.watchOnlyAccount
|
|
|
|
|
}
|
|
|
|
|
Separator {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
|
visible: !d.watchOnlyAccount
|
|
|
|
|
}
|
|
|
|
|
WalletAccountDetailsListItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Origin")
|
|
|
|
|
subTitle: {
|
|
|
|
|
if(keyPair) {
|
|
|
|
|
switch(keyPair.pairType) {
|
|
|
|
|
case Constants.keycard.keyPairType.profile:
|
|
|
|
|
return qsTr("Derived from your default Status keypair")
|
|
|
|
|
case Constants.keycard.keyPairType.seedImport:
|
|
|
|
|
return qsTr("Imported from seed phrase")
|
|
|
|
|
case Constants.keycard.keyPairType.privateKeyImport:
|
|
|
|
|
return qsTr("Imported from private key")
|
|
|
|
|
case Constants.keycard.keyPairType.watchOnly:
|
|
|
|
|
return qsTr("Watched address")
|
|
|
|
|
default:
|
|
|
|
|
return ""
|
|
|
|
|
}
|
2022-03-07 10:33:38 +01:00
|
|
|
|
}
|
2023-07-18 11:10:48 +02:00
|
|
|
|
return ""
|
2022-03-07 10:33:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-18 11:10:48 +02:00
|
|
|
|
Separator {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
|
}
|
|
|
|
|
WalletAccountDetailsListItem {
|
|
|
|
|
id: derivationPath
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Derivation Path")
|
|
|
|
|
subTitle: root.account ? Utils.getPathForDisplay(root.account.path) : ""
|
|
|
|
|
visible: !!subTitle && !d.privateKeyAccount
|
|
|
|
|
}
|
|
|
|
|
Separator {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
|
visible: derivationPath.visible
|
|
|
|
|
}
|
|
|
|
|
WalletAccountDetailsListItem {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
title: qsTr("Stored")
|
|
|
|
|
subTitle: keyPair && keyPair.migratedToKeycard ? qsTr("On Keycard"): qsTr("On device")
|
2022-07-19 15:45:27 +02:00
|
|
|
|
}
|
2022-03-07 10:33:38 +01:00
|
|
|
|
}
|
2023-07-18 11:10:48 +02:00
|
|
|
|
}
|
2022-03-07 10:33:38 +01:00
|
|
|
|
|
2023-07-18 11:10:48 +02:00
|
|
|
|
Separator {
|
|
|
|
|
Layout.topMargin: 40
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
|
color: Theme.palette.baseColor2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
|
Layout.topMargin: 20
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
spacing: 8
|
|
|
|
|
StatusButton {
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
visible: !d.watchOnlyAccount && !d.privateKeyAccount
|
|
|
|
|
text: keyPair && keyPair.migratedToKeycard? qsTr("Stop using Keycard") : qsTr("Migrate to Keycard")
|
|
|
|
|
icon.name: "keycard"
|
|
|
|
|
onClicked: {
|
|
|
|
|
if (keyPair && keyPair.migratedToKeycard)
|
|
|
|
|
console.warn("TODO: stop using Keycard")
|
|
|
|
|
else
|
|
|
|
|
console.warn("TODO: move keys to a Keycard")
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-07 10:33:38 +01:00
|
|
|
|
StatusButton {
|
2023-07-18 11:10:48 +02:00
|
|
|
|
Layout.fillWidth: true
|
2022-07-20 10:18:27 +02:00
|
|
|
|
objectName: "deleteAccountButton"
|
2023-07-18 11:10:48 +02:00
|
|
|
|
visible: !!root.account && !root.account.isDefaultAccount
|
|
|
|
|
text: qsTr("Remove account")
|
|
|
|
|
icon.name: "delete"
|
2022-03-07 10:33:38 +01:00
|
|
|
|
type: StatusBaseButton.Type.Danger
|
2023-07-18 11:10:48 +02:00
|
|
|
|
onClicked: confirmationPopup.open()
|
2022-03-07 10:33:38 +01:00
|
|
|
|
|
|
|
|
|
ConfirmationDialog {
|
|
|
|
|
id: confirmationPopup
|
2022-07-20 10:18:27 +02:00
|
|
|
|
confirmButtonObjectName: "confirmDeleteAccountButton"
|
2023-05-23 14:46:16 +02:00
|
|
|
|
headerSettings.title: qsTr("Confirm %1 Removal").arg(root.account ? root.account.name : "")
|
2022-03-07 10:33:38 +01:00
|
|
|
|
confirmationText: qsTr("You will not be able to restore viewing access to this account in the future unless you enter this account’s address again.")
|
|
|
|
|
confirmButtonLabel: qsTr("Remove Account")
|
|
|
|
|
onConfirmButtonClicked: {
|
2023-05-04 16:34:00 +02:00
|
|
|
|
root.walletStore.deleteAccount(root.account.address);
|
2023-07-18 11:10:48 +02:00
|
|
|
|
confirmationPopup.close()
|
|
|
|
|
root.goBack()
|
2022-03-07 10:33:38 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-10 18:01:17 +01:00
|
|
|
|
Component {
|
|
|
|
|
id: renameAccountModalComponent
|
|
|
|
|
RenameAccontModal {
|
2023-04-17 13:36:40 +02:00
|
|
|
|
account: root.account
|
2022-03-10 18:01:17 +01:00
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
onClosed: destroy()
|
|
|
|
|
walletStore: root.walletStore
|
|
|
|
|
emojiPopup: root.emojiPopup
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|