@latticexyz/cli 2.0.0-alpha.38 → 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
package/dist/chunk-5NC2OON2.js
DELETED
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AbiTypeToSchemaType,
|
|
3
|
-
SchemaType,
|
|
4
|
-
SchemaTypeToAbiType,
|
|
5
|
-
getStaticByteLength,
|
|
6
|
-
parseStaticArray
|
|
7
|
-
} from "./chunk-KPBNUPK6.js";
|
|
8
|
-
|
|
9
|
-
// src/render-solidity/userType.ts
|
|
10
|
-
function resolveAbiOrUserType(abiOrUserType, config) {
|
|
11
|
-
if (abiOrUserType in AbiTypeToSchemaType) {
|
|
12
|
-
const schemaType = AbiTypeToSchemaType[abiOrUserType];
|
|
13
|
-
return {
|
|
14
|
-
schemaType,
|
|
15
|
-
renderTableType: getSchemaTypeInfo(schemaType)
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
const staticArray = parseStaticArray(abiOrUserType);
|
|
19
|
-
if (staticArray) {
|
|
20
|
-
if (staticArray.elementType in AbiTypeToSchemaType) {
|
|
21
|
-
return getStaticArrayTypeInfo(abiOrUserType, staticArray.elementType, staticArray.staticLength);
|
|
22
|
-
} else {
|
|
23
|
-
throw new Error("Static arrays of user types are not supported");
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return getUserTypeInfo(abiOrUserType, config);
|
|
27
|
-
}
|
|
28
|
-
function importForAbiOrUserType(abiOrUserType, usedInDirectory, config) {
|
|
29
|
-
if (abiOrUserType in AbiTypeToSchemaType) {
|
|
30
|
-
return void 0;
|
|
31
|
-
}
|
|
32
|
-
const staticArray = parseStaticArray(abiOrUserType);
|
|
33
|
-
if (staticArray) {
|
|
34
|
-
return void 0;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
symbol: abiOrUserType,
|
|
38
|
-
fromPath: config.userTypesPath + ".sol",
|
|
39
|
-
usedInPath: usedInDirectory
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function getSchemaTypeInfo(schemaType) {
|
|
43
|
-
const staticByteLength = getStaticByteLength(schemaType);
|
|
44
|
-
const isDynamic = staticByteLength === 0;
|
|
45
|
-
const typeId = SchemaTypeToAbiType[schemaType];
|
|
46
|
-
return {
|
|
47
|
-
typeId,
|
|
48
|
-
typeWithLocation: isDynamic ? typeId + " memory" : typeId,
|
|
49
|
-
enumName: SchemaType[schemaType],
|
|
50
|
-
staticByteLength,
|
|
51
|
-
isDynamic,
|
|
52
|
-
typeWrap: "",
|
|
53
|
-
typeUnwrap: "",
|
|
54
|
-
internalTypeId: typeId
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
function getUserTypeInfo(userType, config) {
|
|
58
|
-
if (userType in config.enums) {
|
|
59
|
-
const schemaType = 0 /* UINT8 */;
|
|
60
|
-
const staticByteLength = getStaticByteLength(schemaType);
|
|
61
|
-
const isDynamic = staticByteLength === 0;
|
|
62
|
-
const typeId = userType;
|
|
63
|
-
return {
|
|
64
|
-
schemaType,
|
|
65
|
-
renderTableType: {
|
|
66
|
-
typeId,
|
|
67
|
-
typeWithLocation: typeId,
|
|
68
|
-
enumName: SchemaType[schemaType],
|
|
69
|
-
staticByteLength,
|
|
70
|
-
isDynamic,
|
|
71
|
-
typeWrap: `${userType}`,
|
|
72
|
-
typeUnwrap: `uint8`,
|
|
73
|
-
internalTypeId: `${SchemaTypeToAbiType[schemaType]}`
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
throw new Error(`User type "${userType}" does not exist`);
|
|
78
|
-
}
|
|
79
|
-
function getStaticArrayTypeInfo(abiType, elementType, staticLength) {
|
|
80
|
-
const internalTypeId = elementType + "[]";
|
|
81
|
-
const schemaType = AbiTypeToSchemaType[internalTypeId];
|
|
82
|
-
return {
|
|
83
|
-
schemaType,
|
|
84
|
-
renderTableType: {
|
|
85
|
-
typeId: abiType,
|
|
86
|
-
typeWithLocation: `${abiType} memory`,
|
|
87
|
-
enumName: SchemaType[schemaType],
|
|
88
|
-
staticByteLength: 0,
|
|
89
|
-
isDynamic: true,
|
|
90
|
-
typeWrap: `toStaticArray_${elementType}_${staticLength}`,
|
|
91
|
-
typeUnwrap: `fromStaticArray_${elementType}_${staticLength}`,
|
|
92
|
-
typeWrappingData: {
|
|
93
|
-
kind: "staticArray",
|
|
94
|
-
elementType,
|
|
95
|
-
staticLength
|
|
96
|
-
},
|
|
97
|
-
internalTypeId
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// src/utils/format.ts
|
|
103
|
-
import chalk from "chalk";
|
|
104
|
-
import prettier from "prettier";
|
|
105
|
-
import prettierPluginSolidity from "prettier-plugin-solidity";
|
|
106
|
-
async function formatSolidity(content, prettierConfigPath) {
|
|
107
|
-
let config;
|
|
108
|
-
if (prettierConfigPath) {
|
|
109
|
-
config = await prettier.resolveConfig(prettierConfigPath);
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
return prettier.format(content, {
|
|
113
|
-
plugins: [prettierPluginSolidity],
|
|
114
|
-
parser: "solidity-parse",
|
|
115
|
-
printWidth: 120,
|
|
116
|
-
semi: true,
|
|
117
|
-
tabWidth: 2,
|
|
118
|
-
useTabs: false,
|
|
119
|
-
bracketSpacing: true,
|
|
120
|
-
...config
|
|
121
|
-
});
|
|
122
|
-
} catch (error) {
|
|
123
|
-
let message;
|
|
124
|
-
if (error instanceof Error) {
|
|
125
|
-
message = error.message;
|
|
126
|
-
} else {
|
|
127
|
-
message = error;
|
|
128
|
-
}
|
|
129
|
-
console.log(chalk.yellow(`Error during output formatting: ${message}`));
|
|
130
|
-
return content;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
async function formatTypescript(content) {
|
|
134
|
-
return prettier.format(content, {
|
|
135
|
-
parser: "typescript"
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// src/utils/formatAndWrite.ts
|
|
140
|
-
import { mkdirSync, writeFileSync } from "fs";
|
|
141
|
-
import { dirname } from "path";
|
|
142
|
-
async function formatAndWriteSolidity(output, fullOutputPath, logPrefix) {
|
|
143
|
-
const formattedOutput = await formatSolidity(output);
|
|
144
|
-
mkdirSync(dirname(fullOutputPath), { recursive: true });
|
|
145
|
-
writeFileSync(fullOutputPath, formattedOutput);
|
|
146
|
-
console.log(`${logPrefix}: ${fullOutputPath}`);
|
|
147
|
-
}
|
|
148
|
-
async function formatAndWriteTypescript(output, fullOutputPath, logPrefix) {
|
|
149
|
-
const formattedOutput = await formatTypescript(output);
|
|
150
|
-
mkdirSync(dirname(fullOutputPath), { recursive: true });
|
|
151
|
-
writeFileSync(fullOutputPath, formattedOutput);
|
|
152
|
-
console.log(`${logPrefix}: ${fullOutputPath}`);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export {
|
|
156
|
-
resolveAbiOrUserType,
|
|
157
|
-
importForAbiOrUserType,
|
|
158
|
-
getSchemaTypeInfo,
|
|
159
|
-
getUserTypeInfo,
|
|
160
|
-
formatSolidity,
|
|
161
|
-
formatTypescript,
|
|
162
|
-
formatAndWriteSolidity,
|
|
163
|
-
formatAndWriteTypescript
|
|
164
|
-
};
|
package/dist/chunk-7GA2K5A6.js
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
formatAndWriteTypescript,
|
|
3
|
-
resolveAbiOrUserType
|
|
4
|
-
} from "./chunk-5NC2OON2.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.Number",
|
|
15
|
-
[7 /* UINT64 */]: "RecsType.Number",
|
|
16
|
-
[8 /* UINT72 */]: "RecsType.Number",
|
|
17
|
-
[9 /* UINT80 */]: "RecsType.Number",
|
|
18
|
-
[10 /* UINT88 */]: "RecsType.Number",
|
|
19
|
-
[11 /* UINT96 */]: "RecsType.Number",
|
|
20
|
-
[12 /* UINT104 */]: "RecsType.Number",
|
|
21
|
-
[13 /* UINT112 */]: "RecsType.Number",
|
|
22
|
-
[14 /* UINT120 */]: "RecsType.Number",
|
|
23
|
-
[15 /* UINT128 */]: "RecsType.Number",
|
|
24
|
-
[16 /* UINT136 */]: "RecsType.Number",
|
|
25
|
-
[17 /* UINT144 */]: "RecsType.Number",
|
|
26
|
-
[18 /* UINT152 */]: "RecsType.Number",
|
|
27
|
-
[19 /* UINT160 */]: "RecsType.Number",
|
|
28
|
-
[20 /* UINT168 */]: "RecsType.Number",
|
|
29
|
-
[21 /* UINT176 */]: "RecsType.Number",
|
|
30
|
-
[22 /* UINT184 */]: "RecsType.Number",
|
|
31
|
-
[23 /* UINT192 */]: "RecsType.Number",
|
|
32
|
-
[24 /* UINT200 */]: "RecsType.Number",
|
|
33
|
-
[25 /* UINT208 */]: "RecsType.Number",
|
|
34
|
-
[26 /* UINT216 */]: "RecsType.Number",
|
|
35
|
-
[27 /* UINT224 */]: "RecsType.Number",
|
|
36
|
-
[28 /* UINT232 */]: "RecsType.Number",
|
|
37
|
-
[29 /* UINT240 */]: "RecsType.Number",
|
|
38
|
-
[30 /* UINT248 */]: "RecsType.Number",
|
|
39
|
-
[31 /* UINT256 */]: "RecsType.Number",
|
|
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.Number",
|
|
47
|
-
[39 /* INT64 */]: "RecsType.Number",
|
|
48
|
-
[40 /* INT72 */]: "RecsType.Number",
|
|
49
|
-
[41 /* INT80 */]: "RecsType.Number",
|
|
50
|
-
[42 /* INT88 */]: "RecsType.Number",
|
|
51
|
-
[43 /* INT96 */]: "RecsType.Number",
|
|
52
|
-
[44 /* INT104 */]: "RecsType.Number",
|
|
53
|
-
[45 /* INT112 */]: "RecsType.Number",
|
|
54
|
-
[46 /* INT120 */]: "RecsType.Number",
|
|
55
|
-
[47 /* INT128 */]: "RecsType.Number",
|
|
56
|
-
[48 /* INT136 */]: "RecsType.Number",
|
|
57
|
-
[49 /* INT144 */]: "RecsType.Number",
|
|
58
|
-
[50 /* INT152 */]: "RecsType.Number",
|
|
59
|
-
[51 /* INT160 */]: "RecsType.Number",
|
|
60
|
-
[52 /* INT168 */]: "RecsType.Number",
|
|
61
|
-
[53 /* INT176 */]: "RecsType.Number",
|
|
62
|
-
[54 /* INT184 */]: "RecsType.Number",
|
|
63
|
-
[55 /* INT192 */]: "RecsType.Number",
|
|
64
|
-
[56 /* INT200 */]: "RecsType.Number",
|
|
65
|
-
[57 /* INT208 */]: "RecsType.Number",
|
|
66
|
-
[58 /* INT216 */]: "RecsType.Number",
|
|
67
|
-
[59 /* INT224 */]: "RecsType.Number",
|
|
68
|
-
[60 /* INT232 */]: "RecsType.Number",
|
|
69
|
-
[61 /* INT240 */]: "RecsType.Number",
|
|
70
|
-
[62 /* INT248 */]: "RecsType.Number",
|
|
71
|
-
[63 /* INT256 */]: "RecsType.Number",
|
|
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.NumberArray",
|
|
113
|
-
[105 /* UINT64_ARRAY */]: "RecsType.NumberArray",
|
|
114
|
-
[106 /* UINT72_ARRAY */]: "RecsType.NumberArray",
|
|
115
|
-
[107 /* UINT80_ARRAY */]: "RecsType.NumberArray",
|
|
116
|
-
[108 /* UINT88_ARRAY */]: "RecsType.NumberArray",
|
|
117
|
-
[109 /* UINT96_ARRAY */]: "RecsType.NumberArray",
|
|
118
|
-
[110 /* UINT104_ARRAY */]: "RecsType.NumberArray",
|
|
119
|
-
[111 /* UINT112_ARRAY */]: "RecsType.NumberArray",
|
|
120
|
-
[112 /* UINT120_ARRAY */]: "RecsType.NumberArray",
|
|
121
|
-
[113 /* UINT128_ARRAY */]: "RecsType.NumberArray",
|
|
122
|
-
[114 /* UINT136_ARRAY */]: "RecsType.NumberArray",
|
|
123
|
-
[115 /* UINT144_ARRAY */]: "RecsType.NumberArray",
|
|
124
|
-
[116 /* UINT152_ARRAY */]: "RecsType.NumberArray",
|
|
125
|
-
[117 /* UINT160_ARRAY */]: "RecsType.NumberArray",
|
|
126
|
-
[118 /* UINT168_ARRAY */]: "RecsType.NumberArray",
|
|
127
|
-
[119 /* UINT176_ARRAY */]: "RecsType.NumberArray",
|
|
128
|
-
[120 /* UINT184_ARRAY */]: "RecsType.NumberArray",
|
|
129
|
-
[121 /* UINT192_ARRAY */]: "RecsType.NumberArray",
|
|
130
|
-
[122 /* UINT200_ARRAY */]: "RecsType.NumberArray",
|
|
131
|
-
[123 /* UINT208_ARRAY */]: "RecsType.NumberArray",
|
|
132
|
-
[124 /* UINT216_ARRAY */]: "RecsType.NumberArray",
|
|
133
|
-
[125 /* UINT224_ARRAY */]: "RecsType.NumberArray",
|
|
134
|
-
[126 /* UINT232_ARRAY */]: "RecsType.NumberArray",
|
|
135
|
-
[127 /* UINT240_ARRAY */]: "RecsType.NumberArray",
|
|
136
|
-
[128 /* UINT248_ARRAY */]: "RecsType.NumberArray",
|
|
137
|
-
[129 /* UINT256_ARRAY */]: "RecsType.NumberArray",
|
|
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.NumberArray",
|
|
145
|
-
[137 /* INT64_ARRAY */]: "RecsType.NumberArray",
|
|
146
|
-
[138 /* INT72_ARRAY */]: "RecsType.NumberArray",
|
|
147
|
-
[139 /* INT80_ARRAY */]: "RecsType.NumberArray",
|
|
148
|
-
[140 /* INT88_ARRAY */]: "RecsType.NumberArray",
|
|
149
|
-
[141 /* INT96_ARRAY */]: "RecsType.NumberArray",
|
|
150
|
-
[142 /* INT104_ARRAY */]: "RecsType.NumberArray",
|
|
151
|
-
[143 /* INT112_ARRAY */]: "RecsType.NumberArray",
|
|
152
|
-
[144 /* INT120_ARRAY */]: "RecsType.NumberArray",
|
|
153
|
-
[145 /* INT128_ARRAY */]: "RecsType.NumberArray",
|
|
154
|
-
[146 /* INT136_ARRAY */]: "RecsType.NumberArray",
|
|
155
|
-
[147 /* INT144_ARRAY */]: "RecsType.NumberArray",
|
|
156
|
-
[148 /* INT152_ARRAY */]: "RecsType.NumberArray",
|
|
157
|
-
[149 /* INT160_ARRAY */]: "RecsType.NumberArray",
|
|
158
|
-
[150 /* INT168_ARRAY */]: "RecsType.NumberArray",
|
|
159
|
-
[151 /* INT176_ARRAY */]: "RecsType.NumberArray",
|
|
160
|
-
[152 /* INT184_ARRAY */]: "RecsType.NumberArray",
|
|
161
|
-
[153 /* INT192_ARRAY */]: "RecsType.NumberArray",
|
|
162
|
-
[154 /* INT200_ARRAY */]: "RecsType.NumberArray",
|
|
163
|
-
[155 /* INT208_ARRAY */]: "RecsType.NumberArray",
|
|
164
|
-
[156 /* INT216_ARRAY */]: "RecsType.NumberArray",
|
|
165
|
-
[157 /* INT224_ARRAY */]: "RecsType.NumberArray",
|
|
166
|
-
[158 /* INT232_ARRAY */]: "RecsType.NumberArray",
|
|
167
|
-
[159 /* INT240_ARRAY */]: "RecsType.NumberArray",
|
|
168
|
-
[160 /* INT248_ARRAY */]: "RecsType.NumberArray",
|
|
169
|
-
[161 /* INT256_ARRAY */]: "RecsType.NumberArray",
|
|
170
|
-
[162 /* BYTES1_ARRAY */]: "RecsType.StringArray",
|
|
171
|
-
[163 /* BYTES2_ARRAY */]: "RecsType.StringArray",
|
|
172
|
-
[164 /* BYTES3_ARRAY */]: "RecsType.StringArray",
|
|
173
|
-
[165 /* BYTES4_ARRAY */]: "RecsType.StringArray",
|
|
174
|
-
[166 /* BYTES5_ARRAY */]: "RecsType.StringArray",
|
|
175
|
-
[167 /* BYTES6_ARRAY */]: "RecsType.StringArray",
|
|
176
|
-
[168 /* BYTES7_ARRAY */]: "RecsType.StringArray",
|
|
177
|
-
[169 /* BYTES8_ARRAY */]: "RecsType.StringArray",
|
|
178
|
-
[170 /* BYTES9_ARRAY */]: "RecsType.StringArray",
|
|
179
|
-
[171 /* BYTES10_ARRAY */]: "RecsType.StringArray",
|
|
180
|
-
[172 /* BYTES11_ARRAY */]: "RecsType.StringArray",
|
|
181
|
-
[173 /* BYTES12_ARRAY */]: "RecsType.StringArray",
|
|
182
|
-
[174 /* BYTES13_ARRAY */]: "RecsType.StringArray",
|
|
183
|
-
[175 /* BYTES14_ARRAY */]: "RecsType.StringArray",
|
|
184
|
-
[176 /* BYTES15_ARRAY */]: "RecsType.StringArray",
|
|
185
|
-
[177 /* BYTES16_ARRAY */]: "RecsType.StringArray",
|
|
186
|
-
[178 /* BYTES17_ARRAY */]: "RecsType.StringArray",
|
|
187
|
-
[179 /* BYTES18_ARRAY */]: "RecsType.StringArray",
|
|
188
|
-
[180 /* BYTES19_ARRAY */]: "RecsType.StringArray",
|
|
189
|
-
[181 /* BYTES20_ARRAY */]: "RecsType.StringArray",
|
|
190
|
-
[182 /* BYTES21_ARRAY */]: "RecsType.StringArray",
|
|
191
|
-
[183 /* BYTES22_ARRAY */]: "RecsType.StringArray",
|
|
192
|
-
[184 /* BYTES23_ARRAY */]: "RecsType.StringArray",
|
|
193
|
-
[185 /* BYTES24_ARRAY */]: "RecsType.StringArray",
|
|
194
|
-
[186 /* BYTES25_ARRAY */]: "RecsType.StringArray",
|
|
195
|
-
[187 /* BYTES26_ARRAY */]: "RecsType.StringArray",
|
|
196
|
-
[188 /* BYTES27_ARRAY */]: "RecsType.StringArray",
|
|
197
|
-
[189 /* BYTES28_ARRAY */]: "RecsType.StringArray",
|
|
198
|
-
[190 /* BYTES29_ARRAY */]: "RecsType.StringArray",
|
|
199
|
-
[191 /* BYTES30_ARRAY */]: "RecsType.StringArray",
|
|
200
|
-
[192 /* BYTES31_ARRAY */]: "RecsType.StringArray",
|
|
201
|
-
[193 /* BYTES32_ARRAY */]: "RecsType.StringArray",
|
|
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
|
-
fileSelector: tableData.fileSelector
|
|
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, fileSelector } = table.staticResourceData;
|
|
257
|
-
return `
|
|
258
|
-
(() => {
|
|
259
|
-
const tableId = new TableId("${namespace}", "${fileSelector}");
|
|
260
|
-
return defineComponent(world, {
|
|
261
|
-
${table.fields.map(({ name, recsTypeString }) => `${name}: ${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
|
-
};
|