Skip to content
Lattice

GelatoAutomateAdapterLib

Git Source

Title: GelatoAutomateAdapterLib

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from Gelato (https://github.com/gelatodigital/automate)

Library that wraps Gelato Automate (Web3 Functions) task management. This is the create/track/cancel layer; Gelato executes a created task through a task-creator-specific dedicated msg.sender. Consumer exec entrypoints must gate on it via requireDedicatedMsgSender.

Functions

gelatoAutomateAdapterStorage

Returns the ERC-7201 storage struct for GelatoAutomateAdapter.

function gelatoAutomateAdapterStorage() internal pure returns (GelatoAutomateAdapterStorage storage $);

Returns

NameTypeDescription
$GelatoAutomateAdapterStorage

__GelatoAutomateAdapter_init

Registers the IGelatoAutomateAdapter ERC-165 interface.

Must be called between preInitializer / postInitializer.

function __GelatoAutomateAdapter_init() internal;

registerInterface

Writes true to the ERC-165 map slot for IGelatoAutomateAdapter.

function registerInterface() internal;

getConfig

Returns the current Automate configuration.

function getConfig() internal view returns (address automate, address dedicatedMsgSender);

Returns

NameTypeDescription
automateaddressThe Gelato Automate contract.
dedicatedMsgSenderaddressThe dedicated msg.sender Gelato execs through.

isTask

Returns whether taskId is tracked by this adapter.

function isTask(bytes32 taskId) internal view returns (bool);

Parameters

NameTypeDescription
taskIdbytes32The task ID to query.

Returns

NameTypeDescription
<none>bool

_requireConfigured

Reverts unless both the Automate contract and dedicated msg.sender are set.

Reverts GelatoAutomateNotConfigured if either field is zero.

function _requireConfigured() internal view returns (address a);

Returns

NameTypeDescription
aaddressThe configured Gelato Automate contract.

requireDedicatedMsgSender

Enforces the dedicated msg.sender on consumer exec entrypoints.

Consumer exec entrypoints call this. It is the dedicatedMsgSender enforcement on the exec path: Gelato runs a created task through a task-creator-specific dedicated msg.sender, and only that address may drive the exec flow. Reverts GelatoAutomateOnlyDedicatedMsgSender.

function requireDedicatedMsgSender() internal view;

setConfig

Sets or replaces the Automate configuration.

Caller must hold DEFAULT_ADMIN_ROLE. Reverts GelatoAutomateInvalidConfig if either address is zero.

function setConfig(address automate, address dedicatedMsgSender) internal;

Parameters

NameTypeDescription
automateaddressThe Gelato Automate contract.
dedicatedMsgSenderaddressThe dedicated msg.sender Gelato execs through.

createTask

Creates and tracks a Gelato Automate task.

Caller must hold DEFAULT_ADMIN_ROLE. Reverts GelatoAutomateNotConfigured if not configured. Reverts GelatoAutomateTaskExists if the returned task ID is already tracked.

function createTask(
        address execAddress,
        bytes calldata execDataOrSelector,
        IGelatoAutomate.ModuleData calldata moduleData,
        address feeToken
    ) internal returns (bytes32 taskId);

Parameters

NameTypeDescription
execAddressaddressThe contract Gelato will call when the task runs.
execDataOrSelectorbytesThe calldata (or selector) to run.
moduleDataIGelatoAutomate.ModuleDataThe modules configuring how/when the task triggers.
feeTokenaddressThe fee token (address(0) for native).

Returns

NameTypeDescription
taskIdbytes32The Automate-assigned task ID.

cancelTask

Cancels and untracks a Gelato Automate task.

Caller must hold DEFAULT_ADMIN_ROLE. Reverts GelatoAutomateNotConfigured if not configured. Reverts GelatoAutomateTaskNotFound if the task is not tracked.

function cancelTask(bytes32 taskId) internal;

Parameters

NameTypeDescription
taskIdbytes32The task to cancel.