diff --git a/packages/world/src/AccessControl.sol b/packages/world/src/AccessControl.sol index 4cab35d064..ce364342fd 100644 --- a/packages/world/src/AccessControl.sol +++ b/packages/world/src/AccessControl.sol @@ -22,22 +22,22 @@ library AccessControl { /** * Check for access at the given namespace or name. - * Reverts with AccessDenied if the caller has no access. + * Reverts with World_AccessDenied if the caller has no access. */ function requireAccess(ResourceId resourceId, address caller) internal view { // Check if the given caller has access to the given namespace or name if (!hasAccess(resourceId, caller)) { - revert IWorldErrors.AccessDenied(resourceId.toString(), caller); + revert IWorldErrors.World_AccessDenied(resourceId.toString(), caller); } } /** * Check for ownership of the namespace of the given resource ID. - * Reverts with AccessDenied if the check fails. + * Reverts with World_AccessDenied if the check fails. */ function requireOwner(ResourceId resourceId, address caller) internal view { if (NamespaceOwner._get(ResourceId.unwrap(resourceId.getNamespaceId())) != caller) { - revert IWorldErrors.AccessDenied(resourceId.toString(), caller); + revert IWorldErrors.World_AccessDenied(resourceId.toString(), caller); } } } diff --git a/packages/world/src/SystemCall.sol b/packages/world/src/SystemCall.sol index 50446dd14c..0a241c86eb 100644 --- a/packages/world/src/SystemCall.sol +++ b/packages/world/src/SystemCall.sol @@ -36,7 +36,7 @@ library SystemCall { (address systemAddress, bool publicAccess) = Systems._get(ResourceId.unwrap(systemId)); // Check if the system exists - if (systemAddress == address(0)) revert IWorldErrors.ResourceNotFound(systemId, systemId.toString()); + if (systemAddress == address(0)) revert IWorldErrors.World_ResourceNotFound(systemId, systemId.toString()); // Allow access if the system is public or the caller has access to the namespace or name if (!publicAccess) AccessControl.requireAccess(systemId, caller); diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 3b9bd8e68a..31fe1fee3b 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -55,12 +55,12 @@ contract World is StoreRead, IStoreData, IWorldKernel { function initialize(IModule coreModule) public { // Only the initial creator of the World can initialize it if (msg.sender != creator) { - revert AccessDenied(ROOT_NAMESPACE_ID.toString(), msg.sender); + revert World_AccessDenied(ROOT_NAMESPACE_ID.toString(), msg.sender); } // The World can only be initialized once if (InstalledModules._get(CORE_MODULE_NAME, keccak256("")) != address(0)) { - revert WorldAlreadyInitialized(); + revert World_AlreadyInitialized(); } // Initialize the World by installing the core module @@ -274,7 +274,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { return SystemCall.callWithHooksOrRevert(delegator, systemId, callData, msg.value); } - revert DelegationNotFound(delegator, msg.sender); + revert World_DelegationNotFound(delegator, msg.sender); } /************************************************************************ @@ -297,7 +297,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { fallback() external payable { (bytes32 systemId, bytes4 systemFunctionSelector) = FunctionSelectors._get(msg.sig); - if (systemId == 0) revert FunctionSelectorNotFound(msg.sig); + if (systemId == 0) revert World_FunctionSelectorNotFound(msg.sig); // Replace function selector in the calldata with the system function selector bytes memory callData = Bytes.setBytes4(msg.data, 0, systemFunctionSelector); diff --git a/packages/world/src/interfaces/IWorldErrors.sol b/packages/world/src/interfaces/IWorldErrors.sol index d95922e393..44818662de 100644 --- a/packages/world/src/interfaces/IWorldErrors.sol +++ b/packages/world/src/interfaces/IWorldErrors.sol @@ -4,16 +4,16 @@ pragma solidity >=0.8.21; import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; interface IWorldErrors { - error WorldAlreadyInitialized(); - error ResourceExists(ResourceId resourceId, string resourceIdString); - error ResourceNotFound(ResourceId resourceId, string resourceIdString); - error AccessDenied(string resource, address caller); - error InvalidResourceId(ResourceId resourceId, string resourceIdString); - error SystemExists(address system); - error FunctionSelectorExists(bytes4 functionSelector); - error FunctionSelectorNotFound(bytes4 functionSelector); - error DelegationNotFound(address delegator, address delegatee); - error InsufficientBalance(uint256 balance, uint256 amount); - error InterfaceNotSupported(address contractAddress, bytes4 interfaceId); - error InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString); + error World_AlreadyInitialized(); + error World_ResourceAlreadyExists(ResourceId resourceId, string resourceIdString); + error World_ResourceNotFound(ResourceId resourceId, string resourceIdString); + error World_AccessDenied(string resource, address caller); + error World_InvalidResourceId(ResourceId resourceId, string resourceIdString); + error World_SystemAlreadyExists(address system); + error World_FunctionSelectorAlreadyExists(bytes4 functionSelector); + error World_FunctionSelectorNotFound(bytes4 functionSelector); + error World_DelegationNotFound(address delegator, address delegatee); + error World_InsufficientBalance(uint256 balance, uint256 amount); + error World_InterfaceNotSupported(address contractAddress, bytes4 interfaceId); + error World_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString); } diff --git a/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol b/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol index 3b1a59bbdc..9bae047ac2 100644 --- a/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol +++ b/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol @@ -26,7 +26,7 @@ contract BalanceTransferSystem is System, IWorldErrors { ) public virtual { // Require the target ID to be a namespace ID if (toNamespaceId.getType() != RESOURCE_NAMESPACE) { - revert InvalidResourceType(RESOURCE_NAMESPACE, toNamespaceId, toNamespaceId.toString()); + revert World_InvalidResourceType(RESOURCE_NAMESPACE, toNamespaceId, toNamespaceId.toString()); } // Require caller to have access to the namespace @@ -36,7 +36,7 @@ contract BalanceTransferSystem is System, IWorldErrors { uint256 balance = Balances._get(ResourceId.unwrap(fromNamespaceId)); // Require the balance balance to be greater or equal to the amount to transfer - if (amount > balance) revert InsufficientBalance(balance, amount); + if (amount > balance) revert World_InsufficientBalance(balance, amount); // Update the balances Balances._set(ResourceId.unwrap(fromNamespaceId), balance - amount); @@ -54,7 +54,7 @@ contract BalanceTransferSystem is System, IWorldErrors { uint256 balance = Balances._get(ResourceId.unwrap(fromNamespaceId)); // Require the balance balance to be greater or equal to the amount to transfer - if (amount > balance) revert InsufficientBalance(balance, amount); + if (amount > balance) revert World_InsufficientBalance(balance, amount); // Update the balances Balances._set(ResourceId.unwrap(fromNamespaceId), balance - amount); diff --git a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol index 05811bc8ed..43f0535b97 100644 --- a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol @@ -45,7 +45,7 @@ contract StoreRegistrationSystem is System, IWorldErrors { string[] calldata fieldNames ) public virtual { // Require the name to not be the namespace's root name - if (tableId.getName() == ROOT_NAME) revert InvalidResourceId(tableId, tableId.toString()); + if (tableId.getName() == ROOT_NAME) revert World_InvalidResourceId(tableId, tableId.toString()); // If the namespace doesn't exist yet, register it ResourceId namespaceId = tableId.getNamespaceId(); diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index 9a08b90f29..6ee8391a33 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -39,12 +39,12 @@ contract WorldRegistrationSystem is System, IWorldErrors { function registerNamespace(ResourceId namespaceId) public virtual { // Require the provided namespace ID to have type RESOURCE_NAMESPACE if (namespaceId.getType() != RESOURCE_NAMESPACE) { - revert InvalidResourceType(RESOURCE_NAMESPACE, namespaceId, namespaceId.toString()); + revert World_InvalidResourceType(RESOURCE_NAMESPACE, namespaceId, namespaceId.toString()); } // Require namespace to not exist yet if (ResourceIds._getExists(ResourceId.unwrap(namespaceId))) { - revert ResourceExists(namespaceId, namespaceId.toString()); + revert World_ResourceAlreadyExists(namespaceId, namespaceId.toString()); } // Register namespace resource ID @@ -97,19 +97,19 @@ contract WorldRegistrationSystem is System, IWorldErrors { function registerSystem(ResourceId systemId, WorldContextConsumer system, bool publicAccess) public virtual { // Require the provided system ID to have type RESOURCE_SYSTEM if (systemId.getType() != RESOURCE_SYSTEM) { - revert InvalidResourceType(RESOURCE_SYSTEM, systemId, systemId.toString()); + revert World_InvalidResourceType(RESOURCE_SYSTEM, systemId, systemId.toString()); } // Require the provided address to implement the WorldContextConsumer interface requireInterface(address(system), WORLD_CONTEXT_CONSUMER_INTERFACE_ID); // Require the name to not be the namespace's root name - if (systemId.getName() == ROOT_NAME) revert InvalidResourceId(systemId, systemId.toString()); + if (systemId.getName() == ROOT_NAME) revert World_InvalidResourceId(systemId, systemId.toString()); // Require this system to not be registered at a different system ID yet bytes32 existingSystemId = SystemRegistry._get(address(system)); if (existingSystemId != 0 && existingSystemId != ResourceId.unwrap(systemId)) { - revert SystemExists(address(system)); + revert World_SystemAlreadyExists(address(system)); } // If the namespace doesn't exist yet, register it @@ -171,7 +171,7 @@ contract WorldRegistrationSystem is System, IWorldErrors { // Require the function selector to be globally unique bytes32 existingSystemId = FunctionSelectors._getSystemId(worldFunctionSelector); - if (existingSystemId != 0) revert FunctionSelectorExists(worldFunctionSelector); + if (existingSystemId != 0) revert World_FunctionSelectorAlreadyExists(worldFunctionSelector); // Register the function selector bytes memory systemFunctionSignature = abi.encodePacked(systemFunctionName, systemFunctionArguments); @@ -199,7 +199,7 @@ contract WorldRegistrationSystem is System, IWorldErrors { // Require the function selector to be globally unique bytes32 existingSystemId = FunctionSelectors._getSystemId(worldFunctionSelector); - if (existingSystemId != 0) revert FunctionSelectorExists(worldFunctionSelector); + if (existingSystemId != 0) revert World_FunctionSelectorAlreadyExists(worldFunctionSelector); // Register the function selector FunctionSelectors._set(worldFunctionSelector, ResourceId.unwrap(systemId), systemFunctionSelector); diff --git a/packages/world/src/requireInterface.sol b/packages/world/src/requireInterface.sol index 420d78f1b2..10c927e163 100644 --- a/packages/world/src/requireInterface.sol +++ b/packages/world/src/requireInterface.sol @@ -10,9 +10,9 @@ import { IWorldErrors } from "./interfaces/IWorldErrors.sol"; function requireInterface(address contractAddress, bytes4 interfaceId) view { try IERC165(contractAddress).supportsInterface(interfaceId) returns (bool supported) { if (!supported) { - revert IWorldErrors.InterfaceNotSupported(contractAddress, interfaceId); + revert IWorldErrors.World_InterfaceNotSupported(contractAddress, interfaceId); } } catch { - revert IWorldErrors.InterfaceNotSupported(contractAddress, interfaceId); + revert IWorldErrors.World_InterfaceNotSupported(contractAddress, interfaceId); } } diff --git a/packages/world/test/AccessControl.t.sol b/packages/world/test/AccessControl.t.sol index 07ff0f845f..335a874fee 100644 --- a/packages/world/test/AccessControl.t.sol +++ b/packages/world/test/AccessControl.t.sol @@ -96,7 +96,7 @@ contract AccessControlTest is Test, GasReporter, StoreMock { function testRequireAccessRevert() public { ResourceId tableId = _tableId; - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.AccessDenied.selector, tableId.toString(), caller)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_AccessDenied.selector, tableId.toString(), caller)); AccessControl.requireAccess(tableId, caller); } } diff --git a/packages/world/test/StandardDelegationsModule.t.sol b/packages/world/test/StandardDelegationsModule.t.sol index 7b8b936fae..52b4bb5787 100644 --- a/packages/world/test/StandardDelegationsModule.t.sol +++ b/packages/world/test/StandardDelegationsModule.t.sol @@ -66,7 +66,7 @@ contract StandardDelegationsModuleTest is Test, GasReporter { // Expect the delegation to have been used up vm.prank(delegatee); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.DelegationNotFound.selector, delegator, delegatee)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_DelegationNotFound.selector, delegator, delegatee)); world.callFrom(delegator, systemId, abi.encodeCall(WorldTestSystem.msgSender, ())); } @@ -104,11 +104,11 @@ contract StandardDelegationsModuleTest is Test, GasReporter { // Set the timestamp to maxTimestamp+1 and expect the delegation to be expired vm.warp(maxTimestamp + 1); vm.prank(delegatee); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.DelegationNotFound.selector, delegator, delegatee)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_DelegationNotFound.selector, delegator, delegatee)); world.callFrom(delegator, systemId, abi.encodeCall(WorldTestSystem.msgSender, ())); } - function testRegisterDelegationRevertInterfaceNotSupported() public { + function testRegisterDelegationRevertWorld_InterfaceNotSupported() public { // Register a system that is not a delegation control system System noDelegationControlSystem = new System(); ResourceId noDelegationControlId = WorldResourceIdLib.encode({ @@ -122,7 +122,7 @@ contract StandardDelegationsModuleTest is Test, GasReporter { vm.prank(delegator); vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.InterfaceNotSupported.selector, + IWorldErrors.World_InterfaceNotSupported.selector, address(noDelegationControlSystem), DELEGATION_CONTROL_INTERFACE_ID ) diff --git a/packages/world/test/UniqueEntityModule.t.sol b/packages/world/test/UniqueEntityModule.t.sol index ec150d0a0a..d9bec364d6 100644 --- a/packages/world/test/UniqueEntityModule.t.sol +++ b/packages/world/test/UniqueEntityModule.t.sol @@ -84,7 +84,7 @@ contract UniqueEntityModuleTest is Test, GasReporter { // But changing the table directly isn't allowed vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.AccessDenied.selector, + IWorldErrors.World_AccessDenied.selector, WorldResourceIdLib.encode({ typeId: RESOURCE_TABLE, namespace: NAMESPACE, name: TABLE_NAME }).toString(), alice ) diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 4ff47ce5c1..c8b83209da 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -183,11 +183,11 @@ contract WorldTest is Test, GasReporter { } // Expect an error when trying to write from an address that doesn't have access - function _expectAccessDenied(address caller, bytes14 namespace, bytes16 name, bytes2 resourceType) internal { + function _expectWorld_AccessDenied(address caller, bytes14 namespace, bytes16 name, bytes2 resourceType) internal { vm.prank(caller); vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.AccessDenied.selector, + IWorldErrors.World_AccessDenied.selector, WorldResourceIdLib.encode({ typeId: resourceType, namespace: namespace, name: name }).toString(), caller ) @@ -208,7 +208,7 @@ contract WorldTest is Test, GasReporter { vm.prank(address(0x4242)); vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.AccessDenied.selector, + IWorldErrors.World_AccessDenied.selector, WorldResourceIdLib.encodeNamespace(ROOT_NAMESPACE).toString(), address(0x4242) ) @@ -247,15 +247,15 @@ contract WorldTest is Test, GasReporter { ); // Expect it to not be possible to initialize the World again - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.WorldAlreadyInitialized.selector)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_AlreadyInitialized.selector)); newWorld.initialize(coreModule); } - function testRegisterModuleRevertInterfaceNotSupported() public { + function testRegisterModuleRevertWorld_InterfaceNotSupported() public { // Expect an error when trying to register a module that doesn't implement the IModule interface vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.InterfaceNotSupported.selector, + IWorldErrors.World_InterfaceNotSupported.selector, Module(address(world)), // The World contract does not implement the IModule interface MODULE_INTERFACE_ID ) @@ -265,7 +265,7 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to register a root module that doesn't implement the IModule interface vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.InterfaceNotSupported.selector, + IWorldErrors.World_InterfaceNotSupported.selector, Module(address(world)), // The World contract does not implement the IModule interface MODULE_INTERFACE_ID ) @@ -322,7 +322,9 @@ contract WorldTest is Test, GasReporter { assertTrue(ResourceIds.getExists(world, ResourceId.unwrap(namespaceId))); // Expect an error when registering an existing namespace - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.ResourceExists.selector, namespaceId, namespaceId.toString())); + vm.expectRevert( + abi.encodeWithSelector(IWorldErrors.World_ResourceAlreadyExists.selector, namespaceId, namespaceId.toString()) + ); world.registerNamespace(namespaceId); } @@ -336,7 +338,7 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to register a namespace with an invalid type vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.InvalidResourceType.selector, + IWorldErrors.World_InvalidResourceType.selector, RESOURCE_NAMESPACE, invalidNamespaceId, invalidNamespaceId.toString() @@ -393,7 +395,7 @@ contract WorldTest is Test, GasReporter { ); // Expect revert if caller is not the owner - _expectAccessDenied(address(this), namespace, 0, RESOURCE_NAMESPACE); + _expectWorld_AccessDenied(address(this), namespace, 0, RESOURCE_NAMESPACE); world.transferOwnership(namespaceId, address(1)); } @@ -447,11 +449,11 @@ contract WorldTest is Test, GasReporter { namespace: namespace, name: "otherTable" }); - _expectAccessDenied(address(0x01), namespace, "", RESOURCE_NAMESPACE); + _expectWorld_AccessDenied(address(0x01), namespace, "", RESOURCE_NAMESPACE); world.registerTable(otherTableId, fieldLayout, defaultKeySchema, valueSchema, keyNames, fieldNames); // Expect the World to not be allowed to call registerTable via an external call - _expectAccessDenied(address(world), namespace, "", RESOURCE_NAMESPACE); + _expectWorld_AccessDenied(address(world), namespace, "", RESOURCE_NAMESPACE); world.registerTable(otherTableId, fieldLayout, defaultKeySchema, valueSchema, keyNames, fieldNames); } @@ -506,7 +508,7 @@ contract WorldTest is Test, GasReporter { assertEq(NamespaceOwner.get(world, ResourceId.unwrap(newNamespaceId)), address(this)); // Expect an error when registering an existing system at a new system ID - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.SystemExists.selector, address(system))); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_SystemAlreadyExists.selector, address(system))); world.registerSystem( WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "", name: "newSystem" }), system, @@ -528,13 +530,18 @@ contract WorldTest is Test, GasReporter { new string[](1) ); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.InvalidResourceType.selector, RESOURCE_SYSTEM, tableId, tableId.toString()) + abi.encodeWithSelector( + IWorldErrors.World_InvalidResourceType.selector, + RESOURCE_SYSTEM, + tableId, + tableId.toString() + ) ); world.registerSystem(tableId, newSystem, true); // Expect an error when registering a system in a namespace that is not owned by the caller System yetAnotherSystem = new System(); - _expectAccessDenied(address(0x01), "", "", RESOURCE_NAMESPACE); + _expectWorld_AccessDenied(address(0x01), "", "", RESOURCE_NAMESPACE); world.registerSystem( WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "", name: "rootSystem" }), yetAnotherSystem, @@ -542,7 +549,7 @@ contract WorldTest is Test, GasReporter { ); // Expect the registration to fail when coming from the World (since the World address doesn't have access) - _expectAccessDenied(address(world), "", "", RESOURCE_NAMESPACE); + _expectWorld_AccessDenied(address(world), "", "", RESOURCE_NAMESPACE); world.registerSystem( WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "", name: "rootSystem" }), yetAnotherSystem, @@ -552,7 +559,7 @@ contract WorldTest is Test, GasReporter { // Expect the registration to fail if the provided address does not implement the WorldContextConsumer interface vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.InterfaceNotSupported.selector, + IWorldErrors.World_InterfaceNotSupported.selector, address(world), WORLD_CONTEXT_CONSUMER_INTERFACE_ID ) @@ -628,7 +635,12 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to register a system at the same ID vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.InvalidResourceType.selector, RESOURCE_SYSTEM, tableId, tableId.toString()) + abi.encodeWithSelector( + IWorldErrors.World_InvalidResourceType.selector, + RESOURCE_SYSTEM, + tableId, + tableId.toString() + ) ); world.registerSystem(tableId, system, false); @@ -704,7 +716,7 @@ contract WorldTest is Test, GasReporter { assertTrue(Bool.get(world, tableId)); // Expect an error when trying to write from an address that doesn't have access - _expectAccessDenied(address(0x01), "testSetRecord", "testTable", RESOURCE_TABLE); + _expectWorld_AccessDenied(address(0x01), "testSetRecord", "testTable", RESOURCE_TABLE); Bool.set(world, tableId, true); // Expect the World to have access @@ -730,7 +742,7 @@ contract WorldTest is Test, GasReporter { assertTrue(Bool.get(world, tableId)); // Expect an error when trying to write from an address that doesn't have access - _expectAccessDenied(address(0x01), "testSetField", "testTable", RESOURCE_TABLE); + _expectWorld_AccessDenied(address(0x01), "testSetField", "testTable", RESOURCE_TABLE); world.setField(tableId, singletonKey, 0, abi.encodePacked(true), fieldLayout); // Expect the World to have access @@ -772,7 +784,7 @@ contract WorldTest is Test, GasReporter { assertEq(AddressArray.get(world, tableId, key), dataToPush); // Expect an error when trying to write from an address that doesn't have access - _expectAccessDenied(address(0x01), namespace, name, RESOURCE_TABLE); + _expectWorld_AccessDenied(address(0x01), namespace, name, RESOURCE_TABLE); world.pushToField(tableId, keyTuple, 0, encodedData, fieldLayout); // Expect the World to have access @@ -821,7 +833,7 @@ contract WorldTest is Test, GasReporter { assertTrue(Bool.get(world, tableId)); // Expect an error when trying to delete from an address that doesn't have access - _expectAccessDenied(address(0x02), namespace, name, RESOURCE_TABLE); + _expectWorld_AccessDenied(address(0x02), namespace, name, RESOURCE_TABLE); world.deleteRecord(tableId, singletonKey, fieldLayout); // Expect the World to have access @@ -861,7 +873,7 @@ contract WorldTest is Test, GasReporter { assertEq(returnStruct.input, bytes32(uint256(0x123))); // Expect an error when trying to call a private system from an address that doesn't have access - _expectAccessDenied(address(0x01), "namespace", "testSystem", RESOURCE_SYSTEM); + _expectWorld_AccessDenied(address(0x01), "namespace", "testSystem", RESOURCE_SYSTEM); world.call(systemId, abi.encodeCall(WorldTestSystem.msgSender, ())); // Expect the World to have access @@ -956,7 +968,7 @@ contract WorldTest is Test, GasReporter { assertEq(returnedAddress, delegator); } - function testCallFromFailDelegationNotFound() public { + function testCallFromFailWorld_DelegationNotFound() public { // Register a new system WorldTestSystem system = new WorldTestSystem(); ResourceId systemId = WorldResourceIdLib.encode({ @@ -969,7 +981,7 @@ contract WorldTest is Test, GasReporter { // Expect a revert when attempting to perform a call on behalf of an address that doesn't have a delegation vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.DelegationNotFound.selector, + IWorldErrors.World_DelegationNotFound.selector, address(2), // Delegator address(1) // Delegatee ) @@ -1059,7 +1071,7 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to register an address that doesn't implement the IStoreHook interface vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.InterfaceNotSupported.selector, address(world), STORE_HOOK_INTERFACE_ID) + abi.encodeWithSelector(IWorldErrors.World_InterfaceNotSupported.selector, address(world), STORE_HOOK_INTERFACE_ID) ); world.registerStoreHook( tableId, @@ -1162,7 +1174,11 @@ contract WorldTest is Test, GasReporter { // Expect the registration to fail if the contract does not implement the system hook interface vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.InterfaceNotSupported.selector, address(world), SYSTEM_HOOK_INTERFACE_ID) + abi.encodeWithSelector( + IWorldErrors.World_InterfaceNotSupported.selector, + address(world), + SYSTEM_HOOK_INTERFACE_ID + ) ); world.registerSystemHook( systemId, @@ -1364,11 +1380,11 @@ contract WorldTest is Test, GasReporter { bytes4 sysFunc = WorldTestSystem.msgSender.selector; // Expect an error when trying to register a root function selector from an account without access - _expectAccessDenied(address(0x01), "", "", RESOURCE_NAMESPACE); + _expectWorld_AccessDenied(address(0x01), "", "", RESOURCE_NAMESPACE); world.registerRootFunctionSelector(systemId, worldFunc, sysFunc); // Expect the World to not be able to register a root function selector when calling the function externally - _expectAccessDenied(address(world), "", "", RESOURCE_NAMESPACE); + _expectWorld_AccessDenied(address(world), "", "", RESOURCE_NAMESPACE); world.registerRootFunctionSelector(systemId, "smth", "smth"); startGasReport("Register a root function selector"); diff --git a/packages/world/test/WorldBalance.t.sol b/packages/world/test/WorldBalance.t.sol index 3a6e889925..e231ca9fbb 100644 --- a/packages/world/test/WorldBalance.t.sol +++ b/packages/world/test/WorldBalance.t.sol @@ -176,7 +176,7 @@ contract WorldBalanceTest is Test, GasReporter { assertEq(Balances.get(world, ResourceId.unwrap(namespaceId)), value); } - function testTransferBalanceToNamespaceRevertInsufficientBalance() public { + function testTransferBalanceToNamespaceRevertWorld_InsufficientBalance() public { uint256 value = 1 ether; // Expect the root and non root namespaces to have no balance @@ -194,7 +194,7 @@ contract WorldBalanceTest is Test, GasReporter { assertEq(Balances.get(world, ResourceId.unwrap(ROOT_NAMESPACE_ID)), value); // Expect revert when attempting to transfer more than the balance - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.InsufficientBalance.selector, value, value + 1)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_InsufficientBalance.selector, value, value + 1)); world.transferBalanceToNamespace(ROOT_NAMESPACE_ID, namespaceId, value + 1); // Expect the root namespace to have the value as balance @@ -204,7 +204,7 @@ contract WorldBalanceTest is Test, GasReporter { assertEq(Balances.get(world, ResourceId.unwrap(namespaceId)), 0); } - function testTransferBalanceToNamespaceRevertAccessDenied() public { + function testTransferBalanceToNamespaceRevertWorld_AccessDenied() public { uint256 value = 1 ether; // Expect the root and non root namespaces to have no balance @@ -223,7 +223,9 @@ contract WorldBalanceTest is Test, GasReporter { // Expect revert when attempting to transfer from a namespace without access vm.prank(caller); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.AccessDenied.selector, ROOT_NAMESPACE_ID.toString(), caller)); + vm.expectRevert( + abi.encodeWithSelector(IWorldErrors.World_AccessDenied.selector, ROOT_NAMESPACE_ID.toString(), caller) + ); world.transferBalanceToNamespace(ROOT_NAMESPACE_ID, namespaceId, value); // Expect the root namespace to have the value as balance @@ -233,7 +235,7 @@ contract WorldBalanceTest is Test, GasReporter { assertEq(Balances.get(world, ResourceId.unwrap(namespaceId)), 0); } - function testTransferBalanceToNamespaceRevertInvalidResourceType() public { + function testTransferBalanceToNamespaceRevertWorld_InvalidResourceType() public { uint256 value = 1 ether; // Expect the root namespace to have no balance @@ -254,7 +256,7 @@ contract WorldBalanceTest is Test, GasReporter { vm.prank(caller); vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.InvalidResourceType.selector, + IWorldErrors.World_InvalidResourceType.selector, RESOURCE_NAMESPACE, invalidNamespace, invalidNamespace.toString() @@ -300,7 +302,7 @@ contract WorldBalanceTest is Test, GasReporter { assertEq(receiver.balance, value); } - function testTransferBalanceToAddressRevertInsufficientBalance() public { + function testTransferBalanceToAddressRevertWorld_InsufficientBalance() public { uint256 value = 1 ether; // Expect the root and non root namespaces to have no balance @@ -322,7 +324,7 @@ contract WorldBalanceTest is Test, GasReporter { assertEq(receiver.balance, 0); // Expect revert when attempting to transfer more than the balance - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.InsufficientBalance.selector, value, value + 1)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_InsufficientBalance.selector, value, value + 1)); world.transferBalanceToAddress(ROOT_NAMESPACE_ID, receiver, value + 1); // Expect the root namespace to have value as balance @@ -332,7 +334,7 @@ contract WorldBalanceTest is Test, GasReporter { assertEq(receiver.balance, 0); } - function testTransferBalanceToAddressRevertAccessDenied() public { + function testTransferBalanceToAddressRevertWorld_AccessDenied() public { uint256 value = 1 ether; // Expect the root and non root namespaces to have no balance @@ -357,7 +359,7 @@ contract WorldBalanceTest is Test, GasReporter { vm.prank(caller); vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.AccessDenied.selector, + IWorldErrors.World_AccessDenied.selector, WorldResourceIdLib.encodeNamespace(ROOT_NAMESPACE).toString(), caller ) diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index 75d28609e6..c506ab08c0 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -76,9 +76,9 @@ contract UpdateInFieldTest is Test, GasReporter { } // Expect an error when trying to write from an address that doesn't have access - function _expectAccessDenied(address _caller, ResourceId _tableId) internal { + function _expectWorld_AccessDenied(address _caller, ResourceId _tableId) internal { vm.prank(_caller); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.AccessDenied.selector, _tableId.toString(), _caller)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_AccessDenied.selector, _tableId.toString(), _caller)); } function testPopFromField() public { @@ -128,7 +128,7 @@ contract UpdateInFieldTest is Test, GasReporter { } // Expect an error when trying to write from an address that doesn't have access - _expectAccessDenied(address(0x01), tableId); + _expectWorld_AccessDenied(address(0x01), tableId); world.popFromField(tableId, keyTuple, 0, 20, fieldLayout); // Expect the World to have access @@ -166,7 +166,7 @@ contract UpdateInFieldTest is Test, GasReporter { assertEq(AddressArray.get(world, tableId, key), initData); // Expect an error when trying to write from an address that doesn't have access - _expectAccessDenied(address(0x01), tableId); + _expectWorld_AccessDenied(address(0x01), tableId); world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); // Expect the World to have access