status-desktop/ui/app/AppLayouts/Wallet/services/dapps/WalletConnectSDKBase.qml

64 lines
2.3 KiB
QML
Raw Normal View History

import QtQuick 2.15
/// SDK requires a visible parent to embed WebEngineView
Item {
required property string projectId
signal statusChanged(string message)
signal sdkInit(bool success, var result)
signal pairResponse(bool success)
signal sessionProposal(var sessionProposal)
signal sessionProposalExpired()
refactor: Remove business logic from WC ui components This commit brings a separation of concerns for the UI components involved in dApp interactions. Issue: The UI components depend on the WalletConnectService and also on its dependencies like DAppsRequestHAndler. As a result the UI components have a hard dependency on the WalletConnect specifics and are incompatible with BC. This results in duplication of logic. Issue: The UI components operate on WalletConnect specific JSON object. E.g. session objects, session proposal etc. As a result the UI is built around the WalletConnect message format. Issue: The UI components operate on ListModel items received through functions and stored internally. Any change in the model would result in a crash. Solution: Remove the WalletConnectService dependency from DAppsWorkflow. The DAppsWorkflow now operates with models, signals and functions. This is the first step in the broader refactoring. Moving the logic into the service itself will allow us to further refactor the WC and BC. How does it work now: Dependencies - The UI components have a dependency on models. SessionRequestsModel and DAppsModel. Pairing - The pairing is initiated in the UI. On user input a pairingValidationRequested signal is emitted and the result is received as a function pairingValidated. If the url is valid the UI requests a pairingRequested. When the WalletConnectService is refactored we can go further and request only pairingRequested and to receive a pairingResult call as a function with the result. In the current implementation on pairingRequested we'll receive a connectDApp request. Connecting dApps - The flow is initiated with connectDApp function. This call currently contains all the needed info as args. In the next step it could be replaced with a ConnectionRequests model. The connectDApp call triggered a connection popup if we're not currently showing one to the user. If we're currently showing one it will be queued (corner case). The connection can be accepted with connectionAccepted and rejected with connectionDeclined. Once the connection is accepted we're expecting a result connectionSuccessful or connectionFailed. The connectionSuccessful also expects a new id for the established connection. Signing - The signing flow orbits around the SessionRequestsModel. Each item from the model will generate a popup showing the sign details to the user. Sign can be accepted or rejected using signRequestAccepted or signRequestRejected. No response is currently expected. The model is expected to remove the sign request item.
2024-10-03 18:15:24 +00:00
signal buildApprovedNamespacesResult(var id, var session, string error)
signal approveSessionResult(var proposalId, var approvedNamespaces, string error)
signal rejectSessionResult(var proposalId, string error)
signal sessionRequestExpired(var id)
signal sessionRequestEvent(var sessionRequest)
signal sessionRequestUserAnswerResult(string topic, string id, bool accept /* not reject */, string error)
signal authRequest(var request)
signal authMessageFormated(string formatedMessage, string address)
signal authRequestUserAnswerResult(bool accept, string error)
signal sessionDelete(var topic, string error)
property var pair: function(pairLink) {
console.error("pair not implemented")
}
property var getPairings: function(callback) {
console.error("getPairings not implemented")
}
property var getActiveSessions: function(callback) {
console.error("getActiveSessions not implemented")
}
property var disconnectSession: function(topic) {
console.error("disconnectSession not implemented")
}
property var disconnectPairing: function(topic) {
console.error("disconnectPairing not implemented")
}
property var ping: function(topic) {
console.error("ping not implemented")
}
refactor: Remove business logic from WC ui components This commit brings a separation of concerns for the UI components involved in dApp interactions. Issue: The UI components depend on the WalletConnectService and also on its dependencies like DAppsRequestHAndler. As a result the UI components have a hard dependency on the WalletConnect specifics and are incompatible with BC. This results in duplication of logic. Issue: The UI components operate on WalletConnect specific JSON object. E.g. session objects, session proposal etc. As a result the UI is built around the WalletConnect message format. Issue: The UI components operate on ListModel items received through functions and stored internally. Any change in the model would result in a crash. Solution: Remove the WalletConnectService dependency from DAppsWorkflow. The DAppsWorkflow now operates with models, signals and functions. This is the first step in the broader refactoring. Moving the logic into the service itself will allow us to further refactor the WC and BC. How does it work now: Dependencies - The UI components have a dependency on models. SessionRequestsModel and DAppsModel. Pairing - The pairing is initiated in the UI. On user input a pairingValidationRequested signal is emitted and the result is received as a function pairingValidated. If the url is valid the UI requests a pairingRequested. When the WalletConnectService is refactored we can go further and request only pairingRequested and to receive a pairingResult call as a function with the result. In the current implementation on pairingRequested we'll receive a connectDApp request. Connecting dApps - The flow is initiated with connectDApp function. This call currently contains all the needed info as args. In the next step it could be replaced with a ConnectionRequests model. The connectDApp call triggered a connection popup if we're not currently showing one to the user. If we're currently showing one it will be queued (corner case). The connection can be accepted with connectionAccepted and rejected with connectionDeclined. Once the connection is accepted we're expecting a result connectionSuccessful or connectionFailed. The connectionSuccessful also expects a new id for the established connection. Signing - The signing flow orbits around the SessionRequestsModel. Each item from the model will generate a popup showing the sign details to the user. Sign can be accepted or rejected using signRequestAccepted or signRequestRejected. No response is currently expected. The model is expected to remove the sign request item.
2024-10-03 18:15:24 +00:00
property var buildApprovedNamespaces: function(id, params, supportedNamespaces) {
console.error("buildApprovedNamespaces not implemented")
}
property var approveSession: function(sessionProposal, supportedNamespaces) {
console.error("approveSession not implemented")
}
property var rejectSession: function(id) {
console.error("rejectSession not implemented")
}
property var acceptSessionRequest: function(topic, id, signature) {
console.error("acceptSessionRequest not implemented")
}
property var rejectSessionRequest: function(topic, id, error) {
console.error("rejectSessionRequest not implemented")
}
}