-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Add Gator Permissions Revocation Flow #37209
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
…regatedGatorPermissionByChainId selector
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
I have read the CLA Document and I hereby sign the CLA |
| return { | ||
| // etc | ||
| getState: this.getState.bind(this), | ||
| call: async (method, params, networkClientId) => { |
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 am pretty sure this is not ok. This changes the flow for: eth_call for all calls. Better to change isDelegationDisabled to include direct call then to change this.
| const callData = encodeDisabledDelegationsCheck({ delegationHash }); | ||
|
|
||
| // Make eth_call request through the network controller | ||
| const result = await submitRequestToBackground<Hex>('call', [ |
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.
Rather make this here:
const networkClient = this.networkController.getNetworkClientById(networkClientId);
const result = await networkClient.provider.request({
method: 'eth_call',
params: [{
to: delegationManagerAddress,
data: callData,
}, 'latest'],
});
Something like that. Instead of overriding how eth_call is handled.
| if (isDisabled) { | ||
| await submitRevocation(permissionContext); | ||
| // Return a mock transaction meta since no actual transaction is needed | ||
| const mockTransactionMeta = { |
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 would rather return null, or a different object (like a new object type) instead of a mock object.
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.
if you return null you can then probably remove chainId from dependency array
| ); | ||
| }; | ||
| export const fetchAndUpdateGatorPermissions = async ( | ||
| params?: Json, |
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.
Maybe define params type? Probably define in core and import here so its not just Json?
| api: { | ||
| fetchAndUpdateGatorPermissions: | ||
| controller.fetchAndUpdateGatorPermissions.bind(controller), | ||
| addPendingRevocation: controller.addPendingRevocation.bind(controller), |
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.
Probably change the PR to draft until core is released and you can update package.json with higher version of core so that this functions are available.
| const delegation = | ||
| extractDelegationFromGatorPermissionContext(permissionContext); | ||
|
|
||
| const delegationHash = getDelegationHashOffchain(delegation); |
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.
nit (and not connected to this PR) but maybe a better name would be generateDelegationHash ?

Overview
This PR adds a complete revocation flow for gator permissions, including delegation status checking and transaction handling.
Key Changes
1. Enhanced Gator Permissions Controller
isDelegationDisabledfunction to check if a delegation is already disabled on-chainfetchAndUpdateGatorPermissionsto accept optional parameters for filtering2. Background API Integration
callmethod: New API method inmetamask-controller.jsto handleeth_callrequestsTransactionController:transactionConfirmedevent to allowed events3. Delegation Utilities
encodeDisabledDelegationsCheckanddecodeDisabledDelegationsResultfor on-chain delegation status checking4. Revocation Flow Improvements
Technical Details
Files Modified:
app/scripts/metamask-controller.js: Addedcallmethod for RPC requestsapp/scripts/controller-init/messengers/gator-permissions/gator-permissions-controller-messenger.ts: Added transaction confirmed eventui/store/controller-actions/gator-permissions-controller.ts: Enhanced with delegation checking and improved APIui/hooks/gator-permissions/useRevokeGatorPermissions.ts: Added delegation status checkingshared/lib/delegation/delegation.ts: New delegation utility functionsKey Features:
Testing
Note
Implements gator permission revocation with on-chain disabled checks, wires background
eth_call, and updates messaging/events and UI hooks to manage pending/submitted revocations.addPendingRevocationandsubmitRevocationvia controller init and UI controller actions (ui/store/controller-actions/gator-permissions-controller.ts).fetchAndUpdateGatorPermissionsto accept optional params; UI hook passes{ isRevoked: false }.isDelegationDisabledUI action: performs backgroundeth_calltodisabledDelegations(bytes32)and decodes result.ui/hooks/gator-permissions/useRevokeGatorPermissions.ts):getDelegationHashOffchain) and skip tx if already disabled; callsubmitRevocationand return a mock confirmedTransactionMeta.addPendingRevocation.shared/lib/delegation/delegation.ts):encodeDisabledDelegationsCheckanddecodeDisabledDelegationsResulthelpers.app/scripts/metamask-controller.js):call(method, params, networkClientId)export; special-caseeth_callvia the correct network client, otherwise delegate tocontrollerMessenger.app/scripts/controller-init/messengers/gator-permissions/...):transactionConfirmed,transactionFailed,transactionDropped.useRevokeGatorPermissionstests to cover disabled checks, pending/submitted revocations, and navigation behavior.Written by Cursor Bugbot for commit a3dd9a0. This will update automatically on new commits. Configure here.