GelatoAutomateAdapterLib
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
| Name | Type | Description |
|---|---|---|
| $ | 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
| Name | Type | Description |
|---|---|---|
| automate | address | The Gelato Automate contract. |
| dedicatedMsgSender | address | The dedicated msg.sender Gelato execs through. |
isTask
Returns whether taskId is tracked by this adapter.
function isTask(bytes32 taskId) internal view returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| taskId | bytes32 | The task ID to query. |
Returns
| Name | Type | Description |
|---|---|---|
| <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
| Name | Type | Description |
|---|---|---|
| a | address | The 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
| Name | Type | Description |
|---|---|---|
| automate | address | The Gelato Automate contract. |
| dedicatedMsgSender | address | The 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
| Name | Type | Description |
|---|---|---|
| execAddress | address | The contract Gelato will call when the task runs. |
| execDataOrSelector | bytes | The calldata (or selector) to run. |
| moduleData | IGelatoAutomate.ModuleData | The modules configuring how/when the task triggers. |
| feeToken | address | The fee token (address(0) for native). |
Returns
| Name | Type | Description |
|---|---|---|
| taskId | bytes32 | The 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
| Name | Type | Description |
|---|---|---|
| taskId | bytes32 | The task to cancel. |