@latticexyz/world 2.0.12-main-d7526607 → 2.0.12-main-9be2bb86

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/cache/solidity-files-cache.json +1 -1
  2. package/dist/{chunk-YMY7QWFU.js → chunk-AEVS2CGG.js} +1 -1
  3. package/dist/chunk-AEVS2CGG.js.map +1 -0
  4. package/dist/{chunk-343CB7TH.js → chunk-E5NQ4W4F.js} +2 -2
  5. package/dist/{chunk-343CB7TH.js.map → chunk-E5NQ4W4F.js.map} +1 -1
  6. package/dist/{chunk-G2HK4FEL.js → chunk-HG6V522M.js} +2 -2
  7. package/dist/chunk-MTFNNV27.js +2 -0
  8. package/dist/chunk-MTFNNV27.js.map +1 -0
  9. package/dist/chunk-NXAGBVBE.js +2 -0
  10. package/dist/chunk-NXAGBVBE.js.map +1 -0
  11. package/dist/{chunk-Z4R7FBSR.js → chunk-PWEXBICA.js} +2 -2
  12. package/dist/config/v2.d.ts +5 -10
  13. package/dist/config/v2.js +1 -1
  14. package/dist/{defaults-0e720e83.d.ts → defaults-1be1ffd2.d.ts} +0 -1
  15. package/dist/{output-2c2f47d5.d.ts → dynamicResolution-e364a0fe.d.ts} +24 -14
  16. package/dist/index.d.ts +3 -3
  17. package/dist/index.js +1 -1
  18. package/dist/internal.d.ts +6 -5
  19. package/dist/internal.js +2 -1
  20. package/dist/internal.js.map +1 -1
  21. package/dist/mud.config.js +1 -1
  22. package/dist/node.d.ts +1 -1
  23. package/dist/node.js +1 -1
  24. package/dist/register.d.ts +5 -3
  25. package/dist/register.js +1 -1
  26. package/dist/register.js.map +1 -1
  27. package/dist/{types-6e8f0277.d.ts → types-05e0a946.d.ts} +2 -198
  28. package/dist/{world-3ef0fea7.d.ts → world-028cabe5.d.ts} +2 -2
  29. package/package.json +8 -8
  30. package/ts/config/defaults.ts +0 -1
  31. package/ts/config/resolveWorldConfig.ts +4 -1
  32. package/ts/config/types.ts +1 -3
  33. package/ts/config/v2/compat.ts +1 -15
  34. package/ts/config/v2/dynamicResolution.ts +22 -15
  35. package/ts/config/worldConfig.ts +1 -18
  36. package/ts/exports/internal.ts +2 -0
  37. package/ts/register/index.ts +1 -1
  38. package/dist/chunk-6LUTYQMB.js +0 -2
  39. package/dist/chunk-6LUTYQMB.js.map +0 -1
  40. package/dist/chunk-NPFZQNKD.js +0 -2
  41. package/dist/chunk-NPFZQNKD.js.map +0 -1
  42. package/dist/chunk-YMY7QWFU.js.map +0 -1
  43. /package/dist/{chunk-G2HK4FEL.js.map → chunk-HG6V522M.js.map} +0 -0
  44. /package/dist/{chunk-Z4R7FBSR.js.map → chunk-PWEXBICA.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
- import { DynamicResolutionType, ValueWithType, DynamicResolution } from '@latticexyz/config/library';
3
2
  import { OrDefaults } from '@latticexyz/common/type-utils';
4
- import { S as SYSTEM_DEFAULTS } from './defaults-0e720e83.js';
3
+ import { S as SYSTEM_DEFAULTS } from './defaults-1be1ffd2.js';
4
+ import { V as ValueWithType, D as DynamicResolution } from './dynamicResolution-e364a0fe.js';
5
5
 
6
6
  declare const zWorldConfig: z.ZodObject<{
7
7
  worldContractName: z.ZodOptional<z.ZodString>;
@@ -37,49 +37,6 @@ declare const zWorldConfig: z.ZodObject<{
37
37
  worldsFile: z.ZodDefault<z.ZodString>;
38
38
  worldgenDirectory: z.ZodDefault<z.ZodString>;
39
39
  worldImportPath: z.ZodDefault<z.ZodString>;
40
- modules: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodObject<{
41
- name: z.ZodEffects<z.ZodString, string, string>;
42
- root: z.ZodDefault<z.ZodBoolean>;
43
- args: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodUnion<[z.ZodObject<{
44
- value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>;
45
- type: z.ZodString;
46
- }, "strip", z.ZodTypeAny, {
47
- value: string | number | Uint8Array;
48
- type: string;
49
- }, {
50
- value: string | number | Uint8Array;
51
- type: string;
52
- }>, z.ZodObject<{
53
- type: z.ZodNativeEnum<typeof DynamicResolutionType>;
54
- input: z.ZodString;
55
- }, "strip", z.ZodTypeAny, {
56
- type: DynamicResolutionType;
57
- input: string;
58
- }, {
59
- type: DynamicResolutionType;
60
- input: string;
61
- }>]>, "many">>>;
62
- }, "strip", z.ZodTypeAny, {
63
- name: string;
64
- args: readonly ({
65
- value: string | number | Uint8Array;
66
- type: string;
67
- } | {
68
- type: DynamicResolutionType;
69
- input: string;
70
- })[];
71
- root: boolean;
72
- }, {
73
- name: string;
74
- args?: readonly ({
75
- value: string | number | Uint8Array;
76
- type: string;
77
- } | {
78
- type: DynamicResolutionType;
79
- input: string;
80
- })[] | undefined;
81
- root?: boolean | undefined;
82
- }>, "many">>>;
83
40
  }, "strip", z.ZodTypeAny, {
84
41
  systems: Record<string, {
85
42
  registerFunctionSelectors: boolean;
@@ -91,17 +48,6 @@ declare const zWorldConfig: z.ZodObject<{
91
48
  openAccess: false;
92
49
  })>;
93
50
  excludeSystems: readonly string[];
94
- modules: readonly {
95
- name: string;
96
- args: readonly ({
97
- value: string | number | Uint8Array;
98
- type: string;
99
- } | {
100
- type: DynamicResolutionType;
101
- input: string;
102
- })[];
103
- root: boolean;
104
- }[];
105
51
  worldInterfaceName: string;
106
52
  worldgenDirectory: string;
107
53
  worldImportPath: string;
@@ -120,17 +66,6 @@ declare const zWorldConfig: z.ZodObject<{
120
66
  accessList?: readonly string[] | undefined;
121
67
  })> | undefined;
122
68
  excludeSystems?: readonly string[] | undefined;
123
- modules?: readonly {
124
- name: string;
125
- args?: readonly ({
126
- value: string | number | Uint8Array;
127
- type: string;
128
- } | {
129
- type: DynamicResolutionType;
130
- input: string;
131
- })[] | undefined;
132
- root?: boolean | undefined;
133
- }[] | undefined;
134
69
  worldInterfaceName?: string | undefined;
135
70
  worldgenDirectory?: string | undefined;
136
71
  worldImportPath?: string | undefined;
@@ -173,49 +108,6 @@ declare const zPluginWorldConfig: z.ZodObject<{
173
108
  worldsFile: z.ZodDefault<z.ZodString>;
174
109
  worldgenDirectory: z.ZodDefault<z.ZodString>;
175
110
  worldImportPath: z.ZodDefault<z.ZodString>;
176
- modules: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodObject<{
177
- name: z.ZodEffects<z.ZodString, string, string>;
178
- root: z.ZodDefault<z.ZodBoolean>;
179
- args: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodUnion<[z.ZodObject<{
180
- value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>;
181
- type: z.ZodString;
182
- }, "strip", z.ZodTypeAny, {
183
- value: string | number | Uint8Array;
184
- type: string;
185
- }, {
186
- value: string | number | Uint8Array;
187
- type: string;
188
- }>, z.ZodObject<{
189
- type: z.ZodNativeEnum<typeof DynamicResolutionType>;
190
- input: z.ZodString;
191
- }, "strip", z.ZodTypeAny, {
192
- type: DynamicResolutionType;
193
- input: string;
194
- }, {
195
- type: DynamicResolutionType;
196
- input: string;
197
- }>]>, "many">>>;
198
- }, "strip", z.ZodTypeAny, {
199
- name: string;
200
- args: readonly ({
201
- value: string | number | Uint8Array;
202
- type: string;
203
- } | {
204
- type: DynamicResolutionType;
205
- input: string;
206
- })[];
207
- root: boolean;
208
- }, {
209
- name: string;
210
- args?: readonly ({
211
- value: string | number | Uint8Array;
212
- type: string;
213
- } | {
214
- type: DynamicResolutionType;
215
- input: string;
216
- })[] | undefined;
217
- root?: boolean | undefined;
218
- }>, "many">>>;
219
111
  }, "strip", z.ZodAny, z.objectOutputType<{
220
112
  worldContractName: z.ZodOptional<z.ZodString>;
221
113
  worldInterfaceName: z.ZodDefault<z.ZodString>;
@@ -250,49 +142,6 @@ declare const zPluginWorldConfig: z.ZodObject<{
250
142
  worldsFile: z.ZodDefault<z.ZodString>;
251
143
  worldgenDirectory: z.ZodDefault<z.ZodString>;
252
144
  worldImportPath: z.ZodDefault<z.ZodString>;
253
- modules: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodObject<{
254
- name: z.ZodEffects<z.ZodString, string, string>;
255
- root: z.ZodDefault<z.ZodBoolean>;
256
- args: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodUnion<[z.ZodObject<{
257
- value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>;
258
- type: z.ZodString;
259
- }, "strip", z.ZodTypeAny, {
260
- value: string | number | Uint8Array;
261
- type: string;
262
- }, {
263
- value: string | number | Uint8Array;
264
- type: string;
265
- }>, z.ZodObject<{
266
- type: z.ZodNativeEnum<typeof DynamicResolutionType>;
267
- input: z.ZodString;
268
- }, "strip", z.ZodTypeAny, {
269
- type: DynamicResolutionType;
270
- input: string;
271
- }, {
272
- type: DynamicResolutionType;
273
- input: string;
274
- }>]>, "many">>>;
275
- }, "strip", z.ZodTypeAny, {
276
- name: string;
277
- args: readonly ({
278
- value: string | number | Uint8Array;
279
- type: string;
280
- } | {
281
- type: DynamicResolutionType;
282
- input: string;
283
- })[];
284
- root: boolean;
285
- }, {
286
- name: string;
287
- args?: readonly ({
288
- value: string | number | Uint8Array;
289
- type: string;
290
- } | {
291
- type: DynamicResolutionType;
292
- input: string;
293
- })[] | undefined;
294
- root?: boolean | undefined;
295
- }>, "many">>>;
296
145
  }, z.ZodAny, "strip">, z.objectInputType<{
297
146
  worldContractName: z.ZodOptional<z.ZodString>;
298
147
  worldInterfaceName: z.ZodDefault<z.ZodString>;
@@ -327,49 +176,6 @@ declare const zPluginWorldConfig: z.ZodObject<{
327
176
  worldsFile: z.ZodDefault<z.ZodString>;
328
177
  worldgenDirectory: z.ZodDefault<z.ZodString>;
329
178
  worldImportPath: z.ZodDefault<z.ZodString>;
330
- modules: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodObject<{
331
- name: z.ZodEffects<z.ZodString, string, string>;
332
- root: z.ZodDefault<z.ZodBoolean>;
333
- args: z.ZodDefault<z.ZodReadonly<z.ZodArray<z.ZodUnion<[z.ZodObject<{
334
- value: z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodType<Uint8Array, z.ZodTypeDef, Uint8Array>]>;
335
- type: z.ZodString;
336
- }, "strip", z.ZodTypeAny, {
337
- value: string | number | Uint8Array;
338
- type: string;
339
- }, {
340
- value: string | number | Uint8Array;
341
- type: string;
342
- }>, z.ZodObject<{
343
- type: z.ZodNativeEnum<typeof DynamicResolutionType>;
344
- input: z.ZodString;
345
- }, "strip", z.ZodTypeAny, {
346
- type: DynamicResolutionType;
347
- input: string;
348
- }, {
349
- type: DynamicResolutionType;
350
- input: string;
351
- }>]>, "many">>>;
352
- }, "strip", z.ZodTypeAny, {
353
- name: string;
354
- args: readonly ({
355
- value: string | number | Uint8Array;
356
- type: string;
357
- } | {
358
- type: DynamicResolutionType;
359
- input: string;
360
- })[];
361
- root: boolean;
362
- }, {
363
- name: string;
364
- args?: readonly ({
365
- value: string | number | Uint8Array;
366
- type: string;
367
- } | {
368
- type: DynamicResolutionType;
369
- input: string;
370
- })[] | undefined;
371
- root?: boolean | undefined;
372
- }>, "many">>>;
373
179
  }, z.ZodAny, "strip">>;
374
180
 
375
181
  type SystemUserConfig = {
@@ -441,8 +247,6 @@ interface WorldUserConfig {
441
247
  worldgenDirectory?: string;
442
248
  /** Path for world package imports. Default is "@latticexyz/world/src/" */
443
249
  worldImportPath?: string;
444
- /** Modules to in the World */
445
- modules?: readonly ModuleConfig[];
446
250
  }
447
251
  type WorldConfig = z.output<typeof zWorldConfig>;
448
252
  type SystemConfig = WorldConfig["systems"][string];
@@ -1,7 +1,7 @@
1
1
  import { evaluate, narrow, ErrorMessage, conform } from '@arktype/util';
2
2
  import { StoreInput, StoreWithShorthandsInput, resolveTable, mergeIfUndefined, getPath, extendedScope, Scope, AbiTypeScope, validateTables, UserTypes, resolveStore, Store } from '@latticexyz/store/config/v2';
3
- import { V as ValueWithType, b as DynamicResolution } from './output-2c2f47d5.js';
4
- import { S as SYSTEM_DEFAULTS } from './defaults-0e720e83.js';
3
+ import { V as ValueWithType, D as DynamicResolution } from './dynamicResolution-e364a0fe.js';
4
+ import { S as SYSTEM_DEFAULTS } from './defaults-1be1ffd2.js';
5
5
 
6
6
  type SystemInput = {
7
7
  /** The full resource selector consists of namespace and name */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/world",
3
- "version": "2.0.12-main-d7526607",
3
+ "version": "2.0.12-main-9be2bb86",
4
4
  "description": "World framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,11 +43,11 @@
43
43
  "arktype": "1.0.29-alpha",
44
44
  "viem": "2.9.20",
45
45
  "zod": "^3.22.2",
46
- "@latticexyz/common": "2.0.12-main-d7526607",
47
- "@latticexyz/config": "2.0.12-main-d7526607",
48
- "@latticexyz/protocol-parser": "2.0.12-main-d7526607",
49
- "@latticexyz/schema-type": "2.0.12-main-d7526607",
50
- "@latticexyz/store": "2.0.12-main-d7526607"
46
+ "@latticexyz/common": "2.0.12-main-9be2bb86",
47
+ "@latticexyz/config": "2.0.12-main-9be2bb86",
48
+ "@latticexyz/protocol-parser": "2.0.12-main-9be2bb86",
49
+ "@latticexyz/schema-type": "2.0.12-main-9be2bb86",
50
+ "@latticexyz/store": "2.0.12-main-9be2bb86"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@types/ejs": "^3.1.1",
@@ -62,8 +62,8 @@
62
62
  "tsup": "^6.7.0",
63
63
  "tsx": "^3.12.6",
64
64
  "vitest": "0.34.6",
65
- "@latticexyz/abi-ts": "2.0.12-main-d7526607",
66
- "@latticexyz/gas-report": "2.0.12-main-d7526607"
65
+ "@latticexyz/abi-ts": "2.0.12-main-9be2bb86",
66
+ "@latticexyz/gas-report": "2.0.12-main-9be2bb86"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "pnpm run build:mud && pnpm run build:abi && pnpm run build:abi-ts && pnpm run build:js",
@@ -16,7 +16,6 @@ export const WORLD_DEFAULTS = {
16
16
  worldsFile: "./worlds.json",
17
17
  worldgenDirectory: "world",
18
18
  worldImportPath: "@latticexyz/world/src/",
19
- modules: [],
20
19
  } as const;
21
20
 
22
21
  export type WORLD_DEFAULTS = typeof WORLD_DEFAULTS;
@@ -11,7 +11,10 @@ export type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;
11
11
  * filtering out excluded systems, validate system names refer to existing contracts, and
12
12
  * splitting the access list into addresses and system names.
13
13
  */
14
- export function resolveWorldConfig(config: StoreConfig & WorldConfig, existingContracts?: string[]) {
14
+ export function resolveWorldConfig(
15
+ config: Pick<StoreConfig & WorldConfig, "systems" | "excludeSystems">,
16
+ existingContracts?: string[],
17
+ ) {
15
18
  // Include contract names ending in "System", but not the base "System" contract, and not Interfaces
16
19
  const defaultSystemNames =
17
20
  existingContracts?.filter((name) => name.endsWith("System") && name !== "System" && !name.match(/^I[A-Z]/)) ?? [];
@@ -1,8 +1,8 @@
1
1
  import { z } from "zod";
2
- import { DynamicResolution, ValueWithType } from "@latticexyz/config/library";
3
2
  import { OrDefaults } from "@latticexyz/common/type-utils";
4
3
  import { zWorldConfig } from "./worldConfig";
5
4
  import { SYSTEM_DEFAULTS } from "./defaults";
5
+ import { DynamicResolution, ValueWithType } from "./v2/dynamicResolution";
6
6
 
7
7
  // zod doesn't preserve doc comments
8
8
  export type SystemUserConfig = {
@@ -85,8 +85,6 @@ export interface WorldUserConfig {
85
85
  worldgenDirectory?: string;
86
86
  /** Path for world package imports. Default is "@latticexyz/world/src/" */
87
87
  worldImportPath?: string;
88
- /** Modules to in the World */
89
- modules?: readonly ModuleConfig[];
90
88
  }
91
89
 
92
90
  export type WorldConfig = z.output<typeof zWorldConfig>;
@@ -1,20 +1,8 @@
1
1
  import { conform } from "@arktype/util";
2
- import { Module, World, Systems } from "./output";
2
+ import { World, Systems } from "./output";
3
3
  import { Store } from "@latticexyz/store";
4
4
  import { storeToV1 } from "@latticexyz/store/config/v2";
5
5
 
6
- type modulesToV1<modules extends readonly Module[]> = {
7
- [key in keyof modules]: Omit<modules[key], "artifactPath">;
8
- };
9
-
10
- function modulesToV1<modules extends readonly Module[]>(modules: modules): modulesToV1<modules> {
11
- return modules.map((module) => ({
12
- ...module,
13
- root: module.root ?? false,
14
- args: module.args ?? [],
15
- })) as never;
16
- }
17
-
18
6
  type systemsToV1<systems extends Systems> = {
19
7
  [key in keyof systems]: {
20
8
  name?: systems[key]["name"];
@@ -30,7 +18,6 @@ export type worldToV1<world> = world extends World
30
18
  ? Omit<storeToV1<world>, "v2"> & {
31
19
  systems: systemsToV1<world["systems"]>;
32
20
  excludeSystems: world["excludeSystems"];
33
- modules: modulesToV1<world["modules"]>;
34
21
  worldContractName: world["deploy"]["customWorldContract"];
35
22
  postDeployScript: world["deploy"]["postDeployScript"];
36
23
  deploysDirectory: world["deploy"]["deploysDirectory"];
@@ -46,7 +33,6 @@ export function worldToV1<world>(world: conform<world, World>): worldToV1<world>
46
33
  const v1WorldConfig = {
47
34
  systems: systemsToV1(world.systems),
48
35
  excludeSystems: world.excludeSystems,
49
- modules: modulesToV1(world.modules),
50
36
  worldContractName: world.deploy.customWorldContract,
51
37
  postDeployScript: world.deploy.postDeployScript,
52
38
  deploysDirectory: world.deploy.deploysDirectory,
@@ -1,10 +1,8 @@
1
- export enum DynamicResolutionType {
2
- TABLE_ID,
3
- SYSTEM_ADDRESS,
4
- }
1
+ import { World } from "./output";
5
2
 
6
3
  export type DynamicResolution = {
7
- type: DynamicResolutionType;
4
+ // TODO: add systemAddress support
5
+ type: "tableId";
8
6
  input: string;
9
7
  };
10
8
 
@@ -18,9 +16,9 @@ export type ValueWithType = {
18
16
  */
19
17
  export function resolveTableId(tableName: string) {
20
18
  return {
21
- type: DynamicResolutionType.TABLE_ID,
19
+ type: "tableId",
22
20
  input: tableName,
23
- };
21
+ } as const;
24
22
  }
25
23
 
26
24
  /** Type guard for DynamicResolution */
@@ -38,20 +36,29 @@ export function isValueWithType(value: unknown): value is ValueWithType {
38
36
  */
39
37
  export function resolveWithContext(
40
38
  input: unknown,
41
- context: { systemAddresses?: Record<string, Promise<string>>; tableIds?: Record<string, Uint8Array> },
39
+ context: { config: World; systemAddresses?: Record<string, Promise<string>> },
42
40
  ): ValueWithType {
43
41
  if (isValueWithType(input)) return input;
44
42
 
45
43
  if (isDynamicResolution(input)) {
46
- let resolved: ValueWithType | undefined = undefined;
44
+ if (input.type === "tableId") {
45
+ const tableEntries = Object.entries(context.config.tables).filter(
46
+ ([tableName, table]) => tableName === input.input || table.name === input.input,
47
+ );
47
48
 
48
- if (input.type === DynamicResolutionType.TABLE_ID) {
49
- const tableId = context.tableIds?.[input.input];
50
- resolved = tableId && { value: tableId, type: "bytes32" };
51
- }
49
+ if (tableEntries.length > 1) {
50
+ throw new Error(
51
+ `Found more than one table with name "${input.input}". Try using one of the following table names instead: ${tableEntries.map(([tableName]) => tableName).join(", ")}`,
52
+ );
53
+ }
52
54
 
53
- if (resolved) return resolved;
55
+ if (tableEntries.length === 1) {
56
+ const [entry] = tableEntries;
57
+ const [, table] = entry;
58
+ return { type: "bytes32", value: table.tableId };
59
+ }
60
+ }
54
61
  }
55
62
 
56
- throw new Error(`Could not resolve dynamic resolution: \n${JSON.stringify(input, null, 2)}`);
63
+ throw new Error(`Could not resolve dynamic resolution:\n${JSON.stringify(input, null, 2)}`);
57
64
  }
@@ -1,9 +1,8 @@
1
1
  import { z } from "zod";
2
- import { DynamicResolutionType, zEthereumAddress, zName, zObjectName } from "@latticexyz/config/library";
2
+ import { zEthereumAddress, zName, zObjectName } from "@latticexyz/config/library";
3
3
  import { SYSTEM_DEFAULTS, WORLD_DEFAULTS } from "./defaults";
4
4
 
5
5
  const zSystemName = zObjectName;
6
- const zModuleName = zObjectName;
7
6
  const zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).readonly().default(SYSTEM_DEFAULTS.accessList);
8
7
 
9
8
  // The system config is a combination of a name config and access config
@@ -23,21 +22,6 @@ const zSystemConfig = z.intersection(
23
22
  ]),
24
23
  );
25
24
 
26
- const zValueWithType = z.object({
27
- value: z.union([z.string(), z.number(), z.instanceof(Uint8Array)]),
28
- type: z.string(),
29
- });
30
- const zDynamicResolution = z.object({ type: z.nativeEnum(DynamicResolutionType), input: z.string() });
31
-
32
- const zModuleConfig = z.object({
33
- name: zModuleName,
34
- root: z.boolean().default(false),
35
- args: z
36
- .array(z.union([zValueWithType, zDynamicResolution]))
37
- .readonly()
38
- .default([]),
39
- });
40
-
41
25
  // The parsed world config is the result of parsing the user config
42
26
  export const zWorldConfig = z.object({
43
27
  worldContractName: z.string().optional(),
@@ -49,7 +33,6 @@ export const zWorldConfig = z.object({
49
33
  worldsFile: z.string().default(WORLD_DEFAULTS.worldsFile),
50
34
  worldgenDirectory: z.string().default(WORLD_DEFAULTS.worldgenDirectory),
51
35
  worldImportPath: z.string().default(WORLD_DEFAULTS.worldImportPath),
52
- modules: z.array(zModuleConfig).readonly().default(WORLD_DEFAULTS.modules),
53
36
  });
54
37
 
55
38
  // Catchall preserves other plugins' options
@@ -11,3 +11,5 @@ export * from "../encodeSystemCallsFrom";
11
11
  export * from "../actions/callFrom";
12
12
 
13
13
  export * from "../callWithSignatureTypes";
14
+
15
+ export { resolveTableId, resolveWithContext } from "../config/v2/dynamicResolution";
@@ -5,7 +5,7 @@
5
5
  // For convenience register and reexport store (which does the same for core config),
6
6
  // to reduce the number of needed imports for users
7
7
  import "@latticexyz/store/register";
8
- export { mudConfig, mudCoreConfig, resolveTableId } from "@latticexyz/store/register";
8
+ export { mudConfig, mudCoreConfig } from "@latticexyz/store/register";
9
9
  // Extend core config and types
10
10
  import "./configExtensions";
11
11
  import "./typeExtensions";
@@ -1,2 +0,0 @@
1
- import{storeToV1 as s}from"@latticexyz/store/config/v2";function r(e){return e.map(o=>({...o,root:o.root??!1,args:o.args??[]}))}function l(e){let o={systems:e.systems,excludeSystems:e.excludeSystems,modules:r(e.modules),worldContractName:e.deploy.customWorldContract,postDeployScript:e.deploy.postDeployScript,deploysDirectory:e.deploy.deploysDirectory,worldsFile:e.deploy.worldsFile,worldInterfaceName:e.codegen.worldInterfaceName,worldgenDirectory:e.codegen.worldgenDirectory,worldImportPath:e.codegen.worldImportPath};return{...s(e),...o,v2:e}}export{l as a};
2
- //# sourceMappingURL=chunk-6LUTYQMB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/config/v2/compat.ts"],"sourcesContent":["import { conform } from \"@arktype/util\";\nimport { Module, World, Systems } from \"./output\";\nimport { Store } from \"@latticexyz/store\";\nimport { storeToV1 } from \"@latticexyz/store/config/v2\";\n\ntype modulesToV1<modules extends readonly Module[]> = {\n [key in keyof modules]: Omit<modules[key], \"artifactPath\">;\n};\n\nfunction modulesToV1<modules extends readonly Module[]>(modules: modules): modulesToV1<modules> {\n return modules.map((module) => ({\n ...module,\n root: module.root ?? false,\n args: module.args ?? [],\n })) as never;\n}\n\ntype systemsToV1<systems extends Systems> = {\n [key in keyof systems]: {\n name?: systems[key][\"name\"];\n registerFunctionSelectors: systems[key][\"registerFunctionSelectors\"];\n } & ({ openAccess: true } | { openAccess: false; accessList: systems[key][\"accessList\"] });\n};\n\nfunction systemsToV1<systems extends Systems>(systems: systems): systemsToV1<systems> {\n return systems;\n}\n\nexport type worldToV1<world> = world extends World\n ? Omit<storeToV1<world>, \"v2\"> & {\n systems: systemsToV1<world[\"systems\"]>;\n excludeSystems: world[\"excludeSystems\"];\n modules: modulesToV1<world[\"modules\"]>;\n worldContractName: world[\"deploy\"][\"customWorldContract\"];\n postDeployScript: world[\"deploy\"][\"postDeployScript\"];\n deploysDirectory: world[\"deploy\"][\"deploysDirectory\"];\n worldsFile: world[\"deploy\"][\"worldsFile\"];\n worldInterfaceName: world[\"codegen\"][\"worldInterfaceName\"];\n worldgenDirectory: world[\"codegen\"][\"worldgenDirectory\"];\n worldImportPath: world[\"codegen\"][\"worldImportPath\"];\n v2: world;\n }\n : never;\n\nexport function worldToV1<world>(world: conform<world, World>): worldToV1<world> {\n const v1WorldConfig = {\n systems: systemsToV1(world.systems),\n excludeSystems: world.excludeSystems,\n modules: modulesToV1(world.modules),\n worldContractName: world.deploy.customWorldContract,\n postDeployScript: world.deploy.postDeployScript,\n deploysDirectory: world.deploy.deploysDirectory,\n worldsFile: world.deploy.worldsFile,\n worldInterfaceName: world.codegen.worldInterfaceName,\n worldgenDirectory: world.codegen.worldgenDirectory,\n worldImportPath: world.codegen.worldImportPath,\n };\n\n return { ...storeToV1(world as Store), ...v1WorldConfig, v2: world } as never;\n}\n"],"mappings":"AAGA,OAAS,aAAAA,MAAiB,8BAM1B,SAASC,EAA+CC,EAAwC,CAC9F,OAAOA,EAAQ,IAAKC,IAAY,CAC9B,GAAGA,EACH,KAAMA,EAAO,MAAQ,GACrB,KAAMA,EAAO,MAAQ,CAAC,CACxB,EAAE,CACJ,CA6BO,SAASC,EAAiBC,EAAgD,CAC/E,IAAMC,EAAgB,CACpB,QAAqBD,EAAM,QAC3B,eAAgBA,EAAM,eACtB,QAASE,EAAYF,EAAM,OAAO,EAClC,kBAAmBA,EAAM,OAAO,oBAChC,iBAAkBA,EAAM,OAAO,iBAC/B,iBAAkBA,EAAM,OAAO,iBAC/B,WAAYA,EAAM,OAAO,WACzB,mBAAoBA,EAAM,QAAQ,mBAClC,kBAAmBA,EAAM,QAAQ,kBACjC,gBAAiBA,EAAM,QAAQ,eACjC,EAEA,MAAO,CAAE,GAAGG,EAAUH,CAAc,EAAG,GAAGC,EAAe,GAAID,CAAM,CACrE","names":["storeToV1","modulesToV1","modules","module","worldToV1","world","v1WorldConfig","modulesToV1","storeToV1"]}
@@ -1,2 +0,0 @@
1
- import{a as o,b as t}from"./chunk-343CB7TH.js";import{z as e}from"zod";import{DynamicResolutionType as n,zEthereumAddress as a,zName as l,zObjectName as s}from"@latticexyz/config/library";var r=s,c=s,i=e.array(r.or(a)).readonly().default(o.accessList),d=e.intersection(e.object({name:l.optional(),registerFunctionSelectors:e.boolean().default(o.registerFunctionSelector)}),e.discriminatedUnion("openAccess",[e.object({openAccess:e.literal(!0).default(o.openAccess)}),e.object({openAccess:e.literal(!1),accessList:i})])),u=e.object({value:e.union([e.string(),e.number(),e.instanceof(Uint8Array)]),type:e.string()}),m=e.object({type:e.nativeEnum(n),input:e.string()}),y=e.object({name:c,root:e.boolean().default(!1),args:e.array(e.union([u,m])).readonly().default([])}),f=e.object({worldContractName:e.string().optional(),worldInterfaceName:e.string().default(t.worldInterfaceName),systems:e.record(r,d).default(t.systems),excludeSystems:e.array(r).readonly().default(t.excludeSystems),postDeployScript:e.string().default(t.postDeployScript),deploysDirectory:e.string().default(t.deploysDirectory),worldsFile:e.string().default(t.worldsFile),worldgenDirectory:e.string().default(t.worldgenDirectory),worldImportPath:e.string().default(t.worldImportPath),modules:e.array(y).readonly().default(t.modules)}),S=f.catchall(e.any());export{f as a,S as b};
2
- //# sourceMappingURL=chunk-NPFZQNKD.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/config/worldConfig.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { DynamicResolutionType, zEthereumAddress, zName, zObjectName } from \"@latticexyz/config/library\";\nimport { SYSTEM_DEFAULTS, WORLD_DEFAULTS } from \"./defaults\";\n\nconst zSystemName = zObjectName;\nconst zModuleName = zObjectName;\nconst zSystemAccessList = z.array(zSystemName.or(zEthereumAddress)).readonly().default(SYSTEM_DEFAULTS.accessList);\n\n// The system config is a combination of a name config and access config\nconst zSystemConfig = z.intersection(\n z.object({\n name: zName.optional(),\n registerFunctionSelectors: z.boolean().default(SYSTEM_DEFAULTS.registerFunctionSelector),\n }),\n z.discriminatedUnion(\"openAccess\", [\n z.object({\n openAccess: z.literal(true).default(SYSTEM_DEFAULTS.openAccess),\n }),\n z.object({\n openAccess: z.literal(false),\n accessList: zSystemAccessList,\n }),\n ]),\n);\n\nconst zValueWithType = z.object({\n value: z.union([z.string(), z.number(), z.instanceof(Uint8Array)]),\n type: z.string(),\n});\nconst zDynamicResolution = z.object({ type: z.nativeEnum(DynamicResolutionType), input: z.string() });\n\nconst zModuleConfig = z.object({\n name: zModuleName,\n root: z.boolean().default(false),\n args: z\n .array(z.union([zValueWithType, zDynamicResolution]))\n .readonly()\n .default([]),\n});\n\n// The parsed world config is the result of parsing the user config\nexport const zWorldConfig = z.object({\n worldContractName: z.string().optional(),\n worldInterfaceName: z.string().default(WORLD_DEFAULTS.worldInterfaceName),\n systems: z.record(zSystemName, zSystemConfig).default(WORLD_DEFAULTS.systems),\n excludeSystems: z.array(zSystemName).readonly().default(WORLD_DEFAULTS.excludeSystems),\n postDeployScript: z.string().default(WORLD_DEFAULTS.postDeployScript),\n deploysDirectory: z.string().default(WORLD_DEFAULTS.deploysDirectory),\n worldsFile: z.string().default(WORLD_DEFAULTS.worldsFile),\n worldgenDirectory: z.string().default(WORLD_DEFAULTS.worldgenDirectory),\n worldImportPath: z.string().default(WORLD_DEFAULTS.worldImportPath),\n modules: z.array(zModuleConfig).readonly().default(WORLD_DEFAULTS.modules),\n});\n\n// Catchall preserves other plugins' options\nexport const zPluginWorldConfig = zWorldConfig.catchall(z.any());\n"],"mappings":"+CAAA,OAAS,KAAAA,MAAS,MAClB,OAAS,yBAAAC,EAAuB,oBAAAC,EAAkB,SAAAC,EAAO,eAAAC,MAAmB,6BAG5E,IAAMC,EAAcC,EACdC,EAAcD,EACdE,EAAoBC,EAAE,MAAMJ,EAAY,GAAGK,CAAgB,CAAC,EAAE,SAAS,EAAE,QAAQC,EAAgB,UAAU,EAG3GC,EAAgBH,EAAE,aACtBA,EAAE,OAAO,CACP,KAAMI,EAAM,SAAS,EACrB,0BAA2BJ,EAAE,QAAQ,EAAE,QAAQE,EAAgB,wBAAwB,CACzF,CAAC,EACDF,EAAE,mBAAmB,aAAc,CACjCA,EAAE,OAAO,CACP,WAAYA,EAAE,QAAQ,EAAI,EAAE,QAAQE,EAAgB,UAAU,CAChE,CAAC,EACDF,EAAE,OAAO,CACP,WAAYA,EAAE,QAAQ,EAAK,EAC3B,WAAYD,CACd,CAAC,CACH,CAAC,CACH,EAEMM,EAAiBL,EAAE,OAAO,CAC9B,MAAOA,EAAE,MAAM,CAACA,EAAE,OAAO,EAAGA,EAAE,OAAO,EAAGA,EAAE,WAAW,UAAU,CAAC,CAAC,EACjE,KAAMA,EAAE,OAAO,CACjB,CAAC,EACKM,EAAqBN,EAAE,OAAO,CAAE,KAAMA,EAAE,WAAWO,CAAqB,EAAG,MAAOP,EAAE,OAAO,CAAE,CAAC,EAE9FQ,EAAgBR,EAAE,OAAO,CAC7B,KAAMF,EACN,KAAME,EAAE,QAAQ,EAAE,QAAQ,EAAK,EAC/B,KAAMA,EACH,MAAMA,EAAE,MAAM,CAACK,EAAgBC,CAAkB,CAAC,CAAC,EACnD,SAAS,EACT,QAAQ,CAAC,CAAC,CACf,CAAC,EAGYG,EAAeT,EAAE,OAAO,CACnC,kBAAmBA,EAAE,OAAO,EAAE,SAAS,EACvC,mBAAoBA,EAAE,OAAO,EAAE,QAAQU,EAAe,kBAAkB,EACxE,QAASV,EAAE,OAAOJ,EAAaO,CAAa,EAAE,QAAQO,EAAe,OAAO,EAC5E,eAAgBV,EAAE,MAAMJ,CAAW,EAAE,SAAS,EAAE,QAAQc,EAAe,cAAc,EACrF,iBAAkBV,EAAE,OAAO,EAAE,QAAQU,EAAe,gBAAgB,EACpE,iBAAkBV,EAAE,OAAO,EAAE,QAAQU,EAAe,gBAAgB,EACpE,WAAYV,EAAE,OAAO,EAAE,QAAQU,EAAe,UAAU,EACxD,kBAAmBV,EAAE,OAAO,EAAE,QAAQU,EAAe,iBAAiB,EACtE,gBAAiBV,EAAE,OAAO,EAAE,QAAQU,EAAe,eAAe,EAClE,QAASV,EAAE,MAAMQ,CAAa,EAAE,SAAS,EAAE,QAAQE,EAAe,OAAO,CAC3E,CAAC,EAGYC,EAAqBF,EAAa,SAAST,EAAE,IAAI,CAAC","names":["z","DynamicResolutionType","zEthereumAddress","zName","zObjectName","zSystemName","zObjectName","zModuleName","zSystemAccessList","z","zEthereumAddress","SYSTEM_DEFAULTS","zSystemConfig","zName","zValueWithType","zDynamicResolution","DynamicResolutionType","zModuleConfig","zWorldConfig","WORLD_DEFAULTS","zPluginWorldConfig"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../ts/config/resolveWorldConfig.ts"],"sourcesContent":["import { UnrecognizedSystemErrorFactory } from \"@latticexyz/config/library\";\nimport { StoreConfig } from \"@latticexyz/store/internal\";\nimport { SystemConfig, WorldConfig } from \"./types\";\n\nexport type ResolvedSystemConfig = ReturnType<typeof resolveSystemConfig>;\n\nexport type ResolvedWorldConfig = ReturnType<typeof resolveWorldConfig>;\n\n/**\n * Resolves the world config by combining the default and overridden system configs,\n * filtering out excluded systems, validate system names refer to existing contracts, and\n * splitting the access list into addresses and system names.\n */\nexport function resolveWorldConfig(config: StoreConfig & WorldConfig, existingContracts?: string[]) {\n // Include contract names ending in \"System\", but not the base \"System\" contract, and not Interfaces\n const defaultSystemNames =\n existingContracts?.filter((name) => name.endsWith(\"System\") && name !== \"System\" && !name.match(/^I[A-Z]/)) ?? [];\n const overriddenSystemNames = Object.keys(config.systems);\n\n // Validate every key in systems refers to an existing system contract (and is not called \"World\")\n if (existingContracts) {\n for (const systemName of overriddenSystemNames) {\n if (!existingContracts.includes(systemName) || systemName === \"World\") {\n throw UnrecognizedSystemErrorFactory([\"systems\", systemName], systemName);\n }\n }\n }\n\n // Combine the default and overridden system names and filter out excluded systems\n const systemNames = [...new Set([...defaultSystemNames, ...overriddenSystemNames])].filter(\n (name) => !config.excludeSystems.includes(name),\n );\n\n // Resolve the config\n const resolvedSystems: Record<string, ResolvedSystemConfig> = systemNames.reduce((acc, systemName) => {\n return {\n ...acc,\n [systemName]: resolveSystemConfig(systemName, config.systems[systemName], existingContracts),\n };\n }, {});\n\n return { systems: resolvedSystems };\n}\n\n/**\n * Resolves the system config by combining the default and overridden system configs,\n * @param systemName name of the system\n * @param config optional SystemConfig object, if none is provided the default config is used\n * @param existingContracts optional list of existing contract names, used to validate system names in the access list. If not provided, no validation is performed.\n * @returns ResolvedSystemConfig object\n * Default value for name is `systemName`\n * Default value for registerFunctionSelectors is true\n * Default value for openAccess is true\n * Default value for accessListAddresses is []\n * Default value for accessListSystems is []\n */\nexport function resolveSystemConfig(systemName: string, config?: SystemConfig, existingContracts?: string[]) {\n const name = config?.name ?? systemName;\n const registerFunctionSelectors = config?.registerFunctionSelectors ?? true;\n const openAccess = config?.openAccess ?? true;\n const accessListAddresses: string[] = [];\n const accessListSystems: string[] = [];\n const accessList = config && !config.openAccess ? config.accessList : [];\n\n // Split the access list into addresses and system names\n for (const accessListItem of accessList) {\n if (accessListItem.startsWith(\"0x\")) {\n accessListAddresses.push(accessListItem);\n } else {\n // Validate every system refers to an existing system contract\n if (existingContracts && !existingContracts.includes(accessListItem)) {\n throw UnrecognizedSystemErrorFactory([\"systems\", systemName, \"accessList\"], accessListItem);\n }\n accessListSystems.push(accessListItem);\n }\n }\n\n return { name, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };\n}\n"],"mappings":"AAAA,OAAS,kCAAAA,MAAsC,6BAaxC,SAASC,EAAmBC,EAAmCC,EAA8B,CAElG,IAAMC,EACJD,GAAmB,OAAQE,GAASA,EAAK,SAAS,QAAQ,GAAKA,IAAS,UAAY,CAACA,EAAK,MAAM,SAAS,CAAC,GAAK,CAAC,EAC5GC,EAAwB,OAAO,KAAKJ,EAAO,OAAO,EAGxD,GAAIC,GACF,QAAWI,KAAcD,EACvB,GAAI,CAACH,EAAkB,SAASI,CAAU,GAAKA,IAAe,QAC5D,MAAMP,EAA+B,CAAC,UAAWO,CAAU,EAAGA,CAAU,EAkB9E,MAAO,CAAE,QAZW,CAAC,GAAG,IAAI,IAAI,CAAC,GAAGH,EAAoB,GAAGE,CAAqB,CAAC,CAAC,EAAE,OACjFD,GAAS,CAACH,EAAO,eAAe,SAASG,CAAI,CAChD,EAG0E,OAAO,CAACG,EAAKD,KAC9E,CACL,GAAGC,EACH,CAACD,CAAU,EAAGE,EAAoBF,EAAYL,EAAO,QAAQK,CAAU,EAAGJ,CAAiB,CAC7F,GACC,CAAC,CAAC,CAE6B,CACpC,CAcO,SAASM,EAAoBF,EAAoBL,EAAuBC,EAA8B,CAC3G,IAAME,EAAOH,GAAQ,MAAQK,EACvBG,EAA4BR,GAAQ,2BAA6B,GACjES,EAAaT,GAAQ,YAAc,GACnCU,EAAgC,CAAC,EACjCC,EAA8B,CAAC,EAC/BC,EAAaZ,GAAU,CAACA,EAAO,WAAaA,EAAO,WAAa,CAAC,EAGvE,QAAWa,KAAkBD,EAC3B,GAAIC,EAAe,WAAW,IAAI,EAChCH,EAAoB,KAAKG,CAAc,MAClC,CAEL,GAAIZ,GAAqB,CAACA,EAAkB,SAASY,CAAc,EACjE,MAAMf,EAA+B,CAAC,UAAWO,EAAY,YAAY,EAAGQ,CAAc,EAE5FF,EAAkB,KAAKE,CAAc,EAIzC,MAAO,CAAE,KAAAV,EAAM,0BAAAK,EAA2B,WAAAC,EAAY,oBAAAC,EAAqB,kBAAAC,CAAkB,CAC/F","names":["UnrecognizedSystemErrorFactory","resolveWorldConfig","config","existingContracts","defaultSystemNames","name","overriddenSystemNames","systemName","acc","resolveSystemConfig","registerFunctionSelectors","openAccess","accessListAddresses","accessListSystems","accessList","accessListItem"]}