GatorPermissionsController Actions
8 actions registered.
| Name | Deprecated |
|---|---|
addPendingRevocation | |
decodePermissionFromPermissionContextForOrigin | |
fetchAndUpdateGatorPermissions | |
getState | |
initialize | |
isPendingRevocation | |
submitDirectRevocation | |
submitRevocation |
GatorPermissionsController:addPendingRevocation
Package: @metamask/gator-permissions-controller
Adds a pending revocation that will be submitted once the transaction is confirmed.
This method sets up listeners for the user's approval/rejection decision and terminal transaction states (confirmed, failed, dropped). The flow is:
- Wait for user to approve or reject the transaction
- If approved, add to pending revocations state
- If rejected, cleanup without adding to state
- If confirmed, submit the revocation
- If failed or dropped, cleanup
Includes a timeout safety net to prevent memory leaks if the transaction never reaches a terminal state.
Parameters:
| Name | Description |
|---|---|
params | The pending revocation parameters. |
Returns: A promise that resolves when the listener is set up.
Handler signature:
(params: PendingRevocationParams) => Promise<void>
GatorPermissionsController:decodePermissionFromPermissionContextForOrigin
Package: @metamask/gator-permissions-controller
Decodes a permission context into a structured permission for a specific origin.
This method validates the caller origin, decodes the provided permissionContext
into delegations, identifies the permission type from the caveat enforcers,
extracts the permission-specific data and expiry, and reconstructs a
DecodedPermission containing chainId, account addresses, to, type and data.
Parameters:
| Name | Description |
|---|---|
args | The arguments to this function. |
args.origin | The caller's origin; must match the configured permissions provider Snap id. |
args.chainId | Numeric EIP-155 chain id used for resolving enforcer contracts and encoding. |
args.delegation | delegation representing the permission. |
args.metadata | metadata included in the request. |
args.metadata.justification | the justification as specified in the request metadata. |
args.metadata.origin | the origin as specified in the request metadata. |
Returns: A decoded permission object suitable for UI consumption and follow-up actions.
Handler signature:
({ origin, chainId, delegation: { caveats, delegator, delegate, authority }, metadata: { justification, origin: specifiedOrigin }, }: {
origin: string;
chainId: number;
metadata: {
justification: string;
origin: string;
};
delegation: DelegationDetails;
}) => DecodedPermission
GatorPermissionsController:fetchAndUpdateGatorPermissions
Package: @metamask/gator-permissions-controller
Fetches granted permissions from the gator permissions provider Snap and updates state. If a sync is already in progress, returns the same promise. After the sync completes, the next call will perform a new sync.
Returns: A promise that resolves when the sync completes. All data is available via the controller's state.
Handler signature:
() => Promise<void>
GatorPermissionsController:getState
Package: @metamask/gator-permissions-controller
The action which can be used to retrieve the state of the
GatorPermissionsController.
Handler signature:
() => GatorPermissionsControllerState
GatorPermissionsController:initialize
Package: @metamask/gator-permissions-controller
Initializes the controller. Call once after construction to ensure the controller is ready for use.
Returns: A promise that resolves when initialization is complete.
Handler signature:
() => Promise<void>
GatorPermissionsController:isPendingRevocation
Package: @metamask/gator-permissions-controller
Checks if a permission context is in the pending revocations list.
Parameters:
| Name | Description |
|---|---|
permissionContext | The permission context to check. |
Returns: true if the permission context is pending revocation, false otherwise.
Handler signature:
(permissionContext: Hex) => boolean
GatorPermissionsController:submitDirectRevocation
Package: @metamask/gator-permissions-controller
Submits a revocation directly without requiring an on-chain transaction. Used for already-disabled delegations that don't require an on-chain transaction.
This method:
- Adds the permission context to pending revocations state (disables UI button)
- Immediately calls submitRevocation to remove from snap storage
- On success, removes from pending revocations state (re-enables UI button)
- On failure, keeps in pending revocations so UI can show error/retry state
Parameters:
| Name | Description |
|---|---|
params | The revocation parameters containing the permission context. |
Returns: A promise that resolves when the revocation is submitted successfully.
Handler signature:
(params: RevocationParams) => Promise<void>
GatorPermissionsController:submitRevocation
Package: @metamask/gator-permissions-controller
Submits a revocation to the gator permissions provider snap.
Parameters:
| Name | Description |
|---|---|
revocationParams | The revocation parameters containing the permission context. |
Returns: A promise that resolves when the revocation is submitted successfully.
Handler signature:
(revocationParams: RevocationParams) => Promise<void>