Skip to content

Commit 6344ced

Browse files
authored
feat(world-module-metadata): remove resource existence check (#3650)
1 parent a3645c8 commit 6344ced

6 files changed

Lines changed: 19 additions & 21 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/world-module-metadata": patch
3+
---
4+
5+
Adding/deleting resource tags no longer checks if resource exists, only if you're the resource namespace owner.

packages/store/ts/flattenStoreLogs.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ describe("flattenStoreLogs", async () => {
154154
"Store_SetRecord store__ResourceIds (0x74626d657461646174610000000000005265736f757263655461670000000000)",
155155
"Store_SetRecord store__ResourceIds (0x73796d657461646174610000000000004d6574616461746153797374656d0000)",
156156
"Store_SetRecord world__Systems (0x73796d657461646174610000000000004d6574616461746153797374656d0000)",
157-
"Store_SetRecord world__SystemRegistry (0x00000000000000000000000077c97a668f68dc030a3688fb7655780a1d800f95)",
158-
"Store_SetRecord world__ResourceAccess (0x6e736d6574616461746100000000000000000000000000000000000000000000,0x00000000000000000000000077c97a668f68dc030a3688fb7655780a1d800f95)",
157+
"Store_SetRecord world__SystemRegistry (0x00000000000000000000000092bf17e8e968b62012f80274087d6720712adeab)",
158+
"Store_SetRecord world__ResourceAccess (0x6e736d6574616461746100000000000000000000000000000000000000000000,0x00000000000000000000000092bf17e8e968b62012f80274087d6720712adeab)",
159159
"Store_SetRecord world__FunctionSelector (0xff66f05f00000000000000000000000000000000000000000000000000000000)",
160160
"Store_SetRecord world__FunctionSignatur (0xc6972e9300000000000000000000000000000000000000000000000000000000)",
161161
"Store_SetRecord world__FunctionSignatur (0xff66f05f00000000000000000000000000000000000000000000000000000000)",
@@ -165,7 +165,7 @@ describe("flattenStoreLogs", async () => {
165165
"Store_SetRecord world__FunctionSelector (0x5ce7ca1a00000000000000000000000000000000000000000000000000000000)",
166166
"Store_SetRecord world__FunctionSignatur (0xf128760200000000000000000000000000000000000000000000000000000000)",
167167
"Store_SetRecord world__FunctionSignatur (0x5ce7ca1a00000000000000000000000000000000000000000000000000000000)",
168-
"Store_SetRecord world__InstalledModules (0x0000000000000000000000004eb6f2596d44971d7d8065669c5bdba0a77e76a9,0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470)",
168+
"Store_SetRecord world__InstalledModules (0x0000000000000000000000006c8a14a9033f02b19db6ed9048f96772a6ec754e,0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470)",
169169
"Store_SetRecord metadata__ResourceTag (0x737900000000000000000000000000004d6f766553797374656d000000000000,0x6162690000000000000000000000000000000000000000000000000000000000)",
170170
"Store_SetRecord metadata__ResourceTag (0x737900000000000000000000000000004d6f766553797374656d000000000000,0x776f726c64416269000000000000000000000000000000000000000000000000)",
171171
"Store_SetRecord Position (0x0000000000000000000000001d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e)",

packages/store/ts/getStoreLogs.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,16 +172,16 @@ describe("getStoreLogs", async () => {
172172
"Store_SetRecord world__FunctionSignatur (0x1fae630800000000000000000000000000000000000000000000000000000000)",
173173
"Store_SetRecord world__FunctionSignatur (0x1fae630800000000000000000000000000000000000000000000000000000000)",
174174
"Store_SpliceStaticData world__InstalledModules (0x00000000000000000000000051bd8d2de7017c23ee5bdc885e70dfdd0862b837,0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470)",
175-
"Store_SpliceStaticData world__UserDelegationCo (0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266,0x0000000000000000000000004eb6f2596d44971d7d8065669c5bdba0a77e76a9)",
175+
"Store_SpliceStaticData world__UserDelegationCo (0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266,0x0000000000000000000000006c8a14a9033f02b19db6ed9048f96772a6ec754e)",
176176
"Store_SpliceStaticData store__ResourceIds (0x6e736d6574616461746100000000000000000000000000000000000000000000)",
177177
"Store_SpliceStaticData world__NamespaceOwner (0x6e736d6574616461746100000000000000000000000000000000000000000000)",
178178
"Store_SpliceStaticData world__ResourceAccess (0x6e736d6574616461746100000000000000000000000000000000000000000000,0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266)",
179179
"Store_SetRecord store__Tables (0x74626d657461646174610000000000005265736f757263655461670000000000)",
180180
"Store_SpliceStaticData store__ResourceIds (0x74626d657461646174610000000000005265736f757263655461670000000000)",
181181
"Store_SpliceStaticData store__ResourceIds (0x73796d657461646174610000000000004d6574616461746153797374656d0000)",
182182
"Store_SetRecord world__Systems (0x73796d657461646174610000000000004d6574616461746153797374656d0000)",
183-
"Store_SpliceStaticData world__SystemRegistry (0x00000000000000000000000077c97a668f68dc030a3688fb7655780a1d800f95)",
184-
"Store_SpliceStaticData world__ResourceAccess (0x6e736d6574616461746100000000000000000000000000000000000000000000,0x00000000000000000000000077c97a668f68dc030a3688fb7655780a1d800f95)",
183+
"Store_SpliceStaticData world__SystemRegistry (0x00000000000000000000000092bf17e8e968b62012f80274087d6720712adeab)",
184+
"Store_SpliceStaticData world__ResourceAccess (0x6e736d6574616461746100000000000000000000000000000000000000000000,0x00000000000000000000000092bf17e8e968b62012f80274087d6720712adeab)",
185185
"Store_SetRecord world__FunctionSelector (0xff66f05f00000000000000000000000000000000000000000000000000000000)",
186186
"Store_SetRecord world__FunctionSignatur (0xc6972e9300000000000000000000000000000000000000000000000000000000)",
187187
"Store_SetRecord world__FunctionSignatur (0xff66f05f00000000000000000000000000000000000000000000000000000000)",
@@ -191,8 +191,8 @@ describe("getStoreLogs", async () => {
191191
"Store_SetRecord world__FunctionSelector (0x5ce7ca1a00000000000000000000000000000000000000000000000000000000)",
192192
"Store_SetRecord world__FunctionSignatur (0xf128760200000000000000000000000000000000000000000000000000000000)",
193193
"Store_SetRecord world__FunctionSignatur (0x5ce7ca1a00000000000000000000000000000000000000000000000000000000)",
194-
"Store_SpliceStaticData world__InstalledModules (0x0000000000000000000000004eb6f2596d44971d7d8065669c5bdba0a77e76a9,0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470)",
195-
"Store_DeleteRecord world__UserDelegationCo (0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266,0x0000000000000000000000004eb6f2596d44971d7d8065669c5bdba0a77e76a9)",
194+
"Store_SpliceStaticData world__InstalledModules (0x0000000000000000000000006c8a14a9033f02b19db6ed9048f96772a6ec754e,0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470)",
195+
"Store_DeleteRecord world__UserDelegationCo (0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266,0x0000000000000000000000006c8a14a9033f02b19db6ed9048f96772a6ec754e)",
196196
"Store_SpliceDynamicData metadata__ResourceTag (0x737900000000000000000000000000004d6f766553797374656d000000000000,0x6162690000000000000000000000000000000000000000000000000000000000)",
197197
"Store_SpliceDynamicData metadata__ResourceTag (0x737900000000000000000000000000004d6f766553797374656d000000000000,0x776f726c64416269000000000000000000000000000000000000000000000000)",
198198
"Store_SetRecord Position (0x0000000000000000000000001d96f2f6bef1202e4ce1ff6dad0c2cb002861d3e)",

packages/world-module-metadata/gas-report.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"file": "test/MetadataModule.t.sol:MetadataModuleTest",
44
"test": "testDeleteResourceTag",
55
"name": "delete resource tag",
6-
"gasUsed": 72100
6+
"gasUsed": 67224
77
},
88
{
99
"file": "test/MetadataModule.t.sol:MetadataModuleTest",
@@ -15,6 +15,6 @@
1515
"file": "test/MetadataModule.t.sol:MetadataModuleTest",
1616
"test": "testSetResourceTag",
1717
"name": "set resource tag",
18-
"gasUsed": 118491
18+
"gasUsed": 113614
1919
}
2020
]

packages/world-module-metadata/src/MetadataSystem.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ contract MetadataSystem is System {
1313
}
1414

1515
function setResourceTag(ResourceId resource, bytes32 tag, bytes memory value) public {
16-
AccessControl.requireExistence(resource);
1716
AccessControl.requireOwner(resource, _msgSender());
1817
ResourceTag.set(resource, tag, value);
1918
}
2019

2120
function deleteResourceTag(ResourceId resource, bytes32 tag) public {
22-
AccessControl.requireExistence(resource);
2321
AccessControl.requireOwner(resource, _msgSender());
2422
ResourceTag.deleteRecord(resource, tag);
2523
}

packages/world-module-metadata/test/MetadataModule.t.sol

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,20 +99,15 @@ contract MetadataModuleTest is Test, GasReporter {
9999
assertEq(ResourceTag.get(resource, "label"), "");
100100
}
101101

102-
function testTagNonexistentResource() public {
102+
function testTagArbitraryResource() public {
103103
world.registerDelegation(address(metadataModule), UNLIMITED_DELEGATION, new bytes(0));
104104

105105
world.installModule(metadataModule, new bytes(0));
106-
ResourceId resource = WorldResourceIdLib.encode("tb", "whatever", "SomeTable");
107106

108-
vm.expectRevert(
109-
abi.encodeWithSelector(IWorldErrors.World_ResourceNotFound.selector, resource, resource.toString())
110-
);
111-
world.metadata__setResourceTag(resource, "label", "SomeTable");
107+
ResourceId resource = WorldResourceIdLib.encode("az", "whatever", "SomeResource");
108+
world.registerNamespace(resource.getNamespaceId());
112109

113-
vm.expectRevert(
114-
abi.encodeWithSelector(IWorldErrors.World_ResourceNotFound.selector, resource, resource.toString())
115-
);
110+
world.metadata__setResourceTag(resource, "label", "SomeArbitraryResource");
116111
world.metadata__deleteResourceTag(resource, "label");
117112
}
118113

0 commit comments

Comments
 (0)