@latticexyz/cli 2.0.0-alpha.83 → 2.0.0-alpha.84
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-O6HOO6WA.js → chunk-L4YLJHLJ.js} +1 -9
- package/dist/{chunk-2MNNE4PM.js → chunk-NVMLRISU.js} +14 -11
- package/dist/chunk-VQTZJIFF.js +353 -0
- package/dist/mud.js +4 -4
- package/dist/mud2.js +3 -3
- package/dist/render-solidity/index.js +1 -1
- package/dist/render-ts/index.js +1 -1
- package/dist/utils/deprecated/index.js +2 -2
- package/dist/utils/index.js +1 -1
- package/package.json +12 -9
- package/dist/chunk-FFY7VTYB.js +0 -14358
|
@@ -4,14 +4,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined")
|
|
11
|
-
return require.apply(this, arguments);
|
|
12
|
-
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
});
|
|
14
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
7
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
15
8
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
9
|
};
|
|
17
10
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -32,7 +25,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
32
25
|
));
|
|
33
26
|
|
|
34
27
|
export {
|
|
35
|
-
__require,
|
|
36
28
|
__commonJS,
|
|
37
29
|
__toESM
|
|
38
30
|
};
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-WBESAYJO.js";
|
|
5
5
|
import {
|
|
6
6
|
execLog
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VQTZJIFF.js";
|
|
8
8
|
import {
|
|
9
9
|
anvil,
|
|
10
10
|
forge,
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
import {
|
|
28
28
|
__commonJS,
|
|
29
29
|
__toESM
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-L4YLJHLJ.js";
|
|
31
31
|
|
|
32
32
|
// ../../node_modules/@protobufjs/aspromise/index.js
|
|
33
33
|
var require_aspromise = __commonJS({
|
|
@@ -3563,7 +3563,7 @@ import { MUDError as MUDError3 } from "@latticexyz/config";
|
|
|
3563
3563
|
// package.json
|
|
3564
3564
|
var package_default = {
|
|
3565
3565
|
name: "@latticexyz/cli",
|
|
3566
|
-
version: "2.0.0-alpha.
|
|
3566
|
+
version: "2.0.0-alpha.84+089ff2ac",
|
|
3567
3567
|
description: "Command line interface for mud",
|
|
3568
3568
|
main: "dist/index.js",
|
|
3569
3569
|
types: "dist/index.d.ts",
|
|
@@ -3590,7 +3590,6 @@ var package_default = {
|
|
|
3590
3590
|
release: "npm publish --access=public"
|
|
3591
3591
|
},
|
|
3592
3592
|
devDependencies: {
|
|
3593
|
-
"@latticexyz/store": "^2.0.0-alpha.83+bea12cac",
|
|
3594
3593
|
"@types/ejs": "^3.1.1",
|
|
3595
3594
|
"@types/glob": "^7.2.0",
|
|
3596
3595
|
"@types/node": "^17.0.34",
|
|
@@ -3601,15 +3600,19 @@ var package_default = {
|
|
|
3601
3600
|
vitest: "^0.29.8"
|
|
3602
3601
|
},
|
|
3603
3602
|
dependencies: {
|
|
3603
|
+
"@ethersproject/abi": "^5.7.0",
|
|
3604
|
+
"@ethersproject/providers": "^5.7.2",
|
|
3604
3605
|
"@improbable-eng/grpc-web": "^0.15.0",
|
|
3605
3606
|
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
|
|
3606
|
-
"@latticexyz/config": "^2.0.0-alpha.
|
|
3607
|
-
"@latticexyz/schema-type": "^2.0.0-alpha.
|
|
3608
|
-
"@latticexyz/services": "^2.0.0-alpha.
|
|
3609
|
-
"@latticexyz/solecs": "^2.0.0-alpha.
|
|
3610
|
-
"@latticexyz/std-contracts": "^2.0.0-alpha.
|
|
3607
|
+
"@latticexyz/config": "^2.0.0-alpha.84+089ff2ac",
|
|
3608
|
+
"@latticexyz/schema-type": "^2.0.0-alpha.84+089ff2ac",
|
|
3609
|
+
"@latticexyz/services": "^2.0.0-alpha.84+089ff2ac",
|
|
3610
|
+
"@latticexyz/solecs": "^2.0.0-alpha.84+089ff2ac",
|
|
3611
|
+
"@latticexyz/std-contracts": "^2.0.0-alpha.84+089ff2ac",
|
|
3612
|
+
"@latticexyz/store": "^2.0.0-alpha.84+089ff2ac",
|
|
3613
|
+
"@latticexyz/world": "^2.0.0-alpha.84+089ff2ac",
|
|
3611
3614
|
"@solidity-parser/parser": "^0.16.0",
|
|
3612
|
-
"@typechain/ethers-v5": "^10.
|
|
3615
|
+
"@typechain/ethers-v5": "^10.2.0",
|
|
3613
3616
|
chalk: "^5.0.1",
|
|
3614
3617
|
chokidar: "^3.5.3",
|
|
3615
3618
|
dotenv: "^16.0.3",
|
|
@@ -3631,7 +3634,7 @@ var package_default = {
|
|
|
3631
3634
|
zod: "^3.21.4",
|
|
3632
3635
|
"zod-validation-error": "^1.3.0"
|
|
3633
3636
|
},
|
|
3634
|
-
gitHead: "
|
|
3637
|
+
gitHead: "089ff2ac7168d1bc5568b3b78cc73e14cd8ac95f"
|
|
3635
3638
|
};
|
|
3636
3639
|
|
|
3637
3640
|
// src/commands/set-version.ts
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getOutDirectory,
|
|
3
|
+
getSrcDirectory
|
|
4
|
+
} from "./chunk-FPG73MVN.js";
|
|
5
|
+
|
|
6
|
+
// src/utils/deprecated/exec.ts
|
|
7
|
+
import { execa } from "execa";
|
|
8
|
+
function execLog(command, options) {
|
|
9
|
+
console.log("Cmd:");
|
|
10
|
+
console.log([command, ...options].join(" "));
|
|
11
|
+
return execa(command, options, {
|
|
12
|
+
stdio: ["inherit", "inherit", "inherit"]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// src/utils/deprecated/ids.ts
|
|
17
|
+
import { keccak256 as keccak256Bytes, toUtf8Bytes } from "ethers/lib/utils.js";
|
|
18
|
+
import { readFileSync } from "fs";
|
|
19
|
+
var IDregex = new RegExp(/(?<=uint256 constant ID = uint256\(keccak256\(")(.*)(?="\))/);
|
|
20
|
+
function extractIdFromFile(path5) {
|
|
21
|
+
const content = readFileSync(path5).toString();
|
|
22
|
+
const regexResult = IDregex.exec(content);
|
|
23
|
+
return regexResult && regexResult[0];
|
|
24
|
+
}
|
|
25
|
+
function keccak256(data) {
|
|
26
|
+
return keccak256Bytes(toUtf8Bytes(data));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/utils/deprecated/codegen.ts
|
|
30
|
+
import { readFile, writeFile } from "fs/promises";
|
|
31
|
+
import ejs from "ejs";
|
|
32
|
+
import path from "path";
|
|
33
|
+
var contractsDirectory = new URL("../src/contracts", import.meta.url).pathname;
|
|
34
|
+
var stubLibDeploy = readFile(path.join(contractsDirectory, "LibDeployStub.sol"));
|
|
35
|
+
async function generateLibDeploy(configPath, out, systems) {
|
|
36
|
+
const config = JSON.parse(await readFile(configPath, { encoding: "utf8" }));
|
|
37
|
+
config.initializers ??= [];
|
|
38
|
+
if (systems) {
|
|
39
|
+
const systemsArray = Array.isArray(systems) ? systems : [systems];
|
|
40
|
+
config.systems = config.systems.filter((system) => systemsArray.includes(system.name));
|
|
41
|
+
}
|
|
42
|
+
console.log(`Deploy config:
|
|
43
|
+
`, JSON.stringify(config, null, 2));
|
|
44
|
+
console.log("Generating deployment script");
|
|
45
|
+
const LibDeploy = await ejs.renderFile(path.join(contractsDirectory, "LibDeploy.ejs"), config, { async: true });
|
|
46
|
+
const libDeployPath = path.join(out, "LibDeploy.sol");
|
|
47
|
+
await writeFile(libDeployPath, LibDeploy);
|
|
48
|
+
return libDeployPath;
|
|
49
|
+
}
|
|
50
|
+
async function resetLibDeploy(out) {
|
|
51
|
+
await writeFile(path.join(out, "LibDeploy.sol"), await stubLibDeploy);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/utils/deprecated/deploy.ts
|
|
55
|
+
import { constants, Wallet } from "ethers";
|
|
56
|
+
|
|
57
|
+
// src/utils/deprecated/findLog.ts
|
|
58
|
+
function findLog(deployLogLines, log) {
|
|
59
|
+
for (const logLine of deployLogLines) {
|
|
60
|
+
if (logLine.includes(log)) {
|
|
61
|
+
return logLine.split(log)[1].trim();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
throw new Error("Can not find log");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/utils/deprecated/typegen.ts
|
|
68
|
+
import { runTypeChain, glob as typechainGlob } from "typechain";
|
|
69
|
+
import glob from "glob";
|
|
70
|
+
import { rmSync as rmSync2, writeFileSync } from "fs";
|
|
71
|
+
import path3 from "path";
|
|
72
|
+
|
|
73
|
+
// src/utils/deprecated/build.ts
|
|
74
|
+
import { execa as execa2 } from "execa";
|
|
75
|
+
import { copyFileSync, mkdirSync, readdirSync, rmSync } from "fs";
|
|
76
|
+
import path2 from "path";
|
|
77
|
+
async function forgeBuild(options) {
|
|
78
|
+
if (options?.clear) {
|
|
79
|
+
const out = await getOutDirectory();
|
|
80
|
+
console.log("Clearing forge build output directory", out);
|
|
81
|
+
rmSync(out, { recursive: true, force: true });
|
|
82
|
+
}
|
|
83
|
+
console.log("Running forge build");
|
|
84
|
+
const child = execa2("forge", ["build"], {
|
|
85
|
+
stdio: ["inherit", "pipe", "inherit"]
|
|
86
|
+
});
|
|
87
|
+
return (await child).stdout;
|
|
88
|
+
}
|
|
89
|
+
function getContractsInDirectory(dir, exclude) {
|
|
90
|
+
return readdirSync(dir).filter((item) => item.includes(".sol")).map((item) => item.replace(".sol", "")).filter((item) => !exclude?.includes(item));
|
|
91
|
+
}
|
|
92
|
+
function copyAbi(inDir, outDir, contract) {
|
|
93
|
+
try {
|
|
94
|
+
return copyFileSync(path2.join(inDir, contract + ".sol", contract + ".json"), path2.join(outDir, contract + ".json"));
|
|
95
|
+
} catch (e) {
|
|
96
|
+
console.log("Skipping", contract);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function filterAbi(abiIn = "./out", abiOut = "./abi", exclude = ["Component", "IComponent"]) {
|
|
100
|
+
console.log(`Cleaning output directory (${abiOut}})`);
|
|
101
|
+
rmSync(abiOut, { recursive: true, force: true });
|
|
102
|
+
mkdirSync(abiOut);
|
|
103
|
+
const include = ["Component", "System", "World", "LibQuery"];
|
|
104
|
+
const contracts = getContractsInDirectory(abiIn, exclude).filter((item) => include.find((i) => item.includes(i)));
|
|
105
|
+
console.log("Selected ABIs: ", contracts);
|
|
106
|
+
for (const contract of contracts) {
|
|
107
|
+
if (contract.includes(".t"))
|
|
108
|
+
continue;
|
|
109
|
+
copyAbi(abiIn, abiOut, contract);
|
|
110
|
+
}
|
|
111
|
+
console.log("Successfully moved selected ABIs to ./abi");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/utils/deprecated/constants.ts
|
|
115
|
+
var systemsDir = "systems";
|
|
116
|
+
var componentsDir = "components";
|
|
117
|
+
|
|
118
|
+
// src/utils/deprecated/typegen.ts
|
|
119
|
+
async function generateAbiTypes(inputDir, outputDir, options) {
|
|
120
|
+
if (options?.clear) {
|
|
121
|
+
console.log("Clearing typechain output directory", outputDir);
|
|
122
|
+
rmSync2(outputDir, { recursive: true, force: true });
|
|
123
|
+
}
|
|
124
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
125
|
+
const allFiles = typechainGlob(cwd, [`${inputDir}/**/+([a-zA-Z0-9_]).json`]);
|
|
126
|
+
const result = await runTypeChain({
|
|
127
|
+
cwd,
|
|
128
|
+
filesToProcess: allFiles,
|
|
129
|
+
allFiles,
|
|
130
|
+
outDir: outputDir,
|
|
131
|
+
target: "ethers-v5"
|
|
132
|
+
});
|
|
133
|
+
console.log(`Successfully generated ${result.filesGenerated} files`);
|
|
134
|
+
}
|
|
135
|
+
async function generateSystemTypes(outputDir, options) {
|
|
136
|
+
if (options?.clear) {
|
|
137
|
+
console.log("Clearing system type output files", outputDir);
|
|
138
|
+
rmSync2(path3.join(outputDir, "/SystemTypes.ts"), { force: true });
|
|
139
|
+
rmSync2(path3.join(outputDir, "/SystemAbis.mts"), { force: true });
|
|
140
|
+
rmSync2(path3.join(outputDir, "/SystemAbis.mjs"), { force: true });
|
|
141
|
+
rmSync2(path3.join(outputDir, "/SystemMappings.ts"), { force: true });
|
|
142
|
+
}
|
|
143
|
+
let abis = [];
|
|
144
|
+
let systems = [];
|
|
145
|
+
let ids = [];
|
|
146
|
+
let typePaths = [];
|
|
147
|
+
const srcDir = await getSrcDirectory();
|
|
148
|
+
const systemsPath = path3.join(srcDir, systemsDir, "*.sol");
|
|
149
|
+
const matches = glob.sync(systemsPath);
|
|
150
|
+
systems = matches.map((path5) => {
|
|
151
|
+
const fragments = path5.split("/");
|
|
152
|
+
return fragments[fragments.length - 1].split(".sol")[0];
|
|
153
|
+
});
|
|
154
|
+
ids = matches.map((path5, index) => {
|
|
155
|
+
const id = extractIdFromFile(path5);
|
|
156
|
+
if (!id) {
|
|
157
|
+
console.log("Path:", path5);
|
|
158
|
+
console.log("ID:", id);
|
|
159
|
+
throw new Error(
|
|
160
|
+
"No ID found for" + matches[index] + ". Make sure your system source file includes a ID definition (uint256 constant ID = uint256(keccak256(<ID>));)"
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
return id;
|
|
164
|
+
});
|
|
165
|
+
abis = systems.map((system) => `../abi/${system}.json`);
|
|
166
|
+
typePaths = systems.map((system) => `./ethers-contracts/${system}.ts`);
|
|
167
|
+
console.log("Matches", systems);
|
|
168
|
+
console.log("Solidity", ids);
|
|
169
|
+
console.log("Type paths", typePaths);
|
|
170
|
+
console.log("ABIs", abis);
|
|
171
|
+
const SystemMappings = `// Autogenerated using mud system-types
|
|
172
|
+
export const systemToId = {
|
|
173
|
+
${systems.map((system, index) => ` ${system}: "${ids[index]}",`).join("\n")}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export const idToSystem = {
|
|
177
|
+
${ids.map((id, index) => ` "${id}": "${systems[index]}",`).join("\n")}
|
|
178
|
+
};
|
|
179
|
+
`;
|
|
180
|
+
const SystemTypes = `// Autogenerated using mud system-types
|
|
181
|
+
${typePaths.map((path5, index) => `import { ${systems[index]} } from "${path5.replace(".ts", "")}";`).join("\n")}
|
|
182
|
+
|
|
183
|
+
export type SystemTypes = {
|
|
184
|
+
${systems.map((system, index) => ` "${ids[index]}": ${system};`).join("\n")}
|
|
185
|
+
};
|
|
186
|
+
`;
|
|
187
|
+
const SystemAbis = `// Autogenerated using mud system-types
|
|
188
|
+
${abis.map((path5, index) => `import ${systems[index]} from "${path5}";`).join("\n")}
|
|
189
|
+
|
|
190
|
+
export const SystemAbis = {
|
|
191
|
+
${systems.map((system, index) => ` "${ids[index]}": ${system}.abi,`).join("\n")}
|
|
192
|
+
};
|
|
193
|
+
`;
|
|
194
|
+
console.log("Generating files:");
|
|
195
|
+
console.log("SystemTypes.ts", SystemTypes);
|
|
196
|
+
console.log("SystemAbis.mts", SystemAbis);
|
|
197
|
+
console.log("SystemMappings.ts", SystemMappings);
|
|
198
|
+
writeFileSync(`${outputDir}/SystemTypes.ts`, SystemTypes);
|
|
199
|
+
writeFileSync(`${outputDir}/SystemAbis.mts`, SystemAbis);
|
|
200
|
+
writeFileSync(`${outputDir}/SystemAbis.mjs`, SystemAbis);
|
|
201
|
+
writeFileSync(`${outputDir}/SystemMappings.ts`, SystemMappings);
|
|
202
|
+
}
|
|
203
|
+
async function generateTypes(abiDir, outputDir = "./types", options) {
|
|
204
|
+
if (!abiDir) {
|
|
205
|
+
console.log("Compiling contracts");
|
|
206
|
+
const buildOutput = await getOutDirectory();
|
|
207
|
+
abiDir = "./abi";
|
|
208
|
+
await forgeBuild(options);
|
|
209
|
+
filterAbi(buildOutput, abiDir);
|
|
210
|
+
}
|
|
211
|
+
await generateAbiTypes(abiDir, path3.join(outputDir, "ethers-contracts"), options);
|
|
212
|
+
await generateSystemTypes(outputDir, options);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/utils/deprecated/deploy.ts
|
|
216
|
+
import { execa as execa3 } from "execa";
|
|
217
|
+
import { StaticJsonRpcProvider } from "@ethersproject/providers";
|
|
218
|
+
import path4 from "path";
|
|
219
|
+
var contractsDirectory2 = new URL("../src/contracts", import.meta.url).pathname;
|
|
220
|
+
async function deploy(deployerPrivateKey, rpc = "http://localhost:8545", worldAddress, reuseComponents, gasPrice) {
|
|
221
|
+
const address = deployerPrivateKey ? new Wallet(deployerPrivateKey).address : constants.AddressZero;
|
|
222
|
+
if (gasPrice == null) {
|
|
223
|
+
try {
|
|
224
|
+
console.log("Fetching gas price...");
|
|
225
|
+
const provider = new StaticJsonRpcProvider(rpc, { name: "AnyNetwork", chainId: 1234 });
|
|
226
|
+
gasPrice = (await provider.getGasPrice()).toNumber() * 1.3;
|
|
227
|
+
console.log("Gas price:", gasPrice);
|
|
228
|
+
} catch (e) {
|
|
229
|
+
console.log("Could not fetch gas price");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const child = execa3(
|
|
233
|
+
"forge",
|
|
234
|
+
[
|
|
235
|
+
"script",
|
|
236
|
+
path4.join(contractsDirectory2, "/Deploy.sol"),
|
|
237
|
+
"--target-contract",
|
|
238
|
+
"Deploy",
|
|
239
|
+
"-vvv",
|
|
240
|
+
...!deployerPrivateKey ? [] : ["--broadcast", "--private-keys", deployerPrivateKey],
|
|
241
|
+
"--sig",
|
|
242
|
+
"broadcastDeploy(address,address,bool)",
|
|
243
|
+
address,
|
|
244
|
+
// Deployer
|
|
245
|
+
worldAddress || constants.AddressZero,
|
|
246
|
+
// World address (0 = deploy a new world)
|
|
247
|
+
reuseComponents ? "true" : "false",
|
|
248
|
+
// Reuse components?
|
|
249
|
+
"--fork-url",
|
|
250
|
+
rpc,
|
|
251
|
+
...gasPrice != null ? ["--with-gas-price", String(Math.round(gasPrice))] : []
|
|
252
|
+
],
|
|
253
|
+
{ stdio: ["inherit", "pipe", "pipe"] }
|
|
254
|
+
);
|
|
255
|
+
child.stderr?.on("data", (data) => console.log("stderr:", data.toString()));
|
|
256
|
+
child.stdout?.on("data", (data) => console.log(data.toString()));
|
|
257
|
+
const lines = (await child).stdout?.split("\n");
|
|
258
|
+
const deployedWorldAddress = findLog(lines, "world: address");
|
|
259
|
+
const initialBlockNumber = findLog(lines, "initialBlockNumber: uint256");
|
|
260
|
+
return { child: await child, deployedWorldAddress, initialBlockNumber };
|
|
261
|
+
}
|
|
262
|
+
async function generateAndDeploy(args) {
|
|
263
|
+
let libDeployPath;
|
|
264
|
+
let deployedWorldAddress;
|
|
265
|
+
let initialBlockNumber;
|
|
266
|
+
try {
|
|
267
|
+
libDeployPath = await generateLibDeploy(args.config, contractsDirectory2, args.systems);
|
|
268
|
+
await generateTypes(void 0, "./types", { clear: args.clear });
|
|
269
|
+
const result = await deploy(
|
|
270
|
+
args.deployerPrivateKey,
|
|
271
|
+
args.rpc,
|
|
272
|
+
args.worldAddress,
|
|
273
|
+
Boolean(args.reuseComponents),
|
|
274
|
+
args.gasPrice
|
|
275
|
+
);
|
|
276
|
+
deployedWorldAddress = result.deployedWorldAddress;
|
|
277
|
+
initialBlockNumber = result.initialBlockNumber;
|
|
278
|
+
} finally {
|
|
279
|
+
console.log("Cleaning up deployment script");
|
|
280
|
+
if (libDeployPath)
|
|
281
|
+
await resetLibDeploy(contractsDirectory2);
|
|
282
|
+
}
|
|
283
|
+
return { deployedWorldAddress, initialBlockNumber };
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/utils/deprecated/hsr.ts
|
|
287
|
+
import chokidar from "chokidar";
|
|
288
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
289
|
+
var ImportsRegex = new RegExp(/(?<=import ").*(?=";)|(?<=from ").*(?=";)/g);
|
|
290
|
+
function extractImports(path5) {
|
|
291
|
+
const content = readFileSync2(path5).toString();
|
|
292
|
+
const regexResult = [...content.matchAll(ImportsRegex)].map((match) => match[0]).map((path6) => path6.split("/").at(-1));
|
|
293
|
+
return regexResult;
|
|
294
|
+
}
|
|
295
|
+
function findDependencies(file, dependencyGraph, visited = []) {
|
|
296
|
+
const dependencies = dependencyGraph[file] ?? [];
|
|
297
|
+
const subDependencies = dependencies.flatMap((d) => {
|
|
298
|
+
if (visited.includes(d)) {
|
|
299
|
+
console.warn("Circular dependency detected: ", d, dependencyGraph[d]);
|
|
300
|
+
return [];
|
|
301
|
+
}
|
|
302
|
+
return findDependencies(d, dependencyGraph, [...visited, d]);
|
|
303
|
+
});
|
|
304
|
+
return [.../* @__PURE__ */ new Set([...dependencies, ...subDependencies])];
|
|
305
|
+
}
|
|
306
|
+
function hsr(root, replaceSystems) {
|
|
307
|
+
const dependencyGraph = {};
|
|
308
|
+
const systems = /* @__PURE__ */ new Set();
|
|
309
|
+
console.log("Watching system file changes...");
|
|
310
|
+
chokidar.watch(root).on("all", async (event, path5) => {
|
|
311
|
+
console.log(`[${event}]: ${path5}`);
|
|
312
|
+
const changedFile = path5.split("/").at(-1);
|
|
313
|
+
if (["add", "change"].includes(event)) {
|
|
314
|
+
const imports = extractImports(path5);
|
|
315
|
+
for (const importedFile of imports) {
|
|
316
|
+
dependencyGraph[importedFile] ??= [];
|
|
317
|
+
dependencyGraph[importedFile].push(changedFile);
|
|
318
|
+
}
|
|
319
|
+
if (path5.includes("systems") && path5.includes(".sol"))
|
|
320
|
+
systems.add(changedFile);
|
|
321
|
+
}
|
|
322
|
+
if (event === "change") {
|
|
323
|
+
const dependencies = findDependencies(changedFile, dependencyGraph);
|
|
324
|
+
const changedSystems = [
|
|
325
|
+
...new Set([changedFile, ...dependencies].filter((f) => systems.has(f)).map((f) => f.replace(".sol", "")))
|
|
326
|
+
];
|
|
327
|
+
console.log("Systems to replace", changedSystems);
|
|
328
|
+
if (changedSystems.length > 0)
|
|
329
|
+
await replaceSystems(changedSystems);
|
|
330
|
+
console.log("Watching system file changes...");
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
export {
|
|
336
|
+
execLog,
|
|
337
|
+
IDregex,
|
|
338
|
+
extractIdFromFile,
|
|
339
|
+
keccak256,
|
|
340
|
+
generateLibDeploy,
|
|
341
|
+
resetLibDeploy,
|
|
342
|
+
findLog,
|
|
343
|
+
forgeBuild,
|
|
344
|
+
filterAbi,
|
|
345
|
+
systemsDir,
|
|
346
|
+
componentsDir,
|
|
347
|
+
generateAbiTypes,
|
|
348
|
+
generateSystemTypes,
|
|
349
|
+
generateTypes,
|
|
350
|
+
deploy,
|
|
351
|
+
generateAndDeploy,
|
|
352
|
+
hsr
|
|
353
|
+
};
|
package/dist/mud.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
commands
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NVMLRISU.js";
|
|
5
5
|
import {
|
|
6
6
|
logError
|
|
7
7
|
} from "./chunk-WBESAYJO.js";
|
|
8
8
|
import {
|
|
9
|
-
JsonRpcProvider,
|
|
10
9
|
componentsDir,
|
|
11
10
|
execLog,
|
|
12
11
|
extractIdFromFile,
|
|
@@ -18,7 +17,7 @@ import {
|
|
|
18
17
|
keccak256,
|
|
19
18
|
resetLibDeploy,
|
|
20
19
|
systemsDir
|
|
21
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VQTZJIFF.js";
|
|
22
21
|
import {
|
|
23
22
|
getSrcDirectory,
|
|
24
23
|
getTestDirectory
|
|
@@ -26,7 +25,7 @@ import {
|
|
|
26
25
|
import "./chunk-K25KS5QJ.js";
|
|
27
26
|
import "./chunk-SADK4UCO.js";
|
|
28
27
|
import "./chunk-SKNB74MT.js";
|
|
29
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-L4YLJHLJ.js";
|
|
30
29
|
|
|
31
30
|
// src/mud.ts
|
|
32
31
|
import yargs from "yargs";
|
|
@@ -290,6 +289,7 @@ var test_default = commandModule6;
|
|
|
290
289
|
// src/commands/deprecated/trace.ts
|
|
291
290
|
import { readFileSync } from "fs";
|
|
292
291
|
import { Contract } from "ethers";
|
|
292
|
+
import { JsonRpcProvider } from "@ethersproject/providers";
|
|
293
293
|
|
|
294
294
|
// ../solecs/abi/World.json
|
|
295
295
|
var World_default = {
|
package/dist/mud2.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
commands
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-NVMLRISU.js";
|
|
5
5
|
import {
|
|
6
6
|
logError
|
|
7
7
|
} from "./chunk-WBESAYJO.js";
|
|
8
|
-
import "./chunk-
|
|
8
|
+
import "./chunk-VQTZJIFF.js";
|
|
9
9
|
import "./chunk-FPG73MVN.js";
|
|
10
10
|
import "./chunk-K25KS5QJ.js";
|
|
11
11
|
import "./chunk-SADK4UCO.js";
|
|
12
12
|
import "./chunk-SKNB74MT.js";
|
|
13
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-L4YLJHLJ.js";
|
|
14
14
|
|
|
15
15
|
// src/mud2.ts
|
|
16
16
|
import yargs from "yargs";
|
package/dist/render-ts/index.js
CHANGED
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
hsr,
|
|
15
15
|
keccak256,
|
|
16
16
|
resetLibDeploy
|
|
17
|
-
} from "../../chunk-
|
|
17
|
+
} from "../../chunk-VQTZJIFF.js";
|
|
18
18
|
import "../../chunk-FPG73MVN.js";
|
|
19
|
-
import "../../chunk-
|
|
19
|
+
import "../../chunk-L4YLJHLJ.js";
|
|
20
20
|
export {
|
|
21
21
|
IDregex,
|
|
22
22
|
deploy,
|
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@latticexyz/cli",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.84+089ff2ac",
|
|
4
4
|
"description": "Command line interface for mud",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"release": "npm publish --access=public"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@latticexyz/store": "^2.0.0-alpha.83+bea12cac",
|
|
31
30
|
"@types/ejs": "^3.1.1",
|
|
32
31
|
"@types/glob": "^7.2.0",
|
|
33
32
|
"@types/node": "^17.0.34",
|
|
@@ -38,15 +37,19 @@
|
|
|
38
37
|
"vitest": "^0.29.8"
|
|
39
38
|
},
|
|
40
39
|
"dependencies": {
|
|
40
|
+
"@ethersproject/abi": "^5.7.0",
|
|
41
|
+
"@ethersproject/providers": "^5.7.2",
|
|
41
42
|
"@improbable-eng/grpc-web": "^0.15.0",
|
|
42
43
|
"@improbable-eng/grpc-web-node-http-transport": "^0.15.0",
|
|
43
|
-
"@latticexyz/config": "^2.0.0-alpha.
|
|
44
|
-
"@latticexyz/schema-type": "^2.0.0-alpha.
|
|
45
|
-
"@latticexyz/services": "^2.0.0-alpha.
|
|
46
|
-
"@latticexyz/solecs": "^2.0.0-alpha.
|
|
47
|
-
"@latticexyz/std-contracts": "^2.0.0-alpha.
|
|
44
|
+
"@latticexyz/config": "^2.0.0-alpha.84+089ff2ac",
|
|
45
|
+
"@latticexyz/schema-type": "^2.0.0-alpha.84+089ff2ac",
|
|
46
|
+
"@latticexyz/services": "^2.0.0-alpha.84+089ff2ac",
|
|
47
|
+
"@latticexyz/solecs": "^2.0.0-alpha.84+089ff2ac",
|
|
48
|
+
"@latticexyz/std-contracts": "^2.0.0-alpha.84+089ff2ac",
|
|
49
|
+
"@latticexyz/store": "^2.0.0-alpha.84+089ff2ac",
|
|
50
|
+
"@latticexyz/world": "^2.0.0-alpha.84+089ff2ac",
|
|
48
51
|
"@solidity-parser/parser": "^0.16.0",
|
|
49
|
-
"@typechain/ethers-v5": "^10.
|
|
52
|
+
"@typechain/ethers-v5": "^10.2.0",
|
|
50
53
|
"chalk": "^5.0.1",
|
|
51
54
|
"chokidar": "^3.5.3",
|
|
52
55
|
"dotenv": "^16.0.3",
|
|
@@ -68,5 +71,5 @@
|
|
|
68
71
|
"zod": "^3.21.4",
|
|
69
72
|
"zod-validation-error": "^1.3.0"
|
|
70
73
|
},
|
|
71
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "089ff2ac7168d1bc5568b3b78cc73e14cd8ac95f"
|
|
72
75
|
}
|