Skip to content

Commit

Permalink
fix world
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Jul 24, 2024
1 parent 19e8f6a commit 043480b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/world/ts/config/v2/namespaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -58,7 +59,7 @@ export type resolveNamespacedTables<world> = "namespaces" extends keyof world
readonly [key in namespacedTableKeys<world>]: key extends `${infer namespace}__${infer table}`
? resolveTable<
mergeIfUndefined<
getPath<world, ["namespaces", namespace, "tables", table]>,
expandTableShorthand<getPath<world, ["namespaces", namespace, "tables", table]>>,
{ name: table; namespace: namespace }
>,
extendedScope<world>
Expand Down
3 changes: 2 additions & 1 deletion packages/world/ts/config/v2/world.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof expectedConfig>(config).equals(expectedConfig);
attest<typeof config>(expectedConfig);
});

it("given a schema with a key field with static ABI type, it should use `id` as single key", () => {
Expand Down
6 changes: 5 additions & 1 deletion packages/world/ts/config/v2/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -79,7 +80,10 @@ export function resolveWorld<const world extends WorldInput>(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,
),
];
}),
)
Expand Down

0 comments on commit 043480b

Please sign in to comment.