diff --git a/.changeset/curly-countries-obey.md b/.changeset/curly-countries-obey.md new file mode 100644 index 0000000000..1e2dbae332 --- /dev/null +++ b/.changeset/curly-countries-obey.md @@ -0,0 +1,15 @@ +--- +"@latticexyz/cli": patch +"@latticexyz/world-modules": patch +"@latticexyz/world": major +--- + +Tables and interfaces in the `world` package are now generated to the `codegen` folder. +This is only a breaking change if you imported tables or codegenerated interfaces from `@latticexyz/world` directly. +If you're using the MUD CLI, the changed import paths are already integrated and no further changes are necessary. + +```diff +- import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; ++ import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; + +``` diff --git a/e2e/packages/contracts/src/codegen/world/IWorld.sol b/e2e/packages/contracts/src/codegen/world/IWorld.sol index 707adb849c..4b25e6b927 100644 --- a/e2e/packages/contracts/src/codegen/world/IWorld.sol +++ b/e2e/packages/contracts/src/codegen/world/IWorld.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { ICustomErrorsSystem } from "./ICustomErrorsSystem.sol"; import { INumberListSystem } from "./INumberListSystem.sol"; diff --git a/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol b/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol index dc78180f49..86647aaaec 100644 --- a/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol +++ b/examples/minimal/packages/contracts/src/codegen/world/IWorld.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IChatSystem } from "./IChatSystem.sol"; import { IIncrementSystem } from "./IIncrementSystem.sol"; diff --git a/packages/world-modules/mud.config.ts b/packages/world-modules/mud.config.ts index 4e273a4b90..5dd8ba75e8 100644 --- a/packages/world-modules/mud.config.ts +++ b/packages/world-modules/mud.config.ts @@ -73,5 +73,5 @@ export default mudConfig({ }, }, }, - excludeSystems: [], + excludeSystems: ["UniqueEntitySystem"], }); diff --git a/packages/world-modules/src/interfaces/IBaseWorld.sol b/packages/world-modules/src/interfaces/IBaseWorld.sol index c1f0001aeb..b0f32edd50 100644 --- a/packages/world-modules/src/interfaces/IBaseWorld.sol +++ b/packages/world-modules/src/interfaces/IBaseWorld.sol @@ -6,12 +6,10 @@ pragma solidity >=0.8.21; import { IStore } from "@latticexyz/store/src/IStore.sol"; import { IWorldKernel } from "@latticexyz/world/src/interfaces/IWorldKernel.sol"; -import { IUniqueEntitySystem } from "./IUniqueEntitySystem.sol"; - /** * The IBaseWorld interface includes all systems dynamically added to the World * during the deploy process. */ -interface IBaseWorld is IStore, IWorldKernel, IUniqueEntitySystem { +interface IBaseWorld is IStore, IWorldKernel { } diff --git a/packages/world-modules/src/interfaces/IUniqueEntitySystem.sol b/packages/world-modules/src/interfaces/IUniqueEntitySystem.sol index f0d650be73..d9011e2201 100644 --- a/packages/world-modules/src/interfaces/IUniqueEntitySystem.sol +++ b/packages/world-modules/src/interfaces/IUniqueEntitySystem.sol @@ -1,8 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.21; -/* Autogenerated file. Do not edit manually. */ - +// TODO allow overriding namespace per-system (or a separate config for modules?) interface IUniqueEntitySystem { - function getUniqueEntity() external returns (bytes32); + function uniqueEntity_system_getUniqueEntity() external returns (bytes32 uniqueEntity); } diff --git a/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol b/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol index 5031ae745c..f5ec9cc0df 100644 --- a/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol +++ b/packages/world-modules/src/modules/keysintable/KeysInTableModule.sol @@ -6,7 +6,7 @@ import { ResourceIds } from "@latticexyz/store/src/codegen/tables/ResourceIds.so import { Module } from "@latticexyz/world/src/Module.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { ResourceId, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol"; import { revertWithBytes } from "@latticexyz/world/src/revertWithBytes.sol"; diff --git a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueHook.sol b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueHook.sol index 1655b2255d..d3d7a8d2c3 100644 --- a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueHook.sol +++ b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueHook.sol @@ -7,7 +7,7 @@ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { PackedCounter } from "@latticexyz/store/src/PackedCounter.sol"; import { Tables } from "@latticexyz/store/src/codegen/tables/Tables.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { ResourceId, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol"; diff --git a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol index f9aed943c7..df655d8d18 100644 --- a/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol +++ b/packages/world-modules/src/modules/keyswithvalue/KeysWithValueModule.sol @@ -4,7 +4,7 @@ import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { BEFORE_SET_RECORD, BEFORE_SPLICE_STATIC_DATA, AFTER_SPLICE_STATIC_DATA, BEFORE_SPLICE_DYNAMIC_DATA, AFTER_SPLICE_DYNAMIC_DATA, BEFORE_DELETE_RECORD } from "@latticexyz/store/src/storeHookTypes.sol"; import { Module } from "@latticexyz/world/src/Module.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol"; import { ResourceId, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol"; diff --git a/packages/world-modules/src/modules/std-delegations/StandardDelegationsModule.sol b/packages/world-modules/src/modules/std-delegations/StandardDelegationsModule.sol index 5b754d1dc5..fe5ead7929 100644 --- a/packages/world-modules/src/modules/std-delegations/StandardDelegationsModule.sol +++ b/packages/world-modules/src/modules/std-delegations/StandardDelegationsModule.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.21; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { Module } from "@latticexyz/world/src/Module.sol"; import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol"; diff --git a/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol b/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol index f1d4af8fdc..f3b6a6d39c 100644 --- a/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol +++ b/packages/world-modules/src/modules/uniqueentity/UniqueEntityModule.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.21; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { Module } from "@latticexyz/world/src/Module.sol"; import { WorldContextConsumer } from "@latticexyz/world/src/WorldContext.sol"; diff --git a/packages/world-modules/src/modules/uniqueentity/getUniqueEntity.sol b/packages/world-modules/src/modules/uniqueentity/getUniqueEntity.sol index 5486cc5043..6d3dfa25c4 100644 --- a/packages/world-modules/src/modules/uniqueentity/getUniqueEntity.sol +++ b/packages/world-modules/src/modules/uniqueentity/getUniqueEntity.sol @@ -2,9 +2,9 @@ pragma solidity >=0.8.21; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; -import { IUniqueEntitySystem } from "@latticexyz/world/src/interfaces/IUniqueEntitySystem.sol"; +import { IUniqueEntitySystem } from "../../interfaces/IUniqueEntitySystem.sol"; /** * Increment and get an entity nonce. diff --git a/packages/world-modules/test/KeysInTableModule.t.sol b/packages/world-modules/test/KeysInTableModule.t.sol index 80b79f3968..7ba837e435 100644 --- a/packages/world-modules/test/KeysInTableModule.t.sol +++ b/packages/world-modules/test/KeysInTableModule.t.sol @@ -12,7 +12,7 @@ import { SchemaEncodeHelper } from "@latticexyz/store/test/SchemaEncodeHelper.so import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { World } from "@latticexyz/world/src/World.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol"; import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol"; import { RESOURCE_TABLE } from "@latticexyz/world/src/worldResourceTypes.sol"; diff --git a/packages/world-modules/test/KeysWithValueModule.t.sol b/packages/world-modules/test/KeysWithValueModule.t.sol index 0e4ef27a30..b881def01a 100644 --- a/packages/world-modules/test/KeysWithValueModule.t.sol +++ b/packages/world-modules/test/KeysWithValueModule.t.sol @@ -14,7 +14,7 @@ import { FieldLayout } from "@latticexyz/store/src/FieldLayout.sol"; import { FieldLayoutEncodeHelper } from "@latticexyz/store/test/FieldLayoutEncodeHelper.sol"; import { World } from "@latticexyz/world/src/World.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { WorldResourceIdLib, WorldResourceIdInstance, NAME_BITS, TYPE_BITS } from "@latticexyz/world/src/WorldResourceId.sol"; import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol"; import { RESOURCE_TABLE } from "@latticexyz/world/src/worldResourceTypes.sol"; diff --git a/packages/world-modules/test/StandardDelegationsModule.t.sol b/packages/world-modules/test/StandardDelegationsModule.t.sol index b95d5d7225..df5932592e 100644 --- a/packages/world-modules/test/StandardDelegationsModule.t.sol +++ b/packages/world-modules/test/StandardDelegationsModule.t.sol @@ -9,12 +9,12 @@ import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@lattic import { System } from "@latticexyz/world/src/System.sol"; import { RESOURCE_SYSTEM } from "@latticexyz/world/src/worldResourceTypes.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IWorldErrors } from "@latticexyz/world/src/interfaces/IWorldErrors.sol"; import { DELEGATION_CONTROL_INTERFACE_ID } from "@latticexyz/world/src/interfaces/IDelegationControl.sol"; import { CoreModule } from "@latticexyz/world/src/modules/core/CoreModule.sol"; -import { Systems } from "@latticexyz/world/src/modules/core/tables/Systems.sol"; +import { Systems } from "@latticexyz/world/src/codegen/tables/Systems.sol"; import { StandardDelegationsModule } from "../src/modules/std-delegations/StandardDelegationsModule.sol"; import { CallboundDelegationControl } from "../src/modules/std-delegations/CallboundDelegationControl.sol"; diff --git a/packages/world-modules/test/UniqueEntityModule.t.sol b/packages/world-modules/test/UniqueEntityModule.t.sol index 0b1f549ad1..cbbe46f591 100644 --- a/packages/world-modules/test/UniqueEntityModule.t.sol +++ b/packages/world-modules/test/UniqueEntityModule.t.sol @@ -5,7 +5,7 @@ import { Test } from "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { World } from "@latticexyz/world/src/World.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IWorldErrors } from "@latticexyz/world/src/interfaces/IWorldErrors.sol"; import { CoreModule } from "@latticexyz/world/src/modules/core/CoreModule.sol"; diff --git a/packages/world-modules/test/query.t.sol b/packages/world-modules/test/query.t.sol index c52f3488cc..f5b62e14f1 100644 --- a/packages/world-modules/test/query.t.sol +++ b/packages/world-modules/test/query.t.sol @@ -12,7 +12,7 @@ import { PackedCounter } from "@latticexyz/store/src/PackedCounter.sol"; import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; import { World } from "@latticexyz/world/src/World.sol"; -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "@latticexyz/world/src/WorldResourceId.sol"; import { ROOT_NAMESPACE } from "@latticexyz/world/src/constants.sol"; import { RESOURCE_TABLE } from "@latticexyz/world/src/worldResourceTypes.sol"; diff --git a/packages/world/mud.config.ts b/packages/world/mud.config.ts index fdb06c586e..7150cc36ea 100644 --- a/packages/world/mud.config.ts +++ b/packages/world/mud.config.ts @@ -1,10 +1,9 @@ import { mudConfig } from "./ts/register"; export default mudConfig({ - worldImportPath: "../", + worldImportPath: "../../", worldgenDirectory: "interfaces", worldInterfaceName: "IBaseWorld", - codegenDirectory: "", userTypes: { ResourceId: { filePath: "@latticexyz/store/src/ResourceId.sol", internalType: "bytes32" }, }, @@ -63,7 +62,6 @@ export default mudConfig({ * ************************************************************************/ Balances: { - directory: "modules/core/tables", keySchema: { namespaceId: "ResourceId", }, @@ -72,7 +70,6 @@ export default mudConfig({ }, }, Systems: { - directory: "modules/core/tables", keySchema: { systemId: "ResourceId", }, @@ -83,7 +80,6 @@ export default mudConfig({ dataStruct: false, }, SystemRegistry: { - directory: "modules/core/tables", keySchema: { system: "address", }, @@ -92,14 +88,12 @@ export default mudConfig({ }, }, SystemHooks: { - directory: "modules/core/tables", keySchema: { systemId: "ResourceId", }, valueSchema: "bytes21[]", }, FunctionSelectors: { - directory: "modules/core/tables", keySchema: { functionSelector: "bytes4", }, @@ -110,7 +104,6 @@ export default mudConfig({ dataStruct: false, }, FunctionSignatures: { - directory: "modules/core/tables", keySchema: { functionSelector: "bytes4", }, diff --git a/packages/world/src/AccessControl.sol b/packages/world/src/AccessControl.sol index e1fe7879cc..1ff2826aab 100644 --- a/packages/world/src/AccessControl.sol +++ b/packages/world/src/AccessControl.sol @@ -4,8 +4,8 @@ pragma solidity >=0.8.21; import { ResourceId, WorldResourceIdInstance } from "./WorldResourceId.sol"; import { IWorldErrors } from "./interfaces/IWorldErrors.sol"; -import { ResourceAccess } from "./tables/ResourceAccess.sol"; -import { NamespaceOwner } from "./tables/NamespaceOwner.sol"; +import { ResourceAccess } from "./codegen/tables/ResourceAccess.sol"; +import { NamespaceOwner } from "./codegen/tables/NamespaceOwner.sol"; library AccessControl { using WorldResourceIdInstance for ResourceId; diff --git a/packages/world/src/SystemCall.sol b/packages/world/src/SystemCall.sol index 10c68e76af..e920d5c5f4 100644 --- a/packages/world/src/SystemCall.sol +++ b/packages/world/src/SystemCall.sol @@ -14,10 +14,10 @@ import { BEFORE_CALL_SYSTEM, AFTER_CALL_SYSTEM } from "./systemHookTypes.sol"; import { IWorldErrors } from "./interfaces/IWorldErrors.sol"; import { ISystemHook } from "./interfaces/ISystemHook.sol"; -import { FunctionSelectors } from "./modules/core/tables/FunctionSelectors.sol"; -import { Systems } from "./modules/core/tables/Systems.sol"; -import { SystemHooks } from "./modules/core/tables/SystemHooks.sol"; -import { Balances } from "./modules/core/tables/Balances.sol"; +import { FunctionSelectors } from "./codegen/tables/FunctionSelectors.sol"; +import { Systems } from "./codegen/tables/Systems.sol"; +import { SystemHooks } from "./codegen/tables/SystemHooks.sol"; +import { Balances } from "./codegen/tables/Balances.sol"; library SystemCall { using WorldResourceIdInstance for ResourceId; diff --git a/packages/world/src/Utils.sol b/packages/world/src/Utils.sol index 5e8b16fb31..b40d5ce0dd 100644 --- a/packages/world/src/Utils.sol +++ b/packages/world/src/Utils.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { ResourceId, WorldResourceIdInstance } from "./WorldResourceId.sol"; -import { SystemRegistry } from "./index.sol"; +import { SystemRegistry } from "./codegen/tables/SystemRegistry.sol"; library Utils { using WorldResourceIdInstance for ResourceId; diff --git a/packages/world/src/World.sol b/packages/world/src/World.sol index 5404b05886..838ba41e1f 100644 --- a/packages/world/src/World.sol +++ b/packages/world/src/World.sol @@ -21,19 +21,19 @@ import { revertWithBytes } from "./revertWithBytes.sol"; import { Delegation } from "./Delegation.sol"; import { requireInterface } from "./requireInterface.sol"; -import { NamespaceOwner } from "./tables/NamespaceOwner.sol"; -import { InstalledModules } from "./tables/InstalledModules.sol"; -import { UserDelegationControl } from "./tables/UserDelegationControl.sol"; -import { NamespaceDelegationControl } from "./tables/NamespaceDelegationControl.sol"; +import { NamespaceOwner } from "./codegen/tables/NamespaceOwner.sol"; +import { InstalledModules } from "./codegen/tables/InstalledModules.sol"; +import { UserDelegationControl } from "./codegen/tables/UserDelegationControl.sol"; +import { NamespaceDelegationControl } from "./codegen/tables/NamespaceDelegationControl.sol"; import { IModule, MODULE_INTERFACE_ID } from "./interfaces/IModule.sol"; import { IWorldKernel } from "./interfaces/IWorldKernel.sol"; import { IDelegationControl } from "./interfaces/IDelegationControl.sol"; -import { Systems } from "./modules/core/tables/Systems.sol"; -import { SystemHooks } from "./modules/core/tables/SystemHooks.sol"; -import { FunctionSelectors } from "./modules/core/tables/FunctionSelectors.sol"; -import { Balances } from "./modules/core/tables/Balances.sol"; +import { Systems } from "./codegen/tables/Systems.sol"; +import { SystemHooks } from "./codegen/tables/SystemHooks.sol"; +import { FunctionSelectors } from "./codegen/tables/FunctionSelectors.sol"; +import { Balances } from "./codegen/tables/Balances.sol"; import { CORE_MODULE_NAME } from "./modules/core/constants.sol"; contract World is StoreRead, IStoreData, IWorldKernel { diff --git a/packages/world/src/index.sol b/packages/world/src/codegen/index.sol similarity index 63% rename from packages/world/src/index.sol rename to packages/world/src/codegen/index.sol index 5d61620cac..72d7aa53e2 100644 --- a/packages/world/src/index.sol +++ b/packages/world/src/codegen/index.sol @@ -8,12 +8,12 @@ import { ResourceAccess, ResourceAccessTableId } from "./tables/ResourceAccess.s import { InstalledModules, InstalledModulesTableId } from "./tables/InstalledModules.sol"; import { UserDelegationControl, UserDelegationControlTableId } from "./tables/UserDelegationControl.sol"; import { NamespaceDelegationControl, NamespaceDelegationControlTableId } from "./tables/NamespaceDelegationControl.sol"; -import { Balances, BalancesTableId } from "./modules/core/tables/Balances.sol"; -import { Systems, SystemsTableId } from "./modules/core/tables/Systems.sol"; -import { SystemRegistry, SystemRegistryTableId } from "./modules/core/tables/SystemRegistry.sol"; -import { SystemHooks, SystemHooksTableId } from "./modules/core/tables/SystemHooks.sol"; -import { FunctionSelectors, FunctionSelectorsTableId } from "./modules/core/tables/FunctionSelectors.sol"; -import { FunctionSignatures, FunctionSignaturesTableId } from "./modules/core/tables/FunctionSignatures.sol"; +import { Balances, BalancesTableId } from "./tables/Balances.sol"; +import { Systems, SystemsTableId } from "./tables/Systems.sol"; +import { SystemRegistry, SystemRegistryTableId } from "./tables/SystemRegistry.sol"; +import { SystemHooks, SystemHooksTableId } from "./tables/SystemHooks.sol"; +import { FunctionSelectors, FunctionSelectorsTableId } from "./tables/FunctionSelectors.sol"; +import { FunctionSignatures, FunctionSignaturesTableId } from "./tables/FunctionSignatures.sol"; import { Bool } from "./../test/tables/Bool.sol"; import { TwoFields, TwoFieldsData } from "./../test/tables/TwoFields.sol"; import { AddressArray } from "./../test/tables/AddressArray.sol"; diff --git a/packages/world/src/interfaces/IAccessManagementSystem.sol b/packages/world/src/codegen/interfaces/IAccessManagementSystem.sol similarity index 86% rename from packages/world/src/interfaces/IAccessManagementSystem.sol rename to packages/world/src/codegen/interfaces/IAccessManagementSystem.sol index 0f7caa3e90..4e1f8b4424 100644 --- a/packages/world/src/interfaces/IAccessManagementSystem.sol +++ b/packages/world/src/codegen/interfaces/IAccessManagementSystem.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { ResourceId } from "./../WorldResourceId.sol"; +import { ResourceId } from "./../../WorldResourceId.sol"; interface IAccessManagementSystem { function grantAccess(ResourceId resourceId, address grantee) external; diff --git a/packages/world/src/interfaces/IBalanceTransferSystem.sol b/packages/world/src/codegen/interfaces/IBalanceTransferSystem.sol similarity index 100% rename from packages/world/src/interfaces/IBalanceTransferSystem.sol rename to packages/world/src/codegen/interfaces/IBalanceTransferSystem.sol diff --git a/packages/world/src/interfaces/IBaseWorld.sol b/packages/world/src/codegen/interfaces/IBaseWorld.sol similarity index 93% rename from packages/world/src/interfaces/IBaseWorld.sol rename to packages/world/src/codegen/interfaces/IBaseWorld.sol index 53e6102d14..53c74f4c5b 100644 --- a/packages/world/src/interfaces/IBaseWorld.sol +++ b/packages/world/src/codegen/interfaces/IBaseWorld.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ import { IStore } from "@latticexyz/store/src/IStore.sol"; -import { IWorldKernel } from "../interfaces/IWorldKernel.sol"; +import { IWorldKernel } from "../../interfaces/IWorldKernel.sol"; import { ICoreSystem } from "./ICoreSystem.sol"; import { IAccessManagementSystem } from "./IAccessManagementSystem.sol"; diff --git a/packages/world/src/interfaces/ICallBatchSystem.sol b/packages/world/src/codegen/interfaces/ICallBatchSystem.sol similarity index 79% rename from packages/world/src/interfaces/ICallBatchSystem.sol rename to packages/world/src/codegen/interfaces/ICallBatchSystem.sol index 54cdf3f64c..b164789391 100644 --- a/packages/world/src/interfaces/ICallBatchSystem.sol +++ b/packages/world/src/codegen/interfaces/ICallBatchSystem.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { SystemCallData } from "./../modules/core/types.sol"; +import { SystemCallData } from "./../../modules/core/types.sol"; interface ICallBatchSystem { function callBatch(SystemCallData[] calldata systemCalls) external returns (bytes[] memory returnDatas); diff --git a/packages/world/src/interfaces/ICoreSystem.sol b/packages/world/src/codegen/interfaces/ICoreSystem.sol similarity index 100% rename from packages/world/src/interfaces/ICoreSystem.sol rename to packages/world/src/codegen/interfaces/ICoreSystem.sol diff --git a/packages/world/src/interfaces/IModuleInstallationSystem.sol b/packages/world/src/codegen/interfaces/IModuleInstallationSystem.sol similarity index 79% rename from packages/world/src/interfaces/IModuleInstallationSystem.sol rename to packages/world/src/codegen/interfaces/IModuleInstallationSystem.sol index c56b3eeebb..90642ad230 100644 --- a/packages/world/src/interfaces/IModuleInstallationSystem.sol +++ b/packages/world/src/codegen/interfaces/IModuleInstallationSystem.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { IModule } from "./IModule.sol"; +import { IModule } from "./../../interfaces/IModule.sol"; interface IModuleInstallationSystem { function installModule(IModule module, bytes memory args) external; diff --git a/packages/world/src/interfaces/IWorldRegistrationSystem.sol b/packages/world/src/codegen/interfaces/IWorldRegistrationSystem.sol similarity index 90% rename from packages/world/src/interfaces/IWorldRegistrationSystem.sol rename to packages/world/src/codegen/interfaces/IWorldRegistrationSystem.sol index 93900ee784..65e45dc70e 100644 --- a/packages/world/src/interfaces/IWorldRegistrationSystem.sol +++ b/packages/world/src/codegen/interfaces/IWorldRegistrationSystem.sol @@ -4,8 +4,8 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; -import { ISystemHook } from "./ISystemHook.sol"; -import { WorldContextConsumer } from "./../WorldContext.sol"; +import { ISystemHook } from "./../../interfaces/ISystemHook.sol"; +import { WorldContextConsumer } from "./../../WorldContext.sol"; interface IWorldRegistrationSystem { function registerNamespace(ResourceId namespaceId) external; diff --git a/packages/world/src/modules/core/tables/Balances.sol b/packages/world/src/codegen/tables/Balances.sol similarity index 100% rename from packages/world/src/modules/core/tables/Balances.sol rename to packages/world/src/codegen/tables/Balances.sol diff --git a/packages/world/src/modules/core/tables/FunctionSelectors.sol b/packages/world/src/codegen/tables/FunctionSelectors.sol similarity index 100% rename from packages/world/src/modules/core/tables/FunctionSelectors.sol rename to packages/world/src/codegen/tables/FunctionSelectors.sol diff --git a/packages/world/src/modules/core/tables/FunctionSignatures.sol b/packages/world/src/codegen/tables/FunctionSignatures.sol similarity index 100% rename from packages/world/src/modules/core/tables/FunctionSignatures.sol rename to packages/world/src/codegen/tables/FunctionSignatures.sol diff --git a/packages/world/src/tables/InstalledModules.sol b/packages/world/src/codegen/tables/InstalledModules.sol similarity index 100% rename from packages/world/src/tables/InstalledModules.sol rename to packages/world/src/codegen/tables/InstalledModules.sol diff --git a/packages/world/src/tables/NamespaceDelegationControl.sol b/packages/world/src/codegen/tables/NamespaceDelegationControl.sol similarity index 100% rename from packages/world/src/tables/NamespaceDelegationControl.sol rename to packages/world/src/codegen/tables/NamespaceDelegationControl.sol diff --git a/packages/world/src/tables/NamespaceOwner.sol b/packages/world/src/codegen/tables/NamespaceOwner.sol similarity index 100% rename from packages/world/src/tables/NamespaceOwner.sol rename to packages/world/src/codegen/tables/NamespaceOwner.sol diff --git a/packages/world/src/tables/ResourceAccess.sol b/packages/world/src/codegen/tables/ResourceAccess.sol similarity index 100% rename from packages/world/src/tables/ResourceAccess.sol rename to packages/world/src/codegen/tables/ResourceAccess.sol diff --git a/packages/world/src/modules/core/tables/SystemHooks.sol b/packages/world/src/codegen/tables/SystemHooks.sol similarity index 100% rename from packages/world/src/modules/core/tables/SystemHooks.sol rename to packages/world/src/codegen/tables/SystemHooks.sol diff --git a/packages/world/src/modules/core/tables/SystemRegistry.sol b/packages/world/src/codegen/tables/SystemRegistry.sol similarity index 100% rename from packages/world/src/modules/core/tables/SystemRegistry.sol rename to packages/world/src/codegen/tables/SystemRegistry.sol diff --git a/packages/world/src/modules/core/tables/Systems.sol b/packages/world/src/codegen/tables/Systems.sol similarity index 100% rename from packages/world/src/modules/core/tables/Systems.sol rename to packages/world/src/codegen/tables/Systems.sol diff --git a/packages/world/src/tables/UserDelegationControl.sol b/packages/world/src/codegen/tables/UserDelegationControl.sol similarity index 100% rename from packages/world/src/tables/UserDelegationControl.sol rename to packages/world/src/codegen/tables/UserDelegationControl.sol diff --git a/packages/world/src/factories/WorldFactory.sol b/packages/world/src/factories/WorldFactory.sol index 4d2ccb88ab..674bc525a5 100644 --- a/packages/world/src/factories/WorldFactory.sol +++ b/packages/world/src/factories/WorldFactory.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.21; import { Create2 } from "./Create2.sol"; import { World } from "../World.sol"; import { IWorldFactory } from "./IWorldFactory.sol"; -import { IBaseWorld } from "../interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../codegen/interfaces/IBaseWorld.sol"; import { IModule } from "../interfaces/IModule.sol"; import { ROOT_NAMESPACE_ID } from "../constants.sol"; diff --git a/packages/world/src/interfaces/IUniqueEntitySystem.sol b/packages/world/src/interfaces/IUniqueEntitySystem.sol deleted file mode 100644 index d9011e2201..0000000000 --- a/packages/world/src/interfaces/IUniqueEntitySystem.sol +++ /dev/null @@ -1,7 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.21; - -// TODO allow overriding namespace per-system (or a separate config for modules?) -interface IUniqueEntitySystem { - function uniqueEntity_system_getUniqueEntity() external returns (bytes32 uniqueEntity); -} diff --git a/packages/world/src/modules/core/CoreModule.sol b/packages/world/src/modules/core/CoreModule.sol index e69ebcfd44..e2213b77f8 100644 --- a/packages/world/src/modules/core/CoreModule.sol +++ b/packages/world/src/modules/core/CoreModule.sol @@ -5,27 +5,27 @@ import { WorldContextProvider } from "../../WorldContext.sol"; import { ROOT_NAMESPACE, ROOT_NAMESPACE_ID } from "../../constants.sol"; import { Module } from "../../Module.sol"; -import { IBaseWorld } from "../../interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../../codegen/interfaces/IBaseWorld.sol"; import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; import { ResourceIds } from "@latticexyz/store/src/codegen/tables/ResourceIds.sol"; import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "../../WorldResourceId.sol"; import { RESOURCE_SYSTEM } from "../../worldResourceTypes.sol"; -import { NamespaceOwner } from "../../tables/NamespaceOwner.sol"; -import { ResourceAccess } from "../../tables/ResourceAccess.sol"; -import { InstalledModules } from "../../tables/InstalledModules.sol"; -import { UserDelegationControl } from "../../tables/UserDelegationControl.sol"; -import { NamespaceDelegationControl } from "../../tables/NamespaceDelegationControl.sol"; +import { NamespaceOwner } from "../../codegen/tables/NamespaceOwner.sol"; +import { ResourceAccess } from "../../codegen/tables/ResourceAccess.sol"; +import { InstalledModules } from "../../codegen/tables/InstalledModules.sol"; +import { UserDelegationControl } from "../../codegen/tables/UserDelegationControl.sol"; +import { NamespaceDelegationControl } from "../../codegen/tables/NamespaceDelegationControl.sol"; import { CoreSystem } from "./CoreSystem.sol"; import { CORE_MODULE_NAME, CORE_SYSTEM_ID } from "./constants.sol"; -import { Systems } from "./tables/Systems.sol"; -import { FunctionSelectors } from "./tables/FunctionSelectors.sol"; -import { SystemHooks } from "./tables/SystemHooks.sol"; -import { SystemRegistry } from "./tables/SystemRegistry.sol"; -import { Balances } from "./tables/Balances.sol"; +import { Systems } from "../../codegen/tables/Systems.sol"; +import { FunctionSelectors } from "../../codegen/tables/FunctionSelectors.sol"; +import { SystemHooks } from "../../codegen/tables/SystemHooks.sol"; +import { SystemRegistry } from "../../codegen/tables/SystemRegistry.sol"; +import { Balances } from "../../codegen/tables/Balances.sol"; import { AccessManagementSystem } from "./implementations/AccessManagementSystem.sol"; import { BalanceTransferSystem } from "./implementations/BalanceTransferSystem.sol"; diff --git a/packages/world/src/modules/core/implementations/AccessManagementSystem.sol b/packages/world/src/modules/core/implementations/AccessManagementSystem.sol index 6a3f8317cd..af1c91b80b 100644 --- a/packages/world/src/modules/core/implementations/AccessManagementSystem.sol +++ b/packages/world/src/modules/core/implementations/AccessManagementSystem.sol @@ -5,9 +5,9 @@ import { IModule } from "../../../interfaces/IModule.sol"; import { System } from "../../../System.sol"; import { AccessControl } from "../../../AccessControl.sol"; import { ResourceId, WorldResourceIdLib } from "../../../WorldResourceId.sol"; -import { ResourceAccess } from "../../../tables/ResourceAccess.sol"; -import { InstalledModules } from "../../../tables/InstalledModules.sol"; -import { NamespaceOwner } from "../../../tables/NamespaceOwner.sol"; +import { ResourceAccess } from "../../../codegen/tables/ResourceAccess.sol"; +import { InstalledModules } from "../../../codegen/tables/InstalledModules.sol"; +import { NamespaceOwner } from "../../../codegen/tables/NamespaceOwner.sol"; /** * Granting and revoking access from/to resources. diff --git a/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol b/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol index 30d7165c74..5ba705fe6d 100644 --- a/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol +++ b/packages/world/src/modules/core/implementations/BalanceTransferSystem.sol @@ -10,7 +10,7 @@ import { AccessControl } from "../../../AccessControl.sol"; import { RESOURCE_NAMESPACE } from "../../../worldResourceTypes.sol"; import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol"; -import { Balances } from "../tables/Balances.sol"; +import { Balances } from "../../../codegen/tables/Balances.sol"; contract BalanceTransferSystem is System, IWorldErrors { using ResourceIdInstance for ResourceId; diff --git a/packages/world/src/modules/core/implementations/CallBatchSystem.sol b/packages/world/src/modules/core/implementations/CallBatchSystem.sol index 2f8d63b003..8cabb6ea90 100644 --- a/packages/world/src/modules/core/implementations/CallBatchSystem.sol +++ b/packages/world/src/modules/core/implementations/CallBatchSystem.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { System } from "../../../System.sol"; -import { IBaseWorld } from "../../../interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../../../codegen/interfaces/IBaseWorld.sol"; import { revertWithBytes } from "../../../revertWithBytes.sol"; import { SystemCallData } from "../types.sol"; diff --git a/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol b/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol index c0d9c1f3ea..f507a322a6 100644 --- a/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol +++ b/packages/world/src/modules/core/implementations/ModuleInstallationSystem.sol @@ -5,8 +5,8 @@ import { IModule, MODULE_INTERFACE_ID } from "../../../interfaces/IModule.sol"; import { System } from "../../../System.sol"; import { AccessControl } from "../../../AccessControl.sol"; import { WorldContextProvider } from "../../../WorldContext.sol"; -import { ResourceAccess } from "../../../tables/ResourceAccess.sol"; -import { InstalledModules } from "../../../tables/InstalledModules.sol"; +import { ResourceAccess } from "../../../codegen/tables/ResourceAccess.sol"; +import { InstalledModules } from "../../../codegen/tables/InstalledModules.sol"; import { requireInterface } from "../../../requireInterface.sol"; /** diff --git a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol index b903392262..0f3eb9f6f6 100644 --- a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol @@ -14,14 +14,15 @@ import { AccessControl } from "../../../AccessControl.sol"; import { requireInterface } from "../../../requireInterface.sol"; import { revertWithBytes } from "../../../revertWithBytes.sol"; import { WorldContextProvider } from "../../../WorldContext.sol"; -import { NamespaceOwner } from "../../../tables/NamespaceOwner.sol"; -import { ResourceAccess } from "../../../tables/ResourceAccess.sol"; -import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol"; -import { SystemHooks } from "../tables/SystemHooks.sol"; -import { SystemRegistry } from "../tables/SystemRegistry.sol"; -import { Systems } from "../tables/Systems.sol"; -import { FunctionSelectors } from "../tables/FunctionSelectors.sol"; +import { NamespaceOwner } from "../../../codegen/tables/NamespaceOwner.sol"; +import { ResourceAccess } from "../../../codegen/tables/ResourceAccess.sol"; +import { SystemHooks } from "../../../codegen/tables/SystemHooks.sol"; +import { SystemRegistry } from "../../../codegen/tables/SystemRegistry.sol"; +import { Systems } from "../../../codegen/tables/Systems.sol"; +import { FunctionSelectors } from "../../../codegen/tables/FunctionSelectors.sol"; + +import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol"; import { CORE_SYSTEM_ID } from "../constants.sol"; diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index 6ab8598d61..766fafac01 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -14,19 +14,19 @@ import { RESOURCE_NAMESPACE, RESOURCE_SYSTEM } from "../../../worldResourceTypes import { AccessControl } from "../../../AccessControl.sol"; import { Delegation } from "../../../Delegation.sol"; import { requireInterface } from "../../../requireInterface.sol"; -import { NamespaceOwner } from "../../../tables/NamespaceOwner.sol"; -import { ResourceAccess } from "../../../tables/ResourceAccess.sol"; -import { UserDelegationControl } from "../../../tables/UserDelegationControl.sol"; -import { NamespaceDelegationControl } from "../../../tables/NamespaceDelegationControl.sol"; +import { NamespaceOwner } from "../../../codegen/tables/NamespaceOwner.sol"; +import { ResourceAccess } from "../../../codegen/tables/ResourceAccess.sol"; +import { UserDelegationControl } from "../../../codegen/tables/UserDelegationControl.sol"; +import { NamespaceDelegationControl } from "../../../codegen/tables/NamespaceDelegationControl.sol"; import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "../../../interfaces/ISystemHook.sol"; import { IWorldErrors } from "../../../interfaces/IWorldErrors.sol"; import { IDelegationControl, DELEGATION_CONTROL_INTERFACE_ID } from "../../../interfaces/IDelegationControl.sol"; -import { SystemHooks, SystemHooksTableId } from "../tables/SystemHooks.sol"; -import { SystemRegistry } from "../tables/SystemRegistry.sol"; -import { Systems } from "../tables/Systems.sol"; -import { FunctionSelectors } from "../tables/FunctionSelectors.sol"; -import { FunctionSignatures } from "../tables/FunctionSignatures.sol"; +import { SystemHooks, SystemHooksTableId } from "../../../codegen/tables/SystemHooks.sol"; +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"; /** * Functions related to registering resources other than tables in the World. diff --git a/packages/world/src/test/tables/AddressArray.sol b/packages/world/src/test/tables/AddressArray.sol new file mode 100644 index 0000000000..b9e4230eef --- /dev/null +++ b/packages/world/src/test/tables/AddressArray.sol @@ -0,0 +1,566 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.21; + +/* Autogenerated file. Do not edit manually. */ + +// Import schema type +import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; +import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; +import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; + +FieldLayout constant _fieldLayout = FieldLayout.wrap( + 0x0000000100000000000000000000000000000000000000000000000000000000 +); + +library AddressArray { + /** Get the table values' field layout */ + function getFieldLayout() internal pure returns (FieldLayout) { + return _fieldLayout; + } + + /** Get the table's key schema */ + function getKeySchema() internal pure returns (Schema) { + SchemaType[] memory _keySchema = new SchemaType[](1); + _keySchema[0] = SchemaType.BYTES32; + + return SchemaLib.encode(_keySchema); + } + + /** Get the table's value schema */ + function getValueSchema() internal pure returns (Schema) { + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.ADDRESS_ARRAY; + + return SchemaLib.encode(_valueSchema); + } + + /** Get the table's key names */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](1); + keyNames[0] = "key"; + } + + /** Get the table's field names */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** Register the table with its config */ + function register(ResourceId _tableId) internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Register the table with its config */ + function _register(ResourceId _tableId) internal { + StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Register the table with its config (using the specified store) */ + function register(IStore _store, ResourceId _tableId) internal { + _store.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Get value */ + function getValue(ResourceId _tableId, bytes32 key) internal view returns (address[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); + } + + /** Get value */ + function _getValue(ResourceId _tableId, bytes32 key) internal view returns (address[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); + } + + /** Get value (using the specified store) */ + function getValue(IStore _store, ResourceId _tableId, bytes32 key) internal view returns (address[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + bytes memory _blob = _store.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); + } + + /** Get value */ + function get(ResourceId _tableId, bytes32 key) internal view returns (address[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + bytes memory _blob = StoreSwitch.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); + } + + /** Get value */ + function _get(ResourceId _tableId, bytes32 key) internal view returns (address[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + bytes memory _blob = StoreCore.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); + } + + /** Get value (using the specified store) */ + function get(IStore _store, ResourceId _tableId, bytes32 key) internal view returns (address[] memory value) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + bytes memory _blob = _store.getDynamicField(_tableId, _keyTuple, 0); + return (SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_address()); + } + + /** Set value */ + function setValue(ResourceId _tableId, bytes32 key, address[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** Set value */ + function _setValue(ResourceId _tableId, bytes32 key, address[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** Set value (using the specified store) */ + function setValue(IStore _store, ResourceId _tableId, bytes32 key, address[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** Set value */ + function set(ResourceId _tableId, bytes32 key, address[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreSwitch.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** Set value */ + function _set(ResourceId _tableId, bytes32 key, address[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreCore.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** Set value (using the specified store) */ + function set(IStore _store, ResourceId _tableId, bytes32 key, address[] memory value) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + _store.setDynamicField(_tableId, _keyTuple, 0, EncodeArray.encode((value))); + } + + /** Get the length of value */ + function lengthValue(ResourceId _tableId, bytes32 key) internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 20; + } + } + + /** Get the length of value */ + function _lengthValue(ResourceId _tableId, bytes32 key) internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 20; + } + } + + /** Get the length of value (using the specified store) */ + function lengthValue(IStore _store, ResourceId _tableId, bytes32 key) internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 20; + } + } + + /** Get the length of value */ + function length(ResourceId _tableId, bytes32 key) internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + uint256 _byteLength = StoreSwitch.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 20; + } + } + + /** Get the length of value */ + function _length(ResourceId _tableId, bytes32 key) internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + uint256 _byteLength = StoreCore.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 20; + } + } + + /** Get the length of value (using the specified store) */ + function length(IStore _store, ResourceId _tableId, bytes32 key) internal view returns (uint256) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + uint256 _byteLength = _store.getDynamicFieldLength(_tableId, _keyTuple, 0); + unchecked { + return _byteLength / 20; + } + } + + /** + * Get an item of value + * (unchecked, returns invalid data if index overflows) + */ + function getItemValue(ResourceId _tableId, bytes32 key, uint256 _index) internal view returns (address) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); + return (address(bytes20(_blob))); + } + } + + /** + * Get an item of value + * (unchecked, returns invalid data if index overflows) + */ + function _getItemValue(ResourceId _tableId, bytes32 key, uint256 _index) internal view returns (address) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); + return (address(bytes20(_blob))); + } + } + + /** + * Get an item of value (using the specified store) + * (unchecked, returns invalid data if index overflows) + */ + function getItemValue( + IStore _store, + ResourceId _tableId, + bytes32 key, + uint256 _index + ) internal view returns (address) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); + return (address(bytes20(_blob))); + } + } + + /** + * Get an item of value + * (unchecked, returns invalid data if index overflows) + */ + function getItem(ResourceId _tableId, bytes32 key, uint256 _index) internal view returns (address) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _blob = StoreSwitch.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); + return (address(bytes20(_blob))); + } + } + + /** + * Get an item of value + * (unchecked, returns invalid data if index overflows) + */ + function _getItem(ResourceId _tableId, bytes32 key, uint256 _index) internal view returns (address) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _blob = StoreCore.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); + return (address(bytes20(_blob))); + } + } + + /** + * Get an item of value (using the specified store) + * (unchecked, returns invalid data if index overflows) + */ + function getItem(IStore _store, ResourceId _tableId, bytes32 key, uint256 _index) internal view returns (address) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _blob = _store.getDynamicFieldSlice(_tableId, _keyTuple, 0, _index * 20, (_index + 1) * 20); + return (address(bytes20(_blob))); + } + } + + /** Push an element to value */ + function pushValue(ResourceId _tableId, bytes32 key, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** Push an element to value */ + function _pushValue(ResourceId _tableId, bytes32 key, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** Push an element to value (using the specified store) */ + function pushValue(IStore _store, ResourceId _tableId, bytes32 key, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** Push an element to value */ + function push(ResourceId _tableId, bytes32 key, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreSwitch.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** Push an element to value */ + function _push(ResourceId _tableId, bytes32 key, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreCore.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** Push an element to value (using the specified store) */ + function push(IStore _store, ResourceId _tableId, bytes32 key, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + _store.pushToDynamicField(_tableId, _keyTuple, 0, abi.encodePacked((_element))); + } + + /** Pop an element from value */ + function popValue(ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 20); + } + + /** Pop an element from value */ + function _popValue(ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 20); + } + + /** Pop an element from value (using the specified store) */ + function popValue(IStore _store, ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + _store.popFromDynamicField(_tableId, _keyTuple, 0, 20); + } + + /** Pop an element from value */ + function pop(ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreSwitch.popFromDynamicField(_tableId, _keyTuple, 0, 20); + } + + /** Pop an element from value */ + function _pop(ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreCore.popFromDynamicField(_tableId, _keyTuple, 0, 20); + } + + /** Pop an element from value (using the specified store) */ + function pop(IStore _store, ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + _store.popFromDynamicField(_tableId, _keyTuple, 0, 20); + } + + /** + * Update an element of value at `_index` + * (checked only to prevent modifying other tables; can corrupt own data if index overflows) + */ + function updateValue(ResourceId _tableId, bytes32 key, uint256 _index, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); + } + } + + /** + * Update an element of value at `_index` + * (checked only to prevent modifying other tables; can corrupt own data if index overflows) + */ + function _updateValue(ResourceId _tableId, bytes32 key, uint256 _index, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); + } + } + + /** + * Update an element of value (using the specified store) at `_index` + * (checked only to prevent modifying other tables; can corrupt own data if index overflows) + */ + function updateValue(IStore _store, ResourceId _tableId, bytes32 key, uint256 _index, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); + } + } + + /** + * Update an element of value at `_index` + * (checked only to prevent modifying other tables; can corrupt own data if index overflows) + */ + function update(ResourceId _tableId, bytes32 key, uint256 _index, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreSwitch.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); + } + } + + /** + * Update an element of value at `_index` + * (checked only to prevent modifying other tables; can corrupt own data if index overflows) + */ + function _update(ResourceId _tableId, bytes32 key, uint256 _index, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + StoreCore.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); + } + } + + /** + * Update an element of value (using the specified store) at `_index` + * (checked only to prevent modifying other tables; can corrupt own data if index overflows) + */ + function update(IStore _store, ResourceId _tableId, bytes32 key, uint256 _index, address _element) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + unchecked { + bytes memory _encoded = abi.encodePacked((_element)); + _store.spliceDynamicData(_tableId, _keyTuple, 0, uint40(_index * 20), uint40(_encoded.length), _encoded); + } + } + + /** Delete all data for given keys */ + function deleteRecord(ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** Delete all data for given keys */ + function _deleteRecord(ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** Delete all data for given keys (using the specified store) */ + function deleteRecord(IStore _store, ResourceId _tableId, bytes32 key) internal { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + _store.deleteRecord(_tableId, _keyTuple); + } + + /** Tightly pack dynamic data using this table's schema */ + function encodeLengths(address[] memory value) internal pure returns (PackedCounter _encodedLengths) { + // Lengths are effectively checked during copy by 2**40 bytes exceeding gas limits + unchecked { + _encodedLengths = PackedCounterLib.pack(value.length * 20); + } + } + + /** Tightly pack dynamic data using this table's schema */ + function encodeDynamic(address[] memory value) internal pure returns (bytes memory) { + return abi.encodePacked(EncodeArray.encode((value))); + } + + /** Tightly pack full data using this table's field layout */ + function encode(address[] memory value) internal pure returns (bytes memory, PackedCounter, bytes memory) { + bytes memory _staticData; + PackedCounter _encodedLengths = encodeLengths(value); + bytes memory _dynamicData = encodeDynamic(value); + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** Encode keys as a bytes32 array using this table's field layout */ + function encodeKeyTuple(bytes32 key) internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](1); + _keyTuple[0] = key; + + return _keyTuple; + } +} diff --git a/packages/world/src/test/tables/Bool.sol b/packages/world/src/test/tables/Bool.sol new file mode 100644 index 0000000000..e110386002 --- /dev/null +++ b/packages/world/src/test/tables/Bool.sol @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.21; + +/* Autogenerated file. Do not edit manually. */ + +// Import schema type +import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; +import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; +import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; + +FieldLayout constant _fieldLayout = FieldLayout.wrap( + 0x0001010001000000000000000000000000000000000000000000000000000000 +); + +library Bool { + /** Get the table values' field layout */ + function getFieldLayout() internal pure returns (FieldLayout) { + return _fieldLayout; + } + + /** Get the table's key schema */ + function getKeySchema() internal pure returns (Schema) { + SchemaType[] memory _keySchema = new SchemaType[](0); + + return SchemaLib.encode(_keySchema); + } + + /** Get the table's value schema */ + function getValueSchema() internal pure returns (Schema) { + SchemaType[] memory _valueSchema = new SchemaType[](1); + _valueSchema[0] = SchemaType.BOOL; + + return SchemaLib.encode(_valueSchema); + } + + /** Get the table's key names */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** Get the table's field names */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](1); + fieldNames[0] = "value"; + } + + /** Register the table with its config */ + function register(ResourceId _tableId) internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Register the table with its config */ + function _register(ResourceId _tableId) internal { + StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Register the table with its config (using the specified store) */ + function register(IStore _store, ResourceId _tableId) internal { + _store.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Get value */ + function getValue(ResourceId _tableId) internal view returns (bool value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value */ + function _getValue(ResourceId _tableId) internal view returns (bool value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value (using the specified store) */ + function getValue(IStore _store, ResourceId _tableId) internal view returns (bool value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = _store.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value */ + function get(ResourceId _tableId) internal view returns (bool value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value */ + function _get(ResourceId _tableId) internal view returns (bool value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value (using the specified store) */ + function get(IStore _store, ResourceId _tableId) internal view returns (bool value) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = _store.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Set value */ + function setValue(ResourceId _tableId, bool value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** Set value */ + function _setValue(ResourceId _tableId, bool value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** Set value (using the specified store) */ + function setValue(IStore _store, ResourceId _tableId, bool value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** Set value */ + function set(ResourceId _tableId, bool value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** Set value */ + function _set(ResourceId _tableId, bool value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** Set value (using the specified store) */ + function set(IStore _store, ResourceId _tableId, bool value) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value)), _fieldLayout); + } + + /** Delete all data for given keys */ + function deleteRecord(ResourceId _tableId) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** Delete all data for given keys */ + function _deleteRecord(ResourceId _tableId) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** Delete all data for given keys (using the specified store) */ + function deleteRecord(IStore _store, ResourceId _tableId) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.deleteRecord(_tableId, _keyTuple); + } + + /** Tightly pack static data using this table's schema */ + function encodeStatic(bool value) internal pure returns (bytes memory) { + return abi.encodePacked(value); + } + + /** Tightly pack full data using this table's field layout */ + function encode(bool value) internal pure returns (bytes memory, PackedCounter, bytes memory) { + bytes memory _staticData = encodeStatic(value); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** Encode keys as a bytes32 array using this table's field layout */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} + +function _toBool(uint8 value) pure returns (bool result) { + assembly { + result := value + } +} diff --git a/packages/world/src/test/tables/TwoFields.sol b/packages/world/src/test/tables/TwoFields.sol new file mode 100644 index 0000000000..8685868093 --- /dev/null +++ b/packages/world/src/test/tables/TwoFields.sol @@ -0,0 +1,349 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.21; + +/* Autogenerated file. Do not edit manually. */ + +// Import schema type +import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol"; + +// Import store internals +import { IStore } from "@latticexyz/store/src/IStore.sol"; +import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; +import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; +import { Bytes } from "@latticexyz/store/src/Bytes.sol"; +import { Memory } from "@latticexyz/store/src/Memory.sol"; +import { SliceLib } from "@latticexyz/store/src/Slice.sol"; +import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; +import { FieldLayout, FieldLayoutLib } from "@latticexyz/store/src/FieldLayout.sol"; +import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; +import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; +import { ResourceId } from "@latticexyz/store/src/ResourceId.sol"; +import { RESOURCE_TABLE, RESOURCE_OFFCHAIN_TABLE } from "@latticexyz/store/src/storeResourceTypes.sol"; + +FieldLayout constant _fieldLayout = FieldLayout.wrap( + 0x0002020001010000000000000000000000000000000000000000000000000000 +); + +struct TwoFieldsData { + bool value1; + bool value2; +} + +library TwoFields { + /** Get the table values' field layout */ + function getFieldLayout() internal pure returns (FieldLayout) { + return _fieldLayout; + } + + /** Get the table's key schema */ + function getKeySchema() internal pure returns (Schema) { + SchemaType[] memory _keySchema = new SchemaType[](0); + + return SchemaLib.encode(_keySchema); + } + + /** Get the table's value schema */ + function getValueSchema() internal pure returns (Schema) { + SchemaType[] memory _valueSchema = new SchemaType[](2); + _valueSchema[0] = SchemaType.BOOL; + _valueSchema[1] = SchemaType.BOOL; + + return SchemaLib.encode(_valueSchema); + } + + /** Get the table's key names */ + function getKeyNames() internal pure returns (string[] memory keyNames) { + keyNames = new string[](0); + } + + /** Get the table's field names */ + function getFieldNames() internal pure returns (string[] memory fieldNames) { + fieldNames = new string[](2); + fieldNames[0] = "value1"; + fieldNames[1] = "value2"; + } + + /** Register the table with its config */ + function register(ResourceId _tableId) internal { + StoreSwitch.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Register the table with its config */ + function _register(ResourceId _tableId) internal { + StoreCore.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Register the table with its config (using the specified store) */ + function register(IStore _store, ResourceId _tableId) internal { + _store.registerTable(_tableId, _fieldLayout, getKeySchema(), getValueSchema(), getKeyNames(), getFieldNames()); + } + + /** Get value1 */ + function getValue1(ResourceId _tableId) internal view returns (bool value1) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value1 */ + function _getValue1(ResourceId _tableId) internal view returns (bool value1) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value1 (using the specified store) */ + function getValue1(IStore _store, ResourceId _tableId) internal view returns (bool value1) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = _store.getStaticField(_tableId, _keyTuple, 0, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Set value1 */ + function setValue1(ResourceId _tableId, bool value1) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); + } + + /** Set value1 */ + function _setValue1(ResourceId _tableId, bool value1) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); + } + + /** Set value1 (using the specified store) */ + function setValue1(IStore _store, ResourceId _tableId, bool value1) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.setStaticField(_tableId, _keyTuple, 0, abi.encodePacked((value1)), _fieldLayout); + } + + /** Get value2 */ + function getValue2(ResourceId _tableId) internal view returns (bool value2) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreSwitch.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value2 */ + function _getValue2(ResourceId _tableId) internal view returns (bool value2) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = StoreCore.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Get value2 (using the specified store) */ + function getValue2(IStore _store, ResourceId _tableId) internal view returns (bool value2) { + bytes32[] memory _keyTuple = new bytes32[](0); + + bytes32 _blob = _store.getStaticField(_tableId, _keyTuple, 1, _fieldLayout); + return (_toBool(uint8(bytes1(_blob)))); + } + + /** Set value2 */ + function setValue2(ResourceId _tableId, bool value2) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); + } + + /** Set value2 */ + function _setValue2(ResourceId _tableId, bool value2) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); + } + + /** Set value2 (using the specified store) */ + function setValue2(IStore _store, ResourceId _tableId, bool value2) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.setStaticField(_tableId, _keyTuple, 1, abi.encodePacked((value2)), _fieldLayout); + } + + /** Get the full data */ + function get(ResourceId _tableId) internal view returns (TwoFieldsData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreSwitch.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** Get the full data */ + function _get(ResourceId _tableId) internal view returns (TwoFieldsData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = StoreCore.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** Get the full data (using the specified store) */ + function get(IStore _store, ResourceId _tableId) internal view returns (TwoFieldsData memory _table) { + bytes32[] memory _keyTuple = new bytes32[](0); + + (bytes memory _staticData, PackedCounter _encodedLengths, bytes memory _dynamicData) = _store.getRecord( + _tableId, + _keyTuple, + _fieldLayout + ); + return decode(_staticData, _encodedLengths, _dynamicData); + } + + /** Set the full data using individual values */ + function set(ResourceId _tableId, bool value1, bool value2) internal { + bytes memory _staticData = encodeStatic(value1, value2); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** Set the full data using individual values */ + function _set(ResourceId _tableId, bool value1, bool value2) internal { + bytes memory _staticData = encodeStatic(value1, value2); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** Set the full data using individual values (using the specified store) */ + function set(IStore _store, ResourceId _tableId, bool value1, bool value2) internal { + bytes memory _staticData = encodeStatic(value1, value2); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** Set the full data using the data struct */ + function set(ResourceId _tableId, TwoFieldsData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.value1, _table.value2); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** Set the full data using the data struct */ + function _set(ResourceId _tableId, TwoFieldsData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.value1, _table.value2); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData, _fieldLayout); + } + + /** Set the full data using the data struct (using the specified store) */ + function set(IStore _store, ResourceId _tableId, TwoFieldsData memory _table) internal { + bytes memory _staticData = encodeStatic(_table.value1, _table.value2); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.setRecord(_tableId, _keyTuple, _staticData, _encodedLengths, _dynamicData); + } + + /** + * Decode the tightly packed blob of static data using this table's field layout + * Undefined behaviour for invalid blobs + */ + function decodeStatic(bytes memory _blob) internal pure returns (bool value1, bool value2) { + value1 = (_toBool(uint8(Bytes.slice1(_blob, 0)))); + + value2 = (_toBool(uint8(Bytes.slice1(_blob, 1)))); + } + + /** + * Decode the tightly packed blob using this table's field layout. + * Undefined behaviour for invalid blobs. + */ + function decode( + bytes memory _staticData, + PackedCounter, + bytes memory + ) internal pure returns (TwoFieldsData memory _table) { + (_table.value1, _table.value2) = decodeStatic(_staticData); + } + + /** Delete all data for given keys */ + function deleteRecord(ResourceId _tableId) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreSwitch.deleteRecord(_tableId, _keyTuple); + } + + /** Delete all data for given keys */ + function _deleteRecord(ResourceId _tableId) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + StoreCore.deleteRecord(_tableId, _keyTuple, _fieldLayout); + } + + /** Delete all data for given keys (using the specified store) */ + function deleteRecord(IStore _store, ResourceId _tableId) internal { + bytes32[] memory _keyTuple = new bytes32[](0); + + _store.deleteRecord(_tableId, _keyTuple); + } + + /** Tightly pack static data using this table's schema */ + function encodeStatic(bool value1, bool value2) internal pure returns (bytes memory) { + return abi.encodePacked(value1, value2); + } + + /** Tightly pack full data using this table's field layout */ + function encode(bool value1, bool value2) internal pure returns (bytes memory, PackedCounter, bytes memory) { + bytes memory _staticData = encodeStatic(value1, value2); + + PackedCounter _encodedLengths; + bytes memory _dynamicData; + + return (_staticData, _encodedLengths, _dynamicData); + } + + /** Encode keys as a bytes32 array using this table's field layout */ + function encodeKeyTuple() internal pure returns (bytes32[] memory) { + bytes32[] memory _keyTuple = new bytes32[](0); + + return _keyTuple; + } +} + +function _toBool(uint8 value) pure returns (bool result) { + assembly { + result := value + } +} diff --git a/packages/world/test/AccessControl.t.sol b/packages/world/test/AccessControl.t.sol index b0f9af2fa3..b4ef353d35 100644 --- a/packages/world/test/AccessControl.t.sol +++ b/packages/world/test/AccessControl.t.sol @@ -11,8 +11,8 @@ import { AccessControl } from "../src/AccessControl.sol"; import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "../src/WorldResourceId.sol"; import { RESOURCE_TABLE } from "../src/worldResourceTypes.sol"; -import { ResourceAccess } from "../src/tables/ResourceAccess.sol"; -import { NamespaceOwner } from "../src/tables/NamespaceOwner.sol"; +import { ResourceAccess } from "../src/codegen/tables/ResourceAccess.sol"; +import { NamespaceOwner } from "../src/codegen/tables/NamespaceOwner.sol"; contract AccessControlTest is Test, GasReporter, StoreMock { using WorldResourceIdInstance for ResourceId; diff --git a/packages/world/test/CallBatch.t.sol b/packages/world/test/CallBatch.t.sol index 2aa3fc81ed..8fab0a1baf 100644 --- a/packages/world/test/CallBatch.t.sol +++ b/packages/world/test/CallBatch.t.sol @@ -10,7 +10,7 @@ import { System } from "../src/System.sol"; import { ResourceId, WorldResourceIdLib } from "../src/WorldResourceId.sol"; import { RESOURCE_SYSTEM } from "../src/worldResourceTypes.sol"; -import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol"; import { CoreModule } from "../src/modules/core/CoreModule.sol"; import { SystemCallData } from "../src/modules/core/types.sol"; diff --git a/packages/world/test/Factories.t.sol b/packages/world/test/Factories.t.sol index 13115a184c..c6ae016ba0 100644 --- a/packages/world/test/Factories.t.sol +++ b/packages/world/test/Factories.t.sol @@ -12,8 +12,8 @@ import { CORE_MODULE_NAME } from "../src/modules/core/constants.sol"; import { Create2Factory } from "../src/factories/Create2Factory.sol"; import { WorldFactory } from "../src/factories/WorldFactory.sol"; import { IWorldFactory } from "../src/factories/IWorldFactory.sol"; -import { InstalledModules } from "../src/tables/InstalledModules.sol"; -import { NamespaceOwner } from "../src/tables/NamespaceOwner.sol"; +import { InstalledModules } from "../src/codegen/tables/InstalledModules.sol"; +import { NamespaceOwner } from "../src/codegen/tables/NamespaceOwner.sol"; import { ROOT_NAMESPACE_ID } from "../src/constants.sol"; contract FactoriesTest is Test { diff --git a/packages/world/test/Utils.t.sol b/packages/world/test/Utils.t.sol index 789480666a..b0458c9613 100644 --- a/packages/world/test/Utils.t.sol +++ b/packages/world/test/Utils.t.sol @@ -6,7 +6,7 @@ import { Test } from "forge-std/Test.sol"; import { Utils } from "../src/Utils.sol"; import { System } from "../src/System.sol"; import { World } from "../src/World.sol"; -import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol"; import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "../src/WorldResourceId.sol"; import { RESOURCE_SYSTEM } from "../src/worldResourceTypes.sol"; diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 27aded7654..684d54f896 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -32,17 +32,17 @@ import { SystemHook } from "../src/SystemHook.sol"; import { BEFORE_CALL_SYSTEM, AFTER_CALL_SYSTEM } from "../src/systemHookTypes.sol"; import { Module, MODULE_INTERFACE_ID } from "../src/Module.sol"; -import { NamespaceOwner, NamespaceOwnerTableId } from "../src/tables/NamespaceOwner.sol"; -import { ResourceAccess } from "../src/tables/ResourceAccess.sol"; +import { NamespaceOwner, NamespaceOwnerTableId } from "../src/codegen/tables/NamespaceOwner.sol"; +import { ResourceAccess } from "../src/codegen/tables/ResourceAccess.sol"; import { CoreModule } from "../src/modules/core/CoreModule.sol"; import { CoreSystem } from "../src/modules/core/CoreSystem.sol"; import { CORE_SYSTEM_ID } from "../src/modules/core/constants.sol"; -import { Systems } from "../src/modules/core/tables/Systems.sol"; -import { SystemRegistry } from "../src/modules/core/tables/SystemRegistry.sol"; -import { FunctionSelectors } from "../src/modules/core/tables/FunctionSelectors.sol"; +import { Systems } from "../src/codegen/tables/Systems.sol"; +import { SystemRegistry } from "../src/codegen/tables/SystemRegistry.sol"; +import { FunctionSelectors } from "../src/codegen/tables/FunctionSelectors.sol"; -import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol"; import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol"; import { ISystemHook, SYSTEM_HOOK_INTERFACE_ID } from "../src/interfaces/ISystemHook.sol"; diff --git a/packages/world/test/WorldBalance.t.sol b/packages/world/test/WorldBalance.t.sol index 57e094e3af..a6f2bf521f 100644 --- a/packages/world/test/WorldBalance.t.sol +++ b/packages/world/test/WorldBalance.t.sol @@ -5,11 +5,11 @@ import "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { World } from "../src/World.sol"; import { System } from "../src/System.sol"; -import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol"; import { ResourceId, WorldResourceIdLib, WorldResourceIdInstance } from "../src/WorldResourceId.sol"; import { ROOT_NAMESPACE, ROOT_NAMESPACE_ID } from "../src/constants.sol"; import { CoreModule } from "../src/modules/core/CoreModule.sol"; -import { Balances } from "../src/modules/core/tables/Balances.sol"; +import { Balances } from "../src/codegen/tables/Balances.sol"; import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol"; import { RESOURCE_SYSTEM, RESOURCE_NAMESPACE } from "../src/worldResourceTypes.sol"; diff --git a/packages/world/test/WorldDynamicUpdate.t.sol b/packages/world/test/WorldDynamicUpdate.t.sol index 1d02ca0b48..cd61c61506 100644 --- a/packages/world/test/WorldDynamicUpdate.t.sol +++ b/packages/world/test/WorldDynamicUpdate.t.sol @@ -23,7 +23,7 @@ import { AddressArray } from "./tables/AddressArray.sol"; import { CoreModule } from "../src/modules/core/CoreModule.sol"; -import { IBaseWorld } from "../src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "../src/codegen/interfaces/IBaseWorld.sol"; import { IWorldErrors } from "../src/interfaces/IWorldErrors.sol"; contract UpdateInDynamicFieldTest is Test, GasReporter { diff --git a/packages/world/ts/node/render-solidity/renderWorld.ts b/packages/world/ts/node/render-solidity/renderWorld.ts index c4493b75d6..95233cf281 100644 --- a/packages/world/ts/node/render-solidity/renderWorld.ts +++ b/packages/world/ts/node/render-solidity/renderWorld.ts @@ -18,7 +18,7 @@ export function renderWorld(options: RenderWorldOptions) { : [ { symbol: "IBaseWorld", - path: `${worldImportPath}interfaces/IBaseWorld.sol`, + path: `${worldImportPath}codegen/interfaces/IBaseWorld.sol`, }, ]; const importSymbols = [...baseImports, ...imports].map(({ symbol }) => symbol); diff --git a/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol b/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol index 0fd7430af1..a862dd084e 100644 --- a/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/phaser/packages/contracts/src/codegen/world/IWorld.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IIncrementSystem } from "./IIncrementSystem.sol"; diff --git a/templates/react/packages/contracts/src/codegen/world/IWorld.sol b/templates/react/packages/contracts/src/codegen/world/IWorld.sol index 0fd7430af1..a862dd084e 100644 --- a/templates/react/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/react/packages/contracts/src/codegen/world/IWorld.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IIncrementSystem } from "./IIncrementSystem.sol"; diff --git a/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol b/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol index 83839ef23b..1c2acc311c 100644 --- a/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/threejs/packages/contracts/src/codegen/world/IWorld.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IMoveSystem } from "./IMoveSystem.sol"; diff --git a/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol b/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol index 0fd7430af1..a862dd084e 100644 --- a/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol +++ b/templates/vanilla/packages/contracts/src/codegen/world/IWorld.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.21; /* Autogenerated file. Do not edit manually. */ -import { IBaseWorld } from "@latticexyz/world/src/interfaces/IBaseWorld.sol"; +import { IBaseWorld } from "@latticexyz/world/src/codegen/interfaces/IBaseWorld.sol"; import { IIncrementSystem } from "./IIncrementSystem.sol";