@latticexyz/cli 2.0.0-alpha.39 → 2.0.0-alpha.4
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.
- package/dist/chunk-6V563IAZ.js +283 -0
- package/dist/{chunk-ATAWDHWC.js → chunk-FPG73MVN.js} +5 -1
- package/dist/chunk-KJTPZOUH.js +3864 -0
- package/dist/{chunk-O6HOO6WA.js → chunk-L4YLJHLJ.js} +1 -9
- package/dist/{chunk-KPBNUPK6.js → chunk-SKNB74MT.js} +155 -159
- package/dist/chunk-VQTZJIFF.js +353 -0
- package/dist/{chunk-MXDV47JM.js → chunk-WZFXLDPK.js} +75 -24
- package/dist/chunk-YL4GJLLL.js +26139 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +0 -22
- package/dist/mud.d.ts +1 -1
- package/dist/mud.js +319 -3972
- package/dist/mud2.d.ts +1 -0
- package/dist/mud2.js +25 -0
- package/dist/render-solidity/index.d.ts +3 -3
- package/dist/render-solidity/index.js +3 -4
- package/dist/render-ts/index.d.ts +2 -3
- package/dist/render-ts/index.js +3 -4
- package/dist/utils/deprecated/index.js +3 -3
- package/dist/utils/index.d.ts +9 -19
- package/dist/utils/index.js +7 -18
- package/package.json +19 -20
- package/src/commands/deploy-v2.ts +80 -64
- package/src/commands/deprecated/index.ts +22 -0
- package/src/commands/deprecated/test.ts +1 -1
- package/src/commands/gas-report.ts +54 -55
- package/src/commands/index.ts +2 -17
- package/src/commands/set-version.ts +39 -10
- package/src/commands/tablegen.ts +5 -5
- package/src/commands/test-v2.ts +71 -0
- package/src/commands/tsgen.ts +1 -1
- package/src/commands/worldgen.ts +5 -4
- package/src/contracts/BulkUpload.sol +13 -20
- package/src/contracts/Deploy.sol +3 -3
- package/src/contracts/LibDeploy.sol +1 -1
- package/src/contracts/LibDeployStub.sol +1 -1
- package/src/index.ts +1 -15
- package/src/mud.ts +4 -3
- package/src/mud2.ts +29 -0
- package/src/render-solidity/common.ts +4 -4
- package/src/render-solidity/field.ts +25 -2
- package/src/render-solidity/record.ts +14 -10
- package/src/render-solidity/renderSystemInterface.ts +4 -4
- package/src/render-solidity/renderTableIndex.ts +15 -0
- package/src/render-solidity/renderTypesFromConfig.ts +1 -1
- package/src/render-solidity/tableOptions.ts +2 -2
- package/src/render-solidity/tablegen.ts +13 -1
- package/src/render-solidity/types.ts +2 -1
- package/src/render-solidity/userType.ts +1 -2
- package/src/render-solidity/worldgen.ts +5 -6
- package/src/render-ts/recsV1TableOptions.ts +2 -2
- package/src/render-ts/renderRecsV1Tables.ts +2 -2
- package/src/render-ts/schemaTypesToRecsTypeStrings.ts +136 -136
- package/src/render-ts/tsgen.ts +1 -1
- package/src/render-ts/types.ts +1 -1
- package/src/utils/contractToInterface.ts +5 -3
- package/src/utils/deploy-v2.ts +90 -84
- package/src/utils/errors.ts +3 -34
- package/src/utils/foundry.ts +9 -0
- package/dist/chunk-3FLNCDSC.js +0 -22908
- package/dist/chunk-5NC2OON2.js +0 -164
- package/dist/chunk-7GA2K5A6.js +0 -283
- package/dist/chunk-SLIMIO4Z.js +0 -14358
- package/dist/chunk-UN37BCLQ.js +0 -453
- package/dist/config/index.d.ts +0 -400
- package/dist/config/index.js +0 -85
- package/dist/parseStoreConfig-899f574e.d.ts +0 -369
- package/src/config/commonSchemas.ts +0 -34
- package/src/config/dynamicResolution.ts +0 -49
- package/src/config/index.ts +0 -24
- package/src/config/loadConfig.ts +0 -39
- package/src/config/loadStoreConfig.ts +0 -18
- package/src/config/parseStoreConfig.test-d.ts +0 -40
- package/src/config/parseStoreConfig.ts +0 -314
- package/src/config/validation.ts +0 -163
- package/src/config/world/index.ts +0 -4
- package/src/config/world/loadWorldConfig.test-d.ts +0 -11
- package/src/config/world/loadWorldConfig.ts +0 -26
- package/src/config/world/parseWorldConfig.ts +0 -55
- package/src/config/world/resolveWorldConfig.ts +0 -80
- package/src/config/world/userTypes.ts +0 -72
- package/src/utils/typeUtils.ts +0 -17
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import {
|
|
2
|
+
formatAndWriteTypescript,
|
|
3
|
+
resolveAbiOrUserType
|
|
4
|
+
} from "./chunk-SKNB74MT.js";
|
|
5
|
+
|
|
6
|
+
// src/render-ts/schemaTypesToRecsTypeStrings.ts
|
|
7
|
+
var schemaTypesToRecsTypeStrings = {
|
|
8
|
+
[0 /* UINT8 */]: "RecsType.Number",
|
|
9
|
+
[1 /* UINT16 */]: "RecsType.Number",
|
|
10
|
+
[2 /* UINT24 */]: "RecsType.Number",
|
|
11
|
+
[3 /* UINT32 */]: "RecsType.Number",
|
|
12
|
+
[4 /* UINT40 */]: "RecsType.Number",
|
|
13
|
+
[5 /* UINT48 */]: "RecsType.Number",
|
|
14
|
+
[6 /* UINT56 */]: "RecsType.BigInt",
|
|
15
|
+
[7 /* UINT64 */]: "RecsType.BigInt",
|
|
16
|
+
[8 /* UINT72 */]: "RecsType.BigInt",
|
|
17
|
+
[9 /* UINT80 */]: "RecsType.BigInt",
|
|
18
|
+
[10 /* UINT88 */]: "RecsType.BigInt",
|
|
19
|
+
[11 /* UINT96 */]: "RecsType.BigInt",
|
|
20
|
+
[12 /* UINT104 */]: "RecsType.BigInt",
|
|
21
|
+
[13 /* UINT112 */]: "RecsType.BigInt",
|
|
22
|
+
[14 /* UINT120 */]: "RecsType.BigInt",
|
|
23
|
+
[15 /* UINT128 */]: "RecsType.BigInt",
|
|
24
|
+
[16 /* UINT136 */]: "RecsType.BigInt",
|
|
25
|
+
[17 /* UINT144 */]: "RecsType.BigInt",
|
|
26
|
+
[18 /* UINT152 */]: "RecsType.BigInt",
|
|
27
|
+
[19 /* UINT160 */]: "RecsType.BigInt",
|
|
28
|
+
[20 /* UINT168 */]: "RecsType.BigInt",
|
|
29
|
+
[21 /* UINT176 */]: "RecsType.BigInt",
|
|
30
|
+
[22 /* UINT184 */]: "RecsType.BigInt",
|
|
31
|
+
[23 /* UINT192 */]: "RecsType.BigInt",
|
|
32
|
+
[24 /* UINT200 */]: "RecsType.BigInt",
|
|
33
|
+
[25 /* UINT208 */]: "RecsType.BigInt",
|
|
34
|
+
[26 /* UINT216 */]: "RecsType.BigInt",
|
|
35
|
+
[27 /* UINT224 */]: "RecsType.BigInt",
|
|
36
|
+
[28 /* UINT232 */]: "RecsType.BigInt",
|
|
37
|
+
[29 /* UINT240 */]: "RecsType.BigInt",
|
|
38
|
+
[30 /* UINT248 */]: "RecsType.BigInt",
|
|
39
|
+
[31 /* UINT256 */]: "RecsType.BigInt",
|
|
40
|
+
[32 /* INT8 */]: "RecsType.Number",
|
|
41
|
+
[33 /* INT16 */]: "RecsType.Number",
|
|
42
|
+
[34 /* INT24 */]: "RecsType.Number",
|
|
43
|
+
[35 /* INT32 */]: "RecsType.Number",
|
|
44
|
+
[36 /* INT40 */]: "RecsType.Number",
|
|
45
|
+
[37 /* INT48 */]: "RecsType.Number",
|
|
46
|
+
[38 /* INT56 */]: "RecsType.BigInt",
|
|
47
|
+
[39 /* INT64 */]: "RecsType.BigInt",
|
|
48
|
+
[40 /* INT72 */]: "RecsType.BigInt",
|
|
49
|
+
[41 /* INT80 */]: "RecsType.BigInt",
|
|
50
|
+
[42 /* INT88 */]: "RecsType.BigInt",
|
|
51
|
+
[43 /* INT96 */]: "RecsType.BigInt",
|
|
52
|
+
[44 /* INT104 */]: "RecsType.BigInt",
|
|
53
|
+
[45 /* INT112 */]: "RecsType.BigInt",
|
|
54
|
+
[46 /* INT120 */]: "RecsType.BigInt",
|
|
55
|
+
[47 /* INT128 */]: "RecsType.BigInt",
|
|
56
|
+
[48 /* INT136 */]: "RecsType.BigInt",
|
|
57
|
+
[49 /* INT144 */]: "RecsType.BigInt",
|
|
58
|
+
[50 /* INT152 */]: "RecsType.BigInt",
|
|
59
|
+
[51 /* INT160 */]: "RecsType.BigInt",
|
|
60
|
+
[52 /* INT168 */]: "RecsType.BigInt",
|
|
61
|
+
[53 /* INT176 */]: "RecsType.BigInt",
|
|
62
|
+
[54 /* INT184 */]: "RecsType.BigInt",
|
|
63
|
+
[55 /* INT192 */]: "RecsType.BigInt",
|
|
64
|
+
[56 /* INT200 */]: "RecsType.BigInt",
|
|
65
|
+
[57 /* INT208 */]: "RecsType.BigInt",
|
|
66
|
+
[58 /* INT216 */]: "RecsType.BigInt",
|
|
67
|
+
[59 /* INT224 */]: "RecsType.BigInt",
|
|
68
|
+
[60 /* INT232 */]: "RecsType.BigInt",
|
|
69
|
+
[61 /* INT240 */]: "RecsType.BigInt",
|
|
70
|
+
[62 /* INT248 */]: "RecsType.BigInt",
|
|
71
|
+
[63 /* INT256 */]: "RecsType.BigInt",
|
|
72
|
+
[64 /* BYTES1 */]: "RecsType.String",
|
|
73
|
+
[65 /* BYTES2 */]: "RecsType.String",
|
|
74
|
+
[66 /* BYTES3 */]: "RecsType.String",
|
|
75
|
+
[67 /* BYTES4 */]: "RecsType.String",
|
|
76
|
+
[68 /* BYTES5 */]: "RecsType.String",
|
|
77
|
+
[69 /* BYTES6 */]: "RecsType.String",
|
|
78
|
+
[70 /* BYTES7 */]: "RecsType.String",
|
|
79
|
+
[71 /* BYTES8 */]: "RecsType.String",
|
|
80
|
+
[72 /* BYTES9 */]: "RecsType.String",
|
|
81
|
+
[73 /* BYTES10 */]: "RecsType.String",
|
|
82
|
+
[74 /* BYTES11 */]: "RecsType.String",
|
|
83
|
+
[75 /* BYTES12 */]: "RecsType.String",
|
|
84
|
+
[76 /* BYTES13 */]: "RecsType.String",
|
|
85
|
+
[77 /* BYTES14 */]: "RecsType.String",
|
|
86
|
+
[78 /* BYTES15 */]: "RecsType.String",
|
|
87
|
+
[79 /* BYTES16 */]: "RecsType.String",
|
|
88
|
+
[80 /* BYTES17 */]: "RecsType.String",
|
|
89
|
+
[81 /* BYTES18 */]: "RecsType.String",
|
|
90
|
+
[82 /* BYTES19 */]: "RecsType.String",
|
|
91
|
+
[83 /* BYTES20 */]: "RecsType.String",
|
|
92
|
+
[84 /* BYTES21 */]: "RecsType.String",
|
|
93
|
+
[85 /* BYTES22 */]: "RecsType.String",
|
|
94
|
+
[86 /* BYTES23 */]: "RecsType.String",
|
|
95
|
+
[87 /* BYTES24 */]: "RecsType.String",
|
|
96
|
+
[88 /* BYTES25 */]: "RecsType.String",
|
|
97
|
+
[89 /* BYTES26 */]: "RecsType.String",
|
|
98
|
+
[90 /* BYTES27 */]: "RecsType.String",
|
|
99
|
+
[91 /* BYTES28 */]: "RecsType.String",
|
|
100
|
+
[92 /* BYTES29 */]: "RecsType.String",
|
|
101
|
+
[93 /* BYTES30 */]: "RecsType.String",
|
|
102
|
+
[94 /* BYTES31 */]: "RecsType.String",
|
|
103
|
+
[95 /* BYTES32 */]: "RecsType.String",
|
|
104
|
+
[96 /* BOOL */]: "RecsType.Boolean",
|
|
105
|
+
[97 /* ADDRESS */]: "RecsType.String",
|
|
106
|
+
[98 /* UINT8_ARRAY */]: "RecsType.NumberArray",
|
|
107
|
+
[99 /* UINT16_ARRAY */]: "RecsType.NumberArray",
|
|
108
|
+
[100 /* UINT24_ARRAY */]: "RecsType.NumberArray",
|
|
109
|
+
[101 /* UINT32_ARRAY */]: "RecsType.NumberArray",
|
|
110
|
+
[102 /* UINT40_ARRAY */]: "RecsType.NumberArray",
|
|
111
|
+
[103 /* UINT48_ARRAY */]: "RecsType.NumberArray",
|
|
112
|
+
[104 /* UINT56_ARRAY */]: "RecsType.BigIntArray",
|
|
113
|
+
[105 /* UINT64_ARRAY */]: "RecsType.BigIntArray",
|
|
114
|
+
[106 /* UINT72_ARRAY */]: "RecsType.BigIntArray",
|
|
115
|
+
[107 /* UINT80_ARRAY */]: "RecsType.BigIntArray",
|
|
116
|
+
[108 /* UINT88_ARRAY */]: "RecsType.BigIntArray",
|
|
117
|
+
[109 /* UINT96_ARRAY */]: "RecsType.BigIntArray",
|
|
118
|
+
[110 /* UINT104_ARRAY */]: "RecsType.BigIntArray",
|
|
119
|
+
[111 /* UINT112_ARRAY */]: "RecsType.BigIntArray",
|
|
120
|
+
[112 /* UINT120_ARRAY */]: "RecsType.BigIntArray",
|
|
121
|
+
[113 /* UINT128_ARRAY */]: "RecsType.BigIntArray",
|
|
122
|
+
[114 /* UINT136_ARRAY */]: "RecsType.BigIntArray",
|
|
123
|
+
[115 /* UINT144_ARRAY */]: "RecsType.BigIntArray",
|
|
124
|
+
[116 /* UINT152_ARRAY */]: "RecsType.BigIntArray",
|
|
125
|
+
[117 /* UINT160_ARRAY */]: "RecsType.BigIntArray",
|
|
126
|
+
[118 /* UINT168_ARRAY */]: "RecsType.BigIntArray",
|
|
127
|
+
[119 /* UINT176_ARRAY */]: "RecsType.BigIntArray",
|
|
128
|
+
[120 /* UINT184_ARRAY */]: "RecsType.BigIntArray",
|
|
129
|
+
[121 /* UINT192_ARRAY */]: "RecsType.BigIntArray",
|
|
130
|
+
[122 /* UINT200_ARRAY */]: "RecsType.BigIntArray",
|
|
131
|
+
[123 /* UINT208_ARRAY */]: "RecsType.BigIntArray",
|
|
132
|
+
[124 /* UINT216_ARRAY */]: "RecsType.BigIntArray",
|
|
133
|
+
[125 /* UINT224_ARRAY */]: "RecsType.BigIntArray",
|
|
134
|
+
[126 /* UINT232_ARRAY */]: "RecsType.BigIntArray",
|
|
135
|
+
[127 /* UINT240_ARRAY */]: "RecsType.BigIntArray",
|
|
136
|
+
[128 /* UINT248_ARRAY */]: "RecsType.BigIntArray",
|
|
137
|
+
[129 /* UINT256_ARRAY */]: "RecsType.BigIntArray",
|
|
138
|
+
[130 /* INT8_ARRAY */]: "RecsType.NumberArray",
|
|
139
|
+
[131 /* INT16_ARRAY */]: "RecsType.NumberArray",
|
|
140
|
+
[132 /* INT24_ARRAY */]: "RecsType.NumberArray",
|
|
141
|
+
[133 /* INT32_ARRAY */]: "RecsType.NumberArray",
|
|
142
|
+
[134 /* INT40_ARRAY */]: "RecsType.NumberArray",
|
|
143
|
+
[135 /* INT48_ARRAY */]: "RecsType.NumberArray",
|
|
144
|
+
[136 /* INT56_ARRAY */]: "RecsType.BigIntArray",
|
|
145
|
+
[137 /* INT64_ARRAY */]: "RecsType.BigIntArray",
|
|
146
|
+
[138 /* INT72_ARRAY */]: "RecsType.BigIntArray",
|
|
147
|
+
[139 /* INT80_ARRAY */]: "RecsType.BigIntArray",
|
|
148
|
+
[140 /* INT88_ARRAY */]: "RecsType.BigIntArray",
|
|
149
|
+
[141 /* INT96_ARRAY */]: "RecsType.BigIntArray",
|
|
150
|
+
[142 /* INT104_ARRAY */]: "RecsType.BigIntArray",
|
|
151
|
+
[143 /* INT112_ARRAY */]: "RecsType.BigIntArray",
|
|
152
|
+
[144 /* INT120_ARRAY */]: "RecsType.BigIntArray",
|
|
153
|
+
[145 /* INT128_ARRAY */]: "RecsType.BigIntArray",
|
|
154
|
+
[146 /* INT136_ARRAY */]: "RecsType.BigIntArray",
|
|
155
|
+
[147 /* INT144_ARRAY */]: "RecsType.BigIntArray",
|
|
156
|
+
[148 /* INT152_ARRAY */]: "RecsType.BigIntArray",
|
|
157
|
+
[149 /* INT160_ARRAY */]: "RecsType.BigIntArray",
|
|
158
|
+
[150 /* INT168_ARRAY */]: "RecsType.BigIntArray",
|
|
159
|
+
[151 /* INT176_ARRAY */]: "RecsType.BigIntArray",
|
|
160
|
+
[152 /* INT184_ARRAY */]: "RecsType.BigIntArray",
|
|
161
|
+
[153 /* INT192_ARRAY */]: "RecsType.BigIntArray",
|
|
162
|
+
[154 /* INT200_ARRAY */]: "RecsType.BigIntArray",
|
|
163
|
+
[155 /* INT208_ARRAY */]: "RecsType.BigIntArray",
|
|
164
|
+
[156 /* INT216_ARRAY */]: "RecsType.BigIntArray",
|
|
165
|
+
[157 /* INT224_ARRAY */]: "RecsType.BigIntArray",
|
|
166
|
+
[158 /* INT232_ARRAY */]: "RecsType.BigIntArray",
|
|
167
|
+
[159 /* INT240_ARRAY */]: "RecsType.BigIntArray",
|
|
168
|
+
[160 /* INT248_ARRAY */]: "RecsType.BigIntArray",
|
|
169
|
+
[161 /* INT256_ARRAY */]: "RecsType.BigIntArray",
|
|
170
|
+
[162 /* BYTES1_ARRAY */]: "RecsType.BigIntArray",
|
|
171
|
+
[163 /* BYTES2_ARRAY */]: "RecsType.BigIntArray",
|
|
172
|
+
[164 /* BYTES3_ARRAY */]: "RecsType.BigIntArray",
|
|
173
|
+
[165 /* BYTES4_ARRAY */]: "RecsType.BigIntArray",
|
|
174
|
+
[166 /* BYTES5_ARRAY */]: "RecsType.BigIntArray",
|
|
175
|
+
[167 /* BYTES6_ARRAY */]: "RecsType.BigIntArray",
|
|
176
|
+
[168 /* BYTES7_ARRAY */]: "RecsType.BigIntArray",
|
|
177
|
+
[169 /* BYTES8_ARRAY */]: "RecsType.BigIntArray",
|
|
178
|
+
[170 /* BYTES9_ARRAY */]: "RecsType.BigIntArray",
|
|
179
|
+
[171 /* BYTES10_ARRAY */]: "RecsType.BigIntArray",
|
|
180
|
+
[172 /* BYTES11_ARRAY */]: "RecsType.BigIntArray",
|
|
181
|
+
[173 /* BYTES12_ARRAY */]: "RecsType.BigIntArray",
|
|
182
|
+
[174 /* BYTES13_ARRAY */]: "RecsType.BigIntArray",
|
|
183
|
+
[175 /* BYTES14_ARRAY */]: "RecsType.BigIntArray",
|
|
184
|
+
[176 /* BYTES15_ARRAY */]: "RecsType.BigIntArray",
|
|
185
|
+
[177 /* BYTES16_ARRAY */]: "RecsType.BigIntArray",
|
|
186
|
+
[178 /* BYTES17_ARRAY */]: "RecsType.BigIntArray",
|
|
187
|
+
[179 /* BYTES18_ARRAY */]: "RecsType.BigIntArray",
|
|
188
|
+
[180 /* BYTES19_ARRAY */]: "RecsType.BigIntArray",
|
|
189
|
+
[181 /* BYTES20_ARRAY */]: "RecsType.BigIntArray",
|
|
190
|
+
[182 /* BYTES21_ARRAY */]: "RecsType.BigIntArray",
|
|
191
|
+
[183 /* BYTES22_ARRAY */]: "RecsType.BigIntArray",
|
|
192
|
+
[184 /* BYTES23_ARRAY */]: "RecsType.BigIntArray",
|
|
193
|
+
[185 /* BYTES24_ARRAY */]: "RecsType.BigIntArray",
|
|
194
|
+
[186 /* BYTES25_ARRAY */]: "RecsType.BigIntArray",
|
|
195
|
+
[187 /* BYTES26_ARRAY */]: "RecsType.BigIntArray",
|
|
196
|
+
[188 /* BYTES27_ARRAY */]: "RecsType.BigIntArray",
|
|
197
|
+
[189 /* BYTES28_ARRAY */]: "RecsType.BigIntArray",
|
|
198
|
+
[190 /* BYTES29_ARRAY */]: "RecsType.BigIntArray",
|
|
199
|
+
[191 /* BYTES30_ARRAY */]: "RecsType.BigIntArray",
|
|
200
|
+
[192 /* BYTES31_ARRAY */]: "RecsType.BigIntArray",
|
|
201
|
+
[193 /* BYTES32_ARRAY */]: "RecsType.BigIntArray",
|
|
202
|
+
[194 /* BOOL_ARRAY */]: "RecsType.T",
|
|
203
|
+
// no boolean array
|
|
204
|
+
[195 /* ADDRESS_ARRAY */]: "RecsType.StringArray",
|
|
205
|
+
[196 /* BYTES */]: "RecsType.String",
|
|
206
|
+
[197 /* STRING */]: "RecsType.String"
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// src/render-ts/recsV1TableOptions.ts
|
|
210
|
+
function getRecsV1TableOptions(config) {
|
|
211
|
+
const tableOptions = [];
|
|
212
|
+
for (const tableName of Object.keys(config.tables)) {
|
|
213
|
+
const tableData = config.tables[tableName];
|
|
214
|
+
const fields = Object.keys(tableData.schema).map((name) => {
|
|
215
|
+
const abiOrUserType = tableData.schema[name];
|
|
216
|
+
const { schemaType } = resolveAbiOrUserType(abiOrUserType, config);
|
|
217
|
+
const recsTypeString = schemaTypesToRecsTypeStrings[schemaType];
|
|
218
|
+
return {
|
|
219
|
+
recsTypeString,
|
|
220
|
+
name
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
if (tableData.tableIdArgument)
|
|
224
|
+
continue;
|
|
225
|
+
const staticResourceData = {
|
|
226
|
+
namespace: config.namespace,
|
|
227
|
+
name: tableData.name
|
|
228
|
+
};
|
|
229
|
+
tableOptions.push({
|
|
230
|
+
tableName,
|
|
231
|
+
fields,
|
|
232
|
+
staticResourceData
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
tables: tableOptions
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/render-ts/renderRecsV1Tables.ts
|
|
241
|
+
function renderRecsV1Tables(options) {
|
|
242
|
+
const { tables } = options;
|
|
243
|
+
return `/* Autogenerated file. Do not edit manually. */
|
|
244
|
+
|
|
245
|
+
import { TableId } from "@latticexyz/utils";
|
|
246
|
+
import { defineComponent, Type as RecsType, World } from "@latticexyz/recs";
|
|
247
|
+
|
|
248
|
+
export function defineContractComponents(world: World) {
|
|
249
|
+
return {
|
|
250
|
+
${tables.map((table) => `${table.tableName}: ${renderDefineComponent(table)},`).join("")}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
`;
|
|
254
|
+
}
|
|
255
|
+
function renderDefineComponent(table) {
|
|
256
|
+
const { namespace, name } = table.staticResourceData;
|
|
257
|
+
return `
|
|
258
|
+
(() => {
|
|
259
|
+
const tableId = new TableId("${namespace}", "${name}");
|
|
260
|
+
return defineComponent(world, {
|
|
261
|
+
${table.fields.map(({ name: name2, recsTypeString }) => `${name2}: ${recsTypeString},`).join("")}
|
|
262
|
+
}, {
|
|
263
|
+
metadata: { contractId: tableId.toHexString(), tableId: tableId.toString() },
|
|
264
|
+
});
|
|
265
|
+
})()
|
|
266
|
+
`;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// src/render-ts/tsgen.ts
|
|
270
|
+
import path from "path";
|
|
271
|
+
async function tsgen(config, outDirectory) {
|
|
272
|
+
const fullOutputPath = path.join(outDirectory, `contractComponents.ts`);
|
|
273
|
+
const options = getRecsV1TableOptions(config);
|
|
274
|
+
const output = renderRecsV1Tables(options);
|
|
275
|
+
formatAndWriteTypescript(output, fullOutputPath, "Generated ts definition files");
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
export {
|
|
279
|
+
schemaTypesToRecsTypeStrings,
|
|
280
|
+
getRecsV1TableOptions,
|
|
281
|
+
renderRecsV1Tables,
|
|
282
|
+
tsgen
|
|
283
|
+
};
|
|
@@ -54,6 +54,9 @@ async function cast(args, options) {
|
|
|
54
54
|
env: { FOUNDRY_PROFILE: options?.profile }
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
+
async function anvil(args) {
|
|
58
|
+
return execLog("anvil", args);
|
|
59
|
+
}
|
|
57
60
|
|
|
58
61
|
export {
|
|
59
62
|
getForgeConfig,
|
|
@@ -63,5 +66,6 @@ export {
|
|
|
63
66
|
getOutDirectory,
|
|
64
67
|
getRpcUrl,
|
|
65
68
|
forge,
|
|
66
|
-
cast
|
|
69
|
+
cast,
|
|
70
|
+
anvil
|
|
67
71
|
};
|