Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(deps): bump @metamask/composable-controller from ^3.0.0 to ^6.0.2 #10011

83 changes: 69 additions & 14 deletions app/core/Engine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
NftDetectionController,
NftState,
TokenBalancesController,
TokenBalancesControllerEvents,
TokenDetectionController,
TokenListController,
TokenListState,
TokenListStateChange,
TokenRatesController,
TokenRatesState,
TokensController,
Expand All @@ -36,7 +36,11 @@
AddressBookController,
AddressBookState,
} from '@metamask/address-book-controller';
import { BaseState, ControllerMessenger } from '@metamask/base-controller';
import {
BaseState,
ControllerMessenger,
ControllerStateChangeEvent,
} from '@metamask/base-controller';
import { ComposableController } from '@metamask/composable-controller';
import {
KeyringController,
Expand Down Expand Up @@ -262,24 +266,40 @@
| CurrencyRateStateChange
| GasFeeStateChange
| KeyringControllerEvents
| TokenListStateChange
| NetworkControllerEvents
| PermissionControllerEvents
///: BEGIN:ONLY_INCLUDE_IF(snaps)
| SnapsGlobalEvents
///: END:ONLY_INCLUDE_IF
| SignatureControllerEvents
| KeyringControllerEvents
| PPOMControllerEvents
| AccountsControllerEvents
| PreferencesControllerEvents
| TokenBalancesControllerEvents
| TokenListControllerEvents
| TokensControllerEvents
| TokenListControllerEvents;
// TODO: Replace with `LoggingControllerEvents` once it's defined to include `LoggingControllerStateChangeEvent`
| ControllerStateChangeEvent<'LoggingController', LoggingControllerState>
// TODO: Replace with `NftControllerEvents` once it's defined to include `NftControllerStateChangeEvent`
| ControllerStateChangeEvent<
'NftController',
NftState & { [key: string]: Json }
>
// TODO: Replace with `PhishingControllerEvents` once it's defined to include `PhishingControllerStateChangeEvent`
| ControllerStateChangeEvent<'PhishingController', PhishingControllerState>
// TODO: `NetworkControllerStateChangeEvent` is already provided by `NetworkControllerEvents` and should be excluded from `PPOMControllerEvents`
| PPOMControllerEvents
// TODO: Remove once `PPOMControllerStateChangeEvent` is defined and is included in `PPOMControllerEvents`
| ControllerStateChangeEvent<'PPOMController', PPOMState>
// TODO: Replace with `TransactionControllerEvents` once it's defined to include `TransactionControllerStateChangeEvent`
| ControllerStateChangeEvent<
'TransactionController',
TransactionState & { [key: string]: Json }
>;

type PermissionsByRpcMethod = ReturnType<typeof getPermissionSpecifications>;
type Permissions = PermissionsByRpcMethod[keyof PermissionsByRpcMethod];

export interface EngineState {
export type EngineState = {
AccountTrackerController: AccountTrackerState;
AddressBookController: AddressBookState;
AssetsContractController: BaseState;
Expand Down Expand Up @@ -309,7 +329,7 @@
LoggingController: LoggingControllerState;
PPOMController: PPOMState;
AccountsController: AccountsControllerState;
}
};

/**
* All mobile controllers, keyed by name
Expand Down Expand Up @@ -377,7 +397,12 @@
/**
* ComposableController reference containing all child controllers
*/
datamodel: any;
datamodel: ComposableController<
EngineState,
// TODO: Remove once `BaseControllerV1Instance` type is updated in composable-controller
// @ts-expect-error Hotfix for mismatch between `Controllers` type properties and `BaseControllerV1Instance` type
Controllers[keyof Controllers],
>;

/**
* Object containing the info for the latest incoming tx block
Expand Down Expand Up @@ -1332,17 +1357,47 @@
}
}

this.datamodel = new ComposableController({
this.datamodel = new ComposableController<
EngineState,
// TODO: Remove once `BaseControllerV1Instance` type is updated in composable-controller
// @ts-expect-error Hotfix for mismatch between `Controllers` type properties and `BaseControllerV1Instance` type
Controllers[keyof Controllers],
>({
controllers,
messenger: this.controllerMessenger,
messenger: this.controllerMessenger.getRestricted({
name: 'ComposableController',
allowedActions: [],
// Add `stateChange` event here and in the `GlobalEvents` type
// whenever `messagingSystem` is added to a V1 child controller (or it is upgraded to V2)
allowedEvents: [
'AccountsController:stateChange',
'ApprovalController:stateChange',
'CurrencyRateController:stateChange',
'GasFeeController:stateChange',
'KeyringController:stateChange',
'LoggingController:stateChange',
'NetworkController:stateChange',
'NftController:stateChange',
'PermissionController:stateChange',
'PhishingController:stateChange',
'PreferencesController:stateChange',
'PPOMController:stateChange',
'TokenBalancesController:stateChange',
'TokenListController:stateChange',
'TokensController:stateChange',
'TransactionController:stateChange',
'SnapController:stateChange',
'SubjectMetadataController:stateChange',
],
}),
});
this.context = controllers.reduce<Partial<typeof this.context>>(
this.context = controllers.reduce<typeof this.context>(
(context, controller) => ({
...context,
[controller.name]: controller,
}),
{},
) as typeof this.context;
{} as never,
);

const {
NftController: nfts,
Expand Down Expand Up @@ -1781,9 +1836,9 @@
const modifiedCurrencyRateControllerState = {
...CurrencyRateController,
conversionRate:
CurrencyRateController.conversionRate === null

Check failure on line 1839 in app/core/Engine.ts

View workflow job for this annotation

GitHub Actions / scripts (lint:tsc)

Property 'conversionRate' does not exist on type 'CurrencyRateState'.
? 0
: CurrencyRateController.conversionRate,

Check failure on line 1841 in app/core/Engine.ts

View workflow job for this annotation

GitHub Actions / scripts (lint:tsc)

Property 'conversionRate' does not exist on type 'CurrencyRateState'.
};

return {
Expand Down
Loading