-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat: revoke CAIP-25 endowment if only eip155 account or scope is removed #4978
Conversation
this doesn't handle the snaps case for permitted chains. need to update. EDIT: unsure how to handle this for snaps as the mutator function only receives a caveat value which gives no insight into the Permission's origin |
…sider non-eth accounts
…ators' into jl/caip-multichain-revoke-in-mutators
packages/multichain/src/adapters/caip-permission-adapter-eth-accounts.ts
Show resolved
Hide resolved
@metamaskbot publish-previews |
Preview builds have been published. See these instructions for more information about preview builds. Expand for full list of packages and versions.
|
}); | ||
}); | ||
|
||
it('does not revoke the permission if the target scope does not exist but the permission only has wallet scopes', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The "does not revoke" tests are a bit confusing because it's not clear what we do expect to happen. Could we re-phrase them to make clear that we expect the result to be a no-op? The same goes for those added later in this file as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually maybe these cases are already covered? I do see some "account does not exist" and "scope does not exist" test cases already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done here d65e8eb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a suggestion for the tests, but overall LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ators' into jl/caip-multichain-revoke-in-mutators
…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]>
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
@metamask/multichain
Caip25CaveatMutators.authorizedScopes.removeAccount
now revokes the CAIP-25 endowment if the only account is removed.Caip25CaveatMutators.authorizedScopes.removeScope
now revokes the CAIP-25 endowment if the only non-wallet scope is removed.setEthAccounts
no longer addswallet:eip155
to the optionalScopes if it does not already exist.Checklist