feat: use @metamask/messenger/generate-action-types CLI#3914
Draft
cryptodev-2s wants to merge 4 commits intomainfrom
Draft
feat: use @metamask/messenger/generate-action-types CLI#3914cryptodev-2s wants to merge 4 commits intomainfrom
cryptodev-2s wants to merge 4 commits intomainfrom
Conversation
…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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
generate-action-typesCLI tool as subpath export core#8264