From 9f756ccdcdc2d40f54d74588e862c4111f0ab1b9 Mon Sep 17 00:00:00 2001 From: Ori Pomerantz Date: Wed, 27 Sep 2023 18:11:59 -0500 Subject: [PATCH 1/2] docs(natspec): world/*Mod* --- packages/world/src/IModule.sol | 32 ++++++++++++++++++++++++-------- packages/world/src/Module.sol | 12 +++++++++++- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/packages/world/src/IModule.sol b/packages/world/src/IModule.sol index e5c474634a..60d50cec5e 100644 --- a/packages/world/src/IModule.sol +++ b/packages/world/src/IModule.sol @@ -3,32 +3,48 @@ pragma solidity >=0.8.21; import { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol"; -// ERC-165 Interface ID (see https://eips.ethereum.org/EIPS/eip-165) +/** + * @dev Calculation for ERC-165 interface ID for the IModule functions. + * Combines the selector for each function with the ERC165_INTERFACE_ID. + * See: https://eips.ethereum.org/EIPS/eip-165 + */ bytes4 constant MODULE_INTERFACE_ID = IModule.getName.selector ^ IModule.installRoot.selector ^ IModule.install.selector ^ ERC165_INTERFACE_ID; +/** + * @title IModule + * @dev Interface for the Module system. + * A module can be installed within the context of a world, either as a root or non-root module. + * This interface adheres to the ERC-165 standard for determining interface support. + */ interface IModule is IERC165 { + /// @dev Errors to represent non-support of specific installation types. error Module_RootInstallNotSupported(); error Module_NonRootInstallNotSupported(); /** - * Return the module name as a bytes16. + * @notice Return the name of the module. + * @dev Provides a way to identify the module by a unique name. + * @return name The name of the module as a bytes16. */ function getName() external view returns (bytes16 name); /** - * This function is called by the World as part of `installRootModule`. - * The module expects to be called via the World contract, and therefore installs itself on the `msg.sender`. + * @notice Installs the module as a root module. + * @dev This function is invoked by the World contract during `installRootModule` process. + * The module expects to be interfaced via the World contract and thus installs itself on the `msg.sender`. + * @param args Arguments that may be needed during the installation process. */ function installRoot(bytes memory args) external; /** - * This function is called by the World as part of `installModule`. - * The module expects to be called via the World contract, and therefore installs itself on the `msg.sender`. - * This function is separate from `installRoot` because the logic might be different (eg. accepting namespace parameters, - * or using `callFrom`) + * @notice Installs the module. + * @dev This function is invoked by the World contract during `installModule` process. + * The module expects to be interfaced via the World contract and thus installs itself on the `msg.sender`. + * Logic might differ from `installRoot`, for example, this might accept namespace parameters. + * @param args Arguments that may be needed during the installation process. */ function install(bytes memory args) external; } diff --git a/packages/world/src/Module.sol b/packages/world/src/Module.sol index 0914a155bd..eabd7c2eec 100644 --- a/packages/world/src/Module.sol +++ b/packages/world/src/Module.sol @@ -5,8 +5,18 @@ import { WorldContextConsumer } from "./WorldContext.sol"; import { IModule, MODULE_INTERFACE_ID } from "./IModule.sol"; import { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol"; +/** + * @title Module + * @dev Abstract contract that implements the functionalities of IModule and is associated with a world context. + * It also checks for interface support according to the ERC-165 standard. + */ abstract contract Module is IModule, WorldContextConsumer { - // ERC-165 supportsInterface (see https://eips.ethereum.org/EIPS/eip-165) + /** + * @notice Checks if the given interfaceId is supported by this contract. + * @dev Overrides the functionality from IERC165 and WorldContextConsumer to check for supported interfaces. + * @param interfaceId The bytes4 identifier for the interface. + * @return true if the interface is supported, false otherwise. + */ function supportsInterface( bytes4 interfaceId ) public pure virtual override(IERC165, WorldContextConsumer) returns (bool) { From f25d05b83b81c0c85ae55e1e22c8c8f1b02b0fa9 Mon Sep 17 00:00:00 2001 From: alvarius Date: Fri, 29 Sep 2023 14:40:00 +0100 Subject: [PATCH 2/2] Apply suggestions from code review --- packages/world/src/IModule.sol | 4 ++-- packages/world/src/Module.sol | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/world/src/IModule.sol b/packages/world/src/IModule.sol index 60d50cec5e..898cb59d76 100644 --- a/packages/world/src/IModule.sol +++ b/packages/world/src/IModule.sol @@ -34,7 +34,7 @@ interface IModule is IERC165 { /** * @notice Installs the module as a root module. * @dev This function is invoked by the World contract during `installRootModule` process. - * The module expects to be interfaced via the World contract and thus installs itself on the `msg.sender`. + * The module expects to be called via the World contract and thus installs itself on the `msg.sender`. * @param args Arguments that may be needed during the installation process. */ function installRoot(bytes memory args) external; @@ -42,7 +42,7 @@ interface IModule is IERC165 { /** * @notice Installs the module. * @dev This function is invoked by the World contract during `installModule` process. - * The module expects to be interfaced via the World contract and thus installs itself on the `msg.sender`. + * The module expects to be called via the World contract and thus installs itself on the `msg.sender`. * Logic might differ from `installRoot`, for example, this might accept namespace parameters. * @param args Arguments that may be needed during the installation process. */ diff --git a/packages/world/src/Module.sol b/packages/world/src/Module.sol index eabd7c2eec..6bf4c64921 100644 --- a/packages/world/src/Module.sol +++ b/packages/world/src/Module.sol @@ -7,8 +7,7 @@ import { IERC165, ERC165_INTERFACE_ID } from "./IERC165.sol"; /** * @title Module - * @dev Abstract contract that implements the functionalities of IModule and is associated with a world context. - * It also checks for interface support according to the ERC-165 standard. + * @dev Abstract contract that implements the ERC-165 supportsInterface function for IModule. */ abstract contract Module is IModule, WorldContextConsumer { /**