Skip to content

Conversation

@hanzel98
Copy link
Contributor

@hanzel98 hanzel98 commented Sep 24, 2025

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 ]
This PR depends on this other PR of the permissions-controller #6713

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • 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, 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.


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.

Written by Cursor Bugbot for commit 2774c30. This will update automatically on new commits. Configure here.

@hanzel98 hanzel98 requested a review from a team as a code owner September 24, 2025 16:32
@hanzel98 hanzel98 self-assigned this Sep 24, 2025
@hanzel98 hanzel98 marked this pull request as draft September 24, 2025 16:40
@hanzel98 hanzel98 force-pushed the chore/revokation-rpc-request branch 2 times, most recently from c86dca7 to 1833a20 Compare September 24, 2025 18:47
@hanzel98 hanzel98 force-pushed the chore/revokation-rpc-request branch from 595f36d to 0a44e3c Compare October 14, 2025 03:09
@hanzel98 hanzel98 marked this pull request as ready for review October 26, 2025 01:42
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@MoMannn MoMannn left a comment

Choose a reason for hiding this comment

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

Add changes to CHANGELOG.md under ## [Unreleased].

- Add RevocationParams type with delegationHash field
- Add PermissionProviderSubmitRevocation RPC method enum
- Implement submitRevocation method with proper error handling
- Add comprehensive test suite with 100% coverage
- Export new types in public API

This enables MetaMask clients to submit permission revocations through
the gator permissions provider snap using the permissionsProvider_submitRevocation
RPC method.
@hanzel98 hanzel98 force-pushed the chore/revokation-rpc-request branch from 68fe787 to 6999403 Compare November 3, 2025 19:59
@hanzel98 hanzel98 requested a review from a team as a code owner November 3, 2025 19:59
@hanzel98 hanzel98 force-pushed the chore/revokation-rpc-request branch from 4985f70 to 7b7535f Compare November 3, 2025 20:32
Copy link
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

looks good!

params,
}: {
snapId: SnapId;
params?: Json;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we have a more specific type for the params? I guess it's params for a specific method, so we should always know the type, and leaving it as Json is opening us up for bugs.

*/
public async fetchAndUpdateGatorPermissions(): Promise<GatorPermissionsMap> {
public async fetchAndUpdateGatorPermissions(
params?: Json,
Copy link
Contributor

Choose a reason for hiding this comment

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

same question regarding typing of params

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

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

Looks good!

@hanzel98 hanzel98 merged commit 11b7561 into main Nov 4, 2025
262 checks passed
@hanzel98 hanzel98 deleted the chore/revokation-rpc-request branch November 4, 2025 18:53
V00D00-child added a commit that referenced this pull request Nov 4, 2025
## Explanation

Expose the list of pending revocations in the state to allow MM clients
to create custom selectors that filter on `pendingRevocations` to
determine whether the revoke CTA should show the "pending" status.

- A revocation is added to `pendingRevocations` state on calls to
`addPendingRevocation()`
- A revocation is removed from `pendingRevocations` state given a
`transactionId` when the handler's `cleanup()` function is executed.

## References

Forked from #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
- [x] 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
- [x] I've prepared draft pull requests for clients and consumer
packages to resolve any breaking changes



<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Adds `pendingRevocations` to controller state with lifecycle
management via `addPendingRevocation` and `submitRevocation`, updating
metadata, tests, and changelog.
> 
> - **GatorPermissionsController**:
> - **State**: Add `pendingRevocations: { txId: string;
permissionContext: Hex }[]` with default `[]` and UI exposure in
metadata.
>   - **API**:
>     - New getter `pendingRevocations`.
> - `addPendingRevocation` now appends to state immediately and cleans
up on confirm/fail/drop/timeout by `txId`.
> - `submitRevocation` submits to Snap and removes entry by
`permissionContext` on success.
> - **Internals**: Add private helpers to add/remove pending
revocations; import `Hex` type.
> - **Tests**: Update snapshots, add coverage for pending revocations
lifecycle and getter.
> - **Docs**: Update `CHANGELOG.md` to note exposed pending revocations
and related actions.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
77e676e. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants