-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat(DApps): Refactoring wallet connect service and bring BrowserConnect inline with WC #16730
base: 14996-add-siwe-to-sign-in-via-wallet-connect
Are you sure you want to change the base?
Feat(DApps): Refactoring wallet connect service and bring BrowserConnect inline with WC #16730
Conversation
Jenkins BuildsClick to see older builds (12)
|
@@ -21,6 +21,8 @@ type ConnectorGrantDAppPermissionSignal* = ref object of Signal | |||
url*: string | |||
name*: string | |||
iconUrl*: string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These arguments were missing from the integration. We need to know in the UI on what account a dapp is connected and on what chains.
proc dappValidatesTransaction*(self: Controller, requestId: string, payload: string) {.signal.} | ||
proc dappGrantDAppPermission*(self: Controller, payload: string) {.signal.} | ||
proc dappRevokeDAppPermission*(self: Controller, payload: string) {.signal.} | ||
proc connectRequested*(self: Controller, requestId: string, payload: string) {.signal.} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added request-response pair for the API. This is needed in the UI because it's reacting only on the response. From this point on the nim requests can be done asynchronous.
@@ -137,4 +137,17 @@ QtObject: | |||
|
|||
except Exception as e: | |||
error "recallDAppPermissionFinishedRpc failed: ", err=e.msg | |||
return false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was no way to fetch all the dapps from persistence.
@@ -69,8 +69,8 @@ DappsComboBox { | |||
signal disconnectRequested(string connectionId) | |||
signal pairingRequested(string uri) | |||
signal pairingValidationRequested(string uri) | |||
signal connectionAccepted(var pairingId, var chainIds, string selectedAccount) | |||
signal connectionDeclined(var pairingId) | |||
signal connectionAccepted(string pairingId, var chainIds, string selectedAccount) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to keep things inline and the pairing ids and topics to be strings in all signals
@@ -138,37 +138,37 @@ Item { | |||
id: dappsWorkflow |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this file I've only renamed the WalletConnectService
to DAppsService
} | ||
} | ||
*/ | ||
function parse(event, hexToDec = (hex) => { return parseInt(hex, 16) }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now all the session request parsing happens in this singletone
component. There's also a storybook page where we can paste any WC/BC session request to investigate the resulted object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code moved from the request handler. I've split the stateful implementation and the parsing. This component provides just the parsing.
@@ -48,30 +46,11 @@ QObject { | |||
/// maps to Constants.TransactionEstimatedTime values | |||
property int estimatedTimeCategory: 0 | |||
|
|||
function resolveDappInfoFromSession(session) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not needed. The dapp metadata is known in advanced. This is now provided by the DAppsModel
and we don't need to always do asynchronous calls to the sdk to get this kind of info.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component will parse the session request and validated based on app data (accountsModel, networksModel)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QML entry point for BrowserConnect calls.
ae0a35f
to
b4e22be
Compare
e74fe00
to
b6aae86
Compare
8efad11
to
4636f80
Compare
New component introduced (DAppsModel) to provide a common model for WC and BC. The WCDappsProvider and BCDappsProvider components are responsible to fill the model from different sources
This PR is refactoring the dapps service to avoid code duplication between SDKs and also to avoid overlapping requests/responses. It brings Browser Connect inline with Wallet Connect in terms of session management and sign transactions. New architecture: WalletConnectService becomes DAppsService. Its responsibility is to provide dapp access to the app. This is the component currently used by the UI What does it do: 1. Provide dapp APIs line connect, disconnect, session requests etc 2. Spawn app notifications on dapp events 3. Timeout requests if the dapp does not respons DAppsRequestHandler becomes DAppsModule. This component is consumed by the DAppService. Its responsibility is to aggregate all the building blocks for the dapps, but does not control any of the dapp features or consume the SDKs requests. What does it do: 1. Aggregate all the building blocks for dapps (currently known as plugins) DAppConnectionsPlugin - This component provides the session management features line connect, disconnect and provide a model with the connected dapps. SignRequestPlugin - This component provides the sign request management. It receives the sign request from the dapp, translates it to what Status understands and manages the lifecycle of the request.
b6aae86
to
698cbee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the sign
logic from the dappsRequestHandler
to be reused for both SDKs
return { obj: null, code: SessionRequest.RuntimeError } | ||
} | ||
|
||
updateFeesOnPreparedData(request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saledjenic minor changes to the new fees while resolving the conflicts. It's split in 2 parts. updateFeesOnPreparedData - Updating the preparedData
for the user whenever the fees are null
updateFeesParamsToPassedObj
- updates the fees for the modal
} | ||
|
||
request.setExpired() | ||
d.unsubscribeForFeeUpdates(request.topic, request.requestId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another change is here, where we unsubscribe for fee updates if the request has expired.
cc @saledjenic
@@ -7,7 +7,7 @@ SequentialAnimation { | |||
|
|||
property var target: null | |||
property color fromColor: Theme.palette.directColor1 | |||
property color toColor: Theme.palette.baseColor5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saledjenic updated this when resolving the merge conflict. I don't see any difference for the Theme.palette.directColor1
and now it also works for other colors like danger1
What does the PR do
Closes: #16044 #15936 #15711
Needs status-go PR: status-im/status-go#6051
This is the final PR in the dapps refactoring. At this point the WalletConnect and BrowserConnect is using the same UI and the same qml processing.
Next step for later: Refactor the test_DAppsWorkflow.qml. Currently it's testing everything E2E. But now we have the component separation needed to test everything in isolation.
Affected areas
Wallet Connect
Browser Connect
Architecture compliance
My PR is consistent with this document: Status Desktop Architecture Guide
Screenshot of functionality (including design for comparison)