@latticexyz/cli 2.0.0-alpha.75 → 2.0.0-alpha.78
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-MIGVHECZ.js → chunk-DO7OWTMM.js} +31 -6
- package/dist/{chunk-S7JI7355.js → chunk-MN3HYFJK.js} +2 -1
- package/dist/{chunk-2L44HXDV.js → chunk-TLEAEDUA.js} +47 -45
- package/dist/{chunk-QGY6YXME.js → chunk-XUNWAEP7.js} +4380 -4188
- package/dist/config/index.d.ts +3 -2
- package/dist/config/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mud.js +4 -4
- package/dist/mud2.js +4 -4
- package/dist/{parseStoreConfig-05533795.d.ts → parseStoreConfig-8aa69ac9.d.ts} +8 -0
- package/dist/render-solidity/index.d.ts +1 -1
- package/dist/render-solidity/index.js +1 -1
- package/dist/render-ts/index.d.ts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -2
- package/package.json +7 -7
- package/src/commands/tablegen.ts +4 -4
- package/src/commands/worldgen.ts +4 -2
- package/src/config/parseStoreConfig.ts +3 -0
- package/src/render-solidity/renderTableIndex.ts +15 -0
- package/src/render-solidity/tablegen.ts +12 -0
|
@@ -703,18 +703,43 @@ function renderTypesFromConfig(config) {
|
|
|
703
703
|
|
|
704
704
|
// src/render-solidity/tablegen.ts
|
|
705
705
|
import path3 from "path";
|
|
706
|
+
|
|
707
|
+
// src/render-solidity/renderTableIndex.ts
|
|
708
|
+
function renderTableIndex(options) {
|
|
709
|
+
return `${renderedSolidityHeader}
|
|
710
|
+
|
|
711
|
+
${renderList(options, ({ outputPath, tableName, renderOptions: { structName, staticResourceData } }) => {
|
|
712
|
+
const imports = [tableName];
|
|
713
|
+
if (structName)
|
|
714
|
+
imports.push(structName);
|
|
715
|
+
if (staticResourceData)
|
|
716
|
+
imports.push(`${tableName}TableId`);
|
|
717
|
+
return `import { ${imports.join(", ")} } from "./${outputPath}";`;
|
|
718
|
+
})}
|
|
719
|
+
`;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
// src/render-solidity/tablegen.ts
|
|
723
|
+
import { rmSync } from "fs";
|
|
706
724
|
async function tablegen(config, outputBaseDirectory) {
|
|
707
725
|
const allTableOptions = getTableOptions(config);
|
|
726
|
+
const uniqueTableDirectories = new Set(allTableOptions.map(({ outputPath }) => path3.dirname(outputPath)));
|
|
727
|
+
for (const tableDir of uniqueTableDirectories) {
|
|
728
|
+
rmSync(path3.join(outputBaseDirectory, tableDir), { recursive: true, force: true });
|
|
729
|
+
}
|
|
708
730
|
for (const { outputPath, renderOptions } of allTableOptions) {
|
|
709
|
-
const
|
|
710
|
-
const
|
|
711
|
-
formatAndWriteSolidity(
|
|
731
|
+
const fullOutputPath2 = path3.join(outputBaseDirectory, outputPath);
|
|
732
|
+
const output2 = renderTable(renderOptions);
|
|
733
|
+
formatAndWriteSolidity(output2, fullOutputPath2, "Generated table");
|
|
712
734
|
}
|
|
713
735
|
if (Object.keys(config.enums).length > 0) {
|
|
714
|
-
const
|
|
715
|
-
const
|
|
716
|
-
formatAndWriteSolidity(
|
|
736
|
+
const fullOutputPath2 = path3.join(outputBaseDirectory, `${config.userTypesPath}.sol`);
|
|
737
|
+
const output2 = renderTypesFromConfig(config);
|
|
738
|
+
formatAndWriteSolidity(output2, fullOutputPath2, "Generated types file");
|
|
717
739
|
}
|
|
740
|
+
const fullOutputPath = path3.join(outputBaseDirectory, `Tables.sol`);
|
|
741
|
+
const output = renderTableIndex(allTableOptions);
|
|
742
|
+
formatAndWriteSolidity(output, fullOutputPath, "Generated table index");
|
|
718
743
|
}
|
|
719
744
|
|
|
720
745
|
export {
|
|
@@ -172,7 +172,8 @@ var StoreConfigUnrefined = z3.object({
|
|
|
172
172
|
namespace: zSelector.default(""),
|
|
173
173
|
storeImportPath: z3.string().default("@latticexyz/store/src/"),
|
|
174
174
|
tables: zTablesConfig,
|
|
175
|
-
userTypesPath: z3.string().default("Types")
|
|
175
|
+
userTypesPath: z3.string().default("Types"),
|
|
176
|
+
codegenDirectory: z3.string().default("codegen")
|
|
176
177
|
}).merge(zEnumsConfig);
|
|
177
178
|
var zStoreConfig = StoreConfigUnrefined.superRefine(validateStoreConfig);
|
|
178
179
|
function parseStoreConfig(config) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
deploy
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-XUNWAEP7.js";
|
|
4
4
|
import {
|
|
5
5
|
MUDError,
|
|
6
6
|
loadStoreConfig,
|
|
7
7
|
loadWorldConfig,
|
|
8
8
|
logError
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-MN3HYFJK.js";
|
|
10
10
|
import {
|
|
11
11
|
execLog
|
|
12
12
|
} from "./chunk-FFY7VTYB.js";
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
renderList,
|
|
23
23
|
renderedSolidityHeader,
|
|
24
24
|
tablegen
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-DO7OWTMM.js";
|
|
26
26
|
import {
|
|
27
27
|
tsgen
|
|
28
28
|
} from "./chunk-TPZUS44H.js";
|
|
@@ -2956,9 +2956,9 @@ var commandModule3 = {
|
|
|
2956
2956
|
compare: { type: "string", desc: "Compare to an existing gas report" }
|
|
2957
2957
|
});
|
|
2958
2958
|
},
|
|
2959
|
-
async handler({ path:
|
|
2959
|
+
async handler({ path: path7, save, compare: compare2 }) {
|
|
2960
2960
|
let gasReport = [];
|
|
2961
|
-
for (const file of
|
|
2961
|
+
for (const file of path7) {
|
|
2962
2962
|
gasReport = gasReport.concat(await runGasReport(file));
|
|
2963
2963
|
}
|
|
2964
2964
|
const compareGasReport = [];
|
|
@@ -2990,14 +2990,14 @@ var commandModule3 = {
|
|
|
2990
2990
|
}
|
|
2991
2991
|
};
|
|
2992
2992
|
var gas_report_default = commandModule3;
|
|
2993
|
-
async function runGasReport(
|
|
2994
|
-
if (!
|
|
2995
|
-
console.log("Skipping gas report for", chalk2.bold(
|
|
2993
|
+
async function runGasReport(path7) {
|
|
2994
|
+
if (!path7.endsWith(".t.sol")) {
|
|
2995
|
+
console.log("Skipping gas report for", chalk2.bold(path7), "(not a test file)");
|
|
2996
2996
|
return [];
|
|
2997
2997
|
}
|
|
2998
|
-
console.log("Running gas report for", chalk2.bold(
|
|
2998
|
+
console.log("Running gas report for", chalk2.bold(path7));
|
|
2999
2999
|
const gasReport = [];
|
|
3000
|
-
const fileContents = readFileSync(
|
|
3000
|
+
const fileContents = readFileSync(path7, "utf8");
|
|
3001
3001
|
let newFile = fileContents;
|
|
3002
3002
|
const functionRegex = new RegExp(/function (.*){/g);
|
|
3003
3003
|
let functionMatch;
|
|
@@ -3021,7 +3021,7 @@ console.log("GAS REPORT: ${name} [${functionCall.replaceAll('"', '\\"')}]:", _ga
|
|
|
3021
3021
|
);
|
|
3022
3022
|
}
|
|
3023
3023
|
newFile = newFile.replace(/pure/g, "view");
|
|
3024
|
-
const tempFileName =
|
|
3024
|
+
const tempFileName = path7.replace(/\.t\.sol$/, "MudGasReport.t.sol");
|
|
3025
3025
|
writeFileSync(tempFileName, newFile);
|
|
3026
3026
|
const child = execa("forge", ["test", "--match-path", tempFileName, "-vvv"], {
|
|
3027
3027
|
stdio: ["inherit", "pipe", "inherit"]
|
|
@@ -3042,7 +3042,7 @@ console.log("GAS REPORT: ${name} [${functionCall.replaceAll('"', '\\"')}]:", _ga
|
|
|
3042
3042
|
const name = gasReportMatch[1];
|
|
3043
3043
|
const functionCall = gasReportMatch[2].replace(";", "");
|
|
3044
3044
|
const gasUsed = gasReportMatch[3];
|
|
3045
|
-
gasReport.push({ source:
|
|
3045
|
+
gasReport.push({ source: path7, name, functionCall, gasUsed: parseInt(gasUsed) });
|
|
3046
3046
|
}
|
|
3047
3047
|
return gasReport;
|
|
3048
3048
|
}
|
|
@@ -3066,10 +3066,10 @@ function printGasReport(gasReport, compare2) {
|
|
|
3066
3066
|
const rows = [headers, ...values];
|
|
3067
3067
|
console.log(table(rows, { border: getBorderCharacters("norc") }));
|
|
3068
3068
|
}
|
|
3069
|
-
function saveGasReport(gasReport,
|
|
3070
|
-
console.log(chalk2.bold(`Saving gas report to ${
|
|
3069
|
+
function saveGasReport(gasReport, path7) {
|
|
3070
|
+
console.log(chalk2.bold(`Saving gas report to ${path7}`));
|
|
3071
3071
|
const serializedGasReport = gasReport.map((entry) => `(${entry.source}) | ${entry.name} [${entry.functionCall}]: ${entry.gasUsed}`).join("\n");
|
|
3072
|
-
writeFileSync(
|
|
3072
|
+
writeFileSync(path7, serializedGasReport);
|
|
3073
3073
|
}
|
|
3074
3074
|
|
|
3075
3075
|
// src/commands/hello.ts
|
|
@@ -3090,6 +3090,7 @@ var commandModule4 = {
|
|
|
3090
3090
|
var hello_default = commandModule4;
|
|
3091
3091
|
|
|
3092
3092
|
// src/commands/tablegen.ts
|
|
3093
|
+
import path2 from "path";
|
|
3093
3094
|
var commandModule5 = {
|
|
3094
3095
|
command: "tablegen",
|
|
3095
3096
|
describe: "Autogenerate MUD Store table libraries based on the config file",
|
|
@@ -3099,9 +3100,9 @@ var commandModule5 = {
|
|
|
3099
3100
|
});
|
|
3100
3101
|
},
|
|
3101
3102
|
async handler({ configPath }) {
|
|
3102
|
-
const srcDirectory = await getSrcDirectory();
|
|
3103
3103
|
const config = await loadStoreConfig(configPath);
|
|
3104
|
-
await
|
|
3104
|
+
const srcDir = await getSrcDirectory();
|
|
3105
|
+
await tablegen(config, path2.join(srcDir, config.codegenDirectory));
|
|
3105
3106
|
process.exit(0);
|
|
3106
3107
|
}
|
|
3107
3108
|
};
|
|
@@ -3129,7 +3130,7 @@ var tsgen_default = commandModule6;
|
|
|
3129
3130
|
// src/commands/deploy-v2.ts
|
|
3130
3131
|
import chalk3 from "chalk";
|
|
3131
3132
|
import glob from "glob";
|
|
3132
|
-
import
|
|
3133
|
+
import path3, { basename } from "path";
|
|
3133
3134
|
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
3134
3135
|
|
|
3135
3136
|
// src/utils/getChainId.ts
|
|
@@ -3172,7 +3173,7 @@ async function deployHandler(args) {
|
|
|
3172
3173
|
await forge(["clean"], { profile });
|
|
3173
3174
|
await forge(["build"], { profile });
|
|
3174
3175
|
const srcDir = await getSrcDirectory();
|
|
3175
|
-
const existingContracts = glob.sync(`${srcDir}/**/*.sol`).map((
|
|
3176
|
+
const existingContracts = glob.sync(`${srcDir}/**/*.sol`).map((path7) => basename(path7, ".sol"));
|
|
3176
3177
|
const worldConfig = await loadWorldConfig(configPath, existingContracts);
|
|
3177
3178
|
const storeConfig = await loadStoreConfig(configPath);
|
|
3178
3179
|
const mudConfig = { ...worldConfig, ...storeConfig };
|
|
@@ -3185,10 +3186,10 @@ async function deployHandler(args) {
|
|
|
3185
3186
|
const deploymentInfo = await deploy(mudConfig, { ...args, rpc, privateKey });
|
|
3186
3187
|
if (args.saveDeployment) {
|
|
3187
3188
|
const chainId = await getChainId(rpc);
|
|
3188
|
-
const outputDir =
|
|
3189
|
+
const outputDir = path3.join(mudConfig.deploysDirectory, chainId.toString());
|
|
3189
3190
|
mkdirSync(outputDir, { recursive: true });
|
|
3190
|
-
writeFileSync2(
|
|
3191
|
-
writeFileSync2(
|
|
3191
|
+
writeFileSync2(path3.join(outputDir, "latest.json"), JSON.stringify(deploymentInfo, null, 2));
|
|
3192
|
+
writeFileSync2(path3.join(outputDir, Date.now() + ".json"), JSON.stringify(deploymentInfo, null, 2));
|
|
3192
3193
|
console.log(chalk3.bgGreen(chalk3.whiteBright(`
|
|
3193
3194
|
Deployment result (written to ${outputDir}):
|
|
3194
3195
|
`)));
|
|
@@ -3215,11 +3216,11 @@ var deploy_v2_default = commandModule7;
|
|
|
3215
3216
|
|
|
3216
3217
|
// src/commands/worldgen.ts
|
|
3217
3218
|
import glob2 from "glob";
|
|
3218
|
-
import
|
|
3219
|
+
import path5, { basename as basename2 } from "path";
|
|
3219
3220
|
|
|
3220
3221
|
// src/render-solidity/worldgen.ts
|
|
3221
3222
|
import { readFileSync as readFileSync2 } from "fs";
|
|
3222
|
-
import
|
|
3223
|
+
import path4 from "path";
|
|
3223
3224
|
|
|
3224
3225
|
// src/utils/contractToInterface.ts
|
|
3225
3226
|
import { parse, visit } from "@solidity-parser/parser";
|
|
@@ -3375,7 +3376,7 @@ interface ${interfaceName} is ${renderArguments(["IStore", "IWorldCore", ...impo
|
|
|
3375
3376
|
|
|
3376
3377
|
// src/render-solidity/worldgen.ts
|
|
3377
3378
|
async function worldgen(config, existingContracts, outputBaseDirectory) {
|
|
3378
|
-
const worldgenBaseDirectory =
|
|
3379
|
+
const worldgenBaseDirectory = path4.join(outputBaseDirectory, config.worldgenDirectory);
|
|
3379
3380
|
const systems = existingContracts.filter(({ basename: basename3 }) => Object.keys(config.systems).includes(basename3));
|
|
3380
3381
|
const systemInterfaceImports = [];
|
|
3381
3382
|
for (const system of systems) {
|
|
@@ -3394,7 +3395,7 @@ async function worldgen(config, existingContracts, outputBaseDirectory) {
|
|
|
3394
3395
|
functions,
|
|
3395
3396
|
imports
|
|
3396
3397
|
});
|
|
3397
|
-
const fullOutputPath2 =
|
|
3398
|
+
const fullOutputPath2 = path4.join(worldgenBaseDirectory, systemInterfaceName + ".sol");
|
|
3398
3399
|
await formatAndWriteSolidity(output2, fullOutputPath2, "Generated system interface");
|
|
3399
3400
|
systemInterfaceImports.push({
|
|
3400
3401
|
symbol: systemInterfaceName,
|
|
@@ -3408,7 +3409,7 @@ async function worldgen(config, existingContracts, outputBaseDirectory) {
|
|
|
3408
3409
|
storeImportPath: config.storeImportPath,
|
|
3409
3410
|
worldImportPath: config.worldImportPath
|
|
3410
3411
|
});
|
|
3411
|
-
const fullOutputPath =
|
|
3412
|
+
const fullOutputPath = path4.join(worldgenBaseDirectory, config.worldInterfaceName + ".sol");
|
|
3412
3413
|
await formatAndWriteSolidity(output, fullOutputPath, "Generated system interface");
|
|
3413
3414
|
}
|
|
3414
3415
|
|
|
@@ -3426,9 +3427,9 @@ var commandModule8 = {
|
|
|
3426
3427
|
async handler(args) {
|
|
3427
3428
|
const { configPath, clean } = args;
|
|
3428
3429
|
const srcDir = await getSrcDirectory();
|
|
3429
|
-
const existingContracts = glob2.sync(`${srcDir}/**/*.sol`).map((
|
|
3430
|
-
path:
|
|
3431
|
-
basename: basename2(
|
|
3430
|
+
const existingContracts = glob2.sync(`${srcDir}/**/*.sol`).map((path7) => ({
|
|
3431
|
+
path: path7,
|
|
3432
|
+
basename: basename2(path7, ".sol")
|
|
3432
3433
|
}));
|
|
3433
3434
|
const worldConfig = await loadWorldConfig(
|
|
3434
3435
|
configPath,
|
|
@@ -3436,9 +3437,10 @@ var commandModule8 = {
|
|
|
3436
3437
|
);
|
|
3437
3438
|
const storeConfig = await loadStoreConfig(configPath);
|
|
3438
3439
|
const mudConfig = { ...worldConfig, ...storeConfig };
|
|
3440
|
+
const outputBaseDirectory = path5.join(srcDir, mudConfig.codegenDirectory);
|
|
3439
3441
|
if (clean)
|
|
3440
|
-
rmSync3(
|
|
3441
|
-
await worldgen(mudConfig, existingContracts,
|
|
3442
|
+
rmSync3(path5.join(outputBaseDirectory, mudConfig.worldgenDirectory), { recursive: true, force: true });
|
|
3443
|
+
await worldgen(mudConfig, existingContracts, outputBaseDirectory);
|
|
3442
3444
|
process.exit(0);
|
|
3443
3445
|
}
|
|
3444
3446
|
};
|
|
@@ -3447,12 +3449,12 @@ var worldgen_default = commandModule8;
|
|
|
3447
3449
|
// src/commands/set-version.ts
|
|
3448
3450
|
import chalk4 from "chalk";
|
|
3449
3451
|
import { existsSync, readFileSync as readFileSync3, rmSync as rmSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
3450
|
-
import
|
|
3452
|
+
import path6 from "path";
|
|
3451
3453
|
|
|
3452
3454
|
// package.json
|
|
3453
3455
|
var package_default = {
|
|
3454
3456
|
name: "@latticexyz/cli",
|
|
3455
|
-
version: "2.0.0-alpha.
|
|
3457
|
+
version: "2.0.0-alpha.78+cf5f4bfe",
|
|
3456
3458
|
description: "Command line interface for mud",
|
|
3457
3459
|
main: "dist/index.js",
|
|
3458
3460
|
types: "dist/index.d.ts",
|
|
@@ -3479,7 +3481,7 @@ var package_default = {
|
|
|
3479
3481
|
release: "npm publish --access=public"
|
|
3480
3482
|
},
|
|
3481
3483
|
devDependencies: {
|
|
3482
|
-
"@latticexyz/store": "^2.0.0-alpha.
|
|
3484
|
+
"@latticexyz/store": "^2.0.0-alpha.78+cf5f4bfe",
|
|
3483
3485
|
"@types/ejs": "^3.1.1",
|
|
3484
3486
|
"@types/glob": "^7.2.0",
|
|
3485
3487
|
"@types/node": "^17.0.34",
|
|
@@ -3492,10 +3494,10 @@ var package_default = {
|
|
|
3492
3494
|
dependencies: {
|
|
3493
3495
|
"@improbable-eng/grpc-web": "^0.15.0",
|
|
3494
3496
|
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
|
|
3495
|
-
"@latticexyz/schema-type": "^2.0.0-alpha.
|
|
3496
|
-
"@latticexyz/services": "^2.0.0-alpha.
|
|
3497
|
-
"@latticexyz/solecs": "^2.0.0-alpha.
|
|
3498
|
-
"@latticexyz/std-contracts": "^2.0.0-alpha.
|
|
3497
|
+
"@latticexyz/schema-type": "^2.0.0-alpha.78+cf5f4bfe",
|
|
3498
|
+
"@latticexyz/services": "^2.0.0-alpha.78+cf5f4bfe",
|
|
3499
|
+
"@latticexyz/solecs": "^2.0.0-alpha.78+cf5f4bfe",
|
|
3500
|
+
"@latticexyz/std-contracts": "^2.0.0-alpha.78+cf5f4bfe",
|
|
3499
3501
|
"@solidity-parser/parser": "^0.16.0",
|
|
3500
3502
|
"@typechain/ethers-v5": "^10.1.1",
|
|
3501
3503
|
chalk: "^5.0.1",
|
|
@@ -3522,7 +3524,7 @@ var package_default = {
|
|
|
3522
3524
|
zod: "^3.21.4",
|
|
3523
3525
|
"zod-validation-error": "^1.0.1"
|
|
3524
3526
|
},
|
|
3525
|
-
gitHead: "
|
|
3527
|
+
gitHead: "cf5f4bfe0d1d14e70efbf10ebef47d39f39e7239"
|
|
3526
3528
|
};
|
|
3527
3529
|
|
|
3528
3530
|
// src/commands/set-version.ts
|
|
@@ -3552,7 +3554,7 @@ var commandModule9 = {
|
|
|
3552
3554
|
const { workspaces } = updatePackageJson(rootPath, options);
|
|
3553
3555
|
if (workspaces) {
|
|
3554
3556
|
for (const workspace of workspaces) {
|
|
3555
|
-
const filePath =
|
|
3557
|
+
const filePath = path6.join(workspace, "/package.json");
|
|
3556
3558
|
updatePackageJson(filePath, options);
|
|
3557
3559
|
}
|
|
3558
3560
|
}
|
|
@@ -3565,7 +3567,7 @@ var commandModule9 = {
|
|
|
3565
3567
|
};
|
|
3566
3568
|
function updatePackageJson(filePath, options) {
|
|
3567
3569
|
const { backup, restore, force, mudVersion } = options;
|
|
3568
|
-
const backupFilePath =
|
|
3570
|
+
const backupFilePath = path6.join(path6.dirname(filePath), BACKUP_FILE);
|
|
3569
3571
|
if (backup && !force && existsSync(backupFilePath)) {
|
|
3570
3572
|
throw new MUDError(
|
|
3571
3573
|
`A backup file already exists at ${backupFilePath}.
|
|
@@ -3613,12 +3615,12 @@ Use --force to overwrite it or --restore to restore it.`
|
|
|
3613
3615
|
}
|
|
3614
3616
|
return packageJson;
|
|
3615
3617
|
}
|
|
3616
|
-
function readPackageJson(
|
|
3618
|
+
function readPackageJson(path7) {
|
|
3617
3619
|
try {
|
|
3618
|
-
const jsonString = readFileSync3(
|
|
3620
|
+
const jsonString = readFileSync3(path7, "utf8");
|
|
3619
3621
|
return JSON.parse(jsonString);
|
|
3620
3622
|
} catch {
|
|
3621
|
-
throw new MUDError("Could not read JSON at " +
|
|
3623
|
+
throw new MUDError("Could not read JSON at " + path7);
|
|
3622
3624
|
}
|
|
3623
3625
|
}
|
|
3624
3626
|
async function getCanaryVersion(pkg) {
|