From e92730d85f83f525e326b22e3b167aa4ef141384 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 16 Aug 2023 17:59:37 +0100 Subject: [PATCH 1/5] feat(store): change codegen index filenames --- packages/store/ts/codegen/renderTable.ts | 1 - packages/store/ts/codegen/tablegen.ts | 4 ++-- packages/store/ts/codegen/userType.ts | 2 +- packages/store/ts/config/defaults.ts | 3 ++- packages/store/ts/config/storeConfig.ts | 9 ++++++--- packages/store/ts/register/mudConfig.test-d.ts | 3 ++- packages/store/ts/register/typeExtensions.ts | 3 ++- 7 files changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/store/ts/codegen/renderTable.ts b/packages/store/ts/codegen/renderTable.ts index ecc482660c..8769cb9be5 100644 --- a/packages/store/ts/codegen/renderTable.ts +++ b/packages/store/ts/codegen/renderTable.ts @@ -5,7 +5,6 @@ import { renderedSolidityHeader, renderRelativeImports, renderTableId, - renderValueTypeToBytes32, renderWithStore, renderTypeHelpers, RenderDynamicField, diff --git a/packages/store/ts/codegen/tablegen.ts b/packages/store/ts/codegen/tablegen.ts index f154e42d9b..9852081a41 100644 --- a/packages/store/ts/codegen/tablegen.ts +++ b/packages/store/ts/codegen/tablegen.ts @@ -24,12 +24,12 @@ export async function tablegen(config: StoreConfig, outputBaseDirectory: string) // write types to file if (Object.keys(config.enums).length > 0) { - const fullOutputPath = path.join(outputBaseDirectory, `${config.userTypesPath}.sol`); + const fullOutputPath = path.join(outputBaseDirectory, config.userTypesFilename); const output = renderTypesFromConfig(config); await formatAndWriteSolidity(output, fullOutputPath, "Generated types file"); } - const fullOutputPath = path.join(outputBaseDirectory, `Tables.sol`); + const fullOutputPath = path.join(outputBaseDirectory, config.codegenIndexFilename); const output = renderTableIndex(allTableOptions); await formatAndWriteSolidity(output, fullOutputPath, "Generated table index"); } diff --git a/packages/store/ts/codegen/userType.ts b/packages/store/ts/codegen/userType.ts index e23d988d28..f22f2664de 100644 --- a/packages/store/ts/codegen/userType.ts +++ b/packages/store/ts/codegen/userType.ts @@ -61,7 +61,7 @@ export function importForAbiOrUserType( // user types return { symbol: abiOrUserType, - fromPath: config.userTypesPath + ".sol", + fromPath: config.userTypesFilename, usedInPath: usedInDirectory, }; } diff --git a/packages/store/ts/config/defaults.ts b/packages/store/ts/config/defaults.ts index 0aecf902da..c19e154f5a 100644 --- a/packages/store/ts/config/defaults.ts +++ b/packages/store/ts/config/defaults.ts @@ -1,6 +1,7 @@ export const PATH_DEFAULTS = { storeImportPath: "@latticexyz/store/src/", - userTypesPath: "Types", + userTypesFilename: "types.sol", + codegenIndexFilename: "index.sol", codegenDirectory: "codegen", } as const; diff --git a/packages/store/ts/config/storeConfig.ts b/packages/store/ts/config/storeConfig.ts index 6944b4f61b..64aba20a2a 100644 --- a/packages/store/ts/config/storeConfig.ts +++ b/packages/store/ts/config/storeConfig.ts @@ -254,10 +254,12 @@ export type MUDUserConfig< namespace?: string; /** Path for store package imports. Default is "@latticexyz/store/src/" */ storeImportPath?: string; - /** Path to the file where common user types will be generated and imported from. Default is "Types" */ - userTypesPath?: string; + /** Filename where common user types will be generated and imported from. Default is "types.sol" */ + userTypesFilename?: string; /** Path to the directory where generated files will be placed. (Default is "codegen") */ codegenDirectory?: string; + /** Filename where codegen index will be generated. Default is "index.sol" */ + codegenIndexFilename?: string; }; const StoreConfigUnrefined = z @@ -265,8 +267,9 @@ const StoreConfigUnrefined = z namespace: zSelector.default(DEFAULTS.namespace), storeImportPath: z.string().default(PATH_DEFAULTS.storeImportPath), tables: zTablesConfig, - userTypesPath: z.string().default(PATH_DEFAULTS.userTypesPath), + userTypesFilename: z.string().default(PATH_DEFAULTS.userTypesFilename), codegenDirectory: z.string().default(PATH_DEFAULTS.codegenDirectory), + codegenIndexFilename: z.string().default(PATH_DEFAULTS.codegenIndexFilename), }) .merge(zEnumsConfig); diff --git a/packages/store/ts/register/mudConfig.test-d.ts b/packages/store/ts/register/mudConfig.test-d.ts index 3e0c7c39a0..d1bb57248a 100644 --- a/packages/store/ts/register/mudConfig.test-d.ts +++ b/packages/store/ts/register/mudConfig.test-d.ts @@ -50,7 +50,8 @@ describe("mudConfig", () => { }; namespace: ""; storeImportPath: "@latticexyz/store/src/"; - userTypesPath: "Types"; + userTypesFilename: "types.sol"; codegenDirectory: "codegen"; + codegenIndexFilename: "index.sol"; }>(); }); diff --git a/packages/store/ts/register/typeExtensions.ts b/packages/store/ts/register/typeExtensions.ts index 88dd09dee4..e0bb8d20cb 100644 --- a/packages/store/ts/register/typeExtensions.ts +++ b/packages/store/ts/register/typeExtensions.ts @@ -27,8 +27,9 @@ export interface ExpandMUDUserConfig enums: typeof DEFAULTS.enums; namespace: typeof DEFAULTS.namespace; storeImportPath: typeof PATH_DEFAULTS.storeImportPath; - userTypesPath: typeof PATH_DEFAULTS.userTypesPath; + userTypesFilename: typeof PATH_DEFAULTS.userTypesFilename; codegenDirectory: typeof PATH_DEFAULTS.codegenDirectory; + codegenIndexFilename: typeof PATH_DEFAULTS.codegenIndexFilename; } > { tables: ExpandTablesConfig; From 51f1d426e47d89edeba25897b7df814a1a6c569c Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Sun, 17 Sep 2023 10:17:14 +0100 Subject: [PATCH 2/5] types.sol -> common.sol, clean and build everything --- .../src/codegen/{Tables.sol => index.sol} | 0 .../src/systems/NumberListSystem.sol | 2 +- .../minimal/packages/contracts/package.json | 2 +- .../contracts/script/PostDeploy.s.sol | 2 +- .../src/codegen/{Tables.sol => index.sol} | 0 .../src/systems/ChatNamespacedSystem.sol | 2 +- .../contracts/src/systems/ChatSystem.sol | 2 +- .../contracts/src/systems/IncrementSystem.sol | 2 +- .../contracts/src/systems/InventorySystem.sol | 2 +- .../contracts/src/systems/StructSystem.sol | 2 +- .../contracts/test/ChatNamespaced.t.sol | 2 +- .../packages/contracts/test/CounterTest.t.sol | 2 +- .../packages/contracts/test/StructTest.t.sol | 2 +- packages/cli/contracts/src/codegen/common.sol | 13 +++++++++++ packages/cli/contracts/src/codegen/index.sol | 10 ++++++++ .../contracts/src/codegen/tables/Statics.sol | 2 +- packages/cli/contracts/test/Tablegen.t.sol | 4 ++-- packages/store/src/StoreCore.sol | 2 +- packages/store/src/codegen/common.sol | 10 ++++++++ packages/store/src/codegen/index.sol | 12 ++++++++++ .../store/src/codegen/tables/KeyEncoding.sol | 2 +- packages/store/test/Gas.t.sol | 2 +- packages/store/test/KeyEncoding.t.sol | 4 ++-- packages/store/test/Mixed.t.sol | 2 +- packages/store/test/StoreCore.t.sol | 2 +- packages/store/test/Vector2.t.sol | 2 +- packages/store/test/tables/Callbacks.t.sol | 2 +- packages/store/test/tables/StoreHooks.t.sol | 2 +- .../test/tables/StoreHooksColdLoad.t.sol | 2 +- packages/store/ts/config/defaults.ts | 4 ++-- packages/store/ts/config/storeConfig.ts | 2 +- .../store/ts/register/mudConfig.test-d.ts | 2 +- packages/world/src/common.sol | 10 ++++++++ packages/world/src/index.sol | 23 +++++++++++++++++++ .../world/src/modules/core/CoreModule.sol | 2 +- .../StoreRegistrationSystem.sol | 2 +- .../WorldRegistrationSystem.sol | 2 +- .../src/modules/core/tables/ResourceType.sol | 2 +- .../modules/keysintable/KeysInTableModule.sol | 2 +- packages/world/test/World.t.sol | 4 ++-- .../phaser/packages/contracts/package.json | 2 +- .../src/codegen/{Tables.sol => index.sol} | 0 .../contracts/src/systems/IncrementSystem.sol | 2 +- .../packages/contracts/test/CounterTest.t.sol | 2 +- .../react/packages/contracts/package.json | 2 +- .../src/codegen/{Tables.sol => index.sol} | 0 .../contracts/src/systems/IncrementSystem.sol | 2 +- .../packages/contracts/test/CounterTest.t.sol | 2 +- .../threejs/packages/contracts/package.json | 2 +- .../src/codegen/{Tables.sol => index.sol} | 0 .../contracts/src/systems/MoveSystem.sol | 2 +- .../vanilla/packages/contracts/package.json | 2 +- .../src/codegen/{Tables.sol => index.sol} | 0 .../contracts/src/systems/IncrementSystem.sol | 2 +- .../packages/contracts/test/CounterTest.t.sol | 2 +- 55 files changed, 125 insertions(+), 47 deletions(-) rename e2e/packages/contracts/src/codegen/{Tables.sol => index.sol} (100%) rename examples/minimal/packages/contracts/src/codegen/{Tables.sol => index.sol} (100%) create mode 100644 packages/cli/contracts/src/codegen/common.sol create mode 100644 packages/cli/contracts/src/codegen/index.sol create mode 100644 packages/store/src/codegen/common.sol create mode 100644 packages/store/src/codegen/index.sol create mode 100644 packages/world/src/common.sol create mode 100644 packages/world/src/index.sol rename templates/phaser/packages/contracts/src/codegen/{Tables.sol => index.sol} (100%) rename templates/react/packages/contracts/src/codegen/{Tables.sol => index.sol} (100%) rename templates/threejs/packages/contracts/src/codegen/{Tables.sol => index.sol} (100%) rename templates/vanilla/packages/contracts/src/codegen/{Tables.sol => index.sol} (100%) diff --git a/e2e/packages/contracts/src/codegen/Tables.sol b/e2e/packages/contracts/src/codegen/index.sol similarity index 100% rename from e2e/packages/contracts/src/codegen/Tables.sol rename to e2e/packages/contracts/src/codegen/index.sol diff --git a/e2e/packages/contracts/src/systems/NumberListSystem.sol b/e2e/packages/contracts/src/systems/NumberListSystem.sol index cd6d80a58c..6d48adc115 100644 --- a/e2e/packages/contracts/src/systems/NumberListSystem.sol +++ b/e2e/packages/contracts/src/systems/NumberListSystem.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.0; import { StoreSwitch } from "@latticexyz/store/src/StoreSwitch.sol"; import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; import { System } from "@latticexyz/world/src/System.sol"; -import { NumberList, NumberListTableId } from "../codegen/Tables.sol"; +import { NumberList, NumberListTableId } from "../codegen/index.sol"; contract NumberListSystem is System { function set(uint32[] memory list) public { diff --git a/examples/minimal/packages/contracts/package.json b/examples/minimal/packages/contracts/package.json index 5acf110bed..21abadfe78 100644 --- a/examples/minimal/packages/contracts/package.json +++ b/examples/minimal/packages/contracts/package.json @@ -7,7 +7,7 @@ "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts", "build:abi": "forge clean && forge build --skip test script", "build:abi-ts": "mud abi-ts && prettier --write '**/*.abi.json.d.ts'", - "build:mud": "mud tablegen && mud worldgen", + "build:mud": "rimraf src/codegen && mud tablegen && mud worldgen", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", "dev": "pnpm mud dev-contracts", diff --git a/examples/minimal/packages/contracts/script/PostDeploy.s.sol b/examples/minimal/packages/contracts/script/PostDeploy.s.sol index d540e882e2..059758821e 100644 --- a/examples/minimal/packages/contracts/script/PostDeploy.s.sol +++ b/examples/minimal/packages/contracts/script/PostDeploy.s.sol @@ -6,7 +6,7 @@ import { console } from "forge-std/console.sol"; import { ResourceSelector } from "@latticexyz/world/src/ResourceSelector.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; -import { MessageTable, MessageTableTableId } from "../src/codegen/Tables.sol"; +import { MessageTable, MessageTableTableId } from "../src/codegen/index.sol"; import { ChatNamespacedSystem } from "../src/systems/ChatNamespacedSystem.sol"; contract PostDeploy is Script { diff --git a/examples/minimal/packages/contracts/src/codegen/Tables.sol b/examples/minimal/packages/contracts/src/codegen/index.sol similarity index 100% rename from examples/minimal/packages/contracts/src/codegen/Tables.sol rename to examples/minimal/packages/contracts/src/codegen/index.sol diff --git a/examples/minimal/packages/contracts/src/systems/ChatNamespacedSystem.sol b/examples/minimal/packages/contracts/src/systems/ChatNamespacedSystem.sol index 3a7949e086..88a5958cbe 100644 --- a/examples/minimal/packages/contracts/src/systems/ChatNamespacedSystem.sol +++ b/examples/minimal/packages/contracts/src/systems/ChatNamespacedSystem.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { MessageTable } from "../codegen/Tables.sol"; +import { MessageTable } from "../codegen/index.sol"; // This system is supposed to have a different namespace, but otherwise be identical to ChatSystem contract ChatNamespacedSystem is System { diff --git a/examples/minimal/packages/contracts/src/systems/ChatSystem.sol b/examples/minimal/packages/contracts/src/systems/ChatSystem.sol index 8eb4229f47..6091eb92a9 100644 --- a/examples/minimal/packages/contracts/src/systems/ChatSystem.sol +++ b/examples/minimal/packages/contracts/src/systems/ChatSystem.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { MessageTable } from "../codegen/Tables.sol"; +import { MessageTable } from "../codegen/index.sol"; contract ChatSystem is System { function sendMessage(string memory message) public { diff --git a/examples/minimal/packages/contracts/src/systems/IncrementSystem.sol b/examples/minimal/packages/contracts/src/systems/IncrementSystem.sol index e5f0d89c3d..7d805b655d 100644 --- a/examples/minimal/packages/contracts/src/systems/IncrementSystem.sol +++ b/examples/minimal/packages/contracts/src/systems/IncrementSystem.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { console } from "forge-std/console.sol"; import { System } from "@latticexyz/world/src/System.sol"; -import { CounterTable } from "../codegen/Tables.sol"; +import { CounterTable } from "../codegen/index.sol"; contract IncrementSystem is System { error MyCustomError(); diff --git a/examples/minimal/packages/contracts/src/systems/InventorySystem.sol b/examples/minimal/packages/contracts/src/systems/InventorySystem.sol index 914cad3a80..6360871dde 100644 --- a/examples/minimal/packages/contracts/src/systems/InventorySystem.sol +++ b/examples/minimal/packages/contracts/src/systems/InventorySystem.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { Inventory } from "../codegen/Tables.sol"; +import { Inventory } from "../codegen/index.sol"; contract InventorySystem is System { function pickUp(uint32 item, uint32 itemVariant) public { diff --git a/examples/minimal/packages/contracts/src/systems/StructSystem.sol b/examples/minimal/packages/contracts/src/systems/StructSystem.sol index dec8e95a24..5fe1ad91cb 100644 --- a/examples/minimal/packages/contracts/src/systems/StructSystem.sol +++ b/examples/minimal/packages/contracts/src/systems/StructSystem.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { CounterTable } from "../codegen/Tables.sol"; +import { CounterTable } from "../codegen/index.sol"; import { BytesStruct, StringStruct } from "./structs.sol"; contract StructSystem is System { diff --git a/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol b/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol index 0bd179745f..10a4675e22 100644 --- a/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol +++ b/examples/minimal/packages/contracts/test/ChatNamespaced.t.sol @@ -7,7 +7,7 @@ import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/ge import { StoreCore } from "@latticexyz/store/src/StoreCore.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; -import { MessageTable, MessageTableTableId } from "../src/codegen/Tables.sol"; +import { MessageTable, MessageTableTableId } from "../src/codegen/index.sol"; import { IChatNamespacedSystem } from "../src/interfaces/IChatNamespacedSystem.sol"; contract ChatNamespacedTest is MudTest { diff --git a/examples/minimal/packages/contracts/test/CounterTest.t.sol b/examples/minimal/packages/contracts/test/CounterTest.t.sol index 70b201406a..f731279df5 100644 --- a/examples/minimal/packages/contracts/test/CounterTest.t.sol +++ b/examples/minimal/packages/contracts/test/CounterTest.t.sol @@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; -import { CounterTable, CounterTableTableId } from "../src/codegen/Tables.sol"; +import { CounterTable, CounterTableTableId } from "../src/codegen/index.sol"; contract CounterTest is MudTest { IWorld world; diff --git a/examples/minimal/packages/contracts/test/StructTest.t.sol b/examples/minimal/packages/contracts/test/StructTest.t.sol index 637acd2405..87b67846da 100644 --- a/examples/minimal/packages/contracts/test/StructTest.t.sol +++ b/examples/minimal/packages/contracts/test/StructTest.t.sol @@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; -import { CounterTable, CounterTableTableId } from "../src/codegen/Tables.sol"; +import { CounterTable, CounterTableTableId } from "../src/codegen/index.sol"; import { BytesStruct, StringStruct } from "../src/systems/structs.sol"; contract StructTest is MudTest { diff --git a/packages/cli/contracts/src/codegen/common.sol b/packages/cli/contracts/src/codegen/common.sol new file mode 100644 index 0000000000..85fa534462 --- /dev/null +++ b/packages/cli/contracts/src/codegen/common.sol @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +/* Autogenerated file. Do not edit manually. */ +enum Enum1 { + E1, + E2, + E3 +} + +enum Enum2 { + E1 +} diff --git a/packages/cli/contracts/src/codegen/index.sol b/packages/cli/contracts/src/codegen/index.sol new file mode 100644 index 0000000000..de034e0789 --- /dev/null +++ b/packages/cli/contracts/src/codegen/index.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +/* Autogenerated file. Do not edit manually. */ + +import { Statics, StaticsData, StaticsTableId } from "./tables/Statics.sol"; +import { Dynamics1, Dynamics1Data, Dynamics1TableId } from "./tables/Dynamics1.sol"; +import { Dynamics2, Dynamics2Data, Dynamics2TableId } from "./tables/Dynamics2.sol"; +import { Singleton, SingletonTableId } from "./tables/Singleton.sol"; +import { Ephemeral, EphemeralTableId } from "./tables/Ephemeral.sol"; diff --git a/packages/cli/contracts/src/codegen/tables/Statics.sol b/packages/cli/contracts/src/codegen/tables/Statics.sol index 0c74e1b419..b65c03db2f 100644 --- a/packages/cli/contracts/src/codegen/tables/Statics.sol +++ b/packages/cli/contracts/src/codegen/tables/Statics.sol @@ -19,7 +19,7 @@ import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; // Import user types -import { Enum2, Enum1 } from "./../Types.sol"; +import { Enum2, Enum1 } from "./../common.sol"; bytes32 constant _tableId = bytes32(abi.encodePacked(bytes16(""), bytes16("Statics"))); bytes32 constant StaticsTableId = _tableId; diff --git a/packages/cli/contracts/test/Tablegen.t.sol b/packages/cli/contracts/test/Tablegen.t.sol index af41a9f635..d5a5cbc77b 100644 --- a/packages/cli/contracts/test/Tablegen.t.sol +++ b/packages/cli/contracts/test/Tablegen.t.sol @@ -4,9 +4,9 @@ pragma solidity >=0.8.0; import "forge-std/Test.sol"; import { StoreMock } from "@latticexyz/store/test/StoreMock.sol"; -import { Statics, StaticsData, Dynamics1, Dynamics1Data, Dynamics2, Dynamics2Data, Singleton, Ephemeral } from "../src/codegen/Tables.sol"; +import { Statics, StaticsData, Dynamics1, Dynamics1Data, Dynamics2, Dynamics2Data, Singleton, Ephemeral } from "../src/codegen/index.sol"; -import { Enum1, Enum2 } from "../src/codegen/Types.sol"; +import { Enum1, Enum2 } from "../src/codegen/common.sol"; contract TablegenTest is Test, StoreMock { function testStaticsSetAndGet() public { diff --git a/packages/store/src/StoreCore.sol b/packages/store/src/StoreCore.sol index 5c2b974148..8499f231ea 100644 --- a/packages/store/src/StoreCore.sol +++ b/packages/store/src/StoreCore.sol @@ -9,7 +9,7 @@ import { FieldLayout, FieldLayoutLib } from "./FieldLayout.sol"; import { Schema, SchemaLib } from "./Schema.sol"; import { PackedCounter } from "./PackedCounter.sol"; import { Slice, SliceLib } from "./Slice.sol"; -import { StoreHooks, Tables, StoreHooksTableId } from "./codegen/Tables.sol"; +import { StoreHooks, Tables, StoreHooksTableId } from "./codegen/index.sol"; import { IStoreErrors } from "./IStoreErrors.sol"; import { IStoreHook } from "./IStoreHook.sol"; import { StoreSwitch } from "./StoreSwitch.sol"; diff --git a/packages/store/src/codegen/common.sol b/packages/store/src/codegen/common.sol new file mode 100644 index 0000000000..8be6d938c7 --- /dev/null +++ b/packages/store/src/codegen/common.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +/* Autogenerated file. Do not edit manually. */ +enum ExampleEnum { + None, + First, + Second, + Third +} diff --git a/packages/store/src/codegen/index.sol b/packages/store/src/codegen/index.sol new file mode 100644 index 0000000000..64381605a6 --- /dev/null +++ b/packages/store/src/codegen/index.sol @@ -0,0 +1,12 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +/* Autogenerated file. Do not edit manually. */ + +import { StoreHooks, StoreHooksTableId } from "./tables/StoreHooks.sol"; +import { Callbacks, CallbacksTableId } from "./tables/Callbacks.sol"; +import { Tables, TablesData, TablesTableId } from "./tables/Tables.sol"; +import { Hooks } from "./tables/Hooks.sol"; +import { Mixed, MixedData, MixedTableId } from "./tables/Mixed.sol"; +import { Vector2, Vector2Data, Vector2TableId } from "./tables/Vector2.sol"; +import { KeyEncoding, KeyEncodingTableId } from "./tables/KeyEncoding.sol"; diff --git a/packages/store/src/codegen/tables/KeyEncoding.sol b/packages/store/src/codegen/tables/KeyEncoding.sol index 47cc468cb7..013f19d845 100644 --- a/packages/store/src/codegen/tables/KeyEncoding.sol +++ b/packages/store/src/codegen/tables/KeyEncoding.sol @@ -19,7 +19,7 @@ import { Schema, SchemaLib } from "../../Schema.sol"; import { PackedCounter, PackedCounterLib } from "../../PackedCounter.sol"; // Import user types -import { ExampleEnum } from "./../Types.sol"; +import { ExampleEnum } from "./../common.sol"; bytes32 constant _tableId = bytes32(abi.encodePacked(bytes16("mudstore"), bytes16("KeyEncoding"))); bytes32 constant KeyEncodingTableId = _tableId; diff --git a/packages/store/test/Gas.t.sol b/packages/store/test/Gas.t.sol index ea0a6299e9..bd776cd145 100644 --- a/packages/store/test/Gas.t.sol +++ b/packages/store/test/Gas.t.sol @@ -7,7 +7,7 @@ import { Bytes } from "../src/Bytes.sol"; import { SliceLib } from "../src/Slice.sol"; import { Storage } from "../src/Storage.sol"; import { PackedCounter } from "../src/PackedCounter.sol"; -import { Mixed, MixedData } from "../src/codegen/Tables.sol"; +import { Mixed, MixedData } from "../src/codegen/index.sol"; contract SomeContract { function doSomethingWithBytes(bytes memory data) public {} diff --git a/packages/store/test/KeyEncoding.t.sol b/packages/store/test/KeyEncoding.t.sol index 1c959ba75b..f1b91ae49b 100644 --- a/packages/store/test/KeyEncoding.t.sol +++ b/packages/store/test/KeyEncoding.t.sol @@ -3,8 +3,8 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; -import { KeyEncoding, KeyEncodingTableId } from "../src/codegen/Tables.sol"; -import { ExampleEnum } from "../src/codegen/Types.sol"; +import { KeyEncoding, KeyEncodingTableId } from "../src/codegen/index.sol"; +import { ExampleEnum } from "../src/codegen/common.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreMock } from "../test/StoreMock.sol"; import { FieldLayout } from "../src/FieldLayout.sol"; diff --git a/packages/store/test/Mixed.t.sol b/packages/store/test/Mixed.t.sol index b38f714d53..453c405d4c 100644 --- a/packages/store/test/Mixed.t.sol +++ b/packages/store/test/Mixed.t.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; -import { Mixed, MixedData, MixedTableId } from "../src/codegen/Tables.sol"; +import { Mixed, MixedData, MixedTableId } from "../src/codegen/index.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreMock } from "../test/StoreMock.sol"; import { FieldLayout } from "../src/FieldLayout.sol"; diff --git a/packages/store/test/StoreCore.t.sol b/packages/store/test/StoreCore.t.sol index fc1f25134e..b133420bb0 100644 --- a/packages/store/test/StoreCore.t.sol +++ b/packages/store/test/StoreCore.t.sol @@ -14,7 +14,7 @@ import { StoreMock } from "../test/StoreMock.sol"; import { IStoreErrors } from "../src/IStoreErrors.sol"; import { IStore } from "../src/IStore.sol"; import { StoreSwitch } from "../src/StoreSwitch.sol"; -import { Tables, TablesTableId } from "../src/codegen/Tables.sol"; +import { Tables, TablesTableId } from "../src/codegen/index.sol"; import { FieldLayoutEncodeHelper } from "./FieldLayoutEncodeHelper.sol"; import { StoreHookLib } from "../src/StoreHook.sol"; import { SchemaEncodeHelper } from "./SchemaEncodeHelper.sol"; diff --git a/packages/store/test/Vector2.t.sol b/packages/store/test/Vector2.t.sol index 769054a76a..3c6fe3541a 100644 --- a/packages/store/test/Vector2.t.sol +++ b/packages/store/test/Vector2.t.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; -import { Vector2, Vector2Data, Vector2TableId } from "../src/codegen/Tables.sol"; +import { Vector2, Vector2Data, Vector2TableId } from "../src/codegen/index.sol"; import { StoreCore } from "../src/StoreCore.sol"; import { StoreMock } from "../test/StoreMock.sol"; import { FieldLayout } from "../src/FieldLayout.sol"; diff --git a/packages/store/test/tables/Callbacks.t.sol b/packages/store/test/tables/Callbacks.t.sol index dacf396c31..e7f40e3a78 100644 --- a/packages/store/test/tables/Callbacks.t.sol +++ b/packages/store/test/tables/Callbacks.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { StoreMock } from "../../test/StoreMock.sol"; -import { Callbacks } from "../../src/codegen/Tables.sol"; +import { Callbacks } from "../../src/codegen/index.sol"; contract CallbacksTest is Test, GasReporter, StoreMock { function testSetAndGet() public { diff --git a/packages/store/test/tables/StoreHooks.t.sol b/packages/store/test/tables/StoreHooks.t.sol index 5960dde364..e6fa64dd85 100644 --- a/packages/store/test/tables/StoreHooks.t.sol +++ b/packages/store/test/tables/StoreHooks.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { StoreMock } from "../../test/StoreMock.sol"; -import { StoreHooks } from "../../src/codegen/Tables.sol"; +import { StoreHooks } from "../../src/codegen/index.sol"; contract StoreHooksTest is Test, GasReporter, StoreMock { function testTable() public { diff --git a/packages/store/test/tables/StoreHooksColdLoad.t.sol b/packages/store/test/tables/StoreHooksColdLoad.t.sol index 07513c2c54..2943927e51 100644 --- a/packages/store/test/tables/StoreHooksColdLoad.t.sol +++ b/packages/store/test/tables/StoreHooksColdLoad.t.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.0; import { Test } from "forge-std/Test.sol"; import { GasReporter } from "@latticexyz/gas-report/src/GasReporter.sol"; import { StoreMock } from "../../test/StoreMock.sol"; -import { StoreHooks } from "../../src/codegen/Tables.sol"; +import { StoreHooks } from "../../src/codegen/index.sol"; contract StoreHooksColdLoadTest is Test, GasReporter, StoreMock { bytes21[] hooks; diff --git a/packages/store/ts/config/defaults.ts b/packages/store/ts/config/defaults.ts index c19e154f5a..0393830547 100644 --- a/packages/store/ts/config/defaults.ts +++ b/packages/store/ts/config/defaults.ts @@ -1,8 +1,8 @@ export const PATH_DEFAULTS = { storeImportPath: "@latticexyz/store/src/", - userTypesFilename: "types.sol", - codegenIndexFilename: "index.sol", + userTypesFilename: "common.sol", codegenDirectory: "codegen", + codegenIndexFilename: "index.sol", } as const; export const DEFAULTS = { diff --git a/packages/store/ts/config/storeConfig.ts b/packages/store/ts/config/storeConfig.ts index 502559f87c..2795a266ff 100644 --- a/packages/store/ts/config/storeConfig.ts +++ b/packages/store/ts/config/storeConfig.ts @@ -261,7 +261,7 @@ export type MUDUserConfig< namespace?: string; /** Path for store package imports. Default is "@latticexyz/store/src/" */ storeImportPath?: string; - /** Filename where common user types will be generated and imported from. Default is "types.sol" */ + /** Filename where common user types will be generated and imported from. Default is "common.sol" */ userTypesFilename?: string; /** Path to the directory where generated files will be placed. (Default is "codegen") */ codegenDirectory?: string; diff --git a/packages/store/ts/register/mudConfig.test-d.ts b/packages/store/ts/register/mudConfig.test-d.ts index 1a93a9db56..e310c93804 100644 --- a/packages/store/ts/register/mudConfig.test-d.ts +++ b/packages/store/ts/register/mudConfig.test-d.ts @@ -50,7 +50,7 @@ describe("mudConfig", () => { }; namespace: ""; storeImportPath: "@latticexyz/store/src/"; - userTypesFilename: "types.sol"; + userTypesFilename: "common.sol"; codegenDirectory: "codegen"; codegenIndexFilename: "index.sol"; }>(); diff --git a/packages/world/src/common.sol b/packages/world/src/common.sol new file mode 100644 index 0000000000..6c4b0ff193 --- /dev/null +++ b/packages/world/src/common.sol @@ -0,0 +1,10 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +/* Autogenerated file. Do not edit manually. */ +enum Resource { + NONE, + NAMESPACE, + TABLE, + SYSTEM +} diff --git a/packages/world/src/index.sol b/packages/world/src/index.sol new file mode 100644 index 0000000000..021a7371bf --- /dev/null +++ b/packages/world/src/index.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.0; + +/* Autogenerated file. Do not edit manually. */ + +import { NamespaceOwner, NamespaceOwnerTableId } from "./tables/NamespaceOwner.sol"; +import { ResourceAccess, ResourceAccessTableId } from "./tables/ResourceAccess.sol"; +import { InstalledModules, InstalledModulesTableId } from "./tables/InstalledModules.sol"; +import { Delegations, DelegationsTableId } from "./tables/Delegations.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 { ResourceType, ResourceTypeTableId } from "./modules/core/tables/ResourceType.sol"; +import { FunctionSelectors, FunctionSelectorsTableId } from "./modules/core/tables/FunctionSelectors.sol"; +import { KeysWithValue } from "./modules/keyswithvalue/tables/KeysWithValue.sol"; +import { KeysInTable, KeysInTableData, KeysInTableTableId } from "./modules/keysintable/tables/KeysInTable.sol"; +import { UsedKeysIndex, UsedKeysIndexTableId } from "./modules/keysintable/tables/UsedKeysIndex.sol"; +import { UniqueEntity } from "./modules/uniqueentity/tables/UniqueEntity.sol"; +import { CallboundDelegations, CallboundDelegationsTableId } from "./modules/std-delegations/tables/CallboundDelegations.sol"; +import { TimeboundDelegations, TimeboundDelegationsTableId } from "./modules/std-delegations/tables/TimeboundDelegations.sol"; +import { Bool } from "./../test/tables/Bool.sol"; +import { AddressArray } from "./../test/tables/AddressArray.sol"; diff --git a/packages/world/src/modules/core/CoreModule.sol b/packages/world/src/modules/core/CoreModule.sol index a9712b4576..bbdbdabce1 100644 --- a/packages/world/src/modules/core/CoreModule.sol +++ b/packages/world/src/modules/core/CoreModule.sol @@ -3,7 +3,7 @@ pragma solidity >=0.8.0; import { WorldContextProvider } from "../../WorldContext.sol"; import { ROOT_NAMESPACE } from "../../constants.sol"; -import { Resource } from "../../Types.sol"; +import { Resource } from "../../common.sol"; import { Module } from "../../Module.sol"; import { IBaseWorld } from "../../interfaces/IBaseWorld.sol"; diff --git a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol index eacfff6087..e7c1bb4b37 100644 --- a/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/StoreRegistrationSystem.sol @@ -8,7 +8,7 @@ import { Schema } from "@latticexyz/store/src/Schema.sol"; import { System } from "../../../System.sol"; import { ResourceSelector } from "../../../ResourceSelector.sol"; -import { Resource } from "../../../Types.sol"; +import { Resource } from "../../../common.sol"; import { ROOT_NAMESPACE, ROOT_NAME } from "../../../constants.sol"; import { AccessControl } from "../../../AccessControl.sol"; import { requireInterface } from "../../../requireInterface.sol"; diff --git a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol index 3502e5bd6c..9784b6c1a8 100644 --- a/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol +++ b/packages/world/src/modules/core/implementations/WorldRegistrationSystem.sol @@ -6,7 +6,7 @@ import { Hook, HookLib } from "@latticexyz/store/src/Hook.sol"; import { System } from "../../../System.sol"; import { WorldContextConsumer, WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "../../../WorldContext.sol"; import { ResourceSelector } from "../../../ResourceSelector.sol"; -import { Resource } from "../../../Types.sol"; +import { Resource } from "../../../common.sol"; import { SystemCall } from "../../../SystemCall.sol"; import { SystemHookLib } from "../../../SystemHook.sol"; import { ROOT_NAMESPACE, ROOT_NAME, UNLIMITED_DELEGATION } from "../../../constants.sol"; diff --git a/packages/world/src/modules/core/tables/ResourceType.sol b/packages/world/src/modules/core/tables/ResourceType.sol index 0fb6a1c293..141d9b1bb5 100644 --- a/packages/world/src/modules/core/tables/ResourceType.sol +++ b/packages/world/src/modules/core/tables/ResourceType.sol @@ -19,7 +19,7 @@ import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter, PackedCounterLib } from "@latticexyz/store/src/PackedCounter.sol"; // Import user types -import { Resource } from "./../../../Types.sol"; +import { Resource } from "./../../../common.sol"; bytes32 constant _tableId = bytes32(abi.encodePacked(bytes16(""), bytes16("ResourceType"))); bytes32 constant ResourceTypeTableId = _tableId; diff --git a/packages/world/src/modules/keysintable/KeysInTableModule.sol b/packages/world/src/modules/keysintable/KeysInTableModule.sol index f04834d110..c664bdd2a8 100644 --- a/packages/world/src/modules/keysintable/KeysInTableModule.sol +++ b/packages/world/src/modules/keysintable/KeysInTableModule.sol @@ -4,7 +4,7 @@ pragma solidity >=0.8.0; import { StoreHookLib } from "@latticexyz/store/src/StoreHook.sol"; import { ResourceType } from "../core/tables/ResourceType.sol"; -import { Resource } from "../../Types.sol"; +import { Resource } from "../../common.sol"; import { Module } from "../../Module.sol"; import { IBaseWorld } from "../../interfaces/IBaseWorld.sol"; diff --git a/packages/world/test/World.t.sol b/packages/world/test/World.t.sol index 6a3406fe63..aa38061c7c 100644 --- a/packages/world/test/World.t.sol +++ b/packages/world/test/World.t.sol @@ -14,7 +14,7 @@ import { FieldLayoutEncodeHelper } from "@latticexyz/store/test/FieldLayoutEncod import { Schema, SchemaLib } from "@latticexyz/store/src/Schema.sol"; import { PackedCounter } from "@latticexyz/store/src/PackedCounter.sol"; import { SchemaEncodeHelper } from "@latticexyz/store/test/SchemaEncodeHelper.sol"; -import { Tables, TablesTableId } from "@latticexyz/store/src/codegen/Tables.sol"; +import { Tables, TablesTableId } from "@latticexyz/store/src/codegen/index.sol"; import { EncodeArray } from "@latticexyz/store/src/tightcoder/EncodeArray.sol"; import { StoreHookLib } from "@latticexyz/store/src/StoreHook.sol"; import { RevertSubscriber } from "@latticexyz/store/test/RevertSubscriber.sol"; @@ -25,7 +25,7 @@ import { World } from "../src/World.sol"; import { System } from "../src/System.sol"; import { ResourceSelector } from "../src/ResourceSelector.sol"; import { ROOT_NAMESPACE, ROOT_NAME, UNLIMITED_DELEGATION } from "../src/constants.sol"; -import { Resource } from "../src/Types.sol"; +import { Resource } from "../src/common.sol"; import { WorldContextProvider, WORLD_CONTEXT_CONSUMER_INTERFACE_ID } from "../src/WorldContext.sol"; import { SystemHookLib, SystemHook } from "../src/SystemHook.sol"; import { Module, MODULE_INTERFACE_ID } from "../src/Module.sol"; diff --git a/templates/phaser/packages/contracts/package.json b/templates/phaser/packages/contracts/package.json index d7c3b00abf..c3d56ce47e 100644 --- a/templates/phaser/packages/contracts/package.json +++ b/templates/phaser/packages/contracts/package.json @@ -7,7 +7,7 @@ "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts", "build:abi": "forge clean && forge build --skip test script", "build:abi-ts": "mud abi-ts && prettier --write '**/*.abi.json.d.ts'", - "build:mud": "mud tablegen && mud worldgen", + "build:mud": "rimraf src/codegen && mud tablegen && mud worldgen", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", "dev": "pnpm mud dev-contracts", diff --git a/templates/phaser/packages/contracts/src/codegen/Tables.sol b/templates/phaser/packages/contracts/src/codegen/index.sol similarity index 100% rename from templates/phaser/packages/contracts/src/codegen/Tables.sol rename to templates/phaser/packages/contracts/src/codegen/index.sol diff --git a/templates/phaser/packages/contracts/src/systems/IncrementSystem.sol b/templates/phaser/packages/contracts/src/systems/IncrementSystem.sol index 1075d5999e..db5a2673a2 100644 --- a/templates/phaser/packages/contracts/src/systems/IncrementSystem.sol +++ b/templates/phaser/packages/contracts/src/systems/IncrementSystem.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { Counter } from "../codegen/Tables.sol"; +import { Counter } from "../codegen/index.sol"; contract IncrementSystem is System { function increment() public returns (uint32) { diff --git a/templates/phaser/packages/contracts/test/CounterTest.t.sol b/templates/phaser/packages/contracts/test/CounterTest.t.sol index 5c16ef92af..efe11c5126 100644 --- a/templates/phaser/packages/contracts/test/CounterTest.t.sol +++ b/templates/phaser/packages/contracts/test/CounterTest.t.sol @@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; -import { Counter, CounterTableId } from "../src/codegen/Tables.sol"; +import { Counter, CounterTableId } from "../src/codegen/index.sol"; contract CounterTest is MudTest { IWorld public world; diff --git a/templates/react/packages/contracts/package.json b/templates/react/packages/contracts/package.json index d7c3b00abf..c3d56ce47e 100644 --- a/templates/react/packages/contracts/package.json +++ b/templates/react/packages/contracts/package.json @@ -7,7 +7,7 @@ "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts", "build:abi": "forge clean && forge build --skip test script", "build:abi-ts": "mud abi-ts && prettier --write '**/*.abi.json.d.ts'", - "build:mud": "mud tablegen && mud worldgen", + "build:mud": "rimraf src/codegen && mud tablegen && mud worldgen", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", "dev": "pnpm mud dev-contracts", diff --git a/templates/react/packages/contracts/src/codegen/Tables.sol b/templates/react/packages/contracts/src/codegen/index.sol similarity index 100% rename from templates/react/packages/contracts/src/codegen/Tables.sol rename to templates/react/packages/contracts/src/codegen/index.sol diff --git a/templates/react/packages/contracts/src/systems/IncrementSystem.sol b/templates/react/packages/contracts/src/systems/IncrementSystem.sol index 1075d5999e..db5a2673a2 100644 --- a/templates/react/packages/contracts/src/systems/IncrementSystem.sol +++ b/templates/react/packages/contracts/src/systems/IncrementSystem.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { Counter } from "../codegen/Tables.sol"; +import { Counter } from "../codegen/index.sol"; contract IncrementSystem is System { function increment() public returns (uint32) { diff --git a/templates/react/packages/contracts/test/CounterTest.t.sol b/templates/react/packages/contracts/test/CounterTest.t.sol index 5c16ef92af..efe11c5126 100644 --- a/templates/react/packages/contracts/test/CounterTest.t.sol +++ b/templates/react/packages/contracts/test/CounterTest.t.sol @@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; -import { Counter, CounterTableId } from "../src/codegen/Tables.sol"; +import { Counter, CounterTableId } from "../src/codegen/index.sol"; contract CounterTest is MudTest { IWorld public world; diff --git a/templates/threejs/packages/contracts/package.json b/templates/threejs/packages/contracts/package.json index d7c3b00abf..c3d56ce47e 100644 --- a/templates/threejs/packages/contracts/package.json +++ b/templates/threejs/packages/contracts/package.json @@ -7,7 +7,7 @@ "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts", "build:abi": "forge clean && forge build --skip test script", "build:abi-ts": "mud abi-ts && prettier --write '**/*.abi.json.d.ts'", - "build:mud": "mud tablegen && mud worldgen", + "build:mud": "rimraf src/codegen && mud tablegen && mud worldgen", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", "dev": "pnpm mud dev-contracts", diff --git a/templates/threejs/packages/contracts/src/codegen/Tables.sol b/templates/threejs/packages/contracts/src/codegen/index.sol similarity index 100% rename from templates/threejs/packages/contracts/src/codegen/Tables.sol rename to templates/threejs/packages/contracts/src/codegen/index.sol diff --git a/templates/threejs/packages/contracts/src/systems/MoveSystem.sol b/templates/threejs/packages/contracts/src/systems/MoveSystem.sol index fe2de0c34b..c90fa1c107 100644 --- a/templates/threejs/packages/contracts/src/systems/MoveSystem.sol +++ b/templates/threejs/packages/contracts/src/systems/MoveSystem.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { Position, PositionData } from "../codegen/Tables.sol"; +import { Position, PositionData } from "../codegen/index.sol"; function distance(PositionData memory a, PositionData memory b) pure returns (int32) { int32 deltaX = a.x > b.x ? a.x - b.x : b.x - a.x; diff --git a/templates/vanilla/packages/contracts/package.json b/templates/vanilla/packages/contracts/package.json index d7c3b00abf..c3d56ce47e 100644 --- a/templates/vanilla/packages/contracts/package.json +++ b/templates/vanilla/packages/contracts/package.json @@ -7,7 +7,7 @@ "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts", "build:abi": "forge clean && forge build --skip test script", "build:abi-ts": "mud abi-ts && prettier --write '**/*.abi.json.d.ts'", - "build:mud": "mud tablegen && mud worldgen", + "build:mud": "rimraf src/codegen && mud tablegen && mud worldgen", "deploy:local": "pnpm run build && mud deploy", "deploy:testnet": "pnpm run build && mud deploy --profile=lattice-testnet", "dev": "pnpm mud dev-contracts", diff --git a/templates/vanilla/packages/contracts/src/codegen/Tables.sol b/templates/vanilla/packages/contracts/src/codegen/index.sol similarity index 100% rename from templates/vanilla/packages/contracts/src/codegen/Tables.sol rename to templates/vanilla/packages/contracts/src/codegen/index.sol diff --git a/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol b/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol index 1075d5999e..db5a2673a2 100644 --- a/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol +++ b/templates/vanilla/packages/contracts/src/systems/IncrementSystem.sol @@ -2,7 +2,7 @@ pragma solidity >=0.8.0; import { System } from "@latticexyz/world/src/System.sol"; -import { Counter } from "../codegen/Tables.sol"; +import { Counter } from "../codegen/index.sol"; contract IncrementSystem is System { function increment() public returns (uint32) { diff --git a/templates/vanilla/packages/contracts/test/CounterTest.t.sol b/templates/vanilla/packages/contracts/test/CounterTest.t.sol index 5c16ef92af..efe11c5126 100644 --- a/templates/vanilla/packages/contracts/test/CounterTest.t.sol +++ b/templates/vanilla/packages/contracts/test/CounterTest.t.sol @@ -6,7 +6,7 @@ import { MudTest } from "@latticexyz/world/test/MudTest.t.sol"; import { getKeysWithValue } from "@latticexyz/world/src/modules/keyswithvalue/getKeysWithValue.sol"; import { IWorld } from "../src/codegen/world/IWorld.sol"; -import { Counter, CounterTableId } from "../src/codegen/Tables.sol"; +import { Counter, CounterTableId } from "../src/codegen/index.sol"; contract CounterTest is MudTest { IWorld public world; From 0527ec83bce8419c99e8fab742969bed100e83ac Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Sun, 17 Sep 2023 12:03:14 +0100 Subject: [PATCH 3/5] clean --- packages/store/src/codegen/Tables.sol | 12 ------------ packages/store/src/codegen/Types.sol | 10 ---------- 2 files changed, 22 deletions(-) delete mode 100644 packages/store/src/codegen/Tables.sol delete mode 100644 packages/store/src/codegen/Types.sol diff --git a/packages/store/src/codegen/Tables.sol b/packages/store/src/codegen/Tables.sol deleted file mode 100644 index 64381605a6..0000000000 --- a/packages/store/src/codegen/Tables.sol +++ /dev/null @@ -1,12 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -/* Autogenerated file. Do not edit manually. */ - -import { StoreHooks, StoreHooksTableId } from "./tables/StoreHooks.sol"; -import { Callbacks, CallbacksTableId } from "./tables/Callbacks.sol"; -import { Tables, TablesData, TablesTableId } from "./tables/Tables.sol"; -import { Hooks } from "./tables/Hooks.sol"; -import { Mixed, MixedData, MixedTableId } from "./tables/Mixed.sol"; -import { Vector2, Vector2Data, Vector2TableId } from "./tables/Vector2.sol"; -import { KeyEncoding, KeyEncodingTableId } from "./tables/KeyEncoding.sol"; diff --git a/packages/store/src/codegen/Types.sol b/packages/store/src/codegen/Types.sol deleted file mode 100644 index 8be6d938c7..0000000000 --- a/packages/store/src/codegen/Types.sol +++ /dev/null @@ -1,10 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; - -/* Autogenerated file. Do not edit manually. */ -enum ExampleEnum { - None, - First, - Second, - Third -} From b022ca30ab1a9e35bb9fe550a6cf1b5566b8b401 Mon Sep 17 00:00:00 2001 From: alvarius Date: Sun, 17 Sep 2023 14:52:52 +0100 Subject: [PATCH 4/5] Create shy-monkeys-wonder.md --- .changeset/shy-monkeys-wonder.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .changeset/shy-monkeys-wonder.md diff --git a/.changeset/shy-monkeys-wonder.md b/.changeset/shy-monkeys-wonder.md new file mode 100644 index 0000000000..37d33ff761 --- /dev/null +++ b/.changeset/shy-monkeys-wonder.md @@ -0,0 +1,29 @@ +--- +"@latticexyz/cli": major +"@latticexyz/store": major +"create-mud": patch +--- + +Renamed the default filename of generated user types from `Types.sol` to `common.sol` and the default filename of the generated table index file from `Tables.sol` to `index.sol`. + +Both can be overridden via the MUD config: + +```ts +export default mudConfig({ + /** Filename where common user types will be generated and imported from. */ + userTypesFilename: "common.sol", + /** Filename where codegen index will be generated. */ + codegenIndexFilename: "index.sol" +}); +``` + +Note: `userTypesFilename` was renamed from `userTypesPath` and `.sol` is not appended automatically anymore but needs to be part of the provided filename. + +To update your existing project, update all imports from `Tables.sol` to `index.sol` and all imports from `Types.sol` to `common.sol`, or override the defaults in your MUD config to the previous values. + +```diff +- import { Counter } from "../src/codegen/Tables.sol"; ++ import { Counter } from "../src/codegen/index.sol"; +- import { ExampleEnum } from "../src/codegen/Types.sol"; ++ import { ExampleEnum } from "../src/codegen/common.sol"; +``` From 4626d43de2d2918c29461d4185828edb63da71df Mon Sep 17 00:00:00 2001 From: alvrs Date: Sun, 17 Sep 2023 15:21:35 +0100 Subject: [PATCH 5/5] prettier --- .changeset/shy-monkeys-wonder.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/shy-monkeys-wonder.md b/.changeset/shy-monkeys-wonder.md index 37d33ff761..9105087ee5 100644 --- a/.changeset/shy-monkeys-wonder.md +++ b/.changeset/shy-monkeys-wonder.md @@ -13,7 +13,7 @@ export default mudConfig({ /** Filename where common user types will be generated and imported from. */ userTypesFilename: "common.sol", /** Filename where codegen index will be generated. */ - codegenIndexFilename: "index.sol" + codegenIndexFilename: "index.sol", }); ```