From 043480b4212a7aad0e24cbe5ccdb71f702035303 Mon Sep 17 00:00:00 2001 From: Kevin Ingersoll Date: Wed, 24 Jul 2024 11:00:23 +0100 Subject: [PATCH] fix world --- packages/world/ts/config/v2/namespaces.ts | 3 ++- packages/world/ts/config/v2/world.test.ts | 3 ++- packages/world/ts/config/v2/world.ts | 6 +++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/world/ts/config/v2/namespaces.ts b/packages/world/ts/config/v2/namespaces.ts index f8b1e08853..ced34101c3 100644 --- a/packages/world/ts/config/v2/namespaces.ts +++ b/packages/world/ts/config/v2/namespaces.ts @@ -8,6 +8,7 @@ import { mergeIfUndefined, extendedScope, getPath, + expandTableShorthand, } from "@latticexyz/store/config/v2"; import { NamespaceInput, NamespacesInput } from "./input"; import { ErrorMessage, conform } from "@arktype/util"; @@ -58,7 +59,7 @@ export type resolveNamespacedTables = "namespaces" extends keyof world readonly [key in namespacedTableKeys]: key extends `${infer namespace}__${infer table}` ? resolveTable< mergeIfUndefined< - getPath, + expandTableShorthand>, { name: table; namespace: namespace } >, extendedScope diff --git a/packages/world/ts/config/v2/world.test.ts b/packages/world/ts/config/v2/world.test.ts index 8448f76535..273c92a887 100644 --- a/packages/world/ts/config/v2/world.test.ts +++ b/packages/world/ts/config/v2/world.test.ts @@ -1108,13 +1108,14 @@ describe("defineWorld", () => { ...expectedBaseNamespace, }, }, - userTypes: { CustomType: { type: "address", filePath: "path/to/file" as string } }, + userTypes: { CustomType: { type: "address", filePath: "path/to/file" } }, enums: {}, enumValues: {}, codegen: CODEGEN_DEFAULTS, } as const; attest(config).equals(expectedConfig); + attest(expectedConfig); }); it("given a schema with a key field with static ABI type, it should use `id` as single key", () => { diff --git a/packages/world/ts/config/v2/world.ts b/packages/world/ts/config/v2/world.ts index 725940aba3..bdb9c4420b 100644 --- a/packages/world/ts/config/v2/world.ts +++ b/packages/world/ts/config/v2/world.ts @@ -11,6 +11,7 @@ import { Store, hasOwnKey, validateStore, + expandTableShorthand, } from "@latticexyz/store/config/v2"; import { SystemsInput, WorldInput } from "./input"; import { CONFIG_DEFAULTS, MODULE_DEFAULTS } from "./defaults"; @@ -79,7 +80,10 @@ export function resolveWorld(world: world): reso validateTable(table, scope); return [ `${namespaceKey}__${tableKey}`, - resolveTable(mergeIfUndefined(table, { namespace: namespaceKey, name: tableKey }), scope), + resolveTable( + mergeIfUndefined(expandTableShorthand(table, scope), { namespace: namespaceKey, label: tableKey }), + scope, + ), ]; }), )