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(gator snap): feat: Store metadata when revoking a permission
Required by(MM client): chore: Bump @metamask/gator-permissions-controller to 0.9.0

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

Introduces metadata propagation when submitting revocations and updates types accordingly.

  • BREAKING: RevocationParams now requires revocationMetadata; submitRevocation and submitDirectRevocation forward it to the snap
  • On confirmed transactions, parse the transaction hash and attach it to revocationMetadata.txHash (logs if missing)
  • Adds and exports RevocationMetadata type; updates imports/exports in index.ts and controller
  • Extends tests to include revocationMetadata, verify params sent to permissionsProvider_submitRevocation, and confirm permissions refresh after revocation

Written by Cursor Bugbot for commit 50338af. 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,

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!

One nit that I'm not especially concerned about, but might be a nice tidy up.

I am keen to understand the behaviour regarding failed transactions - we definitely don't want to be marking a permission as revoked if the transaction has failed.

// Handle confirmed transaction - submit revocation
handlers.confirmed = (transactionMeta) => {
if (transactionMeta.id === txId) {
controllerLog('Transaction confirmed, submitting revocation', {
Copy link
Contributor

Choose a reason for hiding this comment

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

not strictly related to this PR - but do we need to check transactionMeta.status here?

When a transaction is confirmed, do we explicitly guard against failed transactions?

Comment on lines +958 to +973
const revocationMetadata: RevocationMetadata = {};
const { hash } = transactionMeta;
if (hash === undefined) {
controllerLog(
'Failed to attach transaction hash after revocation transaction confirmed',
{
txId,
permissionContext,
error: new Error(
'Confirmed transaction is missing transaction hash',
),
},
);
} else {
revocationMetadata.txHash = hash as Hex;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: you could simplify this - moving the assignment out of the else block, and creating the revocationMetadata in a single statement:

Suggested change
const revocationMetadata: RevocationMetadata = {};
const { hash } = transactionMeta;
if (hash === undefined) {
controllerLog(
'Failed to attach transaction hash after revocation transaction confirmed',
{
txId,
permissionContext,
error: new Error(
'Confirmed transaction is missing transaction hash',
),
},
);
} else {
revocationMetadata.txHash = hash as Hex;
}
const { hash } = transactionMeta;
const revocationMetadata: RevocationMetadata = {
txHash: hash as Hex | undefined,
};
if (hash === undefined) {
controllerLog(
'Failed to attach transaction hash after revocation transaction confirmed',
{
txId,
permissionContext,
error: new Error(
'Confirmed transaction is missing transaction hash',
),
},
);
}

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.

4 participants