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
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
import utils 1.0
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
Item {
|
2023-10-03 15:43:35 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
required property string projectId
|
2023-10-27 16:18:24 +00:00
|
|
|
readonly property alias sdkReady: d.sdkReady
|
2023-11-06 19:05:18 +00:00
|
|
|
readonly property alias pairingsModel: d.pairingsModel
|
2023-12-08 18:18:58 +00:00
|
|
|
readonly property alias sessionsModel: d.sessionsModel
|
2023-11-15 21:26:12 +00:00
|
|
|
readonly property alias webEngineLoader: loader
|
|
|
|
|
|
|
|
property alias active: loader.active
|
|
|
|
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
|
|
|
|
|
|
|
|
signal statusChanged(string message)
|
2023-10-27 16:18:24 +00:00
|
|
|
signal sdkInit(bool success, var result)
|
2023-12-08 18:18:58 +00:00
|
|
|
signal sessionProposal(var sessionProposal)
|
|
|
|
signal sessionProposalExpired()
|
|
|
|
signal approveSessionResult(var sessionProposal, string error)
|
|
|
|
signal rejectSessionResult(string error)
|
2023-11-06 19:05:18 +00:00
|
|
|
signal sessionRequestEvent(var sessionRequest)
|
|
|
|
signal sessionRequestUserAnswerResult(bool accept, string error)
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-12-06 14:01:25 +00:00
|
|
|
signal authRequest(var request)
|
|
|
|
signal authSignMessage(string message, string address)
|
|
|
|
signal authRequestUserAnswerResult(bool accept, string error)
|
|
|
|
|
2023-11-24 12:51:36 +00:00
|
|
|
signal sessionDelete(var deletePayload)
|
|
|
|
|
2023-12-06 14:01:25 +00:00
|
|
|
function pair(pairLink) {
|
2023-11-16 15:15:37 +00:00
|
|
|
wcCalls.pair(pairLink)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function disconnectTopic(topic) {
|
|
|
|
wcCalls.disconnectTopic(topic)
|
|
|
|
}
|
|
|
|
|
|
|
|
function ping(topic) {
|
|
|
|
wcCalls.ping(topic)
|
2023-11-24 12:51:36 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function approveSession(sessionProposal, supportedNamespaces) {
|
|
|
|
wcCalls.approveSession(sessionProposal, supportedNamespaces)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function rejectSession(id) {
|
|
|
|
wcCalls.rejectSession(id)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function acceptSessionRequest(topic, id, signature) {
|
2023-11-16 15:15:37 +00:00
|
|
|
wcCalls.acceptSessionRequest(topic, id, signature)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function rejectSessionRequest(topic, id, error) {
|
2023-11-16 15:15:37 +00:00
|
|
|
wcCalls.rejectSessionRequest(topic, id, error)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-12-06 14:01:25 +00:00
|
|
|
function auth(authLink) {
|
|
|
|
wcCalls.auth(authLink)
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatAuthMessage(cacaoPayload, address) {
|
|
|
|
wcCalls.formatAuthMessage(cacaoPayload, address)
|
|
|
|
}
|
|
|
|
|
|
|
|
function authApprove(authRequest, address, signature) {
|
|
|
|
wcCalls.authApprove(authRequest, address, signature)
|
|
|
|
}
|
|
|
|
|
|
|
|
function authReject(id, address) {
|
|
|
|
wcCalls.authReject(id, address)
|
|
|
|
}
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
QtObject {
|
|
|
|
id: d
|
|
|
|
|
|
|
|
property bool sdkReady: false
|
|
|
|
property ListModel pairingsModel: pairings
|
2023-12-08 18:18:58 +00:00
|
|
|
property ListModel sessionsModel: sessions
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
property WebEngineView engine: loader.instance
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
onSdkReadyChanged: {
|
|
|
|
if (sdkReady)
|
|
|
|
{
|
|
|
|
d.resetPairingsModel()
|
2023-12-08 18:18:58 +00:00
|
|
|
d.resetSessionsModel()
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
function resetPairingsModel(entryCallback)
|
2023-11-16 15:15:37 +00:00
|
|
|
{
|
|
|
|
pairings.clear();
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
// We have to postpone `getPairings` call, cause otherwise:
|
|
|
|
// - the last made pairing will always have `active` prop set to false
|
|
|
|
// - expiration date won't be the correct one, but one used in session proposal
|
|
|
|
// - the list of pairings will display succesfully made pairing as inactive
|
|
|
|
Backpressure.debounce(this, 250, () => {
|
|
|
|
wcCalls.getPairings((pairList) => {
|
|
|
|
for (let i = 0; i < pairList.length; i++) {
|
|
|
|
pairings.append(pairList[i]);
|
|
|
|
|
|
|
|
if (entryCallback) {
|
|
|
|
entryCallback(pairList[i])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
|
|
|
function resetSessionsModel() {
|
|
|
|
sessions.clear();
|
|
|
|
|
|
|
|
Backpressure.debounce(this, 250, () => {
|
|
|
|
wcCalls.getActiveSessions((sessionList) => {
|
|
|
|
for (var topic of Object.keys(sessionList)) {
|
|
|
|
sessions.append(sessionList[topic]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})();
|
2023-11-16 15:15:37 +00:00
|
|
|
}
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
function getPairingTopicFromPairingUrl(url)
|
|
|
|
{
|
|
|
|
if (!url.startsWith("wc:"))
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2023-12-08 18:18:58 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
const atIndex = url.indexOf("@");
|
|
|
|
if (atIndex < 0)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2023-12-08 18:18:58 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
return url.slice(3, atIndex);
|
|
|
|
}
|
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
|
|
|
|
2023-11-24 12:51:36 +00:00
|
|
|
d.engine.runJavaScript(`wc.init("${root.projectId}").catch((error) => {wc.statusObject.sdkInitialized("SDK init error: "+error);})`, function(result) {
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.init; response: ${JSON.stringify(result, null, 2)}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
|
|
|
|
if (result && !!result.error)
|
|
|
|
{
|
|
|
|
console.error("init: ", result.error)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
d.engine.runJavaScript(`wc.getPairings()`, function(result) {
|
2023-12-12 08:38:17 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.getPairings; result: ${JSON.stringify(result, null, 2)}`)
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
if (callback && result) {
|
|
|
|
callback(result)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
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
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
d.engine.runJavaScript(`wc.getActiveSessions()`, function(result) {
|
2023-12-12 08:38:17 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.getActiveSessions; result: ${JSON.stringify(result, null, 2)}`)
|
2023-12-08 18:18:58 +00:00
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
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)})
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onApproveSessionResponse(${JSON.stringify(sessionProposal)}, "")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onApproveSessionResponse(${JSON.stringify(sessionProposal)}, e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
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) => {
|
|
|
|
wc.statusObject.onRejectSessionResponse("")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onRejectSessionResponse(e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
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-11-15 21:26:12 +00:00
|
|
|
d.engine.runJavaScript(`wc.respondSessionRequest("${topic}", ${id}, "${signature}")`, function(result) {
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.acceptSessionRequest; response: ${JSON.stringify(result, null, 2)}`)
|
2023-10-03 15:43:35 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
if (result) {
|
|
|
|
if (!!result.error)
|
|
|
|
{
|
|
|
|
console.error("respondSessionRequest: ", result.error)
|
|
|
|
root.sessionRequestUserAnswerResult(true, result.error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
root.sessionRequestUserAnswerResult(true, result.error)
|
|
|
|
}
|
2023-12-08 18:18:58 +00:00
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
d.resetPairingsModel()
|
2023-12-08 18:18:58 +00:00
|
|
|
d.resetSessionsModel()
|
2023-11-16 15:15:37 +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-11-15 21:26:12 +00:00
|
|
|
d.engine.runJavaScript(`wc.rejectSessionRequest("${topic}", ${id}, "${error}")`, function(result) {
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.rejectSessionRequest; response: ${JSON.stringify(result, null, 2)}`)
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
d.resetPairingsModel()
|
|
|
|
d.resetSessionsModel()
|
|
|
|
|
2023-11-16 15:15:37 +00:00
|
|
|
if (result) {
|
|
|
|
if (!!result.error)
|
|
|
|
{
|
|
|
|
console.error("rejectSessionRequest: ", result.error)
|
|
|
|
root.sessionRequestUserAnswerResult(false, result.error)
|
|
|
|
return
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
2023-11-16 15:15:37 +00:00
|
|
|
root.sessionRequestUserAnswerResult(false, result.error)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
2023-11-24 12:51:36 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function disconnectTopic(topic) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.disconnectTopic; topic: "${topic}"`)
|
2023-11-24 12:51:36 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
d.engine.runJavaScript(`
|
|
|
|
wc.disconnect("${topic}")
|
|
|
|
.then((value) => {
|
|
|
|
wc.statusObject.onDisconnectResponse("")
|
|
|
|
})
|
|
|
|
.catch((e) => {
|
|
|
|
wc.statusObject.onDisconnectResponse(e.message)
|
|
|
|
})
|
|
|
|
`
|
|
|
|
)
|
|
|
|
}
|
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
|
|
|
}
|
2023-12-06 14:01:25 +00:00
|
|
|
|
|
|
|
function auth(authLink) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.auth; authLink: ${authLink}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`wc.auth("${authLink}")`, function(result) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.auth; response: ${JSON.stringify(result, null, 2)}`)
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
if (!!result.error) {
|
|
|
|
console.error("auth: ", result.error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function formatAuthMessage(cacaoPayload, address) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.auth; cacaoPayload: ${JSON.stringify(cacaoPayload)}, address: ${address}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`wc.formatAuthMessage(${JSON.stringify(cacaoPayload)}, "${address}")`, function(result) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.formatAuthMessage; response: ${JSON.stringify(result, null, 2)}`)
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
if (!!result.error) {
|
|
|
|
console.error("formatAuthMessage: ", result.error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
root.authSignMessage(result.result, address)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function authApprove(authRequest, address, signature) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.authApprove; authRequest: ${JSON.stringify(authRequest)}, address: ${address}, signature: ${signature}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`wc.approveAuth(${JSON.stringify(authRequest)}, "${address}", "${signature}")`, function(result) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.approveAuth; response: ${JSON.stringify(result, null, 2)}`)
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
if (!!result.error)
|
|
|
|
{
|
|
|
|
console.error("approveAuth: ", result.error)
|
|
|
|
root.authRequestUserAnswerResult(true, result.error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
root.authRequestUserAnswerResult(true, result.error)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function authReject(id, address) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.authReject; id: ${id}, address: ${address}`)
|
|
|
|
|
|
|
|
d.engine.runJavaScript(`wc.rejectAuth(${id}, "${address}")`, function(result) {
|
|
|
|
console.debug(`WC WalletConnectSDK.wcCall.rejectAuth; response: ${JSON.stringify(result, null, 2)}`)
|
|
|
|
|
|
|
|
if (result) {
|
|
|
|
if (!!result.error)
|
|
|
|
{
|
|
|
|
console.error("rejectAuth: ", result.error)
|
|
|
|
root.authRequestUserAnswerResult(false, result.error)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
root.authRequestUserAnswerResult(false, result.error)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
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
|
|
|
|
2023-11-24 15:59:19 +00:00
|
|
|
function bubbleConsoleMessage(type, message) {
|
|
|
|
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) {
|
|
|
|
console.debug(`WC WalletConnectSDK.sdkInitialized; error: ${error}`)
|
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}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPingResponse(error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onPingResponse; error: ${error}`)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDisconnectResponse(error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onDisconnectResponse; error: ${error}`)
|
|
|
|
d.resetPairingsModel()
|
|
|
|
d.resetSessionsModel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onApproveSessionResponse(sessionProposal, error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onApproveSessionResponse; sessionProposal: ${JSON.stringify(sessionProposal, null, 2)}, error: ${error}`)
|
|
|
|
|
|
|
|
// Update the temporary expiry with the one from the pairing
|
|
|
|
d.resetPairingsModel((pairing) => {
|
|
|
|
if (pairing.topic === sessionProposal.params.pairingTopic) {
|
|
|
|
sessionProposal.params.expiry = pairing.expiry
|
|
|
|
root.approveSessionResult(sessionProposal, error)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
d.resetSessionsModel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRejectSessionResponse(error) {
|
|
|
|
console.debug(`WC WalletConnectSDK.onRejectSessionResponse; error: ${error}`)
|
|
|
|
root.rejectSessionResult(error)
|
|
|
|
d.resetPairingsModel()
|
|
|
|
d.resetSessionsModel()
|
|
|
|
}
|
|
|
|
|
|
|
|
function onSessionProposal(details) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onSessionProposal; details: ${JSON.stringify(details, null, 2)}`)
|
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) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionUpdate; details: ${JSON.stringify(details, null, 2)}`)
|
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) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionExtend; details: ${JSON.stringify(details, null, 2)}`)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionPing(details) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionPing; details: ${JSON.stringify(details, null, 2)}`)
|
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) {
|
2023-11-24 12:51:36 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onSessionDelete; details: ${JSON.stringify(details, null, 2)}`)
|
|
|
|
root.sessionDelete(details)
|
2023-12-08 18:18:58 +00:00
|
|
|
d.resetPairingsModel()
|
|
|
|
d.resetSessionsModel()
|
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) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionExpire; details: ${JSON.stringify(details, null, 2)}`)
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionRequest(details) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onSessionRequest; details: ${JSON.stringify(details, null, 2)}`)
|
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) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionRequestSent; details: ${JSON.stringify(details, null, 2)}`)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onSessionEvent(details) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC TODO WalletConnectSDK.onSessionEvent; details: ${JSON.stringify(details, null, 2)}`)
|
2023-11-06 19:05:18 +00:00
|
|
|
}
|
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onProposalExpire(details) {
|
2023-11-15 21:26:12 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onProposalExpire; details: ${JSON.stringify(details, null, 2)}`)
|
2023-12-08 18:18:58 +00:00
|
|
|
root.sessionProposalExpired()
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
2023-12-06 14:01:25 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
function onAuthRequest(details) {
|
2023-12-06 14:01:25 +00:00
|
|
|
console.debug(`WC WalletConnectSDK.onAuthRequest; details: ${JSON.stringify(details, null, 2)}`)
|
|
|
|
root.authRequest(details)
|
|
|
|
}
|
2023-10-03 15:43:35 +00:00
|
|
|
}
|
2023-11-06 19:05:18 +00:00
|
|
|
|
|
|
|
ListModel {
|
|
|
|
id: pairings
|
|
|
|
}
|
2023-11-16 15:15:37 +00:00
|
|
|
|
2023-12-08 18:18:58 +00:00
|
|
|
ListModel {
|
|
|
|
id: sessions
|
|
|
|
}
|
|
|
|
|
2023-11-15 21:26:12 +00:00
|
|
|
WebEngineLoader {
|
|
|
|
id: loader
|
2023-11-16 15:15:37 +00:00
|
|
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
url: "qrc:/app/AppLayouts/Wallet/views/walletconnect/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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|