refactor!: Add consolidated legacy method middleware#8583
Draft
refactor!: Add consolidated legacy method middleware#8583
Conversation
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>
Member
Author
|
@cursor review |
There was a problem hiding this comment.
✅ 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.
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.
createMethodMiddlewareExplanation
References
Checklist
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
createMethodMiddlewareFactoryto@metamask/json-rpc-enginethat buildsJsonRpcEnginemiddleware from handler definitions, validates hook sets (missing/extraneous), dispatches bymethod, and can pass a per-handler delegatedMessengerbased on declaredactionNames.Refactors v2
createMethodMiddlewareto reuse sharedmiddlewareUtils(hook selection/validation and messenger delegation) and drops the v2selectHooksexport.Breaking: Removes the unused permitted RPC method handler modules/tests and related handler/type exports from
@metamask/permission-controller(includingpermissionRpcMethodsandPermittedHandlerExporttypes), 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.