-
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Store metadata when revoking a permission #228
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?
Conversation
… feat/store-metadata-when-revoking-permission
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.
A couple of general comments, and, I think a more architectural concern:
I think we should remove isRevoked from the stored permission, and use the existence of revocationMetadata to determine whether the permission is revoked to help improve data integrity.
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
packages/gator-permissions-snap/src/clients/blockchainMetadataClient.ts
Outdated
Show resolved
Hide resolved
| logger.debug('submitRevocation() called with params:', params); | ||
|
|
||
| const { permissionContext } = validateRevocationParams(params); | ||
| const { permissionContext, metadata } = validateRevocationParams(params); |
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.
we are trusting the timestamp provided by the caller.
We could accept just the txhash (instead of the metadata), fetch the block, and fetch it's timestamp. We are already fetching the tx receipt to ensure it's success.
I don't know how important it is that we have the correct block timestamp.
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. If we ever need a block timestamp to present to the user in the MM client, we can fetch the tx receipt. Seems unnecessary to store block timestamp in the profile sync.
| * @throws ChainDisconnectedError if the provider is on the wrong chain. | ||
| * @throws ResourceUnavailableError if the on-chain check fails and we cannot determine the status. | ||
| */ | ||
| public async checkTransactionReceipt({ |
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 don't think this is the correct place for this function - this class is a "Client that fetches token metadata directly from the blockchain".
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 was following the pattern of checkDelegationDisabledOnChain, which is also in this file, to maintain consistency. It's a bit confusing since the file name is blockchainMetadataClient but the class name in the file is BlockchainTokenMetadataClient.
My suggestion here:
- Create a new class in the file called
BlockchainMetadataClient - Move
checkDelegationDisabledOnChain()andcheckTransactionReceipt()into that new class
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 created a new class, BlockchainMetadataClient, and moved checkDelegationDisabledOnChain() and checkTransactionReceipt() into it.
| throw new InternalError( | ||
| `Transaction receipt not found after ${retries + 1} attempts`, | ||
| ); |
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 think the code here can never execute because the loop either returns, throws, or continues.
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.
Yes, the throw after the loop is unreachable, but it still satisfies TypeScript's control-flow analysis(ie, ts complains with Function lacks ending return statement, and return type does not include 'undefined') when we remove it, even though the code can't logically reach certain points.
| mockBlockchainMetadataClient.checkTransactionReceipt.mockResolvedValueOnce( | ||
| true, | ||
| ); |
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.
All submitRevocation tests mock checkTransactionReceipt to return true, but there's no test for when it returns false
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 added a test case that captures when checkTransactionReceipt.mockResolvedValueOnce returns false which should throw an error - Error(Transaction ${txHash} was not successful. Cannot process revocation.)
… make txHash property optional on RevocationMetadata type
…ationMetadata to handle legacy data that was created before revocationMetadata was introduced
…egation disable and transaction receipt functions checks to BlockchainMetadataClient class
Description
Currently, during permission revocation submission, we store a
booleanrevoked flag to track the permission revocation status in profile sync. This PR extends the permission revocation submission process to allow storing additional metadata on the revocation transaction.References
Required by(Core): Attach metadata when submitting a revocation to the permission provider snap
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Introduces on-chain-aware revocation handling and metadata persistence.
StoredGrantedPermissionwithrevocationMetadataand updatesupdatePermissionRevocationStatusto persist/clear it; validates via zod; maintains 400kb limitssubmitRevocationnow validatesrevocationMetadata, checks delegation disabled on-chain, optionally validatestxHashvia receipt status, then stores revocation with metadataBlockchainMetadataClientfor on-chain checks; addsgetTransactionReceiptwith retry logic andvalidateTransactionReceiptTransactionReceipttype andzTransactionReceipt; updatesvalidateRevocationParamsto acceptrevocationMetadataBlockchainMetadataClientinindex.tsWritten by Cursor Bugbot for commit 81e61df. This will update automatically on new commits. Configure here.