-
-
Notifications
You must be signed in to change notification settings - Fork 252
refactor: migrate ComposableController to @metamask/messenger
#6710
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
Merged
mikesposito
merged 18 commits into
main
from
mikesposito/messenger/composable-controller
Oct 27, 2025
Merged
refactor: migrate ComposableController to @metamask/messenger
#6710
mikesposito
merged 18 commits into
main
from
mikesposito/messenger/composable-controller
Oct 27, 2025
+390
−277
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 tasks
4 tasks
|
Resolving the type errors revealed this runtime breaking change in the unit tests: |
## Explanation <!-- Thanks for your contribution! Take a moment to answer these questions so that reviewers have the information they need to properly understand your changes: * What is the current state of things and why does it need to change? * What is the solution your changes offer and how does it work? * Are there any changes whose purpose might not obvious to those unfamiliar with the domain? * If your primary goal was to update one package but you found you had to update another one along the way, why did you do so? * If you had to upgrade a dependency, why did you do so? --> - Fix incompatibility of `ChildControllerStateChangeEvents` type with `BaseController` (when used in the `Events` type argument of `ComposableControllerMessenger`) by removing unnecessary nested logic from definition. - Update generic parameter names `ControllerName` and `ControllerState` to `ChildControllerName`, `ChildControllerState` for reduced ambiguity. ## References <!-- Are there any issues that this pull request is tied to? Are there other links that reviewers should consult to understand these changes better? Are there client or consumer pull requests to adopt any breaking changes? For example: * Fixes #12345 * Related to #67890 --> - Branches from #6710 ## Checklist - [ ] I've updated the test suite for new or updated code as appropriate - [ ] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [ ] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Simplifies `ChildControllerStateChangeEvents` and types the messenger `subscribe` call to fix `ComposableController` Messenger type errors; updates changelog. > > - **Composable Controller**: > - **Types**: Simplify `ChildControllerStateChangeEvents` by removing nested conditional logic and renaming generics to `ChildControllerName`/`ChildControllerState`. > - **Messenger**: Type the `subscribe` call for child `stateChange` events, updating composed state with the received child state (with an inline ts-expect-error to bypass an unnecessary overload constraint). > - **Docs**: > - Update `packages/composable-controller/CHANGELOG.md` with a Fixed entry describing the type compatibility change. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit b3444fb. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…/composable-controller
The test didn't actually rely upon subscriptions being setup correctly, so this mistake didn't impact the test result. It was only testing the constructor. The mistake has still been updated to avoid confusion.
cryptodev-2s
approved these changes
Oct 26, 2025
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.
LGTM!
Gudahtt
added a commit
that referenced
this pull request
Oct 27, 2025
The `INVALID_CONTROLLER_ERROR` error message incorrectly referenced the property name `messagingSystem`, which is no longer used in the next version of the `BaseController` class (which the `ComposableController` switched to in the PR `#6710). The error message was updated to no mention the messenger instance variable at all, since the check that triggered the error doesn't look for it anyway.
4 tasks
Gudahtt
added a commit
that referenced
this pull request
Oct 27, 2025
The `INVALID_CONTROLLER_ERROR` error message incorrectly referenced the property name `messagingSystem`, which is no longer used in the next version of the `BaseController` class (which the `ComposableController` switched to in the PR `#6710). The error message was updated to no mention the messenger instance variable at all, since the check that triggered the error doesn't look for it anyway.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 27, 2025
## Explanation The `INVALID_CONTROLLER_ERROR` error message incorrectly referenced the property name `messagingSystem`, which is no longer used in the next version of the `BaseController` class (which the `ComposableController` switched to in the PR #6710). The error message was updated to no mention the messenger instance variable at all, since the check that triggered the error doesn't look for it anyway. ## References Fixes minor error introduced by #6710 ## Checklist - [x] I've updated the test suite for new or updated code as appropriate - [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate - [x] I've communicated my changes to consumers by [updating changelogs for packages I've changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs), highlighting breaking changes as necessary - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Update `INVALID_CONTROLLER_ERROR` to remove obsolete `messagingSystem` reference, stating only that controllers must inherit from `BaseController`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 05b6cb3. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Explanation
References
Checklist
Note
Migrates
ComposableControllerto@metamask/messenger, updates types/metadata, rewrites tests, and updates dependencies and docs.RestrictedMessengertoMessenger(@metamask/messenger) and@metamask/base-controller/nextAPIs.ComposableControllerActions/GetState, refineChildControllerStateChangeEvents, and redefineComposableControllerMessengerto useMessenger.anonymousmetadata withincludeInDebugSnapshot; keeppersist,includeInStateLogs,usedInUi.messenger.subscribefor childstateChangeevents with error handling; minor cleanup.@metamask/messenger; update TS project references.composable_controller --> messenger; addeip_7702_internal_rpc_middleware --> controller_utilsin README mermaid graph.Written by Cursor Bugbot for commit 17e9041. This will update automatically on new commits. Configure here.