@latticexyz/cli 1.41.0 → 1.41.1-alpha.41

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 (53) hide show
  1. package/dist/{chunk-GR245KYP.js → chunk-J4DJQNIC.js} +679 -133
  2. package/dist/chunk-O57QENJ6.js +23039 -0
  3. package/dist/config/index.d.ts +610 -296
  4. package/dist/config/index.js +49 -26
  5. package/dist/index.d.ts +2 -110
  6. package/dist/index.js +9 -50
  7. package/dist/mud.js +937 -57
  8. package/dist/utils/index.d.ts +92 -4
  9. package/dist/utils/index.js +2 -3
  10. package/package.json +10 -9
  11. package/src/commands/deploy-v2.ts +11 -15
  12. package/src/commands/index.ts +2 -0
  13. package/src/commands/worldgen.ts +55 -0
  14. package/src/config/commonSchemas.ts +11 -13
  15. package/src/config/dynamicResolution.ts +49 -0
  16. package/src/config/index.ts +15 -3
  17. package/src/config/loadStoreConfig.ts +1 -1
  18. package/src/config/parseStoreConfig.test-d.ts +31 -5
  19. package/src/config/parseStoreConfig.ts +218 -78
  20. package/src/config/validation.ts +25 -0
  21. package/src/config/world/index.ts +4 -0
  22. package/src/config/{loadWorldConfig.test-d.ts → world/loadWorldConfig.test-d.ts} +3 -3
  23. package/src/config/world/loadWorldConfig.ts +26 -0
  24. package/src/config/world/parseWorldConfig.ts +55 -0
  25. package/src/config/world/resolveWorldConfig.ts +80 -0
  26. package/src/config/world/userTypes.ts +72 -0
  27. package/src/index.ts +4 -6
  28. package/src/render-solidity/common.ts +51 -6
  29. package/src/render-solidity/field.ts +40 -44
  30. package/src/render-solidity/index.ts +5 -1
  31. package/src/render-solidity/record.ts +56 -73
  32. package/src/render-solidity/renderSystemInterface.ts +31 -0
  33. package/src/render-solidity/renderTable.ts +98 -70
  34. package/src/render-solidity/renderTypeHelpers.ts +99 -0
  35. package/src/render-solidity/renderTypesFromConfig.ts +2 -2
  36. package/src/render-solidity/renderWorld.ts +24 -0
  37. package/src/render-solidity/{renderTablesFromConfig.ts → tableOptions.ts} +28 -30
  38. package/src/render-solidity/tablegen.ts +20 -22
  39. package/src/render-solidity/types.ts +39 -5
  40. package/src/render-solidity/userType.ts +80 -48
  41. package/src/render-solidity/worldgen.ts +60 -0
  42. package/src/utils/contractToInterface.ts +130 -0
  43. package/src/utils/deploy-v2.ts +268 -101
  44. package/src/utils/formatAndWrite.ts +12 -0
  45. package/src/utils/getChainId.ts +10 -0
  46. package/src/utils/typeUtils.ts +17 -0
  47. package/dist/chunk-AER7UDD4.js +0 -0
  48. package/dist/chunk-XRS7KWBZ.js +0 -547
  49. package/dist/chunk-YZATC2M3.js +0 -397
  50. package/dist/chunk-ZYDMYSTH.js +0 -1178
  51. package/dist/deploy-v2-b7b3207d.d.ts +0 -92
  52. package/src/config/loadWorldConfig.ts +0 -178
  53. package/src/constants.ts +0 -1
@@ -1,60 +1,83 @@
1
1
  import {
2
- AnyCaseName,
3
- BaseRoute,
4
- EthereumAddress,
5
- ObjectName,
6
- OrdinaryRoute,
7
- SingleLevelRoute,
8
- StaticSchemaType,
9
- StoreConfig,
10
- UserEnum,
11
- ValueName,
12
- WorldConfig,
2
+ DynamicResolutionType,
13
3
  getDuplicates,
4
+ isDynamicResolution,
14
5
  loadConfig,
15
6
  loadStoreConfig,
16
7
  loadWorldConfig,
8
+ mudConfig,
9
+ parseStaticArray,
17
10
  parseStoreConfig,
18
11
  parseWorldConfig,
19
12
  resolveSystemConfig,
13
+ resolveTableId,
14
+ resolveWithContext,
20
15
  resolveWorldConfig,
16
+ storeConfig,
21
17
  validateBaseRoute,
22
18
  validateCapitalizedName,
23
19
  validateEnum,
24
20
  validateEthereumAddress,
25
21
  validateName,
26
22
  validateRoute,
23
+ validateSelector,
27
24
  validateSingleLevelRoute,
28
- validateUncapitalizedName
29
- } from "../chunk-YZATC2M3.js";
30
- import "../chunk-GR245KYP.js";
25
+ validateUncapitalizedName,
26
+ zAnyCaseName,
27
+ zBaseRoute,
28
+ zEnumsConfig,
29
+ zEthereumAddress,
30
+ zObjectName,
31
+ zOrdinaryRoute,
32
+ zSchemaConfig,
33
+ zSelector,
34
+ zSingleLevelRoute,
35
+ zStoreConfig,
36
+ zTableConfig,
37
+ zTablesConfig,
38
+ zUserEnum,
39
+ zValueName,
40
+ zWorldConfig
41
+ } from "../chunk-J4DJQNIC.js";
31
42
  import "../chunk-O6HOO6WA.js";
32
43
  export {
33
- AnyCaseName,
34
- BaseRoute,
35
- EthereumAddress,
36
- ObjectName,
37
- OrdinaryRoute,
38
- SingleLevelRoute,
39
- StaticSchemaType,
40
- StoreConfig,
41
- UserEnum,
42
- ValueName,
43
- WorldConfig,
44
+ DynamicResolutionType,
44
45
  getDuplicates,
46
+ isDynamicResolution,
45
47
  loadConfig,
46
48
  loadStoreConfig,
47
49
  loadWorldConfig,
50
+ mudConfig,
51
+ parseStaticArray,
48
52
  parseStoreConfig,
49
53
  parseWorldConfig,
50
54
  resolveSystemConfig,
55
+ resolveTableId,
56
+ resolveWithContext,
51
57
  resolveWorldConfig,
58
+ storeConfig,
52
59
  validateBaseRoute,
53
60
  validateCapitalizedName,
54
61
  validateEnum,
55
62
  validateEthereumAddress,
56
63
  validateName,
57
64
  validateRoute,
65
+ validateSelector,
58
66
  validateSingleLevelRoute,
59
- validateUncapitalizedName
67
+ validateUncapitalizedName,
68
+ zAnyCaseName,
69
+ zBaseRoute,
70
+ zEnumsConfig,
71
+ zEthereumAddress,
72
+ zObjectName,
73
+ zOrdinaryRoute,
74
+ zSchemaConfig,
75
+ zSelector,
76
+ zSingleLevelRoute,
77
+ zStoreConfig,
78
+ zTableConfig,
79
+ zTablesConfig,
80
+ zUserEnum,
81
+ zValueName,
82
+ zWorldConfig
60
83
  };
package/dist/index.d.ts CHANGED
@@ -1,111 +1,3 @@
1
- import { StoreConfig } from './config/index.js';
2
- export { MUDConfig, MUDUserConfig, ResolvedWorldConfig, StoreConfig, StoreUserConfig, WorldUserConfig, loadStoreConfig, loadWorldConfig, parseStoreConfig, parseWorldConfig, resolveWorldConfig } from './config/index.js';
3
- import * as _latticexyz_schema_type from '@latticexyz/schema-type';
4
- export { D as DeployConfig, m as DeploymentInfo, F as ForgeConfig, M as MUDError, a as NotESMConfigError, N as NotInsideProjectError, U as UnrecognizedSystemErrorFactory, j as cast, n as deploy, i as forge, k as formatSolidity, f as fromZodErrorCustom, g as getForgeConfig, e as getOutDirectory, h as getRpcUrl, c as getScriptDirectory, b as getSrcDirectory, d as getTestDirectory, l as logError } from './deploy-v2-b7b3207d.js';
1
+ export { MUDConfig, MUDUserConfig, ResolvedWorldConfig, StoreConfig, StoreUserConfig, WorldUserConfig, loadStoreConfig, loadWorldConfig, mudConfig, parseStoreConfig, parseWorldConfig, resolveTableId, resolveWorldConfig, storeConfig } from './config/index.js';
2
+ import '@latticexyz/schema-type';
5
3
  import 'zod';
6
- import 'zod-validation-error';
7
-
8
- declare function renderTablesFromConfig(config: StoreConfig, srcDirectory: string): {
9
- outputDirectory: string;
10
- tableName: string;
11
- tableData: {
12
- route?: string | undefined;
13
- dataStruct?: boolean | undefined;
14
- directory: string;
15
- tableIdArgument: boolean;
16
- storeArgument: boolean;
17
- primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
18
- schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
19
- } & Required<Pick<{
20
- route?: string | undefined;
21
- dataStruct?: boolean | undefined;
22
- directory: string;
23
- tableIdArgument: boolean;
24
- storeArgument: boolean;
25
- primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
26
- schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
27
- }, "dataStruct">> & Required<Pick<{
28
- route?: string | undefined;
29
- dataStruct?: boolean | undefined;
30
- directory: string;
31
- tableIdArgument: boolean;
32
- storeArgument: boolean;
33
- primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
34
- schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
35
- } & Required<Pick<{
36
- route?: string | undefined;
37
- dataStruct?: boolean | undefined;
38
- directory: string;
39
- tableIdArgument: boolean;
40
- storeArgument: boolean;
41
- primaryKeys: Record<string, string | _latticexyz_schema_type.SchemaType>;
42
- schema: Record<string, string | _latticexyz_schema_type.SchemaType>;
43
- }, "dataStruct">>, "route">>;
44
- output: string;
45
- }[];
46
-
47
- interface RenderTableOptions {
48
- /** List of symbols to import, and their file paths */
49
- imports: ImportDatum[];
50
- /** Name of the library to render. */
51
- libraryName: string;
52
- /** Name of the struct to render. If undefined, struct and its methods aren't rendered. */
53
- structName?: string;
54
- /** Data used to statically registed the table. If undefined, all methods receive `_tableId` as an argument. */
55
- staticRouteData?: StaticRouteData;
56
- /** Path for store package imports */
57
- storeImportPath: string;
58
- primaryKeys: RenderTablePrimaryKey[];
59
- fields: RenderTableField[];
60
- staticFields: RenderTableStaticField[];
61
- dynamicFields: RenderTableDynamicField[];
62
- /** Whether to render get/set methods for the whole record */
63
- withRecordMethods: boolean;
64
- /** Whether to render additional methods that accept a manual `IStore` argument */
65
- storeArgument: boolean;
66
- }
67
- interface ImportDatum {
68
- symbol: string;
69
- path: string;
70
- }
71
- interface StaticRouteData {
72
- /** Name of the table id constant to render. */
73
- tableIdName: string;
74
- baseRoute: string;
75
- subRoute: string;
76
- }
77
- interface RenderTableType {
78
- typeId: string;
79
- typeWithLocation: string;
80
- /** The name of the enum element in SchemaType to use for schema registration (e.g. "UINT256_ARRAY") */
81
- enumName: string;
82
- staticByteLength: number;
83
- isDynamic: boolean;
84
- /** Empty for internal types. Custom `wrap` method for user defined types. */
85
- typeWrap: string;
86
- /** Empty for internal types. Custom `unwrap` method for user defined types. */
87
- typeUnwrap: string;
88
- /** Same as typeId for internal types. The underlying `typeId` for user defined types. */
89
- internalTypeId: string;
90
- }
91
- interface RenderTablePrimaryKey extends RenderTableType {
92
- name: string;
93
- isDynamic: false;
94
- }
95
- interface RenderTableStaticField extends RenderTableField {
96
- isDynamic: false;
97
- }
98
- interface RenderTableDynamicField extends RenderTableField {
99
- isDynamic: true;
100
- }
101
- interface RenderTableField extends RenderTableType {
102
- arrayElement: RenderTableType | undefined;
103
- name: string;
104
- methodNameSuffix: string;
105
- }
106
-
107
- declare function renderTable(options: RenderTableOptions): string;
108
-
109
- declare const deploymentInfoFilenamePrefix = "mud-deployment-";
110
-
111
- export { deploymentInfoFilenamePrefix, renderTable, renderTablesFromConfig };
package/dist/index.js CHANGED
@@ -1,62 +1,21 @@
1
- import {
2
- deploymentInfoFilenamePrefix,
3
- renderTable,
4
- renderTablesFromConfig
5
- } from "./chunk-XRS7KWBZ.js";
6
1
  import {
7
2
  loadStoreConfig,
8
3
  loadWorldConfig,
4
+ mudConfig,
9
5
  parseStoreConfig,
10
6
  parseWorldConfig,
11
- resolveWorldConfig
12
- } from "./chunk-YZATC2M3.js";
13
- import "./chunk-AER7UDD4.js";
14
- import {
15
- deploy,
16
- formatSolidity
17
- } from "./chunk-ZYDMYSTH.js";
18
- import {
19
- MUDError,
20
- NotESMConfigError,
21
- NotInsideProjectError,
22
- UnrecognizedSystemErrorFactory,
23
- fromZodErrorCustom,
24
- logError
25
- } from "./chunk-GR245KYP.js";
26
- import {
27
- cast,
28
- forge,
29
- getForgeConfig,
30
- getOutDirectory,
31
- getRpcUrl,
32
- getScriptDirectory,
33
- getSrcDirectory,
34
- getTestDirectory
35
- } from "./chunk-ATAWDHWC.js";
7
+ resolveTableId,
8
+ resolveWorldConfig,
9
+ storeConfig
10
+ } from "./chunk-J4DJQNIC.js";
36
11
  import "./chunk-O6HOO6WA.js";
37
12
  export {
38
- MUDError,
39
- NotESMConfigError,
40
- NotInsideProjectError,
41
- UnrecognizedSystemErrorFactory,
42
- cast,
43
- deploy,
44
- deploymentInfoFilenamePrefix,
45
- forge,
46
- formatSolidity,
47
- fromZodErrorCustom,
48
- getForgeConfig,
49
- getOutDirectory,
50
- getRpcUrl,
51
- getScriptDirectory,
52
- getSrcDirectory,
53
- getTestDirectory,
54
13
  loadStoreConfig,
55
14
  loadWorldConfig,
56
- logError,
15
+ mudConfig,
57
16
  parseStoreConfig,
58
17
  parseWorldConfig,
59
- renderTable,
60
- renderTablesFromConfig,
61
- resolveWorldConfig
18
+ resolveTableId,
19
+ resolveWorldConfig,
20
+ storeConfig
62
21
  };