Skip to content

feat!: Use StorageService to store source code#3777

Merged
GuillaumeRx merged 22 commits intomainfrom
gr/storage-service
Feb 3, 2026
Merged

feat!: Use StorageService to store source code#3777
GuillaumeRx merged 22 commits intomainfrom
gr/storage-service

Conversation

@GuillaumeRx
Copy link
Contributor

@GuillaumeRx GuillaumeRx commented Dec 16, 2025

This PR adds the use of StorageService to store the Snap source codes.

Changes

  • SnapController:

    • Remove sourceCode from controller's state
    • Move sourceCode to StorageService
    • Add utils functions to set/remove and clear the controller's storage in StorageService
    • Add a new controllerSetup promise that resolves when the controller has finished initialization
    • Make init() async and handle the pre-installed snaps setup inside
  • SnapController tests and test utils:

    • Default the PermissionController:hasPermission to false in order to avoid trying to call lifecycle hooks and throwing an error when calling init. This is due to the fact that PermissionController:hasPermission would return true but PermissionController:getPermissions would not return the correct handler endowment.
    • Refactor getSnapController to an asynchronous function that calls init() and wait for it to finish. That makes sure we don't have any race conditions or side effects when instantiating a controller in the tests.
    • Initialize the StorageService inside getSnapController() to hydrate the storage service with the relevant snap source code
    • Make getSnapControllerOptions() take the rootMessenger in its parameter to allow the creation of the StorageService. That means that in the tests we now retrieve the SnapController's messenger from getSnapControllerOptions()

Note

Low Risk
Low risk dependency-only change; runtime behavior is unchanged unless downstream code begins importing or relying on @metamask/storage-service.

Overview
Adds @metamask/storage-service as a new dependency of @metamask/snaps-controllers via package.json, enabling the package to compile/link against the storage service library.

Written by Cursor Bugbot for commit fdb0378. This will update automatically on new commits. Configure here.

@socket-security
Copy link

socket-security bot commented Dec 16, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​storage-service@​1.0.010010010090100

View full report

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.47%. Comparing base (d47ac3c) to head (fdb0378).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3777   +/-   ##
=======================================
  Coverage   98.46%   98.47%           
=======================================
  Files         429      429           
  Lines       12399    12421   +22     
  Branches     1923     1924    +1     
=======================================
+ Hits        12209    12231   +22     
  Misses        190      190           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Mrtenz
Mrtenz previously requested changes Jan 21, 2026
@GuillaumeRx GuillaumeRx requested a review from Mrtenz January 21, 2026 10:38
@GuillaumeRx GuillaumeRx marked this pull request as ready for review January 21, 2026 11:16
@GuillaumeRx GuillaumeRx requested a review from a team as a code owner January 21, 2026 11:16
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

@GuillaumeRx GuillaumeRx enabled auto-merge February 3, 2026 11:27
@GuillaumeRx GuillaumeRx added this pull request to the merge queue Feb 3, 2026
Merged via the queue into main with commit ce80114 Feb 3, 2026
128 checks passed
@GuillaumeRx GuillaumeRx deleted the gr/storage-service branch February 3, 2026 11:53
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.

3 participants