refactor: use caip25 permission merger / differ#30042
Merged
ffmcgee725 merged 92 commits intomainfrom Mar 3, 2025
Merged
Conversation
…n request is cancelled
…ons implementation to be fully caip25 compliant
…nd Caip25EndowmentPermission request (wip)
…ermimssions page container
Collaborator
Builds ready [e586d94]
Page Load Metrics (1659 ± 107 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
7 tasks
ffmcgee725
added a commit
to MetaMask/core
that referenced
this pull request
Feb 25, 2025
## Explanation Addressing MetaMask/MetaMask-planning#4017 We want to create a merger for the Caip25Permission specification in order to enable wallet_addEthereumChain and wallet_switchEthereumChain to call to the PermissionController rather than the ApprovalController for incremental permission requests (i.e. for the permittedChains flow). <!-- 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 Extension: MetaMask/metamask-extension#30042 ## Changelog <!-- If you're making any consumer-facing changes, list those changes here as if you were updating a changelog, using the template below as a guide. (CATEGORY is one of BREAKING, ADDED, CHANGED, DEPRECATED, REMOVED, or FIXED. For security-related issues, follow the Security Advisory process.) Please take care to name the exact pieces of the API you've added or changed (e.g. types, interfaces, functions, or methods). If there are any breaking changes, make sure to offer a solution for consumers to follow once they upgrade to the changes. Finally, if you're only making changes to development scripts or tests, you may replace the template below with "None". --> ### `@metamask/multichain-api` - **BREAKING**: Renamed `mergeScopes` to `mergeNormalizedScopes` - ADDED: Added merger to CaveatSpecification returned by `caip25CaveatBuilder()` - ADDED: Added `mergeInternalScopes` which merges two `InternalScopesObject`s ## 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 highlighted breaking changes using the "BREAKING" category above as appropriate - [x] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes
Collaborator
Builds ready [fdff9c1]
Page Load Metrics (1581 ± 33 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
mcmire
reviewed
Feb 26, 2025
Contributor
mcmire
left a comment
There was a problem hiding this comment.
Some of the pieces here aren't totally clear to me. I think there's some context I'm missing. I had some question below if you wouldn't mind answering them.
app/scripts/lib/rpc-method-middleware/handlers/wallet-requestPermissions.test.ts
Outdated
Show resolved
Hide resolved
app/scripts/lib/rpc-method-middleware/handlers/wallet-requestPermissions.ts
Show resolved
Hide resolved
app/scripts/lib/rpc-method-middleware/handlers/wallet-requestPermissions.ts
Show resolved
Hide resolved
Contributor
|
@ffmcgee725 Maybe we can add that check that you suggested? Then I think we should be good to go on this PR. (I ran through the manual testing steps and everything worked as described) |
hmalik88
reviewed
Feb 28, 2025
hmalik88
reviewed
Feb 28, 2025
Collaborator
Builds ready [a7ae90c]
Page Load Metrics (1736 ± 63 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
Collaborator
Builds ready [b5a389a]
Page Load Metrics (1685 ± 82 ms)
Bundle size diffs [🚀 Bundle size reduced!]
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Addressing https://github.com/MetaMask/MetaMask-planning/issues/4017
We want to create a merger for the Caip25Permission specification in order to enable wallet_addEthereumChain and wallet_switchEthereumChain to call to the PermissionController rather than the ApprovalController for incremental permission requests (i.e. for the permittedChains flow).
Merger created in this core PR
Description
Related issues
Fixes:
Manual testing steps
We can start everything off by making sure we use the dev build of extension via
yarn && yarn webpackoryarn && yarn startwallet_requestPermissionsemptyeth_accountsrequest (default)eth_accountsandendowment:permitted-chainspermission for the recently added chain viawallet_getPermissionswallet_requestPermissionseth_accountsaccount permission requesteth_accountsandendowment:permitted-chainspermission for the recently added chain viawallet_getPermissionswallet_requestPermissionsendowment:permitted-chainschain permission requesteth_accountsandendowment:permitted-chainspermission for the recently added chain viawallet_getPermissionswallet_requestPermissionseth_accountsandendowment:permitted-chainsaccount + chain permission requesteth_accountsandendowment:permitted-chainspermission for the recently added chain viawallet_getPermissionswallet_requestPermissionsmalformedeth_accountsaddressValue must be a hexadecimal string, starting with "0x".wallet_switchEthereumChainPermissions for new chaineth_accountsandendowment:permitted-chainspermission for the recently added chain viawallet_getPermissionsScreenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist