2024-05-06 17:55:11 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
import QtQml 2.15
|
|
|
|
import Qt.labs.settings 1.0
|
|
|
|
import QtTest 1.15
|
2024-06-04 20:45:03 +00:00
|
|
|
import QtQml.Models 2.14
|
2024-05-06 17:55:11 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
2024-07-12 09:46:43 +00:00
|
|
|
import StatusQ.Core.Backpressure 0.1
|
2024-05-06 17:55:11 +00:00
|
|
|
import StatusQ.Core.Utils 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Popups.Dialog 0.1
|
2024-05-06 20:22:43 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2024-05-06 17:55:11 +00:00
|
|
|
|
|
|
|
import Models 1.0
|
|
|
|
import Storybook 1.0
|
|
|
|
|
|
|
|
import AppLayouts.Wallet.controls 1.0
|
|
|
|
import AppLayouts.Wallet.services.dapps 1.0
|
2024-07-09 17:49:00 +00:00
|
|
|
import AppLayouts.Wallet.services.dapps.types 1.0
|
2024-05-06 17:55:11 +00:00
|
|
|
|
|
|
|
import SortFilterProxyModel 0.2
|
|
|
|
|
|
|
|
import AppLayouts.Wallet.panels 1.0
|
2024-05-06 20:22:43 +00:00
|
|
|
import AppLayouts.Profile.stores 1.0
|
2024-07-17 15:49:30 +00:00
|
|
|
import AppLayouts.Wallet.stores 1.0 as WalletStore
|
2024-05-06 17:55:11 +00:00
|
|
|
|
2024-07-01 11:34:30 +00:00
|
|
|
import mainui 1.0
|
2024-05-06 17:55:11 +00:00
|
|
|
import shared.stores 1.0
|
2024-07-01 11:34:30 +00:00
|
|
|
import utils 1.0
|
2024-05-06 17:55:11 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
|
2024-07-01 11:34:30 +00:00
|
|
|
// Needed for DAppsWorkflow->PairWCModal to open its instructions popup
|
|
|
|
Popups {
|
|
|
|
popupParent: root
|
|
|
|
rootStore: QtObject {}
|
|
|
|
communityTokensStore: QtObject {}
|
|
|
|
}
|
|
|
|
|
2024-05-06 17:55:11 +00:00
|
|
|
SplitView {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
SplitView.fillWidth: true
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.alignment: Qt.AlignCenter
|
|
|
|
Layout.preferredWidth: dappsWorkflow.implicitHeight + 20
|
|
|
|
Layout.preferredHeight: dappsWorkflow.implicitHeight + 20
|
|
|
|
|
|
|
|
border.color: "blue"
|
|
|
|
border.width: 1
|
|
|
|
|
|
|
|
DAppsWorkflow {
|
|
|
|
id: dappsWorkflow
|
|
|
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
|
|
|
spacing: 8
|
2024-05-06 20:22:43 +00:00
|
|
|
|
|
|
|
wcService: walletConnectService
|
2024-07-11 21:00:15 +00:00
|
|
|
loginType: Constants.LoginType.Biometrics
|
|
|
|
selectedAccountAddress: ""
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
ColumnLayout {}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: optionsSpace
|
|
|
|
|
|
|
|
RowLayout {
|
2024-05-31 09:58:47 +00:00
|
|
|
StatusBaseText { text: "projectId" }
|
|
|
|
StatusBaseText {
|
2024-05-06 17:55:11 +00:00
|
|
|
id: projectIdText
|
|
|
|
readonly property string projectId: SystemUtils.getEnvVar("WALLET_CONNECT_PROJECT_ID")
|
2024-05-06 20:22:43 +00:00
|
|
|
text: SQUtils.Utils.elideText(projectId, 3)
|
2024-05-06 17:55:11 +00:00
|
|
|
font.bold: true
|
|
|
|
}
|
|
|
|
}
|
2024-07-31 17:23:39 +00:00
|
|
|
RowLayout {
|
|
|
|
StatusBaseText { text: "SDK status:" }
|
|
|
|
Rectangle {
|
|
|
|
Layout.preferredWidth: 20
|
|
|
|
Layout.preferredHeight: Layout.preferredWidth
|
|
|
|
radius: Layout.preferredWidth / 2
|
|
|
|
color: walletConnectService.wcSDK.sdkReady ? "green" : "red"
|
|
|
|
}
|
|
|
|
}
|
2024-05-06 17:55:11 +00:00
|
|
|
|
2024-05-06 20:22:43 +00:00
|
|
|
CheckBox {
|
|
|
|
text: "Testnet Mode"
|
|
|
|
checked: settings.testNetworks
|
|
|
|
onCheckedChanged: {
|
|
|
|
settings.testNetworks = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-08 11:18:14 +00:00
|
|
|
StatusBaseText { text: "Custom Accounts" }
|
2024-05-31 09:58:47 +00:00
|
|
|
StatusTextArea {
|
|
|
|
text: settings.customAccounts
|
|
|
|
onTextChanged: {
|
|
|
|
settings.customAccounts = text
|
|
|
|
customAccountsModel.clear()
|
|
|
|
let customData = JSON.parse(text)
|
|
|
|
customData.forEach(function(account) {
|
|
|
|
customAccountsModel.append(account)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
Layout.fillWidth: true
|
2024-07-08 11:18:14 +00:00
|
|
|
Layout.maximumHeight: 300
|
|
|
|
clip: true
|
2024-05-31 09:58:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
color: "grey"
|
|
|
|
}
|
|
|
|
|
2024-06-24 21:26:53 +00:00
|
|
|
StatusBaseText { text: "Requests Queue" }
|
|
|
|
|
2024-05-31 09:58:47 +00:00
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
2024-06-24 21:26:53 +00:00
|
|
|
Layout.preferredHeight: Math.min(50, contentHeight)
|
2024-05-31 09:58:47 +00:00
|
|
|
model: walletConnectService.requestHandler.requestsModel
|
|
|
|
delegate: RowLayout {
|
|
|
|
StatusBaseText {
|
|
|
|
text: SQUtils.Utils.elideAndFormatWalletAddress(model.topic, 6, 4)
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-24 21:26:53 +00:00
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 1
|
|
|
|
color: "grey"
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusBaseText { text: "Persisted Sessions" }
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: Math.min(100, contentHeight)
|
|
|
|
model: sessionsModel
|
|
|
|
delegate: RowLayout {
|
|
|
|
StatusBaseText {
|
|
|
|
text: SQUtils.Utils.elideAndFormatWalletAddress(model.topic, 6, 4)
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Clear Persistance")
|
|
|
|
visible: sessionsModel.count > 0
|
|
|
|
onClicked: {
|
|
|
|
settings.persistedSessions = "[]"
|
|
|
|
d.updateSessionsModelAndAddNewIfNotNull(null)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-06 17:55:11 +00:00
|
|
|
// spacer
|
|
|
|
ColumnLayout {}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
CheckBox {
|
|
|
|
|
|
|
|
text: "Enable SDK"
|
|
|
|
checked: settings.enableSDK
|
|
|
|
onCheckedChanged: {
|
|
|
|
settings.enableSDK = checked
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-06 17:55:11 +00:00
|
|
|
RowLayout {
|
2024-05-31 09:58:47 +00:00
|
|
|
StatusBaseText { text: "URI" }
|
|
|
|
StatusInput {
|
2024-05-06 17:55:11 +00:00
|
|
|
id: pairUriInput
|
|
|
|
|
2024-05-31 09:58:47 +00:00
|
|
|
//placeholderText: "Enter WC Pair URI"
|
2024-05-06 17:55:11 +00:00
|
|
|
text: settings.pairUri
|
|
|
|
onTextChanged: {
|
|
|
|
settings.pairUri = text
|
|
|
|
}
|
|
|
|
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-21 10:42:50 +00:00
|
|
|
ComboBox {
|
|
|
|
model: [{testCase: d.noTestCase, name: "No Test Case"},
|
|
|
|
{testCase: d.openDappsTestCase, name: "Open dApps"},
|
|
|
|
{testCase: d.openPairTestCase, name: "Open Pair"}
|
|
|
|
]
|
|
|
|
textRole: "name"
|
|
|
|
valueRole: "testCase"
|
|
|
|
currentIndex: settings.testCase
|
|
|
|
onCurrentValueChanged: {
|
|
|
|
settings.testCase = currentValue
|
|
|
|
if (currentValue !== d.noTestCase) {
|
|
|
|
d.startTestCase()
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-06 20:22:43 +00:00
|
|
|
|
2024-05-06 17:55:11 +00:00
|
|
|
Connections {
|
|
|
|
target: dappsWorkflow
|
|
|
|
|
2024-05-06 20:22:43 +00:00
|
|
|
// If Open Pair workflow if selected in the side bar
|
2024-05-21 10:42:50 +00:00
|
|
|
function onDappsListReady() {
|
|
|
|
if (d.activeTestCase < d.openPairTestCase)
|
2024-05-06 17:55:11 +00:00
|
|
|
return
|
|
|
|
|
2024-07-05 09:32:31 +00:00
|
|
|
let buttons = InspectionUtils.findVisualsByTypeName(dappsWorkflow.popup, "StatusButton")
|
|
|
|
if (buttons.length === 1) {
|
|
|
|
buttons[0].clicked()
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-06 20:22:43 +00:00
|
|
|
function onPairWCReady() {
|
2024-05-21 10:42:50 +00:00
|
|
|
if (d.activeTestCase < d.openPairTestCase)
|
2024-05-06 17:55:11 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
if (pairUriInput.text.length > 0) {
|
|
|
|
let items = InspectionUtils.findVisualsByTypeName(dappsWorkflow, "StatusBaseInput")
|
|
|
|
if (items.length === 1) {
|
|
|
|
items[0].text = pairUriInput.text
|
2024-05-06 20:22:43 +00:00
|
|
|
|
|
|
|
clickDoneIfSDKReady()
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-06 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function clickDoneIfSDKReady() {
|
2024-05-21 10:42:50 +00:00
|
|
|
if (d.activeTestCase < d.openPairTestCase) {
|
2024-05-06 20:22:43 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
let modals = InspectionUtils.findVisualsByTypeName(dappsWorkflow, "PairWCModal")
|
|
|
|
if (modals.length === 1) {
|
|
|
|
let buttons = InspectionUtils.findVisualsByTypeName(modals[0].footer, "StatusButton")
|
2024-07-05 09:32:31 +00:00
|
|
|
if (buttons.length === 1 && buttons[0].enabled && walletConnectService.wcSDK.sdkReady) {
|
2024-05-21 10:42:50 +00:00
|
|
|
d.activeTestCase = d.noTestCase
|
2024-05-06 20:22:43 +00:00
|
|
|
buttons[0].clicked()
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Backpressure.debounce(dappsWorkflow, 250, clickDoneIfSDKReady)()
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-04 20:45:03 +00:00
|
|
|
StatusDialog {
|
|
|
|
id: authMockDialog
|
|
|
|
title: "Authenticate user"
|
|
|
|
visible: false
|
|
|
|
|
|
|
|
property string topic: ""
|
|
|
|
property string id: ""
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
RowLayout {
|
|
|
|
StatusBaseText { text: "Topic" }
|
|
|
|
StatusBaseText { text: authMockDialog.topic }
|
|
|
|
StatusBaseText { text: "ID" }
|
|
|
|
StatusBaseText { text: authMockDialog.id }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
footer: StatusDialogFooter {
|
|
|
|
rightButtons: ObjectModel {
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Reject")
|
|
|
|
onClicked: {
|
|
|
|
walletConnectService.store.userAuthenticationFailed(authMockDialog.topic, authMockDialog.id)
|
|
|
|
authMockDialog.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
StatusButton {
|
|
|
|
text: qsTr("Authenticate")
|
|
|
|
onClicked: {
|
2024-06-07 16:54:19 +00:00
|
|
|
walletConnectService.store.userAuthenticated(authMockDialog.topic, authMockDialog.id, "0x1234567890", "123")
|
2024-06-04 20:45:03 +00:00
|
|
|
authMockDialog.close()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-06 20:22:43 +00:00
|
|
|
WalletConnectService {
|
|
|
|
id: walletConnectService
|
|
|
|
|
|
|
|
wcSDK: WalletConnectSDK {
|
2024-07-31 17:23:39 +00:00
|
|
|
enableSdk: settings.enableSDK
|
2024-05-06 17:55:11 +00:00
|
|
|
|
|
|
|
projectId: projectIdText.projectId
|
2024-05-06 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2024-05-20 18:42:31 +00:00
|
|
|
store: DAppsStore {
|
2024-05-21 10:42:50 +00:00
|
|
|
signal dappsListReceived(string dappsJson)
|
2024-06-07 16:54:19 +00:00
|
|
|
signal userAuthenticated(string topic, string id, string password, string pin)
|
2024-06-04 20:45:03 +00:00
|
|
|
signal userAuthenticationFailed(string topic, string id)
|
2024-05-21 10:42:50 +00:00
|
|
|
|
2024-05-20 18:42:31 +00:00
|
|
|
function addWalletConnectSession(sessionJson) {
|
|
|
|
console.info("Persist Session", sessionJson)
|
2024-05-21 10:42:50 +00:00
|
|
|
|
|
|
|
let session = JSON.parse(sessionJson)
|
2024-06-24 21:26:53 +00:00
|
|
|
d.updateSessionsModelAndAddNewIfNotNull(session)
|
2024-05-21 10:42:50 +00:00
|
|
|
|
2024-06-24 21:26:53 +00:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
function deactivateWalletConnectSession(topic) {
|
|
|
|
console.info("Deactivate Persisted Session", topic)
|
|
|
|
|
|
|
|
let sessions = JSON.parse(settings.persistedSessions)
|
|
|
|
let newSessions = sessions.filter(function(session) {
|
|
|
|
return session.topic !== topic
|
|
|
|
})
|
|
|
|
settings.persistedSessions = JSON.stringify(newSessions)
|
|
|
|
d.updateSessionsModelAndAddNewIfNotNull(null)
|
2024-06-07 16:54:19 +00:00
|
|
|
return true
|
2024-05-21 10:42:50 +00:00
|
|
|
}
|
|
|
|
|
2024-06-27 14:15:17 +00:00
|
|
|
function updateWalletConnectSessions(activeTopicsJson) {
|
|
|
|
console.info("Update Persisted Sessions", activeTopicsJson)
|
|
|
|
|
|
|
|
let activeTopics = JSON.parse(activeTopicsJson)
|
|
|
|
let sessions = JSON.parse(settings.persistedSessions)
|
|
|
|
let newSessions = sessions.filter(function(session) {
|
|
|
|
return activeTopics.includes(session.topic)
|
|
|
|
})
|
|
|
|
settings.persistedSessions = JSON.stringify(newSessions)
|
|
|
|
d.updateSessionsModelAndAddNewIfNotNull(null)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2024-05-21 10:42:50 +00:00
|
|
|
function getDapps() {
|
2024-06-24 21:26:53 +00:00
|
|
|
let dappsJson = JSON.stringify(d.persistedDapps)
|
|
|
|
this.dappsListReceived(dappsJson)
|
2024-05-21 10:42:50 +00:00
|
|
|
return true
|
2024-05-20 18:42:31 +00:00
|
|
|
}
|
2024-06-04 20:45:03 +00:00
|
|
|
|
|
|
|
function authenticateUser(topic, id, address) {
|
|
|
|
authMockDialog.topic = topic
|
|
|
|
authMockDialog.id = id
|
|
|
|
authMockDialog.open()
|
|
|
|
return true
|
|
|
|
}
|
2024-06-07 16:54:19 +00:00
|
|
|
|
2024-07-01 21:02:05 +00:00
|
|
|
// hardcoded for https://react-app.walletconnect.com/
|
|
|
|
function signMessageUnsafe(topic, id, address, password, message) {
|
|
|
|
console.info(`calling mocked DAppsStore.signMessageUnsafe(${topic}, ${id}, ${address}, ${password}, ${message})`)
|
|
|
|
return "0xc8f39cb4cffa5c4659e0ccc7c417cc61d0cfc9e59de310368ac734065164f5515bfbaf4550d409896f7e2210b82a1cf65edcd77f696b4d3d24477fb81a90af8a1c"
|
|
|
|
}
|
|
|
|
|
2024-06-07 16:54:19 +00:00
|
|
|
// hardcoded for https://react-app.walletconnect.com/
|
|
|
|
function signMessage(topic, id, address, password, message) {
|
2024-06-18 19:45:56 +00:00
|
|
|
console.info(`calling mocked DAppsStore.signMessage(${topic}, ${id}, ${address}, ${password}, ${message})`)
|
2024-06-07 16:54:19 +00:00
|
|
|
return "0x0b083acc1b3b612dd38e8e725b28ce9b2dd4936b4cf7922da4e4a3c6f44f7f4f6d3050ccb41455a2b85093f1bfadb10fc6a75d83bb590b2eb70e3447653459701c"
|
|
|
|
}
|
|
|
|
|
|
|
|
// hardcoded for https://react-app.walletconnect.com/
|
2024-07-01 21:02:05 +00:00
|
|
|
function safeSignTypedData(topic, id, address, password, typedDataJson, chainId, legacy) {
|
|
|
|
console.info(`calling mocked DAppsStore.safeSignTypedData(${topic}, ${id}, ${address}, ${password}, ${typedDataJson}, ${chainId}, ${legacy})`)
|
2024-06-07 16:54:19 +00:00
|
|
|
return "0xf8ceb3468319cc215523b67c24c4504b3addd9bf8de31c278038d7478c9b6de554f7d8a516cd5d6a066b7d48b81f03d9d6bb7d5d754513c08325674ebcc7efbc1b"
|
|
|
|
}
|
2024-06-12 13:48:44 +00:00
|
|
|
|
2024-06-18 19:45:56 +00:00
|
|
|
// hardcoded for https://react-app.walletconnect.com/
|
|
|
|
function signTransaction(topic, id, address, chainId, password, tx) {
|
|
|
|
console.info(`calling mocked DAppsStore.signTransaction(${topic}, ${id}, ${address}, ${chainId}, ${password}, ${tx})`)
|
|
|
|
return "0xf8672a8402fb7acf82520894e2d622c817878da5143bbe06866ca8e35273ba8a80808401546d71a04fc89c2f007c3b27d0fcff07d3e69c29f940967fab4caf525f9af72dadb48befa00c5312a3cb6f50328889ad361a0c88bb9d1b1a4fc510f6783b287930b4e187b5"
|
2024-06-12 13:48:44 +00:00
|
|
|
}
|
2024-06-23 08:27:29 +00:00
|
|
|
|
|
|
|
function sendTransaction(topic, id, address, chainId, password, tx) {
|
|
|
|
console.info(`calling mocked DAppsStore.sendTransaction(${topic}, ${id}, ${address}, ${chainId}, ${password}, ${tx})`)
|
|
|
|
return "0xf8672a8402fb7acf82520894e2d622c817878da5143bbe068"
|
|
|
|
}
|
2024-07-09 17:49:00 +00:00
|
|
|
|
|
|
|
function getEstimatedTime(chainId, maxFeePerGas) {
|
|
|
|
return Constants.TransactionEstimatedTime.LessThanThreeMins
|
|
|
|
}
|
2024-07-17 10:46:43 +00:00
|
|
|
|
2024-07-17 15:49:30 +00:00
|
|
|
function getSuggestedFees() {
|
|
|
|
return {
|
|
|
|
gasPrice: 2.0,
|
|
|
|
baseFee: 5.0,
|
|
|
|
maxPriorityFeePerGas: 2.0,
|
|
|
|
maxFeePerGasL: 1.0,
|
|
|
|
maxFeePerGasM: 1.1,
|
|
|
|
maxFeePerGasH: 1.2,
|
|
|
|
l1GasFee: 4.0,
|
|
|
|
eip1559Enabled: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-07-17 10:46:43 +00:00
|
|
|
function hexToDec(hex) {
|
|
|
|
if (hex.length > "0xfffffffffffff".length) {
|
|
|
|
console.warn(`Beware of possible loss of precision converting ${hex}`)
|
|
|
|
}
|
|
|
|
return parseInt(hex, 16).toString()
|
|
|
|
}
|
2024-05-06 20:22:43 +00:00
|
|
|
}
|
2024-05-06 17:55:11 +00:00
|
|
|
|
2024-07-03 20:46:00 +00:00
|
|
|
walletRootStore: QObject {
|
2024-06-29 20:24:05 +00:00
|
|
|
property var filteredFlatModel: SortFilterProxyModel {
|
2024-05-06 20:22:43 +00:00
|
|
|
sourceModel: NetworksModel.flatNetworks
|
|
|
|
filters: ValueFilter { roleName: "isTest"; value: settings.testNetworks; }
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
2024-05-31 09:58:47 +00:00
|
|
|
property var accounts: customAccountsModel.count > 0 ? customAccountsModel : defaultAccountsModel
|
2024-06-29 20:24:05 +00:00
|
|
|
readonly property ListModel nonWatchAccounts: accounts
|
2024-06-24 21:26:53 +00:00
|
|
|
|
2024-06-29 20:24:05 +00:00
|
|
|
function getNetworkShortNames(chainIds) {
|
|
|
|
return "eth:oeth:arb"
|
|
|
|
}
|
2024-07-17 10:46:43 +00:00
|
|
|
readonly property CurrenciesStore currencyStore: CurrenciesStore {}
|
2024-07-17 15:49:30 +00:00
|
|
|
readonly property WalletStore.WalletAssetsStore walletAssetsStore: WalletStore.WalletAssetsStore {
|
|
|
|
// Silence warnings
|
|
|
|
assetsWithFilteredBalances: ListModel {}
|
|
|
|
// Name mismatch between storybook and production
|
|
|
|
readonly property var groupedAccountAssetsModel: groupedAccountsAssetsModel
|
|
|
|
}
|
2024-08-05 18:18:26 +00:00
|
|
|
|
|
|
|
readonly property string selectedAddress: ""
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
2024-06-04 20:45:03 +00:00
|
|
|
|
2024-06-12 13:48:44 +00:00
|
|
|
onDisplayToastMessage: (message, isErr) => {
|
|
|
|
if(isErr) {
|
|
|
|
console.log(`Storybook.displayToastMessage(${message}, "", "warning", false, Constants.ephemeralNotificationType.danger, "")`)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
console.log(`Storybook.displayToastMessage(${message}, "", "checkmark-circle", false, Constants.ephemeralNotificationType.success, "")`)
|
|
|
|
}
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-05-31 09:58:47 +00:00
|
|
|
QObject {
|
2024-05-06 17:55:11 +00:00
|
|
|
id: d
|
|
|
|
|
2024-05-21 10:42:50 +00:00
|
|
|
property int activeTestCase: noTestCase
|
2024-05-06 17:55:11 +00:00
|
|
|
|
2024-05-21 10:42:50 +00:00
|
|
|
function startTestCase() {
|
|
|
|
d.activeTestCase = settings.testCase
|
2024-05-06 17:55:11 +00:00
|
|
|
if(root.visible) {
|
2024-06-19 13:13:32 +00:00
|
|
|
dappsWorkflow.popup.open()
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
2024-05-21 10:42:50 +00:00
|
|
|
|
|
|
|
readonly property int noTestCase: 0
|
|
|
|
readonly property int openDappsTestCase: 1
|
|
|
|
readonly property int openPairTestCase: 2
|
|
|
|
|
2024-06-24 21:26:53 +00:00
|
|
|
ListModel {
|
|
|
|
id: sessionsModel
|
|
|
|
}
|
|
|
|
|
|
|
|
function updateSessionsModelAndAddNewIfNotNull(newSession) {
|
|
|
|
var sessions = JSON.parse(settings.persistedSessions)
|
|
|
|
if (!!newSession) {
|
|
|
|
sessions.push(newSession)
|
|
|
|
settings.persistedSessions = JSON.stringify(sessions)
|
|
|
|
}
|
|
|
|
|
|
|
|
sessionsModel.clear()
|
|
|
|
d.persistedDapps = []
|
|
|
|
sessions.forEach(function(session) {
|
|
|
|
sessionsModel.append(session)
|
2024-05-31 09:58:47 +00:00
|
|
|
|
2024-06-24 21:26:53 +00:00
|
|
|
let firstIconUrl = session.peer.metadata.icons.length > 0 ? session.peer.metadata.icons[0] : ""
|
|
|
|
let persistedDapp = {
|
|
|
|
"name": session.peer.metadata.name,
|
|
|
|
"url": session.peer.metadata.url,
|
|
|
|
"iconUrl": firstIconUrl,
|
|
|
|
"topic": session.topic
|
|
|
|
}
|
|
|
|
var found = false
|
|
|
|
for (var i = 0; i < d.persistedDapps.length; i++) {
|
|
|
|
if (d.persistedDapps[i].url == persistedDapp.url) {
|
|
|
|
found = true
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!found) {
|
|
|
|
d.persistedDapps.push(persistedDapp)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
property var persistedDapps: []
|
2024-05-31 09:58:47 +00:00
|
|
|
ListModel {
|
|
|
|
id: customAccountsModel
|
|
|
|
}
|
|
|
|
WalletAccountsModel{
|
|
|
|
id: defaultAccountsModel
|
|
|
|
}
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
onVisibleChanged: {
|
2024-05-21 10:42:50 +00:00
|
|
|
if (visible && d.activeTestCase !== d.noTestCase) {
|
|
|
|
d.startTestCase()
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Settings {
|
|
|
|
id: settings
|
|
|
|
|
2024-05-21 10:42:50 +00:00
|
|
|
property int testCase: d.noTestCase
|
2024-05-06 17:55:11 +00:00
|
|
|
property string pairUri: ""
|
2024-05-06 20:22:43 +00:00
|
|
|
property bool testNetworks: false
|
2024-05-31 09:34:59 +00:00
|
|
|
property bool enableSDK: true
|
2024-07-04 13:33:05 +00:00
|
|
|
property bool pending : false
|
2024-07-05 09:32:31 +00:00
|
|
|
property string customAccounts: "[]"
|
2024-06-24 21:26:53 +00:00
|
|
|
property string persistedSessions: "[]"
|
|
|
|
}
|
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
d.updateSessionsModelAndAddNewIfNotNull(null)
|
2024-05-06 17:55:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// category: Wallet
|
2024-07-01 11:34:30 +00:00
|
|
|
// https://www.figma.com/design/HrmZp1y4S77QJezRFRl6ku/dApp-Interactions---Milestone-1?node-id=3649-30334&t=t5qqtR3RITR4yCOx-0
|