Skip to main content

GatorPermissionsController Actions

8 actions registered.

NameDeprecated
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:

  1. Wait for user to approve or reject the transaction
  2. If approved, add to pending revocations state
  3. If rejected, cleanup without adding to state
  4. If confirmed, submit the revocation
  5. If failed or dropped, cleanup

Includes a timeout safety net to prevent memory leaks if the transaction never reaches a terminal state.

Parameters:

NameDescription
paramsThe 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:

NameDescription
argsThe arguments to this function.
args.originThe caller's origin; must match the configured permissions provider Snap id.
args.chainIdNumeric EIP-155 chain id used for resolving enforcer contracts and encoding.
args.delegationdelegation representing the permission.
args.metadatametadata included in the request.
args.metadata.justificationthe justification as specified in the request metadata.
args.metadata.originthe 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:

NameDescription
permissionContextThe 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:

  1. Adds the permission context to pending revocations state (disables UI button)
  2. Immediately calls submitRevocation to remove from snap storage
  3. On success, removes from pending revocations state (re-enables UI button)
  4. On failure, keeps in pending revocations so UI can show error/retry state

Parameters:

NameDescription
paramsThe 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:

NameDescription
revocationParamsThe revocation parameters containing the permission context.

Returns: A promise that resolves when the revocation is submitted successfully.

Handler signature:

(revocationParams: RevocationParams) => Promise<void>