IHatcher

Git Source

Inherits: IBeacon

Author: mortimr @ Kiln

The Hatcher can deploy, upgrade, fix and pause a set of instances called cubs. All cubs point to the same coomon implementation.

Unstructured Storage Friendly

Functions

implementation

Retrieve the common implementation.

function implementation() external view returns (address implementationAddress);

Returns

NameTypeDescription
implementationAddressaddressAddress of the common implementation

status

Retrieve cub status details.

function status(address cub) external view returns (address implementationAddress, bool hasFixes, bool isPaused);

Parameters

NameTypeDescription
cubaddressThe address of the cub to fetch the status of

Returns

NameTypeDescription
implementationAddressaddressThe current implementation address to use
hasFixesboolTrue if there are fixes to apply
isPausedboolTrue if the system is paused globally or the calling cub is paused

initialProgress

Retrieve the initial progress.

This value is the starting progress value for all new cubs

function initialProgress() external view returns (uint256 currentInitialProgress);

Returns

NameTypeDescription
currentInitialProgressuint256The initial progress

progress

Retrieve the current progress of a specific cub.

function progress(address cub) external view returns (uint256 currentProgress);

Parameters

NameTypeDescription
cubaddressAddress of the cub

Returns

NameTypeDescription
currentProgressuint256The current progress of the cub

globalPaused

Retrieve the global pause status.

function globalPaused() external view returns (bool isGlobalPaused);

Returns

NameTypeDescription
isGlobalPausedboolTrue if globally paused

paused

Retrieve a cub pause status.

function paused(address cub) external view returns (bool isPaused);

Parameters

NameTypeDescription
cubaddressAddress of the cub

Returns

NameTypeDescription
isPausedboolTrue if paused

pauser

Retrieve the address of the pauser.

function pauser() external view returns (address);

fixes

Retrieve a cub's global fixes that need to be applied, taking its progress into account.

function fixes(address cub) external view returns (address[] memory fixesAddresses);

Parameters

NameTypeDescription
cubaddressAddress of the cub

Returns

NameTypeDescription
fixesAddressesaddress[]An array of addresses that implement fixes

globalFixes

Retrieve the raw list of global fixes.

function globalFixes() external view returns (address[] memory globalFixesAddresses);

Returns

NameTypeDescription
globalFixesAddressesaddress[]An array of addresses that implement the global fixes

nextHatch

Retrieve the address of the next hatched cub.

function nextHatch() external view returns (address nextHatchedCub);

Returns

NameTypeDescription
nextHatchedCubaddressThe address of the next cub

frozen

Retrieve the freeze status.

function frozen() external view returns (bool);

Returns

NameTypeDescription
<none>boolTrue if frozen

freezeTime

Retrieve the timestamp when the freeze happens.

function freezeTime() external view returns (uint256);

Returns

NameTypeDescription
<none>uint256The freeze timestamp

hatch

Creates a new cub.

function hatch(bytes calldata cdata) external returns (address cubAddress);

Parameters

NameTypeDescription
cdatabytesThe calldata to use for the initial atomic call

Returns

NameTypeDescription
cubAddressaddressThe address of the new cub

hatch

Creates a new cub, without calldata.

function hatch() external returns (address cubAddress);

Returns

NameTypeDescription
cubAddressaddressThe address of the new cub

commitFixes

Sets the progress of the caller to the current global fixes array length.

function commitFixes() external;

setPauser

Sets the address of the pauser.

function setPauser(address newPauser) external;

Parameters

NameTypeDescription
newPauseraddressAddress of the new pauser

applyFixToCubs

Apply a fix to several cubs.

function applyFixToCubs(address fixer, address[] calldata cubs) external;

Parameters

NameTypeDescription
fixeraddressFixer contract implementing the fix
cubsaddress[]List of cubs to apply the fix on

applyFixesToCub

Apply several fixes to one cub.

function applyFixesToCub(address cub, address[] calldata fixers) external;

Parameters

NameTypeDescription
cubaddressThe cub to apply the fixes on
fixersaddress[]List of fixer contracts implementing the fixes

registerGlobalFix

Register a new global fix for cubs to call asynchronously.

function registerGlobalFix(address fixer) external;

Parameters

NameTypeDescription
fixeraddressAddress of the fixer implementing the fix

deleteGlobalFix

Deletes a global fix from the array.

function deleteGlobalFix(uint256 index) external;

Parameters

NameTypeDescription
indexuint256Index of the global fix to remove

upgradeTo

Upgrades the common implementation address.

function upgradeTo(address newImplementation) external;

Parameters

NameTypeDescription
newImplementationaddressAddress of the new common implementation

upgradeToAndChangeInitialProgress

Upgrades the common implementation address and the initial progress value.

function upgradeToAndChangeInitialProgress(address newImplementation, uint256 initialProgress_) external;

Parameters

NameTypeDescription
newImplementationaddressAddress of the new common implementation
initialProgress_uint256The new initial progress value

setInitialProgress

Sets the initial progress value.

function setInitialProgress(uint256 initialProgress_) external;

Parameters

NameTypeDescription
initialProgress_uint256The new initial progress value

setCubProgress

Sets the progress of a cub.

function setCubProgress(address cub, uint256 newProgress) external;

Parameters

NameTypeDescription
cubaddressAddress of the cub
newProgressuint256New progress value

pauseCubs

Pauses a set of cubs.

function pauseCubs(address[] calldata cubs) external;

Parameters

NameTypeDescription
cubsaddress[]List of cubs to pause

unpauseCubs

Unpauses a set of cubs.

function unpauseCubs(address[] calldata cubs) external;

Parameters

NameTypeDescription
cubsaddress[]List of cubs to unpause

globalPause

Pauses all the cubs of the system.

function globalPause() external;

globalUnpause

Unpauses all the cubs of the system.

If a cub was specifically paused, this method won't unpause it

function globalUnpause() external;

freeze

Sets the freeze timestamp.

function freeze(uint256 freezeTimeout) external;

Parameters

NameTypeDescription
freezeTimeoutuint256The timeout to add to current timestamp before freeze happens

cancelFreeze

Cancels the freezing procedure.

function cancelFreeze() external;

Events

GlobalPause

Emitted when the system is globally paused.

event GlobalPause();

GlobalUnpause

Emitted when the system is globally unpaused.

event GlobalUnpause();

Pause

Emitted when a specific cub is paused.

event Pause(address cub);

Unpause

Emitted when a specific cub is unpaused.

event Unpause(address cub);

DeletedGlobalFix

Emitted when a global fix is removed.

event DeletedGlobalFix(uint256 index);

AppliedFix

Emitted when a cub has properly applied a fix.

event AppliedFix(address cub, address fix);

Upgraded

Emitted the common implementation is updated.

event Upgraded(address indexed implementation);

Hatched

Emitted a new cub is hatched.

event Hatched(address indexed cub, bytes cdata);

SetInitialProgress

Emitted a the initial progress has been changed.

event SetInitialProgress(uint256 initialProgress);

SetPauser

Emitted a new pauser is set.

event SetPauser(address pauser);

CommittedFixes

Emitted a cub committed some global fixes.

event CommittedFixes(address cub, uint256 progress);

RegisteredGlobalFix

Emitted a global fix is registered.

event RegisteredGlobalFix(address fix, uint256 index);

Errors

ImplementationNotAContract

The provided implementation is not a smart contract.

error ImplementationNotAContract(address implementation);