Skip to content

refactor!: Add consolidated legacy method middleware#8583

Draft
rekmarks wants to merge 4 commits intomainfrom
rekm/v2-permitted-handlers
Draft

refactor!: Add consolidated legacy method middleware#8583
rekmarks wants to merge 4 commits intomainfrom
rekm/v2-permitted-handlers

Conversation

@rekmarks
Copy link
Copy Markdown
Member

@rekmarks rekmarks commented Apr 24, 2026

  • refactor(permission-controller)!: Remove unrestricted rpc methods
  • feat(json-rpc-engine): consolidate legacy createMethodMiddleware
  • refactor(json-rpc-engine)!: Support messenger handlers in legacy method middleware

Explanation

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Medium risk due to new legacy JSON-RPC dispatch middleware (including delegated messenger support) and breaking removal of permission-controller RPC handler exports/types, which may impact downstream integrations relying on those exports.

Overview
Adds a deprecated legacy createMethodMiddlewareFactory to @metamask/json-rpc-engine that builds JsonRpcEngine middleware from handler definitions, validates hook sets (missing/extraneous), dispatches by method, and can pass a per-handler delegated Messenger based on declared actionNames.

Refactors v2 createMethodMiddleware to reuse shared middlewareUtils (hook selection/validation and messenger delegation) and drops the v2 selectHooks export.

Breaking: Removes the unused permitted RPC method handler modules/tests and related handler/type exports from @metamask/permission-controller (including permissionRpcMethods and PermittedHandlerExport types), and updates changelogs/tests accordingly.

Reviewed by Cursor Bugbot for commit be9aaca. Bugbot is set up for automated code reviews on this repo. Configure here.

rekmarks and others added 3 commits April 24, 2026 13:32
Add `createMethodMiddlewareFactory` to the legacy (v1) surface,
consolidating the near-identical `makeMethodMiddlewareMaker`
implementations from metamask-extension and metamask-mobile. The new
export is deprecated in favor of the v2 `createMethodMiddleware`.

Extract `selectHooks` and `assertExpectedHooks` into a shared
`hookUtils.ts` module used by both v1 and v2. v2 now performs the same
strict missing/extraneous hook validation as v1 at middleware
construction time.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rekmarks rekmarks changed the title refactor!: Consolidate legacy method middleware implementation refactor!: Add consolidated legacy method middleware Apr 24, 2026
@rekmarks
Copy link
Copy Markdown
Member Author

@cursor review

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit be9aaca. Configure here.

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.

1 participant