Skip to content
Open
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
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
"changelog:validate": "yarn workspaces foreach --all --parallel --interlaced --verbose run changelog:validate",
"child-workspace-package-names-as-json": "ts-node scripts/child-workspace-package-names-as-json.ts",
"clean": "yarn workspaces foreach --all --parallel --verbose run clean",
"generate-method-action-types": "yarn workspaces foreach --all --parallel --interlaced --verbose run generate-method-action-types",
"get-release-tag": "ts-node --swc scripts/get-release-tag.ts",
"install-chrome": "./scripts/install-chrome.sh",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:tsconfig && yarn constraints && yarn lint:dependencies",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn lint:tsconfig && yarn constraints && yarn lint:dependencies && yarn generate-method-action-types --check",
"lint:dependencies": "yarn workspaces foreach --all --parallel --verbose run lint:dependencies && yarn dedupe --check",
"lint:eslint": "eslint . --cache",
"lint:fix": "yarn workspaces foreach --all --parallel run lint:eslint --fix && yarn lint:misc --write && yarn lint:tsconfig && yarn constraints --fix && yarn dedupe",
Expand Down Expand Up @@ -120,7 +121,8 @@
"tsx": "^4.20.3",
"typescript": "~5.3.3",
"typescript-eslint": "^8.6.0",
"vite": "^6.4.1"
"vite": "^6.4.1",
"yargs": "^17.7.1"
},
"packageManager": "yarn@4.10.3",
"engines": {
Expand Down
48 changes: 48 additions & 0 deletions packages/snaps-controllers/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,54 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- **BREAKING:** All `SnapController` action types were renamed from `DoSomething` to `SnapControllerDoSomethingAction` ([#3907](https://github.com/MetaMask/snaps/pull/3907))
- `GetSnap` is now `SnapControllerGetSnapAction`.
- Note: The method is now called `getSnap` instead of `get`.
- `HandleSnapRequest` is now `SnapControllerHandleRequestAction`.
- `GetSnapState` is now `SnapControllerGetSnapStateAction`.
- `HasSnap` is now `SnapControllerHasSnapAction`.
- Note: The method is now called `hasSnap` instead of `has`.
- `UpdateSnapState` is now `SnapControllerUpdateSnapStateAction`.
- `ClearSnapState` is now `SnapControllerClearSnapStateAction`.
- `UpdateRegistry` is now `SnapControllerUpdateRegistryAction`.
- `EnableSnap` is now `SnapControllerEnableSnapAction`.
- Note: The method is now called `enableSnap` instead of `enable`.
- `DisableSnap` is now `SnapControllerDisableSnapAction`.
- Note: The method is now called `disableSnap` instead of `disable`.
- `RemoveSnap` is now `SnapControllerRemoveSnapAction`.
- Note: The method is now called `removeSnap` instead of `remove`.
- `GetPermittedSnaps` is now `SnapControllerGetPermittedSnapsAction`.
- Note: The method is now called `getPermittedSnaps` instead of `getPermitted`.
- `GetAllSnaps` is now `SnapControllerGetAllSnapsAction`.
- Note: The method is now called `getAllSnaps` instead of `getAll`.
- `GetRunnableSnaps` is now `SnapControllerGetRunnableSnapsAction`.
- `StopAllSnaps` is now `SnapControllerStopAllSnapsAction`.
- `IncrementActiveReferences` is now `SnapControllerIncrementActiveReferencesAction`.
- `DecrementActiveReferences` is now `SnapControllerDecrementActiveReferencesAction`.
- `InstallSnaps` is now `SnapControllerInstallSnapsAction`.
- Note: The method is now called `installSnaps` instead of `install`.
- `DisconnectOrigin` is now `SnapControllerDisconnectOriginAction`.
- Note: The method is now called `disconnectOrigin` instead of `removeSnapFromSubject`.
- `RevokeDynamicPermissions` is now `SnapControllerRevokeDynamicSnapPermissionsAction`.
- `GetSnapFile` is now `SnapControllerGetSnapFileAction`.
- `IsMinimumPlatformVersion` is now `SnapControllerIsMinimumPlatformVersionAction`.
- `SetClientActive` is now `SnapControllerSetClientActiveAction`.
- **BREAKING:** All `SnapController` event types were renamed from `OnSomething` to `SnapControllerOnSomethingEvent` ([#3907](https://github.com/MetaMask/snaps/pull/3907))
- `SnapStateChange` was removed in favour of `SnapControllerStateChangeEvent`.
- `SnapBlocked` is now `SnapControllerSnapBlockedEvent`.
- `SnapInstallStarted` is now `SnapControllerSnapInstallStartedEvent`.
- `SnapInstallFailed` is now `SnapControllerSnapInstallFailedEvent`.
- `SnapInstalled` is now `SnapControllerSnapInstalledEvent`.
- `SnapUninstalled` is now `SnapControllerSnapUninstalledEvent`.
- `SnapUnblocked` is now `SnapControllerSnapUnblockedEvent.
- `SnapUpdated` is now `SnapControllerSnapUpdatedEvent`.
- `SnapRolledback` is now `SnapControllerSnapRolledbackEvent`.
- `SnapTerminated` is now `SnapControllerSnapTerminatedEvent`.
- `SnapEnabled` is now `SnapControllerSnapEnabledEvent`.
- `SnapDisabled` is now `SnapControllerSnapDisabledEvent`.

## [18.0.4]

### Fixed
Expand Down
1 change: 1 addition & 0 deletions packages/snaps-controllers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
"changelog:update": "../../scripts/update-changelog.sh @metamask/snaps-controllers",
"changelog:validate": "../../scripts/validate-changelog.sh @metamask/snaps-controllers",
"generate-method-action-types": "tsx ../../scripts/generate-method-action-types.mts",
"lint": "yarn lint:eslint && yarn lint:misc --check && yarn changelog:validate && yarn lint:dependencies",
"lint:ci": "yarn lint",
"lint:dependencies": "depcheck",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@ describe('CronjobController', () => {
deriveStateFromMetadata(
controller.state,
controller.metadata,
'anonymous',
'includeInDebugSnapshot',
),
).toMatchInlineSnapshot(`{}`);
});
Expand Down
27 changes: 14 additions & 13 deletions packages/snaps-controllers/src/cronjob/CronjobController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,21 @@ import { nanoid } from 'nanoid';

import { getCronjobSpecificationSchedule, getExecutionDate } from './utils';
import type {
HandleSnapRequest,
SnapDisabled,
SnapEnabled,
SnapInstalled,
SnapUninstalled,
SnapUpdated,
} from '..';
SnapControllerHandleRequestAction,
SnapControllerSnapDisabledEvent,
SnapControllerSnapEnabledEvent,
SnapControllerSnapInstalledEvent,
SnapControllerSnapUninstalledEvent,
SnapControllerSnapUpdatedEvent,
} from '../snaps';
import { METAMASK_ORIGIN } from '../snaps/constants';
import { Timer } from '../snaps/Timer';

export type CronjobControllerGetStateAction = ControllerGetStateAction<
typeof controllerName,
CronjobControllerState
>;

export type CronjobControllerStateChangeEvent = ControllerStateChangeEvent<
typeof controllerName,
CronjobControllerState
Expand Down Expand Up @@ -68,7 +69,7 @@ export type Get = {

export type CronjobControllerActions =
| CronjobControllerGetStateAction
| HandleSnapRequest
| SnapControllerHandleRequestAction
| GetPermissions
| Schedule
| Cancel
Expand All @@ -77,11 +78,11 @@ export type CronjobControllerActions =

export type CronjobControllerEvents =
| CronjobControllerStateChangeEvent
| SnapInstalled
| SnapUninstalled
| SnapUpdated
| SnapEnabled
| SnapDisabled;
| SnapControllerSnapInstalledEvent
| SnapControllerSnapUninstalledEvent
| SnapControllerSnapUpdatedEvent
| SnapControllerSnapEnabledEvent
| SnapControllerSnapDisabledEvent;

export type CronjobControllerMessenger = Messenger<
typeof controllerName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('SnapInsightsController', () => {
},
);

rootMessenger.registerActionHandler('SnapController:getAll', () => {
rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => {
return [getTruncatedSnap(), getTruncatedSnap({ id: MOCK_LOCAL_SNAP_ID })];
});

Expand Down Expand Up @@ -157,7 +157,7 @@ describe('SnapInsightsController', () => {
},
);

rootMessenger.registerActionHandler('SnapController:getAll', () => {
rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => {
return [getTruncatedSnap(), getTruncatedSnap({ id: MOCK_LOCAL_SNAP_ID })];
});

Expand Down Expand Up @@ -285,7 +285,7 @@ describe('SnapInsightsController', () => {
messenger: controllerMessenger,
});

rootMessenger.registerActionHandler('SnapController:getAll', () => {
rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => {
return [getTruncatedSnap(), getTruncatedSnap({ id: MOCK_LOCAL_SNAP_ID })];
});

Expand Down Expand Up @@ -388,7 +388,7 @@ describe('SnapInsightsController', () => {
messenger: controllerMessenger,
});

rootMessenger.registerActionHandler('SnapController:getAll', () => {
rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => {
return [getTruncatedSnap(), getTruncatedSnap({ id: MOCK_LOCAL_SNAP_ID })];
});

Expand Down Expand Up @@ -456,7 +456,7 @@ describe('SnapInsightsController', () => {
it('ignores insight if transaction has already been signed', async () => {
const rootMessenger = getRootSnapInsightsControllerMessenger();

rootMessenger.registerActionHandler('SnapController:getAll', () => {
rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => {
return [getTruncatedSnap(), getTruncatedSnap({ id: MOCK_LOCAL_SNAP_ID })];
});

Expand Down Expand Up @@ -556,7 +556,7 @@ describe('SnapInsightsController', () => {
messenger: controllerMessenger,
});

rootMessenger.registerActionHandler('SnapController:getAll', () => {
rootMessenger.registerActionHandler('SnapController:getAllSnaps', () => {
return [getTruncatedSnap(), getTruncatedSnap({ id: MOCK_LOCAL_SNAP_ID })];
});

Expand Down Expand Up @@ -661,7 +661,7 @@ describe('SnapInsightsController', () => {
deriveStateFromMetadata(
controller.state,
controller.metadata,
'anonymous',
'includeInDebugSnapshot',
),
).toMatchInlineSnapshot(`{}`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import { HandlerType } from '@metamask/snaps-utils';
import { hasProperty, hexToBigInt } from '@metamask/utils';

import type { DeleteInterface } from '../interface';
import type { GetAllSnaps, HandleSnapRequest } from '../snaps';
import type {
SnapControllerGetAllSnapsAction,
SnapControllerHandleRequestAction,
} from '../snaps';
import { getRunnableSnaps } from '../snaps';
import type {
TransactionControllerUnapprovedTransactionAddedEvent,
Expand All @@ -33,8 +36,8 @@ import type {
const controllerName = 'SnapInsightsController';

export type SnapInsightsControllerAllowedActions =
| HandleSnapRequest
| GetAllSnaps
| SnapControllerHandleRequestAction
| SnapControllerGetAllSnapsAction
| GetPermissions
| DeleteInterface;

Expand Down Expand Up @@ -143,7 +146,7 @@ export class SnapInsightsController extends BaseController<
* @returns A list of objects containing Snap IDs and the permission object.
*/
#getSnapsWithPermission(permissionName: string) {
const allSnaps = this.messenger.call('SnapController:getAll');
const allSnaps = this.messenger.call('SnapController:getAllSnaps');
const filteredSnaps = getRunnableSnaps(allSnaps);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as MultichainRouter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same reply 😄


return filteredSnaps.reduce<SnapWithPermission[]>((accumulator, snap) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ describe('SnapInterfaceController', () => {
);

rootMessenger.registerActionHandler(
'SnapController:get',
'SnapController:getSnap',
() => undefined,
);

Expand All @@ -673,7 +673,7 @@ describe('SnapInterfaceController', () => {

expect(controllerMessenger.call).toHaveBeenNthCalledWith(
1,
'SnapController:get',
'SnapController:getSnap',
MOCK_SNAP_ID,
);
});
Expand Down Expand Up @@ -2024,7 +2024,7 @@ describe('SnapInterfaceController', () => {
deriveStateFromMetadata(
controller.state,
controller.metadata,
'anonymous',
'includeInDebugSnapshot',
),
).toMatchInlineSnapshot(`{}`);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
isMatchingChainId,
validateInterfaceContext,
} from './utils';
import type { GetSnap } from '../snaps';
import type { SnapControllerGetSnapAction } from '../snaps';

const MAX_UI_CONTENT_SIZE = 10_000_000; // 10 mb

Expand Down Expand Up @@ -125,7 +125,7 @@ export type SnapInterfaceControllerAllowedActions =
| PhishingControllerTestOrigin
| ApprovalControllerHasRequestAction
| ApprovalControllerAcceptRequestAction
| GetSnap
| SnapControllerGetSnapAction
| MultichainAssetsControllerGetStateAction
| AccountsControllerGetSelectedMultichainAccountAction
| AccountsControllerGetAccountByAddressAction
Expand Down Expand Up @@ -598,7 +598,7 @@ export class SnapInterfaceController extends BaseController<
* @returns The snap.
*/
#getSnap(id: string) {
return this.messenger.call('SnapController:get', id);
return this.messenger.call('SnapController:getSnap', id);
}

#hasPermission(snapId: SnapId, permission: string) {
Expand Down
Loading
Loading