Creation and Initialization

Create a Routines Contract

Hosts use the deploy function to have the Factory clone the model (which, as mentioned, contains the standard logic):

function deploy(bytes memory data) public returns (address contractAddress, bytes memory initResultData) {
    initResultData = _call(contractAddress = _clone(fixedInflationImplementationAddress), data);
    emit FixedInflationDeployed(contractAddress, msg.sender, initResultData);
}

When the Factory does this, it calls the init function for the Routines contract, passing the encoded data as a data parameter.

The init function works as follow:

function init(address _extension, bytes memory extensionPayload, FixedInflationEntry memory newEntry, FixedInflationOperation[] memory newOperations) public returns(bytes memory extensionInitResult) {
  • _extension -> the address of the deployed extension to be linked to the contract. If it passed as address(0), a new Extension is cloned and deployed.

  • extensionInitData -> the encoded initialize extension data (available if an init extension function is provided). The default extension's init data contains the host address.

  • newEntry -> the FixedInflationEntry of the contract.

  • newOperations -> the FixedInflationOperation[] of the contract.

As noted above, the deployed extension doesn't need to have been initialized before this (and thus an init function is not provided), but can be done directly through the contract's init function, passing the extensionInitData in the payload.

If the FixedInflationEntry and FixedInflationOperation[] parameter was passed in init function, also the passed Operations are created.

_set(newEntry, newOperations);

Otherwise, Operations can be created directly using the setEntry function.

Last updated