2024-08-12 10:41:27 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
2024-07-02 23:31:34 +00:00
|
|
|
import QtQml 2.15
|
2021-09-28 15:04:06 +00:00
|
|
|
|
2024-03-13 17:38:16 +00:00
|
|
|
import StatusQ 0.1
|
2022-07-19 13:17:35 +00:00
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
2022-08-03 12:51:47 +00:00
|
|
|
import StatusQ.Components 0.1
|
2022-07-19 13:17:35 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2023-04-26 15:53:49 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as StatusQUtils
|
2024-04-10 20:56:10 +00:00
|
|
|
import StatusQ.Popups 0.1
|
2022-07-19 13:17:35 +00:00
|
|
|
|
2024-03-13 17:38:16 +00:00
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
2024-10-24 08:41:28 +00:00
|
|
|
import shared.stores 1.0 as SharedStores
|
2024-05-22 08:13:39 +00:00
|
|
|
|
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
2024-10-03 18:15:24 +00:00
|
|
|
import AppLayouts.Wallet.services.dapps 1.0
|
2024-05-22 08:13:39 +00:00
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
import utils 1.0
|
2021-10-05 20:50:22 +00:00
|
|
|
|
|
|
|
import "../controls"
|
2020-05-28 13:49:28 +00:00
|
|
|
|
|
|
|
Item {
|
2022-07-19 13:17:35 +00:00
|
|
|
id: root
|
2021-10-05 20:50:22 +00:00
|
|
|
|
2024-10-24 08:41:28 +00:00
|
|
|
property SharedStores.NetworkConnectionStore networkConnectionStore
|
2024-05-22 08:13:39 +00:00
|
|
|
property WalletStores.RootStore walletStore
|
2020-06-03 19:59:18 +00:00
|
|
|
|
2024-10-24 08:41:28 +00:00
|
|
|
property var overview
|
|
|
|
|
2024-08-12 10:41:27 +00:00
|
|
|
property bool dappsEnabled
|
2024-09-25 17:15:13 +00:00
|
|
|
property int loginType // RootStore.loginType -> Constants.LoginType enum
|
2024-08-12 10:41:27 +00:00
|
|
|
|
2023-12-26 10:19:41 +00:00
|
|
|
property alias headerButton: headerButton
|
|
|
|
property alias networkFilter: networkFilter
|
|
|
|
|
|
|
|
signal buttonClicked()
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2022-09-13 16:17:54 +00:00
|
|
|
implicitHeight: 88
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2022-07-19 13:17:35 +00:00
|
|
|
GridLayout {
|
|
|
|
width: parent.width
|
|
|
|
columns: 2
|
2023-04-26 15:53:49 +00:00
|
|
|
rowSpacing: 0
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2022-07-19 13:17:35 +00:00
|
|
|
// account + balance
|
2022-09-13 16:17:54 +00:00
|
|
|
RowLayout {
|
2024-10-15 19:26:12 +00:00
|
|
|
spacing: Theme.halfPadding
|
2022-07-19 13:17:35 +00:00
|
|
|
StatusBaseText {
|
2023-12-26 15:27:53 +00:00
|
|
|
objectName: "walletHeaderTitle"
|
2022-09-13 16:17:54 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-04-26 15:53:49 +00:00
|
|
|
verticalAlignment: Text.AlignVCenter
|
2023-12-26 10:19:41 +00:00
|
|
|
color: {
|
|
|
|
if (root.walletStore.showSavedAddresses)
|
|
|
|
return Theme.palette.directColor1
|
|
|
|
|
|
|
|
return overview.isAllAccounts ? Theme.palette.directColor5 : Utils.getColorForId(overview.colorId)
|
|
|
|
}
|
2023-04-26 15:53:49 +00:00
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
lineHeight: 38
|
2022-07-19 13:17:35 +00:00
|
|
|
font.bold: true
|
2023-04-26 15:53:49 +00:00
|
|
|
font.pixelSize: 28
|
2023-12-26 10:19:41 +00:00
|
|
|
text: {
|
|
|
|
if (root.walletStore.showSavedAddresses)
|
|
|
|
return qsTr("Saved addresses")
|
|
|
|
|
2024-05-27 09:35:07 +00:00
|
|
|
return overview.isAllAccounts ? qsTr("All accounts") : overview.name
|
2023-12-26 10:19:41 +00:00
|
|
|
}
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|
2023-04-26 15:53:49 +00:00
|
|
|
StatusEmoji {
|
2022-09-13 16:17:54 +00:00
|
|
|
Layout.alignment: Qt.AlignVCenter
|
2023-04-26 15:53:49 +00:00
|
|
|
Layout.preferredWidth: 28
|
|
|
|
Layout.preferredHeight: 28
|
2023-12-26 10:19:41 +00:00
|
|
|
emojiId: !!root.overview && StatusQUtils.Emoji.iconId(root.overview.emoji ?? "", StatusQUtils.Emoji.size.big) || ""
|
|
|
|
visible: !root.walletStore.showSavedAddresses &&
|
|
|
|
!!root.overview && !root.overview.isAllAccounts
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 16
|
2022-07-19 13:17:35 +00:00
|
|
|
Layout.alignment: Qt.AlignTrailing
|
2023-04-26 15:53:49 +00:00
|
|
|
Layout.topMargin: 5
|
2024-07-02 23:31:34 +00:00
|
|
|
Row {
|
|
|
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
|
|
|
Layout.preferredHeight: 38
|
|
|
|
spacing: 8
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
id: reloadButton
|
|
|
|
size: StatusBaseButton.Size.Tiny
|
|
|
|
height: parent.height
|
|
|
|
width: height
|
|
|
|
borderColor: Theme.palette.directColor7
|
|
|
|
borderWidth: 1
|
|
|
|
|
|
|
|
normalColor: Theme.palette.transparent
|
|
|
|
hoverColor: Theme.palette.baseColor2
|
|
|
|
|
|
|
|
icon.name: "refresh"
|
2024-07-11 08:16:26 +00:00
|
|
|
icon.color: {
|
|
|
|
if (!interactive) {
|
|
|
|
return Theme.palette.baseColor1;
|
|
|
|
}
|
|
|
|
if (hovered) {
|
|
|
|
return Theme.palette.directColor1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Theme.palette.baseColor1;
|
|
|
|
}
|
2024-07-02 23:31:34 +00:00
|
|
|
asset.mirror: true
|
|
|
|
|
2024-10-24 08:41:28 +00:00
|
|
|
loading: root.walletStore.isAccountTokensReloading
|
2024-07-02 23:31:34 +00:00
|
|
|
interactive: !loading && !throttleTimer.running
|
2024-10-24 08:41:28 +00:00
|
|
|
readonly property string lastReloadTimeFormated: !!root.walletStore.lastReloadTimestamp ?
|
2024-07-02 23:31:34 +00:00
|
|
|
LocaleUtils.formatRelativeTimestamp(
|
2024-10-24 08:41:28 +00:00
|
|
|
root.walletStore.lastReloadTimestamp * 1000) : ""
|
2024-07-02 23:31:34 +00:00
|
|
|
tooltip.text: qsTr("Last refreshed %1").arg(lastReloadTimeFormated)
|
|
|
|
|
2024-10-24 08:41:28 +00:00
|
|
|
onClicked: root.walletStore.reloadAccountTokens()
|
2024-07-02 23:31:34 +00:00
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: throttleTimer
|
|
|
|
interval: 1000*60 //throttle for 1 min
|
|
|
|
running: true // Start the timer immediately to disable manual reload initially, as automatic refresh is performed upon entering the wallet.
|
|
|
|
}
|
|
|
|
|
|
|
|
onLastReloadTimeFormatedChanged: {
|
|
|
|
// Start the throttle timer whenever the tokens are reloaded,
|
|
|
|
// which can be triggered by either automatic or manual reload.
|
|
|
|
throttleTimer.restart()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-04-05 11:10:44 +00:00
|
|
|
|
2024-05-06 17:55:11 +00:00
|
|
|
DAppsWorkflow {
|
2024-10-03 18:15:24 +00:00
|
|
|
id: dappsWorkflow
|
2024-04-10 20:56:10 +00:00
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
2024-10-03 18:15:24 +00:00
|
|
|
readonly property WalletConnectService wcService: Global.walletConnectService
|
|
|
|
|
2024-04-10 20:56:10 +00:00
|
|
|
spacing: 8
|
2024-05-01 16:15:42 +00:00
|
|
|
|
2024-08-05 13:41:20 +00:00
|
|
|
visible: !root.walletStore.showSavedAddresses
|
2024-08-12 10:41:27 +00:00
|
|
|
&& root.dappsEnabled
|
2024-10-03 18:15:24 +00:00
|
|
|
&& wcService.serviceAvailableToCurrentAddress
|
2024-05-06 20:22:43 +00:00
|
|
|
enabled: !!Global.walletConnectService
|
|
|
|
|
2024-08-05 13:41:20 +00:00
|
|
|
|
2024-09-25 17:15:13 +00:00
|
|
|
loginType: root.loginType
|
2024-07-11 21:00:15 +00:00
|
|
|
selectedAccountAddress: root.walletStore.selectedAddress
|
2024-10-03 18:15:24 +00:00
|
|
|
model: wcService.dappsModel
|
|
|
|
accountsModel: wcService.validAccounts
|
|
|
|
networksModel: wcService.flatNetworks
|
|
|
|
sessionRequestsModel: wcService.sessionRequestsModel
|
|
|
|
|
|
|
|
formatBigNumber: (number, symbol, noSymbolOption) => wcService.walletRootStore.currencyStore.formatBigNumber(number, symbol, noSymbolOption)
|
|
|
|
|
|
|
|
onDisconnectRequested: (connectionId) => wcService.disconnectDapp(connectionId)
|
|
|
|
onPairingRequested: (uri) => wcService.pair(uri)
|
|
|
|
onPairingValidationRequested: (uri) => wcService.validatePairingUri(uri)
|
|
|
|
onConnectionAccepted: (pairingId, chainIds, selectedAccount) => wcService.approvePairSession(pairingId, chainIds, selectedAccount)
|
|
|
|
onConnectionDeclined: (pairingId) => wcService.rejectPairSession(pairingId)
|
|
|
|
onSignRequestAccepted: (connectionId, requestId) => wcService.sign(connectionId, requestId)
|
|
|
|
onSignRequestRejected: (connectionId, requestId) => wcService.rejectSign(connectionId, requestId, false /*hasError*/)
|
2024-10-30 21:37:42 +00:00
|
|
|
onSubscribeForFeeUpdates: (connectionId, requestId) => wcService.subscribeForFeeUpdates(connectionId, requestId)
|
2024-10-03 18:15:24 +00:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: dappsWorkflow.wcService
|
|
|
|
function onPairingValidated(validationState) {
|
|
|
|
dappsWorkflow.pairingValidated(validationState)
|
|
|
|
}
|
|
|
|
function onApproveSessionResult(pairingId, err, newConnectionId) {
|
|
|
|
if (err) {
|
|
|
|
dappsWorkflow.connectionFailed(pairingId)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
dappsWorkflow.connectionSuccessful(pairingId, newConnectionId)
|
|
|
|
}
|
|
|
|
function onConnectDApp(dappChains, dappUrl, dappName, dappIcon, pairingId) {
|
|
|
|
dappsWorkflow.connectDApp(dappChains, dappUrl, dappName, dappIcon, pairingId)
|
|
|
|
}
|
|
|
|
}
|
2024-04-10 20:56:10 +00:00
|
|
|
}
|
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
StatusButton {
|
2023-12-26 10:19:41 +00:00
|
|
|
id: headerButton
|
2023-12-26 15:27:53 +00:00
|
|
|
objectName: "walletHeaderButton"
|
2023-04-26 15:53:49 +00:00
|
|
|
Layout.preferredHeight: 38
|
|
|
|
Layout.alignment: Qt.AlignTop
|
2023-03-08 13:44:47 +00:00
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
spacing: 8
|
|
|
|
size: StatusBaseButton.Size.Small
|
2023-12-26 10:19:41 +00:00
|
|
|
borderColor: root.walletStore.showSavedAddresses? "transparent" : Theme.palette.directColor7
|
|
|
|
normalColor: root.walletStore.showSavedAddresses? Theme.palette.primaryColor3 : Theme.palette.transparent
|
|
|
|
hoverColor: root.walletStore.showSavedAddresses? Theme.palette.primaryColor2 : Theme.palette.baseColor2
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2023-12-26 10:19:41 +00:00
|
|
|
font.weight: root.walletStore.showSavedAddresses? Font.Medium : Font.Normal
|
2023-04-26 15:53:49 +00:00
|
|
|
textPosition: StatusBaseButton.TextPosition.Left
|
2023-12-26 10:19:41 +00:00
|
|
|
textColor: root.walletStore.showSavedAddresses? Theme.palette.primaryColor1 : Theme.palette.baseColor1
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2023-12-26 10:19:41 +00:00
|
|
|
icon.name: root.walletStore.showSavedAddresses? "" : "invite-users"
|
2023-04-26 15:53:49 +00:00
|
|
|
icon.height: 16
|
|
|
|
icon.width: 16
|
|
|
|
icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
2023-04-05 11:10:44 +00:00
|
|
|
}
|
2020-05-28 13:49:28 +00:00
|
|
|
|
2023-04-26 15:53:49 +00:00
|
|
|
// network filter
|
|
|
|
NetworkFilter {
|
|
|
|
id: networkFilter
|
|
|
|
|
|
|
|
Layout.alignment: Qt.AlignTop
|
|
|
|
|
2024-05-22 08:13:39 +00:00
|
|
|
flatNetworks: root.walletStore.filteredFlatModel
|
|
|
|
onToggleNetwork: root.walletStore.toggleNetwork(chainId)
|
2023-04-26 15:53:49 +00:00
|
|
|
|
2024-06-15 21:33:12 +00:00
|
|
|
Binding on selection {
|
|
|
|
value: chainIdsAggregator.value
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionAggregator {
|
|
|
|
id: chainIdsAggregator
|
|
|
|
|
|
|
|
readonly property SortFilterProxyModel enabledNetworksModel: SortFilterProxyModel{
|
|
|
|
sourceModel: walletStore.filteredFlatModel
|
|
|
|
filters: ValueFilter {
|
|
|
|
roleName: "isEnabled"
|
|
|
|
value: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
model: enabledNetworksModel
|
|
|
|
initialValue: []
|
|
|
|
roleName: "chainId"
|
|
|
|
|
|
|
|
aggregateFunction: (aggr, value) => [...aggr, value]
|
|
|
|
}
|
2023-04-26 15:53:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
spacing: 4
|
2023-12-26 10:19:41 +00:00
|
|
|
visible: !root.walletStore.showSavedAddresses &&
|
|
|
|
!!root.networkConnectionStore &&
|
|
|
|
!networkConnectionStore.accountBalanceNotAvailable
|
2023-04-26 15:53:49 +00:00
|
|
|
StatusTextWithLoadingState {
|
|
|
|
font.pixelSize: 28
|
|
|
|
font.bold: true
|
|
|
|
customColor: Theme.palette.directColor1
|
2023-12-26 10:19:41 +00:00
|
|
|
text: loading ?
|
|
|
|
Constants.dummyText :
|
|
|
|
!!root.overview?
|
|
|
|
LocaleUtils.currencyAmountToLocaleString(root.overview.currencyBalance) : ""
|
|
|
|
loading: !!root.overview && root.overview.balanceLoading
|
2023-04-26 15:53:49 +00:00
|
|
|
lineHeightMode: Text.FixedHeight
|
|
|
|
lineHeight: 38
|
|
|
|
}
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|
2022-02-15 13:19:45 +00:00
|
|
|
}
|
2022-07-19 13:17:35 +00:00
|
|
|
}
|