Skip to content
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

Move snap_manageAccounts to a gated permitted method #2869

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

GuillaumeRx
Copy link
Contributor

@GuillaumeRx GuillaumeRx commented Oct 31, 2024

This PR moves the snap_manageAccounts method from a restricted method to a permitted method.

This allows us to couple it with the Keyring endowment. The implementation checks if the snap has the permission to use the Keyring and throws if not.

This also refactors how the message is passed to the snap. The keyring will now be retrieved on the hook implementation and we will only expose a mutated version of handleKeyringSnapMessage where we will bind the origin coming from the RPC engine to the method hook. This ensures we don't manipulate the origin inside the method implementation.

Fixes: #2798

@GuillaumeRx GuillaumeRx requested a review from a team as a code owner October 31, 2024 11:43
@Mrtenz
Copy link
Member

Mrtenz commented Oct 31, 2024

I don't think we can do this without a breaking change. Snaps may still request the permission which will no longer exist, and it also exists in the permission controller state for existing Snaps.

@GuillaumeRx
Copy link
Contributor Author

I don't think we can do this without a breaking change. Snaps may still request the permission which will no longer exist, and it also exists in the permission controller state for existing Snaps.

@Mrtenz I'm working on a migration on the extension side and a fix in the snap side :) This should probably be a draft.

@Mrtenz Mrtenz marked this pull request as draft October 31, 2024 13:21
@GuillaumeRx GuillaumeRx force-pushed the gr/couple-manage-accounts-keyring branch from c2a0010 to d781570 Compare November 22, 2024 11:13
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.57%. Comparing base (45db6e7) to head (3543200).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2869      +/-   ##
==========================================
+ Coverage   94.48%   94.57%   +0.09%     
==========================================
  Files         487      487              
  Lines       10427    10442      +15     
  Branches     1598     1600       +2     
==========================================
+ Hits         9852     9876      +24     
+ Misses        575      566       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Couple snap_manageAccounts to endowment:keyring
2 participants