Skip to content

Conversation

@V00D00-child
Copy link
Member

@V00D00-child V00D00-child commented Dec 15, 2025

Explanation

This PR extends the GatorPermissionsController to allow attaching metadata when submitting a revocation to the permission provider snap. Metadata includes:

  • The transaction hash
  • The block timestamp

References

Requires: feat: Store metadata when revoking a permission

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
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Attaches the confirmed transaction hash as revocation metadata when submitting permissionsProvider_submitRevocation, updating types, controller logic, tests, and changelog.

  • Controller (src/GatorPermissionsController.ts)
    • On transactionConfirmed, parse transactionMeta.hash and pass it as revocationMetadata.txHash in submitRevocation.
    • Accepts optional revocationMetadata in submitRevocation params; logs when hash is missing.
  • Types (src/types.ts)
    • Add RevocationMetadata and optional revocationMetadata to RevocationParams.
  • Tests (src/GatorPermissionsController.test.ts)
    • Add test ensuring permissionsProvider_submitRevocation receives revocationMetadata.txHash after confirmation.
  • Changelog
    • Document support for attaching metadata (transaction hash) on permission revocation.

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

@V00D00-child V00D00-child changed the title [DRAFT] Attach metadata when submitting a revocation to the permission provider snap feat: Attach metadata when submitting a revocation to the permission provider snap Dec 17, 2025
@V00D00-child V00D00-child marked this pull request as ready for review December 17, 2025 22:26
@V00D00-child V00D00-child requested review from a team as code owners December 17, 2025 22:26
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.

Should we also add revocationMetadata to StoredGatorPermission (and as per my comments on the related PR, perhaps remove the isRevoked flag?

This would probably require some changes to how we load the permission from storage also, but IMO worthwhile,

*/
export type RevocationMetadata = {
txHash: Hex;
blockTimestamp: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

is blockTimestamp a decimal string?

If that's the case, any reason not to represent it as a number? As is, it's a bit ambiguous.

Copy link
Member Author

Choose a reason for hiding this comment

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

I dropped the block timestamp from the metadata. Seems unnecessary to pass this data to our Snap to store in profile sync when we can always fetch using the transaction hash.

/**
* The metadata associated with the permission revocation transaction.
*/
metadata?: RevocationMetadata;
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be required? Is there a scenario where we want to persist the revocation status, but don't have revocation metadata?

As per other comments, I think we should name this explicitly revocationMetadata to make it clear to what it is pertaining.

Copy link
Member Author

Choose a reason for hiding this comment

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

There is an edge case in extension where we call submitRevocation with only permissionContext. In this case, we would not pass any revocation metadata, so we have to make that value optional.

Here is a link to the code for more context: https://github.com/MetaMask/metamask-extension/blob/main/ui/hooks/gator-permissions/useRevokeGatorPermissions.ts#L176

Edge case: Before submitting a revocation transaction, we check whether the delegation is already disabled on-chain. If it is disabled, we don't submit a transaction; instead, we pass the permissionContext to the Snap revocation method.

Comment on lines 978 to 980
const revocationParams = metadata
? { permissionContext, metadata }
: { permissionContext };
Copy link
Contributor

Choose a reason for hiding this comment

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

As per previous comment - should we accept revocations where we don't have the metadata? In what scenario can this happen?

Copy link
Member Author

Choose a reason for hiding this comment

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

In this case, where we are in the context of a handler that runs when a transaction is confirmed, we should accept revocations even when we don't have the metadata. Not sure why the hash on TransactionMeta type coming from transaction-controller is marked as optional, but I would expect it to be present when the transaction is confirmed.

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