-
Notifications
You must be signed in to change notification settings - Fork 16
Module
File: Module.sol
- This contract acts as the base contract for modules.
- This contract provides a framework for triggering and receiving orchestrator callbacks (via
call
) - This contract also provides a modifier to authenticate callers via the module's orchestrator.
- Each module is identified via a unique identifier based on its major version, title, and url given in the metadata.
- Modules will automatically be updated in case of minor updates, however they won't be automatically updated in case of major updates
modifier onlyAuthorized()
Modifier to guarantee function is only callable by addresses authorized via Orchestrator.
modifier onlyOrchestrator()
Modifier to guarantee function is only callable by the orchestrator. onlyOrchestrator
functions MUST only access the module's storage, i.e. __Module_
variables. Advised to use function prefix __Module_
modifier onlyAuthorizedOrManager()
Modifier to guarantee function is only callable either by addresses authorized via Orchestrator or the Orchestrator's manager.
modifier initializer2()
Same functioning as the OpenZeppelin initializer, which is to prevent re-initialization of init
functions, but for the init2
function.
modifier validDependencyData(bytes memory dependencyData)
Modifier to ensure that the dependencyData
passed is valid or not. This simply checks whether the first decoded element from the dependencyData
is a boolean or not and then whether it is true or not.
1. identifier
function identifier() external view returns (bytes32);
Returns the module's identifier. The identifier is defined as the keccak256 hash of the module's abi packed encoded major version, URL, and title.
Return Data
- Returns the module's identifier. (Each module is identified via a unique identifier based on its major version, title, and url given in the metadata.)
2. version
function version() external view returns (uint, unit);
This function returns the module's version.
Return data
- The module's major version.
- The module's minor version.
3. url
function url() external view returns (string memory);
This function returns the module's URL.
Return data
- The module's URL.
4. title
function title() external view returns (string memory);
This function returns the module's title.
Return data
- The module's title.
function orchestrator() external view returns (IOrchestrator);
This function returns the module's {IOrchestrator} orchestrator instance.
Return data
- The module's orchestrator.
function init( IOrchestrator orchestrator, Metadata memory metadata, bytes memory configdata) external;
The module's initializer function. CAN be overriden by downstream contract. MUST call __Module_init()
.
Parameter(s)
-
IOrchestrator orchestrator
-> The module's orchestrator instance. -
Metadata metadata
-> The module's metadata. -
bytes configdata
-> Variable config data for specific module implementations.
function init2(IOrchestrator orchestrator, bytes memory configData)
external;
This is the second initialization function of the module to take care of (cross)dependencies.
- IOrchestrator orchestrator: The module's orchestrator instance.
- bytes configData: Variable config data for specific module implementations.
This is a section of the documentation that breaks down the Module documentation in more granular details.
Modules are used within the Inverter Network to implement specific business logic that can be added to an orchestrator during its initialization.
Modules must be trusted by the orchestrator creator.
Modules are activated in an orchestrator during its initialization. They can be deactivated by authorized addresses at any time.
The contract provides a __Module_init(orchestrator)
function for initialization that MUST be called during the downstream module contract's init()
function in order to correctly initialize the storage.
The init()
function is declared inside the base Module
contract and, therefore, has to be implemented inside the downstream contract.
Similarly, the init2()
function is also declared inside the base Module
contract and can be implemented inside the downstream contracts if that module has a requirement for a late dependency injection.
Users are authenticated using the orchestrator's IAuthenticator
instance.
This ensures that all access management is handled solely by the orchestrator.
The base Module contract (src/modules/base/Module.sol
) provides a framework for triggering and receiving orchestrator callbacks (via call
) and a modifier to authenticate callers via the module's orchestrator using the IAuthorizer
interface.
A module can trigger a callback from its orchestrator via the internal _triggerOrchestratorCallback(bytes memory data)
function.
The callback is executed via call
in the module's context.
Per convention, the function name SHOULD be prefixed with __Module_
.
Orchestrator callbacks executed in the module's context MUST be authenticated via the onlyOrchestrator
modifier!