-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Remove Snap accounts even if the snap is disabled #21087
Conversation
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. |
Updated dependencies detected. Learn more about Socket for GitHub ↗︎
|
Builds ready [684da5c]
Page Load Metrics (1071 ± 348 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## develop #21087 +/- ##
===========================================
- Coverage 68.43% 68.41% -0.02%
===========================================
Files 1012 1012
Lines 40507 40508 +1
Branches 10826 10823 -3
===========================================
- Hits 27718 27710 -8
- Misses 12789 12798 +9
☔ View full report in Codecov by Sentry. |
5c325aa
to
1417058
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.
I didn't run the client but the code LGTM
1417058
to
79b6e5c
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.
Currently, when removing a snap, we send a listAccounts request to the snap to obtain the list of accounts it owns, then we proceed to remove them one by one. However, if the snap is disabled, we cannot retrieve this list and an error is thrown, blocking the snap removal. This PR resolves this issue by retrieving the list of accounts from the SnapKeyring instead of calling the snap. By doing so, it also addresses another bug: the source of truth about the accounts managed by a snap should be the SnapKeyring rather than the snap itself. This is because the snap could potentially spoof addresses owned by other keyrings, leading to their inadvertent removal.
79b6e5c
to
6b307df
Compare
* @param snapId - Snap ID to get accounts for. | ||
* @returns The addresses of the accounts. | ||
*/ | ||
export const getAccountsBySnapId = async (controller: any, snapId: 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.
Can this be typed?
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.
I just pushed a commit to address this with better types.
I added better types to the |
Builds ready [1754e47]
Page Load Metrics (872 ± 372 ms)
Bundle size diffs
|
Description
Currently, when removing a snap, we send a
listAccounts
request to the snap to obtain the list of accounts it owns, then we proceed to remove them one by one. However, if the snap is disabled, we cannot retrieve this list and an error is thrown, blocking the snap removal.This PR resolves this issue by retrieving the list of accounts from the
SnapKeyring
instead of calling the snap. By doing so, it also addresses another bug: the source of truth about the accounts managed by a snap should be theSnapKeyring
rather than the snap itself. This is because the snap could potentially spoof addresses owned by other keyrings, leading to their inadvertent removal.Fixes: https://github.com/MetaMask/accounts-planning/issues/55
Depends on: #20684
Manual testing steps
Install Flask, and onboard a SRP or create a new one.
Install the SSK.
Create 2 accounts using the SSK.
Go to "Settings" > "Snaps" > "MetaMask Simple Keyring Snap".
Disabled the snap.
Click on "Remove MetaMask SSK".
Confirm by clicking on "Remove Snap".
The snap should have been removed.
Check the console of the extension, you should see the following logs:
Screenshots/Recordings
Screen.Recording.2023-09-28.at.12.44.40.mov
Pre-merge author checklist
Pre-merge reviewer checklist