Skip to content

feat: use @metamask/messenger/generate-action-types CLI#3914

Draft
cryptodev-2s wants to merge 4 commits intomainfrom
feat/use-messenger-generate-action-types
Draft

feat: use @metamask/messenger/generate-action-types CLI#3914
cryptodev-2s wants to merge 4 commits intomainfrom
feat/use-messenger-generate-action-types

Conversation

@cryptodev-2s
Copy link
Copy Markdown
Contributor

Explanation

Replace the local copy-pasted scripts/generate-method-action-types.mts (781 lines) with the CLI from @metamask/messenger/generate-action-types.

Currently uses a preview build (@metamask-previews/messenger@0.3.0-preview-a462582) via resolution. Once MetaMask/core#8264 is merged and released, the resolution should be removed and the dependency updated to the released version.

References

Mrtenz and others added 4 commits March 23, 2026 14:08
…3907)

This renames all `SnapController` action and event names and types to
follow the `Controller...Action` pattern used in most other controllers.
I've also added the `generate-method-actions` script used in
`MetaMask/core` to automatically generate these types.

I found numerous unrelated type errors in test files that I fixed in
this pull request as well, since it was a bit difficult to determine if
a type error was caused by this refactor or not, in some cases.

## Breaking changes

- All `SnapController` action types were renamed from `DoSomething` to
`SnapControllerDoSomethingAction`.
   - `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 `SnapControllerRemoveSnapFromSubjectAction`.
- `RevokeDynamicPermissions` is now
`SnapControllerRevokeDynamicSnapPermissionsAction`.
   - `GetSnapFile` is now `SnapControllerGetSnapFileAction`.
- `IsMinimumPlatformVersion` is now
`SnapControllerIsMinimumPlatformVersionAction`.
   - `SetClientActive` is now `SnapControllerSetClientActiveAction`.
- All `SnapController` event types were renamed from `OnSomething` to
`SnapControllerOnSomethingEvent`.
- `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`.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **High Risk**
> Large breaking rename of `SnapController` messenger action/event names
(e.g., `get`→`getSnap`, `getAll`→`getAllSnaps`) and their exported
TypeScript types across multiple controllers/tests, which can easily
break downstream integrations. Adds a generated action-type source file
and enforces it via lint, so CI failures are likely if regeneration is
missed.
> 
> **Overview**
> **Standardizes `SnapController` messenger API naming** by renaming
action/event type aliases to the `SnapController…Action` /
`SnapController…Event` pattern and updating call sites (notably
`SnapController:get`→`SnapController:getSnap` and
`SnapController:getAll`→`SnapController:getAllSnaps`) across controllers
and tests.
> 
> **Introduces generated method action types** by adding
`SnapController-method-action-types.ts` (auto-generated union of method
action types), wiring workspace scripts (`generate-method-action-types`)
and enforcing it in root `lint`.
> 
> Also includes small cleanup/consistency fixes in tests (e.g., metadata
key `anonymous`→`includeInDebugSnapshot`) and removes now-unneeded lint
suppression comments in execution services.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
7386c7f. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
)

This renames all `CronjobController` action and event names and types to
follow the `Controller...Action` pattern used in most other controllers.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Primarily a type-level refactor but marked breaking because exported
action type names and cronjob exports change; downstream TypeScript code
and messenger typings may need updates.
> 
> **Overview**
> **Standardizes `CronjobController` messenger action typing.** The PR
moves cronjob method action definitions into a new auto-generated
`CronjobController-method-action-types.ts`, renaming the exported action
types to the `CronjobController…Action` convention.
> 
> `CronjobController` now wires its messenger via
`registerMethodActionHandlers` with an explicit
`MESSENGER_EXPOSED_METHODS` list, and narrows messenger generics by
separating controller actions/events from externally *allowed* ones.
Public exports from `cronjob/index.ts` are adjusted accordingly, and the
changelog is updated to document the new breaking action type names
(including `CronjobControllerScheduleAction`,
`CronjobControllerCancelAction`, `CronjobControllerGetAction`).
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
e5867a2. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
…es (#3912)

This renames all `SnapInterfaceController` action and event names and
types to follow the `Controller...Action` pattern used in most other
controllers.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Breaking change that renames exported `SnapInterfaceController` action
types and adjusts messenger handler registration; downstream packages
relying on the old type names or exports will fail to compile. Runtime
behavior should be unchanged but messaging wiring changes could affect
integration if method exposure lists drift.
> 
> **Overview**
> **BREAKING:** Renames `SnapInterfaceController` action type aliases to
the standardized `SnapInterfaceController...Action` naming scheme,
updates `CHANGELOG`, and adjusts consumers (`SnapController`,
`SnapInsightsController`, and `snaps-simulation`) to use the new types.
> 
> Moves `SnapInterfaceController` method action type definitions into a
new auto-generated `SnapInterfaceController-method-action-types.ts`,
updates `interface/index.ts` exports, and replaces per-action
`registerActionHandler` calls with `registerMethodActionHandlers` driven
by a single `MESSENGER_EXPOSED_METHODS` list.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
4cd791b. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Replace local copy-pasted script with the CLI from
@metamask/messenger. Uses preview build via resolution until release.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (controller-refactors@2799c4c). Learn more about missing BASE report.

Additional details and impacted files
@@                   Coverage Diff                   @@
##             controller-refactors    #3914   +/-   ##
=======================================================
  Coverage                        ?   98.55%           
=======================================================
  Files                           ?      425           
  Lines                           ?    12343           
  Branches                        ?     1935           
=======================================================
  Hits                            ?    12165           
  Misses                          ?      178           
  Partials                        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​metamask/​messenger@​0.3.0-preview-a462582100100100100100

View full report

Base automatically changed from controller-refactors to main March 26, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants