Skip to content

Conversation

@FrederikBolding
Copy link
Member

@FrederikBolding FrederikBolding commented Aug 26, 2025

Closes #3315.


Note

Replaces RestrictedMessenger with @metamask/messenger across packages, renames metadata flag, and updates deps/tests and controller wiring with breaking API changes.

  • Core refactor (breaking):
    • Replace RestrictedMessenger with @metamask/messenger Messenger across snaps-controllers, snaps-rpc-methods, snaps-simulation, and snaps-utils.
    • Rename metadata anonymous to includeInDebugSnapshot in controllers; update persistence and debug snapshot handling.
    • Switch all messagingSystem.* calls to messenger.* (subscribe, unsubscribe, registerActionHandler, call, publish).
    • Update controller constructor types and exported messengers (e.g., CronjobControllerMessenger, SnapInsightsControllerMessenger, SnapInterfaceControllerMessenger, MultichainRouterMessenger, ExecutionServiceMessenger, WebSocketServiceMessenger).
    • snaps-rpc-methods: handleSnapInstall now takes messenger (was messagingSystem).
    • Export WithSnapKeyringFunction from MultichainRouter.
  • Dependency updates:
    • Bump @metamask/approval-controller^8.0.0, @metamask/base-controller^9.0.0, @metamask/permission-controller^12.0.0; add @metamask/messenger where needed; remove @metamask/base-controller in some packages.
  • Tests and mocks:
    • Update test utilities to use Messenger delegation; adapt expectations from rootMessenger.call to controllerMessenger.call.
    • Adjust mocks/enums (e.g., PhishingDetectorResultType), add JSON-RPC id/jsonrpc fields, and origin constants.
  • Misc:
    • Minor API and typing tweaks (e.g., persistence via deriveStateFromMetadata, WebSocket mock fixes).

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

@FrederikBolding FrederikBolding force-pushed the fb/base-controller-migration branch 2 times, most recently from 293ddb4 to 88d1ae4 Compare September 2, 2025 10:31
@Mrtenz Mrtenz force-pushed the fb/base-controller-migration branch 2 times, most recently from c4e0f41 to d22006d Compare September 5, 2025 12:14
@Mrtenz Mrtenz changed the title wip: base controller migration refactor: base controller migration Sep 8, 2025
@codecov
Copy link

codecov bot commented Sep 8, 2025

Codecov Report

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

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3611      +/-   ##
==========================================
- Coverage   98.29%   98.28%   -0.02%     
==========================================
  Files         417      418       +1     
  Lines       11925    12152     +227     
  Branches     1851     1876      +25     
==========================================
+ Hits        11722    11943     +221     
- Misses        203      209       +6     

☔ 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.

@FrederikBolding FrederikBolding force-pushed the fb/base-controller-migration branch from fea5048 to e3e359b Compare October 23, 2025 13:31
@mikesposito
Copy link
Member

@metamaskbot publish-previews

1 similar comment
@Gudahtt
Copy link
Member

Gudahtt commented Oct 23, 2025

@metamaskbot publish-previews

@cryptodev-2s cryptodev-2s force-pushed the fb/base-controller-migration branch from 6992e4e to 6ccfe09 Compare October 26, 2025 19:28
@cryptodev-2s cryptodev-2s marked this pull request as ready for review October 27, 2025 20:58
@cryptodev-2s cryptodev-2s requested a review from a team as a code owner October 27, 2025 20:58
@socket-security
Copy link

socket-security bot commented Oct 27, 2025

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updated@​metamask/​approval-controller@​7.2.0 ⏵ 8.0.01001007693 +6100
Updated@​metamask/​permission-controller@​11.0.6 ⏵ 12.0.09910079 +193 +10100

View full report

Mrtenz
Mrtenz previously approved these changes Oct 27, 2025
export type RootControllerAllowedEvents =
SnapInterfaceControllerStateChangeEvent;

export type RootControllerMessenger = Messenger<
Copy link
Member

Choose a reason for hiding this comment

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

This is odd. What is this type used for?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is meant as a type for https://github.com/MetaMask/snaps/blob/fb/base-controller-migration/packages/snaps-simulation/src/simulation.ts#L362 which we pass around to be used in the snaps-jest framework.

Copy link
Member Author

Choose a reason for hiding this comment

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

May have been written before we had MockAnyNamespace

Copy link
Member

Choose a reason for hiding this comment

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

Ah OK. I was asking because we introduced another use of any here, which our guidelines generally forbid the use of.

We should be able to get rid of all of the any instances we've introduced here, but we can figure that out later. It would also be nice to get rid of this export if we don't need it anymore.

@cryptodev-2s cryptodev-2s added this pull request to the merge queue Oct 27, 2025
Merged via the queue into main with commit 7baa5d9 Oct 27, 2025
341 of 346 checks passed
@cryptodev-2s cryptodev-2s deleted the fb/base-controller-migration branch October 27, 2025 22:14
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.

Replace RestrictedMessenger with delegated Messenger

6 participants