Commit 11b7561
authored
New Action on the GatorPermissionsController to Allow the Consumer to SubmitRevocation (#6713)
## Explanation
**What is the current state of things and why does it need to change?**
The GatorPermissionsController currently provides functionality to
fetch, enable, disable, and decode gator permissions, but it lacks the
ability to revoke permissions. This missing capability prevents MetaMask
clients from providing users with a complete permission management
experience where they can not only grant permissions but also revoke
them when needed.
**What is the solution your changes offer and how does it work?**
This PR adds a new `submitRevocation` action to the
GatorPermissionsController that allows consumers (MetaMask clients) to
submit permission revocations through the gator permissions provider
snap. The implementation:
- Adds a new `RevocationParams` type that accepts a `delegationHash`
(hex string) to identify the permission to revoke
- Implements a `submitRevocation` method that forwards the revocation
request to the gator permissions provider snap using the
`permissionsProvider_submitRevocation` RPC method
- Includes proper error handling using existing error types
(`GatorPermissionsNotEnabledError` and `GatorPermissionsProviderError`)
- Added new filter in the function to request the permissions
- Follows the established patterns in the controller for action
registration and snap communication
**Are there any changes whose purpose might not obvious to those
unfamiliar with the domain?**
The `delegationHash` parameter is a unique identifier for ERC-7715
delegations/permissions that allows the snap to locate and revoke the
specific permission. This hash-based approach is standard in the
ERC-7715 delegation framework for permission management.
## References
[[Related to
]](https://app.zenhub.com/workspaces/readable-permissions-67982ce51eb4360029b2c1a1/issues/gh/metamask/delegator-readable-permissions/357)
This PR depends on this other PR of the permissions-controller
#6713
## 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
- [ ] 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
- [ ] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes
**Note**: The changelog item should be checked off after updating the
CHANGELOG.md file, and the last item can be checked as N/A since this is
a new feature addition with no breaking changes.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Adds `submitRevocation` and `addPendingRevocation` actions, optional
fetch filters, and integrates TransactionController events for
revocation flow.
>
> - **GatorPermissionsController (core)**:
> - Add actions: `submitRevocation` (submits revocations to snap) and
`addPendingRevocation` (queues until tx confirmation; cleans up on
fail/drop/timeout).
> - Subscribe to `TransactionController` events: `transactionConfirmed`,
`transactionFailed`, `transactionDropped`.
> - Enhance `fetchAndUpdateGatorPermissions` to accept optional filter
`params` forwarded to snap.
> - Internal snap RPC support: new enum
`permissionsProvider_submitRevocation`.
> - Types: add `RevocationParams`, `PendingRevocationParams`; extend
`StoredGatorPermission*` with optional `isRevoked`.
> - Exports: surface new actions/types via `src/index.ts`.
> - **Tests**:
> - Add comprehensive tests for fetch with params, `submitRevocation`,
and `addPendingRevocation` (including event-driven and error paths).
> - **Docs**:
> - README: document filtered permission fetch usage.
> - CHANGELOG: record new actions and changes.
> - **Build/Config**:
> - Add devDependency `@metamask/transaction-controller`; update TS
project references to include transaction-controller.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2774c30. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 0b86a8e commit 11b7561
File tree
10 files changed
+677
-5
lines changed- packages/gator-permissions-controller
- src
10 files changed
+677
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
12 | 17 | | |
13 | 18 | | |
14 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
0 commit comments