@latticexyz/cli 0.11.1 → 0.13.0

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.
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.handler = exports.builder = exports.desc = exports.command = void 0;
13
+ const importExeca = eval('import("execa")');
14
+ exports.command = "bulkupload";
15
+ exports.desc = "Uploads the provided ECS state to the provided World";
16
+ const builder = (yargs) => yargs.options({
17
+ statePath: { type: "string", demandOption: true, desc: "Path to the ECS state to upload" },
18
+ worldAddress: { type: "string", demandOption: true, desc: "Contract address of the World to upload to" },
19
+ rpc: { type: "string", demandOption: true, desc: "JSON RPC endpoint" },
20
+ });
21
+ exports.builder = builder;
22
+ const handler = (argv) => __awaiter(void 0, void 0, void 0, function* () {
23
+ const { execa } = yield importExeca;
24
+ const { statePath, worldAddress, rpc } = argv;
25
+ console.log("Uploading state at ", statePath, "to", worldAddress, "on", rpc);
26
+ const url = __dirname + "/../../src/contracts/BulkUpload.sol";
27
+ console.log("Using BulkUpload script from", url);
28
+ try {
29
+ yield execa("forge", [
30
+ "script",
31
+ "--sig",
32
+ '"run(string, address)"',
33
+ "--rpc-url",
34
+ rpc,
35
+ `${url}:BulkUpload`,
36
+ statePath,
37
+ worldAddress,
38
+ ]);
39
+ }
40
+ catch (e) {
41
+ console.error(e);
42
+ }
43
+ process.exit(0);
44
+ });
45
+ exports.handler = handler;
@@ -302,7 +302,7 @@ const deploy = (options) => __awaiter(void 0, void 0, void 0, function* () {
302
302
  const cmdArgs = options.upgradeSystems
303
303
  ? [
304
304
  "workspace",
305
- "ri-contracts",
305
+ "contracts",
306
306
  "forge:deploy",
307
307
  ...(options.dry ? [] : ["--broadcast", "--private-keys", wallet.privateKey]),
308
308
  "--sig",
@@ -314,7 +314,7 @@ const deploy = (options) => __awaiter(void 0, void 0, void 0, function* () {
314
314
  ]
315
315
  : [
316
316
  "workspace",
317
- "ri-contracts",
317
+ "contracts",
318
318
  "forge:deploy",
319
319
  ...(options.dry ? [] : ["--broadcast", "--private-keys", wallet.privateKey]),
320
320
  "--sig",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@latticexyz/cli",
3
- "version": "0.11.1",
3
+ "version": "0.13.0",
4
4
  "description": "Command line interface for mud",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -13,11 +13,13 @@
13
13
  "directory": "packages/cli"
14
14
  },
15
15
  "scripts": {
16
- "prepare": "yarn build",
17
- "globalinstall": "yarn build && npm link",
16
+ "prepare": "yarn build && chmod u+x git-install.sh",
17
+ "globalinstall": "yarn prepare && npm link",
18
18
  "build": "rimraf dist && tsc -p . && chmod u+x dist/index.js",
19
19
  "link": "yarn link",
20
- "test": "echo 'todo: add tests'"
20
+ "test": "echo 'todo: add tests'",
21
+ "git:install": "bash git-install.sh",
22
+ "release": "npm publish || echo 'version already published'"
21
23
  },
22
24
  "devDependencies": {
23
25
  "@types/clear": "^0.1.2",
@@ -34,15 +36,18 @@
34
36
  "typescript": "^4.6.4"
35
37
  },
36
38
  "dependencies": {
37
- "@latticexyz/solecs": "^0.11.1",
38
- "@latticexyz/utils": "^0.11.1",
39
+ "@latticexyz/solecs": "^0.13.0",
40
+ "@latticexyz/std-contracts": "^0.13.0",
41
+ "@latticexyz/utils": "^0.13.0",
39
42
  "chalk": "^5.0.1",
40
43
  "clear": "^0.1.0",
41
44
  "commander": "^9.2.0",
45
+ "ds-test": "https://github.com/dapphub/ds-test.git#9310e879db8ba3ea6d5c6489a579118fd264a3f5",
42
46
  "esm": "^3.2.25",
43
47
  "ethers": "^5.6.7",
44
48
  "execa": "^6.1.0",
45
49
  "figlet": "^1.5.2",
50
+ "forge-std": "https://github.com/foundry-rs/forge-std.git#6b4ca42943f093642bac31783b08aa52a5a6ff64",
46
51
  "glob": "^8.0.3",
47
52
  "inquirer": "^8.2.4",
48
53
  "inquirer-prompt-suggest": "^0.1.0",
@@ -51,6 +56,7 @@
51
56
  "node-fetch": "^3.2.6",
52
57
  "openurl": "^1.1.1",
53
58
  "path": "^0.12.7",
59
+ "solmate": "https://github.com/Rari-Capital/solmate.git#9cf1428245074e39090dceacb0c28b1f684f584c",
54
60
  "typechain": "^8.1.0",
55
61
  "uuid": "^8.3.2",
56
62
  "yargs": "^17.5.1"
@@ -58,5 +64,5 @@
58
64
  "pkg": {
59
65
  "scripts": "build/**/*.js"
60
66
  },
61
- "gitHead": "43b26a1c0311605a3f91e630e57487a8e4faa58f"
67
+ "gitHead": "d4f7761040185d9d4b65c286e774e15fb8207f81"
62
68
  }
@@ -0,0 +1,44 @@
1
+ import { Arguments, CommandBuilder } from "yargs";
2
+
3
+ const importExeca = eval('import("execa")') as Promise<typeof import("execa")>;
4
+
5
+ type Options = {
6
+ statePath: string;
7
+ worldAddress: string;
8
+ rpc: string;
9
+ };
10
+
11
+ export const command = "bulkupload";
12
+ export const desc = "Uploads the provided ECS state to the provided World";
13
+
14
+ export const builder: CommandBuilder<Options, Options> = (yargs) =>
15
+ yargs.options({
16
+ statePath: { type: "string", demandOption: true, desc: "Path to the ECS state to upload" },
17
+ worldAddress: { type: "string", demandOption: true, desc: "Contract address of the World to upload to" },
18
+ rpc: { type: "string", demandOption: true, desc: "JSON RPC endpoint" },
19
+ });
20
+
21
+ export const handler = async (argv: Arguments<Options>): Promise<void> => {
22
+ const { execa } = await importExeca;
23
+ const { statePath, worldAddress, rpc } = argv;
24
+ console.log("Uploading state at ", statePath, "to", worldAddress, "on", rpc);
25
+ const url = __dirname + "/../../src/contracts/BulkUpload.sol";
26
+ console.log("Using BulkUpload script from", url);
27
+
28
+ try {
29
+ await execa("forge", [
30
+ "script",
31
+ "--sig",
32
+ '"run(string, address)"',
33
+ "--rpc-url",
34
+ rpc,
35
+ `${url}:BulkUpload`,
36
+ statePath,
37
+ worldAddress,
38
+ ]);
39
+ } catch (e) {
40
+ console.error(e);
41
+ }
42
+
43
+ process.exit(0);
44
+ };
@@ -0,0 +1,62 @@
1
+ import { defaultAbiCoder as abi } from "ethers/lib/utils";
2
+ import { Arguments, CommandBuilder } from "yargs";
3
+ import { execLog } from "../utils";
4
+
5
+ type Options = {
6
+ rpc?: string;
7
+ caller?: string;
8
+ world: string;
9
+ systemId?: string;
10
+ systemAddress?: string;
11
+ argTypes?: any[];
12
+ args?: any[];
13
+ calldata?: string;
14
+ broadcast?: boolean;
15
+ callerPrivateKey?: string;
16
+ debug?: boolean;
17
+ };
18
+
19
+ export const command = "call-system";
20
+ export const desc = "Execute a mud system";
21
+
22
+ export const builder: CommandBuilder<Options, Options> = (yargs) =>
23
+ yargs.options({
24
+ rpc: { type: "string", description: "json rpc endpoint, defaults to http://localhost:8545" },
25
+ caller: { type: "string", description: "caller address" },
26
+ world: { type: "string", required: true, description: "world contract address" },
27
+ systemId: { type: "string", description: "system id preimage (eg mud.system.Move)" },
28
+ systemAddress: { type: "string", description: "system address (alternative to system id)" },
29
+ argTypes: { type: "array", description: "system argument types for abi encoding" },
30
+ args: { type: "array", description: "system arguments" },
31
+ calldata: { type: "string", description: "abi encoded system arguments (instead of args/argTypes)" },
32
+ broadcast: { type: "boolean", description: "send txs to the chain" },
33
+ callerPrivateKey: {
34
+ type: "string",
35
+ description: "must be set if broadcast is set, must correspond to caller address",
36
+ },
37
+ debug: { type: "boolean", description: "open debugger" },
38
+ });
39
+
40
+ export const handler = async (argv: Arguments<Options>): Promise<void> => {
41
+ const { rpc, caller, world, systemId, argTypes, args, calldata, broadcast, callerPrivateKey, debug } = argv;
42
+ const encodedArgs = calldata ?? (argTypes && args && abi.encode(argTypes, args)) ?? "";
43
+ await execLog("forge", [
44
+ "script",
45
+ "--fork-url",
46
+ rpc ?? "http://localhost:8545", // default anvil rpc
47
+ "--sig",
48
+ "debug(address,address,string,bytes,bool)",
49
+ "src/test/utils/Debug.sol", // the cli expects the Debug.sol file at this path
50
+ caller ?? "0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266", // default anvil deployer
51
+ world,
52
+ systemId || "",
53
+ encodedArgs,
54
+ broadcast ? "true" : "false",
55
+ "-vvvvv",
56
+ broadcast ? "--broadcast" : "",
57
+ callerPrivateKey ? `--private-key ${callerPrivateKey}` : "",
58
+ debug ? "--debug" : "",
59
+ ]);
60
+
61
+ process.exit(0);
62
+ };
@@ -0,0 +1,54 @@
1
+ import { Arguments, CommandBuilder } from "yargs";
2
+ import { exec } from "../utils";
3
+
4
+ type Options = {
5
+ name: string;
6
+ };
7
+
8
+ export const command = "create <name>";
9
+ export const desc = "Sets up a fresh mud project into <name>. Requires yarn.";
10
+
11
+ export const builder: CommandBuilder<Options, Options> = (yargs) =>
12
+ yargs.positional("name", { type: "string", demandOption: true });
13
+
14
+ export const handler = async (argv: Arguments<Options>): Promise<void> => {
15
+ const { name } = argv;
16
+ console.log("Creating new mud project in", name);
17
+
18
+ console.log("Cloning...");
19
+ await exec(`git clone https://github.com/latticexyz/mud _mudtemp`);
20
+
21
+ console.log("Moving...");
22
+ await exec(`cp -r _mudtemp/packages/ri ${name}`);
23
+
24
+ console.log("Setting up vscode solidity settings...");
25
+ await exec(`cp -r _mudtemp/.vscode ${name}/.vscode`);
26
+
27
+ console.log("Cleaning up...");
28
+ await exec(`rm -rf _mudtemp`);
29
+
30
+ console.log("Setting up package.json...");
31
+ await exec(`mv ${name}/packagejson.template ${name}/package.json`);
32
+
33
+ console.log("Installing dependencies using yarn...");
34
+ await exec(`cd ${name} && yarn install`);
35
+
36
+ console.log("Setting up foundry.toml...");
37
+ await exec(`rm ${name}/contracts/foundry.toml`);
38
+ await exec(`mv ${name}/contracts/foundrytoml.template ${name}/contracts/foundry.toml`);
39
+
40
+ console.log("Setting up remappings...");
41
+ await exec(`rm ${name}/contracts/remappings.txt`);
42
+ await exec(`mv ${name}/contracts/remappingstxt.template ${name}/contracts/remappings.txt`);
43
+
44
+ console.log("Setting up compile task...");
45
+ await exec(`rm ${name}/contracts/tasks/compile.ts`);
46
+ await exec(`mv ${name}/contracts/tasks/compilets.template ${name}/contracts/tasks/compile.ts`);
47
+
48
+ console.log("Building contracts...");
49
+ await exec(`cd ${name}/contracts && yarn build`);
50
+
51
+ console.log("Done setting up! Run `yarn start` to start client and chain, then head to localhost:3000 to explore.");
52
+
53
+ process.exit(0);
54
+ };