Skip to content

Conversation

@hanzel98
Copy link
Contributor

@hanzel98 hanzel98 commented Nov 26, 2025

Explanation

This PR adds support for revoking already-disabled delegations that don't require an on-chain transaction. Previously, the revocation flow required creating a transaction and waiting for it to confirm, but for delegations that are already disabled on-chain, we can submit the revocation directly to the snap without waiting for a transaction.

What this PR does:

  1. Adds submitDirectRevocation method: This new method combines adding a pending revocation to state (to disable the UI button) and immediately submitting the revocation to the snap. This simplifies the caller code in metamask-extension since they no longer need to call two separate methods.

  2. Adds isPendingRevocation helper method: A utility method to check if a permission context is currently in the pending revocations list. This can be used by the UI to determine button states.

  3. Improves error handling in submitRevocation: Refactored to use a finally block to ensure pending revocations are always cleared when the revocation succeeds, even if the refresh operation fails. This prevents stuck Revocation Pending states in the UI.

Key implementation details:

  • submitDirectRevocation uses a placeholder txId format (no-tx-${permissionContext}) that won't conflict with real transaction IDs
  • The pending revocation is removed by permissionContext (not txId), so the placeholder doesn't affect functionality
  • If submitRevocation fails, the pending revocation stays in state so the UI can show an error/retry state
  • The finally block ensures cleanup happens even if the refresh fails after successful revocation
  • All new functionality is fully tested with comprehensive test coverage

Usage:

Before (required two calls):
await gatorPermissionsController.addDirectPendingRevocation({ permissionContext });
await gatorPermissionsController.submitRevocation({ permissionContext });

After (single call):
await gatorPermissionsController.submitDirectRevocation({ permissionContext });

Testing:

  • All existing tests pass (45 tests)
  • Added 4 new tests for submitDirectRevocation
  • Added 3 new tests for isPendingRevocation
  • Added 1 test for finally block behavior in submitRevocation
  • All tests passing ✅

Related

This change is needed to support revoking already-disabled delegations in the MetaMask extension UI.


Note

Adds submitDirectRevocation and isPendingRevocation, and improves revocation cleanup and error handling.

  • Controller (src/GatorPermissionsController.ts):
    • New APIs: submitDirectRevocation(params) for already-disabled delegations; isPendingRevocation(permissionContext) helper.
    • Actions/Handlers: Register GatorPermissionsController:submitDirectRevocation and :isPendingRevocation.
    • Revocation flow: submitRevocation now refreshes permissions after submit, clears pending in a finally block, and wraps refresh failures with GatorPermissionsFetchError (specific message).
    • Pending state: Removal by permissionContext is now case-insensitive.
  • Exports (src/index.ts): Export new action types for direct revocation and pending check.
  • Tests: Add tests for submitDirectRevocation, isPendingRevocation, and submitRevocation cleanup-on-refresh-failure.
  • Changelog: Note addition of submitDirectRevocation in Unreleased.

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

…ready-disabled delegations

- Add submitDirectRevocation method that combines adding to pending state and submitting revocation
- Add isPendingRevocation helper method to check if a permission is pending
- Update submitRevocation to use finally block for clearing pending revocations
- Export new action types in index.ts
@hanzel98 hanzel98 requested review from a team as code owners November 26, 2025 15:45
@hanzel98 hanzel98 self-assigned this Nov 26, 2025
@hanzel98 hanzel98 requested review from MoMannn and mj-kiwi November 26, 2025 20:23
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 to me!

@hanzel98 hanzel98 added this pull request to the merge queue Nov 27, 2025
Merged via the queue into main with commit 9ffb1ec Nov 27, 2025
279 checks passed
@hanzel98 hanzel98 deleted the feat/gator-permissions-submit-direct-revocation branch November 27, 2025 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants