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

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 (131) hide show
  1. package/dist/index.js +704 -1
  2. package/dist/index.js.map +791 -0
  3. package/package.json +77 -101
  4. package/LICENSE +0 -202
  5. package/bin/dev.cmd +0 -3
  6. package/bin/dev.js +0 -25
  7. package/bin/run.cmd +0 -3
  8. package/bin/run.js +0 -8
  9. package/dist/baseCommand.d.ts +0 -22
  10. package/dist/baseCommand.d.ts.map +0 -1
  11. package/dist/baseCommand.js +0 -92
  12. package/dist/builder/directory.d.ts +0 -3
  13. package/dist/builder/directory.d.ts.map +0 -1
  14. package/dist/builder/directory.js +0 -37
  15. package/dist/builder/docker.d.ts +0 -10
  16. package/dist/builder/docker.d.ts.map +0 -1
  17. package/dist/builder/docker.js +0 -112
  18. package/dist/builder/empty.d.ts +0 -3
  19. package/dist/builder/empty.d.ts.map +0 -1
  20. package/dist/builder/empty.js +0 -21
  21. package/dist/builder/index.d.ts +0 -6
  22. package/dist/builder/index.d.ts.map +0 -1
  23. package/dist/builder/index.js +0 -5
  24. package/dist/builder/none.d.ts +0 -3
  25. package/dist/builder/none.d.ts.map +0 -1
  26. package/dist/builder/none.js +0 -11
  27. package/dist/builder/tar.d.ts +0 -3
  28. package/dist/builder/tar.d.ts.map +0 -1
  29. package/dist/builder/tar.js +0 -30
  30. package/dist/commands/address-book.d.ts +0 -9
  31. package/dist/commands/address-book.d.ts.map +0 -1
  32. package/dist/commands/address-book.js +0 -40
  33. package/dist/commands/build.d.ts +0 -12
  34. package/dist/commands/build.d.ts.map +0 -1
  35. package/dist/commands/build.js +0 -73
  36. package/dist/commands/clean.d.ts +0 -8
  37. package/dist/commands/clean.d.ts.map +0 -1
  38. package/dist/commands/clean.js +0 -11
  39. package/dist/commands/create.d.ts +0 -16
  40. package/dist/commands/create.d.ts.map +0 -1
  41. package/dist/commands/create.js +0 -66
  42. package/dist/commands/deploy/build.d.ts +0 -15
  43. package/dist/commands/deploy/build.d.ts.map +0 -1
  44. package/dist/commands/deploy/build.js +0 -62
  45. package/dist/commands/deploy/index.d.ts +0 -12
  46. package/dist/commands/deploy/index.d.ts.map +0 -1
  47. package/dist/commands/deploy/index.js +0 -78
  48. package/dist/commands/doctor.d.ts +0 -13
  49. package/dist/commands/doctor.d.ts.map +0 -1
  50. package/dist/commands/doctor.js +0 -106
  51. package/dist/commands/hash.d.ts +0 -10
  52. package/dist/commands/hash.d.ts.map +0 -1
  53. package/dist/commands/hash.js +0 -22
  54. package/dist/commands/run.d.ts +0 -21
  55. package/dist/commands/run.d.ts.map +0 -1
  56. package/dist/commands/run.js +0 -191
  57. package/dist/commands/send/erc20.d.ts +0 -14
  58. package/dist/commands/send/erc20.d.ts.map +0 -1
  59. package/dist/commands/send/erc20.js +0 -70
  60. package/dist/commands/send/erc721.d.ts +0 -14
  61. package/dist/commands/send/erc721.d.ts.map +0 -1
  62. package/dist/commands/send/erc721.js +0 -73
  63. package/dist/commands/send/ether.d.ts +0 -13
  64. package/dist/commands/send/ether.d.ts.map +0 -1
  65. package/dist/commands/send/ether.js +0 -32
  66. package/dist/commands/send/generic.d.ts +0 -15
  67. package/dist/commands/send/generic.d.ts.map +0 -1
  68. package/dist/commands/send/generic.js +0 -119
  69. package/dist/commands/send/index.d.ts +0 -28
  70. package/dist/commands/send/index.d.ts.map +0 -1
  71. package/dist/commands/send/index.js +0 -102
  72. package/dist/commands/shell.d.ts +0 -15
  73. package/dist/commands/shell.d.ts.map +0 -1
  74. package/dist/commands/shell.js +0 -65
  75. package/dist/config.d.ts +0 -102
  76. package/dist/config.d.ts.map +0 -1
  77. package/dist/config.js +0 -367
  78. package/dist/contracts.d.ts +0 -4317
  79. package/dist/contracts.d.ts.map +0 -1
  80. package/dist/contracts.js +0 -1799
  81. package/dist/exec/cartesi-machine.d.ts +0 -9
  82. package/dist/exec/cartesi-machine.d.ts.map +0 -1
  83. package/dist/exec/cartesi-machine.js +0 -20
  84. package/dist/exec/crane.d.ts +0 -15
  85. package/dist/exec/crane.d.ts.map +0 -1
  86. package/dist/exec/crane.js +0 -17
  87. package/dist/exec/genext2fs.d.ts +0 -28
  88. package/dist/exec/genext2fs.d.ts.map +0 -1
  89. package/dist/exec/genext2fs.js +0 -44
  90. package/dist/exec/index.d.ts +0 -5
  91. package/dist/exec/index.d.ts.map +0 -1
  92. package/dist/exec/index.js +0 -4
  93. package/dist/exec/mksquashfs.d.ts +0 -21
  94. package/dist/exec/mksquashfs.d.ts.map +0 -1
  95. package/dist/exec/mksquashfs.js +0 -45
  96. package/dist/exec/util.d.ts +0 -36
  97. package/dist/exec/util.d.ts.map +0 -1
  98. package/dist/exec/util.js +0 -80
  99. package/dist/flags.d.ts +0 -17
  100. package/dist/flags.d.ts.map +0 -1
  101. package/dist/flags.js +0 -28
  102. package/dist/index.d.ts +0 -2
  103. package/dist/index.d.ts.map +0 -1
  104. package/dist/machine.d.ts +0 -6
  105. package/dist/machine.d.ts.map +0 -1
  106. package/dist/machine.js +0 -80
  107. package/dist/node/DockerfileDeploy.txt +0 -4
  108. package/dist/node/default.env +0 -27
  109. package/dist/node/docker-compose-anvil.yaml +0 -50
  110. package/dist/node/docker-compose-bundler.yaml +0 -57
  111. package/dist/node/docker-compose-database.yaml +0 -10
  112. package/dist/node/docker-compose-envfile.yaml +0 -4
  113. package/dist/node/docker-compose-explorer.yaml +0 -88
  114. package/dist/node/docker-compose-host.yaml +0 -30
  115. package/dist/node/docker-compose-paymaster.yaml +0 -33
  116. package/dist/node/docker-compose-prompt.yaml +0 -17
  117. package/dist/node/docker-compose-proxy.yaml +0 -48
  118. package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
  119. package/dist/node/docker-compose-validator-cpus.yaml +0 -6
  120. package/dist/node/docker-compose-validator-memory.yaml +0 -6
  121. package/dist/node/docker-compose-validator.yaml +0 -59
  122. package/dist/prompts.d.ts +0 -62
  123. package/dist/prompts.d.ts.map +0 -1
  124. package/dist/prompts.js +0 -158
  125. package/dist/types/docker.d.ts +0 -22
  126. package/dist/types/docker.d.ts.map +0 -1
  127. package/dist/types/docker.js +0 -1
  128. package/dist/wallet.d.ts +0 -24
  129. package/dist/wallet.d.ts.map +0 -1
  130. package/dist/wallet.js +0 -204
  131. package/oclif.manifest.json +0 -876
@@ -1,78 +0,0 @@
1
- import confirm from "@inquirer/confirm";
2
- import select from "@inquirer/select";
3
- import { Flags } from "@oclif/core";
4
- import chalk from "chalk";
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);
10
- // print machine hash
11
- const templateHash = this.getMachineHash();
12
- if (!templateHash) {
13
- this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
14
- }
15
- this.logPrompt({
16
- title: "Cartesi machine templateHash",
17
- value: templateHash,
18
- });
19
- // ask for deployment type
20
- const hosting = flags.hosting ||
21
- (await select({
22
- message: "Select hosting type",
23
- choices: [
24
- {
25
- name: "Self-hosting",
26
- description: `Select this option if you want to run the node for your application.
27
- You will need the following infrastructure:
28
-
29
- - a cloud server for the application node
30
- - a postgres database
31
- - a web3 node provider
32
- - a funded wallet
33
- `,
34
- value: "self-hosted",
35
- },
36
- {
37
- name: "Use third-party provider",
38
- description: "Select this option to use a third-party service provider to run a node for your application.",
39
- value: "third-party",
40
- disabled: "(coming soon)",
41
- },
42
- ],
43
- }));
44
- let queryString = "";
45
- switch (hosting) {
46
- case "self-hosted": {
47
- // build docker image
48
- await this.config.runCommand("deploy:build");
49
- queryString = `?templateHash=${templateHash}`;
50
- break;
51
- }
52
- case "third-party": {
53
- this.error("Third-party provider deployment not supported yet");
54
- }
55
- }
56
- // prompt user to open webapp for onchain deployment
57
- const deployUrl = `${flags.webapp}${queryString}`;
58
- if (await confirm({ message: `Open ${chalk.cyan(deployUrl)}?` })) {
59
- open(deployUrl, { app: { name: apps.chrome } });
60
- }
61
- 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
- }),
77
- };
78
- export default Deploy;
@@ -1,13 +0,0 @@
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
- }
13
- //# sourceMappingURL=doctor.d.ts.map
@@ -1 +0,0 @@
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,106 +0,0 @@
1
- import { execa } from "execa";
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
- }
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;
25
- }
26
- }
27
- return true;
28
- }
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
- }
41
- }
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
- }
50
- }
51
- return true;
52
- }
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
- }
76
- }
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
- }
85
- }
86
- return true;
87
- }
88
- async run() {
89
- try {
90
- if (await this.checkDocker()) {
91
- await this.checkCompose();
92
- await this.checkBuildx();
93
- }
94
- }
95
- catch (e) {
96
- this.error(e);
97
- }
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;
@@ -1,10 +0,0 @@
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
- }
10
- //# sourceMappingURL=hash.d.ts.map
@@ -1 +0,0 @@
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,22 +0,0 @@
1
- import chalk from "chalk";
2
- import { BaseCommand } from "../baseCommand.js";
3
- class HashCommand extends BaseCommand {
4
- async run() {
5
- const hash = this.getMachineHash();
6
- if (hash) {
7
- if (!this.jsonEnabled()) {
8
- process.stdout.write(`${chalk.green("?")} Cartesi machine templateHash ${chalk.cyan(hash)}\n`);
9
- }
10
- else {
11
- return { hash };
12
- }
13
- }
14
- else {
15
- this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
16
- }
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;
@@ -1,21 +0,0 @@
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
- }
21
- //# sourceMappingURL=run.d.ts.map
@@ -1 +0,0 @@
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,191 +0,0 @@
1
- import { Flags } from "@oclif/core";
2
- import { execa } from "execa";
3
- import fs from "fs-extra";
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);
9
- let projectName;
10
- if (flags["no-backend"]) {
11
- projectName = "cartesi-node";
12
- }
13
- else {
14
- // get machine hash
15
- const hash = this.getMachineHash();
16
- // Check if snapshot exists
17
- if (!hash) {
18
- throw new Error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
19
- }
20
- projectName = hash.substring(2, 10);
21
- }
22
- // path of the tool instalation
23
- const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..");
24
- // 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"];
28
- const env = {
29
- ANVIL_VERBOSITY: flags.verbose ? "--steps-tracing" : "--silent",
30
- BLOCK_TIME: blockInterval.toString(),
31
- BLOCK_TIMEOUT: (blockInterval + 3).toString(),
32
- CARTESI_EPOCH_LENGTH: epochLength.toString(),
33
- CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG: flags.verbose
34
- ? "false"
35
- : "true",
36
- CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG: flags.verbose
37
- ? "false"
38
- : "true",
39
- CARTESI_LOG_LEVEL: flags.verbose ? "info" : "error",
40
- CARTESI_SNAPSHOT_DIR: "/usr/share/rollups-node/snapshot",
41
- CARTESI_BIN_PATH: binPath,
42
- CARTESI_LISTEN_PORT: listenPort.toString(),
43
- CARTESI_VALIDATOR_CPUS: flags.cpus?.toString(),
44
- CARTESI_VALIDATOR_MEMORY: flags.memory?.toString(),
45
- };
46
- // validator
47
- const composeFiles = ["docker-compose-validator.yaml"];
48
- if (flags.cpus) {
49
- composeFiles.push("docker-compose-validator-cpus.yaml");
50
- }
51
- if (flags.memory) {
52
- composeFiles.push("docker-compose-validator-memory.yaml");
53
- }
54
- // prompt
55
- composeFiles.push("docker-compose-prompt.yaml");
56
- // database
57
- composeFiles.push("docker-compose-database.yaml");
58
- // proxy
59
- composeFiles.push("docker-compose-proxy.yaml");
60
- // anvil
61
- composeFiles.push("docker-compose-anvil.yaml");
62
- // explorer
63
- if (!flags["disable-explorer"]) {
64
- composeFiles.push("docker-compose-explorer.yaml");
65
- }
66
- // account abstraction
67
- if (!flags["disable-bundler"]) {
68
- composeFiles.push("docker-compose-bundler.yaml");
69
- }
70
- if (!flags["disable-paymaster"] && !flags["disable-bundler"]) {
71
- // only add paymaster if bundler is enabled
72
- composeFiles.push("docker-compose-paymaster.yaml");
73
- }
74
- // load the no-backend compose file
75
- if (flags["no-backend"]) {
76
- composeFiles.push("docker-compose-host.yaml");
77
- }
78
- else {
79
- // snapshot volume
80
- composeFiles.push("docker-compose-snapshot-volume.yaml");
81
- }
82
- // add project env file loading
83
- if (fs.existsSync("./.cartesi.env")) {
84
- composeFiles.push("docker-compose-envfile.yaml");
85
- }
86
- // create the "--file <file>" list
87
- const files = composeFiles
88
- .map((f) => ["--file", path.join(binPath, "node", f)])
89
- .flat();
90
- const compose_args = [
91
- "compose",
92
- ...files,
93
- "--project-directory",
94
- ".",
95
- "--project-name",
96
- projectName,
97
- ];
98
- const up_args = [];
99
- if (!flags.verbose) {
100
- compose_args.push("--progress", "quiet");
101
- up_args.push("--attach", "validator");
102
- up_args.push("--attach", "prompt");
103
- }
104
- // XXX: need this handler, so SIGINT can still call the finally block below
105
- process.on("SIGINT", () => { });
106
- try {
107
- if (flags["dry-run"]) {
108
- // show the docker compose configuration
109
- await execa("docker", [...compose_args, "config"], {
110
- env,
111
- stdio: "inherit",
112
- });
113
- return;
114
- }
115
- // run compose environment
116
- await execa("docker", [...compose_args, "up", ...up_args], {
117
- env,
118
- stdio: "inherit",
119
- });
120
- }
121
- catch (e) {
122
- // 130 is a graceful shutdown, so we can swallow it
123
- if (e.exitCode !== 130) {
124
- throw e;
125
- }
126
- }
127
- finally {
128
- // shut it down, including volumes
129
- await execa("docker", [...compose_args, "down", "--volumes"], {
130
- env,
131
- stdio: "inherit",
132
- });
133
- }
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
- }),
190
- };
191
- export default Run;
@@ -1,14 +0,0 @@
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
- }
14
- //# sourceMappingURL=erc20.d.ts.map
@@ -1 +0,0 @@
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,70 +0,0 @@
1
- import input from "@inquirer/input";
2
- import { erc20Abi, isAddress, parseEther, } from "viem";
3
- import { erc20PortalAbi, erc20PortalAddress } from "../../contracts.js";
4
- import * as CustomFlags from "../../flags.js";
5
- import { SendBaseCommand } from "./index.js";
6
- class SendERC20 extends SendBaseCommand {
7
- async readToken(publicClient, address) {
8
- const args = { abi: erc20Abi, address };
9
- const symbol = await publicClient.readContract({
10
- ...args,
11
- functionName: "symbol",
12
- });
13
- const name = await publicClient.readContract({
14
- ...args,
15
- functionName: "name",
16
- });
17
- const decimals = await publicClient.readContract({
18
- ...args,
19
- functionName: "decimals",
20
- });
21
- return {
22
- name,
23
- symbol,
24
- decimals,
25
- };
26
- }
27
- async send(publicClient, walletClient) {
28
- // get dapp address from local node, or ask
29
- const applicationAddress = await super.getApplicationAddress();
30
- const ercValidator = async (value) => {
31
- if (!isAddress(value)) {
32
- return "Invalid address";
33
- }
34
- try {
35
- await this.readToken(publicClient, value);
36
- }
37
- catch (e) {
38
- return "Invalid token";
39
- }
40
- return true;
41
- };
42
- const tokenAddress = this.flags.token ||
43
- (await input({
44
- message: "Token address",
45
- validate: ercValidator,
46
- }));
47
- const amount = this.flags.amount || (await input({ message: "Amount" }));
48
- const { request } = await publicClient.simulateContract({
49
- address: erc20PortalAddress,
50
- abi: erc20PortalAbi,
51
- functionName: "depositERC20Tokens",
52
- args: [
53
- tokenAddress,
54
- applicationAddress,
55
- parseEther(amount),
56
- "0x",
57
- ],
58
- account: walletClient.account,
59
- });
60
- return walletClient.writeContract(request);
61
- }
62
- }
63
- SendERC20.summary = "Send ERC-20 deposit to the application.";
64
- SendERC20.description = "Sends ERC-20 deposits to the application, optionally in interactive mode.";
65
- SendERC20.flags = {
66
- token: CustomFlags.address({ description: "token address" }),
67
- amount: CustomFlags.number({ description: "amount" }),
68
- };
69
- SendERC20.examples = ["<%= config.bin %> <%= command.id %>"];
70
- export default SendERC20;
@@ -1,14 +0,0 @@
1
- import { Address, PublicClient, WalletClient } from "viem";
2
- import { SendBaseCommand } from "./index.js";
3
- export default class SendERC721 extends SendBaseCommand<typeof SendERC721> {
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
- tokenId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<bigint | 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
- }
14
- //# sourceMappingURL=erc721.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"erc721.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc721.ts"],"names":[],"mappings":"AACA,OAAO,EACH,OAAO,EAGP,YAAY,EACZ,YAAY,EACf,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAO7C,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,eAAe,CAAC,OAAO,UAAU,CAAC;IACtE,MAAM,CAAC,OAAO,SAA8C;IAE5D,MAAM,CAAC,WAAW,SAC+D;IAEjF,MAAM,CAAC,KAAK;;;MAGV;IAEF,MAAM,CAAC,QAAQ,WAA2C;YAE5C,SAAS;IAmBV,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CAkDtB"}
@@ -1,73 +0,0 @@
1
- import input from "@inquirer/input";
2
- import { erc721Abi, isAddress, } from "viem";
3
- import { erc721PortalAbi, erc721PortalAddress } from "../../contracts.js";
4
- import * as CustomFlags from "../../flags.js";
5
- import { SendBaseCommand } from "./index.js";
6
- class SendERC721 extends SendBaseCommand {
7
- async readToken(publicClient, address) {
8
- const args = { abi: erc721Abi, address };
9
- const symbol = await publicClient.readContract({
10
- ...args,
11
- functionName: "symbol",
12
- });
13
- const name = await publicClient.readContract({
14
- ...args,
15
- functionName: "name",
16
- });
17
- return {
18
- name,
19
- symbol,
20
- };
21
- }
22
- async send(publicClient, walletClient) {
23
- // get dapp address from local node, or ask
24
- const applicationAddress = await super.getApplicationAddress();
25
- const ercValidator = async (value) => {
26
- if (!isAddress(value)) {
27
- return "Invalid address";
28
- }
29
- try {
30
- await this.readToken(publicClient, value);
31
- }
32
- catch (e) {
33
- return "Invalid token";
34
- }
35
- return true;
36
- };
37
- const token = this.flags.token ||
38
- (await input({
39
- message: "Token address",
40
- validate: ercValidator,
41
- }));
42
- const tokenId = this.flags.tokenId ||
43
- (await input({
44
- message: "Token ID",
45
- validate: (value) => {
46
- try {
47
- BigInt(value);
48
- return true;
49
- }
50
- catch (e) {
51
- return "Invalid number";
52
- }
53
- },
54
- }));
55
- const { request } = await publicClient.simulateContract({
56
- address: erc721PortalAddress,
57
- abi: erc721PortalAbi,
58
- functionName: "depositERC721Token",
59
- args: [token, applicationAddress, BigInt(tokenId), "0x", "0x"],
60
- account: walletClient.account,
61
- });
62
- // XXX: add support for baseLayerData and execLayerData
63
- return walletClient.writeContract(request);
64
- }
65
- }
66
- SendERC721.summary = "Send ERC-721 deposit to the application.";
67
- SendERC721.description = "Sends ERC-721 deposits to the application, optionally in interactive mode.";
68
- SendERC721.flags = {
69
- token: CustomFlags.address({ description: "token address" }),
70
- tokenId: CustomFlags.bigint({ description: "token ID" }),
71
- };
72
- SendERC721.examples = ["<%= config.bin %> <%= command.id %>"];
73
- export default SendERC721;
@@ -1,13 +0,0 @@
1
- import { Address, PublicClient, WalletClient } from "viem";
2
- import { SendBaseCommand } from "./index.js";
3
- export default class SendEther extends SendBaseCommand<typeof SendEther> {
4
- static summary: string;
5
- static description: string;
6
- static flags: {
7
- amount: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`${number}` | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- execLayerData: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`0x${string}`, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- };
10
- static examples: string[];
11
- send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
12
- }
13
- //# sourceMappingURL=ether.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ether.d.ts","sourceRoot":"","sources":["../../../src/commands/send/ether.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAc,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIvE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,eAAe,CAAC,OAAO,SAAS,CAAC;IACpE,MAAM,CAAC,OAAO,SAA4C;IAE1D,MAAM,CAAC,WAAW,SAC6D;IAE/E,MAAM,CAAC,KAAK;;;MAMV;IAEF,MAAM,CAAC,QAAQ,WAA2C;IAE7C,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CAkBtB"}