Skip to content

Commit 9ea6b88

Browse files
MajorLiftmcmire
andauthored
Upgrade ComposableController to extend BaseControllerV2 (#3590)
## Explanation As part of the upcoming core wallet library initiative, we plan to migrate all controllers to `BaseControllerV2`. This commit upgrades `ComposableController`. ## References - Closes #2082 - See #1509 ## Changelog ### `@metamask/composable-controller` ## Added - Add types `ComposableControllerState`, `ComposableControllerStateChangeEvent`, `ComposableControllerEvents`, `ComposableControllerMessenger`. ## Changed - **BREAKING:** `ComposableController` is upgraded to extend `BaseControllerV2`. - The constructor now expects an options object with required properties `controllers` and `messenger` as its only argument. - `ComposableController` no longer has a `subscribe` method. Instead, listeners for `ComposableController` events must be registered to the controller messenger that generated the restricted messenger assigned to the instance's `messagingSystem` class field. - Any getters for `ComposableController` state that access the internal class field directly should be refactored to instead use listeners that are subscribed to `ComposableControllerStateChangeEvent`. ## 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 highlighted breaking changes using the "BREAKING" category above as appropriate --------- Co-authored-by: Ellilot Winkler <elliot.winkler@gmail.com>
1 parent dd0e83e commit 9ea6b88

File tree

5 files changed

+212
-190
lines changed

5 files changed

+212
-190
lines changed

packages/base-controller/src/BaseControllerV2.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,6 @@ export class BaseController<
113113

114114
public readonly metadata: StateMetadata<ControllerState>;
115115

116-
/**
117-
* The existence of the `subscribe` property is how the ComposableController detects whether a
118-
* controller extends the old BaseController or the new one. We set it to `undefined` here to
119-
* ensure the ComposableController never mistakes them for an older style controller.
120-
*/
121-
public readonly subscribe: undefined;
122-
123116
/**
124117
* Creates a BaseController instance.
125118
*

packages/composable-controller/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Add types `ComposableControllerState`, `ComposableControllerStateChangeEvent`, `ComposableControllerEvents`, `ComposableControllerMessenger` ([#3590](https://github.com/MetaMask/core/pull/3590))
10+
11+
### Changed
12+
- **BREAKING:** `ComposableController` is upgraded to extend `BaseControllerV2` ([#3590](https://github.com/MetaMask/core/pull/3590))
13+
- The constructor now expects an options object with required properties `controllers` and `messenger` as its only argument.
14+
- `ComposableController` no longer has a `subscribe` method. Instead, listeners for `ComposableController` events must be registered to the controller messenger that generated the restricted messenger assigned to the instance's `messagingSystem` class field.
15+
- Any getters for `ComposableController` state that access the internal class field directly should be refactored to instead use listeners that are subscribed to `ComposableControllerStateChangeEvent`.
816

917
## [4.0.0]
1018
### Changed

0 commit comments

Comments
 (0)