From 328d0da5f406cb53c745d2c35139e614cb4ac2de Mon Sep 17 00:00:00 2001 From: Fraser Scott Date: Fri, 26 Jan 2024 15:44:51 +0000 Subject: [PATCH] refactor(world,world-modules): rename module args to encodedArgs --- .../src/modules/erc20-puppet/ERC20Module.sol | 2 +- .../src/modules/erc721-puppet/ERC721Module.sol | 2 +- .../src/modules/keysintable/KeysInTableModule.sol | 2 +- .../modules/keyswithvalue/KeysWithValueModule.sol | 2 +- .../modules/uniqueentity/UniqueEntityModule.sol | 4 ++-- packages/world/src/IModule.sol | 8 ++++---- packages/world/src/IWorldKernel.sol | 4 ++-- packages/world/src/Module.sol | 12 ++++++------ packages/world/src/World.sol | 14 +++++++------- .../interfaces/IModuleInstallationSystem.sol | 2 +- .../implementations/ModuleInstallationSystem.sol | 8 ++++---- 11 files changed, 30 insertions(+), 30 deletions(-) diff --git a/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol b/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol index 8864576d7b..84ec381409 100644 --- a/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol +++ b/packages/world-modules/src/modules/erc20-puppet/ERC20Module.sol @@ -25,7 +25,7 @@ contract ERC20Module is Module { address immutable registrationLibrary = address(new ERC20ModuleRegistrationLibrary()); - function install(bytes memory args) public { + function install(bytes memory encodedArgs) public { // Require the module to not be installed with these args yet requireNotInstalled(__self, args); diff --git a/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol b/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol index ef2064f044..dcca430f81 100644 --- a/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol +++ b/packages/world-modules/src/modules/erc721-puppet/ERC721Module.sol @@ -29,7 +29,7 @@ contract ERC721Module is Module { address immutable registrationLibrary = address(new ERC721ModuleRegistrationLibrary()); - function install(bytes memory args) public { + function install(bytes memory encodedArgs) public { // Require the module to not be installed with these args yet requireNotInstalled(__self, args); diff --git a/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol b/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol index 4e61c0162d..b8388bc2a6 100644 --- a/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol +++ b/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol @@ -33,7 +33,7 @@ contract KeysInTableModule is Module { // from the source table id (passed as argument to the hook methods) KeysInTableHook private immutable hook = new KeysInTableHook(); - function installRoot(bytes memory args) public override { + function installRoot(bytes memory encodedArgs) public override { // Naive check to ensure this is only installed once // TODO: only revert if there's nothing to do requireNotInstalled(__self, args); diff --git a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol index d380eb8081..7027692b9d 100644 --- a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol +++ b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol @@ -35,7 +35,7 @@ contract KeysWithValueModule is Module { // from the source table id (passed as argument to the hook methods) KeysWithValueHook private immutable hook = new KeysWithValueHook(); - function installRoot(bytes memory args) public { + function installRoot(bytes memory encodedArgs) public { // Naive check to ensure this is only installed once // TODO: only revert if there's nothing to do requireNotInstalled(__self, args); diff --git a/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol b/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol index c104843bbf..d9ceb07644 100644 --- a/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol +++ b/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol @@ -22,7 +22,7 @@ contract UniqueEntityModule is Module { // known tables, we can deploy it once and register it in multiple Worlds. UniqueEntitySystem private immutable uniqueEntitySystem = new UniqueEntitySystem(); - function installRoot(bytes memory args) public { + function installRoot(bytes memory encodedArgs) public { // Naive check to ensure this is only installed once // TODO: only revert if there's nothing to do requireNotInstalled(__self, args); @@ -51,7 +51,7 @@ contract UniqueEntityModule is Module { if (!success) revertWithBytes(data); } - function install(bytes memory args) public { + function install(bytes memory encodedArgs) public { // Naive check to ensure this is only installed once // TODO: only revert if there's nothing to do requireNotInstalled(__self, args); diff --git a/packages/world/src/IModule.sol b/packages/world/src/IModule.sol index 00f6d0c7df..03e87a78b5 100644 --- a/packages/world/src/IModule.sol +++ b/packages/world/src/IModule.sol @@ -20,16 +20,16 @@ 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 called via the World contract and thus installs itself on the `msg.sender`. - * @param args Arguments that may be needed during the installation process. + * @param encodedArgs Arguments that may be needed during the installation process. */ - function installRoot(bytes memory args) external; + function installRoot(bytes memory encodedArgs) external; /** * @notice Installs the module. * @dev This function is invoked by the World contract during `installModule` process. * 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. + * @param encodedArgs Arguments that may be needed during the installation process. */ - function install(bytes memory args) external; + function install(bytes memory encodedArgs) external; } diff --git a/packages/world/src/IWorldKernel.sol b/packages/world/src/IWorldKernel.sol index 20f2ba9757..85116cc255 100644 --- a/packages/world/src/IWorldKernel.sol +++ b/packages/world/src/IWorldKernel.sol @@ -14,9 +14,9 @@ interface IWorldModuleInstallation { * @notice Install the given root module in the World. * @dev Requires the caller to own the root namespace. The module is delegatecalled and installed in the root namespace. * @param module The module to be installed. - * @param args The arguments provided for the module installation. + * @param encodedArgs The arguments provided for the module installation. */ - function installRootModule(IModule module, bytes memory args) external; + function installRootModule(IModule module, bytes memory encodedArgs) external; } /** diff --git a/packages/world/src/Module.sol b/packages/world/src/Module.sol index 5a4e896576..ca245353c2 100644 --- a/packages/world/src/Module.sol +++ b/packages/world/src/Module.sol @@ -32,20 +32,20 @@ abstract contract Module is IModule, WorldContextConsumer { /** * @dev Check if a module with the given name and arguments is installed. * @param moduleAddress The address of the module. - * @param args The arguments for the module installation. + * @param encodedArgs The arguments for the module installation. * @return true if the module is installed, false otherwise. */ - function isInstalled(address moduleAddress, bytes memory args) internal view returns (bool) { - return InstalledModules.get(moduleAddress, keccak256(args)); + function isInstalled(address moduleAddress, bytes memory encodedArgs) internal view returns (bool) { + return InstalledModules.get(moduleAddress, keccak256(encodedArgs)); } /** * @dev Revert if the module with the given name and arguments is already installed. * @param moduleAddress The address of the module. - * @param args The arguments for the module installation. + * @param encodedArgs The arguments for the module installation. */ - function requireNotInstalled(address moduleAddress, bytes memory args) internal view { - if (isInstalled(moduleAddress, args)) { + function requireNotInstalled(address moduleAddress, bytes memory encodedArgs) internal view { + if (isInstalled(moduleAddress, encodedArgs)) { revert Module_AlreadyInstalled(); } } diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 5398ca3f18..b98287cf2f 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -84,20 +84,20 @@ contract World is StoreData, IWorldKernel { /** * @notice Installs a given root module in the World. * @param module The module to be installed. - * @param args Arguments for module installation. + * @param encodedArgs Arguments for module installation. * @dev The caller must own the root namespace. */ - function installRootModule(IModule module, bytes memory args) public prohibitDirectCallback { + function installRootModule(IModule module, bytes memory encodedArgs) public prohibitDirectCallback { AccessControl.requireOwner(ROOT_NAMESPACE_ID, msg.sender); - _installRootModule(module, args); + _installRootModule(module, encodedArgs); } /** * @dev Internal function to install a root module. * @param module The module to be installed. - * @param args Arguments for module installation. + * @param encodedArgs Arguments for module installation. */ - function _installRootModule(IModule module, bytes memory args) internal { + function _installRootModule(IModule module, bytes memory encodedArgs) internal { // Require the provided address to implement the IModule interface requireInterface(address(module), type(IModule).interfaceId); @@ -105,11 +105,11 @@ contract World is StoreData, IWorldKernel { msgSender: msg.sender, msgValue: 0, target: address(module), - callData: abi.encodeCall(IModule.installRoot, (args)) + callData: abi.encodeCall(IModule.installRoot, (encodedArgs)) }); // Register the module in the InstalledModules table - InstalledModules._set(address(module), keccak256(args), true); + InstalledModules._set(address(module), keccak256(encodedArgs), true); } /************************************************************************ diff --git a/packages/world/src/codegen/interfaces/IModuleInstallationSystem.sol b/packages/world/src/codegen/interfaces/IModuleInstallationSystem.sol index aac66c776e..554be1d2ce 100644 --- a/packages/world/src/codegen/interfaces/IModuleInstallationSystem.sol +++ b/packages/world/src/codegen/interfaces/IModuleInstallationSystem.sol @@ -10,5 +10,5 @@ import { IModule } from "./../../IModule.sol"; * @dev This interface is automatically generated from the corresponding system contract. Do not edit manually. */ interface IModuleInstallationSystem { - function installModule(IModule module, bytes memory args) external; + function installModule(IModule module, bytes memory encodedArgs) external; } diff --git a/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol b/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol index fcc54e5d98..5cc8f02fd8 100644 --- a/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol +++ b/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol @@ -19,9 +19,9 @@ contract ModuleInstallationSystem is System, LimitedCallContext { * @dev Validates the given module against the IModule interface and delegates the installation process. * The module is then registered in the InstalledModules table. * @param module The module to be installed. - * @param args Arguments for the module installation. + * @param encodedArgs Arguments for the module installation. */ - function installModule(IModule module, bytes memory args) public onlyDelegatecall { + function installModule(IModule module, bytes memory encodedArgs) public onlyDelegatecall { // Require the provided address to implement the IModule interface requireInterface(address(module), type(IModule).interfaceId); @@ -29,10 +29,10 @@ contract ModuleInstallationSystem is System, LimitedCallContext { msgSender: _msgSender(), msgValue: 0, target: address(module), - callData: abi.encodeCall(IModule.install, (args)) + callData: abi.encodeCall(IModule.install, (encodedArgs)) }); // Register the module in the InstalledModules table - InstalledModules._set(address(module), keccak256(args), true); + InstalledModules._set(address(module), keccak256(encodedArgs), true); } }