Skip to content

refactor: migrate eip-5792 & capabilities middleware handlers into monorepo#19064

Merged
ffmcgee725 merged 14 commits intomainfrom
jc/mmp-5698
Sep 4, 2025
Merged

refactor: migrate eip-5792 & capabilities middleware handlers into monorepo#19064
ffmcgee725 merged 14 commits intomainfrom
jc/mmp-5698

Conversation

@ffmcgee725
Copy link
Copy Markdown
Member

@ffmcgee725 ffmcgee725 commented Sep 1, 2025

Description

We identified duplication in JSON RPC middleware logic between the mobile and extension clients, particularly around the 5792 middleware stack and capability handling. During recent Wallet API and Perps integration discussions, the team agreed this presents an opportunity to abstract and centralize this logic into a core monorepo module.

The motivation here is to:

  • Reduce code duplication across mobile and extension clients
  • Create a client-agnostic foundation for capabilities (including auxiliary funds, capability advertising, and required assets)
  • Support the upcoming Metamask Pay (MM Pay) initiative by establishing a standardized middleware layer
  • Facilitate future multi-chain and auxiliary funds work without creating divergent patterns

So the work done on this PR aims to:

  1. Import 5792 middleware handlers from the new core package eip-5792-middleware that host shared middleware logic.
  2. Remove 5792 code from mobile.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://github.com/MetaMask/MetaMask-planning/issues/5698

Manual testing steps

  1. No user facing changes, but for extra confirmation, we can make sure using EIP 5792 methods via https://metamask.github.io/test-dapp/ still works!

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@ffmcgee725 ffmcgee725 added the No QA Needed Apply this label when your PR does not need any QA effort. label Sep 1, 2025
@metamaskbot metamaskbot added the team-wallet-api-platform-deprecated DEPRECATED: please use "team-wallet-integrations" instead label Sep 1, 2025
@github-actions github-actions bot added the size-M label Sep 1, 2025
@socket-security
Copy link
Copy Markdown

socket-security bot commented Sep 1, 2025

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

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addednpm/​@​metamask/​eip-5792-middleware@​1.0.0741007389100
Updatednpm/​@​metamask/​keyring-controller@​22.1.0 ⏵ 22.1.199 +21007697 +3100

View full report

@github-actions github-actions bot added size-XL and removed size-M labels Sep 2, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 3, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: f612ee3
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/ed595d7a-d8ec-46a4-ac96-8d7fee417b12

Note

  • You can rerun any failed steps by opening the Bitrise build, tapping Rebuild on the upper right then Rebuild unsuccessful Workflows
  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

adonesky1 pushed a commit to MetaMask/core that referenced this pull request Sep 3, 2025
…po (#6422)

## Explanation

We identified duplication in JSON RPC middleware logic between the
mobile and extension clients, particularly around the 5792 middleware
stack and capability handling. During recent Wallet API and Perps
integration discussions, the team agreed this presents an opportunity to
abstract and centralize this logic into a core monorepo module.

The motivation here is to:

* Reduce code duplication across mobile and extension clients
* Create a client-agnostic foundation for capabilities (including
auxiliary funds, capability advertising, and required assets)
* Support the upcoming Metamask Pay (MM Pay) initiative by establishing
a standardized middleware layer
* Facilitate future multi-chain and auxiliary funds work without
creating divergent patterns

So the work done on this PR aims to:

1. Create a new core package `eip-5792-middleware` to host shared
middleware logic.
2. Extract the 5792 middleware logic and capability handlers from both
extension and mobile clients.
a.
[Extension](MetaMask/metamask-extension#35541)
   b. [Mobile](MetaMask/metamask-mobile#19064)
4. Refactor them to be client-agnostic and consumable by both clients.
5. Maintain feature parity with existing implementations while improving
modularity and testability.
6. Include initial unit tests and integration hooks.

<!--
Thanks for your contribution! Take a moment to answer these questions so
that reviewers have the information they need to properly understand
your changes:

* What is the current state of things and why does it need to change?
* What is the solution your changes offer and how does it work?
* Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?
* If your primary goal was to update one package but you found you had
to update another one along the way, why did you do so?
* If you had to upgrade a dependency, why did you do so?
-->

## References

<!--
Are there any issues that this pull request is tied to?
Are there other links that reviewers should consult to understand these
changes better?
Are there client or consumer pull requests to adopt any breaking
changes?

For example:

* Fixes
[#5698](MetaMask/MetaMask-planning#5698)
-->

* Fixes
[#5698](MetaMask/MetaMask-planning#5698)

## 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
@ffmcgee725 ffmcgee725 marked this pull request as ready for review September 4, 2025 10:01
@ffmcgee725 ffmcgee725 requested a review from a team as a code owner September 4, 2025 10:01
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 4, 2025

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: 6c4d8f8
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/9265ccda-4174-4fe3-9409-8d86348e6f85

Note

  • You can rerun any failed steps by opening the Bitrise build, tapping Rebuild on the upper right then Rebuild unsuccessful Workflows
  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

wenfix
wenfix previously approved these changes Sep 4, 2025
@ffmcgee725
Copy link
Copy Markdown
Member Author

Skipping Smoke E2E since every workflow is broken on main at the moment.

Previous run has all passing workflows except for the one that was also failing on main at the time.

@ffmcgee725 ffmcgee725 enabled auto-merge September 4, 2025 10:44
@ffmcgee725 ffmcgee725 added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Sep 4, 2025
@ffmcgee725
Copy link
Copy Markdown
Member Author

Skipping sonar cloud as testability on BackgroundBridge component will be re-visited in this pending ticket

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Sep 4, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
26.7% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@ffmcgee725 ffmcgee725 added this pull request to the merge queue Sep 4, 2025
Merged via the queue into main with commit f7189cf Sep 4, 2025
63 of 65 checks passed
@ffmcgee725 ffmcgee725 deleted the jc/mmp-5698 branch September 4, 2025 12:21
@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2025
@metamaskbot metamaskbot added the release-7.56.0 Issue or pull request that will be included in release 7.56.0 label Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

No QA Needed Apply this label when your PR does not need any QA effort. release-7.56.0 Issue or pull request that will be included in release 7.56.0 size-XL skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-wallet-api-platform-deprecated DEPRECATED: please use "team-wallet-integrations" instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants