feat: sdk permissions system integration
Description
Changes to include permissions system within sdk workflows (js + android). WalletConnect will require a separate PR and migrate away from persisting connection in DefaultPreferences.
- new connection modal flow (allow multiple account selection)
- new sessions management ui
Design: https://www.figma.com/file/piME5CaTYUz07Gc7Ye7c22/Deeplinking--SDK?type=design&node-id=1633-2285&mode=design&t=egikpsEVgt3xcMNg-0
https://app.zenhub.com/workspaces/metamask-mobile-5f984938ddc0e4001d4b79cb/issues/gh/metamask/mobile-planning/868
- added online indication in connection list
Related issues
Fixes:
Manual testing steps
- See QA comments
Screenshots/Recordings
Before
After
Pre-merge author checklist
- [x] I’ve followed MetaMask Coding Standards.
- [x] I've clearly explained what problem this PR is solving and how it is solved.
- [x] I've linked related issues
- [x] I've included manual testing steps
- [x] I've included screenshots/recordings if applicable
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using JSDoc format if applicable
- [x] I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
- [x] I’ve properly set the pull request status:
- [x] In case it's not yet "ready for review", I've set it to "draft".
- [x] In case it's "ready for review", I've changed it from "draft" to "non-draft".
Pre-merge reviewer checklist
- [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.
E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/b989d065-bb5f-4484-810e-522bce54a6cf You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label
Codecov Report
Attention: Patch coverage is 21.07280% with 206 lines in your changes are missing coverage. Please review.
Project coverage is 41.35%. Comparing base (
e9a1442) to head (05cf76c). Report is 1 commits behind head on main.
Additional details and impacted files
@@ Coverage Diff @@
## main #8531 +/- ##
==========================================
- Coverage 41.54% 41.35% -0.19%
==========================================
Files 1268 1271 +3
Lines 30664 30804 +140
Branches 3011 3028 +17
==========================================
+ Hits 12738 12740 +2
- Misses 17172 17304 +132
- Partials 754 760 +6
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Important notes:
- Permission system on WalletConnect has been left aside for a second stage so for the scope of this PR it was verified that the way a user connects to a WalletConnet dapp remains the same
- A bug was found on the WalletConnect integration related to the accountsSync on
metamask_accountsChangedafter a rebase with main. Before merging it was verified that the issue is present on main and the root cause was not this PR (see video 1 below) - For the SDK context, developers usually refer to
ethereum.selectedAddressso both the funcionality ofwallet_getPermissionsand the normal functionality of updating theethereum.selectedAddresswere checked - On this first stage, the "Manage Connections" screen in MetaMask (security & privacy) only contemplates the removal of: A single dapp connection; Removal of one account from a connection|; Removal of all connections from all dapps
Video 1 (a new issue will be created with it) https://github.com/MetaMask/metamask-mobile/issues/8706:
https://github.com/MetaMask/metamask-mobile/assets/104831203/4a16a109-7700-4fc6-8a74-06f27f83f4d5
Error:
ERROR {"context": "client"} No matching key. session: 45e54d0244a9670d8d918f2f523bf2ec7bd7d468175cb841fb26c5b07d46fc92
WARN WC2::updateSession can't update session topic=45e54d0244a9670d8d918f2f523bf2ec7bd7d468175cb841fb26c5b07d46fc92 [Error: No matching key. session: 45e54d0244a9670d8d918f2f523bf2ec7bd7d468175cb841fb26c5b07d46fc92]
Dapps and platforms used for testing:
- Android SDK native dapp
- WalletConnect
- iOS SDK
- JS SDK: mix between node, reactNative and webdapp
Test Cases Connect one account
- Open dapp
- connect 1 account
- dapp gets 1 account
- Switching to an account without permissions does not sync the account to the dapp
Connect multiple accounts
- open dapp
- connect multiple accounts
- dapp gets the list of approved accounts
- switching to an account with permissions
- selectedAddress is changed to the selected one
- signing from dapp promps a sign to the selected address that should be the one selected on the wallet side
Explore permissions
- Open dapp
- connect multiple accounts
- dapp gets the list of approved accounts
- switching to an account without persmissions
- selected address remains the same
- signing prompts to sign with the selected address (not the one selected in the wallet) ->
ethereum.selectedAddress
Update permissions
- open dapp
- connect 2 accounts
- call requestPermissions
- remove the permission to one of the accounts
- Dapp gets the updated accounts. The account that was removed is not showing
WalletConnect
- Open a WC2 dapp
- connect one or more accounts
- selectedAddress becomes accounts[0]
- The behaviour of the WC Dapp remains the same as it was
Manage Connections screen
https://github.com/MetaMask/metamask-mobile/assets/104831203/acec7460-60be-46d1-a293-c4e9361e0643
JS Overview (QR Code)
https://github.com/MetaMask/metamask-mobile/assets/104831203/62302032-9a94-4a31-9096-daf190d6f475
JS Connection (deeplink)
https://github.com/MetaMask/metamask-mobile/assets/104831203/df177c93-2b78-4ac8-af0d-7cc3acb6a39b
WalletConnect
https://github.com/MetaMask/metamask-mobile/assets/104831203/1b586258-d945-4700-8fa6-cd65f0af0e34
Quality Gate passed
Issues
4 New issues
Measures
0 Security Hotspots
14.5% Coverage on New Code
2.9% Duplication on New Code