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

NameTypeDescription
namestringThe name of the module type to be registered.
interfaceIdbytes4The 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

NameTypeDescription
namestringThe 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

NameTypeDescription
namestringThe name of the module.
moduleAddressaddressThe 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

NameTypeDescription
namestringThe name of the module to be registered.
moduleAddressaddressThe address of the module.
moduleTypestringThe 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

NameTypeDescription
namestringThe name of the module.

isRegistered

function isRegistered(address moduleAddress) external view returns (bool)

Checks if a module is registered in the protocol.

Parameters

NameTypeDescription
moduleAddressaddressThe address of the module.

Return Values

NameTypeDescription
[0]boolisRegistered True if the module is registered, false otherwise.

getModule

function getModule(string name) external view returns (address)

Returns the address of a module.

Parameters

NameTypeDescription
namestringThe name of the module.

Return Values

NameTypeDescription
[0]addressThe address of the module.

getModuleType

function getModuleType(address moduleAddress) external view returns (string)

Returns the module type of a given module address.

Parameters

NameTypeDescription
moduleAddressaddressThe address of the module.

Return Values

NameTypeDescription
[0]stringThe 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

NameTypeDescription
moduleTypestringThe type of the module as a string.

Return Values

NameTypeDescription
[0]bytes4The 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.