From d08789282c8b8d4c12897e2ff5a688af9115fb1c Mon Sep 17 00:00:00 2001 From: alvarius Date: Fri, 22 Sep 2023 19:40:41 +0100 Subject: [PATCH] refactor(store,world): prefix errors with library/contract name (#1568) --- .changeset/large-drinks-sell.md | 6 ++ packages/store/src/IStoreErrors.sol | 23 +++--- packages/store/src/StoreCore.sol | 36 +++++----- packages/store/test/StoreCore.t.sol | 26 +++---- packages/world/src/AccessControl.sol | 8 +-- packages/world/src/SystemCall.sol | 2 +- packages/world/src/World.sol | 10 +-- packages/world/src/interfaces/IModule.sol | 4 +- .../world/src/interfaces/IWorldErrors.sol | 26 +++---- .../world/src/modules/core/CoreModule.sol | 2 +- .../implementations/BalanceTransferSystem.sol | 6 +- .../StoreRegistrationSystem.sol | 2 +- .../WorldRegistrationSystem.sol | 14 ++-- .../modules/keysintable/KeysInTableModule.sol | 2 +- .../keyswithvalue/KeysWithValueModule.sol | 2 +- .../StandardDelegationsModule.sol | 2 +- packages/world/src/requireInterface.sol | 4 +- packages/world/test/AccessControl.t.sol | 6 +- .../test/StandardDelegationsModule.t.sol | 6 +- packages/world/test/UniqueEntityModule.t.sol | 2 +- packages/world/test/World.t.sol | 71 ++++++++++++------- packages/world/test/WorldBalance.t.sol | 12 ++-- packages/world/test/WorldDynamicUpdate.t.sol | 8 ++- 23 files changed, 152 insertions(+), 128 deletions(-) create mode 100644 .changeset/large-drinks-sell.md diff --git a/.changeset/large-drinks-sell.md b/.changeset/large-drinks-sell.md new file mode 100644 index 0000000000..eaa9b5c5f2 --- /dev/null +++ b/.changeset/large-drinks-sell.md @@ -0,0 +1,6 @@ +--- +"@latticexyz/store": patch +"@latticexyz/world": patch +--- + +Prefixed all errors with their respective library/contract for improved debugging. diff --git a/packages/store/src/IStoreErrors.sol b/packages/store/src/IStoreErrors.sol index 239d064035..e75591d41f 100644 --- a/packages/store/src/IStoreErrors.sol +++ b/packages/store/src/IStoreErrors.sol @@ -5,17 +5,16 @@ import { ResourceId } from "./ResourceId.sol"; interface IStoreErrors { // Errors include a stringified version of the tableId for easier debugging if cleartext tableIds are used - error StoreCore_TableAlreadyExists(ResourceId tableId, string tableIdString); - error StoreCore_TableNotFound(ResourceId tableId, string tableIdString); - error StoreCore_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString); + error Store_TableAlreadyExists(ResourceId tableId, string tableIdString); + error Store_TableNotFound(ResourceId tableId, string tableIdString); + error Store_InvalidResourceType(bytes2 expected, ResourceId resourceId, string resourceIdString); - error StoreCore_NotImplemented(); - error StoreCore_NotDynamicField(); - error StoreCore_InvalidStaticDataLength(uint256 expected, uint256 received); - error StoreCore_InvalidDynamicDataLength(uint256 expected, uint256 received); - error StoreCore_InvalidKeyNamesLength(uint256 expected, uint256 received); - error StoreCore_InvalidFieldNamesLength(uint256 expected, uint256 received); - error StoreCore_InvalidValueSchemaLength(uint256 expected, uint256 received); - error StoreCore_DataIndexOverflow(uint256 length, uint256 received); - error StoreCore_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength); + error Store_NotDynamicField(); + error Store_InvalidStaticDataLength(uint256 expected, uint256 received); + error Store_InvalidDynamicDataLength(uint256 expected, uint256 received); + error Store_InvalidKeyNamesLength(uint256 expected, uint256 received); + error Store_InvalidFieldNamesLength(uint256 expected, uint256 received); + error Store_InvalidValueSchemaLength(uint256 expected, uint256 received); + error Store_DataIndexOverflow(uint256 length, uint256 received); + error Store_InvalidSplice(uint40 startWithinField, uint40 deleteCount, uint40 fieldLength); } diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 4db4bb6d1a..c87059a9aa 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -88,7 +88,7 @@ library StoreCore { function getFieldLayout(ResourceId tableId) internal view returns (FieldLayout fieldLayout) { fieldLayout = FieldLayout.wrap(Tables._getFieldLayout(ResourceId.unwrap(tableId))); if (fieldLayout.isEmpty()) { - revert IStoreErrors.StoreCore_TableNotFound(tableId, string(abi.encodePacked(tableId))); + revert IStoreErrors.Store_TableNotFound(tableId, string(abi.encodePacked(tableId))); } } @@ -99,7 +99,7 @@ library StoreCore { keySchema = Schema.wrap(Tables._getKeySchema(ResourceId.unwrap(tableId))); // key schemas can be empty for singleton tables, so we can't depend on key schema for table check if (!ResourceIds._getExists(ResourceId.unwrap(tableId))) { - revert IStoreErrors.StoreCore_TableNotFound(tableId, string(abi.encodePacked(tableId))); + revert IStoreErrors.Store_TableNotFound(tableId, string(abi.encodePacked(tableId))); } } @@ -109,7 +109,7 @@ library StoreCore { function getValueSchema(ResourceId tableId) internal view returns (Schema valueSchema) { valueSchema = Schema.wrap(Tables._getValueSchema(ResourceId.unwrap(tableId))); if (valueSchema.isEmpty()) { - revert IStoreErrors.StoreCore_TableNotFound(tableId, string(abi.encodePacked(tableId))); + revert IStoreErrors.Store_TableNotFound(tableId, string(abi.encodePacked(tableId))); } } @@ -126,7 +126,7 @@ library StoreCore { ) internal { // Verify the table ID is of type RESOURCE_TABLE if (tableId.getType() != RESOURCE_TABLE && tableId.getType() != RESOURCE_OFFCHAIN_TABLE) { - revert IStoreErrors.StoreCore_InvalidResourceType(RESOURCE_TABLE, tableId, string(abi.encodePacked(tableId))); + revert IStoreErrors.Store_InvalidResourceType(RESOURCE_TABLE, tableId, string(abi.encodePacked(tableId))); } // Verify the field layout is valid @@ -138,22 +138,22 @@ library StoreCore { // Verify the number of key names matches the number of key schema types if (keyNames.length != keySchema.numFields()) { - revert IStoreErrors.StoreCore_InvalidKeyNamesLength(keySchema.numFields(), keyNames.length); + revert IStoreErrors.Store_InvalidKeyNamesLength(keySchema.numFields(), keyNames.length); } // Verify the number of value names if (fieldNames.length != fieldLayout.numFields()) { - revert IStoreErrors.StoreCore_InvalidFieldNamesLength(fieldLayout.numFields(), fieldNames.length); + revert IStoreErrors.Store_InvalidFieldNamesLength(fieldLayout.numFields(), fieldNames.length); } // Verify the number of value schema types if (valueSchema.numFields() != fieldLayout.numFields()) { - revert IStoreErrors.StoreCore_InvalidValueSchemaLength(fieldLayout.numFields(), valueSchema.numFields()); + revert IStoreErrors.Store_InvalidValueSchemaLength(fieldLayout.numFields(), valueSchema.numFields()); } // Verify there is no resource with this ID yet if (ResourceIds._getExists(ResourceId.unwrap(tableId))) { - revert IStoreErrors.StoreCore_TableAlreadyExists(tableId, string(abi.encodePacked(tableId))); + revert IStoreErrors.Store_TableAlreadyExists(tableId, string(abi.encodePacked(tableId))); } // Register the table metadata @@ -182,7 +182,7 @@ library StoreCore { function registerStoreHook(ResourceId tableId, IStoreHook hookAddress, uint8 enabledHooksBitmap) internal { // Hooks are only supported for tables, not for offchain tables if (tableId.getType() != RESOURCE_TABLE) { - revert IStoreErrors.StoreCore_InvalidResourceType(RESOURCE_TABLE, tableId, string(abi.encodePacked(tableId))); + revert IStoreErrors.Store_InvalidResourceType(RESOURCE_TABLE, tableId, string(abi.encodePacked(tableId))); } StoreHooks.push(ResourceId.unwrap(tableId), Hook.unwrap(HookLib.encode(address(hookAddress), enabledHooksBitmap))); @@ -476,7 +476,7 @@ library StoreCore { FieldLayout fieldLayout ) internal { if (fieldIndex < fieldLayout.numStaticFields()) { - revert IStoreErrors.StoreCore_NotDynamicField(); + revert IStoreErrors.Store_NotDynamicField(); } StoreCoreInternal._pushToDynamicField(tableId, keyTuple, fieldLayout, fieldIndex, dataToPush); @@ -493,7 +493,7 @@ library StoreCore { FieldLayout fieldLayout ) internal { if (fieldIndex < fieldLayout.numStaticFields()) { - revert IStoreErrors.StoreCore_NotDynamicField(); + revert IStoreErrors.Store_NotDynamicField(); } StoreCoreInternal._popFromDynamicField(tableId, keyTuple, fieldLayout, fieldIndex, byteLengthToPop); @@ -511,13 +511,13 @@ library StoreCore { FieldLayout fieldLayout ) internal { if (fieldIndex < fieldLayout.numStaticFields()) { - revert IStoreErrors.StoreCore_NotDynamicField(); + revert IStoreErrors.Store_NotDynamicField(); } // index must be checked because it could be arbitrarily large // (but dataToSet.length can be unchecked - it won't overflow into another slot due to gas costs and hashed slots) if (startByteIndex > type(uint40).max) { - revert IStoreErrors.StoreCore_DataIndexOverflow(type(uint40).max, startByteIndex); + revert IStoreErrors.Store_DataIndexOverflow(type(uint40).max, startByteIndex); } StoreCoreInternal._setDynamicFieldItem(tableId, keyTuple, fieldLayout, fieldIndex, startByteIndex, dataToSet); @@ -651,7 +651,7 @@ library StoreCore { ) internal view returns (bytes memory) { uint8 numStaticFields = uint8(fieldLayout.numStaticFields()); if (fieldIndex < fieldLayout.numStaticFields()) { - revert IStoreErrors.StoreCore_NotDynamicField(); + revert IStoreErrors.Store_NotDynamicField(); } // Get the length and storage location of the dynamic field @@ -687,7 +687,7 @@ library StoreCoreInternal { // Splicing dynamic data is not supported for offchain tables, because it // requires reading the previous encoded lengths from storage if (tableId.getType() != RESOURCE_TABLE) { - revert IStoreErrors.StoreCore_InvalidResourceType(RESOURCE_TABLE, tableId, string(abi.encodePacked(tableId))); + revert IStoreErrors.Store_InvalidResourceType(RESOURCE_TABLE, tableId, string(abi.encodePacked(tableId))); } uint256 previousFieldLength = previousEncodedLengths.atIndex(dynamicFieldIndex); @@ -696,7 +696,7 @@ library StoreCoreInternal { // If the total length of the field is changed, the data has to be appended/removed at the end of the field. // Otherwise offchain indexers would shift the data after inserted data, while onchain the data is truncated at the end. if (previousFieldLength != updatedFieldLength && startWithinField + deleteCount != previousFieldLength) { - revert IStoreErrors.StoreCore_InvalidSplice(startWithinField, deleteCount, uint40(previousFieldLength)); + revert IStoreErrors.Store_InvalidSplice(startWithinField, deleteCount, uint40(previousFieldLength)); } // Compute start index for the splice @@ -894,10 +894,10 @@ library StoreCoreInternal { bytes memory dynamicData ) internal pure { if (fieldLayout.staticDataLength() != staticData.length) { - revert IStoreErrors.StoreCore_InvalidStaticDataLength(fieldLayout.staticDataLength(), staticData.length); + revert IStoreErrors.Store_InvalidStaticDataLength(fieldLayout.staticDataLength(), staticData.length); } if (encodedLengths.total() != dynamicData.length) { - revert IStoreErrors.StoreCore_InvalidDynamicDataLength(encodedLengths.total(), dynamicData.length); + revert IStoreErrors.Store_InvalidDynamicDataLength(encodedLengths.total(), dynamicData.length); } } diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index f72f690876..f429d92739 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -105,7 +105,7 @@ contract StoreCoreTest is Test, StoreMock { // Expect a revert when registering a table that already exists vm.expectRevert( abi.encodeWithSelector( - IStoreErrors.StoreCore_TableAlreadyExists.selector, + IStoreErrors.Store_TableAlreadyExists.selector, ResourceId.unwrap(tableId), string(bytes.concat(ResourceId.unwrap(tableId))) ) @@ -142,7 +142,7 @@ contract StoreCoreTest is Test, StoreMock { vm.expectRevert( abi.encodeWithSelector( - IStoreErrors.StoreCore_InvalidResourceType.selector, + IStoreErrors.Store_InvalidResourceType.selector, RESOURCE_TABLE, invalidTableId, string(abi.encodePacked(invalidTableId)) @@ -182,7 +182,7 @@ contract StoreCoreTest is Test, StoreMock { vm.expectRevert( abi.encodeWithSelector( - IStoreErrors.StoreCore_TableNotFound.selector, + IStoreErrors.Store_TableNotFound.selector, tableId2, string(abi.encodePacked(ResourceId.unwrap(tableId2))) ) @@ -190,20 +190,12 @@ contract StoreCoreTest is Test, StoreMock { IStore(this).getFieldLayout(tableId2); vm.expectRevert( - abi.encodeWithSelector( - IStoreErrors.StoreCore_TableNotFound.selector, - tableId2, - string(abi.encodePacked(tableId2)) - ) + abi.encodeWithSelector(IStoreErrors.Store_TableNotFound.selector, tableId2, string(abi.encodePacked(tableId2))) ); IStore(this).getValueSchema(tableId2); vm.expectRevert( - abi.encodeWithSelector( - IStoreErrors.StoreCore_TableNotFound.selector, - tableId2, - string(abi.encodePacked(tableId2)) - ) + abi.encodeWithSelector(IStoreErrors.Store_TableNotFound.selector, tableId2, string(abi.encodePacked(tableId2))) ); IStore(this).getKeySchema(tableId2); } @@ -223,11 +215,11 @@ contract StoreCoreTest is Test, StoreMock { string[] memory oneName = new string[](1); // Register table with invalid key names - vm.expectRevert(abi.encodeWithSelector(IStoreErrors.StoreCore_InvalidKeyNamesLength.selector, 4, 1)); + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_InvalidKeyNamesLength.selector, 4, 1)); IStore(this).registerTable(tableId, fieldLayout, keySchema, valueSchema, oneName, oneName); // Register table with invalid value names - vm.expectRevert(abi.encodeWithSelector(IStoreErrors.StoreCore_InvalidFieldNamesLength.selector, 1, 4)); + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_InvalidFieldNamesLength.selector, 1, 4)); IStore(this).registerTable(tableId, fieldLayout, keySchema, valueSchema, fourNames, fourNames); } @@ -333,7 +325,7 @@ contract StoreCoreTest is Test, StoreMock { keyTuple[0] = "some key"; // This should fail because the data is not 6 bytes long - vm.expectRevert(abi.encodeWithSelector(IStoreErrors.StoreCore_InvalidStaticDataLength.selector, 6, 4)); + vm.expectRevert(abi.encodeWithSelector(IStoreErrors.Store_InvalidStaticDataLength.selector, 6, 4)); IStore(this).setRecord(tableId, keyTuple, staticData, PackedCounter.wrap(bytes32(0)), new bytes(0), fieldLayout); } @@ -1051,7 +1043,7 @@ contract StoreCoreTest is Test, StoreMock { // startByteIndex must not overflow vm.expectRevert( - abi.encodeWithSelector(IStoreErrors.StoreCore_DataIndexOverflow.selector, type(uint40).max, type(uint56).max) + abi.encodeWithSelector(IStoreErrors.Store_DataIndexOverflow.selector, type(uint40).max, type(uint56).max) ); IStore(this).updateInField(data.tableId, data.keyTuple, 2, type(uint56).max, data.thirdDataForUpdate, fieldLayout); } diff --git a/packages/world/src/AccessControl.sol b/packages/world/src/AccessControl.sol index cb8284f321..2b57c5f581 100644 --- a/packages/world/src/AccessControl.sol +++ b/packages/world/src/AccessControl.sol @@ -21,22 +21,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 9627fea7cf..91e35b256b 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -54,7 +54,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { */ modifier requireNoCallback() { if (msg.sender == address(this)) { - revert WorldCallbackNotAllowed(msg.sig); + revert World_CallbackNotAllowed(msg.sig); } _; } @@ -65,12 +65,12 @@ contract World is StoreRead, IStoreData, IWorldKernel { function initialize(IModule coreModule) public requireNoCallback { // 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 @@ -291,7 +291,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); } /************************************************************************ @@ -314,7 +314,7 @@ contract World is StoreRead, IStoreData, IWorldKernel { fallback() external payable requireNoCallback { (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/IModule.sol b/packages/world/src/interfaces/IModule.sol index e94fcbfdfa..e5c474634a 100644 --- a/packages/world/src/interfaces/IModule.sol +++ b/packages/world/src/interfaces/IModule.sol @@ -10,8 +10,8 @@ bytes4 constant MODULE_INTERFACE_ID = IModule.getName.selector ^ ERC165_INTERFACE_ID; interface IModule is IERC165 { - error RootInstallModeNotSupported(); - error NonRootInstallNotSupported(); + error Module_RootInstallNotSupported(); + error Module_NonRootInstallNotSupported(); /** * Return the module name as a bytes16. diff --git a/packages/world/src/interfaces/IWorldErrors.sol b/packages/world/src/interfaces/IWorldErrors.sol index 2df3bfcb46..5cff530663 100644 --- a/packages/world/src/interfaces/IWorldErrors.sol +++ b/packages/world/src/interfaces/IWorldErrors.sol @@ -4,17 +4,17 @@ 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 WorldCallbackNotAllowed(bytes4 functionSelector); + 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); + error World_CallbackNotAllowed(bytes4 functionSelector); } diff --git a/packages/world/src/modules/core/CoreModule.sol b/packages/world/src/modules/core/CoreModule.sol index 91c3bb4edf..0a63273cf7 100644 --- a/packages/world/src/modules/core/CoreModule.sol +++ b/packages/world/src/modules/core/CoreModule.sol @@ -56,7 +56,7 @@ contract CoreModule is Module { } function install(bytes memory) public pure { - revert NonRootInstallNotSupported(); + revert Module_NonRootInstallNotSupported(); } /** 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 9b91816493..65c20fc66d 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/modules/keysintable/KeysInTableModule.sol b/packages/world/src/modules/keysintable/KeysInTableModule.sol index dd10f5c8ea..5a702c0b18 100644 --- a/packages/world/src/modules/keysintable/KeysInTableModule.sol +++ b/packages/world/src/modules/keysintable/KeysInTableModule.sol @@ -104,6 +104,6 @@ contract KeysInTableModule is Module { } function install(bytes memory) public pure { - revert NonRootInstallNotSupported(); + revert Module_NonRootInstallNotSupported(); } } diff --git a/packages/world/src/modules/keyswithvalue/KeysWithValueModule.sol b/packages/world/src/modules/keyswithvalue/KeysWithValueModule.sol index ea0eb947e4..35a14aa3ba 100644 --- a/packages/world/src/modules/keyswithvalue/KeysWithValueModule.sol +++ b/packages/world/src/modules/keyswithvalue/KeysWithValueModule.sol @@ -86,6 +86,6 @@ contract KeysWithValueModule is Module { } function install(bytes memory) public pure { - revert NonRootInstallNotSupported(); + revert Module_NonRootInstallNotSupported(); } } diff --git a/packages/world/src/modules/std-delegations/StandardDelegationsModule.sol b/packages/world/src/modules/std-delegations/StandardDelegationsModule.sol index e4834d3309..3e2edbd09a 100644 --- a/packages/world/src/modules/std-delegations/StandardDelegationsModule.sol +++ b/packages/world/src/modules/std-delegations/StandardDelegationsModule.sol @@ -45,6 +45,6 @@ contract StandardDelegationsModule is Module { } function install(bytes memory) public pure { - revert NonRootInstallNotSupported(); + revert Module_NonRootInstallNotSupported(); } } 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 f571dc85d3..11b52a3c50 100644 --- a/packages/world/test/AccessControl.t.sol +++ b/packages/world/test/AccessControl.t.sol @@ -89,7 +89,9 @@ contract AccessControlTest is Test, GasReporter, StoreMock { endGasReport(); vm.prank(caller); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.AccessDenied.selector, tableId.toString(), address(this))); + vm.expectRevert( + abi.encodeWithSelector(IWorldErrors.World_AccessDenied.selector, tableId.toString(), address(this)) + ); startGasReport("AccessControl: requireAccess (this address)"); AccessControl.requireAccess(tableId, address(this)); endGasReport(); @@ -98,7 +100,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..42e49f5372 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,7 +104,7 @@ 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, ())); } @@ -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 451d3861dd..eb15f8ef04 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -188,7 +188,7 @@ contract WorldTest is Test, GasReporter { vm.prank(caller); vm.expectRevert( abi.encodeWithSelector( - IWorldErrors.AccessDenied.selector, + IWorldErrors.World_AccessDenied.selector, WorldResourceIdLib.encode({ typeId: resourceType, namespace: namespace, name: name }).toString(), caller ) @@ -209,7 +209,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) ) @@ -248,7 +248,7 @@ 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); } @@ -256,7 +256,7 @@ contract WorldTest is Test, GasReporter { // 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 ) @@ -266,7 +266,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 ) @@ -323,7 +323,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); } @@ -337,7 +339,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() @@ -435,7 +437,7 @@ contract WorldTest is Test, GasReporter { // Expect an error when registering an existing table vm.expectRevert( abi.encodeWithSelector( - IStoreErrors.StoreCore_TableAlreadyExists.selector, + IStoreErrors.Store_TableAlreadyExists.selector, tableId, string(bytes.concat(ResourceId.unwrap(tableId))) ) @@ -454,7 +456,7 @@ contract WorldTest is Test, GasReporter { // Expect the World to not be allowed to call registerTable via an external call vm.prank(address(world)); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.registerTable.selector) + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.registerTable.selector) ); world.registerTable(otherTableId, fieldLayout, defaultKeySchema, valueSchema, keyNames, fieldNames); } @@ -510,7 +512,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, @@ -532,7 +534,12 @@ 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); @@ -548,7 +555,7 @@ contract WorldTest is Test, GasReporter { // Expect the registration to fail when coming from the World vm.prank(address(world)); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.registerSystem.selector) + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.registerSystem.selector) ); world.registerSystem( WorldResourceIdLib.encode({ typeId: RESOURCE_SYSTEM, namespace: "", name: "rootSystem" }), @@ -559,7 +566,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 ) @@ -635,7 +642,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); @@ -646,7 +658,7 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to register a table at the same ID vm.expectRevert( abi.encodeWithSelector( - IStoreErrors.StoreCore_InvalidResourceType.selector, + IStoreErrors.Store_InvalidResourceType.selector, RESOURCE_TABLE, systemId, string(abi.encodePacked(systemId)) @@ -664,7 +676,7 @@ contract WorldTest is Test, GasReporter { // Expect an error when trying to register a new table at an existing table ID vm.expectRevert( abi.encodeWithSelector( - IStoreErrors.StoreCore_TableAlreadyExists.selector, + IStoreErrors.Store_TableAlreadyExists.selector, ResourceId.unwrap(tableId), string(bytes.concat(ResourceId.unwrap(tableId))) ) @@ -718,7 +730,7 @@ contract WorldTest is Test, GasReporter { // Expect the World to not have access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.setRecord.selector)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.setRecord.selector)); TwoFields.set(world, tableId, true, true); } @@ -745,7 +757,7 @@ contract WorldTest is Test, GasReporter { // Expect the World to not have access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.setField.selector)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.setField.selector)); world.setField(tableId, singletonKey, 0, abi.encodePacked(true), fieldLayout); } @@ -788,7 +800,7 @@ contract WorldTest is Test, GasReporter { // Expect the World to not have access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.pushToField.selector)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.pushToField.selector)); world.pushToField(tableId, keyTuple, 0, encodedData, fieldLayout); } @@ -838,7 +850,9 @@ contract WorldTest is Test, GasReporter { // Expect the World to not have access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.deleteRecord.selector)); + vm.expectRevert( + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.deleteRecord.selector) + ); world.deleteRecord(tableId, singletonKey, fieldLayout); } @@ -879,7 +893,7 @@ contract WorldTest is Test, GasReporter { // Expect the World to have not access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.call.selector)); + vm.expectRevert(abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.call.selector)); world.call(systemId, abi.encodeCall(WorldTestSystem.msgSender, ())); // Expect errors from the system to be forwarded @@ -983,7 +997,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 ) @@ -1073,7 +1087,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, @@ -1176,7 +1190,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, @@ -1384,7 +1402,10 @@ contract WorldTest is Test, GasReporter { // Expect the World to not be able to register a root function selector when calling the function externally vm.prank(address(world)); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.registerRootFunctionSelector.selector) + abi.encodeWithSelector( + IWorldErrors.World_CallbackNotAllowed.selector, + world.registerRootFunctionSelector.selector + ) ); world.registerRootFunctionSelector(systemId, "smth", "smth"); diff --git a/packages/world/test/WorldBalance.t.sol b/packages/world/test/WorldBalance.t.sol index 3a6e889925..7da180a53e 100644 --- a/packages/world/test/WorldBalance.t.sol +++ b/packages/world/test/WorldBalance.t.sol @@ -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 @@ -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 @@ -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() @@ -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 @@ -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 ab3bc46e04..3d054da1e7 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -78,7 +78,7 @@ 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 { 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 { @@ -133,7 +133,9 @@ contract UpdateInFieldTest is Test, GasReporter { // Expect the World to not have access vm.prank(address(world)); - vm.expectRevert(abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.popFromField.selector)); + vm.expectRevert( + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.popFromField.selector) + ); world.popFromField(tableId, keyTuple, 0, 20, fieldLayout); } @@ -173,7 +175,7 @@ contract UpdateInFieldTest is Test, GasReporter { // Expect the World to not have access vm.prank(address(world)); vm.expectRevert( - abi.encodeWithSelector(IWorldErrors.WorldCallbackNotAllowed.selector, world.updateInField.selector) + abi.encodeWithSelector(IWorldErrors.World_CallbackNotAllowed.selector, world.updateInField.selector) ); world.updateInField(tableId, keyTuple, 0, 0, EncodeArray.encode(dataForUpdate), fieldLayout); }