@latticexyz/cli 2.2.19 → 2.2.20-391575967cd09bd527d819222232a54a7d722fc2
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.
| @@ -12,13 +12,26 @@ import { loadConfig, resolveConfigPath } from "@latticexyz/config/node"; | |
| 12 12 | 
             
            // src/build.ts
         | 
| 13 13 | 
             
            import { tablegen } from "@latticexyz/store/codegen";
         | 
| 14 14 | 
             
            import { buildSystemsManifest, worldgen } from "@latticexyz/world/node";
         | 
| 15 | 
            -
            import { forge } from "@latticexyz/common/foundry";
         | 
| 16 15 | 
             
            import { execa } from "execa";
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            // src/utils/printCommand.ts
         | 
| 18 | 
            +
            import chalk from "chalk";
         | 
| 19 | 
            +
            function printCommand(proc) {
         | 
| 20 | 
            +
              console.log("\n" + chalk.gray("> " + proc.spawnargs.join(" ")));
         | 
| 21 | 
            +
              return proc;
         | 
| 22 | 
            +
            }
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            // src/build.ts
         | 
| 17 25 | 
             
            async function build({ rootDir, config, foundryProfile }) {
         | 
| 18 26 | 
             
              await Promise.all([tablegen({ rootDir, config }), worldgen({ rootDir, config })]);
         | 
| 19 | 
            -
              await  | 
| 27 | 
            +
              await printCommand(
         | 
| 28 | 
            +
                execa("forge", ["build"], {
         | 
| 29 | 
            +
                  stdio: "inherit",
         | 
| 30 | 
            +
                  env: { FOUNDRY_PROFILE: foundryProfile ?? process.env.FOUNDRY_PROFILE }
         | 
| 31 | 
            +
                })
         | 
| 32 | 
            +
              );
         | 
| 20 33 | 
             
              await buildSystemsManifest({ rootDir, config });
         | 
| 21 | 
            -
              await execa("mud", ["abi-ts"], { stdio: "inherit" });
         | 
| 34 | 
            +
              await printCommand(execa("mud", ["abi-ts"], { stdio: "inherit" }));
         | 
| 22 35 | 
             
            }
         | 
| 23 36 |  | 
| 24 37 | 
             
            // src/commands/build.ts
         | 
| @@ -51,18 +64,18 @@ var commandModule2 = { | |
| 51 64 | 
             
              describe: "Start a local Ethereum node for development",
         | 
| 52 65 | 
             
              builder(yargs) {
         | 
| 53 66 | 
             
                return yargs.options({
         | 
| 54 | 
            -
                  blocktime: { type: "number", default:  | 
| 67 | 
            +
                  blocktime: { type: "number", default: 2, decs: "Interval in which new blocks are produced" }
         | 
| 55 68 | 
             
                });
         | 
| 56 69 | 
             
              },
         | 
| 57 70 | 
             
              async handler({ blocktime }) {
         | 
| 58 71 | 
             
                console.log("Clearing devnode history");
         | 
| 59 72 | 
             
                const userHomeDir = homedir();
         | 
| 60 73 | 
             
                rmSync(path2.join(userHomeDir, ".foundry", "anvil", "tmp"), { recursive: true, force: true });
         | 
| 61 | 
            -
                const  | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
                   | 
| 65 | 
            -
                 | 
| 74 | 
            +
                const child = printCommand(
         | 
| 75 | 
            +
                  execa2("anvil", ["-b", String(blocktime), "--block-base-fee-per-gas", "0"], {
         | 
| 76 | 
            +
                    stdio: "inherit"
         | 
| 77 | 
            +
                  })
         | 
| 78 | 
            +
                );
         | 
| 66 79 | 
             
                process.on("SIGINT", () => {
         | 
| 67 80 | 
             
                  console.log("\ngracefully shutting down from SIGINT (Crtl-C)");
         | 
| 68 81 | 
             
                  child.kill();
         | 
| @@ -1690,8 +1703,8 @@ import { getChainId } from "viem/actions"; | |
| 1690 1703 | 
             
            // src/utils/postDeploy.ts
         | 
| 1691 1704 | 
             
            import { existsSync } from "fs";
         | 
| 1692 1705 | 
             
            import path6 from "path";
         | 
| 1693 | 
            -
            import  | 
| 1694 | 
            -
            import {  | 
| 1706 | 
            +
            import { getScriptDirectory } from "@latticexyz/common/foundry";
         | 
| 1707 | 
            +
            import { execa as execa3 } from "execa";
         | 
| 1695 1708 | 
             
            async function postDeploy(postDeployScript, worldAddress, rpc, profile, forgeOptions, kms) {
         | 
| 1696 1709 | 
             
              const userOptions = forgeOptions?.replaceAll("\\", "").split(" ") ?? [];
         | 
| 1697 1710 | 
             
              const postDeployPath = path6.join(await getScriptDirectory(), postDeployScript + ".s.sol");
         | 
| @@ -1699,24 +1712,26 @@ async function postDeploy(postDeployScript, worldAddress, rpc, profile, forgeOpt | |
| 1699 1712 | 
             
                console.log(`No script at ${postDeployPath}, skipping post deploy hook`);
         | 
| 1700 1713 | 
             
                return;
         | 
| 1701 1714 | 
             
              }
         | 
| 1702 | 
            -
               | 
| 1703 | 
            -
             | 
| 1704 | 
            -
             | 
| 1705 | 
            -
                   | 
| 1706 | 
            -
             | 
| 1707 | 
            -
             | 
| 1708 | 
            -
             | 
| 1709 | 
            -
             | 
| 1710 | 
            -
             | 
| 1711 | 
            -
             | 
| 1712 | 
            -
             | 
| 1713 | 
            -
             | 
| 1714 | 
            -
                   | 
| 1715 | 
            -
                   | 
| 1716 | 
            -
             | 
| 1717 | 
            -
             | 
| 1718 | 
            -
             | 
| 1719 | 
            -
             | 
| 1715 | 
            +
              await printCommand(
         | 
| 1716 | 
            +
                execa3(
         | 
| 1717 | 
            +
                  "forge",
         | 
| 1718 | 
            +
                  [
         | 
| 1719 | 
            +
                    "script",
         | 
| 1720 | 
            +
                    postDeployScript,
         | 
| 1721 | 
            +
                    ["--sig", "run(address)", worldAddress],
         | 
| 1722 | 
            +
                    ["--rpc-url", rpc],
         | 
| 1723 | 
            +
                    "--broadcast",
         | 
| 1724 | 
            +
                    "-vvv",
         | 
| 1725 | 
            +
                    kms ? ["--aws"] : [],
         | 
| 1726 | 
            +
                    ...userOptions
         | 
| 1727 | 
            +
                  ].flat(),
         | 
| 1728 | 
            +
                  {
         | 
| 1729 | 
            +
                    stdio: "inherit",
         | 
| 1730 | 
            +
                    env: {
         | 
| 1731 | 
            +
                      FOUNDRY_PROFILE: profile ?? process.env.FOUNDRY_PROFILE
         | 
| 1732 | 
            +
                    }
         | 
| 1733 | 
            +
                  }
         | 
| 1734 | 
            +
                )
         | 
| 1720 1735 | 
             
              );
         | 
| 1721 1736 | 
             
            }
         | 
| 1722 1737 |  | 
| @@ -2259,8 +2274,9 @@ function resolveLinkPath(packageJsonPath, mudLinkPath, packageName) { | |
| 2259 2274 | 
             
            var set_version_default = commandModule7;
         | 
| 2260 2275 |  | 
| 2261 2276 | 
             
            // src/commands/test.ts
         | 
| 2262 | 
            -
            import {  | 
| 2277 | 
            +
            import { getRpcUrl as getRpcUrl2 } from "@latticexyz/common/foundry";
         | 
| 2263 2278 | 
             
            import chalk4 from "chalk";
         | 
| 2279 | 
            +
            import { execa as execa4 } from "execa";
         | 
| 2264 2280 | 
             
            var testOptions = {
         | 
| 2265 2281 | 
             
              ...deployOptions,
         | 
| 2266 2282 | 
             
              port: { type: "number", description: "Port to run internal node for fork testing on", default: 4242 },
         | 
| @@ -2278,8 +2294,12 @@ var commandModule8 = { | |
| 2278 2294 | 
             
              },
         | 
| 2279 2295 | 
             
              async handler(opts) {
         | 
| 2280 2296 | 
             
                if (!opts.worldAddress) {
         | 
| 2281 | 
            -
                   | 
| 2282 | 
            -
             | 
| 2297 | 
            +
                  printCommand(
         | 
| 2298 | 
            +
                    execa4("anvil", ["--quiet", ["--port", String(opts.port)], ["--block-base-fee-per-gas", "0"]].flat(), {
         | 
| 2299 | 
            +
                      stdio: "inherit",
         | 
| 2300 | 
            +
                      env: { FOUNDRY_PROFILE: opts.profile ?? process.env.FOUNDRY_PROFILE }
         | 
| 2301 | 
            +
                    })
         | 
| 2302 | 
            +
                  );
         | 
| 2283 2303 | 
             
                }
         | 
| 2284 2304 | 
             
                const forkRpc = opts.worldAddress ? await getRpcUrl2(opts.profile) : `http://127.0.0.1:${opts.port}`;
         | 
| 2285 2305 | 
             
                const worldAddress = opts.worldAddress ?? (await runDeploy({
         | 
| @@ -2290,12 +2310,15 @@ var commandModule8 = { | |
| 2290 2310 | 
             
                console.log(chalk4.blue("World address", worldAddress));
         | 
| 2291 2311 | 
             
                const userOptions = opts.forgeOptions?.replaceAll("\\", "").split(" ") ?? [];
         | 
| 2292 2312 | 
             
                try {
         | 
| 2293 | 
            -
                  await  | 
| 2294 | 
            -
                     | 
| 2295 | 
            -
             | 
| 2296 | 
            -
                       | 
| 2297 | 
            -
             | 
| 2298 | 
            -
             | 
| 2313 | 
            +
                  await printCommand(
         | 
| 2314 | 
            +
                    execa4("forge", ["test", ["--fork-url", forkRpc], ...userOptions].flat(), {
         | 
| 2315 | 
            +
                      stdio: "inherit",
         | 
| 2316 | 
            +
                      env: {
         | 
| 2317 | 
            +
                        FOUNDRY_PROFILE: opts.profile ?? process.env.FOUNDRY_PROFILE,
         | 
| 2318 | 
            +
                        WORLD_ADDRESS: worldAddress
         | 
| 2319 | 
            +
                      }
         | 
| 2320 | 
            +
                    })
         | 
| 2321 | 
            +
                  );
         | 
| 2299 2322 | 
             
                  process.exit(0);
         | 
| 2300 2323 | 
             
                } catch (e) {
         | 
| 2301 2324 | 
             
                  console.error(e);
         | 
| @@ -2310,11 +2333,12 @@ import path11 from "node:path"; | |
| 2310 2333 | 
             
            import fs from "node:fs";
         | 
| 2311 2334 | 
             
            import { loadConfig as loadConfig5, resolveConfigPath as resolveConfigPath5 } from "@latticexyz/config/node";
         | 
| 2312 2335 | 
             
            import { MUDError as MUDError4 } from "@latticexyz/common/errors";
         | 
| 2313 | 
            -
            import {  | 
| 2336 | 
            +
            import { getRpcUrl as getRpcUrl3 } from "@latticexyz/common/foundry";
         | 
| 2314 2337 | 
             
            import worldConfig4 from "@latticexyz/world/mud.config";
         | 
| 2315 2338 | 
             
            import { createClient, http as http2 } from "viem";
         | 
| 2316 2339 | 
             
            import { getChainId as getChainId2, readContract as readContract2 } from "viem/actions";
         | 
| 2317 2340 | 
             
            import { resolveSystems as resolveSystems2 } from "@latticexyz/world/node";
         | 
| 2341 | 
            +
            import { execa as execa5 } from "execa";
         | 
| 2318 2342 | 
             
            var systemsTableId = worldConfig4.namespaces.world.tables.Systems.tableId;
         | 
| 2319 2343 | 
             
            function getWorldAddress(worldsFile, chainId) {
         | 
| 2320 2344 | 
             
              if (!fs.existsSync(worldsFile)) {
         | 
| @@ -2362,21 +2386,27 @@ var commandModule9 = { | |
| 2362 2386 | 
             
                    })
         | 
| 2363 2387 | 
             
                  }))
         | 
| 2364 2388 | 
             
                );
         | 
| 2365 | 
            -
                 | 
| 2366 | 
            -
                   | 
| 2367 | 
            -
             | 
| 2368 | 
            -
             | 
| 2369 | 
            -
             | 
| 2370 | 
            -
             | 
| 2371 | 
            -
             | 
| 2372 | 
            -
             | 
| 2373 | 
            -
             | 
| 2389 | 
            +
                await printCommand(
         | 
| 2390 | 
            +
                  execa5(
         | 
| 2391 | 
            +
                    "cast",
         | 
| 2392 | 
            +
                    [
         | 
| 2393 | 
            +
                      "run",
         | 
| 2394 | 
            +
                      ["--label", `${worldAddress}:World`],
         | 
| 2395 | 
            +
                      ...labels.map(({ label, address }) => ["--label", `${address}:${label}`]),
         | 
| 2396 | 
            +
                      args.tx
         | 
| 2397 | 
            +
                    ].flat(),
         | 
| 2398 | 
            +
                    {
         | 
| 2399 | 
            +
                      stdio: "inherit",
         | 
| 2400 | 
            +
                      env: { FOUNDRY_PROFILE: profile ?? process.env.FOUNDRY_PROFILE }
         | 
| 2401 | 
            +
                    }
         | 
| 2402 | 
            +
                  )
         | 
| 2403 | 
            +
                );
         | 
| 2374 2404 | 
             
              }
         | 
| 2375 2405 | 
             
            };
         | 
| 2376 2406 | 
             
            var trace_default = commandModule9;
         | 
| 2377 2407 |  | 
| 2378 2408 | 
             
            // src/commands/dev-contracts.ts
         | 
| 2379 | 
            -
            import {  | 
| 2409 | 
            +
            import { getScriptDirectory as getScriptDirectory2, getSrcDirectory } from "@latticexyz/common/foundry";
         | 
| 2380 2410 | 
             
            import chalk5 from "chalk";
         | 
| 2381 2411 | 
             
            import chokidar from "chokidar";
         | 
| 2382 2412 | 
             
            import { loadConfig as loadConfig6, resolveConfigPath as resolveConfigPath6 } from "@latticexyz/config/node";
         | 
| @@ -2385,6 +2415,7 @@ import { homedir as homedir2 } from "os"; | |
| 2385 2415 | 
             
            import { rmSync as rmSync2 } from "fs";
         | 
| 2386 2416 | 
             
            import { BehaviorSubject, debounceTime, exhaustMap, filter } from "rxjs";
         | 
| 2387 2417 | 
             
            import { isDefined as isDefined5 } from "@latticexyz/common/utils";
         | 
| 2418 | 
            +
            import { execa as execa6 } from "execa";
         | 
| 2388 2419 | 
             
            var devOptions = {
         | 
| 2389 2420 | 
             
              rpc: deployOptions.rpc,
         | 
| 2390 2421 | 
             
              configPath: deployOptions.configPath,
         | 
| @@ -2408,8 +2439,11 @@ var commandModule10 = { | |
| 2408 2439 | 
             
                  console.log(chalk5.gray("Cleaning devnode cache"));
         | 
| 2409 2440 | 
             
                  const userHomeDir = homedir2();
         | 
| 2410 2441 | 
             
                  rmSync2(path12.join(userHomeDir, ".foundry", "anvil", "tmp"), { recursive: true, force: true });
         | 
| 2411 | 
            -
                   | 
| 2412 | 
            -
             | 
| 2442 | 
            +
                  await printCommand(
         | 
| 2443 | 
            +
                    execa6("anvil", ["--quiet", ["--block-time", "2"], ["--block-base-fee-per-gas", "0"]].flat(), {
         | 
| 2444 | 
            +
                      stdio: "inherit"
         | 
| 2445 | 
            +
                    })
         | 
| 2446 | 
            +
                  );
         | 
| 2413 2447 | 
             
                  rpc = "http://127.0.0.1:8545";
         | 
| 2414 2448 | 
             
                }
         | 
| 2415 2449 | 
             
                const lastChange$ = new BehaviorSubject(Date.now());
         | 
| @@ -2473,23 +2507,29 @@ var dev_contracts_default = commandModule10; | |
| 2473 2507 | 
             
            import { sliceHex, zeroHash } from "viem";
         | 
| 2474 2508 |  | 
| 2475 2509 | 
             
            // src/verify/verifyContract.ts
         | 
| 2476 | 
            -
            import {  | 
| 2510 | 
            +
            import { execa as execa7 } from "execa";
         | 
| 2477 2511 | 
             
            async function verifyContract(options2) {
         | 
| 2478 | 
            -
               | 
| 2479 | 
            -
             | 
| 2480 | 
            -
             | 
| 2481 | 
            -
             | 
| 2482 | 
            -
             | 
| 2483 | 
            -
             | 
| 2484 | 
            -
             | 
| 2485 | 
            -
             | 
| 2512 | 
            +
              await printCommand(
         | 
| 2513 | 
            +
                execa7(
         | 
| 2514 | 
            +
                  "forge",
         | 
| 2515 | 
            +
                  [
         | 
| 2516 | 
            +
                    "verify-contract",
         | 
| 2517 | 
            +
                    options2.address,
         | 
| 2518 | 
            +
                    options2.name,
         | 
| 2519 | 
            +
                    ["--rpc-url", options2.rpc],
         | 
| 2520 | 
            +
                    options2.verifier ? ["--verifier", options2.verifier] : [],
         | 
| 2521 | 
            +
                    options2.verifierUrl ? ["--verifier-url", options2.verifierUrl] : []
         | 
| 2522 | 
            +
                  ].flat(),
         | 
| 2523 | 
            +
                  { stdio: "inherit" }
         | 
| 2524 | 
            +
                )
         | 
| 2525 | 
            +
              );
         | 
| 2486 2526 | 
             
            }
         | 
| 2487 2527 |  | 
| 2488 2528 | 
             
            // src/verify.ts
         | 
| 2489 2529 | 
             
            import PQueue from "p-queue";
         | 
| 2490 2530 | 
             
            import { MUDError as MUDError5 } from "@latticexyz/common/errors";
         | 
| 2491 2531 | 
             
            import { getStorageAt } from "viem/actions";
         | 
| 2492 | 
            -
            import { execa as  | 
| 2532 | 
            +
            import { execa as execa8 } from "execa";
         | 
| 2493 2533 | 
             
            import { getContractAddress as getContractAddress6, getDeployer } from "@latticexyz/common/internal";
         | 
| 2494 2534 | 
             
            var ERC1967_IMPLEMENTATION_SLOT = "0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc";
         | 
| 2495 2535 | 
             
            async function verify({
         | 
| @@ -2532,13 +2572,13 @@ async function verify({ | |
| 2532 2572 | 
             
                })
         | 
| 2533 2573 | 
             
              );
         | 
| 2534 2574 | 
             
              if (verifier === "sourcify") {
         | 
| 2535 | 
            -
                await  | 
| 2575 | 
            +
                await execa8("npm", ["install"], {
         | 
| 2536 2576 | 
             
                  cwd: "node_modules/@latticexyz/store"
         | 
| 2537 2577 | 
             
                });
         | 
| 2538 | 
            -
                await  | 
| 2578 | 
            +
                await execa8("npm", ["install"], {
         | 
| 2539 2579 | 
             
                  cwd: "node_modules/@latticexyz/world"
         | 
| 2540 2580 | 
             
                });
         | 
| 2541 | 
            -
                await  | 
| 2581 | 
            +
                await execa8("npm", ["install"], {
         | 
| 2542 2582 | 
             
                  cwd: "node_modules/@latticexyz/world-modules"
         | 
| 2543 2583 | 
             
                });
         | 
| 2544 2584 | 
             
                Object.entries(
         | 
| @@ -3013,4 +3053,4 @@ var commands = [ | |
| 3013 3053 | 
             
            export {
         | 
| 3014 3054 | 
             
              commands
         | 
| 3015 3055 | 
             
            };
         | 
| 3016 | 
            -
            //# sourceMappingURL=commands- | 
| 3056 | 
            +
            //# sourceMappingURL=commands-YM3AS57B.js.map
         |