feat(WalletConnect): Expose `emitSessionEvent` function from the WC js SDK

This commit exposes the `emitSessionEvent` function to qml
This commit is contained in:
Alex Jbanca 2024-10-23 14:37:32 +03:00 committed by Alex Jbanca
parent 0d67d5138b
commit 7d3cd5c7bf
4 changed files with 33 additions and 1 deletions

View File

@ -89,6 +89,10 @@ WalletConnectSDKBase {
wcCalls.buildAuthObject(id, authPayload, signature, iss)
}
emitSessionEvent: function(topic, event, chainId) {
wcCalls.emitSessionEvent(topic, event, chainId)
}
QtObject {
id: d
@ -244,6 +248,18 @@ WalletConnectSDKBase {
)
}
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)
})`)
}
function disconnectPairing(topic) {
console.debug(`WC WalletConnectSDK.wcCall.disconnectPairing; topic: "${topic}"`)
@ -348,6 +364,14 @@ WalletConnectSDKBase {
`
)
}
function connected() {
console.debug(`WC WalletConnectSDK.wcCall.connected;`)
}
function disconnected() {
console.debug(`WC WalletConnectSDK.wcCall.disconnected;`)
}
}
QtObject {

View File

@ -82,4 +82,8 @@ Item {
property var rejectSessionAuthenticate: function(id, error) {
console.error("rejectSessionAuthenticate not implemented")
}
property var emitSessionEvent: function(topic, event, chainId) {
console.error("emitSessionEvent not implemented")
}
}

File diff suppressed because one or more lines are too long

View File

@ -236,5 +236,9 @@ window.wc = {
id: id,
reason: getSdkError('USER_REJECTED') // or choose a different reason if applicable
})
},
emitSessionEvent: async function (topic, event, chainId) {
return await window.wc.walletKit.emitSessionEvent({topic, event, chainId});
}
};