@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.
- package/dist/base.d.ts +14 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +77 -0
- package/dist/commands/address-book.d.ts +2 -8
- package/dist/commands/address-book.d.ts.map +1 -1
- package/dist/commands/address-book.js +15 -14
- package/dist/commands/build.d.ts +2 -11
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +16 -28
- package/dist/commands/clean.d.ts +2 -7
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +9 -10
- package/dist/commands/create.d.ts +2 -14
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +37 -51
- package/dist/commands/deploy/build.d.ts +2 -14
- package/dist/commands/deploy/build.d.ts.map +1 -1
- package/dist/commands/deploy/build.js +41 -47
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/{deploy/index.js → deploy.js} +26 -28
- package/dist/commands/doctor.d.ts +2 -12
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +83 -90
- package/dist/commands/hash.d.ts +2 -9
- package/dist/commands/hash.d.ts.map +1 -1
- package/dist/commands/hash.js +14 -14
- package/dist/commands/run.d.ts +2 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +49 -82
- package/dist/commands/send/erc20.d.ts +2 -13
- package/dist/commands/send/erc20.d.ts.map +1 -1
- package/dist/commands/send/erc20.js +55 -52
- package/dist/commands/send/erc721.d.ts +2 -13
- package/dist/commands/send/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +49 -46
- package/dist/commands/send/ether.d.ts +2 -12
- package/dist/commands/send/ether.d.ts.map +1 -1
- package/dist/commands/send/ether.js +23 -21
- package/dist/commands/send/generic.d.ts +2 -14
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +91 -97
- package/dist/commands/send.d.ts +21 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +67 -0
- package/dist/commands/shell.d.ts +2 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +21 -43
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -1
- package/dist/node/docker-compose-anvil.yaml +2 -2
- package/dist/node/docker-compose-bundler.yaml +1 -1
- package/dist/node/docker-compose-database.yaml +1 -1
- package/dist/node/docker-compose-espresso.yaml +127 -0
- package/dist/node/docker-compose-explorer.yaml +1 -1
- package/dist/node/docker-compose-paymaster.yaml +1 -1
- package/package.json +8 -27
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -25
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -8
- package/dist/baseCommand.d.ts +0 -22
- package/dist/baseCommand.d.ts.map +0 -1
- package/dist/baseCommand.js +0 -92
- package/dist/commands/deploy/index.d.ts +0 -12
- package/dist/commands/deploy/index.d.ts.map +0 -1
- package/dist/commands/send/index.d.ts +0 -28
- package/dist/commands/send/index.d.ts.map +0 -1
- package/dist/commands/send/index.js +0 -102
- package/dist/flags.d.ts +0 -17
- package/dist/flags.d.ts.map +0 -1
- package/dist/flags.js +0 -28
- 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 {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 =
|
|
19
|
+
const templateHash = getMachineHash();
|
|
12
20
|
if (!templateHash) {
|
|
13
|
-
|
|
21
|
+
command.error(`Cartesi machine snapshot not found, run 'build'`);
|
|
22
|
+
return;
|
|
14
23
|
}
|
|
15
|
-
|
|
24
|
+
logPrompt({
|
|
16
25
|
title: "Cartesi machine templateHash",
|
|
17
26
|
value: templateHash,
|
|
18
27
|
});
|
|
19
28
|
// ask for deployment type
|
|
20
|
-
const 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
|
-
|
|
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
|
-
|
|
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 = `${
|
|
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 {
|
|
2
|
-
export
|
|
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":"
|
|
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"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -1,106 +1,99 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
2
|
import semver from "semver";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
84
|
+
return true;
|
|
85
|
+
};
|
|
86
|
+
export const registerDoctorCommand = (program) => {
|
|
87
|
+
program.command("doctor").action(async (_, command) => {
|
|
89
88
|
try {
|
|
90
|
-
if (await
|
|
91
|
-
await
|
|
92
|
-
await
|
|
89
|
+
if (await checkDocker()) {
|
|
90
|
+
await checkCompose();
|
|
91
|
+
await checkBuildx();
|
|
93
92
|
}
|
|
94
93
|
}
|
|
95
94
|
catch (e) {
|
|
96
|
-
|
|
95
|
+
command.error(e.message);
|
|
97
96
|
}
|
|
98
|
-
|
|
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
|
+
};
|
package/dist/commands/hash.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
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":"
|
|
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"}
|
package/dist/commands/hash.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import chalk from "chalk";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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 (!
|
|
8
|
-
|
|
11
|
+
if (!json) {
|
|
12
|
+
console.log(`${chalk.green("?")} Cartesi machine templateHash ${chalk.cyan(hash)}\n`);
|
|
9
13
|
}
|
|
10
14
|
else {
|
|
11
|
-
|
|
15
|
+
process.stdout.write(JSON.stringify({ hash }));
|
|
12
16
|
}
|
|
13
17
|
}
|
|
14
18
|
else {
|
|
15
|
-
|
|
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
|
+
};
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -1,21 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
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":"
|
|
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"}
|
package/dist/commands/run.js
CHANGED
|
@@ -1,54 +1,73 @@
|
|
|
1
|
-
import {
|
|
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 {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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 (
|
|
30
|
+
if (backend) {
|
|
11
31
|
projectName = "cartesi-node";
|
|
12
32
|
}
|
|
13
33
|
else {
|
|
14
34
|
// get machine hash
|
|
15
|
-
const hash =
|
|
35
|
+
const hash = getMachineHash();
|
|
16
36
|
// Check if snapshot exists
|
|
17
37
|
if (!hash) {
|
|
18
|
-
throw new Error(`Cartesi machine snapshot not found, run '
|
|
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 =
|
|
26
|
-
const
|
|
27
|
-
const listenPort = flags["listen-port"];
|
|
45
|
+
const blockInterval = blockTime;
|
|
46
|
+
const listenPort = port;
|
|
28
47
|
const env = {
|
|
29
|
-
ANVIL_VERBOSITY:
|
|
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:
|
|
52
|
+
CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG: verbose
|
|
34
53
|
? "false"
|
|
35
54
|
: "true",
|
|
36
|
-
CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG:
|
|
55
|
+
CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG: verbose
|
|
37
56
|
? "false"
|
|
38
57
|
: "true",
|
|
39
|
-
CARTESI_LOG_LEVEL:
|
|
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:
|
|
44
|
-
CARTESI_VALIDATOR_MEMORY:
|
|
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 (
|
|
67
|
+
if (cpus) {
|
|
49
68
|
composeFiles.push("docker-compose-validator-cpus.yaml");
|
|
50
69
|
}
|
|
51
|
-
if (
|
|
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 (!
|
|
82
|
+
if (!disableExplorer) {
|
|
64
83
|
composeFiles.push("docker-compose-explorer.yaml");
|
|
65
84
|
}
|
|
66
85
|
// account abstraction
|
|
67
|
-
if (!
|
|
86
|
+
if (!disableBundler) {
|
|
68
87
|
composeFiles.push("docker-compose-bundler.yaml");
|
|
69
88
|
}
|
|
70
|
-
if (!
|
|
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 (
|
|
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 (!
|
|
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 (
|
|
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 {
|
|
2
|
-
|
|
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":"
|
|
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"}
|