diff --git a/packages/store/ts/config/v2/compat.test.ts b/packages/store/ts/config/v2/compat.test.ts index 5a4c19b21a..61d5c5d983 100644 --- a/packages/store/ts/config/v2/compat.test.ts +++ b/packages/store/ts/config/v2/compat.test.ts @@ -8,8 +8,8 @@ import { Store } from "./output"; describe("configToV1", () => { it("should transform the broad v2 output to the broad v1 output", () => { - attest>(); - attest, StoreConfigV1>(); + attest, "v2">>(); + attest, "v2">, StoreConfigV1>(); }); it("should transform a v2 store config output to the v1 config output", () => { @@ -89,7 +89,10 @@ describe("configToV1", () => { }, }); - attest(storeToV1(configV2)).equals(configV1); - attest>(configV1); + const { v2, ...v1FromV2 } = storeToV1(configV2); + + attest(v1FromV2).equals(configV1); + attest(configV1).equals(v1FromV2); + attest(v2).equals(configV2); }); }); diff --git a/packages/store/ts/config/v2/compat.ts b/packages/store/ts/config/v2/compat.ts index 633e7c7080..45aba9bd5a 100644 --- a/packages/store/ts/config/v2/compat.ts +++ b/packages/store/ts/config/v2/compat.ts @@ -15,18 +15,19 @@ export type storeToV1 = store extends Store }; storeImportPath: store["codegen"]["storeImportPath"]; userTypesFilename: store["codegen"]["userTypesFilename"]; - codegenDirectory: store["codegen"]["codegenDirectory"]; - codegenIndexFilename: store["codegen"]["codegenIndexFilename"]; + codegenDirectory: store["codegen"]["outputDirectory"]; + codegenIndexFilename: store["codegen"]["indexFilename"]; tables: { [key in keyof store["tables"] as store["tables"][key]["name"]]: tableToV1; }; + v2: store; } : never; type schemaToV1 = { [key in keyof schema]: schema[key]["internalType"] }; export type tableToV1 = { - directory: table["codegen"]["directory"]; + directory: table["codegen"]["outputDirectory"]; dataStruct: table["codegen"]["dataStruct"]; tableIdArgument: table["codegen"]["tableIdArgument"]; storeArgument: table["codegen"]["storeArgument"]; @@ -47,7 +48,7 @@ export function storeToV1(store: conform): storeToV1 return [ table.name, { - directory: table.codegen.directory, + directory: table.codegen.outputDirectory, dataStruct: table.codegen.dataStruct, tableIdArgument: table.codegen.tableIdArgument, storeArgument: table.codegen.storeArgument, @@ -66,8 +67,9 @@ export function storeToV1(store: conform): storeToV1 userTypes: resolvedUserTypes, storeImportPath: store.codegen.storeImportPath, userTypesFilename: store.codegen.userTypesFilename, - codegenDirectory: store.codegen.codegenDirectory, - codegenIndexFilename: store.codegen.codegenIndexFilename, + codegenDirectory: store.codegen.outputDirectory, + codegenIndexFilename: store.codegen.indexFilename, tables: resolvedTables, + v2: store, } as unknown as storeToV1; } diff --git a/packages/store/ts/config/v2/defaults.ts b/packages/store/ts/config/v2/defaults.ts index 55ee159bf7..5da3c10ffe 100644 --- a/packages/store/ts/config/v2/defaults.ts +++ b/packages/store/ts/config/v2/defaults.ts @@ -1,16 +1,20 @@ export const CODEGEN_DEFAULTS = { storeImportPath: "@latticexyz/store/src/", userTypesFilename: "common.sol", - codegenDirectory: "codegen", - codegenIndexFilename: "index.sol", + outputDirectory: "codegen", + indexFilename: "index.sol", } as const; export const TABLE_CODEGEN_DEFAULTS = { - directory: "tables", + outputDirectory: "tables", tableIdArgument: false, storeArgument: false, } as const; +export const TABLE_DEPLOY_DEFAULTS = { + disabled: false, +} as const; + export const TABLE_DEFAULTS = { namespace: "", type: "table", diff --git a/packages/store/ts/config/v2/input.ts b/packages/store/ts/config/v2/input.ts index 1bda537786..c75f58c088 100644 --- a/packages/store/ts/config/v2/input.ts +++ b/packages/store/ts/config/v2/input.ts @@ -1,5 +1,5 @@ import { Hex } from "viem"; -import { Codegen, Enums, TableCodegen, UserTypes } from "./output"; +import { Codegen, Enums, TableCodegen, TableDeploy, UserTypes } from "./output"; import { Scope } from "./scope"; export type SchemaInput = { @@ -18,6 +18,7 @@ export type TableInput = { readonly namespace?: string; readonly type?: "table" | "offchainTable"; readonly codegen?: Partial; + readonly deploy?: Partial; }; export type TablesInput = { diff --git a/packages/store/ts/config/v2/output.ts b/packages/store/ts/config/v2/output.ts index 3bec5d60a3..05dc8e8c57 100644 --- a/packages/store/ts/config/v2/output.ts +++ b/packages/store/ts/config/v2/output.ts @@ -11,21 +11,26 @@ export type Enums = { }; export type TableCodegen = { - readonly directory: string; + readonly outputDirectory: string; readonly tableIdArgument: boolean; readonly storeArgument: boolean; readonly dataStruct: boolean; }; +export type TableDeploy = { + readonly disabled: boolean; +}; + export type Table = BaseTable & { readonly codegen: TableCodegen; + readonly deploy: TableDeploy; }; export type Codegen = { readonly storeImportPath: string; readonly userTypesFilename: string; - readonly codegenDirectory: string; - readonly codegenIndexFilename: string; + readonly outputDirectory: string; + readonly indexFilename: string; }; export type Store = { diff --git a/packages/store/ts/config/v2/store.test.ts b/packages/store/ts/config/v2/store.test.ts index 805c700b5f..21b5ef938c 100644 --- a/packages/store/ts/config/v2/store.test.ts +++ b/packages/store/ts/config/v2/store.test.ts @@ -2,7 +2,7 @@ import { describe, it } from "vitest"; import { defineStore } from "./store"; import { attest } from "@arktype/attest"; import { resourceToHex } from "@latticexyz/common"; -import { CODEGEN_DEFAULTS, TABLE_CODEGEN_DEFAULTS } from "./defaults"; +import { CODEGEN_DEFAULTS, TABLE_CODEGEN_DEFAULTS, TABLE_DEPLOY_DEFAULTS } from "./defaults"; import { Store } from "./output"; describe("defineStore", () => { @@ -39,6 +39,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -87,6 +88,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { @@ -134,6 +136,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -182,6 +185,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, Second: { tableId: resourceToHex({ type: "table", namespace: "", name: "Second" }), @@ -204,6 +208,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -256,6 +261,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, Second: { tableId: resourceToHex({ type: "table", namespace: "", name: "Second" }), @@ -278,6 +284,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { @@ -386,6 +393,7 @@ describe("defineStore", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { diff --git a/packages/store/ts/config/v2/storeWithShorthands.test.ts b/packages/store/ts/config/v2/storeWithShorthands.test.ts index 762f9f6ef7..c25fd9fc7b 100644 --- a/packages/store/ts/config/v2/storeWithShorthands.test.ts +++ b/packages/store/ts/config/v2/storeWithShorthands.test.ts @@ -2,7 +2,7 @@ import { describe, it } from "vitest"; import { defineStoreWithShorthands } from "./storeWithShorthands"; import { attest } from "@arktype/attest"; import { resourceToHex } from "@latticexyz/common"; -import { CODEGEN_DEFAULTS, TABLE_CODEGEN_DEFAULTS } from "./defaults"; +import { CODEGEN_DEFAULTS, TABLE_CODEGEN_DEFAULTS, TABLE_DEPLOY_DEFAULTS } from "./defaults"; import { defineStore } from "./store"; describe("defineStoreWithShorthands", () => { @@ -27,6 +27,7 @@ describe("defineStoreWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -62,6 +63,7 @@ describe("defineStoreWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { CustomType: { type: "address", filePath: "path/to/file" } }, @@ -101,6 +103,7 @@ describe("defineStoreWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -140,6 +143,7 @@ describe("defineStoreWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, diff --git a/packages/store/ts/config/v2/table.test.ts b/packages/store/ts/config/v2/table.test.ts index 21cff20396..a385fd3812 100644 --- a/packages/store/ts/config/v2/table.test.ts +++ b/packages/store/ts/config/v2/table.test.ts @@ -2,7 +2,7 @@ import { attest } from "@arktype/attest"; import { describe, it } from "vitest"; import { getStaticAbiTypeKeys, AbiTypeScope, extendScope } from "./scope"; import { validateKeys, defineTable } from "./table"; -import { TABLE_CODEGEN_DEFAULTS } from "./defaults"; +import { TABLE_CODEGEN_DEFAULTS, TABLE_DEPLOY_DEFAULTS } from "./defaults"; import { resourceToHex } from "@latticexyz/common"; import { getKeySchema, getValueSchema } from "@latticexyz/protocol-parser/internal"; @@ -65,6 +65,7 @@ describe("resolveTable", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, } as const; attest(table).equals(expected); @@ -88,6 +89,7 @@ describe("resolveTable", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, } as const; attest(table).equals(expected); @@ -117,11 +119,25 @@ describe("resolveTable", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, } as const; attest(table).equals(expected); }); + it("should pass through deploy config", () => { + const table = defineTable({ + schema: { id: "address" }, + key: ["id"], + name: "", + deploy: { disabled: true }, + }); + + const expected = { disabled: true } as const; + + attest(table.deploy).equals(expected); + }); + it("should throw if the provided key is a dynamic ABI type", () => { attest(() => defineTable({ diff --git a/packages/store/ts/config/v2/table.ts b/packages/store/ts/config/v2/table.ts index 81ba4cea96..2f1fd83929 100644 --- a/packages/store/ts/config/v2/table.ts +++ b/packages/store/ts/config/v2/table.ts @@ -1,11 +1,11 @@ import { ErrorMessage, conform, narrow, requiredKeyOf } from "@arktype/util"; import { isStaticAbiType } from "@latticexyz/schema-type/internal"; import { Hex } from "viem"; -import { get, hasOwnKey } from "./generics"; +import { get, hasOwnKey, mergeIfUndefined } from "./generics"; import { resolveSchema, validateSchema } from "./schema"; import { AbiTypeScope, Scope, getStaticAbiTypeKeys } from "./scope"; import { TableCodegen } from "./output"; -import { TABLE_CODEGEN_DEFAULTS, TABLE_DEFAULTS } from "./defaults"; +import { TABLE_CODEGEN_DEFAULTS, TABLE_DEFAULTS, TABLE_DEPLOY_DEFAULTS } from "./defaults"; import { resourceToHex } from "@latticexyz/common"; import { SchemaInput, TableInput } from "./input"; @@ -121,7 +121,7 @@ export type resolveTableCodegen = { export function resolveTableCodegen(input: input): resolveTableCodegen { const options = input.codegen; return { - directory: get(options, "directory") ?? TABLE_CODEGEN_DEFAULTS.directory, + outputDirectory: get(options, "outputDirectory") ?? TABLE_CODEGEN_DEFAULTS.outputDirectory, tableIdArgument: get(options, "tableIdArgument") ?? TABLE_CODEGEN_DEFAULTS.tableIdArgument, storeArgument: get(options, "storeArgument") ?? TABLE_CODEGEN_DEFAULTS.storeArgument, // dataStruct is true if there are at least 2 value fields @@ -138,6 +138,10 @@ export type resolveTable = input extends Tab readonly key: Readonly; readonly schema: resolveSchema; readonly codegen: resolveTableCodegen; + readonly deploy: mergeIfUndefined< + undefined extends input["deploy"] ? {} : input["deploy"], + typeof TABLE_DEPLOY_DEFAULTS + >; } : never; @@ -158,6 +162,7 @@ export function resolveTable; } diff --git a/packages/world/ts/config/v2/compat.test.ts b/packages/world/ts/config/v2/compat.test.ts index 6ab70ffc14..fd476aa649 100644 --- a/packages/world/ts/config/v2/compat.test.ts +++ b/packages/world/ts/config/v2/compat.test.ts @@ -10,8 +10,8 @@ import { defineWorld } from "./world"; describe("configToV1", () => { it("should transform the broad v2 output to the broad v1 output", () => { // Making the `worldContractName` prop required here since it is required on the output of `mudConfig` - attest>(); - attest, WorldConfigV1 & StoreConfigV1 & { worldContractName: string | undefined }>(); + attest, "v2">>(); + attest, "v2">, WorldConfigV1 & StoreConfigV1 & { worldContractName: string | undefined }>(); }); it("should transform a v2 store config output to the v1 config output", () => { @@ -90,7 +90,10 @@ describe("configToV1", () => { }, }); - attest(worldToV1(configV2)).equals(configV1); - attest>(configV1); + const { v2, ...v1FromV2 } = worldToV1(configV2); + + attest(v1FromV2).equals(configV1); + attest(configV1).equals(v1FromV2); + attest(configV2).equals(v2); }); }); diff --git a/packages/world/ts/config/v2/compat.ts b/packages/world/ts/config/v2/compat.ts index fc1272a633..85f8326078 100644 --- a/packages/world/ts/config/v2/compat.ts +++ b/packages/world/ts/config/v2/compat.ts @@ -26,17 +26,18 @@ function systemsToV1(systems: systems): systemsToV1 = world extends World - ? storeToV1 & { + ? Omit, "v2"> & { systems: systemsToV1; excludeSystems: mutable; modules: modulesToV1; - worldContractName: world["deployment"]["customWorldContract"]; - postDeployScript: world["deployment"]["postDeployScript"]; - deploysDirectory: world["deployment"]["deploysDirectory"]; - worldsFile: world["deployment"]["worldsFile"]; + worldContractName: world["deploy"]["customWorldContract"]; + postDeployScript: world["deploy"]["postDeployScript"]; + deploysDirectory: world["deploy"]["deploysDirectory"]; + worldsFile: world["deploy"]["worldsFile"]; worldInterfaceName: world["codegen"]["worldInterfaceName"]; worldgenDirectory: world["codegen"]["worldgenDirectory"]; worldImportPath: world["codegen"]["worldImportPath"]; + v2: world; } : never; @@ -45,14 +46,14 @@ export function worldToV1(world: conform): worldToV1 systems: systemsToV1(world.systems), excludeSystems: world.excludeSystems, modules: modulesToV1(world.modules), - worldContractName: world.deployment.customWorldContract, - postDeployScript: world.deployment.postDeployScript, - deploysDirectory: world.deployment.deploysDirectory, - worldsFile: world.deployment.worldsFile, + worldContractName: world.deploy.customWorldContract, + postDeployScript: world.deploy.postDeployScript, + deploysDirectory: world.deploy.deploysDirectory, + worldsFile: world.deploy.worldsFile, worldInterfaceName: world.codegen.worldInterfaceName, worldgenDirectory: world.codegen.worldgenDirectory, worldImportPath: world.codegen.worldImportPath, }; - return { ...storeToV1(world as Store), ...v1WorldConfig } as worldToV1; + return { ...storeToV1(world as Store), ...v1WorldConfig, v2: world } as worldToV1; } diff --git a/packages/world/ts/config/v2/defaults.ts b/packages/world/ts/config/v2/defaults.ts index 94c2cf1248..8204edc3a8 100644 --- a/packages/world/ts/config/v2/defaults.ts +++ b/packages/world/ts/config/v2/defaults.ts @@ -10,7 +10,7 @@ export const CODEGEN_DEFAULTS = { worldImportPath: "@latticexyz/world/src/", } as const; -export const DEPLOYMENT_DEFAULTS = { +export const DEPLOY_DEFAULTS = { customWorldContract: undefined, postDeployScript: "PostDeploy", deploysDirectory: "./deploys", @@ -23,5 +23,5 @@ export const CONFIG_DEFAULTS = { excludeSystems: [] as string[], modules: [], codegen: CODEGEN_DEFAULTS, - deployment: DEPLOYMENT_DEFAULTS, + deploy: DEPLOY_DEFAULTS, } as const; diff --git a/packages/world/ts/config/v2/deploy.ts b/packages/world/ts/config/v2/deploy.ts new file mode 100644 index 0000000000..bfb4e81f54 --- /dev/null +++ b/packages/world/ts/config/v2/deploy.ts @@ -0,0 +1,10 @@ +import { mergeIfUndefined, isObject } from "@latticexyz/store/config/v2"; +import { DEPLOY_DEFAULTS } from "./defaults"; + +export type resolveDeploy = deploy extends {} + ? mergeIfUndefined + : typeof DEPLOY_DEFAULTS; + +export function resolveDeploy(deploy: deploy): resolveDeploy { + return (isObject(deploy) ? mergeIfUndefined(deploy, DEPLOY_DEFAULTS) : DEPLOY_DEFAULTS) as resolveDeploy; +} diff --git a/packages/world/ts/config/v2/deployment.ts b/packages/world/ts/config/v2/deployment.ts deleted file mode 100644 index 9aeee565a9..0000000000 --- a/packages/world/ts/config/v2/deployment.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { mergeIfUndefined, isObject } from "@latticexyz/store/config/v2"; -import { DEPLOYMENT_DEFAULTS } from "./defaults"; - -export type resolveDeployment = deployment extends {} - ? mergeIfUndefined - : typeof DEPLOYMENT_DEFAULTS; - -export function resolveDeployment(deployment: deployment): resolveDeployment { - return ( - isObject(deployment) ? mergeIfUndefined(deployment, DEPLOYMENT_DEFAULTS) : DEPLOYMENT_DEFAULTS - ) as resolveDeployment; -} diff --git a/packages/world/ts/config/v2/input.ts b/packages/world/ts/config/v2/input.ts index fb7c7dc6e4..5769a69c57 100644 --- a/packages/world/ts/config/v2/input.ts +++ b/packages/world/ts/config/v2/input.ts @@ -21,7 +21,7 @@ export type SystemInput = { export type SystemsInput = { [key: string]: SystemInput }; -export type DeploymentInput = { +export type DeployInput = { /** * Script to execute after the deployment is complete (Default "PostDeploy"). * Script must be placed in the forge scripts directory (see foundry.toml) and have a ".s.sol" extension. @@ -57,8 +57,8 @@ export type WorldInput = evaluate< excludeSystems?: string[]; /** Modules to in the World */ modules?: Module[]; - /** Deployment config */ - deployment?: DeploymentInput; + /** Deploy config */ + deploy?: DeployInput; /** Codegen config */ codegen?: CodegenInput; } diff --git a/packages/world/ts/config/v2/output.ts b/packages/world/ts/config/v2/output.ts index 1983668030..290d191e65 100644 --- a/packages/world/ts/config/v2/output.ts +++ b/packages/world/ts/config/v2/output.ts @@ -29,7 +29,7 @@ export type System = { export type Systems = { readonly [key: string]: System }; -export type Deployment = { +export type Deploy = { /** The name of a custom World contract to deploy. If no name is provided, a default MUD World is deployed */ readonly customWorldContract: string | undefined; /** @@ -58,8 +58,8 @@ export type World = Store & { readonly excludeSystems: readonly string[]; /** Modules to in the World */ readonly modules: readonly Module[]; - /** Deployment config */ - readonly deployment: Deployment; + /** Deploy config */ + readonly deploy: Deploy; /** Codegen config */ readonly codegen: Codegen; }; diff --git a/packages/world/ts/config/v2/world.test.ts b/packages/world/ts/config/v2/world.test.ts index 47b2fe9880..7895da0405 100644 --- a/packages/world/ts/config/v2/world.test.ts +++ b/packages/world/ts/config/v2/world.test.ts @@ -2,8 +2,12 @@ import { describe, it } from "vitest"; import { defineWorld } from "./world"; import { attest } from "@arktype/attest"; import { resourceToHex } from "@latticexyz/common"; -import { TABLE_CODEGEN_DEFAULTS, CODEGEN_DEFAULTS as STORE_CODEGEN_DEFAULTS } from "@latticexyz/store/config/v2"; -import { CODEGEN_DEFAULTS as WORLD_CODEGEN_DEFAULTS, DEPLOYMENT_DEFAULTS, CONFIG_DEFAULTS } from "./defaults"; +import { + TABLE_CODEGEN_DEFAULTS, + CODEGEN_DEFAULTS as STORE_CODEGEN_DEFAULTS, + TABLE_DEPLOY_DEFAULTS, +} from "@latticexyz/store/config/v2"; +import { CODEGEN_DEFAULTS as WORLD_CODEGEN_DEFAULTS, DEPLOY_DEFAULTS, CONFIG_DEFAULTS } from "./defaults"; import { World } from "./output"; const CODEGEN_DEFAULTS = { ...STORE_CODEGEN_DEFAULTS, ...WORLD_CODEGEN_DEFAULTS }; @@ -51,6 +55,7 @@ describe("defineWorld", () => { namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -111,6 +116,7 @@ describe("defineWorld", () => { namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { @@ -212,6 +218,7 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -260,6 +267,7 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { @@ -307,12 +315,13 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, enums: {}, namespace: "", - deployment: DEPLOYMENT_DEFAULTS, + deploy: DEPLOY_DEFAULTS, } as const; attest(config).equals(expected); @@ -356,6 +365,7 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, Second: { tableId: resourceToHex({ type: "table", namespace: "", name: "Second" }), @@ -378,6 +388,7 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -431,6 +442,7 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, Second: { tableId: resourceToHex({ type: "table", namespace: "", name: "Second" }), @@ -453,6 +465,7 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { @@ -562,6 +575,7 @@ describe("defineWorld", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { diff --git a/packages/world/ts/config/v2/world.ts b/packages/world/ts/config/v2/world.ts index da5f83c5e0..70a011f0e9 100644 --- a/packages/world/ts/config/v2/world.ts +++ b/packages/world/ts/config/v2/world.ts @@ -19,7 +19,7 @@ import { Tables } from "@latticexyz/store"; import { resolveSystems } from "./systems"; import { resolveNamespacedTables, validateNamespaces } from "./namespaces"; import { resolveCodegen } from "./codegen"; -import { resolveDeployment } from "./deployment"; +import { resolveDeploy } from "./deploy"; export type validateWorld = { readonly [key in keyof world]: key extends "tables" @@ -58,8 +58,8 @@ export type resolveWorld = evaluate< { [key in keyof world]: key extends "systems" ? resolveSystems - : key extends "deployment" - ? resolveDeployment + : key extends "deploy" + ? resolveDeploy : key extends "codegen" ? resolveCodegen : world[key]; @@ -95,7 +95,7 @@ export function resolveWorld(world: world): reso ...resolvedStore, tables: { ...resolvedStore.tables, ...resolvedNamespacedTables }, codegen: mergeIfUndefined(resolvedStore.codegen, resolveCodegen(world.codegen)), - deployment: resolveDeployment(world.deployment), + deploy: resolveDeploy(world.deploy), systems: resolveSystems(world.systems ?? CONFIG_DEFAULTS.systems), excludeSystems: get(world, "excludeSystems"), modules: world.modules, diff --git a/packages/world/ts/config/v2/worldWithShorthands.test.ts b/packages/world/ts/config/v2/worldWithShorthands.test.ts index 437a301691..c992cb36c0 100644 --- a/packages/world/ts/config/v2/worldWithShorthands.test.ts +++ b/packages/world/ts/config/v2/worldWithShorthands.test.ts @@ -2,7 +2,11 @@ import { describe, it } from "vitest"; import { defineWorldWithShorthands } from "./worldWithShorthands"; import { attest } from "@arktype/attest"; import { resourceToHex } from "@latticexyz/common"; -import { TABLE_CODEGEN_DEFAULTS, CODEGEN_DEFAULTS as STORE_CODEGEN_DEFAULTS } from "@latticexyz/store/config/v2"; +import { + TABLE_CODEGEN_DEFAULTS, + CODEGEN_DEFAULTS as STORE_CODEGEN_DEFAULTS, + TABLE_DEPLOY_DEFAULTS, +} from "@latticexyz/store/config/v2"; import { CODEGEN_DEFAULTS as WORLD_CODEGEN_DEFAULTS, CONFIG_DEFAULTS } from "./defaults"; const CODEGEN_DEFAULTS = { ...STORE_CODEGEN_DEFAULTS, ...WORLD_CODEGEN_DEFAULTS }; @@ -46,6 +50,7 @@ describe("defineWorldWithShorthands", () => { namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { @@ -108,6 +113,7 @@ describe("defineWorldWithShorthands", () => { namespace: "ExampleNamespace", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { @@ -147,6 +153,7 @@ describe("defineWorldWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -184,6 +191,7 @@ describe("defineWorldWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: false as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: { CustomType: { type: "address", filePath: "path/to/file" as string } }, @@ -223,6 +231,7 @@ describe("defineWorldWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {}, @@ -262,6 +271,7 @@ describe("defineWorldWithShorthands", () => { namespace: "", codegen: { ...TABLE_CODEGEN_DEFAULTS, dataStruct: true as boolean }, type: "table", + deploy: TABLE_DEPLOY_DEFAULTS, }, }, userTypes: {},