-
Notifications
You must be signed in to change notification settings - Fork 17
Module Factory
Rahul Saxena edited this page Aug 7, 2023
·
1 revision
File: ModuleFactory.sol
- Module Factory is an owned factory for deploying modules.
- Module factory handles the linking of a module's IModule.Metadata to its IBeacon instance contract using the
_beacons
mapping. - The registered metadata is used to deploy and initialize inverter modules using the
createModule
function. - A metadata's registered IBeacon implementation can not be changed after registration.
- You have to register a new IBeacon implementation by changing the metadata (e.g. by increasing the version).
- validMetadata
modifier validMetadata(IModule.Metadata memory data)
Modifier to guarantee function is only callable with valid metadata. The validity is checked via the isValid
function from LibMetadata
library.
- validBeacon
modifier validBeacon(IBeacon beacon)
Modifier to guarantee function is only callable with valid {IBeacon} instance. Revert if beacon's implementation is zero address.
function getBeaconAndId(IModule.Metadata memory metadata)
external
view
returns (IBeacon, bytes32);
Returns the {IBeacon} instance registered and the id for given metadata.
- metadata: The module's metadata of type
IModule.Metadata
- IBeacon: The module's {IBeacon} instance registered
- bytes32: The metadata's id
function createModule(
IModule.Metadata memory metadata,
IOrchestrator orchestrator,
bytes memory configData
) external returns (address);
Creates a module instance identified by the metadata passed in the parameters.
- metadata: The module's metadata of type
IModule.Metadata
- orchestrator: The orchestrator's instance of the module.
- configData: The configuration data of the module. Contains the information required to initialize the module.
- address: The address of the newly deployed module.
function registerMetadata(IModule.Metadata memory metadata, IBeacon beacon)
external;
Registers metadata metadata
with {IBeacon} implementation beacon
. The function is only callable by the owner.
- metadata: The module's metadata of type
IModule.Metadata
- beacon: The module's {IBeacon} instance.