Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jl/caip25 permission migration/update mutators #28709

Merged

Conversation

jiexi
Copy link
Contributor

@jiexi jiexi commented Nov 26, 2024

Description

Replaces existing caveat mutators. Handles ensuring wallet:eip155 is only upserted for permissions granted to snaps.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to this page...

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.

Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

Copy link

socket-security bot commented Nov 26, 2024

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/[email protected] None 0 313 kB metamaskbot

🚮 Removed packages: npm/@metamask/[email protected]

View full report↗︎

Copy link

socket-security bot commented Nov 26, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

jiexi added a commit to MetaMask/core that referenced this pull request Nov 26, 2024
…oved (#4978)

## Explanation

Updates the CAIP-25 mutators so that if the only eip155 account or scope
is removed then the entire permission is revoked.

## References

Related: MetaMask/metamask-extension#28709

## 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`

- **CHANGED**: `Caip25CaveatMutators.authorizedScopes.removeAccount` now
revokes the CAIP-25 endowment if the only account is removed.
- **CHANGED**: `Caip25CaveatMutators.authorizedScopes.removeScope` now
revokes the CAIP-25 endowment if the only non-wallet scope is removed.
- **CHANGED**: `setEthAccounts` no longer adds `wallet:eip155` to the
optionalScopes if it does not already exist.

## 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

---------

Co-authored-by: Alex Donesky <[email protected]>
@jiexi
Copy link
Contributor Author

jiexi commented Nov 26, 2024

@SocketSecurity ignore npm/@metamask/[email protected]

metamaskbot is us

@jiexi
Copy link
Contributor Author

jiexi commented Nov 26, 2024

just tested manually. seems to work as expected

@metamaskbot
Copy link
Collaborator

Builds ready [2d78f33]
Page Load Metrics (1685 ± 67 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15222056168913967
domContentLoaded14871953165212761
load14982041168513967
domInteractive246939147
backgroundConnect982352311
firstReactRender1672362210
getState55718168
initialActions00000
loadScripts10981466123210450
setupStore65110105
uiStartup16932332188016278
Bundle size diffs [🚀 Bundle size reduced!]
  • background: -23.65 KiB (-0.40%)
  • ui: 636 Bytes (0.01%)
  • common: -106.94 KiB (-1.28%)

@@ -297,7 +297,7 @@ export const NetworkListMenu = ({ onClose }: { onClose: () => void }) => {
}

if (permittedAccountAddresses.length > 0) {
addPermittedChain(selectedTabOrigin, network.chainId);
dispatch(addPermittedChain(selectedTabOrigin, network.chainId));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixing this upstream in develop here #28741

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nevermind, this is the result of a bad merge against develop. Develop actually properly dispatches this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

resolved in the CAIP-25 permission branch upstream of this

@jiexi jiexi marked this pull request as ready for review November 26, 2024 19:22
@jiexi jiexi requested review from a team as code owners November 26, 2024 19:22
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM other than figuring out what's going on with the permission auto-granting piece

@jiexi jiexi merged commit d2fd282 into caip25-permission-migration Nov 26, 2024
14 of 17 checks passed
@jiexi jiexi deleted the jl/caip25-permission-migration/update-mutators branch November 26, 2024 19:49
@github-actions github-actions bot locked and limited conversation to collaborators Nov 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants