Skip to content

Commit cfdd5e7

Browse files
mikespositoMajorLiftcryptodev-2sGudahtt
authored
refactor: migrate ComposableController to @metamask/messenger (#6710)
## 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? --> ## 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 --> * Related to #5626 ## 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] > Migrates `ComposableController` to `@metamask/messenger`, updates types/metadata, rewrites tests, and updates dependencies and docs. > > - **@metamask/composable-controller**: > - Migrate from `RestrictedMessenger` to `Messenger` (`@metamask/messenger`) and `@metamask/base-controller/next` APIs. > - Update types: add `ComposableControllerActions/GetState`, refine `ChildControllerStateChangeEvents`, and redefine `ComposableControllerMessenger` to use `Messenger`. > - Replace `anonymous` metadata with `includeInDebugSnapshot`; keep `persist`, `includeInStateLogs`, `usedInUi`. > - Use `messenger.subscribe` for child `stateChange` events with error handling; minor cleanup. > - Tests: rewrite to new messenger API and delegation; add case for failed subscription; remove allowlist-dependent cases. > - Add dependency `@metamask/messenger`; update TS project references. > - Changelog: document breaking changes and a typing fix. > - **Docs/Graph**: > - Add `composable_controller --> messenger`; add `eip_7702_internal_rpc_middleware --> controller_utils` in README mermaid graph. > - **Tooling**: > - Adjust ESLint warning thresholds; update lockfile. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 17e9041. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Jongsun Suh <jongsun.suh@icloud.com> Co-authored-by: Salah-Eddine Saakoun <salah-eddine.saakoun@consensys.net> Co-authored-by: Mark Stacey <markjstacey@gmail.com>
1 parent 1860493 commit cfdd5e7

File tree

9 files changed

+389
-277
lines changed

9 files changed

+389
-277
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ linkStyle default opacity:0.5
207207
chain_agnostic_permission --> network_controller;
208208
chain_agnostic_permission --> permission_controller;
209209
composable_controller --> base_controller;
210+
composable_controller --> messenger;
210211
composable_controller --> json_rpc_engine;
211212
core_backend --> base_controller;
212213
core_backend --> controller_utils;

eslint-warning-thresholds.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,6 @@
107107
"packages/composable-controller/src/ComposableController.test.ts": {
108108
"import-x/namespace": 3
109109
},
110-
"packages/composable-controller/src/ComposableController.ts": {
111-
"@typescript-eslint/no-unused-vars": 1
112-
},
113110
"packages/controller-utils/jest.environment.js": {
114111
"n/prefer-global/text-encoder": 1,
115112
"n/prefer-global/text-decoder": 1,

packages/composable-controller/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- **BREAKING:** Migrate `ComposableController` to new `Messenger` from `@metamask/messenger` ([#6710](https://github.com/MetaMask/core/pull/6710))
13+
- Previously, the controller accepted a `RestrictedMessenger` instance from `@metamask/base-controller`.
14+
- **BREAKING:** Metadata property `anonymous` renamed to `includeInDebugSnapshot` ([#6710](https://github.com/MetaMask/core/pull/6710))
15+
16+
### Fixed
17+
18+
- Resolve incompatibility of `ChildControllerStateChangeEvents` type with `BaseController` (when used in the `Events` type argument of `ComposableControllerMessenger`) by removing unnecessary nested logic from definition ([#6904](https://github.com/MetaMask/core/pull/6904))
19+
- Also update generic parameter names `ControllerName` and `ControllerState` to `ChildControllerName`, `ChildControllerState` for reduced ambiguity.
20+
1021
## [11.1.1]
1122

1223
### Changed

packages/composable-controller/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"test:watch": "NODE_OPTIONS=--experimental-vm-modules jest --watch"
4848
},
4949
"dependencies": {
50-
"@metamask/base-controller": "^8.4.2"
50+
"@metamask/base-controller": "^8.4.2",
51+
"@metamask/messenger": "^0.3.0"
5152
},
5253
"devDependencies": {
5354
"@metamask/auto-changelog": "^3.4.4",

0 commit comments

Comments
 (0)