Skip to main content

IPeriodicTaskManager

Git Source

Title: IPeriodicTaskManager

Interface for a contract that can manage periodic tasks with ordering capabilities

Functions

addPeriodicTask

Adds a periodic task to the end of the task list

This function should be protected by a role check for the "admin" role

function addPeriodicTask(address task_) external;

Parameters

NameTypeDescription
task_addressThe periodic task to add

addPeriodicTaskAtIndex

Adds a periodic task at a specific index in the task list

This function should be protected by a role check for the "admin" role

If the index is greater than the current length, the task will be added at the end

function addPeriodicTaskAtIndex(address task_, bytes4 customSelector_, uint256 index_) external;

Parameters

NameTypeDescription
task_addressThe periodic task to add
customSelector_bytes4The custom selector to use for the task (or 0)
index_uint256The index where to insert the task

removePeriodicTask

Removes a periodic task from the task list

This function should be protected by a role check for the "admin" role

function removePeriodicTask(address task_) external;

Parameters

NameTypeDescription
task_addressThe periodic task to remove

removePeriodicTaskAtIndex

Removes a periodic task at a specific index

This function should be protected by a role check for the "admin" role

function removePeriodicTaskAtIndex(uint256 index_) external;

Parameters

NameTypeDescription
index_uint256The index of the task to remove

getPeriodicTaskCount

Gets the total number of periodic tasks

function getPeriodicTaskCount() external view returns (uint256 _taskCount);

Returns

NameTypeDescription
_taskCountuint256The number of periodic tasks

getPeriodicTaskAtIndex

Gets a periodic task at a specific index

function getPeriodicTaskAtIndex(uint256 index_) external view returns (address _task, bytes4 _customSelector);

Parameters

NameTypeDescription
index_uint256The index of the task to get

Returns

NameTypeDescription
_taskaddressThe address of the periodic task at the specified index
_customSelectorbytes4The custom selector for the task (or 0)

getPeriodicTasks

Gets all periodic tasks

function getPeriodicTasks() external view returns (address[] memory _tasks, bytes4[] memory _customSelectors);

Returns

NameTypeDescription
_tasksaddress[]An array of all periodic tasks in order
_customSelectorsbytes4[]An array of all custom selectors in order

getPeriodicTaskIndex

Gets the index of a specific periodic task

function getPeriodicTaskIndex(address task_) external view returns (uint256 _index);

Parameters

NameTypeDescription
task_addressThe periodic task to find

Returns

NameTypeDescription
_indexuint256The index of the task, or type(uint256).max if not found

hasPeriodicTask

Checks if a periodic task exists in the manager

function hasPeriodicTask(address task_) external view returns (bool _exists);

Parameters

NameTypeDescription
task_addressThe periodic task to check

Returns

NameTypeDescription
_existsboolTrue if the task exists, false otherwise

Events

PeriodicTaskAdded

Emitted when a periodic task is added

event PeriodicTaskAdded(address indexed task_, bytes4 customSelector_, uint256 indexed index_);

Parameters

NameTypeDescription
task_addressThe address of the periodic task
customSelector_bytes4
index_uint256The index where the task was added

PeriodicTaskRemoved

Emitted when a periodic task is removed

event PeriodicTaskRemoved(address indexed task_, uint256 indexed index_);

Parameters

NameTypeDescription
task_addressThe address of the periodic task
index_uint256The index where the task was removed from

Errors

PeriodicTaskManager_TaskNotFound

Error thrown when trying to remove a task that doesn't exist

error PeriodicTaskManager_TaskNotFound(address task_);

PeriodicTaskManager_TaskAlreadyExists

Error thrown when trying to add a task that already exists

error PeriodicTaskManager_TaskAlreadyExists(address task_);

PeriodicTaskManager_ZeroAddress

Error thrown when the provided task address is zero

error PeriodicTaskManager_ZeroAddress();

PeriodicTaskManager_NotPeriodicTask

Error thrown when the provided task does not implement the IPeriodicTask interface

error PeriodicTaskManager_NotPeriodicTask(address task_);

PeriodicTaskManager_CustomSelectorFailed

Error thrown when a custom selector fails

error PeriodicTaskManager_CustomSelectorFailed(address task_, bytes4 customSelector_, bytes reason_);