@latticexyz/cli 2.0.0-alpha.78 → 2.0.0-alpha.8
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-O6HOO6WA.js → chunk-L4YLJHLJ.js} +1 -9
- package/dist/{chunk-TLEAEDUA.js → chunk-QAJBBYA2.js} +357 -224
- package/dist/{chunk-KPBNUPK6.js → chunk-SKNB74MT.js} +155 -159
- package/dist/chunk-VQTZJIFF.js +353 -0
- package/dist/{chunk-DO7OWTMM.js → chunk-WZFXLDPK.js} +7 -9
- package/dist/{chunk-XUNWAEP7.js → chunk-YL4GJLLL.js} +5345 -6628
- 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 +36 -37
- 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 +1 -1
- package/src/commands/tsgen.ts +1 -1
- package/src/commands/worldgen.ts +1 -2
- 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/renderTypesFromConfig.ts +1 -1
- package/src/render-solidity/tableOptions.ts +2 -2
- package/src/render-solidity/tablegen.ts +1 -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 +79 -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-MN3HYFJK.js +0 -442
- package/dist/config/index.d.ts +0 -409
- package/dist/config/index.js +0 -85
- package/dist/parseStoreConfig-8aa69ac9.d.ts +0 -377
- 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 -317
- 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/dist/chunk-MN3HYFJK.js
DELETED
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AbiTypes,
|
|
3
|
-
StaticAbiTypes,
|
|
4
|
-
getDuplicates,
|
|
5
|
-
parseStaticArray,
|
|
6
|
-
validateBaseRoute,
|
|
7
|
-
validateCapitalizedName,
|
|
8
|
-
validateEnum,
|
|
9
|
-
validateEthereumAddress,
|
|
10
|
-
validateName,
|
|
11
|
-
validateRoute,
|
|
12
|
-
validateSelector,
|
|
13
|
-
validateSingleLevelRoute,
|
|
14
|
-
validateUncapitalizedName
|
|
15
|
-
} from "./chunk-KPBNUPK6.js";
|
|
16
|
-
|
|
17
|
-
// src/config/commonSchemas.ts
|
|
18
|
-
import { z } from "zod";
|
|
19
|
-
var zObjectName = z.string().superRefine(validateCapitalizedName);
|
|
20
|
-
var zValueName = z.string().superRefine(validateUncapitalizedName);
|
|
21
|
-
var zAnyCaseName = z.string().superRefine(validateName);
|
|
22
|
-
var zUserEnum = z.array(zObjectName).superRefine(validateEnum);
|
|
23
|
-
var zOrdinaryRoute = z.string().superRefine(validateRoute);
|
|
24
|
-
var zSingleLevelRoute = z.string().superRefine(validateSingleLevelRoute);
|
|
25
|
-
var zBaseRoute = z.string().superRefine(validateBaseRoute);
|
|
26
|
-
var zEthereumAddress = z.string().superRefine(validateEthereumAddress);
|
|
27
|
-
var zSelector = z.string().superRefine(validateSelector);
|
|
28
|
-
|
|
29
|
-
// src/config/loadConfig.ts
|
|
30
|
-
import { findUp } from "find-up";
|
|
31
|
-
import path from "path";
|
|
32
|
-
|
|
33
|
-
// src/utils/errors.ts
|
|
34
|
-
import chalk from "chalk";
|
|
35
|
-
import { z as z2, ZodError, ZodIssueCode } from "zod";
|
|
36
|
-
import { fromZodError, ValidationError } from "zod-validation-error";
|
|
37
|
-
function fromZodErrorCustom(error, prefix) {
|
|
38
|
-
return fromZodError(error, {
|
|
39
|
-
prefix: chalk.red(prefix),
|
|
40
|
-
prefixSeparator: "\n- ",
|
|
41
|
-
issueSeparator: "\n- "
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
var NotInsideProjectError = class extends Error {
|
|
45
|
-
constructor() {
|
|
46
|
-
super(...arguments);
|
|
47
|
-
this.name = "NotInsideProjectError";
|
|
48
|
-
this.message = "You are not inside a MUD project";
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
var MUDError = class extends Error {
|
|
52
|
-
constructor() {
|
|
53
|
-
super(...arguments);
|
|
54
|
-
this.name = "MUDError";
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
function UnrecognizedSystemErrorFactory(path2, systemName) {
|
|
58
|
-
return new z2.ZodError([{ code: ZodIssueCode.custom, path: path2, message: `Unrecognized system: "${systemName}"` }]);
|
|
59
|
-
}
|
|
60
|
-
function logError(error) {
|
|
61
|
-
if (error instanceof ValidationError) {
|
|
62
|
-
console.log(chalk.redBright(error.message));
|
|
63
|
-
} else if (error instanceof ZodError) {
|
|
64
|
-
const validationError = fromZodError(error, {
|
|
65
|
-
prefixSeparator: "\n- ",
|
|
66
|
-
issueSeparator: "\n- "
|
|
67
|
-
});
|
|
68
|
-
console.log(chalk.redBright(validationError.message));
|
|
69
|
-
} else if (error instanceof NotInsideProjectError) {
|
|
70
|
-
console.log(chalk.red(error.message));
|
|
71
|
-
console.log("");
|
|
72
|
-
console.log(chalk.blue(`To learn more about MUD's configuration, please go to https://mud.dev/packages/cli/`));
|
|
73
|
-
} else if (error instanceof MUDError) {
|
|
74
|
-
console.log(chalk.red(error));
|
|
75
|
-
} else {
|
|
76
|
-
console.log(error);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/config/loadConfig.ts
|
|
81
|
-
import esbuild from "esbuild";
|
|
82
|
-
import { rmSync } from "fs";
|
|
83
|
-
var configFiles = ["mud.config.js", "mud.config.mjs", "mud.config.ts", "mud.config.mts"];
|
|
84
|
-
var TEMP_CONFIG = "mud.config.temp.mjs";
|
|
85
|
-
async function loadConfig(configPath) {
|
|
86
|
-
configPath = await resolveConfigPath(configPath);
|
|
87
|
-
try {
|
|
88
|
-
await esbuild.build({ entryPoints: [configPath], format: "esm", outfile: TEMP_CONFIG });
|
|
89
|
-
configPath = await resolveConfigPath(TEMP_CONFIG);
|
|
90
|
-
return (await import(configPath)).default;
|
|
91
|
-
} finally {
|
|
92
|
-
rmSync(TEMP_CONFIG);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
async function resolveConfigPath(configPath) {
|
|
96
|
-
if (configPath === void 0) {
|
|
97
|
-
configPath = await getUserConfigPath();
|
|
98
|
-
} else {
|
|
99
|
-
if (!path.isAbsolute(configPath)) {
|
|
100
|
-
configPath = path.join(process.cwd(), configPath);
|
|
101
|
-
configPath = path.normalize(configPath);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return configPath;
|
|
105
|
-
}
|
|
106
|
-
async function getUserConfigPath() {
|
|
107
|
-
const tsConfigPath = await findUp(configFiles);
|
|
108
|
-
if (tsConfigPath === void 0) {
|
|
109
|
-
throw new NotInsideProjectError();
|
|
110
|
-
}
|
|
111
|
-
return tsConfigPath;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/config/loadStoreConfig.ts
|
|
115
|
-
import { ZodError as ZodError2 } from "zod";
|
|
116
|
-
|
|
117
|
-
// src/config/parseStoreConfig.ts
|
|
118
|
-
import { z as z3, ZodIssueCode as ZodIssueCode2 } from "zod";
|
|
119
|
-
var zTableName = zObjectName;
|
|
120
|
-
var zKeyName = zValueName;
|
|
121
|
-
var zColumnName = zValueName;
|
|
122
|
-
var zUserEnumName = zObjectName;
|
|
123
|
-
var zFieldData = z3.string();
|
|
124
|
-
var zPrimaryKey = z3.string();
|
|
125
|
-
var zPrimaryKeys = z3.record(zKeyName, zPrimaryKey).default({ key: "bytes32" });
|
|
126
|
-
var zFullSchemaConfig = z3.record(zColumnName, zFieldData).refine((arg) => Object.keys(arg).length > 0, "Table schema may not be empty");
|
|
127
|
-
var zShorthandSchemaConfig = zFieldData.transform((fieldData) => {
|
|
128
|
-
return zFullSchemaConfig.parse({
|
|
129
|
-
value: fieldData
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
var zSchemaConfig = zFullSchemaConfig.or(zShorthandSchemaConfig);
|
|
133
|
-
var zFullTableConfig = z3.object({
|
|
134
|
-
directory: z3.string().default("tables"),
|
|
135
|
-
fileSelector: zSelector.optional(),
|
|
136
|
-
tableIdArgument: z3.boolean().default(false),
|
|
137
|
-
storeArgument: z3.boolean().default(true),
|
|
138
|
-
primaryKeys: zPrimaryKeys,
|
|
139
|
-
schema: zSchemaConfig,
|
|
140
|
-
dataStruct: z3.boolean().optional()
|
|
141
|
-
}).transform((arg) => {
|
|
142
|
-
if (Object.keys(arg.schema).length === 1) {
|
|
143
|
-
arg.dataStruct ??= false;
|
|
144
|
-
} else {
|
|
145
|
-
arg.dataStruct ??= true;
|
|
146
|
-
}
|
|
147
|
-
return arg;
|
|
148
|
-
});
|
|
149
|
-
var zShorthandTableConfig = zFieldData.transform((fieldData) => {
|
|
150
|
-
return zFullTableConfig.parse({
|
|
151
|
-
schema: {
|
|
152
|
-
value: fieldData
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
var zTableConfig = zFullTableConfig.or(zShorthandTableConfig);
|
|
157
|
-
var zTablesConfig = z3.record(zTableName, zTableConfig).transform((tables) => {
|
|
158
|
-
for (const tableName of Object.keys(tables)) {
|
|
159
|
-
const table = tables[tableName];
|
|
160
|
-
table.fileSelector ??= tableName;
|
|
161
|
-
tables[tableName] = table;
|
|
162
|
-
}
|
|
163
|
-
return tables;
|
|
164
|
-
});
|
|
165
|
-
var zEnumsConfig = z3.object({
|
|
166
|
-
enums: z3.record(zUserEnumName, zUserEnum).default({})
|
|
167
|
-
});
|
|
168
|
-
function storeConfig(config) {
|
|
169
|
-
return config;
|
|
170
|
-
}
|
|
171
|
-
var StoreConfigUnrefined = z3.object({
|
|
172
|
-
namespace: zSelector.default(""),
|
|
173
|
-
storeImportPath: z3.string().default("@latticexyz/store/src/"),
|
|
174
|
-
tables: zTablesConfig,
|
|
175
|
-
userTypesPath: z3.string().default("Types"),
|
|
176
|
-
codegenDirectory: z3.string().default("codegen")
|
|
177
|
-
}).merge(zEnumsConfig);
|
|
178
|
-
var zStoreConfig = StoreConfigUnrefined.superRefine(validateStoreConfig);
|
|
179
|
-
function parseStoreConfig(config) {
|
|
180
|
-
return zStoreConfig.parse(config);
|
|
181
|
-
}
|
|
182
|
-
function validateStoreConfig(config, ctx) {
|
|
183
|
-
for (const table of Object.values(config.tables)) {
|
|
184
|
-
const primaryKeyNames = Object.keys(table.primaryKeys);
|
|
185
|
-
const fieldNames = Object.keys(table.schema);
|
|
186
|
-
const duplicateVariableNames = getDuplicates([...primaryKeyNames, ...fieldNames]);
|
|
187
|
-
if (duplicateVariableNames.length > 0) {
|
|
188
|
-
ctx.addIssue({
|
|
189
|
-
code: ZodIssueCode2.custom,
|
|
190
|
-
message: `Field and primary key names within one table must be unique: ${duplicateVariableNames.join(", ")}`
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
const tableNames = Object.keys(config.tables);
|
|
195
|
-
const staticUserTypeNames = Object.keys(config.enums);
|
|
196
|
-
const userTypeNames = staticUserTypeNames;
|
|
197
|
-
const globalNames = [...tableNames, ...userTypeNames];
|
|
198
|
-
const duplicateGlobalNames = getDuplicates(globalNames);
|
|
199
|
-
if (duplicateGlobalNames.length > 0) {
|
|
200
|
-
ctx.addIssue({
|
|
201
|
-
code: ZodIssueCode2.custom,
|
|
202
|
-
message: `Table, enum names must be globally unique: ${duplicateGlobalNames.join(", ")}`
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
for (const table of Object.values(config.tables)) {
|
|
206
|
-
for (const primaryKeyType of Object.values(table.primaryKeys)) {
|
|
207
|
-
validateStaticAbiOrUserType(staticUserTypeNames, primaryKeyType, ctx);
|
|
208
|
-
}
|
|
209
|
-
for (const fieldType of Object.values(table.schema)) {
|
|
210
|
-
validateAbiOrUserType(userTypeNames, staticUserTypeNames, fieldType, ctx);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
function validateAbiOrUserType(userTypeNames, staticUserTypeNames, type, ctx) {
|
|
215
|
-
if (!AbiTypes.includes(type) && !userTypeNames.includes(type)) {
|
|
216
|
-
const staticArray = parseStaticArray(type);
|
|
217
|
-
if (staticArray) {
|
|
218
|
-
validateStaticArray(staticUserTypeNames, staticArray.elementType, staticArray.staticLength, ctx);
|
|
219
|
-
} else {
|
|
220
|
-
ctx.addIssue({
|
|
221
|
-
code: ZodIssueCode2.custom,
|
|
222
|
-
message: `${type} is not a valid abi type, and is not defined in userTypes`
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
function validateStaticAbiOrUserType(staticUserTypeNames, type, ctx) {
|
|
228
|
-
if (!StaticAbiTypes.includes(type) && !staticUserTypeNames.includes(type)) {
|
|
229
|
-
ctx.addIssue({
|
|
230
|
-
code: ZodIssueCode2.custom,
|
|
231
|
-
message: `${type} is not a static type`
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function validateStaticArray(staticUserTypeNames, elementType, staticLength, ctx) {
|
|
236
|
-
validateStaticAbiOrUserType(staticUserTypeNames, elementType, ctx);
|
|
237
|
-
if (staticLength === 0) {
|
|
238
|
-
ctx.addIssue({
|
|
239
|
-
code: ZodIssueCode2.custom,
|
|
240
|
-
message: `Static array length must not be 0`
|
|
241
|
-
});
|
|
242
|
-
} else if (staticLength >= 2 ** 16) {
|
|
243
|
-
ctx.addIssue({
|
|
244
|
-
code: ZodIssueCode2.custom,
|
|
245
|
-
message: `Static array length must be less than 2**16`
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// src/config/loadStoreConfig.ts
|
|
251
|
-
async function loadStoreConfig(configPath) {
|
|
252
|
-
const config = await loadConfig(configPath);
|
|
253
|
-
try {
|
|
254
|
-
return parseStoreConfig(config);
|
|
255
|
-
} catch (error) {
|
|
256
|
-
if (error instanceof ZodError2) {
|
|
257
|
-
throw fromZodErrorCustom(error, "StoreConfig Validation Error");
|
|
258
|
-
} else {
|
|
259
|
-
throw error;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// src/config/world/loadWorldConfig.ts
|
|
265
|
-
import { ZodError as ZodError3 } from "zod";
|
|
266
|
-
|
|
267
|
-
// src/config/world/parseWorldConfig.ts
|
|
268
|
-
import { z as z4 } from "zod";
|
|
269
|
-
|
|
270
|
-
// src/config/dynamicResolution.ts
|
|
271
|
-
var DynamicResolutionType = /* @__PURE__ */ ((DynamicResolutionType2) => {
|
|
272
|
-
DynamicResolutionType2[DynamicResolutionType2["TABLE_ID"] = 0] = "TABLE_ID";
|
|
273
|
-
DynamicResolutionType2[DynamicResolutionType2["SYSTEM_ADDRESS"] = 1] = "SYSTEM_ADDRESS";
|
|
274
|
-
return DynamicResolutionType2;
|
|
275
|
-
})(DynamicResolutionType || {});
|
|
276
|
-
function resolveTableId(tableName) {
|
|
277
|
-
return {
|
|
278
|
-
type: 0 /* TABLE_ID */,
|
|
279
|
-
input: tableName
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
|
-
function isDynamicResolution(value) {
|
|
283
|
-
return typeof value === "object" && value !== null && "type" in value && "input" in value;
|
|
284
|
-
}
|
|
285
|
-
async function resolveWithContext(unresolved, context) {
|
|
286
|
-
if (!isDynamicResolution(unresolved))
|
|
287
|
-
return unresolved;
|
|
288
|
-
let resolved = void 0;
|
|
289
|
-
if (unresolved.type === 0 /* TABLE_ID */) {
|
|
290
|
-
const tableId = context.tableIds?.[unresolved.input];
|
|
291
|
-
resolved = tableId && { value: tableId, type: "bytes32" };
|
|
292
|
-
}
|
|
293
|
-
if (resolved === void 0) {
|
|
294
|
-
throw new MUDError(`Could not resolve dynamic resolution:
|
|
295
|
-
${JSON.stringify(unresolved, null, 2)}`);
|
|
296
|
-
}
|
|
297
|
-
return resolved;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// src/config/world/parseWorldConfig.ts
|
|
301
|
-
var zSystemName = zObjectName;
|
|
302
|
-
var zModuleName = zObjectName;
|
|
303
|
-
var zSystemAccessList = z4.array(zSystemName.or(zEthereumAddress)).default([]);
|
|
304
|
-
var zSystemConfig = z4.intersection(
|
|
305
|
-
z4.object({
|
|
306
|
-
fileSelector: zSelector,
|
|
307
|
-
registerFunctionSelectors: z4.boolean().default(true)
|
|
308
|
-
}),
|
|
309
|
-
z4.discriminatedUnion("openAccess", [
|
|
310
|
-
z4.object({
|
|
311
|
-
openAccess: z4.literal(true)
|
|
312
|
-
}),
|
|
313
|
-
z4.object({
|
|
314
|
-
openAccess: z4.literal(false),
|
|
315
|
-
accessList: zSystemAccessList
|
|
316
|
-
})
|
|
317
|
-
])
|
|
318
|
-
);
|
|
319
|
-
var zValueWithType = z4.object({
|
|
320
|
-
value: z4.union([z4.string(), z4.number(), z4.instanceof(Uint8Array)]),
|
|
321
|
-
type: z4.string()
|
|
322
|
-
});
|
|
323
|
-
var zDynamicResolution = z4.object({ type: z4.nativeEnum(DynamicResolutionType), input: z4.string() });
|
|
324
|
-
var zModuleConfig = z4.object({
|
|
325
|
-
name: zModuleName,
|
|
326
|
-
root: z4.boolean().default(false),
|
|
327
|
-
args: z4.array(z4.union([zValueWithType, zDynamicResolution])).default([])
|
|
328
|
-
});
|
|
329
|
-
var zWorldConfig = z4.object({
|
|
330
|
-
namespace: zSelector.default(""),
|
|
331
|
-
worldContractName: z4.string().optional(),
|
|
332
|
-
worldInterfaceName: z4.string().default("IWorld"),
|
|
333
|
-
overrideSystems: z4.record(zSystemName, zSystemConfig).default({}),
|
|
334
|
-
excludeSystems: z4.array(zSystemName).default([]),
|
|
335
|
-
postDeployScript: z4.string().default("PostDeploy"),
|
|
336
|
-
deploysDirectory: z4.string().default("./deploys"),
|
|
337
|
-
worldgenDirectory: z4.string().default("world"),
|
|
338
|
-
worldImportPath: z4.string().default("@latticexyz/world/src/"),
|
|
339
|
-
modules: z4.array(zModuleConfig).default([])
|
|
340
|
-
});
|
|
341
|
-
async function parseWorldConfig(config) {
|
|
342
|
-
return zWorldConfig.parse(config);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// src/config/world/resolveWorldConfig.ts
|
|
346
|
-
function resolveWorldConfig(config, existingContracts) {
|
|
347
|
-
const defaultSystemNames = existingContracts?.filter((name) => name.endsWith("System") && name !== "System" && !name.match(/^I[A-Z]/)) ?? [];
|
|
348
|
-
const overriddenSystemNames = Object.keys(config.overrideSystems);
|
|
349
|
-
if (existingContracts) {
|
|
350
|
-
for (const systemName of overriddenSystemNames) {
|
|
351
|
-
if (!existingContracts.includes(systemName) || systemName === "World") {
|
|
352
|
-
throw UnrecognizedSystemErrorFactory(["overrideSystems", systemName], systemName);
|
|
353
|
-
}
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
const systemNames = [.../* @__PURE__ */ new Set([...defaultSystemNames, ...overriddenSystemNames])].filter(
|
|
357
|
-
(name) => !config.excludeSystems.includes(name)
|
|
358
|
-
);
|
|
359
|
-
const resolvedSystems = systemNames.reduce((acc, systemName) => {
|
|
360
|
-
return {
|
|
361
|
-
...acc,
|
|
362
|
-
[systemName]: resolveSystemConfig(systemName, config.overrideSystems[systemName], existingContracts)
|
|
363
|
-
};
|
|
364
|
-
}, {});
|
|
365
|
-
const { overrideSystems, excludeSystems, ...otherConfig } = config;
|
|
366
|
-
return { ...otherConfig, systems: resolvedSystems };
|
|
367
|
-
}
|
|
368
|
-
function resolveSystemConfig(systemName, config, existingContracts) {
|
|
369
|
-
const fileSelector = config?.fileSelector ?? systemName;
|
|
370
|
-
const registerFunctionSelectors = config?.registerFunctionSelectors ?? true;
|
|
371
|
-
const openAccess = config?.openAccess ?? true;
|
|
372
|
-
const accessListAddresses = [];
|
|
373
|
-
const accessListSystems = [];
|
|
374
|
-
const accessList = config && !config.openAccess ? config.accessList : [];
|
|
375
|
-
for (const accessListItem of accessList) {
|
|
376
|
-
if (accessListItem.startsWith("0x")) {
|
|
377
|
-
accessListAddresses.push(accessListItem);
|
|
378
|
-
} else {
|
|
379
|
-
if (existingContracts && !existingContracts.includes(accessListItem)) {
|
|
380
|
-
throw UnrecognizedSystemErrorFactory(["overrideSystems", systemName, "accessList"], accessListItem);
|
|
381
|
-
}
|
|
382
|
-
accessListSystems.push(accessListItem);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return { fileSelector, registerFunctionSelectors, openAccess, accessListAddresses, accessListSystems };
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
// src/config/world/loadWorldConfig.ts
|
|
389
|
-
async function loadWorldConfig(configPath, existingContracts) {
|
|
390
|
-
const config = await loadConfig(configPath);
|
|
391
|
-
try {
|
|
392
|
-
const parsedConfig = zWorldConfig.parse(config);
|
|
393
|
-
return resolveWorldConfig(parsedConfig, existingContracts);
|
|
394
|
-
} catch (error) {
|
|
395
|
-
if (error instanceof ZodError3) {
|
|
396
|
-
throw fromZodErrorCustom(error, "WorldConfig Validation Error");
|
|
397
|
-
} else {
|
|
398
|
-
throw error;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
// src/config/index.ts
|
|
404
|
-
function mudConfig(config) {
|
|
405
|
-
return config;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
export {
|
|
409
|
-
fromZodErrorCustom,
|
|
410
|
-
NotInsideProjectError,
|
|
411
|
-
MUDError,
|
|
412
|
-
UnrecognizedSystemErrorFactory,
|
|
413
|
-
logError,
|
|
414
|
-
loadConfig,
|
|
415
|
-
zObjectName,
|
|
416
|
-
zValueName,
|
|
417
|
-
zAnyCaseName,
|
|
418
|
-
zUserEnum,
|
|
419
|
-
zOrdinaryRoute,
|
|
420
|
-
zSingleLevelRoute,
|
|
421
|
-
zBaseRoute,
|
|
422
|
-
zEthereumAddress,
|
|
423
|
-
zSelector,
|
|
424
|
-
zSchemaConfig,
|
|
425
|
-
zTableConfig,
|
|
426
|
-
zTablesConfig,
|
|
427
|
-
zEnumsConfig,
|
|
428
|
-
storeConfig,
|
|
429
|
-
zStoreConfig,
|
|
430
|
-
parseStoreConfig,
|
|
431
|
-
loadStoreConfig,
|
|
432
|
-
DynamicResolutionType,
|
|
433
|
-
resolveTableId,
|
|
434
|
-
isDynamicResolution,
|
|
435
|
-
resolveWithContext,
|
|
436
|
-
zWorldConfig,
|
|
437
|
-
parseWorldConfig,
|
|
438
|
-
resolveWorldConfig,
|
|
439
|
-
resolveSystemConfig,
|
|
440
|
-
loadWorldConfig,
|
|
441
|
-
mudConfig
|
|
442
|
-
};
|