-
-
Notifications
You must be signed in to change notification settings - Fork 262
feat: Attach metadata when submitting a revocation to the permission provider snap #7503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: Attach metadata when submitting a revocation to the permission provider snap #7503
Conversation
jeffsmale90
left a comment
There was a problem hiding this 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,
packages/gator-permissions-controller/src/GatorPermissionsController.ts
Outdated
Show resolved
Hide resolved
| */ | ||
| export type RevocationMetadata = { | ||
| txHash: Hex; | ||
| blockTimestamp: string; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be interesting to include the timestamp of when it was marked as revoked - especially if there's no hash 🤷
| /** | ||
| * The metadata associated with the permission revocation transaction. | ||
| */ | ||
| metadata?: RevocationMetadata; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes sense - I still think it makes more sense to set the revocationMetadata, but just make the txHash property optional. It reduces the data redundancy, making it more difficult to get inconsistent data, or to mis-interpret the data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the RevocationParams to make revocationMetadata required and made txHash optional on RevocationMetadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making revocationMetadata required on RevocationParams will introduce a breaking change to the submitRevocation() interface. I will open a daft PR on the MM client to update calls to submitRevocation() to match the new interface.
| const revocationParams = metadata | ||
| ? { permissionContext, metadata } | ||
| : { permissionContext }; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Explanation
This PR extends the
GatorPermissionsControllerto allow attaching metadata when submitting a revocation to the permission provider snap. Metadata includes:The block timestampReferences
Requires: feat: Store metadata when revoking a permission
Checklist
Note
Introduces metadata support for revocation submissions and updates flow to include transaction hash on confirmation.
RevocationParamsnow requiresrevocationMetadata;submitRevocation/submitDirectRevocationforward it topermissionsProvider_submitRevocationtransactionMeta.hashontransactionConfirmedand setsrevocationMetadata.txHash; logs when hash is missingrevocationMetadata, validate refresh viapermissionsProvider_getGrantedPermissions, and cover tx-hash propagationWritten by Cursor Bugbot for commit 52b2bef. This will update automatically on new commits. Configure here.