OrchestratorFactory_v1.sol

Git Source

Inherits: IOrchestratorFactory_v1, ERC2771ContextUpgradeable, Ownable2StepUpgradeable, ERC165Upgradeable

Author: Inverter Network

OrchestratorFactory_v1 facilitates the deployment of {Orchestrator_v1}s and their associated modules for the Inverter Network, ensuring seamless creation and configuration of various components in a single transaction.

Utilizes {ERC2771ContextUpgradeable} for meta-transaction capabilities and {ERC165Upgradeable} for interface detection. {Orchestrator_v1}s are deployed through EIP-1167 minimal proxies for efficiency. Integrates with the module factory to instantiate necessary modules with custom configurations, supporting complex setup with interdependencies among modules.

State Variables

beacon

Returns the {IOrchestrator_v1} {IInverterBeacon_v1} address.

IInverterBeacon_v1 public override beacon;

moduleFactory

Returns the {IModuleFactory_v1} implementation address.

address public override moduleFactory;

_orchestrators

Maps the id to the {Orchestrator_v1}s.

mapping(uint => address) private _orchestrators;

_orchestratorIdCounter

The counter of the current {Orchestrator_v1} id.

Starts counting from 1.

uint private _orchestratorIdCounter;

_deploymentNonces

Maps a users address to a nonce. Used for the create2-based deployment.

mapping(address => uint) private _deploymentNonces;

__gap

Storage gap for future upgrades.

uint[50] private __gap;

Functions

supportsInterface

See {IERC165-supportsInterface}.

function supportsInterface(bytes4 interfaceId)
    public
    view
    virtual
    override(ERC165Upgradeable)
    returns (bool);

validOrchestratorId

Modifier to guarantee that the given id is valid.

modifier validOrchestratorId(uint id);

constructor

constructor(address _trustedForwarder)
    ERC2771ContextUpgradeable(_trustedForwarder);

init

The factories initializer function.

function init(
    address governor_,
    IInverterBeacon_v1 beacon_,
    address moduleFactory_
) external initializer;

Parameters

NameTypeDescription

governor_

address

The address of the {Governor_v1} contract.

beacon_

IInverterBeacon_v1

The address of the {IInverterBeacon_v1} containing the {Orchestrator_v1} implementation.

moduleFactory_

address

The address of the {ModuleFactory_v1} contract.

createOrchestrator

Creates a new {Orchestrator_v1}.

function createOrchestrator(
    WorkflowConfig memory workflowConfig,
    ModuleConfig memory fundingManagerConfig,
    ModuleConfig memory authorizerConfig,
    ModuleConfig memory paymentProcessorConfig,
    ModuleConfig[] memory moduleConfigs
) external returns (IOrchestrator_v1);

Parameters

NameTypeDescription

workflowConfig

WorkflowConfig

The workflow's config data.

fundingManagerConfig

ModuleConfig

The config data for the orchestrator's {IFundingManager_v1} instance.

authorizerConfig

ModuleConfig

The config data for the {Orchestrator_v1}'s {IAuthorizer_v1} instance.

paymentProcessorConfig

ModuleConfig

The config data for the orchestrator's {IPaymentProcessor_v1} instance.

moduleConfigs

ModuleConfig[]

Variable length set of optional module's config data.

Returns

NameTypeDescription

<none>

IOrchestrator_v1

CreatedOrchestrator Returns the created orchestrator instance

getOrchestratorByID

Returns the {IOrchestrator_v1} address that corresponds to the given id.

function getOrchestratorByID(uint id)
    external
    view
    validOrchestratorId(id)
    returns (address);

Parameters

NameTypeDescription

id

uint256

The requested orchestrator's id.

Returns

NameTypeDescription

<none>

address

orchestratorAddress The address of the corresponding {Orchestrator_v1}.

getOrchestratorIDCounter

Returns the counter of the current {Orchestrator_v1} id.

function getOrchestratorIDCounter() external view returns (uint);

Returns

NameTypeDescription

<none>

uint256

id The id of the next created {Orchestrator_v1}.

_createModuleProxies

Creates the modules based on their `moduleConfigs`.

function _createModuleProxies(
    ModuleConfig[] memory moduleConfigs,
    address orchestratorProxy,
    WorkflowConfig memory workflowConfig
) internal returns (address[] memory);

Parameters

NameTypeDescription

moduleConfigs

ModuleConfig[]

The config data of the modules that will be created with this function call.

orchestratorProxy

address

The address of the {Orchestrator_v1} Proxy that will be linked to the modules.

workflowConfig

WorkflowConfig

The workflow's config data.

_initModules

Internal function to initialize the modules.

function _initModules(
    address[] memory modules,
    ModuleConfig[] memory moduleConfigs,
    address proxy
) internal;

Parameters

NameTypeDescription

modules

address[]

The modules to initialize.

moduleConfigs

ModuleConfig[]

The config data of the modules that will be initialized.

proxy

address

The address of the {Orchestrator_v1} Proxy that will be linked to the modules.

_createSalt

Internal function to generate salt for the create2-based deployment flow. This salt is the hash of (msgSender, nonce), where the nonce is an increasing number for each user.

function _createSalt() internal returns (bytes32);

_msgSender

Needs to be overridden, because they are imported via the Ownable2Step as well.

function _msgSender()
    internal
    view
    virtual
    override(ERC2771ContextUpgradeable, ContextUpgradeable)
    returns (address sender);

_msgData

Needs to be overridden, because they are imported via the Ownable2Step as well.

function _msgData()
    internal
    view
    virtual
    override(ERC2771ContextUpgradeable, ContextUpgradeable)
    returns (bytes calldata);

_contextSuffixLength

function _contextSuffixLength()
    internal
    view
    virtual
    override(ERC2771ContextUpgradeable, ContextUpgradeable)
    returns (uint);

Last updated