Skip to content

Commit

Permalink
Add logic for excluding non-controllers from child controllers passed…
Browse files Browse the repository at this point in the history
… into `ComposableController`
  • Loading branch information
MajorLift committed Aug 1, 2024
1 parent 36b966e commit fe6b8f8
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,13 @@ type RequiredControllers = Omit<Controllers, 'PPOMController'>;
*/
type OptionalControllers = Pick<Controllers, 'PPOMController'>;

type NonControllers = Pick<
Controllers,
| 'AssetsContractController'
| 'NftDetectionController'
| 'TokenDetectionController'
>;

/**
* Core controller responsible for composing other metamask controllers together
* and exposing convenience methods for common wallet operations.
Expand Down Expand Up @@ -1499,9 +1506,19 @@ class Engine {

this.datamodel = new ComposableController<
EngineState,
Controllers[keyof Controllers]
Controllers[Exclude<keyof Controllers, keyof NonControllers>]
>({
controllers,
controllers: controllers.filter(
(
controller,
): controller is Controllers[Exclude<
keyof Controllers,
keyof NonControllers
>] =>
'state' in controller &&
controller.state !== undefined &&
Object.keys(controller.state).length > 0,
),
messenger: this.controllerMessenger.getRestricted({
name: 'ComposableController',
allowedActions: [],
Expand Down

0 comments on commit fe6b8f8

Please sign in to comment.