From 92baf85b10796be060b86e7303a3b3f332e7adbf Mon Sep 17 00:00:00 2001 From: alvrs Date: Fri, 19 Jan 2024 18:52:43 +0000 Subject: [PATCH 1/9] feat(world): prevent invalid namespace strings --- packages/world/src/IWorldErrors.sol | 6 ++++++ packages/world/src/WorldResourceId.sol | 1 + packages/world/src/requireNamespace.sol | 19 ++++++++++++++++++- packages/world/test/World.t.sol | 6 ++++++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/packages/world/src/IWorldErrors.sol b/packages/world/src/IWorldErrors.sol index 29aed90045..7308db3d23 100644 --- a/packages/world/src/IWorldErrors.sol +++ b/packages/world/src/IWorldErrors.sol @@ -42,6 +42,12 @@ interface IWorldErrors { */ error World_InvalidResourceId(ResourceId resourceId, string resourceIdString); + /** + * @notice Raised when an namespace contains an invalid sequence of characters ("__"). + * @param namespace The invalid namespace. + */ + error World_InvalidNamespace(bytes14 namespace); + /** * @notice Raised when trying to register a system that already exists. * @param system The address of the system. diff --git a/packages/world/src/WorldResourceId.sol b/packages/world/src/WorldResourceId.sol index 4c6b340103..eb91ddd245 100644 --- a/packages/world/src/WorldResourceId.sol +++ b/packages/world/src/WorldResourceId.sol @@ -7,6 +7,7 @@ import { ResourceId, ResourceIdInstance, TYPE_BITS } from "@latticexyz/store/src import { ROOT_NAMESPACE, ROOT_NAME } from "./constants.sol"; import { RESOURCE_NAMESPACE, MASK_RESOURCE_NAMESPACE } from "./worldResourceTypes.sol"; +uint256 constant NAMESPACE_BYTES = 14; uint256 constant NAMESPACE_BITS = 14 * 8; // 14 bytes * 8 bits per byte uint256 constant NAME_BITS = 16 * 8; // 16 bytes * 8 bits per byte diff --git a/packages/world/src/requireNamespace.sol b/packages/world/src/requireNamespace.sol index 7de2c8088c..dd5e78c361 100644 --- a/packages/world/src/requireNamespace.sol +++ b/packages/world/src/requireNamespace.sol @@ -1,7 +1,9 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.21; -import { ResourceId, WorldResourceIdInstance } from "./WorldResourceId.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; + +import { ResourceId, WorldResourceIdInstance, NAMESPACE_BYTES } from "./WorldResourceId.sol"; import { RESOURCE_NAMESPACE } from "./worldResourceTypes.sol"; import { IWorldErrors } from "./IWorldErrors.sol"; @@ -13,7 +15,22 @@ using WorldResourceIdInstance for ResourceId; * @param resourceId The resource ID to verify. */ function requireNamespace(ResourceId resourceId) pure { + requireValidCharacters(resourceId.getNamespace()); + if (ResourceId.unwrap(resourceId) != ResourceId.unwrap(resourceId.getNamespaceId())) { revert IWorldErrors.World_InvalidResourceType(RESOURCE_NAMESPACE, resourceId, resourceId.toString()); } } + +/** + * @notice Checks if a given namespace string is valid. + * @dev Reverts with IWorldErrors.World_InvalidNamespace if the namespace includes the reserved separator string ("__"). + * @param namespace The namespace to verify. + */ +function requireValidCharacters(bytes14 namespace) pure { + for (uint256 i; i < NAMESPACE_BYTES - 1; i++) { + if (Bytes.slice1(namespace, i) == bytes1("_") && Bytes.slice1(namespace, i + 1) == bytes1("_")) { + revert IWorldErrors.World_InvalidNamespace(namespace); + } + } +} diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 9078a01e79..9090eca6e6 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -348,6 +348,12 @@ contract WorldTest is Test, GasReporter { world.registerNamespace(namespaceId); } + function testRegisterInvalidNamespace() public { + bytes14 invalid_namespace = "invld__nmsp"; + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_InvalidNamespace.selector, invalid_namespace)); + world.registerNamespace(WorldResourceIdLib.encodeNamespace(invalid_namespace)); + } + function testRegisterCoreNamespacesRevert() public { vm.expectRevert( abi.encodeWithSelector( From 0598d1e647e50802287ced99a7c5d7bc7abf79e7 Mon Sep 17 00:00:00 2001 From: alvrs Date: Mon, 22 Jan 2024 17:55:37 +0000 Subject: [PATCH 2/9] update gas-report --- packages/world-modules/gas-report.json | 12 ++++++------ packages/world/gas-report.json | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/packages/world-modules/gas-report.json b/packages/world-modules/gas-report.json index a330ba3498..e947939188 100644 --- a/packages/world-modules/gas-report.json +++ b/packages/world-modules/gas-report.json @@ -135,7 +135,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 683899 + "gasUsed": 687446 }, { "file": "test/KeysWithValueModule.t.sol", @@ -153,7 +153,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 683899 + "gasUsed": 687446 }, { "file": "test/KeysWithValueModule.t.sol", @@ -165,7 +165,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 683899 + "gasUsed": 687446 }, { "file": "test/KeysWithValueModule.t.sol", @@ -183,7 +183,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 683899 + "gasUsed": 687446 }, { "file": "test/KeysWithValueModule.t.sol", @@ -303,7 +303,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 701756 + "gasUsed": 705303 }, { "file": "test/UniqueEntityModule.t.sol", @@ -315,7 +315,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 670623 + "gasUsed": 674170 }, { "file": "test/UniqueEntityModule.t.sol", diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index 3d135987cd..e6ae595a9d 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -63,7 +63,7 @@ "file": "test/Factories.t.sol", "test": "testWorldFactory", "name": "deploy world via WorldFactory", - "gasUsed": 13041829 + "gasUsed": 13045376 }, { "file": "test/World.t.sol", @@ -111,7 +111,7 @@ "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 120951 + "gasUsed": 124498 }, { "file": "test/World.t.sol", @@ -129,13 +129,13 @@ "file": "test/World.t.sol", "test": "testRegisterTable", "name": "Register a new table in the namespace", - "gasUsed": 536881 + "gasUsed": 536849 }, { "file": "test/World.t.sol", "test": "testRenounceNamespace", "name": "Renounce namespace ownership", - "gasUsed": 36773 + "gasUsed": 40320 }, { "file": "test/World.t.sol", @@ -153,7 +153,7 @@ "file": "test/World.t.sol", "test": "testUnregisterNamespaceDelegation", "name": "unregister a namespace delegation", - "gasUsed": 28360 + "gasUsed": 31907 }, { "file": "test/World.t.sol", From fbc96a22a73c691e0e66e321883b0a237bc9e970 Mon Sep 17 00:00:00 2001 From: alvrs Date: Mon, 22 Jan 2024 18:31:18 +0000 Subject: [PATCH 3/9] refactor --- packages/world-modules/gas-report.json | 12 ++++++------ packages/world/gas-report.json | 8 ++++---- .../implementations/AccessManagementSystem.sol | 8 ++++---- .../implementations/BalanceTransferSystem.sol | 6 +++--- .../implementations/WorldRegistrationSystem.sol | 12 ++++++------ ...quireNamespace.sol => validateNamespace.sol} | 17 ++++++----------- 6 files changed, 29 insertions(+), 34 deletions(-) rename packages/world/src/{requireNamespace.sol => validateNamespace.sol} (76%) diff --git a/packages/world-modules/gas-report.json b/packages/world-modules/gas-report.json index e947939188..310266e60e 100644 --- a/packages/world-modules/gas-report.json +++ b/packages/world-modules/gas-report.json @@ -135,7 +135,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testGetKeysWithValueGas", "name": "install keys with value module", - "gasUsed": 687446 + "gasUsed": 687430 }, { "file": "test/KeysWithValueModule.t.sol", @@ -153,7 +153,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testInstall", "name": "install keys with value module", - "gasUsed": 687446 + "gasUsed": 687430 }, { "file": "test/KeysWithValueModule.t.sol", @@ -165,7 +165,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetAndDeleteRecordHook", "name": "install keys with value module", - "gasUsed": 687446 + "gasUsed": 687430 }, { "file": "test/KeysWithValueModule.t.sol", @@ -183,7 +183,7 @@ "file": "test/KeysWithValueModule.t.sol", "test": "testSetField", "name": "install keys with value module", - "gasUsed": 687446 + "gasUsed": 687430 }, { "file": "test/KeysWithValueModule.t.sol", @@ -303,7 +303,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstall", "name": "install unique entity module", - "gasUsed": 705303 + "gasUsed": 705287 }, { "file": "test/UniqueEntityModule.t.sol", @@ -315,7 +315,7 @@ "file": "test/UniqueEntityModule.t.sol", "test": "testInstallRoot", "name": "installRoot unique entity module", - "gasUsed": 674170 + "gasUsed": 674154 }, { "file": "test/UniqueEntityModule.t.sol", diff --git a/packages/world/gas-report.json b/packages/world/gas-report.json index e6ae595a9d..f180dbc31b 100644 --- a/packages/world/gas-report.json +++ b/packages/world/gas-report.json @@ -63,7 +63,7 @@ "file": "test/Factories.t.sol", "test": "testWorldFactory", "name": "deploy world via WorldFactory", - "gasUsed": 13045376 + "gasUsed": 13045360 }, { "file": "test/World.t.sol", @@ -111,7 +111,7 @@ "file": "test/World.t.sol", "test": "testRegisterNamespace", "name": "Register a new namespace", - "gasUsed": 124498 + "gasUsed": 124482 }, { "file": "test/World.t.sol", @@ -135,7 +135,7 @@ "file": "test/World.t.sol", "test": "testRenounceNamespace", "name": "Renounce namespace ownership", - "gasUsed": 40320 + "gasUsed": 40304 }, { "file": "test/World.t.sol", @@ -153,7 +153,7 @@ "file": "test/World.t.sol", "test": "testUnregisterNamespaceDelegation", "name": "unregister a namespace delegation", - "gasUsed": 31907 + "gasUsed": 31891 }, { "file": "test/World.t.sol", diff --git a/packages/world/src/modules/core/implementations/AccessManagementSystem.sol b/packages/world/src/modules/core/implementations/AccessManagementSystem.sol index 51816fd70a..1dffc586aa 100644 --- a/packages/world/src/modules/core/implementations/AccessManagementSystem.sol +++ b/packages/world/src/modules/core/implementations/AccessManagementSystem.sol @@ -6,7 +6,7 @@ import { AccessControl } from "../../../AccessControl.sol"; import { ResourceId } from "../../../WorldResourceId.sol"; import { ResourceAccess } from "../../../codegen/tables/ResourceAccess.sol"; import { NamespaceOwner } from "../../../codegen/tables/NamespaceOwner.sol"; -import { requireNamespace } from "../../../requireNamespace.sol"; +import { validateNamespace } from "../../../validateNamespace.sol"; import { LimitedCallContext } from "../LimitedCallContext.sol"; @@ -53,8 +53,8 @@ contract AccessManagementSystem is System, LimitedCallContext { * @param newOwner The address to which ownership should be transferred. */ function transferOwnership(ResourceId namespaceId, address newOwner) public virtual onlyDelegatecall { - // Require the namespace ID to be a valid namespace - requireNamespace(namespaceId); + // Require the namespace to be a valid namespace ID + validateNamespace(namespaceId); // Require the namespace to exist AccessControl.requireExistence(namespaceId); @@ -79,7 +79,7 @@ contract AccessManagementSystem is System, LimitedCallContext { */ function renounceOwnership(ResourceId namespaceId) public virtual onlyDelegatecall { // Require the namespace ID to be a valid namespace - requireNamespace(namespaceId); + validateNamespace(namespaceId); // Require the namespace to exist AccessControl.requireExistence(namespaceId); diff --git a/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol b/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol index fa7a30a566..cb703f8bdc 100644 --- a/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol +++ b/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol @@ -11,7 +11,7 @@ import { RESOURCE_NAMESPACE } from "../../../worldResourceTypes.sol"; import { IWorldErrors } from "../../../IWorldErrors.sol"; import { Balances } from "../../../codegen/tables/Balances.sol"; -import { requireNamespace } from "../../../requireNamespace.sol"; +import { validateNamespace } from "../../../validateNamespace.sol"; import { LimitedCallContext } from "../LimitedCallContext.sol"; @@ -35,9 +35,9 @@ contract BalanceTransferSystem is System, IWorldErrors, LimitedCallContext { uint256 amount ) public virtual onlyDelegatecall { // Require the from namespace to be a valid namespace ID - requireNamespace(fromNamespaceId); + validateNamespace(fromNamespaceId); // Require the to namespace to be a valid namespace ID - requireNamespace(toNamespaceId); + validateNamespace(toNamespaceId); // Require the namespace to exist AccessControl.requireExistence(toNamespaceId); diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index f88a6faf68..3112fd4b52 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -27,7 +27,7 @@ import { SystemRegistry } from "../../../codegen/tables/SystemRegistry.sol"; import { Systems } from "../../../codegen/tables/Systems.sol"; import { FunctionSelectors } from "../../../codegen/tables/FunctionSelectors.sol"; import { FunctionSignatures } from "../../../codegen/tables/FunctionSignatures.sol"; -import { requireNamespace } from "../../../requireNamespace.sol"; +import { validateNamespace } from "../../../validateNamespace.sol"; import { LimitedCallContext } from "../LimitedCallContext.sol"; @@ -44,8 +44,8 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext { * @param namespaceId The unique identifier for the new namespace */ function registerNamespace(ResourceId namespaceId) public virtual onlyDelegatecall { - // Require namespace ID to be a valid namespace - requireNamespace(namespaceId); + // Require namespace to be a valid namespace ID + validateNamespace(namespaceId); // Require namespace to not exist yet if (ResourceIds._getExists(namespaceId)) { @@ -299,8 +299,8 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext { ResourceId delegationControlId, bytes memory initCallData ) public onlyDelegatecall { - // Require namespace ID to be a valid namespace - requireNamespace(namespaceId); + // Require namespace to be a valid namespace ID + validateNamespace(namespaceId); // Require the delegation to not be unlimited if (!Delegation.isLimited(delegationControlId)) { @@ -335,7 +335,7 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext { */ function unregisterNamespaceDelegation(ResourceId namespaceId) public onlyDelegatecall { // Require namespace ID to be a valid namespace - requireNamespace(namespaceId); + validateNamespace(namespaceId); // Require the namespace to exist AccessControl.requireExistence(namespaceId); diff --git a/packages/world/src/requireNamespace.sol b/packages/world/src/validateNamespace.sol similarity index 76% rename from packages/world/src/requireNamespace.sol rename to packages/world/src/validateNamespace.sol index dd5e78c361..bb6f4627e0 100644 --- a/packages/world/src/requireNamespace.sol +++ b/packages/world/src/validateNamespace.sol @@ -10,24 +10,19 @@ import { IWorldErrors } from "./IWorldErrors.sol"; using WorldResourceIdInstance for ResourceId; /** - * @notice Checks if a given `resourceId` is a namespace. + * @notice Checks if a given `resourceId` is a valid namespace. * @dev Reverts with IWorldErrors.World_InvalidResourceType if the ID does not have the correct components. + * @dev Reverts with IWorldErrors.World_InvalidNamespace if the namespace includes the reserved separator string ("__"). * @param resourceId The resource ID to verify. */ -function requireNamespace(ResourceId resourceId) pure { - requireValidCharacters(resourceId.getNamespace()); - +function validateNamespace(ResourceId resourceId) pure { + // Require the resourceId to have the namespace type if (ResourceId.unwrap(resourceId) != ResourceId.unwrap(resourceId.getNamespaceId())) { revert IWorldErrors.World_InvalidResourceType(RESOURCE_NAMESPACE, resourceId, resourceId.toString()); } -} -/** - * @notice Checks if a given namespace string is valid. - * @dev Reverts with IWorldErrors.World_InvalidNamespace if the namespace includes the reserved separator string ("__"). - * @param namespace The namespace to verify. - */ -function requireValidCharacters(bytes14 namespace) pure { + // Require the namespace to not include the reserved separator + bytes14 namespace = resourceId.getNamespace(); for (uint256 i; i < NAMESPACE_BYTES - 1; i++) { if (Bytes.slice1(namespace, i) == bytes1("_") && Bytes.slice1(namespace, i + 1) == bytes1("_")) { revert IWorldErrors.World_InvalidNamespace(namespace); From df61c19e91e84f14f5223f4a560daee745852749 Mon Sep 17 00:00:00 2001 From: alvrs Date: Mon, 22 Jan 2024 18:46:45 +0000 Subject: [PATCH 4/9] add additional test --- packages/world/test/World.t.sol | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 9090eca6e6..278733ed46 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -349,9 +349,20 @@ contract WorldTest is Test, GasReporter { } function testRegisterInvalidNamespace() public { - bytes14 invalid_namespace = "invld__nmsp"; - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_InvalidNamespace.selector, invalid_namespace)); - world.registerNamespace(WorldResourceIdLib.encodeNamespace(invalid_namespace)); + ResourceId invalidNamespaceId = WorldResourceIdLib.encode(RESOURCE_SYSTEM, "namespace", "system"); + vm.expectRevert( + abi.encodeWithSelector( + IWorldErrors.World_InvalidResourceType.selector, + RESOURCE_NAMESPACE, + invalidNamespaceId, + invalidNamespaceId.toString() + ) + ); + world.registerNamespace(invalidNamespaceId); + + bytes14 invalidNamespace = "invld__nmsp"; + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_InvalidNamespace.selector, invalidNamespace)); + world.registerNamespace(WorldResourceIdLib.encodeNamespace(invalidNamespace)); } function testRegisterCoreNamespacesRevert() public { From edeea8634218d6c677f86131d314a8b1d899fa40 Mon Sep 17 00:00:00 2001 From: alvarius Date: Mon, 22 Jan 2024 18:56:59 +0000 Subject: [PATCH 5/9] Create tidy-stingrays-think.md --- .changeset/tidy-stingrays-think.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/tidy-stingrays-think.md diff --git a/.changeset/tidy-stingrays-think.md b/.changeset/tidy-stingrays-think.md new file mode 100644 index 0000000000..f1b5d8ecf8 --- /dev/null +++ b/.changeset/tidy-stingrays-think.md @@ -0,0 +1,9 @@ +--- +"@latticexyz/world": major +--- + +Namespaces are not allowed to contain double underscores ("__") anymore, as this sequence of characters is used to [separate the namespace and function selector](https://github.com/latticexyz/mud/pull/2168) in namespaced systems. +This is to prevent signature clashes of functions in different namespaces. + +(Example: If namespaces were allowed to contain this separator string, a function "function" in namespace "namespace__my" would result in the namespaced function selector "namespace__my__function", +and would clash with a function "my__function" in namespace "namespace".) From 3630aba5366bcaf404842d68ba7a906ff01fd8d3 Mon Sep 17 00:00:00 2001 From: alvrs Date: Mon, 22 Jan 2024 20:16:34 +0000 Subject: [PATCH 6/9] prettier --- .changeset/tidy-stingrays-think.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.changeset/tidy-stingrays-think.md b/.changeset/tidy-stingrays-think.md index f1b5d8ecf8..97a4431ba3 100644 --- a/.changeset/tidy-stingrays-think.md +++ b/.changeset/tidy-stingrays-think.md @@ -2,8 +2,8 @@ "@latticexyz/world": major --- -Namespaces are not allowed to contain double underscores ("__") anymore, as this sequence of characters is used to [separate the namespace and function selector](https://github.com/latticexyz/mud/pull/2168) in namespaced systems. +Namespaces are not allowed to contain double underscores ("\_\_") anymore, as this sequence of characters is used to [separate the namespace and function selector](https://github.com/latticexyz/mud/pull/2168) in namespaced systems. This is to prevent signature clashes of functions in different namespaces. -(Example: If namespaces were allowed to contain this separator string, a function "function" in namespace "namespace__my" would result in the namespaced function selector "namespace__my__function", -and would clash with a function "my__function" in namespace "namespace".) +(Example: If namespaces were allowed to contain this separator string, a function "function" in namespace "namespace**my" would result in the namespaced function selector "namespace**my**function", +and would clash with a function "my**function" in namespace "namespace".) From c97adb64e6edd271e4f6f59fafbb4bfe3aca1ba9 Mon Sep 17 00:00:00 2001 From: alvarius Date: Mon, 22 Jan 2024 20:49:11 +0000 Subject: [PATCH 7/9] Apply suggestions from code review --- .changeset/tidy-stingrays-think.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/tidy-stingrays-think.md b/.changeset/tidy-stingrays-think.md index 97a4431ba3..2bbee42817 100644 --- a/.changeset/tidy-stingrays-think.md +++ b/.changeset/tidy-stingrays-think.md @@ -5,5 +5,5 @@ Namespaces are not allowed to contain double underscores ("\_\_") anymore, as this sequence of characters is used to [separate the namespace and function selector](https://github.com/latticexyz/mud/pull/2168) in namespaced systems. This is to prevent signature clashes of functions in different namespaces. -(Example: If namespaces were allowed to contain this separator string, a function "function" in namespace "namespace**my" would result in the namespaced function selector "namespace**my**function", -and would clash with a function "my**function" in namespace "namespace".) +(Example: If namespaces were allowed to contain this separator string, a function "function" in namespace "namespace\_\_my" would result in the namespaced function selector "namespace\_\_my\_\_function", +and would clash with a function "my\_\_function" in namespace "namespace".) From f3bbc32db91612c07e97dec51246a617d452a808 Mon Sep 17 00:00:00 2001 From: alvarius Date: Mon, 22 Jan 2024 20:52:14 +0000 Subject: [PATCH 8/9] Apply suggestions from code review --- .../modules/core/implementations/AccessManagementSystem.sol | 2 +- .../modules/core/implementations/WorldRegistrationSystem.sol | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/world/src/modules/core/implementations/AccessManagementSystem.sol b/packages/world/src/modules/core/implementations/AccessManagementSystem.sol index 1dffc586aa..41e58ad6af 100644 --- a/packages/world/src/modules/core/implementations/AccessManagementSystem.sol +++ b/packages/world/src/modules/core/implementations/AccessManagementSystem.sol @@ -53,7 +53,7 @@ contract AccessManagementSystem is System, LimitedCallContext { * @param newOwner The address to which ownership should be transferred. */ function transferOwnership(ResourceId namespaceId, address newOwner) public virtual onlyDelegatecall { - // Require the namespace to be a valid namespace ID + // Require the namespace ID to be a valid namespace validateNamespace(namespaceId); // Require the namespace to exist diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index 3112fd4b52..77fecb482a 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -44,7 +44,7 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext { * @param namespaceId The unique identifier for the new namespace */ function registerNamespace(ResourceId namespaceId) public virtual onlyDelegatecall { - // Require namespace to be a valid namespace ID + // Require namespace ID to be valid namespace validateNamespace(namespaceId); // Require namespace to not exist yet @@ -299,7 +299,7 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext { ResourceId delegationControlId, bytes memory initCallData ) public onlyDelegatecall { - // Require namespace to be a valid namespace ID + // Require namespace ID to be a valid namespace validateNamespace(namespaceId); // Require the delegation to not be unlimited From e5372ab3912cfcff36ce4a7a3e2a125b578b131b Mon Sep 17 00:00:00 2001 From: alvarius Date: Mon, 22 Jan 2024 20:52:46 +0000 Subject: [PATCH 9/9] Update packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol --- .../modules/core/implementations/WorldRegistrationSystem.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index 77fecb482a..a0f7dc70dc 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -44,7 +44,7 @@ contract WorldRegistrationSystem is System, IWorldErrors, LimitedCallContext { * @param namespaceId The unique identifier for the new namespace */ function registerNamespace(ResourceId namespaceId) public virtual onlyDelegatecall { - // Require namespace ID to be valid namespace + // Require namespace ID to be a valid namespace validateNamespace(namespaceId); // Require namespace to not exist yet