References
Motivation
The ComposableController API is currently not working as expected in downstream consumers (mobile).
Explanation
- The
BaseControllerV1Instance type needs to be fixed to accommodate controller versions used in mobile that inherit from BaseControllerV1.
Type 'PhishingController | AccountsController | AccountTrackerController | AddressBookController | ... 22 more ... | SwapsController' does not satisfy the constraint 'ControllerInstance'.
Type 'AccountTrackerController' is not assignable to type 'ControllerInstance'.
Type 'AccountTrackerController' is not assignable to type 'BaseControllerV1Instance'.
Types have separate declarations of a private property 'initialConfig'.ts(2344)
- The
ChildControllers optional generic parameter should either be converted into a required parameter, or annotated in jsdoc to make it clear that a full list of controllers can be supplied by the consumer as a type argument.
- Fix
LegacyComposableControllerStateConstraint to { [name: string]: Record<any, any> }, since index signature of interface types used for V1 state objects is not fixed to string.
- Test on mobile engine whether runtime checks
isBaseController() and isBaseControllerV1() are functioning as intended.
References
@metamask/composable-controllerfrom^3.0.0to^6.0.2metamask-mobile#10011Motivation
The
ComposableControllerAPI is currently not working as expected in downstream consumers (mobile).Explanation
BaseControllerV1Instancetype needs to be fixed to accommodate controller versions used in mobile that inherit fromBaseControllerV1.ChildControllersoptional generic parameter should either be converted into a required parameter, or annotated in jsdoc to make it clear that a full list of controllers can be supplied by the consumer as a type argument.LegacyComposableControllerStateConstraintto{ [name: string]: Record<any, any> }, since index signature ofinterfacetypes used for V1 state objects is not fixed tostring.isBaseController()andisBaseControllerV1()are functioning as intended.