2023-10-03 15:43:35 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
import QtQuick.Controls 2.15
|
|
|
|
import QtQuick.Layouts 1.15
|
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
import QtWebEngine 1.10
|
|
|
|
import QtWebChannel 1.15
|
|
|
|
|
2023-10-03 15:43:35 +00:00
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
2023-11-15 21:26:12 +00:00
|
|
|
import StatusQ.Components 0.1
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2024-05-31 09:58:47 +00:00
|
|
|
import "types"
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
WalletConnectSDKBase {
|
2023-10-03 15:43:35 +00:00
|
|
|
id: root
|
|
|
|
|
2023-10-27 16:18:24 +00:00
|
|
|
readonly property alias sdkReady: d.sdkReady
|
2023-11-15 21:26:12 +00:00
|
|
|
|
2024-07-29 13:50:08 +00:00
|
|
|
// Enable the WalletConnect SDK
|
|
|
|
property alias enableSdk: loader.active
|
2024-08-13 09:13:54 +00:00
|
|
|
property alias userUID: loader.profileName
|
2024-07-29 13:50:08 +00:00
|
|
|
readonly property alias url: loader.url
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
implicitWidth: 1
|
|
|
|
implicitHeight: 1
|
|
|
|
|
2024-05-06 20:22:43 +00:00
|
|
|
/// Generates \c pairResponse signal and expects to receive
|
|
|
|
/// a \c sessionProposal signal with the sessionProposal object
|
2024-05-31 09:34:59 +00:00
|
|
|
pair: function(pairLink) {
|
2023-11-16 15:15:37 +00:00
|
|
|
wcCalls.pair(pairLink)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
getPairings: function(callback) {
|
2023-12-14 10:34:15 +00:00
|
|
|
wcCalls.getPairings(callback)
|
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
getActiveSessions: function(callback) {
|
2023-12-14 07:39:38 +00:00
|
|
|
wcCalls.getActiveSessions(callback)
|
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
disconnectSession: function(topic) {
|
2023-12-14 07:39:38 +00:00
|
|
|
wcCalls.disconnectSession(topic)
|
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
disconnectPairing: function(topic) {
|
2023-12-14 07:39:38 +00:00
|
|
|
wcCalls.disconnectPairing(topic)
|
2023-12-08 18:18:58 +00:00
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
ping: function(topic) {
|
2023-12-08 18:18:58 +00:00
|
|
|
wcCalls.ping(topic)
|
2023-11-24 12:51:36 +00:00
|
|
|
}
|
|
|
|
|
2024-10-03 18:15:24 +00:00
|
|
|
buildApprovedNamespaces: function(id, params, supportedNamespaces) {
|
|
|
|
wcCalls.buildApprovedNamespaces(id, params, supportedNamespaces)
|
2024-05-06 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
approveSession: function(sessionProposal, supportedNamespaces) {
|
2023-12-08 18:18:58 +00:00
|
|
|
wcCalls.approveSession(sessionProposal, supportedNamespaces)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
rejectSession: function(id) {
|
2023-12-08 18:18:58 +00:00
|
|
|
wcCalls.rejectSession(id)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
acceptSessionRequest: function(topic, id, signature) {
|
2023-11-16 15:15:37 +00:00
|
|
|
wcCalls.acceptSessionRequest(topic, id, signature)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2024-05-31 09:34:59 +00:00
|
|
|
rejectSessionRequest: function(topic, id, error) {
|
2023-11-16 15:15:37 +00:00
|
|
|
wcCalls.rejectSessionRequest(topic, id, error)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2024-10-17 15:02:51 +00:00
|
|
|
populateAuthPayload: function(id, authPayload, chains, methods) {
|
|
|
|
wcCalls.populateAuthPayload(id, authPayload, chains, methods)
|
|
|
|
}
|
|
|
|
|
|
|
|
formatAuthMessage: function(id, request, iss) {
|
|
|
|
wcCalls.formatAuthMessage(id, request, iss)
|
|
|
|
}
|
|
|
|
|
|
|
|
acceptSessionAuthenticate: function(id, auths) {
|
|
|
|
wcCalls.acceptSessionAuthenticate(id, auths)
|
|
|
|
}
|
|
|
|
|
|
|
|
rejectSessionAuthenticate: function(id, error) {
|
|
|
|
wcCalls.rejectSessionAuthenticate(id, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
buildAuthObject: function(id, authPayload, signature, iss) {
|
|
|
|
wcCalls.buildAuthObject(id, authPayload, signature, iss)
|
|
|
|
}
|
|
|
|
|
2024-10-23 11:37:32 +00:00
|
|
|
emitSessionEvent: function(topic, event, chainId) {
|
|
|
|
wcCalls.emitSessionEvent(topic, event, chainId)
|
|
|
|
}
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
property bool sdkReady: false
|
2023-11-15 21:26:12 +00:00
|
|
|
property WebEngineView engine: loader.instance
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
QtObject {
|
|
|
|
id: wcCalls
|
|
|
|
|
|
|
|
function init() {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.init; root.projectId: ${root.projectId}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2024-07-29 13:50:08 +00:00
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.init("${root.projectId}")
|
|
|
|
.then(()=> {
|
|
|
|
wc.statusObject.sdkInitialized("");
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
wc.statusObject.sdkInitialized("SDK init error: "+error)
|
|
|
|
})
|
|
|
|
`)
|
2023-11-16 15:15:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getPairings(callback) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.getPairings;`)
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2024-01-31 15:45:23 +00:00
|
|
|
if (d.engine) {
|
|
|
|
d.engine.runJavaScript(`wc.getPairings()`, function(result) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.getPairings; result: ${JSON.stringify(result)}`)
|
2024-01-31 15:45:23 +00:00
|
|
|
|
|
|
|
if (callback && result) {
|
|
|
|
callback(result)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2023-12-08 18:18:58 +00:00
|
|
|
}
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function getActiveSessions(callback) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.getActiveSessions;`)
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2024-01-31 15:45:23 +00:00
|
|
|
if (d.engine) {
|
|
|
|
d.engine.runJavaScript(`wc.getActiveSessions()`, function(result) {
|
|
|
|
if (callback && result) {
|
|
|
|
callback(result)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2023-11-16 15:15:37 +00:00
|
|
|
}
|
2023-10-27 16:18:24 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
function pair(pairLink) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.pair; pairLink: ${pairLink}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.pair("${pairLink}")
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onPairResponse("")
|
2023-11-16 15:15:37 +00:00
|
|
|
})
|
2023-12-08 18:18:58 +00:00
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onPairResponse(e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
2023-11-16 15:15:37 +00:00
|
|
|
}
|
|
|
|
|
2024-10-03 18:15:24 +00:00
|
|
|
function buildApprovedNamespaces(pairingId, params, supportedNamespaces) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.buildApprovedNamespaces; id: ${pairingId}, params: ${JSON.stringify(params)}, supportedNamespaces: ${JSON.stringify(supportedNamespaces)}`)
|
2024-05-06 20:22:43 +00:00
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.buildApprovedNamespaces(${JSON.stringify(params)}, ${JSON.stringify(supportedNamespaces)})
|
|
|
|
.then((approvedNamespaces) => {
|
2024-10-03 18:15:24 +00:00
|
|
|
wc.statusObject.onBuildApprovedNamespacesResponse(${pairingId}, approvedNamespaces, "")
|
2024-05-06 20:22:43 +00:00
|
|
|
})
|
|
|
|
.catch((e) => {
|
2024-10-03 18:15:24 +00:00
|
|
|
wc.statusObject.onBuildApprovedNamespacesResponse(${pairingId}, "", e.message)
|
2024-05-06 20:22:43 +00:00
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function approveSession(sessionProposal, supportedNamespaces) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.approveSession; sessionProposal: ${JSON.stringify(sessionProposal)}, supportedNamespaces: ${JSON.stringify(supportedNamespaces)}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.approveSession(${JSON.stringify(sessionProposal)}, ${JSON.stringify(supportedNamespaces)})
|
2023-12-14 07:39:38 +00:00
|
|
|
.then((session) => {
|
2024-10-03 18:15:24 +00:00
|
|
|
wc.statusObject.onApproveSessionResponse(${sessionProposal.id}, session, "")
|
2023-12-08 18:18:58 +00:00
|
|
|
})
|
|
|
|
.catch((e) => {
|
2024-10-03 18:15:24 +00:00
|
|
|
wc.statusObject.onApproveSessionResponse(${sessionProposal.id}, "", e.message)
|
2023-12-08 18:18:58 +00:00
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
2023-11-16 15:15:37 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function rejectSession(id) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.rejectSession; id: ${id}`)
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.rejectSession(${id})
|
|
|
|
.then((value) => {
|
2024-10-03 18:15:24 +00:00
|
|
|
wc.statusObject.onRejectSessionResponse(${id}, "")
|
2023-12-08 18:18:58 +00:00
|
|
|
})
|
|
|
|
.catch((e) => {
|
2024-10-03 18:15:24 +00:00
|
|
|
wc.statusObject.onRejectSessionResponse(${id}, e.message)
|
2023-12-08 18:18:58 +00:00
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
function acceptSessionRequest(topic, id, signature) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.acceptSessionRequest; topic: "${topic}", id: ${id}, signature: "${signature}"`)
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-12-12 12:14:23 +00:00
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.respondSessionRequest("${topic}", ${id}, "${signature}")
|
|
|
|
.then((value) => {
|
2024-06-04 20:45:03 +00:00
|
|
|
wc.statusObject.onAcceptSessionRequestResponse("${topic}", ${id}, "")
|
2023-12-12 12:14:23 +00:00
|
|
|
})
|
|
|
|
.catch((e) => {
|
2024-06-04 20:45:03 +00:00
|
|
|
wc.statusObject.onAcceptSessionRequestResponse("${topic}", ${id}, e.message)
|
2023-12-12 12:14:23 +00:00
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
function rejectSessionRequest(topic, id, error) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.rejectSessionRequest; topic: "${topic}", id: ${id}, error: "${error}"`)
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-12-12 12:14:23 +00:00
|
|
|
d.engine.runJavaScript(`
|
2024-10-04 12:49:16 +00:00
|
|
|
wc.rejectSessionRequest("${topic}", ${id}, ${error})
|
2023-12-12 12:14:23 +00:00
|
|
|
.then((value) => {
|
2024-06-04 20:45:03 +00:00
|
|
|
wc.statusObject.onRejectSessionRequestResponse("${topic}", ${id}, "")
|
2023-12-12 12:14:23 +00:00
|
|
|
})
|
|
|
|
.catch((e) => {
|
2024-06-04 20:45:03 +00:00
|
|
|
wc.statusObject.onRejectSessionRequestResponse("${topic}", ${id}, e.message)
|
2023-12-12 12:14:23 +00:00
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
2023-11-24 12:51:36 +00:00
|
|
|
|
2023-12-14 07:39:38 +00:00
|
|
|
function disconnectSession(topic) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.disconnectSession; topic: "${topic}"`)
|
2023-11-24 12:51:36 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.disconnect("${topic}")
|
2023-12-14 07:39:38 +00:00
|
|
|
.then(() => {
|
|
|
|
wc.statusObject.onDisconnectSessionResponse("${topic}", "")
|
2023-12-08 18:18:58 +00:00
|
|
|
})
|
|
|
|
.catch((e) => {
|
2023-12-14 07:39:38 +00:00
|
|
|
wc.statusObject.onDisconnectSessionResponse("", e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2024-10-23 11:37:32 +00:00
|
|
|
function emitSessionEvent(topic, event, chainId) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.emitSessionEvent; topic: ${topic}, event: ${JSON.stringify(event)}, chainId: ${chainId}`)
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.emitSessionEvent("${topic}", ${JSON.stringify(event)}, "${chainId}")
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.echo("debug", " emitSessionEvent success")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.echo("error", " emitSessionEvent error: " + e.message)
|
|
|
|
})`)
|
|
|
|
}
|
|
|
|
|
2023-12-14 07:39:38 +00:00
|
|
|
function disconnectPairing(topic) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.disconnectPairing; topic: "${topic}"`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.disconnect("${topic}")
|
|
|
|
.then(() => {
|
|
|
|
wc.statusObject.onDisconnectPairingResponse("${topic}", "")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onDisconnectPairingResponse("", e.message)
|
2023-12-08 18:18:58 +00:00
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
2023-11-24 12:51:36 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function ping(topic) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.ping; topic: "${topic}"`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.ping("${topic}")
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onPingResponse("")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onPingResponse(e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
2023-11-24 12:51:36 +00:00
|
|
|
}
|
2024-10-17 15:02:51 +00:00
|
|
|
|
|
|
|
function populateAuthPayload(id, authPayload, chains, methods) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.populateAuthPayload; id: "${id}", authPayload: ${JSON.stringify(authPayload)}, chains: ${JSON.stringify(chains)}, methods: ${JSON.stringify(methods)}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.populateAuthPayload(${JSON.stringify(authPayload)}, ${JSON.stringify(chains)}, ${JSON.stringify(methods)})
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onPopulateAuthPayloadResponse("${id}", value, "")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onPopulateAuthPayloadResponse("${id}", "", e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatAuthMessage(id, request, iss) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.formatAuthMessage; id: ${id}, request: ${JSON.stringify(request)}, iss: ${iss}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.formatAuthMessage(${JSON.stringify(request)}, "${iss}")
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onFormatAuthMessageResponse(${id}, value, "")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onFormatAuthMessageResponse(${id}, "", e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function buildAuthObject(id, authPayload, signature, iss) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.buildAuthObject; id: ${id}, authPayload: ${JSON.stringify(authPayload)}, signature: ${signature}, iss: ${iss}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.buildAuthObject(${JSON.stringify(authPayload)}, "${signature}", "${iss}")
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onBuildAuthObjectResponse(${id}, value, "")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onBuildAuthObjectResponse(${id}, "", e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function acceptSessionAuthenticate(id, auths) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.acceptSessionAuthenticate; id: ${id}, auths: ${JSON.stringify(auths)}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.acceptSessionAuthenticate(${id}, ${JSON.stringify(auths)})
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onAcceptSessionAuthenticateResult(${id}, value, "")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onAcceptSessionAuthenticateResult(${id}, "", e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
function rejectSessionAuthenticate(id, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.rejectSessionAuthenticate; id: ${id}, error: "${error}"`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.rejectSessionAuthenticate(${id}, ${error})
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onRejectSessionAuthenticateResult(${id}, value, "")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onRejectSessionAuthenticateResult(${id}, "", e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2023-10-03 15:43:35 +00:00
|
|
|
QtObject {
|
2023-11-16 15:15:37 +00:00
|
|
|
id: statusObject
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
WebChannel.id: "statusObject"
|
2023-11-06 19:05:18 +00:00
|
|
|
|
2024-07-29 13:50:08 +00:00
|
|
|
function echo(type, message) {
|
2023-11-24 15:59:19 +00:00
|
|
|
if (type === "warn") {
|
|
|
|
console.warn(message)
|
|
|
|
} else if (type === "debug") {
|
|
|
|
console.debug(message)
|
|
|
|
} else if (type === "error") {
|
|
|
|
console.error(message)
|
|
|
|
} else {
|
|
|
|
console.log(message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function sdkInitialized(error) {
|
2024-07-29 13:50:08 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.sdkInitialized: ${!!error ? "error: " + error : "success"}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
d.sdkReady = !error
|
|
|
|
root.sdkInit(d.sdkReady, error)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onPairResponse(error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onPairResponse; error: ${error}`)
|
2024-05-06 20:22:43 +00:00
|
|
|
root.pairResponse(error == "")
|
2023-12-08 18:18:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onPingResponse(error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onPingResponse; error: ${error}`)
|
|
|
|
}
|
|
|
|
|
2023-12-14 07:39:38 +00:00
|
|
|
function onDisconnectSessionResponse(topic, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onDisconnectSessionResponse; topic: ${topic}, error: ${error}`)
|
|
|
|
root.sessionDelete(topic, error)
|
2023-12-08 18:18:58 +00:00
|
|
|
}
|
|
|
|
|
2023-12-14 07:39:38 +00:00
|
|
|
function onDisconnectPairingResponse(topic, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onDisconnectPairingResponse; topic: ${topic}, error: ${error}`)
|
|
|
|
}
|
2023-12-08 18:18:58 +00:00
|
|
|
|
2024-10-03 18:15:24 +00:00
|
|
|
function onBuildApprovedNamespacesResponse(id, approvedNamespaces, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onBuildApprovedNamespacesResponse; id: ${id}, approvedNamespaces: ${approvedNamespaces ? JSON.stringify(approvedNamespaces) : "-"}, error: ${error}`)
|
|
|
|
root.buildApprovedNamespacesResult(id, approvedNamespaces, error)
|
2024-05-06 20:22:43 +00:00
|
|
|
}
|
|
|
|
|
2024-10-03 18:15:24 +00:00
|
|
|
function onApproveSessionResponse(proposalId, session, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onApproveSessionResponse; proposalId: ${proposalId}, sessionTopic: ${JSON.stringify(session)}, error: ${error}`)
|
|
|
|
root.approveSessionResult(proposalId, session, error)
|
2023-12-08 18:18:58 +00:00
|
|
|
}
|
|
|
|
|
2024-10-03 18:15:24 +00:00
|
|
|
function onRejectSessionResponse(proposalId, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onRejectSessionResponse; proposalId: ${proposalId}, error: ${error}`)
|
|
|
|
root.rejectSessionResult(proposalId, error)
|
2023-12-08 18:18:58 +00:00
|
|
|
}
|
|
|
|
|
2024-06-04 20:45:03 +00:00
|
|
|
function onAcceptSessionRequestResponse(topic, id, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onAcceptSessionRequestResponse; topic: ${topic}, id: ${id} error: ${error}`)
|
|
|
|
let responseToAccept = true
|
|
|
|
root.sessionRequestUserAnswerResult(topic, id, responseToAccept, error)
|
2023-12-12 12:14:23 +00:00
|
|
|
}
|
|
|
|
|
2024-06-04 20:45:03 +00:00
|
|
|
function onRejectSessionRequestResponse(topic, id, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onRejectSessionRequestResponse; topic: ${topic}, id: ${id}, error: ${error}`)
|
|
|
|
let responseToAccept = false
|
|
|
|
root.sessionRequestUserAnswerResult(topic, id, responseToAccept, error)
|
2023-12-12 12:14:23 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionProposal(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onSessionProposal; details: ${JSON.stringify(details)}`)
|
2023-12-08 18:18:58 +00:00
|
|
|
root.sessionProposal(details)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionUpdate(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionUpdate; details: ${JSON.stringify(details)}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
}
|
2023-11-06 19:05:18 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionExtend(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionExtend; details: ${JSON.stringify(details)}`)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionPing(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionPing; details: ${JSON.stringify(details)}`)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionDelete(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onSessionDelete; details: ${JSON.stringify(details)}`)
|
2023-12-14 07:39:38 +00:00
|
|
|
root.sessionDelete(details.topic, "")
|
2023-10-27 16:18:24 +00:00
|
|
|
}
|
2023-11-06 19:05:18 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionExpire(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionExpire; details: ${JSON.stringify(details)}`)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionRequest(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onSessionRequest; details: ${JSON.stringify(details)}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
root.sessionRequestEvent(details)
|
|
|
|
}
|
2023-11-06 19:05:18 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionRequestSent(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionRequestSent; details: ${JSON.stringify(details)}`)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionEvent(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionEvent; details: ${JSON.stringify(details)}`)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onProposalExpire(details) {
|
2024-06-24 21:26:53 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onProposalExpire; details: ${JSON.stringify(details)}`)
|
2023-12-08 18:18:58 +00:00
|
|
|
root.sessionProposalExpired()
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
2024-10-04 12:49:16 +00:00
|
|
|
|
|
|
|
function onSessionRequestExpire(id) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onSessionRequestExpire; id: ${id}`)
|
|
|
|
root.sessionRequestExpired(id)
|
|
|
|
}
|
2024-10-17 15:02:51 +00:00
|
|
|
|
|
|
|
function onPopulateAuthPayloadResponse(id, payload, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onPopulateAuthPayloadResponse; id: ${id}, payload: ${JSON.stringify(payload)}, error: ${error}`)
|
|
|
|
root.populateAuthPayloadResult(id, payload, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onFormatAuthMessageResponse(id, message, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onFormatAuthMessageResponse; id: ${id}, message: ${JSON.stringify(message)}, error: ${error}`)
|
|
|
|
root.formatAuthMessageResult(id, message, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onBuildAuthObjectResponse(id, authObject, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onBuildAuthObjectResponse; id: ${id}, authObject: ${JSON.stringify(authObject)}, error: ${error}`)
|
|
|
|
root.buildAuthObjectResult(id, authObject, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSessionAuthenticate(details) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onSessionAuthenticate; details: ${JSON.stringify(details)}`)
|
|
|
|
root.sessionAuthenticateRequest(details)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onAcceptSessionAuthenticateResult(id, result, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onAcceptSessionAuthenticateResult; id: ${id}, result: ${JSON.stringify(result)}, error: ${error}`)
|
|
|
|
root.acceptSessionAuthenticateResult(id, result, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRejectSessionAuthenticateResult(id, result, error) {
|
|
|
|
//console.debug(`WC WalletConnectSDK.onRejectSessionAuthenticateResult; id: ${id}, result: ${result}, error: ${error}`)
|
|
|
|
root.rejectSessionAuthenticateResult(id, result, error)
|
|
|
|
}
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
2023-11-06 19:05:18 +00:00
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
WebEngineLoader {
|
|
|
|
id: loader
|
2023-11-16 15:15:37 +00:00
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
2024-05-06 11:46:48 +00:00
|
|
|
url: "qrc:/app/AppLayouts/Wallet/services/dapps/sdk/src/index.html"
|
2023-11-15 21:26:12 +00:00
|
|
|
webChannelObjects: [ statusObject ]
|
|
|
|
|
|
|
|
onPageLoaded: function() {
|
|
|
|
wcCalls.init()
|
|
|
|
}
|
|
|
|
onPageLoadingError: function(error) {
|
|
|
|
console.error("WebEngineLoader.onPageLoadingError: ", error)
|
2023-11-16 15:15:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|