You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(json-rpc-engine): Permit passing middleware functions to compatibility adapters (#6991)
## Explanation
As a convenience, permit passing one or more middleware functions or an
engine to `asV2Middleware` and `asLegacyMiddleware`.
## References
N/A
## Checklist
- [x] I've updated the test suite for new or updated code as appropriate
- [x] I've updated documentation (JSDoc, Markdown, etc.) for new or
updated code as appropriate
- [x] I've communicated my changes to consumers by [updating changelogs
for packages I've
changed](https://github.com/MetaMask/core/tree/main/docs/contributing.md#updating-changelogs),
highlighting breaking changes as necessary
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Enable `asV2Middleware` and `asLegacyMiddleware` to accept one or
multiple middleware functions (in addition to engines), with docs,
tests, and changelog updates.
>
> - **API (compatibility adapters)**
> - `asV2Middleware(...)`: add overloads to accept single/multiple
legacy `JsonRpcEngine` middlewares; composes via `mergeMiddleware`;
existing engine support unchanged.
> - `asLegacyMiddleware(...)`: add overloads to accept single/multiple
V2 `JsonRpcMiddleware`; wraps them in a temporary V2 engine internally.
> - **Behavior & Tests**
> - Verify composing multiple middlewares, forwarding results/errors,
and continuing pipeline when middleware doesn’t end.
> - Confirm context/request propagation between legacy and V2 paths.
> - **Docs**
> - Update `README.md` and `src/README.md` with new usage examples
(engine vs. middleware conversion) and context propagation notes.
> - **Changelog**
> - Append PR reference to `JsonRpcEngineV2` entry in `CHANGELOG.md`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
d1fe897. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Cursor Agent <[email protected]>
0 commit comments