-
Notifications
You must be signed in to change notification settings - Fork 174
/
ModuleInstallationSystem.sol
33 lines (29 loc) · 1.22 KB
/
ModuleInstallationSystem.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.21;
import { IModule, MODULE_INTERFACE_ID } from "../../../IModule.sol";
import { System } from "../../../System.sol";
import { AccessControl } from "../../../AccessControl.sol";
import { WorldContextProvider } from "../../../WorldContext.sol";
import { ResourceAccess } from "../../../codegen/tables/ResourceAccess.sol";
import { InstalledModules } from "../../../codegen/tables/InstalledModules.sol";
import { requireInterface } from "../../../requireInterface.sol";
/**
* Installation of (non-root) modules in the World.
*/
contract ModuleInstallationSystem is System {
/**
* Install the given module at the given namespace in the World.
*/
function installModule(IModule module, bytes memory args) public {
// Require the provided address to implement the IModule interface
requireInterface(address(module), MODULE_INTERFACE_ID);
WorldContextProvider.callWithContextOrRevert({
msgSender: _msgSender(),
msgValue: 0,
target: address(module),
callData: abi.encodeCall(IModule.install, (args))
});
// Register the module in the InstalledModules table
InstalledModules._set(module.getName(), keccak256(args), address(module));
}
}