-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(WC): Refactor dapps service to work with multiple SDKs
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.
- Loading branch information
Showing
38 changed files
with
3,288 additions
and
1,110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import QtQuick 2.15 | ||
import QtQuick.Controls 2.15 | ||
import QtQuick.Layouts 1.15 | ||
|
||
import AppLayouts.Wallet.services.dapps.types 1.0 | ||
|
||
SplitView { | ||
id: root | ||
orientation: Qt.Horizontal | ||
|
||
readonly property string sign: "{\n\ | ||
\"id\": 1730473461432473,\n\ | ||
\"params\": {\n\ | ||
\"chainId\": \"eip155:1\",\n\ | ||
\"request\": {\n\ | ||
\"expiryTimestamp\": 1730473761,\n\ | ||
\"method\": \"personal_sign\",\n\ | ||
\"params\": [\n\ | ||
\"0x4d7920656d61696c206973206a6f686e40646f652e636f6d202d2031373330343733343631343331\",\n\ | ||
\"0x8b6950bb8a74489a83e6a1281e3aa008f02bf368\"\n\ | ||
]\n\ | ||
},\n\ | ||
\"topic\": \"3a9a320f8fc8e7a814895b148911373ba7df58c176ddca989f0e72ea1f9b8148\",\n\ | ||
\"verifyContext\": {\n\ | ||
\"verified\": {\n\ | ||
\"isScam\": false,\n\ | ||
\"origin\": \"https://react-app.walletconnect.com\",\n\ | ||
\"validation\": \"VALID\",\n\ | ||
\"verifyUrl\": \"https://verify.walletconnect.org\"\n\ | ||
}\n\ | ||
}\n\ | ||
}\n\ | ||
}" | ||
readonly property string transaction: "{\n\ | ||
\"id\": 1730473547658704,\n\ | ||
\"params\": {\n\ | ||
\"chainId\": \"eip155:10\",\n\ | ||
\"request\": {\n\ | ||
\"expiryTimestamp\": 1730473847,\n\ | ||
\"method\": \"eth_sendTransaction\",\n\ | ||
\"params\": [\n\ | ||
{\n\ | ||
\"data\": \"0x\",\n\ | ||
\"from\": \"0x8b6950bb8a74489a83e6a1281e3aa008f02bf368\",\n\ | ||
\"gasLimit\": \"0x5208\",\n\ | ||
\"gasPrice\": \"0x0f437c\",\n\ | ||
\"nonce\": \"0x4e\",\n\ | ||
\"to\": \"0x8b6950bb8a74489a83e6a1281e3aa008f02bf368\",\n\ | ||
\"value\": \"0x00\"\n\ | ||
}\n\ | ||
]\n\ | ||
}\n\ | ||
},\n\ | ||
\"topic\": \"3a9a320f8fc8e7a814895b148911373ba7df58c176ddca989f0e72ea1f9b8148\",\n\ | ||
\"verifyContext\": {\n\ | ||
\"verified\": {\n\ | ||
\"isScam\": false,\n\ | ||
\"origin\": \"https://react-app.walletconnect.com\",\n\ | ||
\"validation\": \"VALID\",\n\ | ||
\"verifyUrl\": \"https://verify.walletconnect.org\"\n\ | ||
}\n\ | ||
}\n\ | ||
}" | ||
ScrollView { | ||
SplitView.fillHeight: true | ||
SplitView.fillWidth: true | ||
TextArea { | ||
id: result | ||
text: "Result: " + JSON.stringify(SessionRequest.parse(JSON.parse(textEdit.text.replace(/\\n/g, "\n"))), undefined, 2) | ||
readOnly: true | ||
} | ||
} | ||
|
||
ColumnLayout { | ||
SplitView.fillHeight: true | ||
SplitView.fillWidth: true | ||
SplitView.preferredWidth: root.width / 2 | ||
Label { | ||
text: "Paste the event here to simulate the session request parsing" | ||
font.bold: true | ||
} | ||
Rectangle { | ||
Layout.fillWidth: true | ||
height: 2 | ||
color: "black" | ||
} | ||
TextArea { | ||
id: textEdit | ||
Layout.fillHeight: true | ||
Layout.fillWidth: true | ||
text: root.transaction | ||
onTextChanged: text = JSON.stringify(JSON.parse(text.replace(/\\/g, "")), undefined, 2) | ||
} | ||
ComboBox { | ||
id: comboBox | ||
Layout.fillWidth: true | ||
Layout.fillHeight: true | ||
model: ["sign", "transaction"] | ||
currentIndex: 0 | ||
onCurrentIndexChanged: textEdit.text = root[comboBox.currentText] | ||
} | ||
} | ||
} |
Oops, something went wrong.