Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e861f35

Browse files
committedFeb 7, 2025·
update docs
1 parent 826fb9b commit e861f35

File tree

2 files changed

+567
-0
lines changed

2 files changed

+567
-0
lines changed
 

‎docs/pages/world/reference/internal/init-module-implementation.mdx

+329
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,35 @@ function installModule(IModule module, bytes memory encodedArgs) public onlyDele
107107
| `module` | `IModule` | The module to be installed. |
108108
| `encodedArgs` | `bytes` | The ABI encoded arguments for module installation. |
109109

110+
## ModuleInstallationSystem
111+
112+
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/ModuleInstallationSystem.sol)
113+
114+
**Inherits:**
115+
[System](/world/reference/system#system), [LimitedCallContext](/world/reference/internal/init-module#limitedcallcontext)
116+
117+
_A system contract to handle the installation of (non-root) modules in the World._
118+
119+
### Functions
120+
121+
#### installModule
122+
123+
Installs a module into the World under a specified namespace.
124+
125+
_Validates the given module against the IModule interface and delegates the installation process.
126+
The module is then registered in the InstalledModules table._
127+
128+
```solidity
129+
function installModule(IModule module, bytes memory encodedArgs) public onlyDelegatecall;
130+
```
131+
132+
**Parameters**
133+
134+
| Name | Type | Description |
135+
| ------------- | --------- | -------------------------------------------------- |
136+
| `module` | `IModule` | The module to be installed. |
137+
| `encodedArgs` | `bytes` | The ABI encoded arguments for module installation. |
138+
110139
## BalanceTransferSystem
111140

112141
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/BalanceTransferSystem.sol)
@@ -168,6 +197,86 @@ function transferBalanceToAddress(
168197

169198
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/StoreRegistrationSystem.sol)
170199

200+
**Inherits:**
201+
[System](/world/reference/system#system), [IWorldErrors](/world/reference/world-external#iworlderrors), IStoreRegistration, [LimitedCallContext](/world/reference/internal/init-module#limitedcallcontext)
202+
203+
_This contract provides functionality for the registration of store-related resources within the World framework._
204+
205+
### Functions
206+
207+
#### registerTable
208+
209+
Register a table within the World framework.
210+
211+
_Registers a table with the specified configuration. If the namespace for the table does not exist, it's created.
212+
Existing namespaces require the caller to be the owner for table registration._
213+
214+
```solidity
215+
function registerTable(
216+
ResourceId tableId,
217+
FieldLayout fieldLayout,
218+
Schema keySchema,
219+
Schema valueSchema,
220+
string[] calldata keyNames,
221+
string[] calldata fieldNames
222+
) public virtual onlyDelegatecall;
223+
```
224+
225+
**Parameters**
226+
227+
| Name | Type | Description |
228+
| ------------- | ------------- | ------------------------------------------------ |
229+
| `tableId` | `ResourceId` | The resource ID of the table. |
230+
| `fieldLayout` | `FieldLayout` | The field layout structure for the table. |
231+
| `keySchema` | `Schema` | The schema for the keys of the table. |
232+
| `valueSchema` | `Schema` | The schema for the values within the table. |
233+
| `keyNames` | `string[]` | The names associated with the keys in the table. |
234+
| `fieldNames` | `string[]` | The names of the fields in the table. |
235+
236+
#### registerStoreHook
237+
238+
Register a storage hook for a specified table.
239+
240+
_The caller must be the owner of the namespace to which the table belongs.
241+
The hook must conform to the IStoreHook interface._
242+
243+
```solidity
244+
function registerStoreHook(
245+
ResourceId tableId,
246+
IStoreHook hookAddress,
247+
uint8 enabledHooksBitmap
248+
) public virtual onlyDelegatecall;
249+
```
250+
251+
**Parameters**
252+
253+
| Name | Type | Description |
254+
| -------------------- | ------------ | -------------------------------------------------------------------- |
255+
| `tableId` | `ResourceId` | The resource ID of the table for which the hook is being registered. |
256+
| `hookAddress` | `IStoreHook` | The address of the storage hook contract. |
257+
| `enabledHooksBitmap` | `uint8` | A bitmap indicating which hook functionalities are enabled. |
258+
259+
#### unregisterStoreHook
260+
261+
Unregister a previously registered storage hook for a specified table.
262+
263+
_The caller must be the owner of the namespace to which the table belongs._
264+
265+
```solidity
266+
function unregisterStoreHook(ResourceId tableId, IStoreHook hookAddress) public virtual onlyDelegatecall;
267+
```
268+
269+
**Parameters**
270+
271+
| Name | Type | Description |
272+
| ------------- | ------------ | ----------------------------------------------------------------------- |
273+
| `tableId` | `ResourceId` | The resource ID of the table from which the hook is being unregistered. |
274+
| `hookAddress` | `IStoreHook` | The address of the storage hook contract. |
275+
276+
## StoreRegistrationSystem
277+
278+
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/StoreRegistrationSystem.sol)
279+
171280
**Inherits:**
172281
[System](/world/reference/system#system), [IWorldErrors](/world/reference/world-external#iworlderrors), [LimitedCallContext](/world/reference/internal/init-module#limitedcallcontext)
173282

@@ -528,3 +637,223 @@ function unregisterNamespaceDelegation(ResourceId namespaceId) public onlyDelega
528637
| Name | Type | Description |
529638
| ------------- | ------------ | ----------------------- |
530639
| `namespaceId` | `ResourceId` | The ID of the namespace |
640+
641+
## WorldRegistrationSystem
642+
643+
[Git Source](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol)
644+
645+
**Inherits:**
646+
[System](/world/reference/system#system), [IWorldErrors](/world/reference/world-external#iworlderrors), [LimitedCallContext](/world/reference/internal/init-module#limitedcallcontext)
647+
648+
_This contract provides functions related to registering resources other than tables in the World._
649+
650+
### Functions
651+
652+
#### registerNamespace
653+
654+
Registers a new namespace
655+
656+
_Creates a new namespace resource with the given ID_
657+
658+
```solidity
659+
function registerNamespace(ResourceId namespaceId) public virtual onlyDelegatecall;
660+
```
661+
662+
**Parameters**
663+
664+
| Name | Type | Description |
665+
| ------------- | ------------ | ------------------------------------------- |
666+
| `namespaceId` | `ResourceId` | The unique identifier for the new namespace |
667+
668+
#### registerSystemHook
669+
670+
Registers a new system hook
671+
672+
_Adds a new hook for the system at the provided system ID_
673+
674+
```solidity
675+
function registerSystemHook(
676+
ResourceId systemId,
677+
ISystemHook hookAddress,
678+
uint8 enabledHooksBitmap
679+
) public virtual onlyDelegatecall;
680+
```
681+
682+
**Parameters**
683+
684+
| Name | Type | Description |
685+
| -------------------- | ------------- | ----------------------------------------- |
686+
| `systemId` | `ResourceId` | The ID of the system |
687+
| `hookAddress` | `ISystemHook` | The address of the hook being registered |
688+
| `enabledHooksBitmap` | `uint8` | Bitmap indicating which hooks are enabled |
689+
690+
#### unregisterSystemHook
691+
692+
Unregisters a system hook
693+
694+
_Removes a hook for the system at the provided system ID_
695+
696+
```solidity
697+
function unregisterSystemHook(ResourceId systemId, ISystemHook hookAddress) public virtual onlyDelegatecall;
698+
```
699+
700+
**Parameters**
701+
702+
| Name | Type | Description |
703+
| ------------- | ------------- | ------------------------------------------ |
704+
| `systemId` | `ResourceId` | The ID of the system |
705+
| `hookAddress` | `ISystemHook` | The address of the hook being unregistered |
706+
707+
#### registerSystem
708+
709+
Registers a system
710+
711+
_Registers or upgrades a system at the given ID
712+
If the namespace doesn't exist yet, it is registered.
713+
The system is granted access to its namespace, so it can write to any
714+
table in the same namespace.
715+
If publicAccess is true, no access control check is performed for calling the system.
716+
This function doesn't check whether a system already exists at the given selector,
717+
making it possible to upgrade systems._
718+
719+
```solidity
720+
function registerSystem(ResourceId systemId, System system, bool publicAccess) public virtual onlyDelegatecall;
721+
```
722+
723+
**Parameters**
724+
725+
| Name | Type | Description |
726+
| -------------- | ------------ | --------------------------------------------------- |
727+
| `systemId` | `ResourceId` | The unique identifier for the system |
728+
| `system` | `System` | The system being registered |
729+
| `publicAccess` | `bool` | Flag indicating if access control check is bypassed |
730+
731+
#### registerFunctionSelector
732+
733+
Registers a new World function selector
734+
735+
_Creates a mapping between a World function and its associated system function_
736+
737+
```solidity
738+
function registerFunctionSelector(
739+
ResourceId systemId,
740+
string memory systemFunctionSignature
741+
) public onlyDelegatecall returns (bytes4 worldFunctionSelector);
742+
```
743+
744+
**Parameters**
745+
746+
| Name | Type | Description |
747+
| ------------------------- | ------------ | ------------------------------------ |
748+
| `systemId` | `ResourceId` | The system ID |
749+
| `systemFunctionSignature` | `string` | The signature of the system function |
750+
751+
**Returns**
752+
753+
| Name | Type | Description |
754+
| ----------------------- | -------- | ---------------------------------- |
755+
| `worldFunctionSelector` | `bytes4` | The selector of the World function |
756+
757+
#### registerRootFunctionSelector
758+
759+
Registers a root World function selector
760+
761+
_Creates a mapping for a root World function without namespace or name prefix_
762+
763+
```solidity
764+
function registerRootFunctionSelector(
765+
ResourceId systemId,
766+
string memory worldFunctionSignature,
767+
string memory systemFunctionSignature
768+
) public onlyDelegatecall returns (bytes4 worldFunctionSelector);
769+
```
770+
771+
**Parameters**
772+
773+
| Name | Type | Description |
774+
| ------------------------- | ------------ | ------------------------------------ |
775+
| `systemId` | `ResourceId` | The system ID |
776+
| `worldFunctionSignature` | `string` | The signature of the World function |
777+
| `systemFunctionSignature` | `string` | The signature of the system function |
778+
779+
**Returns**
780+
781+
| Name | Type | Description |
782+
| ----------------------- | -------- | ---------------------------------- |
783+
| `worldFunctionSelector` | `bytes4` | The selector of the World function |
784+
785+
#### registerDelegation
786+
787+
Registers a delegation for the caller
788+
789+
_Creates a new delegation from the caller to the specified delegatee_
790+
791+
```solidity
792+
function registerDelegation(
793+
address delegatee,
794+
ResourceId delegationControlId,
795+
bytes memory initCallData
796+
) public onlyDelegatecall;
797+
```
798+
799+
**Parameters**
800+
801+
| Name | Type | Description |
802+
| --------------------- | ------------ | ------------------------------------------ |
803+
| `delegatee` | `address` | The address of the delegatee |
804+
| `delegationControlId` | `ResourceId` | The ID controlling the delegation |
805+
| `initCallData` | `bytes` | The initialization data for the delegation |
806+
807+
#### unregisterDelegation
808+
809+
Unregisters a delegation
810+
811+
_Deletes the new delegation from the caller to the specified delegatee_
812+
813+
```solidity
814+
function unregisterDelegation(address delegatee) public onlyDelegatecall;
815+
```
816+
817+
**Parameters**
818+
819+
| Name | Type | Description |
820+
| ----------- | --------- | ---------------------------- |
821+
| `delegatee` | `address` | The address of the delegatee |
822+
823+
#### registerNamespaceDelegation
824+
825+
Registers a delegation for a namespace
826+
827+
_Sets up a new delegation control for a specific namespace_
828+
829+
```solidity
830+
function registerNamespaceDelegation(
831+
ResourceId namespaceId,
832+
ResourceId delegationControlId,
833+
bytes memory initCallData
834+
) public onlyDelegatecall;
835+
```
836+
837+
**Parameters**
838+
839+
| Name | Type | Description |
840+
| --------------------- | ------------ | ------------------------------------------ |
841+
| `namespaceId` | `ResourceId` | The ID of the namespace |
842+
| `delegationControlId` | `ResourceId` | The ID controlling the delegation |
843+
| `initCallData` | `bytes` | The initialization data for the delegation |
844+
845+
#### unregisterNamespaceDelegation
846+
847+
Unregisters a delegation for a namespace
848+
849+
_Deletes the delegation control for a specific namespace_
850+
851+
```solidity
852+
function unregisterNamespaceDelegation(ResourceId namespaceId) public onlyDelegatecall;
853+
```
854+
855+
**Parameters**
856+
857+
| Name | Type | Description |
858+
| ------------- | ------------ | ----------------------- |
859+
| `namespaceId` | `ResourceId` | The ID of the namespace |
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.