@@ -462,22 +462,6 @@ type Controllers = {
462
462
SwapsController : SwapsController ;
463
463
} ;
464
464
465
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
466
- type NonControllers = {
467
- AssetsContractController : AssetsContractController ;
468
- NftDetectionController : NftDetectionController ;
469
- TokenDetectionController : TokenDetectionController ;
470
- } ;
471
-
472
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
473
- type NonControllerNames = keyof NonControllers ;
474
-
475
- const NONCONTROLLER_NAMES = [
476
- 'AssetsContractController' ,
477
- 'NftDetectionController' ,
478
- 'TokenDetectionController' ,
479
- ] as const ;
480
-
481
465
/**
482
466
* Controllers that area always instantiated
483
467
*/
@@ -488,6 +472,24 @@ type RequiredControllers = Omit<Controllers, 'PPOMController'>;
488
472
*/
489
473
type OptionalControllers = Pick < Controllers , 'PPOMController' > ;
490
474
475
+ /**
476
+ * Messageable modules that are part of the Engine's context, but are not defined with state.
477
+ * TODO: Replace with type guard once consistent inheritance for non-controllers is implemented. See: https://github.com/MetaMask/decisions/pull/41
478
+ */
479
+ const STATELESS_NON_CONTROLLER_NAMES = [
480
+ 'AssetsContractController' ,
481
+ 'NftDetectionController' ,
482
+ 'TokenDetectionController' ,
483
+ ] as const ;
484
+
485
+ /**
486
+ * Controllers that are defined with state.
487
+ */
488
+ type StatefulControllers = Omit <
489
+ Controllers ,
490
+ ( typeof STATELESS_NON_CONTROLLER_NAMES ) [ number ]
491
+ > ;
492
+
491
493
/**
492
494
* Combines required and optional controllers for the Engine context type.
493
495
*/
@@ -530,7 +532,7 @@ export class Engine {
530
532
*/
531
533
datamodel : ComposableController <
532
534
EngineState ,
533
- Exclude < Controllers [ keyof Controllers ] , NonControllers [ NonControllerNames ] >
535
+ StatefulControllers [ keyof StatefulControllers ]
534
536
> ;
535
537
536
538
/**
@@ -1780,18 +1782,15 @@ export class Engine {
1780
1782
1781
1783
this . datamodel = new ComposableController <
1782
1784
EngineState ,
1783
- Exclude <
1784
- Controllers [ keyof Controllers ] ,
1785
- NonControllers [ keyof NonControllers ]
1786
- >
1785
+ StatefulControllers [ keyof StatefulControllers ]
1787
1786
> ( {
1788
1787
controllers : controllers . filter (
1789
1788
(
1790
1789
controller ,
1791
- ) : controller is Exclude <
1792
- Controllers [ keyof Controllers ] ,
1793
- NonControllers [ keyof NonControllers ]
1794
- > => ! NONCONTROLLER_NAMES . find ( ( name ) => name === controller . name ) ,
1790
+ ) : controller is StatefulControllers [ keyof StatefulControllers ] =>
1791
+ ! STATELESS_NON_CONTROLLER_NAMES . find (
1792
+ ( name ) => name === controller . name ,
1793
+ ) ,
1795
1794
) ,
1796
1795
messenger : this . controllerMessenger . getRestricted ( {
1797
1796
name : 'ComposableController' ,
0 commit comments