Skip to content

Commit

Permalink
docs(world): fix links to source code, core->init (#2265)
Browse files Browse the repository at this point in the history
  • Loading branch information
qbzzt authored Feb 14, 2024
1 parent 5268ab2 commit f790d23
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions docs/pages/world/account-delegation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The most common type of delegation is when a delegator address allows a specific

### Creating a user delegation

First, the delegator has to call [`registerDelegation`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol#L234-L263).
First, the delegator has to call [`registerDelegation`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol#L251-L284).
This function takes three parameters:

- `delegatee`, the address given the privileges.
Expand Down Expand Up @@ -51,14 +51,14 @@ This means that if you need in a `World` to implement multiple delegation algori

### Removing a user delegation

You can use [`unregisterDelegation`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol#L283-L291) to remove a delegation.
You can use [`unregisterDelegation`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol#L286-L294) to remove a delegation.

Because of `unregisterDelegation` delegations cannot be used for a delegator to commit to allow something to be done in the future.
If you need a _commitment_, create a table with a `System` that lets the address that commits write the commitment and have an action that other addresses can call only if the proper commitment is there - without giving the committed address an option to delete the entry.

## Namespace delegation

The owner of a namespace can use [`registerNamespaceDelegation`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol#L300-L332) to register a delegation that applies to all callers of systems in this namespace.
The owner of a namespace can use [`registerNamespaceDelegation`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol#L296-L335) to register a delegation that applies to all callers of systems in this namespace.
This functionality is useful, for example, to implement a trusted forwarder for the namespace.
This is not a security concern because the namespace owner already has full control over any table or `System` in the namespace.

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/world/balance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ uint256 balance = Balances.get(<namespace>);
To transfer ETH out of the `World` you need to have the `access` permission level to the namespace itself.
Note that `System` contracts within the namespace do have that permission.

You use either [`transferBalanceToNamespace`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol#L23-L52), if you want to transfer between namespaces in the same `World`, or [`transferBalanceToAddress`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol#L54-L77), to transfer to a different address.
You use either [`transferBalanceToNamespace`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/BalanceTransferSystem.sol#L25-L57), if you want to transfer between namespaces in the same `World`, or [`transferBalanceToAddress`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/BalanceTransferSystem.sol#L59-L86), to transfer to a different address.

<details>

Expand Down
4 changes: 2 additions & 2 deletions docs/pages/world/batch-calls.mdx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Batch calls

Batch calls allow a single call to the `World` to perform multiple `System` calls.
Using [`batchCall`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/BatchCallSystem.sol#L15-L33) you can issue calls on your own behalf.
If you have the proper [delegations](/world/account-delegation), you can also use [`batchCallFrom`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/BatchCallSystem.sol#L35-L53) to issue `System` calls on behalf of other addresses.
Using [`batchCall`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/BatchCallSystem.sol#L15-L35) you can issue calls on your own behalf.
If you have the proper [delegations](/world/account-delegation), you can also use [`batchCallFrom`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/BatchCallSystem.sol#L37-L57) to issue `System` calls on behalf of other addresses.

The calls take place sequentially, and after they all finish successfully you get back the return values from all of them.
If any of the calls revert, so does `batchCall` / `batchCallFrom`, so all the state changes created by the previous calls are discarded.
4 changes: 2 additions & 2 deletions docs/pages/world/function-selectors.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ To improve the developer experience of calling `System` functions, the namespace
This removes the need for the caller to know the system's `ResourceId`, and the need to manually encode the calldata via `abi.encodeCall`.
Once the namespace owner registers a function selector for a `System` function, anybody can call the `System` via `<World>.<namespace>__<function>(<args>)`.

To register a function selector, you use [`<world>.registerFunctionSelector`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol#L164-L201).
To register a function selector, you use [`<world>.registerFunctionSelector`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol#L180-L218).
This function takes two parameters:

- The `ResourceID` of the `System`.
Expand All @@ -39,7 +39,7 @@ After the function selector is registered, it can be accessed directly on the Wo

## Root function selectors

The owner of the root namespace can use [`registerRootFunctionSelector`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol#L203-L232) to register an arbitrary string as a function signature.
The owner of the root namespace can use [`registerRootFunctionSelector`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol#L220-L249) to register an arbitrary string as a function signature.

This function has three parameters:

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/world/modules.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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/core/implementations/ModuleInstallationSystem.sol#L17-L37).
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`.

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/world/namespaces-access-control.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ By default access to a namespace is granted to:

Namespace access provides access to all the resources within the namespace, so there is no need, by default, for access to the resources within the namespace.

If that is insufficient, [`AccessManagementSystem`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/AccessManagementSystem.sol) lets you [`grantAccess`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/AccessManagementSystem.sol#L17-L29), [`revokeAccess`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/AccessManagementSystem.sol#L31-L43), and [`transferOwnership`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/AccessManagementSystem.sol#L45-L63) of a namespace.
If that is insufficient, [`AccessManagementSystem`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol) lets you [`grantAccess`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol#L18-L33), [`revokeAccess`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol#L35-L47), and [`transferOwnership`](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/AccessManagementSystem.sol#L49-L73) of a namespace.

For example, here is a script that grants access to the `Counter` table to one address and revokes it for another.

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/world/system-hooks.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# System hooks

The [namespace owner](/world/namespaces-access-control#ownership) can [register](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol#L65-L81) hooks that are called before and/or after calls to a specific `System`.
The [namespace owner](/world/namespaces-access-control#ownership) can [register](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol#L68-L99) hooks that are called before and/or after calls to a specific `System`.

## System hook contracts

Expand Down
2 changes: 1 addition & 1 deletion docs/pages/world/systems.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ If you need to call a `System` from a `System` in the root namespace you can use

## Registering systems

For a `System` to be callable from a `World` it has to be [registered](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol#L97-L201).
For a `System` to be callable from a `World` it has to be [registered](https://github.com/latticexyz/mud/blob/main/packages/world/src/modules/init/implementations/WorldRegistrationSystem.sol#L115-L178).
Only the [namespace owner](./namespaces-access-control#ownership) can register a `System` in a namespace.

`System`s can be registered once per `World`, but the same system can be registered in multiple `World`s.
Expand Down

0 comments on commit f790d23

Please sign in to comment.