@@ -8,10 +8,11 @@ import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@lattic
8
8
import { ResourceIds } from "@latticexyz/store/src/codegen/tables/ResourceIds.sol " ;
9
9
import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol " ;
10
10
import { REGISTRATION_SYSTEM_ID } from "@latticexyz/world/src/modules/init/constants.sol " ;
11
+ import { worldRegistrationSystem } from "@latticexyz/world/src/codegen/systems/WorldRegistrationSystemLib.sol " ;
12
+ import { storeRegistrationSystem } from "@latticexyz/world/src/codegen/systems/StoreRegistrationSystemLib.sol " ;
11
13
12
14
import { MetadataSystem } from "./MetadataSystem.sol " ;
13
15
import { ResourceTag } from "./codegen/tables/ResourceTag.sol " ;
14
- import { DelegatorContext, DelegatedRegistrationSystemLib } from "./DelegatorContext.sol " ;
15
16
16
17
/**
17
18
* @title MetadataModule
@@ -21,22 +22,19 @@ import { DelegatorContext, DelegatedRegistrationSystemLib } from "./DelegatorCon
21
22
*/
22
23
contract MetadataModule is Module {
23
24
using WorldResourceIdInstance for ResourceId;
24
- using DelegatedRegistrationSystemLib for DelegatorContext;
25
25
26
26
MetadataSystem private immutable metadataSystem = new MetadataSystem ();
27
27
28
28
function install (bytes memory args ) public override {
29
- DelegatorContext memory world = DelegatorContext (IBaseWorld (_world ()), _msgSender ());
30
-
31
29
ResourceId namespace = ResourceTag._tableId.getNamespaceId ();
32
30
if (! ResourceIds.getExists (namespace)) {
33
- world .registerNamespace (namespace);
31
+ worldRegistrationSystem. callFrom ( _msgSender ()) .registerNamespace (namespace);
34
32
}
35
- AccessControl.requireOwner (namespace, world.delegator );
33
+ AccessControl.requireOwner (namespace, _msgSender () );
36
34
37
35
if (! ResourceIds.getExists (ResourceTag._tableId)) {
38
36
// TODO: add a `ResourceTag.getTableDef()` that returns a struct that can be used to register?
39
- world .registerTable (
37
+ storeRegistrationSystem. callFrom ( _msgSender ()) .registerTable (
40
38
ResourceTag._tableId,
41
39
ResourceTag._fieldLayout,
42
40
ResourceTag._keySchema,
@@ -53,10 +51,19 @@ contract MetadataModule is Module {
53
51
);
54
52
// TODO: add support for upgrading system and registering new function selectors
55
53
if (! ResourceIds.getExists (metadataSystemId)) {
56
- world.registerSystem (metadataSystemId, metadataSystem, true );
57
- world.registerFunctionSelector (metadataSystemId, "getResourceTag(bytes32,bytes32) " );
58
- world.registerFunctionSelector (metadataSystemId, "setResourceTag(bytes32,bytes32,bytes) " );
59
- world.registerFunctionSelector (metadataSystemId, "deleteResourceTag(bytes32,bytes32) " );
54
+ worldRegistrationSystem.callFrom (_msgSender ()).registerSystem (metadataSystemId, metadataSystem, true );
55
+ worldRegistrationSystem.callFrom (_msgSender ()).registerFunctionSelector (
56
+ metadataSystemId,
57
+ "getResourceTag(bytes32,bytes32) "
58
+ );
59
+ worldRegistrationSystem.callFrom (_msgSender ()).registerFunctionSelector (
60
+ metadataSystemId,
61
+ "setResourceTag(bytes32,bytes32,bytes) "
62
+ );
63
+ worldRegistrationSystem.callFrom (_msgSender ()).registerFunctionSelector (
64
+ metadataSystemId,
65
+ "deleteResourceTag(bytes32,bytes32) "
66
+ );
60
67
}
61
68
}
62
69
}
0 commit comments