@latticexyz/cli 1.40.0 → 1.41.1-alpha.0

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 (81) hide show
  1. package/LICENSE +21 -0
  2. package/dist/chunk-ATAWDHWC.js +67 -0
  3. package/dist/{chunk-6AQ6LFVZ.js → chunk-J4DJQNIC.js} +743 -103
  4. package/dist/chunk-KD354QKC.js +23039 -0
  5. package/dist/{chunk-S3V3XX7N.js → chunk-SLIMIO4Z.js} +1 -1
  6. package/dist/config/index.d.ts +746 -8
  7. package/dist/config/index.js +63 -17
  8. package/dist/index.d.ts +1 -2
  9. package/dist/index.js +14 -10
  10. package/dist/mud.js +1055 -49
  11. package/dist/utils/deprecated/index.js +2 -2
  12. package/dist/utils/index.d.ts +56 -7
  13. package/dist/utils/index.js +17 -3
  14. package/package.json +16 -11
  15. package/src/commands/deploy-v2.ts +96 -0
  16. package/src/commands/deprecated/call-system.ts +1 -1
  17. package/src/commands/deprecated/deploy-contracts.ts +1 -1
  18. package/src/commands/deprecated/test.ts +9 -6
  19. package/src/commands/deprecated/trace.ts +1 -1
  20. package/src/commands/gas-report.ts +1 -1
  21. package/src/commands/index.ts +4 -0
  22. package/src/commands/tablegen.ts +4 -18
  23. package/src/commands/worldgen.ts +55 -0
  24. package/src/config/commonSchemas.ts +19 -5
  25. package/src/config/dynamicResolution.ts +49 -0
  26. package/src/config/index.ts +20 -0
  27. package/src/config/loadStoreConfig.ts +3 -89
  28. package/src/config/parseStoreConfig.test-d.ts +40 -0
  29. package/src/config/parseStoreConfig.ts +314 -0
  30. package/src/config/validation.ts +71 -0
  31. package/src/config/world/index.ts +4 -0
  32. package/src/config/world/loadWorldConfig.test-d.ts +11 -0
  33. package/src/config/world/loadWorldConfig.ts +26 -0
  34. package/src/config/world/parseWorldConfig.ts +55 -0
  35. package/src/config/world/resolveWorldConfig.ts +80 -0
  36. package/src/config/world/userTypes.ts +72 -0
  37. package/src/index.ts +13 -5
  38. package/src/mud.ts +4 -0
  39. package/src/render-solidity/common.ts +138 -0
  40. package/src/render-solidity/field.ts +137 -0
  41. package/src/render-solidity/index.ts +10 -0
  42. package/src/render-solidity/record.ts +154 -0
  43. package/src/render-solidity/renderSystemInterface.ts +31 -0
  44. package/src/render-solidity/renderTable.ts +164 -0
  45. package/src/render-solidity/renderTypeHelpers.ts +99 -0
  46. package/src/render-solidity/renderTypes.ts +19 -0
  47. package/src/render-solidity/renderTypesFromConfig.ts +13 -0
  48. package/src/render-solidity/renderWorld.ts +24 -0
  49. package/src/{render-table/renderTablesFromConfig.ts → render-solidity/tableOptions.ts} +45 -37
  50. package/src/render-solidity/tablegen.ts +33 -0
  51. package/src/render-solidity/types.ts +110 -0
  52. package/src/render-solidity/userType.ts +132 -0
  53. package/src/render-solidity/worldgen.ts +60 -0
  54. package/src/utils/contractToInterface.ts +130 -0
  55. package/src/utils/deploy-v2.ts +512 -0
  56. package/src/utils/deprecated/build.ts +1 -1
  57. package/src/utils/deprecated/typegen.ts +1 -1
  58. package/src/utils/errors.ts +12 -2
  59. package/src/utils/execLog.ts +22 -0
  60. package/src/utils/formatAndWrite.ts +12 -0
  61. package/src/utils/foundry.ts +94 -0
  62. package/src/utils/getChainId.ts +10 -0
  63. package/src/utils/index.ts +2 -1
  64. package/src/utils/typeUtils.ts +17 -0
  65. package/dist/chunk-B6VWCGHZ.js +0 -199
  66. package/dist/chunk-JKAA3WMC.js +0 -55
  67. package/dist/chunk-JNGSW4AP.js +0 -493
  68. package/dist/chunk-PJ6GS2R4.js +0 -22
  69. package/dist/chunk-UC3QPOON.js +0 -35
  70. package/dist/loadStoreConfig-37f99136.d.ts +0 -164
  71. package/dist/render-table/index.d.ts +0 -29
  72. package/dist/render-table/index.js +0 -24
  73. package/dist/renderTable-9e6410c5.d.ts +0 -72
  74. package/src/config/loadStoreConfig.test-d.ts +0 -11
  75. package/src/render-table/common.ts +0 -67
  76. package/src/render-table/field.ts +0 -132
  77. package/src/render-table/index.ts +0 -6
  78. package/src/render-table/record.ts +0 -176
  79. package/src/render-table/renderTable.ts +0 -109
  80. package/src/render-table/types.ts +0 -51
  81. package/src/utils/forgeConfig.ts +0 -45
@@ -1,493 +0,0 @@
1
- import {
2
- SchemaType,
3
- SchemaTypeArrayToElement,
4
- SchemaTypeId,
5
- getStaticByteLength
6
- } from "./chunk-6AQ6LFVZ.js";
7
-
8
- // src/render-table/common.ts
9
- function renderList(list, renderItem) {
10
- return internalRenderList("", list, renderItem);
11
- }
12
- function renderArguments(args) {
13
- const filteredArgs = args.filter((arg) => arg !== void 0 && arg !== "");
14
- return internalRenderList(",", filteredArgs, (arg) => arg);
15
- }
16
- function renderCommonData({ staticRouteData, primaryKeys }) {
17
- const _tableId = staticRouteData ? "" : "_tableId";
18
- const _typedTableId = staticRouteData ? "" : "uint256 _tableId";
19
- const _keyArgs = renderArguments(primaryKeys.map(({ name }) => name));
20
- const _typedKeyArgs = renderArguments(primaryKeys.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));
21
- const _primaryKeysDefinition = `
22
- bytes32[] memory _primaryKeys = new bytes32[](${primaryKeys.length});
23
- ${renderList(
24
- primaryKeys,
25
- ({ name, typeId, staticByteLength }, index) => `
26
- _primaryKeys[${index}] = ${renderValueTypeToBytes32(name, typeId, staticByteLength)};
27
- `
28
- )}
29
- `;
30
- return {
31
- _tableId,
32
- _typedTableId,
33
- _keyArgs,
34
- _typedKeyArgs,
35
- _primaryKeysDefinition
36
- };
37
- }
38
- function renderValueTypeToBytes32(innerText, typeId, staticByteLength) {
39
- const bits = staticByteLength * 8;
40
- if (typeId.match(/^uint\d{1,3}$/)) {
41
- return `bytes32(uint256(${innerText}))`;
42
- } else if (typeId.match(/^int\d{1,3}$/)) {
43
- return `bytes32(uint256(uint${bits}(${innerText})))`;
44
- } else if (typeId.match(/^bytes\d{1,2}$/)) {
45
- return `bytes32(${innerText})`;
46
- } else if (typeId === "address") {
47
- return `bytes32(bytes20(${innerText}))`;
48
- } else if (typeId === "bool") {
49
- return `_boolToBytes32(${innerText})`;
50
- } else {
51
- throw new Error(`Unknown value type id ${typeId}`);
52
- }
53
- }
54
- function internalRenderList(lineTerminator, list, renderItem) {
55
- return list.map((item, index) => renderItem(item, index) + (index === list.length - 1 ? "" : lineTerminator)).join("\n");
56
- }
57
-
58
- // src/render-table/field.ts
59
- function renderFieldMethods(options) {
60
- const { _typedTableId, _typedKeyArgs, _primaryKeysDefinition } = renderCommonData(options);
61
- let result = "";
62
- for (const [index, field] of options.fields.entries()) {
63
- const _typedFieldName = `${field.typeWithLocation} ${field.name}`;
64
- result += `
65
- /** Get ${field.name} */
66
- function get${field.methodNameSuffix}(${renderArguments([
67
- _typedTableId,
68
- _typedKeyArgs
69
- ])}) internal view returns (${_typedFieldName}) {
70
- ${_primaryKeysDefinition}
71
- bytes memory _blob = StoreSwitch.getField(_tableId, _primaryKeys, ${index});
72
- return ${renderDecodeFieldSingle(field)};
73
- }
74
- `;
75
- if (options.storeArgument) {
76
- result += `
77
- /** Get ${field.name} from the specified store */
78
- function get${field.methodNameSuffix}(${renderArguments([
79
- _typedTableId,
80
- `IStore _store`,
81
- _typedKeyArgs
82
- ])}) internal view returns (${_typedFieldName}) {
83
- ${_primaryKeysDefinition}
84
- bytes memory _blob = _store.getField(_tableId, _primaryKeys, ${index});
85
- return ${renderDecodeFieldSingle(field)};
86
- }
87
- `;
88
- }
89
- result += `
90
- /** Set ${field.name} */
91
- function set${field.methodNameSuffix}(${renderArguments([
92
- _typedTableId,
93
- _typedKeyArgs,
94
- _typedFieldName
95
- ])}) internal {
96
- ${_primaryKeysDefinition}
97
- StoreSwitch.setField(_tableId, _primaryKeys, ${index}, ${renderEncodeField(field)});
98
- }
99
- `;
100
- if (field.isDynamic) {
101
- const portionData = fieldPortionData(field);
102
- result += `
103
- /** Push ${portionData.title} to ${field.name} */
104
- function push${field.methodNameSuffix}(${renderArguments([
105
- _typedTableId,
106
- _typedKeyArgs,
107
- `${portionData.typeWithLocation} ${portionData.name}`
108
- ])}) internal {
109
- ${_primaryKeysDefinition}
110
- bytes memory _blob = StoreSwitch.getField(_tableId, _primaryKeys, ${index});
111
- bytes memory _newBlob = abi.encodePacked(_blob, ${portionData.encodeFunc}(${portionData.name}));
112
- StoreSwitch.setField(_tableId, _primaryKeys, ${index}, _newBlob);
113
- }
114
- `;
115
- }
116
- }
117
- return result;
118
- }
119
- function renderEncodeField(field) {
120
- let func;
121
- if (field.arrayElement) {
122
- func = "EncodeArray.encode";
123
- } else if (field.isDynamic) {
124
- func = "bytes";
125
- } else {
126
- func = "abi.encodePacked";
127
- }
128
- return `${func}(${field.name})`;
129
- }
130
- function renderDecodeValueType(typeId, staticByteLength, offset) {
131
- const innerSlice = `Bytes.slice${staticByteLength}(_blob, ${offset})`;
132
- const bits = staticByteLength * 8;
133
- if (typeId.match(/^uint\d{1,3}$/) || typeId === "address") {
134
- return `${typeId}(${innerSlice})`;
135
- } else if (typeId.match(/^int\d{1,3}$/)) {
136
- return `${typeId}(uint${bits}(${innerSlice}))`;
137
- } else if (typeId.match(/^bytes\d{1,2}$/)) {
138
- return innerSlice;
139
- } else if (typeId === "bool") {
140
- return `_toBool(uint8(${innerSlice}))`;
141
- } else {
142
- throw new Error(`Unknown value type id ${typeId}`);
143
- }
144
- }
145
- function fieldPortionData(field) {
146
- if (field.arrayElement) {
147
- return {
148
- typeWithLocation: field.arrayElement.typeWithLocation,
149
- name: "_element",
150
- encodeFunc: "abi.encodePacked",
151
- title: "an element"
152
- };
153
- } else {
154
- return {
155
- typeWithLocation: `${field.typeId} memory`,
156
- name: "_slice",
157
- encodeFunc: "bytes",
158
- title: "a slice"
159
- };
160
- }
161
- }
162
- function renderDecodeFieldSingle(field) {
163
- const { typeId, isDynamic, arrayElement } = field;
164
- if (arrayElement) {
165
- return `SliceLib.getSubslice(_blob, 0, _blob.length).decodeArray_${arrayElement.typeId}()`;
166
- } else if (isDynamic) {
167
- return `${typeId}(_blob)`;
168
- } else {
169
- return renderDecodeValueType(typeId, field.staticByteLength, 0);
170
- }
171
- }
172
-
173
- // src/render-table/record.ts
174
- function renderRecordMethods(options) {
175
- const { staticFields, dynamicFields, structName, storeArgument } = options;
176
- const { _tableId, _typedTableId, _keyArgs, _typedKeyArgs, _primaryKeysDefinition } = renderCommonData(options);
177
- let result = `
178
- /** Get the full data */
179
- function get(${renderArguments([_typedTableId, _typedKeyArgs])}) internal view returns (${renderDecodedRecord(
180
- options
181
- )}) {
182
- ${_primaryKeysDefinition}
183
- bytes memory _blob = StoreSwitch.getRecord(_tableId, _primaryKeys, getSchema());
184
- return decode(_blob);
185
- }
186
- `;
187
- if (storeArgument) {
188
- result += `
189
- /** Get the full data from the specified store */
190
- function get(${renderArguments([
191
- _typedTableId,
192
- `IStore _store`,
193
- _typedKeyArgs
194
- ])}) internal view returns (${renderDecodedRecord(options)}) {
195
- ${_primaryKeysDefinition}
196
- bytes memory _blob = _store.getRecord(_tableId, _primaryKeys);
197
- return decode(_blob);
198
- }
199
- `;
200
- }
201
- result += `
202
- /** Set the full data using individual values */
203
- function set(${renderArguments([
204
- _typedTableId,
205
- _typedKeyArgs,
206
- renderArguments(options.fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`))
207
- ])}) internal {
208
- ${renderEncodedLengths(dynamicFields)}
209
- bytes memory _data = abi.encodePacked(${renderArguments([
210
- renderArguments(staticFields.map(({ name }) => name)),
211
- // TODO try gas optimization (preallocate for all, encodePacked statics, and direct encode dynamics)
212
- // (see https://github.com/latticexyz/mud/issues/444)
213
- ...dynamicFields.length === 0 ? [] : ["_encodedLengths.unwrap()", renderArguments(dynamicFields.map((field) => renderEncodeField(field)))]
214
- ])});
215
-
216
- ${_primaryKeysDefinition}
217
-
218
- StoreSwitch.setRecord(_tableId, _primaryKeys, _data);
219
- }
220
- `;
221
- if (structName !== void 0) {
222
- result += `
223
- /** Set the full data using the data struct */
224
- function set(${renderArguments([_typedTableId, _typedKeyArgs, `${structName} memory _table`])}) internal {
225
- set(${renderArguments([
226
- _tableId,
227
- _keyArgs,
228
- renderArguments(options.fields.map(({ name }) => `_table.${name}`))
229
- ])});
230
- }
231
- `;
232
- }
233
- result += renderDecodeFunction(options);
234
- return result;
235
- }
236
- function renderDecodeFunction({ structName, fields, staticFields, dynamicFields }) {
237
- const renderedDecodedRecord = structName ? `${structName} memory _table` : renderArguments(fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));
238
- const fieldNamePrefix = structName ? "_table." : "";
239
- const staticOffsets = staticFields.map(() => 0);
240
- let _acc = 0;
241
- for (const [index, field] of staticFields.entries()) {
242
- staticOffsets[index] = _acc;
243
- _acc += field.staticByteLength;
244
- }
245
- if (dynamicFields.length > 0) {
246
- const totalStaticLength = staticFields.reduce((acc, { staticByteLength }) => acc + staticByteLength, 0);
247
- return `
248
- /** Decode the tightly packed blob using this table's schema */
249
- function decode(bytes memory _blob) internal view returns (${renderedDecodedRecord}) {
250
- // ${totalStaticLength} is the total byte length of static data
251
- PackedCounter _encodedLengths = PackedCounter.wrap(Bytes.slice32(_blob, ${totalStaticLength}));
252
-
253
- ${renderList(
254
- staticFields,
255
- (field, index) => `
256
- ${fieldNamePrefix}${field.name} = ${renderDecodeStaticFieldPartial(field, staticOffsets[index])};
257
- `
258
- )}
259
- uint256 _start;
260
- uint256 _end = ${totalStaticLength + 32};
261
- ${renderList(
262
- dynamicFields,
263
- (field, index) => `
264
- _start = _end;
265
- _end += _encodedLengths.atIndex(${index});
266
- ${fieldNamePrefix}${field.name} = ${renderDecodeDynamicFieldPartial(field)};
267
- `
268
- )}
269
- }
270
- `;
271
- } else {
272
- return `
273
- /** Decode the tightly packed blob using this table's schema */
274
- function decode(bytes memory _blob) internal pure returns (${renderedDecodedRecord}) {
275
- ${renderList(
276
- staticFields,
277
- (field, index) => `
278
- ${fieldNamePrefix}${field.name} = ${renderDecodeStaticFieldPartial(field, staticOffsets[index])};
279
- `
280
- )}
281
- }
282
- `;
283
- }
284
- }
285
- function renderDecodedRecord({ structName, fields }) {
286
- if (structName) {
287
- return `${structName} memory _table`;
288
- } else {
289
- return renderArguments(fields.map(({ name, typeWithLocation }) => `${typeWithLocation} ${name}`));
290
- }
291
- }
292
- function renderDecodeDynamicFieldPartial(field) {
293
- const { typeId, arrayElement } = field;
294
- if (arrayElement) {
295
- return `SliceLib.getSubslice(_blob, _start, _end).decodeArray_${arrayElement.typeId}()`;
296
- } else {
297
- return `${typeId}(SliceLib.getSubslice(_blob, _start, _end).toBytes())`;
298
- }
299
- }
300
- function renderDecodeStaticFieldPartial(field, start) {
301
- const { typeId, staticByteLength } = field;
302
- return renderDecodeValueType(typeId, staticByteLength, start);
303
- }
304
- function renderEncodedLengths(dynamicFields) {
305
- if (dynamicFields.length > 0) {
306
- return `
307
- uint16[] memory _counters = new uint16[](${dynamicFields.length});
308
- ${renderList(dynamicFields, ({ name, arrayElement }, index) => {
309
- if (arrayElement) {
310
- return `_counters[${index}] = uint16(${name}.length * ${arrayElement.staticByteLength});`;
311
- } else {
312
- return `_counters[${index}] = uint16(bytes(${name}).length);`;
313
- }
314
- })}
315
- PackedCounter _encodedLengths = PackedCounterLib.pack(_counters);
316
- `;
317
- } else {
318
- return "";
319
- }
320
- }
321
-
322
- // src/render-table/renderTable.ts
323
- function renderTable(options) {
324
- const { libraryName, structName, staticRouteData, storeImportPath, fields, withRecordMethods } = options;
325
- const { _typedTableId, _typedKeyArgs, _primaryKeysDefinition } = renderCommonData(options);
326
- return `// SPDX-License-Identifier: MIT
327
- pragma solidity >=0.8.0;
328
-
329
- /* Autogenerated file. Do not edit manually. */
330
-
331
- import { SchemaType } from "@latticexyz/schema-type/src/solidity/SchemaType.sol";
332
-
333
- import { IStore } from "${storeImportPath}IStore.sol";
334
- import { StoreSwitch } from "${storeImportPath}StoreSwitch.sol";
335
- import { StoreCore } from "${storeImportPath}StoreCore.sol";
336
- import { Bytes } from "${storeImportPath}Bytes.sol";
337
- import { SliceLib } from "${storeImportPath}Slice.sol";
338
- import { EncodeArray } from "${storeImportPath}tightcoder/EncodeArray.sol";
339
- import { Schema, SchemaLib } from "${storeImportPath}Schema.sol";
340
- import { PackedCounter, PackedCounterLib } from "${storeImportPath}PackedCounter.sol";
341
-
342
- ${!staticRouteData ? "" : `
343
- uint256 constant _tableId = uint256(keccak256("${staticRouteData.baseRoute + staticRouteData.subRoute}"));
344
- uint256 constant ${staticRouteData.tableIdName} = _tableId;
345
- `}
346
-
347
- ${!structName ? "" : `
348
- struct ${structName} {
349
- ${renderList(fields, ({ name, typeId }) => `${typeId} ${name};`)}
350
- }
351
- `}
352
-
353
- library ${libraryName} {
354
- /** Get the table's schema */
355
- function getSchema() internal pure returns (Schema) {
356
- SchemaType[] memory _schema = new SchemaType[](${fields.length});
357
- ${renderList(fields, ({ enumName }, index) => `_schema[${index}] = SchemaType.${enumName};`)}
358
-
359
- return SchemaLib.encode(_schema);
360
- }
361
-
362
- /** Register the table's schema */
363
- function registerSchema(${_typedTableId}) internal {
364
- StoreSwitch.registerSchema(_tableId, getSchema());
365
- }
366
-
367
- ${!options.storeArgument ? "" : `
368
- /** Register the table's schema for the specified store */
369
- function registerSchema(${renderArguments([_typedTableId, "IStore _store"])}) internal {
370
- _store.registerSchema(_tableId, getSchema());
371
- }
372
- `}
373
-
374
- ${renderFieldMethods(options)}
375
-
376
- ${withRecordMethods ? renderRecordMethods(options) : ""}
377
-
378
- /* Delete all data for given keys */
379
- function deleteRecord(${renderArguments([_typedTableId, _typedKeyArgs])}) internal {
380
- ${_primaryKeysDefinition}
381
- StoreSwitch.deleteRecord(_tableId, _primaryKeys);
382
- }
383
- }
384
-
385
- ${// nothing can be cast to bool, so an assembly helper is required
386
- !fields.some(({ typeId }) => typeId === "bool") ? "" : `
387
- function _toBool(uint8 value) pure returns (bool result) {
388
- assembly {
389
- result := value
390
- }
391
- }
392
- `}
393
-
394
- ${// nothing can be cast from bool, so an assembly helper is required
395
- !options.primaryKeys.some(({ typeId }) => typeId === "bool") ? "" : `
396
- function _boolToBytes32(bool value) pure returns (bytes32 result) {
397
- assembly {
398
- result := value
399
- }
400
- }
401
- `}
402
-
403
- `;
404
- }
405
-
406
- // src/render-table/renderTablesFromConfig.ts
407
- function renderTablesFromConfig(config) {
408
- const storeImportPath = config.storeImportPath;
409
- const renderedTables = [];
410
- for (const tableName of Object.keys(config.tables)) {
411
- const tableData = config.tables[tableName];
412
- const withStruct = tableData.dataStruct;
413
- const withRecordMethods = withStruct || Object.keys(tableData.schema).length > 1;
414
- const noFieldMethodSuffix = !withRecordMethods && Object.keys(tableData.schema).length === 1;
415
- const primaryKeys = Object.keys(tableData.primaryKeys).map((name) => {
416
- const type = tableData.primaryKeys[name];
417
- const typeInfo = getSchemaTypeInfo(type);
418
- if (typeInfo.isDynamic)
419
- throw new Error("Parsing error: found dynamic primary key");
420
- const primaryKey = {
421
- ...typeInfo,
422
- name,
423
- isDynamic: false
424
- };
425
- return primaryKey;
426
- });
427
- const fields = Object.keys(tableData.schema).map((name) => {
428
- const type = tableData.schema[name];
429
- const elementType = SchemaTypeArrayToElement[type];
430
- const field = {
431
- ...getSchemaTypeInfo(type),
432
- arrayElement: elementType ? getSchemaTypeInfo(elementType) : void 0,
433
- name,
434
- methodNameSuffix: noFieldMethodSuffix ? "" : `${name[0].toUpperCase()}${name.slice(1)}`
435
- };
436
- return field;
437
- });
438
- const staticFields = fields.filter(({ isDynamic }) => !isDynamic);
439
- const dynamicFields = fields.filter(({ isDynamic }) => isDynamic);
440
- const staticRouteData = (() => {
441
- if (tableData.tableIdArgument) {
442
- return;
443
- } else {
444
- return {
445
- tableIdName: tableName + "TableId",
446
- baseRoute: config.baseRoute + tableData.route,
447
- subRoute: `/${tableName}`
448
- };
449
- }
450
- })();
451
- renderedTables.push({
452
- tableName,
453
- tableData,
454
- output: renderTable({
455
- libraryName: tableName,
456
- structName: withStruct ? tableName + "Data" : void 0,
457
- staticRouteData,
458
- storeImportPath,
459
- primaryKeys,
460
- fields,
461
- staticFields,
462
- dynamicFields,
463
- withRecordMethods,
464
- storeArgument: tableData.storeArgument
465
- })
466
- });
467
- }
468
- return renderedTables;
469
- }
470
- function getSchemaTypeInfo(schemaType) {
471
- const staticByteLength = getStaticByteLength(schemaType);
472
- const isDynamic = staticByteLength === 0;
473
- const typeId = SchemaTypeId[schemaType];
474
- return {
475
- typeId,
476
- typeWithLocation: isDynamic ? typeId + " memory" : typeId,
477
- enumName: SchemaType[schemaType],
478
- staticByteLength,
479
- isDynamic
480
- };
481
- }
482
-
483
- export {
484
- renderList,
485
- renderArguments,
486
- renderCommonData,
487
- renderFieldMethods,
488
- renderEncodeField,
489
- renderDecodeValueType,
490
- renderRecordMethods,
491
- renderTable,
492
- renderTablesFromConfig
493
- };
@@ -1,22 +0,0 @@
1
- // src/utils/forgeConfig.ts
2
- import { execa } from "execa";
3
- async function getForgeConfig() {
4
- const { stdout } = await execa("forge", ["config", "--json"], { stdio: ["inherit", "pipe", "pipe"] });
5
- return JSON.parse(stdout);
6
- }
7
- async function getSrcDirectory() {
8
- return (await getForgeConfig()).src;
9
- }
10
- async function getTestDirectory() {
11
- return (await getForgeConfig()).test;
12
- }
13
- async function getOutDirectory() {
14
- return (await getForgeConfig()).out;
15
- }
16
-
17
- export {
18
- getForgeConfig,
19
- getSrcDirectory,
20
- getTestDirectory,
21
- getOutDirectory
22
- };
@@ -1,35 +0,0 @@
1
- // src/utils/format.ts
2
- import chalk from "chalk";
3
- import prettier from "prettier";
4
- import prettierPluginSolidity from "prettier-plugin-solidity";
5
- async function formatSolidity(content, prettierConfigPath) {
6
- let config;
7
- if (prettierConfigPath) {
8
- config = await prettier.resolveConfig(prettierConfigPath);
9
- }
10
- try {
11
- return prettier.format(content, {
12
- plugins: [prettierPluginSolidity],
13
- parser: "solidity-parse",
14
- printWidth: 120,
15
- semi: true,
16
- tabWidth: 2,
17
- useTabs: false,
18
- bracketSpacing: true,
19
- ...config
20
- });
21
- } catch (error) {
22
- let message;
23
- if (error instanceof Error) {
24
- message = error.message;
25
- } else {
26
- message = error;
27
- }
28
- console.log(chalk.yellow(`Error during output formatting: ${message}`));
29
- return content;
30
- }
31
- }
32
-
33
- export {
34
- formatSolidity
35
- };