InitModule
Git Source (opens in a new tab)
Inherits: Module
Registers internal World tables, systems, and their function selectors.
This module only supports installRoot
because it installs root tables, systems and function selectors.
State Variables
accessManagementSystem
address internal immutable accessManagementSystem;
balanceTransferSystem
address internal immutable balanceTransferSystem;
batchCallSystem
address internal immutable batchCallSystem;
registrationSystem
address internal immutable registrationSystem;
Functions
constructor
constructor(
AccessManagementSystem _accessManagementSystem,
BalanceTransferSystem _balanceTransferSystem,
BatchCallSystem _batchCallSystem,
RegistrationSystem _registrationSystem
);
installRoot
Root installation of the module.
Registers core tables, systems, and function selectors in the World.
function installRoot(bytes memory) public override;
install
Non-root installation of the module.
Installation is only supported at root level, so this function will always revert.
function install(bytes memory) public pure;
_registerTables
Register World's tables.
This internal function registers various tables and sets initial permissions.
function _registerTables() internal;
_registerSystems
Register the systems in the World.
function _registerSystems() internal;
_registerSystem
Register the internal system in the World.
Uses the WorldRegistrationSystem's registerSystem
implementation to register the system on the World.
function _registerSystem(address target, ResourceId systemId) internal;
_registerFunctionSelectors
Register function selectors for all core system functions in the World.
Iterates through known function signatures and registers them.
function _registerFunctionSelectors() internal;
_registerRootFunctionSelector
Register the function selector in the World.
Uses the RegistrationSystem's registerRootFunctionSelector
to register the function selector.
function _registerRootFunctionSelector(ResourceId systemId, string memory functionSignature) internal;
constants.sol
Git Source (opens in a new tab)
ACCESS_MANAGEMENT_SYSTEM_ID
Resource ID for access management system.
This ID is derived from the RESOURCE_SYSTEM type, the ROOT_NAMESPACE, and the system name.
ResourceId constant ACCESS_MANAGEMENT_SYSTEM_ID = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_SYSTEM, ROOT_NAMESPACE, bytes16("AccessManagement")))
);
BALANCE_TRANSFER_SYSTEM_ID
Resource ID for balance transfer system.
This ID is derived from the RESOURCE_SYSTEM type, the ROOT_NAMESPACE, and the system name.
ResourceId constant BALANCE_TRANSFER_SYSTEM_ID = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_SYSTEM, ROOT_NAMESPACE, bytes16("BalanceTransfer")))
);
BATCH_CALL_SYSTEM_ID
Resource ID for batch call system.
This ID is derived from the RESOURCE_SYSTEM type, the ROOT_NAMESPACE, and the system name.
ResourceId constant BATCH_CALL_SYSTEM_ID = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_SYSTEM, ROOT_NAMESPACE, bytes16("BatchCall")))
);
REGISTRATION_SYSTEM_ID
Resource ID for core registration system.
This ID is derived from the RESOURCE_SYSTEM type, the ROOT_NAMESPACE, and the system name.
ResourceId constant REGISTRATION_SYSTEM_ID = ResourceId.wrap(
bytes32(abi.encodePacked(RESOURCE_SYSTEM, ROOT_NAMESPACE, bytes16("Registration")))
);
RegistrationSystem
Git Source (opens in a new tab)
Inherits: IWorldErrors, ModuleInstallationSystem, StoreRegistrationSystem, WorldRegistrationSystem
This system aggregates World registration and installation functionalities externalized from the World contract, aiming to keep the World contract's bytecode lean.
Aggregates multiple system implementations for the World.
LimitedCallContext
Git Source (opens in a new tab)
Systems are expected to be always called via the central World contract.
Depending on whether it is a root or non-root system, the call is performed via delegatecall
or call
.
Since Systems are expected to be stateless and only interact with the World state,
it is normally not necessary to prevent direct calls to the systems.
However, since the CoreSystem
is known to always be registered as a root system in the World,
it is always expected to be delegatecalled, so we made this expectation explicit by reverting if it is not delegatecalled.
Based on OpenZeppelin's UUPSUpgradeable.sol https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v5.0.0/contracts/proxy/utils/UUPSUpgradeable.sol#L50 (opens in a new tab)
State Variables
__self
address private immutable __self = address(this);
Functions
onlyDelegatecall
modifier onlyDelegatecall();
_checkDelegatecall
Reverts if the execution is not performed via delegatecall.
function _checkDelegatecall() internal view virtual;
Errors
UnauthorizedCallContext
error UnauthorizedCallContext();
SystemCallData
Git Source (opens in a new tab)
Holds data for making system calls.
Used to represent a call to a specific system identified by a ResourceId.
struct SystemCallData {
ResourceId systemId;
bytes callData;
}
SystemCallFromData
Git Source (opens in a new tab)
Holds data for making system calls with a specific sender.
Used to represent a call from a specific address to a specific system.
struct SystemCallFromData {
address from;
ResourceId systemId;
bytes callData;
}