@latticexyz/cli 2.0.0-alpha.68 → 2.0.0-alpha.7
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-TPZUS44H.js → chunk-6V563IAZ.js} +5 -5
- package/dist/{chunk-B6YHE4SO.js → chunk-KJTPZOUH.js} +364 -231
- 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-MIGVHECZ.js → chunk-WZFXLDPK.js} +38 -15
- package/dist/{chunk-3FH42MS5.js → chunk-YL4GJLLL.js} +6982 -6230
- package/dist/index.d.ts +2 -4
- package/dist/index.js +0 -22
- package/dist/mud.js +311 -318
- package/dist/mud2.js +7 -9
- package/dist/render-solidity/index.d.ts +2 -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 +2 -2
- package/dist/utils/index.d.ts +3 -15
- package/dist/utils/index.js +4 -15
- package/package.json +17 -20
- package/src/commands/deploy-v2.ts +8 -4
- package/src/commands/deprecated/test.ts +1 -1
- package/src/commands/gas-report.ts +54 -55
- package/src/commands/set-version.ts +39 -10
- package/src/commands/tablegen.ts +5 -5
- 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/render-solidity/common.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 +1 -1
- package/src/render-solidity/userType.ts +1 -2
- package/src/render-solidity/worldgen.ts +3 -3
- package/src/render-ts/recsV1TableOptions.ts +2 -2
- package/src/render-ts/renderRecsV1Tables.ts +2 -2
- package/src/render-ts/tsgen.ts +1 -1
- package/src/render-ts/types.ts +1 -1
- package/src/utils/contractToInterface.ts +1 -1
- package/src/utils/deploy-v2.ts +85 -78
- package/src/utils/errors.ts +3 -23
- package/dist/chunk-5NC2OON2.js +0 -164
- package/dist/chunk-FFY7VTYB.js +0 -14358
- package/dist/chunk-S7JI7355.js +0 -441
- package/dist/config/index.d.ts +0 -408
- package/dist/config/index.js +0 -85
- package/dist/parseStoreConfig-05533795.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 -40
- 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 -56
- package/src/config/world/resolveWorldConfig.ts +0 -80
- package/src/config/world/userTypes.ts +0 -74
- package/src/utils/typeUtils.ts +0 -17
package/src/utils/errors.ts
CHANGED
|
@@ -1,28 +1,8 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import {
|
|
2
|
+
import { ZodError } from "zod";
|
|
3
3
|
import { fromZodError, ValidationError } from "zod-validation-error";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export function fromZodErrorCustom(error: ZodError, prefix: string) {
|
|
7
|
-
return fromZodError(error, {
|
|
8
|
-
prefix: chalk.red(prefix),
|
|
9
|
-
prefixSeparator: "\n- ",
|
|
10
|
-
issueSeparator: "\n- ",
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class NotInsideProjectError extends Error {
|
|
15
|
-
name = "NotInsideProjectError";
|
|
16
|
-
message = "You are not inside a MUD project";
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class MUDError extends Error {
|
|
20
|
-
name = "MUDError";
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function UnrecognizedSystemErrorFactory(path: string[], systemName: string) {
|
|
24
|
-
return new z.ZodError([{ code: ZodIssueCode.custom, path: path, message: `Unrecognized system: "${systemName}"` }]);
|
|
25
|
-
}
|
|
4
|
+
import { NotInsideProjectError } from "@latticexyz/config";
|
|
5
|
+
import { MUDError } from "@latticexyz/config";
|
|
26
6
|
|
|
27
7
|
export function logError(error: unknown) {
|
|
28
8
|
if (error instanceof ValidationError) {
|
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
|
-
};
|