ModuleRegistry.sol
This contract is used to register and track modules in the protocol.
modules
mapping(string => address) modules
Returns the address of a registered module by its name.
moduleTypes
mapping(address => string) moduleTypes
Returns the module type of a registered module by its address.
allModuleTypes
mapping(string => bytes4) allModuleTypes
Returns the interface ID of a registered module type.
constructor
constructor(address governance) public
registerModuleType
function registerModuleType(string name, bytes4 interfaceId) external
Registers a new module type in the registry associate with an interface.
Enforced to be only callable by the protocol admin in governance.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the module type to be registered. |
interfaceId | bytes4 | The interface ID associated with the module type. |
removeModuleType
function removeModuleType(string name) external
Removes a module type from the registry.
Enforced to be only callable by the protocol admin in governance.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the module type to be removed. |
registerModule
function registerModule(string name, address moduleAddress) external
Registers a new module in the registry.
Enforced to be only callable by the protocol admin in governance.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the module. |
moduleAddress | address | The address of the module. |
registerModule
function registerModule(string name, address moduleAddress, string moduleType) external
Registers a new module in the registry with an associated module type.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the module to be registered. |
moduleAddress | address | The address of the module. |
moduleType | string | The type of the module being registered. |
removeModule
function removeModule(string name) external
Removes a module from the registry.
Enforced to be only callable by the protocol admin in governance.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the module. |
isRegistered
function isRegistered(address moduleAddress) external view returns (bool)
Checks if a module is registered in the protocol.
Parameters
Name | Type | Description |
---|---|---|
moduleAddress | address | The address of the module. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | isRegistered True if the module is registered, false otherwise. |
getModule
function getModule(string name) external view returns (address)
Returns the address of a module.
Parameters
Name | Type | Description |
---|---|---|
name | string | The name of the module. |
Return Values
Name | Type | Description |
---|---|---|
[0] | address | The address of the module. |
getModuleType
function getModuleType(address moduleAddress) external view returns (string)
Returns the module type of a given module address.
Parameters
Name | Type | Description |
---|---|---|
moduleAddress | address | The address of the module. |
Return Values
Name | Type | Description |
---|---|---|
[0] | string | The type of the module as a string. |
getModuleTypeInterfaceId
function getModuleTypeInterfaceId(string moduleType) external view returns (bytes4)
Returns the interface ID associated with a given module type.
Parameters
Name | Type | Description |
---|---|---|
moduleType | string | The type of the module as a string. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bytes4 | The interface ID of the module type as bytes4. |
_registerModule
function _registerModule(string name, address moduleAddress, string moduleType) internal
Registers a new module in the registry.
Updated 2 months ago