Skip to content

Commit 11b7561

Browse files
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

10 files changed

+677
-5
lines changed

packages/gator-permissions-controller/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [0.3.0]
1111

12+
### Added
13+
14+
- Add `submitRevocation` action to submit permission revocations through the gator permissions provider snap
15+
- Add `addPendingRevocation` action to queue revocations until transaction confirmation
16+
1217
### Changed
1318

1419
- **BREAKING:** Use new `Messenger` from `@metamask/messenger` ([#6461](https://github.com/MetaMask/core/pull/6461))

packages/gator-permissions-controller/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,16 @@ gatorPermissionsController.enableGatorPermissions();
2929
### Fetch from Profile Sync
3030

3131
```typescript
32+
// Fetch all permissions
3233
const permissions =
3334
await gatorPermissionsController.fetchAndUpdateGatorPermissions();
35+
36+
// Fetch permissions with optional filter params
37+
const filteredPermissions =
38+
await gatorPermissionsController.fetchAndUpdateGatorPermissions({
39+
origin: 'https://example.com',
40+
chainId: '0x1',
41+
});
3442
```
3543

3644
## Contributing

packages/gator-permissions-controller/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"@lavamoat/preinstall-always-fail": "^2.1.0",
6363
"@metamask/auto-changelog": "^3.4.4",
6464
"@metamask/snaps-controllers": "^14.0.1",
65+
"@metamask/transaction-controller": "^61.1.0",
6566
"@ts-bridge/cli": "^0.6.4",
6667
"@types/jest": "^27.4.1",
6768
"deepmerge": "^4.2.2",

0 commit comments

Comments
 (0)