@latticexyz/cli 2.0.0-alpha.93 → 2.0.0-foundry-js-c7b0289b

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 (139) hide show
  1. package/dist/chunk-22IIKR4S.js +4 -0
  2. package/dist/chunk-22IIKR4S.js.map +1 -0
  3. package/dist/commands-UYAATBY6.js +27 -0
  4. package/dist/commands-UYAATBY6.js.map +1 -0
  5. package/dist/errors-XGN6V2Y3.js +2 -0
  6. package/dist/errors-XGN6V2Y3.js.map +1 -0
  7. package/dist/index.js +1 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/mud.js +2 -8340
  10. package/dist/mud.js.map +1 -0
  11. package/package.json +54 -46
  12. package/src/commands/deploy.ts +26 -0
  13. package/src/commands/dev-contracts.ts +114 -0
  14. package/src/commands/devnode.ts +7 -2
  15. package/src/commands/faucet.ts +1 -1
  16. package/src/commands/index.ts +19 -14
  17. package/src/commands/set-version.ts +103 -81
  18. package/src/commands/tablegen.ts +7 -5
  19. package/src/commands/test.ts +65 -0
  20. package/src/commands/trace.ts +118 -0
  21. package/src/commands/worldgen.ts +29 -28
  22. package/src/common.ts +1 -0
  23. package/src/debug.ts +3 -0
  24. package/src/deploy/assertNamespaceOwner.ts +42 -0
  25. package/src/deploy/common.ts +76 -0
  26. package/src/deploy/configToTables.ts +68 -0
  27. package/src/deploy/create2/README.md +9 -0
  28. package/src/deploy/create2/deployment.json +7 -0
  29. package/src/deploy/debug.ts +3 -0
  30. package/src/deploy/deploy.ts +108 -0
  31. package/src/deploy/deployWorld.ts +33 -0
  32. package/src/deploy/ensureContract.ts +61 -0
  33. package/src/deploy/ensureContractsDeployed.ts +25 -0
  34. package/src/deploy/ensureDeployer.ts +36 -0
  35. package/src/deploy/ensureFunctions.ts +86 -0
  36. package/src/deploy/ensureModules.ts +73 -0
  37. package/src/deploy/ensureSystems.ts +162 -0
  38. package/src/deploy/ensureTables.ts +65 -0
  39. package/src/deploy/ensureWorldFactory.ts +47 -0
  40. package/src/deploy/getFunctions.ts +58 -0
  41. package/src/deploy/getResourceAccess.ts +51 -0
  42. package/src/deploy/getResourceIds.ts +31 -0
  43. package/src/deploy/getSystems.ts +48 -0
  44. package/src/deploy/getTableValue.ts +30 -0
  45. package/src/deploy/getTables.ts +59 -0
  46. package/src/deploy/getWorldDeploy.ts +39 -0
  47. package/src/deploy/logsToWorldDeploy.ts +49 -0
  48. package/src/deploy/resolveConfig.ts +151 -0
  49. package/src/deploy/resourceLabel.ts +3 -0
  50. package/src/index.ts +1 -1
  51. package/src/modules.d.ts +11 -0
  52. package/src/mud.ts +38 -23
  53. package/src/mudPackages.ts +24 -0
  54. package/src/runDeploy.ts +128 -0
  55. package/src/utils/errors.ts +1 -1
  56. package/src/utils/getExistingContracts.ts +12 -0
  57. package/src/utils/modules/constants.ts +26 -0
  58. package/src/utils/printMUD.ts +14 -0
  59. package/src/utils/utils/getContractData.ts +32 -0
  60. package/src/utils/utils/postDeploy.ts +25 -0
  61. package/dist/chunk-6V563IAZ.js +0 -283
  62. package/dist/chunk-FPG73MVN.js +0 -71
  63. package/dist/chunk-L4YLJHLJ.js +0 -30
  64. package/dist/chunk-P5YXGXRI.js +0 -3842
  65. package/dist/chunk-SKNB74MT.js +0 -726
  66. package/dist/chunk-VQTZJIFF.js +0 -353
  67. package/dist/chunk-WZFXLDPK.js +0 -761
  68. package/dist/chunk-YL4GJLLL.js +0 -26139
  69. package/dist/index.d.ts +0 -2
  70. package/dist/mud.d.ts +0 -1
  71. package/dist/mud2.d.ts +0 -1
  72. package/dist/mud2.js +0 -25
  73. package/dist/render-solidity/index.d.ts +0 -171
  74. package/dist/render-solidity/index.js +0 -49
  75. package/dist/render-ts/index.d.ts +0 -26
  76. package/dist/render-ts/index.js +0 -14
  77. package/dist/utils/deprecated/index.d.ts +0 -76
  78. package/dist/utils/deprecated/index.js +0 -36
  79. package/dist/utils/index.d.ts +0 -88
  80. package/dist/utils/index.js +0 -39
  81. package/src/commands/deploy-v2.ts +0 -112
  82. package/src/commands/deprecated/bulkupload.ts +0 -50
  83. package/src/commands/deprecated/call-system.ts +0 -70
  84. package/src/commands/deprecated/codegen-libdeploy.ts +0 -29
  85. package/src/commands/deprecated/deploy-contracts.ts +0 -120
  86. package/src/commands/deprecated/index.ts +0 -22
  87. package/src/commands/deprecated/system-types.ts +0 -29
  88. package/src/commands/deprecated/test.ts +0 -53
  89. package/src/commands/deprecated/trace.ts +0 -81
  90. package/src/commands/deprecated/types.ts +0 -33
  91. package/src/commands/gas-report.ts +0 -219
  92. package/src/commands/test-v2.ts +0 -71
  93. package/src/commands/tsgen.ts +0 -33
  94. package/src/contracts/BulkUpload.sol +0 -174
  95. package/src/contracts/Deploy.sol +0 -23
  96. package/src/contracts/LibDeploy.ejs +0 -121
  97. package/src/contracts/LibDeploy.sol +0 -23
  98. package/src/contracts/LibDeployStub.sol +0 -23
  99. package/src/mud2.ts +0 -29
  100. package/src/render-solidity/common.ts +0 -138
  101. package/src/render-solidity/field.ts +0 -160
  102. package/src/render-solidity/index.ts +0 -10
  103. package/src/render-solidity/record.ts +0 -158
  104. package/src/render-solidity/renderSystemInterface.ts +0 -31
  105. package/src/render-solidity/renderTable.ts +0 -164
  106. package/src/render-solidity/renderTableIndex.ts +0 -15
  107. package/src/render-solidity/renderTypeHelpers.ts +0 -99
  108. package/src/render-solidity/renderTypes.ts +0 -19
  109. package/src/render-solidity/renderTypesFromConfig.ts +0 -13
  110. package/src/render-solidity/renderWorld.ts +0 -24
  111. package/src/render-solidity/tableOptions.ts +0 -107
  112. package/src/render-solidity/tablegen.ts +0 -35
  113. package/src/render-solidity/types.ts +0 -111
  114. package/src/render-solidity/userType.ts +0 -131
  115. package/src/render-solidity/worldgen.ts +0 -59
  116. package/src/render-ts/index.ts +0 -5
  117. package/src/render-ts/recsV1TableOptions.ts +0 -39
  118. package/src/render-ts/renderRecsV1Tables.ts +0 -31
  119. package/src/render-ts/schemaTypesToRecsTypeStrings.ts +0 -202
  120. package/src/render-ts/tsgen.ts +0 -12
  121. package/src/render-ts/types.ts +0 -13
  122. package/src/utils/contractToInterface.ts +0 -132
  123. package/src/utils/deploy-v2.ts +0 -518
  124. package/src/utils/deprecated/build.ts +0 -55
  125. package/src/utils/deprecated/codegen.ts +0 -42
  126. package/src/utils/deprecated/constants.ts +0 -2
  127. package/src/utils/deprecated/deploy.ts +0 -111
  128. package/src/utils/deprecated/exec.ts +0 -18
  129. package/src/utils/deprecated/findLog.ts +0 -8
  130. package/src/utils/deprecated/hsr.ts +0 -71
  131. package/src/utils/deprecated/ids.ts +0 -14
  132. package/src/utils/deprecated/index.ts +0 -8
  133. package/src/utils/deprecated/typegen.ts +0 -133
  134. package/src/utils/execLog.ts +0 -22
  135. package/src/utils/format.ts +0 -39
  136. package/src/utils/formatAndWrite.ts +0 -21
  137. package/src/utils/foundry.ts +0 -103
  138. package/src/utils/getChainId.ts +0 -10
  139. package/src/utils/index.ts +0 -5
@@ -1,31 +0,0 @@
1
- import { RecsV1TableOptions } from "./types.js";
2
-
3
- export function renderRecsV1Tables(options: RecsV1TableOptions) {
4
- const { tables } = options;
5
-
6
- return `/* Autogenerated file. Do not edit manually. */
7
-
8
- import { TableId } from "@latticexyz/utils";
9
- import { defineComponent, Type as RecsType, World } from "@latticexyz/recs";
10
-
11
- export function defineContractComponents(world: World) {
12
- return {
13
- ${tables.map((table) => `${table.tableName}: ${renderDefineComponent(table)},`).join("")}
14
- }
15
- }
16
- `;
17
- }
18
-
19
- function renderDefineComponent(table: RecsV1TableOptions["tables"][number]) {
20
- const { namespace, name } = table.staticResourceData;
21
- return `
22
- (() => {
23
- const tableId = new TableId("${namespace}", "${name}");
24
- return defineComponent(world, {
25
- ${table.fields.map(({ name, recsTypeString }) => `${name}: ${recsTypeString},`).join("")}
26
- }, {
27
- metadata: { contractId: tableId.toHexString(), tableId: tableId.toString() },
28
- });
29
- })()
30
- `;
31
- }
@@ -1,202 +0,0 @@
1
- import { SchemaType } from "@latticexyz/schema-type";
2
-
3
- export const schemaTypesToRecsTypeStrings: Record<SchemaType, string> = {
4
- [SchemaType.UINT8]: "RecsType.Number",
5
- [SchemaType.UINT16]: "RecsType.Number",
6
- [SchemaType.UINT24]: "RecsType.Number",
7
- [SchemaType.UINT32]: "RecsType.Number",
8
- [SchemaType.UINT40]: "RecsType.Number",
9
- [SchemaType.UINT48]: "RecsType.Number",
10
- [SchemaType.UINT56]: "RecsType.BigInt",
11
- [SchemaType.UINT64]: "RecsType.BigInt",
12
- [SchemaType.UINT72]: "RecsType.BigInt",
13
- [SchemaType.UINT80]: "RecsType.BigInt",
14
- [SchemaType.UINT88]: "RecsType.BigInt",
15
- [SchemaType.UINT96]: "RecsType.BigInt",
16
- [SchemaType.UINT104]: "RecsType.BigInt",
17
- [SchemaType.UINT112]: "RecsType.BigInt",
18
- [SchemaType.UINT120]: "RecsType.BigInt",
19
- [SchemaType.UINT128]: "RecsType.BigInt",
20
- [SchemaType.UINT136]: "RecsType.BigInt",
21
- [SchemaType.UINT144]: "RecsType.BigInt",
22
- [SchemaType.UINT152]: "RecsType.BigInt",
23
- [SchemaType.UINT160]: "RecsType.BigInt",
24
- [SchemaType.UINT168]: "RecsType.BigInt",
25
- [SchemaType.UINT176]: "RecsType.BigInt",
26
- [SchemaType.UINT184]: "RecsType.BigInt",
27
- [SchemaType.UINT192]: "RecsType.BigInt",
28
- [SchemaType.UINT200]: "RecsType.BigInt",
29
- [SchemaType.UINT208]: "RecsType.BigInt",
30
- [SchemaType.UINT216]: "RecsType.BigInt",
31
- [SchemaType.UINT224]: "RecsType.BigInt",
32
- [SchemaType.UINT232]: "RecsType.BigInt",
33
- [SchemaType.UINT240]: "RecsType.BigInt",
34
- [SchemaType.UINT248]: "RecsType.BigInt",
35
- [SchemaType.UINT256]: "RecsType.BigInt",
36
- [SchemaType.INT8]: "RecsType.Number",
37
- [SchemaType.INT16]: "RecsType.Number",
38
- [SchemaType.INT24]: "RecsType.Number",
39
- [SchemaType.INT32]: "RecsType.Number",
40
- [SchemaType.INT40]: "RecsType.Number",
41
- [SchemaType.INT48]: "RecsType.Number",
42
- [SchemaType.INT56]: "RecsType.BigInt",
43
- [SchemaType.INT64]: "RecsType.BigInt",
44
- [SchemaType.INT72]: "RecsType.BigInt",
45
- [SchemaType.INT80]: "RecsType.BigInt",
46
- [SchemaType.INT88]: "RecsType.BigInt",
47
- [SchemaType.INT96]: "RecsType.BigInt",
48
- [SchemaType.INT104]: "RecsType.BigInt",
49
- [SchemaType.INT112]: "RecsType.BigInt",
50
- [SchemaType.INT120]: "RecsType.BigInt",
51
- [SchemaType.INT128]: "RecsType.BigInt",
52
- [SchemaType.INT136]: "RecsType.BigInt",
53
- [SchemaType.INT144]: "RecsType.BigInt",
54
- [SchemaType.INT152]: "RecsType.BigInt",
55
- [SchemaType.INT160]: "RecsType.BigInt",
56
- [SchemaType.INT168]: "RecsType.BigInt",
57
- [SchemaType.INT176]: "RecsType.BigInt",
58
- [SchemaType.INT184]: "RecsType.BigInt",
59
- [SchemaType.INT192]: "RecsType.BigInt",
60
- [SchemaType.INT200]: "RecsType.BigInt",
61
- [SchemaType.INT208]: "RecsType.BigInt",
62
- [SchemaType.INT216]: "RecsType.BigInt",
63
- [SchemaType.INT224]: "RecsType.BigInt",
64
- [SchemaType.INT232]: "RecsType.BigInt",
65
- [SchemaType.INT240]: "RecsType.BigInt",
66
- [SchemaType.INT248]: "RecsType.BigInt",
67
- [SchemaType.INT256]: "RecsType.BigInt",
68
- [SchemaType.BYTES1]: "RecsType.String",
69
- [SchemaType.BYTES2]: "RecsType.String",
70
- [SchemaType.BYTES3]: "RecsType.String",
71
- [SchemaType.BYTES4]: "RecsType.String",
72
- [SchemaType.BYTES5]: "RecsType.String",
73
- [SchemaType.BYTES6]: "RecsType.String",
74
- [SchemaType.BYTES7]: "RecsType.String",
75
- [SchemaType.BYTES8]: "RecsType.String",
76
- [SchemaType.BYTES9]: "RecsType.String",
77
- [SchemaType.BYTES10]: "RecsType.String",
78
- [SchemaType.BYTES11]: "RecsType.String",
79
- [SchemaType.BYTES12]: "RecsType.String",
80
- [SchemaType.BYTES13]: "RecsType.String",
81
- [SchemaType.BYTES14]: "RecsType.String",
82
- [SchemaType.BYTES15]: "RecsType.String",
83
- [SchemaType.BYTES16]: "RecsType.String",
84
- [SchemaType.BYTES17]: "RecsType.String",
85
- [SchemaType.BYTES18]: "RecsType.String",
86
- [SchemaType.BYTES19]: "RecsType.String",
87
- [SchemaType.BYTES20]: "RecsType.String",
88
- [SchemaType.BYTES21]: "RecsType.String",
89
- [SchemaType.BYTES22]: "RecsType.String",
90
- [SchemaType.BYTES23]: "RecsType.String",
91
- [SchemaType.BYTES24]: "RecsType.String",
92
- [SchemaType.BYTES25]: "RecsType.String",
93
- [SchemaType.BYTES26]: "RecsType.String",
94
- [SchemaType.BYTES27]: "RecsType.String",
95
- [SchemaType.BYTES28]: "RecsType.String",
96
- [SchemaType.BYTES29]: "RecsType.String",
97
- [SchemaType.BYTES30]: "RecsType.String",
98
- [SchemaType.BYTES31]: "RecsType.String",
99
- [SchemaType.BYTES32]: "RecsType.String",
100
- [SchemaType.BOOL]: "RecsType.Boolean",
101
- [SchemaType.ADDRESS]: "RecsType.String",
102
- [SchemaType.UINT8_ARRAY]: "RecsType.NumberArray",
103
- [SchemaType.UINT16_ARRAY]: "RecsType.NumberArray",
104
- [SchemaType.UINT24_ARRAY]: "RecsType.NumberArray",
105
- [SchemaType.UINT32_ARRAY]: "RecsType.NumberArray",
106
- [SchemaType.UINT40_ARRAY]: "RecsType.NumberArray",
107
- [SchemaType.UINT48_ARRAY]: "RecsType.NumberArray",
108
- [SchemaType.UINT56_ARRAY]: "RecsType.BigIntArray",
109
- [SchemaType.UINT64_ARRAY]: "RecsType.BigIntArray",
110
- [SchemaType.UINT72_ARRAY]: "RecsType.BigIntArray",
111
- [SchemaType.UINT80_ARRAY]: "RecsType.BigIntArray",
112
- [SchemaType.UINT88_ARRAY]: "RecsType.BigIntArray",
113
- [SchemaType.UINT96_ARRAY]: "RecsType.BigIntArray",
114
- [SchemaType.UINT104_ARRAY]: "RecsType.BigIntArray",
115
- [SchemaType.UINT112_ARRAY]: "RecsType.BigIntArray",
116
- [SchemaType.UINT120_ARRAY]: "RecsType.BigIntArray",
117
- [SchemaType.UINT128_ARRAY]: "RecsType.BigIntArray",
118
- [SchemaType.UINT136_ARRAY]: "RecsType.BigIntArray",
119
- [SchemaType.UINT144_ARRAY]: "RecsType.BigIntArray",
120
- [SchemaType.UINT152_ARRAY]: "RecsType.BigIntArray",
121
- [SchemaType.UINT160_ARRAY]: "RecsType.BigIntArray",
122
- [SchemaType.UINT168_ARRAY]: "RecsType.BigIntArray",
123
- [SchemaType.UINT176_ARRAY]: "RecsType.BigIntArray",
124
- [SchemaType.UINT184_ARRAY]: "RecsType.BigIntArray",
125
- [SchemaType.UINT192_ARRAY]: "RecsType.BigIntArray",
126
- [SchemaType.UINT200_ARRAY]: "RecsType.BigIntArray",
127
- [SchemaType.UINT208_ARRAY]: "RecsType.BigIntArray",
128
- [SchemaType.UINT216_ARRAY]: "RecsType.BigIntArray",
129
- [SchemaType.UINT224_ARRAY]: "RecsType.BigIntArray",
130
- [SchemaType.UINT232_ARRAY]: "RecsType.BigIntArray",
131
- [SchemaType.UINT240_ARRAY]: "RecsType.BigIntArray",
132
- [SchemaType.UINT248_ARRAY]: "RecsType.BigIntArray",
133
- [SchemaType.UINT256_ARRAY]: "RecsType.BigIntArray",
134
- [SchemaType.INT8_ARRAY]: "RecsType.NumberArray",
135
- [SchemaType.INT16_ARRAY]: "RecsType.NumberArray",
136
- [SchemaType.INT24_ARRAY]: "RecsType.NumberArray",
137
- [SchemaType.INT32_ARRAY]: "RecsType.NumberArray",
138
- [SchemaType.INT40_ARRAY]: "RecsType.NumberArray",
139
- [SchemaType.INT48_ARRAY]: "RecsType.NumberArray",
140
- [SchemaType.INT56_ARRAY]: "RecsType.BigIntArray",
141
- [SchemaType.INT64_ARRAY]: "RecsType.BigIntArray",
142
- [SchemaType.INT72_ARRAY]: "RecsType.BigIntArray",
143
- [SchemaType.INT80_ARRAY]: "RecsType.BigIntArray",
144
- [SchemaType.INT88_ARRAY]: "RecsType.BigIntArray",
145
- [SchemaType.INT96_ARRAY]: "RecsType.BigIntArray",
146
- [SchemaType.INT104_ARRAY]: "RecsType.BigIntArray",
147
- [SchemaType.INT112_ARRAY]: "RecsType.BigIntArray",
148
- [SchemaType.INT120_ARRAY]: "RecsType.BigIntArray",
149
- [SchemaType.INT128_ARRAY]: "RecsType.BigIntArray",
150
- [SchemaType.INT136_ARRAY]: "RecsType.BigIntArray",
151
- [SchemaType.INT144_ARRAY]: "RecsType.BigIntArray",
152
- [SchemaType.INT152_ARRAY]: "RecsType.BigIntArray",
153
- [SchemaType.INT160_ARRAY]: "RecsType.BigIntArray",
154
- [SchemaType.INT168_ARRAY]: "RecsType.BigIntArray",
155
- [SchemaType.INT176_ARRAY]: "RecsType.BigIntArray",
156
- [SchemaType.INT184_ARRAY]: "RecsType.BigIntArray",
157
- [SchemaType.INT192_ARRAY]: "RecsType.BigIntArray",
158
- [SchemaType.INT200_ARRAY]: "RecsType.BigIntArray",
159
- [SchemaType.INT208_ARRAY]: "RecsType.BigIntArray",
160
- [SchemaType.INT216_ARRAY]: "RecsType.BigIntArray",
161
- [SchemaType.INT224_ARRAY]: "RecsType.BigIntArray",
162
- [SchemaType.INT232_ARRAY]: "RecsType.BigIntArray",
163
- [SchemaType.INT240_ARRAY]: "RecsType.BigIntArray",
164
- [SchemaType.INT248_ARRAY]: "RecsType.BigIntArray",
165
- [SchemaType.INT256_ARRAY]: "RecsType.BigIntArray",
166
- [SchemaType.BYTES1_ARRAY]: "RecsType.BigIntArray",
167
- [SchemaType.BYTES2_ARRAY]: "RecsType.BigIntArray",
168
- [SchemaType.BYTES3_ARRAY]: "RecsType.BigIntArray",
169
- [SchemaType.BYTES4_ARRAY]: "RecsType.BigIntArray",
170
- [SchemaType.BYTES5_ARRAY]: "RecsType.BigIntArray",
171
- [SchemaType.BYTES6_ARRAY]: "RecsType.BigIntArray",
172
- [SchemaType.BYTES7_ARRAY]: "RecsType.BigIntArray",
173
- [SchemaType.BYTES8_ARRAY]: "RecsType.BigIntArray",
174
- [SchemaType.BYTES9_ARRAY]: "RecsType.BigIntArray",
175
- [SchemaType.BYTES10_ARRAY]: "RecsType.BigIntArray",
176
- [SchemaType.BYTES11_ARRAY]: "RecsType.BigIntArray",
177
- [SchemaType.BYTES12_ARRAY]: "RecsType.BigIntArray",
178
- [SchemaType.BYTES13_ARRAY]: "RecsType.BigIntArray",
179
- [SchemaType.BYTES14_ARRAY]: "RecsType.BigIntArray",
180
- [SchemaType.BYTES15_ARRAY]: "RecsType.BigIntArray",
181
- [SchemaType.BYTES16_ARRAY]: "RecsType.BigIntArray",
182
- [SchemaType.BYTES17_ARRAY]: "RecsType.BigIntArray",
183
- [SchemaType.BYTES18_ARRAY]: "RecsType.BigIntArray",
184
- [SchemaType.BYTES19_ARRAY]: "RecsType.BigIntArray",
185
- [SchemaType.BYTES20_ARRAY]: "RecsType.BigIntArray",
186
- [SchemaType.BYTES21_ARRAY]: "RecsType.BigIntArray",
187
- [SchemaType.BYTES22_ARRAY]: "RecsType.BigIntArray",
188
- [SchemaType.BYTES23_ARRAY]: "RecsType.BigIntArray",
189
- [SchemaType.BYTES24_ARRAY]: "RecsType.BigIntArray",
190
- [SchemaType.BYTES25_ARRAY]: "RecsType.BigIntArray",
191
- [SchemaType.BYTES26_ARRAY]: "RecsType.BigIntArray",
192
- [SchemaType.BYTES27_ARRAY]: "RecsType.BigIntArray",
193
- [SchemaType.BYTES28_ARRAY]: "RecsType.BigIntArray",
194
- [SchemaType.BYTES29_ARRAY]: "RecsType.BigIntArray",
195
- [SchemaType.BYTES30_ARRAY]: "RecsType.BigIntArray",
196
- [SchemaType.BYTES31_ARRAY]: "RecsType.BigIntArray",
197
- [SchemaType.BYTES32_ARRAY]: "RecsType.BigIntArray",
198
- [SchemaType.BOOL_ARRAY]: "RecsType.T", // no boolean array
199
- [SchemaType.ADDRESS_ARRAY]: "RecsType.StringArray",
200
- [SchemaType.BYTES]: "RecsType.String",
201
- [SchemaType.STRING]: "RecsType.String",
202
- };
@@ -1,12 +0,0 @@
1
- import path from "path";
2
- import { StoreConfig } from "@latticexyz/config";
3
- import { getRecsV1TableOptions } from "../render-ts/recsV1TableOptions.js";
4
- import { renderRecsV1Tables } from "../render-ts/renderRecsV1Tables.js";
5
- import { formatAndWriteTypescript } from "../utils/formatAndWrite.js";
6
-
7
- export async function tsgen(config: StoreConfig, outDirectory: string) {
8
- const fullOutputPath = path.join(outDirectory, `contractComponents.ts`);
9
- const options = getRecsV1TableOptions(config);
10
- const output = renderRecsV1Tables(options);
11
- formatAndWriteTypescript(output, fullOutputPath, "Generated ts definition files");
12
- }
@@ -1,13 +0,0 @@
1
- export interface RecsV1TableOptions {
2
- tables: {
3
- tableName: string;
4
- fields: {
5
- recsTypeString: string;
6
- name: string;
7
- }[];
8
- staticResourceData: {
9
- namespace: string;
10
- name: string;
11
- };
12
- }[];
13
- }
@@ -1,132 +0,0 @@
1
- import { parse, visit } from "@solidity-parser/parser";
2
- import { TypeName, VariableDeclaration } from "@solidity-parser/parser/dist/src/ast-types.js";
3
- import { MUDError } from "@latticexyz/config";
4
- import { RenderSystemInterfaceFunction } from "../render-solidity/types.js";
5
-
6
- /**
7
- * Parse the contract data to get the functions necessary to generate an interface,
8
- * and symbols to import from the original contract.
9
- * @param data contents of a file with the solidity contract
10
- * @param contractName name of the contract
11
- * @returns interface data
12
- */
13
- export function contractToInterface(data: string, contractName: string) {
14
- const ast = parse(data);
15
-
16
- let withContract = false;
17
- let symbols: string[] = [];
18
- const functions: RenderSystemInterfaceFunction[] = [];
19
-
20
- visit(ast, {
21
- ContractDefinition({ name }) {
22
- if (name === contractName) {
23
- withContract = true;
24
- }
25
- },
26
- FunctionDefinition(
27
- { name, visibility, parameters, stateMutability, returnParameters, isConstructor, isFallback, isReceiveEther },
28
- parent
29
- ) {
30
- if (parent !== undefined && parent.type === "ContractDefinition" && parent.name === contractName) {
31
- try {
32
- // skip constructor and fallbacks
33
- if (isConstructor || isFallback || isReceiveEther) return;
34
- // forbid default visibility (this check might be unnecessary, modern solidity already disallows this)
35
- if (visibility === "default") throw new MUDError(`Visibility is not specified`);
36
-
37
- if (visibility === "external" || visibility === "public") {
38
- functions.push({
39
- name: name === null ? "" : name,
40
- parameters: parameters.map(parseParameter),
41
- stateMutability: stateMutability || "",
42
- returnParameters: returnParameters === null ? [] : returnParameters.map(parseParameter),
43
- });
44
-
45
- for (const { typeName } of parameters.concat(returnParameters ?? [])) {
46
- symbols = symbols.concat(typeNameToExternalSymbols(typeName));
47
- }
48
- }
49
- } catch (error: unknown) {
50
- if (error instanceof MUDError) {
51
- error.message = `Function "${name}" in contract "${contractName}": ${error.message}`;
52
- }
53
- throw error;
54
- }
55
- }
56
- },
57
- });
58
-
59
- if (!withContract) {
60
- throw new MUDError(`Contract not found: ${contractName}`);
61
- }
62
-
63
- return {
64
- functions,
65
- symbols,
66
- };
67
- }
68
-
69
- function parseParameter({ name, typeName, storageLocation }: VariableDeclaration): string {
70
- let typedNameWithLocation = "";
71
-
72
- const { name: flattenedTypeName, stateMutability } = flattenTypeName(typeName);
73
- // type name (e.g. uint256)
74
- typedNameWithLocation += flattenedTypeName;
75
- // optional mutability (e.g. address payable)
76
- if (stateMutability !== null) {
77
- typedNameWithLocation += ` ${stateMutability}`;
78
- }
79
- // location, when relevant (e.g. string memory)
80
- if (storageLocation !== null) {
81
- typedNameWithLocation += ` ${storageLocation}`;
82
- }
83
- // optional variable name
84
- if (name !== null) {
85
- typedNameWithLocation += ` ${name}`;
86
- }
87
-
88
- return typedNameWithLocation;
89
- }
90
-
91
- function flattenTypeName(typeName: TypeName | null): { name: string; stateMutability: string | null } {
92
- if (typeName === null) {
93
- return {
94
- name: "",
95
- stateMutability: null,
96
- };
97
- }
98
- if (typeName.type === "ElementaryTypeName") {
99
- return {
100
- name: typeName.name,
101
- stateMutability: typeName.stateMutability,
102
- };
103
- } else if (typeName.type === "UserDefinedTypeName") {
104
- return {
105
- name: typeName.namePath,
106
- stateMutability: null,
107
- };
108
- } else if (typeName.type === "ArrayTypeName") {
109
- const length = typeName.length?.type === "NumberLiteral" ? typeName.length.number : "";
110
- const { name, stateMutability } = flattenTypeName(typeName.baseTypeName);
111
- return {
112
- name: `${name}[${length}]`,
113
- stateMutability,
114
- };
115
- } else {
116
- // TODO function types are unsupported but could be useful
117
- throw new MUDError(`Invalid typeName.type ${typeName.type}`);
118
- }
119
- }
120
-
121
- // Get symbols that need to be imported for given typeName
122
- function typeNameToExternalSymbols(typeName: TypeName | null): string[] {
123
- if (typeName?.type === "UserDefinedTypeName") {
124
- // split is needed to get a library, if types are internal to it
125
- const symbol = typeName.namePath.split(".")[0];
126
- return [symbol];
127
- } else if (typeName?.type === "ArrayTypeName") {
128
- return typeNameToExternalSymbols(typeName.baseTypeName);
129
- } else {
130
- return [];
131
- }
132
- }