Registering a Module
Developers wishing to register a module to signal it's availability to the Frontends, Lens API, and users, can do that using the ModuleRegistry contract. Registration is not required - any module will be registered automatically on the first use. Same rules apply to registering currencies.
Registration is declarative, and just emits an event that can be tracked by anyone, and is supposed to let everyone know that this kind of module is available--so they can dive deep into its code and see how it works. The data provided during the registration isn't verified anywhere on-chain, and as it's public and open--it shouldn't be blindly trusted, but rather be treated as a hint of what modules are available and what types they might be.
How to register a module
Registering a module is very simple--you just need to pass it's address and type to the registerModule() function:
enum ModuleType {
__, // Just to avoid 0 as valid ModuleType
PUBLICATION_ACTION_MODULE,
REFERENCE_MODULE,
FOLLOW_MODULE
}
registerModule(address moduleAddress, uint256 moduleType);
Where moduleType is a number representing a type of the module:
Module Type | uin256 to pass |
---|---|
Publication Action Module (aka Open Action) | 1 |
Reference Module | 2 |
Follow Module | 3 |
If you've committed a mistake and passed the wrong type during registration--you can register again with a proper type. Same if you want to register a contract that acts like multiple module types--just register as many types of it as needed.
Registration of a module emits an event:
event ModuleRegistered(
address indexed moduleAddress,
uint256 indexed moduleType,
uint256 timestamp
);
Remember, you don't need to explicitly signal your module via Registration--you can just use it in a publication or profile and it will be registered automatically on the first use with a proper type.
How to register a ERC20 currency
Same as with modules, anyone can register a ERC20 currency--all you need to do is pass its address to registerErc20Currency() function:
function registerErc20Currency(address currencyAddress);
Registering a currency just signals that a currency is available to use and emits an event for the Frontends, Lens API and users to track which currencies are available.
During registration the decimals
, name
and symbol
of the currency is fetched.
Registration of a currency emits an event:
event erc20CurrencyRegistered(
address indexed erc20CurrencyAddress,
string name,
string symbol,
uint8 decimals,
uint256 timestamp
);
You don't have to do this registration--the currency will also be registered automatically when first used with any of the modules.
Updated about 1 month ago