Skip to content

Conversation

hanzel98
Copy link
Contributor

Description

This PR implements the isRevoked flag feature for permissions stored in profile sync to ensure off-chain storage stays in sync with on-chain contract state after revocation transactions reach finality.

Key Changes:

  1. Added isRevoked flag to the StoredGrantedPermission type that defaults to false when permissions are stored
  2. Implemented new RPC method permissionsProvider_submitRevocation accessible only by the MetaMask origin to update the revocation status
  3. Added validation and on-chain verification to ensure revocations are only processed for delegations that are actually disabled on-chain
  4. Comprehensive test coverage for all new functionality including edge cases and error scenarios

The RPC method validates the delegation hash, fetches the existing permission, verifies the delegation is disabled on-chain via the delegation manager contract, and updates the permission's isRevoked status to true.

Related issues

Fixes: #357

Manual testing steps

  1. Build and run the gator-permissions-snap
  2. Grant a permission through the snap interface
  3. Revoke the permission on-chain through the delegation manager contract
  4. Call the permissionsProvider_submitRevocation RPC method with the delegation hash
  5. Verify the permission's isRevoked flag is set to true in profile sync
  6. Attempt to call the RPC method with an invalid delegation hash and verify it rejects
  7. Attempt to call the RPC method for a delegation that is not disabled on-chain and verify it rejects

Screenshots/Recordings

Before

  • Permissions stored in profile sync had no revocation tracking
  • No mechanism to sync off-chain permission state with on-chain revocations
  • Once granted, permissions appeared active in profile sync even after on-chain revocation

After

  • Permissions now include an isRevoked boolean flag (defaults to false)
  • New RPC method permissionsProvider_submitRevocation allows MetaMask to update revocation status
  • Off-chain permission state accurately reflects on-chain delegation status
  • Proper validation ensures only legitimate revocations are processed

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Additional Technical Details:

@hanzel98 hanzel98 requested a review from a team as a code owner September 23, 2025 16:14
@hanzel98 hanzel98 marked this pull request as draft September 23, 2025 16:14
@hanzel98 hanzel98 self-assigned this Sep 23, 2025
delegationHash: z
.string()
.regex(/^0x[a-fA-F0-9]{64}$/u, 'Invalid delegation hash'),
});
Copy link

Choose a reason for hiding this comment

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

Bug: Permission Revocation Fails Due to Regex and Context Mismatch

The submitRevocation RPC method fails to revoke permissions. Its input validation regex incorrectly restricts the delegationHash parameter to a single 32-byte hash, rejecting permissions with multiple delegations. Additionally, profileSyncManager.getGrantedPermission expects a full permission context (storage key), but receives only a single delegation hash, preventing successful permission lookups.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

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

review again

@hanzel98 hanzel98 force-pushed the chore/is-revoke-flag branch from 02f55e2 to d4be06e Compare October 3, 2025 20:13
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.

1 participant