2023-10-24 11:21:20 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
2022-02-11 09:44:49 +00:00
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
2022-03-15 13:38:20 +00:00
|
|
|
import StatusQ.Controls 0.1
|
2023-07-11 15:10:26 +00:00
|
|
|
import StatusQ.Components 0.1
|
2023-07-18 09:10:48 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2022-02-11 09:44:49 +00:00
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
2023-08-04 12:41:57 +00:00
|
|
|
import shared.popups.keypairimport 1.0
|
2022-02-11 09:44:49 +00:00
|
|
|
import shared.status 1.0
|
|
|
|
|
|
|
|
import "../controls"
|
|
|
|
import "../popups"
|
|
|
|
import "../panels"
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
|
|
import AppLayouts.Profile.views.wallet 1.0
|
2023-10-26 21:11:20 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0
|
2022-02-11 09:44:49 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsContentBase {
|
2022-02-11 09:44:49 +00:00
|
|
|
id: root
|
|
|
|
|
2022-03-10 17:01:17 +00:00
|
|
|
property var emojiPopup
|
2022-09-13 16:17:54 +00:00
|
|
|
property var rootStore
|
|
|
|
property var walletStore
|
2023-10-26 21:11:20 +00:00
|
|
|
required property TokensStore tokensStore
|
2022-02-11 09:44:49 +00:00
|
|
|
|
2022-03-15 13:38:20 +00:00
|
|
|
readonly property int mainViewIndex: 0;
|
|
|
|
readonly property int networksViewIndex: 1;
|
2023-07-11 15:10:26 +00:00
|
|
|
readonly property int editNetworksViewIndex: 2;
|
|
|
|
readonly property int accountOrderViewIndex: 3;
|
|
|
|
readonly property int accountViewIndex: 4;
|
2023-10-24 11:21:20 +00:00
|
|
|
readonly property int manageTokensViewIndex: 5
|
2023-06-27 07:13:55 +00:00
|
|
|
|
2023-10-24 11:21:20 +00:00
|
|
|
readonly property string walletSectionTitle: qsTr("Wallet")
|
|
|
|
readonly property string networksSectionTitle: qsTr("Networks")
|
2022-02-11 09:44:49 +00:00
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
function resetStack() {
|
2023-07-11 15:10:26 +00:00
|
|
|
if(stackContainer.currentIndex === root.editNetworksViewIndex) {
|
|
|
|
stackContainer.currentIndex = root.networksViewIndex
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
stackContainer.currentIndex = mainViewIndex;
|
|
|
|
}
|
2022-03-15 13:38:20 +00:00
|
|
|
}
|
2022-02-11 09:44:49 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
StackLayout {
|
|
|
|
id: stackContainer
|
2022-03-02 12:54:58 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
width: root.contentWidth
|
2023-07-14 12:06:41 +00:00
|
|
|
height: stackContainer.currentIndex === root.mainViewIndex ? main.height:
|
|
|
|
stackContainer.currentIndex === root.networksViewIndex ? networksView.height:
|
|
|
|
stackContainer.currentIndex === root.editNetworksViewIndex ? editNetwork.height:
|
|
|
|
stackContainer.currentIndex === root.accountOrderViewIndex ? accountOrderView.height: accountView.height
|
2022-05-07 11:45:15 +00:00
|
|
|
currentIndex: mainViewIndex
|
2022-03-07 09:33:38 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
onCurrentIndexChanged: {
|
2022-09-13 16:17:54 +00:00
|
|
|
root.rootStore.backButtonName = ""
|
2023-10-24 11:21:20 +00:00
|
|
|
root.sectionTitle = root.walletSectionTitle
|
2022-05-07 11:45:15 +00:00
|
|
|
root.titleRowComponentLoader.sourceComponent = undefined
|
2023-07-11 15:10:26 +00:00
|
|
|
root.titleRowLeftComponentLoader.sourceComponent = undefined
|
|
|
|
root.titleRowLeftComponentLoader.visible = false
|
|
|
|
root.titleLayout.spacing = 5
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2023-06-27 07:13:55 +00:00
|
|
|
if (currentIndex == root.mainViewIndex) {
|
|
|
|
root.titleRowComponentLoader.sourceComponent = addNewAccountButtonComponent
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
if(currentIndex == root.networksViewIndex) {
|
2023-10-24 11:21:20 +00:00
|
|
|
root.rootStore.backButtonName = root.walletSectionTitle
|
|
|
|
root.sectionTitle = root.networksSectionTitle
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
2023-07-11 15:10:26 +00:00
|
|
|
if(currentIndex == root.editNetworksViewIndex) {
|
2023-10-24 11:21:20 +00:00
|
|
|
root.rootStore.backButtonName = root.networksSectionTitle
|
|
|
|
root.sectionTitle = qsTr("Edit %1").arg(!!editNetwork.combinedNetwork.prod &&
|
|
|
|
!!editNetwork.combinedNetwork.prod.chainName ? editNetwork.combinedNetwork.prod.chainName: "")
|
2023-07-11 15:10:26 +00:00
|
|
|
root.titleRowLeftComponentLoader.visible = true
|
|
|
|
root.titleRowLeftComponentLoader.sourceComponent = networkIcon
|
|
|
|
root.titleLayout.spacing = 12
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
|
|
} else if(currentIndex == root.accountViewIndex) {
|
|
|
|
root.rootStore.backButtonName = root.walletSectionTitle
|
2022-05-07 11:45:15 +00:00
|
|
|
root.sectionTitle = ""
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
|
|
} else if(currentIndex == root.accountOrderViewIndex) {
|
|
|
|
root.rootStore.backButtonName = root.walletSectionTitle
|
2023-06-20 11:59:15 +00:00
|
|
|
root.sectionTitle = qsTr("Edit account order")
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
|
|
} else if(currentIndex == root.manageTokensViewIndex) {
|
|
|
|
root.rootStore.backButtonName = root.walletSectionTitle
|
|
|
|
root.titleRowLeftComponentLoader.visible = false
|
|
|
|
root.sectionTitle = qsTr("Manage tokens")
|
2023-06-20 11:59:15 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-04 09:09:58 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
MainView {
|
|
|
|
id: main
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Layout.fillWidth: true
|
2023-07-14 12:06:41 +00:00
|
|
|
Layout.fillHeight: false
|
2022-03-15 13:38:20 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
walletStore: root.walletStore
|
2023-06-27 07:13:55 +00:00
|
|
|
emojiPopup: root.emojiPopup
|
2022-05-07 11:45:15 +00:00
|
|
|
|
|
|
|
onGoToNetworksView: {
|
|
|
|
stackContainer.currentIndex = networksViewIndex
|
2022-02-11 09:44:49 +00:00
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
onGoToAccountView: {
|
2023-07-18 09:10:48 +00:00
|
|
|
root.walletStore.selectedAccount = account
|
|
|
|
accountView.keyPair = keypair
|
2022-05-07 11:45:15 +00:00
|
|
|
stackContainer.currentIndex = accountViewIndex
|
2022-02-11 09:44:49 +00:00
|
|
|
}
|
2022-03-07 09:33:38 +00:00
|
|
|
|
2023-06-20 11:59:15 +00:00
|
|
|
onGoToAccountOrderView: {
|
|
|
|
stackContainer.currentIndex = accountOrderViewIndex
|
|
|
|
}
|
2023-07-28 07:57:58 +00:00
|
|
|
onRunRenameKeypairFlow: {
|
|
|
|
renameKeypairPopup.keyUid = model.keyPair.keyUid
|
|
|
|
renameKeypairPopup.name = model.keyPair.name
|
|
|
|
renameKeypairPopup.accounts = model.keyPair.accounts
|
|
|
|
renameKeypairPopup.active = true
|
|
|
|
}
|
|
|
|
onRunRemoveKeypairFlow: {
|
|
|
|
removeKeypairPopup.name = model.keyPair.name
|
2023-08-08 19:01:19 +00:00
|
|
|
removeKeypairPopup.keyUid = model.keyPair.keyUid
|
|
|
|
removeKeypairPopup.accounts= model.keyPair.accounts
|
2023-07-28 07:57:58 +00:00
|
|
|
removeKeypairPopup.active = true
|
|
|
|
}
|
2023-08-25 09:05:05 +00:00
|
|
|
onRunMoveKeypairToKeycardFlow: {
|
|
|
|
root.rootStore.keycardStore.runSetupKeycardPopup(model.keyPair.keyUid)
|
|
|
|
}
|
2023-08-29 14:22:41 +00:00
|
|
|
onRunStopUsingKeycardFlow: {
|
|
|
|
root.rootStore.keycardStore.runStopUsingKeycardPopup(model.keyPair.keyUid)
|
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
onGoToManageTokensView: {
|
|
|
|
stackContainer.currentIndex = manageTokensViewIndex
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
NetworksView {
|
2023-07-14 12:06:41 +00:00
|
|
|
id: networksView
|
2023-07-11 15:10:26 +00:00
|
|
|
Layout.fillWidth: true
|
2023-07-14 12:06:41 +00:00
|
|
|
Layout.fillHeight: false
|
2023-07-11 15:10:26 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
walletStore: root.walletStore
|
|
|
|
|
|
|
|
onGoBack: {
|
|
|
|
stackContainer.currentIndex = mainViewIndex
|
|
|
|
}
|
2023-07-11 15:10:26 +00:00
|
|
|
|
|
|
|
onEditNetwork: {
|
|
|
|
editNetwork.combinedNetwork = network
|
|
|
|
stackContainer.currentIndex = editNetworksViewIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EditNetworkView {
|
|
|
|
id: editNetwork
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
networksModule: root.walletStore.networksModule
|
2023-09-04 15:36:28 +00:00
|
|
|
onEvaluateRpcEndPoint: root.walletStore.evaluateRpcEndPoint(url, isMainUrl)
|
2023-08-07 18:47:16 +00:00
|
|
|
onUpdateNetworkValues: {
|
2023-10-06 12:33:33 +00:00
|
|
|
root.walletStore.updateNetworkEndPointValues(chainId, newMainRpcInput, newFailoverRpcUrl, revertToDefault)
|
2023-08-07 18:47:16 +00:00
|
|
|
stackContainer.currentIndex = networksViewIndex
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
2023-06-20 11:59:15 +00:00
|
|
|
AccountOrderView {
|
2023-07-14 12:06:41 +00:00
|
|
|
id: accountOrderView
|
2023-07-11 15:10:26 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
2023-06-20 11:59:15 +00:00
|
|
|
walletStore: root.walletStore
|
|
|
|
onGoBack: {
|
|
|
|
stackContainer.currentIndex = mainViewIndex
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
AccountView {
|
2023-04-17 11:36:40 +00:00
|
|
|
id: accountView
|
2023-07-18 09:10:48 +00:00
|
|
|
account: root.walletStore.selectedAccount
|
2022-05-07 11:45:15 +00:00
|
|
|
walletStore: root.walletStore
|
|
|
|
emojiPopup: root.emojiPopup
|
2023-07-18 09:10:48 +00:00
|
|
|
userProfilePublicKey: walletStore.userProfilePublicKey
|
|
|
|
onGoBack: stackContainer.currentIndex = mainViewIndex
|
|
|
|
onVisibleChanged: if(!visible) root.walletStore.selectedAccount = null
|
2023-07-28 07:57:58 +00:00
|
|
|
onRunRenameKeypairFlow: {
|
|
|
|
renameKeypairPopup.keyUid = keyPair.keyUid
|
|
|
|
renameKeypairPopup.name = keyPair.name
|
|
|
|
renameKeypairPopup.accounts = keyPair.accounts
|
|
|
|
renameKeypairPopup.active = true
|
|
|
|
}
|
|
|
|
onRunRemoveKeypairFlow: {
|
|
|
|
removeKeypairPopup.name = keyPair.name
|
2023-08-08 19:01:19 +00:00
|
|
|
removeKeypairPopup.keyUid = keyPair.keyUid
|
|
|
|
removeKeypairPopup.accounts= keyPair.accounts
|
2023-07-28 07:57:58 +00:00
|
|
|
removeKeypairPopup.active = true
|
|
|
|
}
|
2023-08-23 07:09:50 +00:00
|
|
|
onRunImportMissingKeypairFlow: {
|
|
|
|
root.walletStore.runKeypairImportPopup(keyPair.keyUid, Constants.keypairImportPopup.mode.selectImportMethod)
|
|
|
|
}
|
2023-08-25 09:05:05 +00:00
|
|
|
onRunMoveKeypairToKeycardFlow: {
|
|
|
|
root.rootStore.keycardStore.runSetupKeycardPopup(keyPair.keyUid)
|
|
|
|
}
|
2023-08-29 14:22:41 +00:00
|
|
|
onRunStopUsingKeycardFlow: {
|
|
|
|
root.rootStore.keycardStore.runStopUsingKeycardPopup(keyPair.keyUid)
|
|
|
|
}
|
2023-10-10 15:46:43 +00:00
|
|
|
onUpdateWatchAccountHiddenFromTotalBalance: {
|
|
|
|
root.walletStore.updateWatchAccountHiddenFromTotalBalance(address, hideFromTotalBalance)
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
2023-10-24 11:21:20 +00:00
|
|
|
ManageTokensView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
2023-10-25 10:40:10 +00:00
|
|
|
|
2023-10-26 21:11:20 +00:00
|
|
|
sourcesOfTokensModel: tokensStore.sourcesOfTokensModel
|
|
|
|
tokensListModel: tokensStore.extendedFlatTokensModel
|
2023-10-24 11:21:20 +00:00
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
DappPermissionsView {
|
|
|
|
walletStore: root.walletStore
|
|
|
|
}
|
2022-03-04 09:09:58 +00:00
|
|
|
|
2023-06-27 07:13:55 +00:00
|
|
|
Component {
|
|
|
|
id: addNewAccountButtonComponent
|
|
|
|
StatusButton {
|
2023-07-26 10:23:27 +00:00
|
|
|
objectName: "settings_Wallet_MainView_AddNewAccountButton"
|
2023-06-27 07:13:55 +00:00
|
|
|
text: qsTr("Add new account")
|
|
|
|
onClicked: root.walletStore.runAddAccountPopup()
|
|
|
|
}
|
|
|
|
}
|
2023-07-11 15:10:26 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: networkIcon
|
|
|
|
StatusRoundedImage {
|
|
|
|
width: 28
|
|
|
|
height: 28
|
|
|
|
image.source: Style.svg(!!editNetwork.combinedNetwork.prod && !!editNetwork.combinedNetwork.prod.iconUrl ? editNetwork.combinedNetwork.prod.iconUrl: "")
|
|
|
|
image.fillMode: Image.PreserveAspectCrop
|
|
|
|
}
|
|
|
|
}
|
2023-07-28 07:57:58 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: renameKeypairPopup
|
|
|
|
active: false
|
|
|
|
|
|
|
|
property string keyUid
|
|
|
|
property string name
|
|
|
|
property var accounts
|
|
|
|
|
|
|
|
sourceComponent: RenameKeypairPopup {
|
|
|
|
accountsModule: root.walletStore.accountsModule
|
|
|
|
keyUid: renameKeypairPopup.keyUid
|
|
|
|
name: renameKeypairPopup.name
|
|
|
|
accounts: renameKeypairPopup.accounts
|
|
|
|
|
|
|
|
onClosed: {
|
|
|
|
renameKeypairPopup.active = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoaded: {
|
|
|
|
renameKeypairPopup.item.open()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: removeKeypairPopup
|
|
|
|
active: false
|
|
|
|
|
|
|
|
property string name
|
2023-08-08 19:01:19 +00:00
|
|
|
property string keyUid
|
|
|
|
property var accounts
|
2023-07-28 07:57:58 +00:00
|
|
|
|
2023-08-08 19:01:19 +00:00
|
|
|
sourceComponent: RemoveKeypairPopup {
|
|
|
|
name: removeKeypairPopup.name
|
|
|
|
relatedAccounts: removeKeypairPopup.accounts
|
|
|
|
getNetworkShortNames: function(chainIds) {return root.walletStore.getNetworkShortNames(chainIds)}
|
|
|
|
onClosed: removeKeypairPopup.active = false
|
|
|
|
onConfirmClicked: {
|
2023-07-28 07:57:58 +00:00
|
|
|
root.walletStore.deleteKeypair(removeKeypairPopup.keyUid)
|
|
|
|
removeKeypairPopup.active = false
|
|
|
|
}
|
|
|
|
}
|
2023-08-08 19:01:19 +00:00
|
|
|
onLoaded: removeKeypairPopup.item.open()
|
2023-07-28 07:57:58 +00:00
|
|
|
}
|
2023-08-04 12:41:57 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: root.walletStore.walletModule
|
|
|
|
|
|
|
|
function onDisplayKeypairImportPopup() {
|
|
|
|
keypairImport.active = true
|
|
|
|
}
|
|
|
|
function onDestroyKeypairImportPopup() {
|
|
|
|
keypairImport.active = false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: keypairImport
|
|
|
|
active: false
|
|
|
|
asynchronous: true
|
|
|
|
|
|
|
|
sourceComponent: KeypairImportPopup {
|
|
|
|
store.keypairImportModule: root.walletStore.walletModule.keypairImportModule
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoaded: {
|
|
|
|
keypairImport.item.open()
|
|
|
|
}
|
|
|
|
}
|
2022-02-11 09:44:49 +00:00
|
|
|
}
|
2023-10-24 11:21:20 +00:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
root.titleRowComponentLoader.sourceComponent = addNewAccountButtonComponent
|
|
|
|
}
|
2022-04-13 10:10:51 +00:00
|
|
|
}
|