Skip to content

Commit

Permalink
updated modules page with new installation options
Browse files Browse the repository at this point in the history
  • Loading branch information
qbzzt committed May 21, 2024
1 parent 9220036 commit acc023a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
5 changes: 1 addition & 4 deletions docs/pages/config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ The global configuration keys are all optional.
The keys are the names of the enumerations.
The values are arrays of the strings for the values the enumeration can take.

- **`tables`**: a record of tables. The keys in the record are table names.
The value is a record of [table properties](https://github.com/latticexyz/mud/blob/main/packages/store/ts/config/storeConfig.ts#L110-L135).

- **`excludeSystems`**: an array of `string`: which systems to not deploy, even if their name ends with “System”.

- **`codegen`**: a record of code generation options.
Expand All @@ -144,7 +141,7 @@ The global configuration keys are all optional.
of the core World implementation](/world/upgrades). The default is `false`.

- **`modules`**: a list of modules to be installed into the `World`.
Each entry in this list is a a record with these fields:
Each entry in this list is a record with these fields:

- **`name`** a `string`: The name of the module.
- **`artifactPath`** a `string`: The path to the compiled version of the contract with the module.
Expand Down
14 changes: 9 additions & 5 deletions docs/pages/world/modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ This is somewhat similar to one of the use cases for [foundry scripts](https://b

## Module installation

Modules can be installed using [`World.installModule(address moduleAddress, bytes memory initData)`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/ModuleInstallationSystem.sol#L17-L37).
When you do this, the `World` calls the module's `install` function with `initData` as the argument(s).
Because this is a call, the module does not have any administrative permissions on the `World`.
There are two methods to install modules in a `World`:

Alternatively, the owner of the root namespace can install modules using [`World.installRootModule(address moduleAddress, bytes memory initData)`](https://github.com/latticexyz/mud/blob/main/packages/world/src/World.sol#L90-L119).
In this case, the `World` uses delegatecall and module has all the permissions of a `System` in the root namespace.
- Include the module under the `modules` field [in the `mud.config.ts` file](/config).

- Deploy the module contract (or use an already deployed one) and then call the `World` to install the module.
For an unprivileged installation use [`World.installModule(address moduleAddress, bytes memory initData)`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/ModuleInstallationSystem.sol#L17-L37).
When you do this, the `World` calls the module's `install` function with `initData` as the argument(s).
If you own the root namespace you can also run a module with administrative permissions (the same as those of a [`System` in the root namespace](/world/systems#root-systems)).
To do so, use [`World.installRootModule(address moduleAddress, bytes memory initData)`](https://github.com/latticexyz/mud/blob/main/packages/world/src/World.sol#L90-L119).
When you do this, the `World` calls the module's `installRoot` function with `initData` as the argument(s).

## Writing modules

Expand Down

0 comments on commit acc023a

Please sign in to comment.