@cartesi/cli 2.0.0-alpha.3 → 2.0.0-alpha.5

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.
Files changed (76) hide show
  1. package/dist/base.d.ts +14 -0
  2. package/dist/base.d.ts.map +1 -0
  3. package/dist/base.js +77 -0
  4. package/dist/commands/address-book.d.ts +2 -8
  5. package/dist/commands/address-book.d.ts.map +1 -1
  6. package/dist/commands/address-book.js +15 -14
  7. package/dist/commands/build.d.ts +2 -11
  8. package/dist/commands/build.d.ts.map +1 -1
  9. package/dist/commands/build.js +16 -28
  10. package/dist/commands/clean.d.ts +2 -7
  11. package/dist/commands/clean.d.ts.map +1 -1
  12. package/dist/commands/clean.js +9 -10
  13. package/dist/commands/create.d.ts +2 -14
  14. package/dist/commands/create.d.ts.map +1 -1
  15. package/dist/commands/create.js +37 -51
  16. package/dist/commands/deploy/build.d.ts +2 -14
  17. package/dist/commands/deploy/build.d.ts.map +1 -1
  18. package/dist/commands/deploy/build.js +41 -47
  19. package/dist/commands/deploy.d.ts +3 -0
  20. package/dist/commands/deploy.d.ts.map +1 -0
  21. package/dist/commands/{deploy/index.js → deploy.js} +26 -28
  22. package/dist/commands/doctor.d.ts +2 -12
  23. package/dist/commands/doctor.d.ts.map +1 -1
  24. package/dist/commands/doctor.js +83 -90
  25. package/dist/commands/hash.d.ts +2 -9
  26. package/dist/commands/hash.d.ts.map +1 -1
  27. package/dist/commands/hash.js +14 -14
  28. package/dist/commands/run.d.ts +2 -20
  29. package/dist/commands/run.d.ts.map +1 -1
  30. package/dist/commands/run.js +49 -82
  31. package/dist/commands/send/erc20.d.ts +2 -13
  32. package/dist/commands/send/erc20.d.ts.map +1 -1
  33. package/dist/commands/send/erc20.js +55 -52
  34. package/dist/commands/send/erc721.d.ts +2 -13
  35. package/dist/commands/send/erc721.d.ts.map +1 -1
  36. package/dist/commands/send/erc721.js +49 -46
  37. package/dist/commands/send/ether.d.ts +2 -12
  38. package/dist/commands/send/ether.d.ts.map +1 -1
  39. package/dist/commands/send/ether.js +23 -21
  40. package/dist/commands/send/generic.d.ts +2 -14
  41. package/dist/commands/send/generic.d.ts.map +1 -1
  42. package/dist/commands/send/generic.js +91 -97
  43. package/dist/commands/send.d.ts +21 -0
  44. package/dist/commands/send.d.ts.map +1 -0
  45. package/dist/commands/send.js +67 -0
  46. package/dist/commands/shell.d.ts +2 -14
  47. package/dist/commands/shell.d.ts.map +1 -1
  48. package/dist/commands/shell.js +21 -43
  49. package/dist/config.d.ts +1 -1
  50. package/dist/config.js +1 -1
  51. package/dist/index.d.ts +2 -1
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +51 -1
  54. package/dist/node/docker-compose-anvil.yaml +2 -2
  55. package/dist/node/docker-compose-bundler.yaml +1 -1
  56. package/dist/node/docker-compose-database.yaml +1 -1
  57. package/dist/node/docker-compose-espresso.yaml +127 -0
  58. package/dist/node/docker-compose-explorer.yaml +1 -1
  59. package/dist/node/docker-compose-paymaster.yaml +1 -1
  60. package/package.json +8 -27
  61. package/bin/dev.cmd +0 -3
  62. package/bin/dev.js +0 -25
  63. package/bin/run.cmd +0 -3
  64. package/bin/run.js +0 -8
  65. package/dist/baseCommand.d.ts +0 -22
  66. package/dist/baseCommand.d.ts.map +0 -1
  67. package/dist/baseCommand.js +0 -92
  68. package/dist/commands/deploy/index.d.ts +0 -12
  69. package/dist/commands/deploy/index.d.ts.map +0 -1
  70. package/dist/commands/send/index.d.ts +0 -28
  71. package/dist/commands/send/index.d.ts.map +0 -1
  72. package/dist/commands/send/index.js +0 -102
  73. package/dist/flags.d.ts +0 -17
  74. package/dist/flags.d.ts.map +0 -1
  75. package/dist/flags.js +0 -28
  76. package/oclif.manifest.json +0 -876
@@ -1,23 +1,32 @@
1
+ import { Option } from "@commander-js/extra-typings";
1
2
  import confirm from "@inquirer/confirm";
2
3
  import select from "@inquirer/select";
3
- import { Flags } from "@oclif/core";
4
4
  import chalk from "chalk";
5
5
  import open, { apps } from "open";
6
- import { BaseCommand } from "../../baseCommand.js";
7
- class Deploy extends BaseCommand {
8
- async run() {
9
- const { flags } = await this.parse(Deploy);
6
+ import { getMachineHash, logPrompt } from "../base.js";
7
+ import { registerBuildCommand } from "./deploy/build.js";
8
+ export const registerDeployCommand = (program) => {
9
+ const deployCommand = program
10
+ .command("deploy")
11
+ .description("Package and deploy the application to a supported live network.")
12
+ .addOption(new Option("--hosting <hosting>", "hosting type").choices([
13
+ "self-hosted",
14
+ "third-party",
15
+ ]))
16
+ .addOption(new Option("--webapp <webapp>", "webapp address").makeOptionMandatory())
17
+ .action(async (options, command) => {
10
18
  // print machine hash
11
- const templateHash = this.getMachineHash();
19
+ const templateHash = getMachineHash();
12
20
  if (!templateHash) {
13
- this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
21
+ command.error(`Cartesi machine snapshot not found, run 'build'`);
22
+ return;
14
23
  }
15
- this.logPrompt({
24
+ logPrompt({
16
25
  title: "Cartesi machine templateHash",
17
26
  value: templateHash,
18
27
  });
19
28
  // ask for deployment type
20
- const hosting = flags.hosting ||
29
+ const hosting = options.hosting ||
21
30
  (await select({
22
31
  message: "Select hosting type",
23
32
  choices: [
@@ -45,34 +54,23 @@ You will need the following infrastructure:
45
54
  switch (hosting) {
46
55
  case "self-hosted": {
47
56
  // build docker image
48
- await this.config.runCommand("deploy:build");
57
+ // Execute the build subcommand
58
+ program.commands
59
+ .find((cmd) => cmd.name() === "build")
60
+ ?.parseAsync(program.args);
49
61
  queryString = `?templateHash=${templateHash}`;
50
62
  break;
51
63
  }
52
64
  case "third-party": {
53
- this.error("Third-party provider deployment not supported yet");
65
+ command.error("Third-party provider deployment not supported yet");
54
66
  }
55
67
  }
56
68
  // prompt user to open webapp for onchain deployment
57
- const deployUrl = `${flags.webapp}${queryString}`;
69
+ const deployUrl = `${options.webapp}${queryString}`;
58
70
  if (await confirm({ message: `Open ${chalk.cyan(deployUrl)}?` })) {
59
71
  open(deployUrl, { app: { name: apps.chrome } });
60
72
  }
61
73
  return;
62
- }
63
- }
64
- Deploy.summary = "Deploy application to a live network.";
65
- Deploy.description = "Package and deploy the application to a supported live network.";
66
- Deploy.examples = ["<%= config.bin %> <%= command.id %>"];
67
- Deploy.flags = {
68
- hosting: Flags.string({
69
- options: ["self-hosted", "third-party"],
70
- summary: "hosting type",
71
- description: "Select wheather the user will host an application node himself, or use a third-party node provider",
72
- }),
73
- webapp: Flags.url({
74
- description: "address of deploy webapp",
75
- required: true,
76
- }),
74
+ });
75
+ registerBuildCommand(deployCommand);
77
76
  };
78
- export default Deploy;
@@ -1,13 +1,3 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export default class DoctorCommand extends BaseCommand<typeof DoctorCommand> {
3
- static description: string;
4
- static examples: string[];
5
- private static MINIMUM_DOCKER_VERSION;
6
- private static MINIMUM_DOCKER_COMPOSE_VERSION;
7
- private static MINIMUM_BUILDX_VERSION;
8
- private checkDocker;
9
- private checkCompose;
10
- private checkBuildx;
11
- run(): Promise<void>;
12
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const registerDoctorCommand: (program: Command) => void;
13
3
  //# sourceMappingURL=doctor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW,CAAC,OAAO,aAAa,CAAC;IACxE,MAAM,CAAC,WAAW,SAA2C;IAE7D,MAAM,CAAC,QAAQ,WAA2C;IAE1D,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAY;IACjD,OAAO,CAAC,MAAM,CAAC,8BAA8B,CAAY;IACzD,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAY;YAEnC,WAAW;YA+BX,YAAY;YAiCZ,WAAW;IAiDZ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAYpC"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAgHtD,eAAO,MAAM,qBAAqB,YAAa,OAAO,SAarD,CAAC"}
@@ -1,106 +1,99 @@
1
1
  import { execa } from "execa";
2
2
  import semver from "semver";
3
- import { BaseCommand } from "../baseCommand.js";
4
- class DoctorCommand extends BaseCommand {
5
- async checkDocker() {
6
- try {
7
- const { stdout: dockerVersion } = await execa("docker", [
8
- "version",
9
- "--format",
10
- "{{json .Client.Version}}",
11
- ]);
12
- const v = semver.coerce(dockerVersion);
13
- if (v !== null &&
14
- !semver.gte(v, DoctorCommand.MINIMUM_DOCKER_VERSION)) {
15
- throw new Error(`Unsupported Docker version. Minimum required version is ${DoctorCommand.MINIMUM_DOCKER_VERSION}. Installed version is ${v}.`);
16
- }
3
+ const MINIMUM_DOCKER_VERSION = "23.0.0"; // Replace with our minimum required Docker version
4
+ const MINIMUM_DOCKER_COMPOSE_VERSION = "2.21.0"; // Replace with our minimum required Docker Compose version
5
+ const MINIMUM_BUILDX_VERSION = "0.13.0"; // Replace with our minimum required Buildx version
6
+ const checkDocker = async () => {
7
+ try {
8
+ const { stdout: dockerVersion } = await execa("docker", [
9
+ "version",
10
+ "--format",
11
+ "{{json .Client.Version}}",
12
+ ]);
13
+ const v = semver.coerce(dockerVersion);
14
+ if (v !== null && !semver.gte(v, MINIMUM_DOCKER_VERSION)) {
15
+ throw new Error(`Unsupported Docker version. Minimum required version is ${MINIMUM_DOCKER_VERSION}. Installed version is ${v}.`);
17
16
  }
18
- catch (e) {
19
- if (e instanceof Error &&
20
- e.code === "ENOENT") {
21
- throw new Error("Docker not found");
22
- }
23
- else {
24
- throw e;
25
- }
17
+ }
18
+ catch (e) {
19
+ if (e instanceof Error &&
20
+ e.code === "ENOENT") {
21
+ throw new Error("Docker not found");
22
+ }
23
+ else {
24
+ throw e;
26
25
  }
27
- return true;
28
26
  }
29
- async checkCompose() {
30
- try {
31
- const { stdout: dockerComposeVersion } = await execa("docker", [
32
- "compose",
33
- "version",
34
- "--short",
35
- ]);
36
- const v = semver.coerce(dockerComposeVersion);
37
- if (v !== null &&
38
- !semver.gte(v, DoctorCommand.MINIMUM_DOCKER_COMPOSE_VERSION)) {
39
- throw new Error(`Unsupported Docker Compose version. Minimum required version is ${DoctorCommand.MINIMUM_DOCKER_COMPOSE_VERSION}. Installed version is ${v}.`);
40
- }
27
+ return true;
28
+ };
29
+ const checkCompose = async () => {
30
+ try {
31
+ const { stdout: dockerComposeVersion } = await execa("docker", [
32
+ "compose",
33
+ "version",
34
+ "--short",
35
+ ]);
36
+ const v = semver.coerce(dockerComposeVersion);
37
+ if (v !== null && !semver.gte(v, MINIMUM_DOCKER_COMPOSE_VERSION)) {
38
+ throw new Error(`Unsupported Docker Compose version. Minimum required version is ${MINIMUM_DOCKER_COMPOSE_VERSION}. Installed version is ${v}.`);
41
39
  }
42
- catch (e) {
43
- if (e instanceof Error &&
44
- e.exitCode === 125) {
45
- throw new Error("Docker Compose is required but not installed or the command execution failed. Please refer to the Docker Compose documentation for installation instructions: https://docs.docker.com/compose/install/");
46
- }
47
- else {
48
- throw e;
49
- }
40
+ }
41
+ catch (e) {
42
+ if (e instanceof Error &&
43
+ e.exitCode === 125) {
44
+ throw new Error("Docker Compose is required but not installed or the command execution failed. Please refer to the Docker Compose documentation for installation instructions: https://docs.docker.com/compose/install/");
45
+ }
46
+ else {
47
+ throw e;
50
48
  }
51
- return true;
52
49
  }
53
- async checkBuildx() {
54
- try {
55
- const { stdout: buildxOutput } = await execa("docker", [
56
- "buildx",
57
- "version",
58
- ]);
59
- const v = semver.coerce(buildxOutput);
60
- if (v !== null &&
61
- !semver.gte(v, DoctorCommand.MINIMUM_BUILDX_VERSION)) {
62
- throw new Error(`Unsupported Docker Buildx version. Minimum required version is ${DoctorCommand.MINIMUM_BUILDX_VERSION}. Installed version is ${v}.`);
63
- }
64
- const { stdout: platformsOutput } = await execa("docker", [
65
- "buildx",
66
- "ls",
67
- "--format",
68
- "{{.Platforms}}",
69
- ]);
70
- const buildxPlatforms = platformsOutput
71
- .split(",")
72
- .map((platform) => platform.trim());
73
- if (!buildxPlatforms.includes("linux/riscv64")) {
74
- throw new Error("Your system does not support riscv64 architecture. Run `docker run --privileged --rm tonistiigi/binfmt:riscv` to enable riscv64 support.");
75
- }
50
+ return true;
51
+ };
52
+ const checkBuildx = async () => {
53
+ try {
54
+ const { stdout: buildxOutput } = await execa("docker", [
55
+ "buildx",
56
+ "version",
57
+ ]);
58
+ const v = semver.coerce(buildxOutput);
59
+ if (v !== null && !semver.gte(v, MINIMUM_BUILDX_VERSION)) {
60
+ throw new Error(`Unsupported Docker Buildx version. Minimum required version is ${MINIMUM_BUILDX_VERSION}. Installed version is ${v}.`);
76
61
  }
77
- catch (e) {
78
- if (e instanceof Error &&
79
- e.exitCode === 125) {
80
- throw new Error("Docker Buildx is required but not installed. Please refer to the Docker Desktop documentation for installation instructions: https://docs.docker.com/desktop/");
81
- }
82
- else {
83
- throw e;
84
- }
62
+ const { stdout: platformsOutput } = await execa("docker", [
63
+ "buildx",
64
+ "ls",
65
+ "--format",
66
+ "{{.Platforms}}",
67
+ ]);
68
+ const buildxPlatforms = platformsOutput
69
+ .split(",")
70
+ .map((platform) => platform.trim());
71
+ if (!buildxPlatforms.includes("linux/riscv64")) {
72
+ throw new Error("Your system does not support riscv64 architecture. Run `docker run --privileged --rm tonistiigi/binfmt:riscv` to enable riscv64 support.");
73
+ }
74
+ }
75
+ catch (e) {
76
+ if (e instanceof Error &&
77
+ e.exitCode === 125) {
78
+ throw new Error("Docker Buildx is required but not installed. Please refer to the Docker Desktop documentation for installation instructions: https://docs.docker.com/desktop/");
79
+ }
80
+ else {
81
+ throw e;
85
82
  }
86
- return true;
87
83
  }
88
- async run() {
84
+ return true;
85
+ };
86
+ export const registerDoctorCommand = (program) => {
87
+ program.command("doctor").action(async (_, command) => {
89
88
  try {
90
- if (await this.checkDocker()) {
91
- await this.checkCompose();
92
- await this.checkBuildx();
89
+ if (await checkDocker()) {
90
+ await checkCompose();
91
+ await checkBuildx();
93
92
  }
94
93
  }
95
94
  catch (e) {
96
- this.error(e);
95
+ command.error(e.message);
97
96
  }
98
- this.log("Your system is ready.");
99
- }
100
- }
101
- DoctorCommand.description = "Verify the minimal sytem requirements";
102
- DoctorCommand.examples = ["<%= config.bin %> <%= command.id %>"];
103
- DoctorCommand.MINIMUM_DOCKER_VERSION = "23.0.0"; // Replace with our minimum required Docker version
104
- DoctorCommand.MINIMUM_DOCKER_COMPOSE_VERSION = "2.21.0"; // Replace with our minimum required Docker Compose version
105
- DoctorCommand.MINIMUM_BUILDX_VERSION = "0.13.0"; // Replace with our minimum required Buildx version
106
- export default DoctorCommand;
97
+ console.log("Your system is ready.");
98
+ });
99
+ };
@@ -1,10 +1,3 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export default class HashCommand extends BaseCommand<typeof HashCommand> {
3
- static summary: string;
4
- static description: string;
5
- static enableJsonFlag: boolean;
6
- run(): Promise<{
7
- hash: `0x${string}`;
8
- } | undefined>;
9
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const registerHashCommand: (program: Command) => void;
10
3
  //# sourceMappingURL=hash.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/commands/hash.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,OAAO,WAAW,CAAC;IACpE,MAAM,CAAC,OAAO,SAA0D;IAExE,MAAM,CAAC,WAAW,SAC2F;IAE7G,OAAc,cAAc,UAAQ;IAEvB,GAAG;;;CAgBnB"}
1
+ {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/commands/hash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,mBAAmB,YAAa,OAAO,SAuBnD,CAAC"}
@@ -1,22 +1,22 @@
1
1
  import chalk from "chalk";
2
- import { BaseCommand } from "../baseCommand.js";
3
- class HashCommand extends BaseCommand {
4
- async run() {
5
- const hash = this.getMachineHash();
2
+ import { getMachineHash } from "../base.js";
3
+ export const registerHashCommand = (program) => {
4
+ program
5
+ .command("hash")
6
+ .description("Converts the binary generated by the build command to hexadecimal and prints out the result to console.")
7
+ .option("--json", "Format output as json.")
8
+ .action(async ({ json }, command) => {
9
+ const hash = getMachineHash();
6
10
  if (hash) {
7
- if (!this.jsonEnabled()) {
8
- process.stdout.write(`${chalk.green("?")} Cartesi machine templateHash ${chalk.cyan(hash)}\n`);
11
+ if (!json) {
12
+ console.log(`${chalk.green("?")} Cartesi machine templateHash ${chalk.cyan(hash)}\n`);
9
13
  }
10
14
  else {
11
- return { hash };
15
+ process.stdout.write(JSON.stringify({ hash }));
12
16
  }
13
17
  }
14
18
  else {
15
- this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
19
+ command.error(`Cartesi machine snapshot not found, run 'build'`);
16
20
  }
17
- }
18
- }
19
- HashCommand.summary = "Prints out image hash generated by the build command";
20
- HashCommand.description = "Converts the binary generated by the build command to hexadecimal and prints out the result to console";
21
- HashCommand.enableJsonFlag = true;
22
- export default HashCommand;
21
+ });
22
+ };
@@ -1,21 +1,3 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export default class Run extends BaseCommand<typeof Run> {
3
- static summary: string;
4
- static description: string;
5
- static examples: string[];
6
- static flags: {
7
- "block-time": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- "disable-explorer": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
- "disable-bundler": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
10
- "disable-paymaster": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
11
- "epoch-length": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
- "no-backend": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
13
- verbose: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
14
- "listen-port": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
15
- cpus: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
16
- memory: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
17
- "dry-run": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
18
- };
19
- run(): Promise<void>;
20
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const registerRunCommand: (program: Command) => void;
21
3
  //# sourceMappingURL=run.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,WAAW,CAAC,OAAO,GAAG,CAAC;IACpD,MAAM,CAAC,OAAO,SAA2B;IAEzC,MAAM,CAAC,WAAW,SAAmD;IAErE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;;;;;;;;;;;MAyDV;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAoJpC"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/commands/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAM9D,eAAO,MAAM,kBAAkB,YAAa,OAAO,SAyOlD,CAAC"}
@@ -1,54 +1,73 @@
1
- import { Flags } from "@oclif/core";
1
+ import { Option } from "@commander-js/extra-typings";
2
2
  import { execa } from "execa";
3
3
  import fs from "fs-extra";
4
4
  import path from "path";
5
- import { BaseCommand } from "../baseCommand.js";
6
- class Run extends BaseCommand {
7
- async run() {
8
- const { flags } = await this.parse(Run);
5
+ import { getMachineHash } from "../base.js";
6
+ export const registerRunCommand = (program) => {
7
+ program
8
+ .command("run")
9
+ .description("Run a local cartesi node for the application.")
10
+ .addOption(new Option("--block-time <number>", "interval between blocks (in seconds)")
11
+ .argParser(Number)
12
+ .default(5))
13
+ .addOption(new Option("--epoch-length <number>", "length of an epoch (in blocks)")
14
+ .argParser(Number)
15
+ .default(720))
16
+ .option("--disable-explorer", "disable local explorer service to save machine resources", false)
17
+ .option("--disable-bundler", "disable local bundler service to save machine resources", false)
18
+ .option("--disable-paymaster", "disable local paymaster service to save machine resources", false)
19
+ .option("--enable-espresso", "enable espresso development node", false)
20
+ .option("--no-backend", "run a node without the application code", false)
21
+ .option("-v, --verbose", "verbose output", false)
22
+ .addOption(new Option("--port <number>", "port to listen for incoming connections")
23
+ .argParser(Number)
24
+ .default(8080))
25
+ .addOption(new Option("--cpus <number>", "number of cpu limits for the rollups-node").argParser(Number))
26
+ .addOption(new Option("--memory <number>", "memory limit for the rollups-node in MB").argParser(Number))
27
+ .option("--dry-run", "show the docker compose configuration", false)
28
+ .action(async ({ blockTime, epochLength, disableExplorer, disableBundler, disablePaymaster, enableEspresso, backend, verbose, port, dryRun, cpus, memory, }) => {
9
29
  let projectName;
10
- if (flags["no-backend"]) {
30
+ if (backend) {
11
31
  projectName = "cartesi-node";
12
32
  }
13
33
  else {
14
34
  // get machine hash
15
- const hash = this.getMachineHash();
35
+ const hash = getMachineHash();
16
36
  // Check if snapshot exists
17
37
  if (!hash) {
18
- throw new Error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
38
+ throw new Error(`Cartesi machine snapshot not found, run 'build'`);
19
39
  }
20
40
  projectName = hash.substring(2, 10);
21
41
  }
22
42
  // path of the tool instalation
23
43
  const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..");
24
44
  // setup the environment variable used in docker compose
25
- const blockInterval = flags["block-time"];
26
- const epochLength = flags["epoch-length"];
27
- const listenPort = flags["listen-port"];
45
+ const blockInterval = blockTime;
46
+ const listenPort = port;
28
47
  const env = {
29
- ANVIL_VERBOSITY: flags.verbose ? "--steps-tracing" : "--silent",
48
+ ANVIL_VERBOSITY: verbose ? "--steps-tracing" : "--silent",
30
49
  BLOCK_TIME: blockInterval.toString(),
31
50
  BLOCK_TIMEOUT: (blockInterval + 3).toString(),
32
51
  CARTESI_EPOCH_LENGTH: epochLength.toString(),
33
- CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG: flags.verbose
52
+ CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG: verbose
34
53
  ? "false"
35
54
  : "true",
36
- CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG: flags.verbose
55
+ CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG: verbose
37
56
  ? "false"
38
57
  : "true",
39
- CARTESI_LOG_LEVEL: flags.verbose ? "info" : "error",
58
+ CARTESI_LOG_LEVEL: verbose ? "info" : "error",
40
59
  CARTESI_SNAPSHOT_DIR: "/usr/share/rollups-node/snapshot",
41
60
  CARTESI_BIN_PATH: binPath,
42
61
  CARTESI_LISTEN_PORT: listenPort.toString(),
43
- CARTESI_VALIDATOR_CPUS: flags.cpus?.toString(),
44
- CARTESI_VALIDATOR_MEMORY: flags.memory?.toString(),
62
+ CARTESI_VALIDATOR_CPUS: cpus?.toString(),
63
+ CARTESI_VALIDATOR_MEMORY: memory?.toString(),
45
64
  };
46
65
  // validator
47
66
  const composeFiles = ["docker-compose-validator.yaml"];
48
- if (flags.cpus) {
67
+ if (cpus) {
49
68
  composeFiles.push("docker-compose-validator-cpus.yaml");
50
69
  }
51
- if (flags.memory) {
70
+ if (memory) {
52
71
  composeFiles.push("docker-compose-validator-memory.yaml");
53
72
  }
54
73
  // prompt
@@ -60,19 +79,23 @@ class Run extends BaseCommand {
60
79
  // anvil
61
80
  composeFiles.push("docker-compose-anvil.yaml");
62
81
  // explorer
63
- if (!flags["disable-explorer"]) {
82
+ if (!disableExplorer) {
64
83
  composeFiles.push("docker-compose-explorer.yaml");
65
84
  }
66
85
  // account abstraction
67
- if (!flags["disable-bundler"]) {
86
+ if (!disableBundler) {
68
87
  composeFiles.push("docker-compose-bundler.yaml");
69
88
  }
70
- if (!flags["disable-paymaster"] && !flags["disable-bundler"]) {
89
+ if (!disablePaymaster && !disableBundler) {
71
90
  // only add paymaster if bundler is enabled
72
91
  composeFiles.push("docker-compose-paymaster.yaml");
73
92
  }
93
+ // espresso development node
94
+ if (enableEspresso) {
95
+ composeFiles.push("docker-compose-espresso.yaml");
96
+ }
74
97
  // load the no-backend compose file
75
- if (flags["no-backend"]) {
98
+ if (backend) {
76
99
  composeFiles.push("docker-compose-host.yaml");
77
100
  }
78
101
  else {
@@ -96,7 +119,7 @@ class Run extends BaseCommand {
96
119
  projectName,
97
120
  ];
98
121
  const up_args = [];
99
- if (!flags.verbose) {
122
+ if (!verbose) {
100
123
  compose_args.push("--progress", "quiet");
101
124
  up_args.push("--attach", "validator");
102
125
  up_args.push("--attach", "prompt");
@@ -104,7 +127,7 @@ class Run extends BaseCommand {
104
127
  // XXX: need this handler, so SIGINT can still call the finally block below
105
128
  process.on("SIGINT", () => { });
106
129
  try {
107
- if (flags["dry-run"]) {
130
+ if (dryRun) {
108
131
  // show the docker compose configuration
109
132
  await execa("docker", [...compose_args, "config"], {
110
133
  env,
@@ -131,61 +154,5 @@ class Run extends BaseCommand {
131
154
  stdio: "inherit",
132
155
  });
133
156
  }
134
- }
135
- }
136
- Run.summary = "Run application node.";
137
- Run.description = "Run a local cartesi node for the application.";
138
- Run.examples = ["<%= config.bin %> <%= command.id %>"];
139
- Run.flags = {
140
- "block-time": Flags.integer({
141
- description: "interval between blocks (in seconds)",
142
- default: 5,
143
- }),
144
- "disable-explorer": Flags.boolean({
145
- default: false,
146
- description: "disable local explorer service to save machine resources",
147
- summary: "disable explorer service",
148
- }),
149
- "disable-bundler": Flags.boolean({
150
- default: false,
151
- description: "disable local bundler service to save machine resources",
152
- summary: "disable bundler service",
153
- }),
154
- "disable-paymaster": Flags.boolean({
155
- default: false,
156
- description: "disable local paymaster service to save machine resources",
157
- summary: "disable paymaster service",
158
- }),
159
- "epoch-length": Flags.integer({
160
- description: "length of an epoch (in blocks)",
161
- default: 720,
162
- }),
163
- "no-backend": Flags.boolean({
164
- description: "Run a node without the application code. Application must be executed by the developer on the host machine, fetching inputs from the node running at http://localhost:5004",
165
- summary: "run a node without the application code",
166
- default: false,
167
- }),
168
- verbose: Flags.boolean({
169
- description: "verbose output",
170
- default: false,
171
- char: "v",
172
- }),
173
- "listen-port": Flags.integer({
174
- description: "port to listen for incoming connections",
175
- default: 8080,
176
- }),
177
- cpus: Flags.integer({
178
- description: "Define the number of CPUs to use (eg.: 1) for the rollups-node",
179
- summary: "number of cpu limits for the rollups-node",
180
- }),
181
- memory: Flags.integer({
182
- description: "Define the amount of memory to use for the rollups-node in MB (eg.: 1024)",
183
- summary: "memory limit for the rollups-node in MB",
184
- }),
185
- "dry-run": Flags.boolean({
186
- description: "show the docker compose configuration",
187
- default: false,
188
- hidden: true,
189
- }),
157
+ });
190
158
  };
191
- export default Run;
@@ -1,14 +1,3 @@
1
- import { Address, PublicClient, WalletClient } from "viem";
2
- import { SendBaseCommand } from "./index.js";
3
- export default class SendERC20 extends SendBaseCommand<typeof SendERC20> {
4
- static summary: string;
5
- static description: string;
6
- static flags: {
7
- token: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`0x${string}` | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- amount: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`${number}` | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- };
10
- static examples: string[];
11
- private readToken;
12
- send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
13
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const registerErc20Command: (program: Command) => void;
14
3
  //# sourceMappingURL=erc20.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc20.ts"],"names":[],"mappings":"AACA,OAAO,EACH,OAAO,EAIP,YAAY,EACZ,YAAY,EACf,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQ7C,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,eAAe,CAAC,OAAO,SAAS,CAAC;IACpE,MAAM,CAAC,OAAO,SAA6C;IAE3D,MAAM,CAAC,WAAW,SAC8D;IAEhF,MAAM,CAAC,KAAK;;;MAGV;IAEF,MAAM,CAAC,QAAQ,WAA2C;YAE5C,SAAS;IAwBV,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CA2CtB"}
1
+ {"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc20.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AA8DtD,eAAO,MAAM,oBAAoB,YAAa,OAAO,SA8CpD,CAAC"}