2024-10-30 15:18:24 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import StatusQ.Core.Utils 0.1 as SQUtils
|
|
|
|
|
|
|
|
SQUtils.QObject {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
required property var controller
|
|
|
|
|
|
|
|
// Signals driven by the dApp
|
|
|
|
signal connectRequested(string requestId, string dappJson)
|
2024-11-11 16:22:45 +00:00
|
|
|
signal sendTransaction(string requestId, string requestJson)
|
|
|
|
signal personalSign(string requestId, string dappJson)
|
2024-10-30 15:18:24 +00:00
|
|
|
|
|
|
|
signal connected(string dappJson)
|
|
|
|
signal disconnected(string dappJson)
|
|
|
|
|
|
|
|
// Responses to user actions
|
|
|
|
signal approveConnectResponse(string id, bool error)
|
|
|
|
signal rejectConnectResponse(string id, bool error)
|
|
|
|
|
2024-11-07 09:10:10 +00:00
|
|
|
signal approveTransactionResponse(string topic, string requestId, bool error)
|
|
|
|
signal rejectTransactionResponse(string topic, string requestId, bool error)
|
2024-11-11 16:22:45 +00:00
|
|
|
signal approvePersonalSignResponse(string topic, string requestId, bool error)
|
|
|
|
signal rejectPersonalSignResponse(string topic, string requestId, bool error)
|
2024-10-30 15:18:24 +00:00
|
|
|
|
|
|
|
function approveConnection(id, account, chainId) {
|
|
|
|
return controller.approveConnection(id, account, chainId)
|
|
|
|
}
|
|
|
|
|
|
|
|
function rejectConnection(id, error) {
|
|
|
|
return controller.rejectConnection(id, error)
|
|
|
|
}
|
|
|
|
|
2024-11-07 09:10:10 +00:00
|
|
|
function approveTransaction(topic, requestId, signature) {
|
|
|
|
return controller.approveTransaction(topic, requestId, signature)
|
2024-10-30 15:18:24 +00:00
|
|
|
}
|
|
|
|
|
2024-11-07 09:10:10 +00:00
|
|
|
function rejectTransaction(topic, requestId, error) {
|
|
|
|
return controller.rejectTransaction(topic, requestId, error)
|
2024-10-30 15:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function disconnect(id) {
|
|
|
|
return controller.disconnect(id)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getDApps() {
|
|
|
|
return controller.getDApps()
|
|
|
|
}
|
|
|
|
|
2024-11-11 16:22:45 +00:00
|
|
|
function approvePersonalSign(topic, requestId, signature) {
|
|
|
|
return controller.approvePersonalSigning(topic, requestId, signature)
|
|
|
|
}
|
|
|
|
|
|
|
|
function rejectPersonalSign(topic, requestId) {
|
|
|
|
return controller.rejectPersonalSigning(topic, requestId)
|
|
|
|
}
|
|
|
|
|
2024-10-30 15:18:24 +00:00
|
|
|
Connections {
|
|
|
|
target: controller
|
|
|
|
|
|
|
|
function onConnectRequested(requestId, dappJson) {
|
|
|
|
root.connectRequested(requestId, dappJson)
|
|
|
|
}
|
|
|
|
|
2024-11-11 16:22:45 +00:00
|
|
|
function onSendTransaction(requestId, requestJson) {
|
|
|
|
root.sendTransaction(requestId, requestJson)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPersonalSign(requestId, dappJson) {
|
|
|
|
root.personalSign(requestId, dappJson)
|
2024-10-30 15:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function onConnected(dappJson) {
|
|
|
|
root.connected(dappJson)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onDisconnected(dappJson) {
|
|
|
|
root.disconnected(dappJson)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onApproveConnectResponse(id, error) {
|
|
|
|
root.approveConnectResponse(id, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRejectConnectResponse(id, error) {
|
|
|
|
root.rejectConnectResponse(id, error)
|
|
|
|
}
|
|
|
|
|
2024-11-07 09:10:10 +00:00
|
|
|
function onApproveTransactionResponse(topic, requestId, error) {
|
|
|
|
root.approveTransactionResponse(topic, requestId, error)
|
2024-10-30 15:18:24 +00:00
|
|
|
}
|
|
|
|
|
2024-11-07 09:10:10 +00:00
|
|
|
function onRejectTransactionResponse(topic, requestId, error) {
|
|
|
|
root.rejectTransactionResponse(topic, requestId, error)
|
2024-10-30 15:18:24 +00:00
|
|
|
}
|
2024-11-11 16:22:45 +00:00
|
|
|
|
|
|
|
function onApprovePersonalSignResponse(topic, requestId, error) {
|
|
|
|
root.approvePersonalSignResponse(topic, requestId, error)
|
|
|
|
}
|
|
|
|
|
|
|
|
function onRejectPersonalSignResponse(topic, requestId, error) {
|
|
|
|
root.rejectPersonalSignResponse(topic, requestId, error)
|
|
|
|
}
|
2024-10-30 15:18:24 +00:00
|
|
|
}
|
|
|
|
}
|