Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ linkStyle default opacity:0.5
earn_controller --> transaction_controller;
eip_5792_middleware --> transaction_controller;
eip_5792_middleware --> keyring_controller;
eip_7702_internal_rpc_middleware --> controller_utils;
eip1193_permission_middleware --> chain_agnostic_permission;
eip1193_permission_middleware --> controller_utils;
eip1193_permission_middleware --> json_rpc_engine;
Expand Down Expand Up @@ -336,6 +337,7 @@ linkStyle default opacity:0.5
transaction_controller --> remote_feature_flag_controller;
user_operation_controller --> base_controller;
user_operation_controller --> controller_utils;
user_operation_controller --> messenger;
user_operation_controller --> polling_controller;
user_operation_controller --> approval_controller;
user_operation_controller --> eth_block_tracker;
Expand Down
6 changes: 6 additions & 0 deletions packages/user-operation-controller/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** Use new `Messenger` from `@metamask/messenger` ([#6494](https://github.com/MetaMask/core/pull/6494))
- Previously, `UserOperationController` accepted a `RestrictedMessenger` instance from `@metamask/base-controller`.
- **BREAKING:** Metadata property `anonymous` renamed to `includeInDebugSnapshot` ([#6494](https://github.com/MetaMask/core/pull/6494))

## [39.2.1]

### Changed
Expand Down
1 change: 1 addition & 0 deletions packages/user-operation-controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"@metamask/base-controller": "^8.4.2",
"@metamask/controller-utils": "^11.14.1",
"@metamask/eth-query": "^4.0.0",
"@metamask/messenger": "^0.3.0",
"@metamask/polling-controller": "^14.0.2",
"@metamask/rpc-errors": "^7.0.2",
"@metamask/superstruct": "^3.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { deriveStateFromMetadata } from '@metamask/base-controller';
import { deriveStateFromMetadata } from '@metamask/base-controller/next';
import { ApprovalType } from '@metamask/controller-utils';
import { errorCodes } from '@metamask/rpc-errors';
import {
Expand Down Expand Up @@ -1453,7 +1453,7 @@ describe('UserOperationController', () => {
deriveStateFromMetadata(
controller.state,
controller.metadata,
'anonymous',
'includeInDebugSnapshot',
),
).toMatchInlineSnapshot(`Object {}`);
});
Expand Down
39 changes: 20 additions & 19 deletions packages/user-operation-controller/src/UserOperationController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ import type {
AddApprovalRequest,
AddResult,
} from '@metamask/approval-controller';
import type { RestrictedMessenger } from '@metamask/base-controller';
import { BaseController } from '@metamask/base-controller';
import {
BaseController,
type ControllerGetStateAction,
type ControllerStateChangeEvent,
} from '@metamask/base-controller/next';
import { ApprovalType } from '@metamask/controller-utils';
import EthQuery from '@metamask/eth-query';
import type { GasFeeState } from '@metamask/gas-fee-controller';
Expand All @@ -13,6 +16,7 @@ import type {
KeyringControllerPatchUserOperationAction,
KeyringControllerSignUserOperationAction,
} from '@metamask/keyring-controller';
import type { Messenger } from '@metamask/messenger';
import type {
NetworkControllerGetNetworkClientByIdAction,
Provider,
Expand All @@ -28,7 +32,6 @@ import { add0x } from '@metamask/utils';
// This package purposefully relies on Node's EventEmitter module.
// eslint-disable-next-line import-x/no-nodejs-modules
import EventEmitter from 'events';
import type { Patch } from 'immer';
import { cloneDeep } from 'lodash';
import { v1 as random } from 'uuid';

Expand Down Expand Up @@ -60,7 +63,7 @@ const stateMetadata = {
userOperations: {
includeInStateLogs: true,
persist: true,
anonymous: false,
includeInDebugSnapshot: false,
usedInUi: true,
},
};
Expand Down Expand Up @@ -102,15 +105,15 @@ export type UserOperationControllerState = {
userOperations: Record<string, UserOperationMetadata>;
};

export type GetUserOperationState = {
type: `${typeof controllerName}:getState`;
handler: () => UserOperationControllerState;
};
export type GetUserOperationState = ControllerGetStateAction<
typeof controllerName,
UserOperationControllerState
>;

export type UserOperationStateChange = {
type: `${typeof controllerName}:stateChange`;
payload: [UserOperationControllerState, Patch[]];
};
export type UserOperationStateChange = ControllerStateChangeEvent<
typeof controllerName,
UserOperationControllerState
>;

export type UserOperationControllerActions =
| GetUserOperationState
Expand All @@ -122,12 +125,10 @@ export type UserOperationControllerActions =

export type UserOperationControllerEvents = UserOperationStateChange;

export type UserOperationControllerMessenger = RestrictedMessenger<
export type UserOperationControllerMessenger = Messenger<
typeof controllerName,
UserOperationControllerActions,
UserOperationControllerEvents,
UserOperationControllerActions['type'],
UserOperationControllerEvents['type']
UserOperationControllerEvents
>;

export type UserOperationControllerOptions = {
Expand Down Expand Up @@ -339,7 +340,7 @@ export class UserOperationController extends BaseController<

const smartContractAccount =
requestSmartContractAccount ??
new SnapSmartContractAccount(this.messagingSystem);
new SnapSmartContractAccount(this.messenger);

const cache: UserOperationCache = {
chainId,
Expand Down Expand Up @@ -739,7 +740,7 @@ export class UserOperationController extends BaseController<
const type = ApprovalType.Transaction;
const requestData = { txId: id };

return (await this.messagingSystem.call(
return (await this.messenger.call(
'ApprovalController:addRequest',
{
id,
Expand Down Expand Up @@ -774,7 +775,7 @@ export class UserOperationController extends BaseController<
async #getProvider(
networkClientId: string,
): Promise<{ provider: Provider; chainId: string }> {
const { provider, configuration } = this.messagingSystem.call(
const { provider, configuration } = this.messenger.call(
'NetworkController:getNetworkClientById',
networkClientId,
);
Expand Down
3 changes: 3 additions & 0 deletions packages/user-operation-controller/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
},
{
"path": "../transaction-controller/tsconfig.build.json"
},
{
"path": "../messenger/tsconfig.build.json"
}
],
"include": ["../../types", "./src"]
Expand Down
3 changes: 3 additions & 0 deletions packages/user-operation-controller/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
},
{
"path": "../transaction-controller"
},
{
"path": "../messenger"
}
],
"include": ["../../types", "./src"]
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5052,6 +5052,7 @@ __metadata:
"@metamask/eth-query": "npm:^4.0.0"
"@metamask/gas-fee-controller": "npm:^24.1.1"
"@metamask/keyring-controller": "npm:^23.2.0"
"@metamask/messenger": "npm:^0.3.0"
"@metamask/network-controller": "npm:^24.3.1"
"@metamask/polling-controller": "npm:^14.0.2"
"@metamask/rpc-errors": "npm:^7.0.2"
Expand Down
Loading