@cartesi/cli 2.0.0-alpha.2 → 2.0.0-alpha.21
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 +28 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +109 -0
- package/dist/builder/directory.d.ts +2 -2
- package/dist/builder/directory.d.ts.map +1 -1
- package/dist/builder/directory.js +5 -3
- package/dist/builder/docker.d.ts +2 -2
- package/dist/builder/docker.d.ts.map +1 -1
- package/dist/builder/docker.js +39 -37
- package/dist/builder/empty.d.ts +1 -1
- package/dist/builder/empty.d.ts.map +1 -1
- package/dist/builder/empty.js +1 -1
- package/dist/builder/none.d.ts +1 -1
- package/dist/builder/none.d.ts.map +1 -1
- package/dist/builder/none.js +1 -1
- package/dist/builder/tar.d.ts +1 -1
- package/dist/builder/tar.d.ts.map +1 -1
- package/dist/builder/tar.js +1 -1
- package/dist/commands/address-book.d.ts +5 -8
- package/dist/commands/address-book.d.ts.map +1 -1
- package/dist/commands/address-book.js +18 -14
- package/dist/commands/build.d.ts +7 -11
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +82 -58
- 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 +6 -15
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +25 -54
- 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 +8 -61
- package/dist/commands/deploy.d.ts +3 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +12 -0
- package/dist/commands/deposit/erc1155.d.ts +18 -0
- package/dist/commands/deposit/erc1155.d.ts.map +1 -0
- package/dist/commands/deposit/erc1155.js +254 -0
- package/dist/commands/deposit/erc20.d.ts +10 -0
- package/dist/commands/deposit/erc20.d.ts.map +1 -0
- package/dist/commands/deposit/erc20.js +125 -0
- package/dist/commands/deposit/erc721.d.ts +10 -0
- package/dist/commands/deposit/erc721.d.ts.map +1 -0
- package/dist/commands/deposit/erc721.js +143 -0
- package/dist/commands/deposit/ether.d.ts +10 -0
- package/dist/commands/deposit/ether.d.ts.map +1 -0
- package/dist/commands/deposit/ether.js +65 -0
- package/dist/commands/deposit.d.ts +9 -0
- package/dist/commands/deposit.d.ts.map +1 -0
- package/dist/commands/deposit.js +37 -0
- package/dist/commands/doctor.d.ts +2 -12
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +90 -91
- package/dist/commands/hash.d.ts +4 -9
- package/dist/commands/hash.d.ts.map +1 -1
- package/dist/commands/hash.js +14 -14
- package/dist/commands/logs.d.ts +9 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +34 -0
- package/dist/commands/run.d.ts +14 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +193 -182
- package/dist/commands/send.d.ts +10 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +130 -0
- package/dist/commands/shell.d.ts +6 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +34 -51
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +50 -0
- package/dist/compose/default.env +36 -0
- package/dist/compose/docker-compose-anvil.yaml +39 -0
- package/dist/compose/docker-compose-bundler.yaml +71 -0
- package/dist/{node → compose}/docker-compose-database.yaml +4 -2
- package/dist/compose/docker-compose-explorer.yaml +96 -0
- package/dist/compose/docker-compose-node-cpus.yaml +6 -0
- package/dist/compose/docker-compose-node-memory.yaml +6 -0
- package/dist/compose/docker-compose-node.yaml +50 -0
- package/dist/compose/docker-compose-passkey-server.yaml +37 -0
- package/dist/compose/docker-compose-paymaster.yaml +40 -0
- package/dist/compose/docker-compose-proxy.yaml +24 -0
- package/dist/config.d.ts +30 -9
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +93 -53
- package/dist/contracts.d.ts +1695 -1636
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +632 -592
- package/dist/exec/cartesi-machine.d.ts +2 -2
- package/dist/exec/cartesi-machine.d.ts.map +1 -1
- package/dist/exec/cartesi-machine.js +3 -5
- package/dist/exec/genext2fs.d.ts +6 -3
- package/dist/exec/genext2fs.d.ts.map +1 -1
- package/dist/exec/genext2fs.js +5 -5
- package/dist/exec/index.d.ts +0 -1
- package/dist/exec/index.d.ts.map +1 -1
- package/dist/exec/index.js +0 -1
- package/dist/exec/mksquashfs.d.ts +2 -2
- package/dist/exec/mksquashfs.d.ts.map +1 -1
- package/dist/exec/mksquashfs.js +4 -2
- package/dist/exec/rollups.d.ts +105 -0
- package/dist/exec/rollups.d.ts.map +1 -0
- package/dist/exec/rollups.js +375 -0
- package/dist/exec/util.d.ts +1 -16
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +3 -50
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -1
- package/dist/machine.d.ts +8 -2
- package/dist/machine.d.ts.map +1 -1
- package/dist/machine.js +26 -16
- package/dist/prompts.d.ts +13 -2
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +60 -26
- package/dist/template.d.ts +3 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +16 -0
- package/dist/wallet.d.ts +9222 -21
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +35 -198
- package/package.json +39 -57
- 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/deploy/index.js +0 -78
- package/dist/commands/send/erc20.d.ts +0 -14
- package/dist/commands/send/erc20.d.ts.map +0 -1
- package/dist/commands/send/erc20.js +0 -70
- package/dist/commands/send/erc721.d.ts +0 -14
- package/dist/commands/send/erc721.d.ts.map +0 -1
- package/dist/commands/send/erc721.js +0 -73
- package/dist/commands/send/ether.d.ts +0 -13
- package/dist/commands/send/ether.d.ts.map +0 -1
- package/dist/commands/send/ether.js +0 -32
- package/dist/commands/send/generic.d.ts +0 -15
- package/dist/commands/send/generic.d.ts.map +0 -1
- package/dist/commands/send/generic.js +0 -119
- 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/exec/crane.d.ts +0 -15
- package/dist/exec/crane.d.ts.map +0 -1
- package/dist/exec/crane.js +0 -17
- package/dist/flags.d.ts +0 -17
- package/dist/flags.d.ts.map +0 -1
- package/dist/flags.js +0 -28
- package/dist/node/DockerfileDeploy.txt +0 -4
- package/dist/node/default.env +0 -27
- package/dist/node/docker-compose-anvil.yaml +0 -50
- package/dist/node/docker-compose-bundler.yaml +0 -57
- package/dist/node/docker-compose-envfile.yaml +0 -4
- package/dist/node/docker-compose-explorer.yaml +0 -88
- package/dist/node/docker-compose-host.yaml +0 -30
- package/dist/node/docker-compose-paymaster.yaml +0 -33
- package/dist/node/docker-compose-prompt.yaml +0 -17
- package/dist/node/docker-compose-proxy.yaml +0 -48
- package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
- package/dist/node/docker-compose-validator-cpus.yaml +0 -6
- package/dist/node/docker-compose-validator-memory.yaml +0 -6
- package/dist/node/docker-compose-validator.yaml +0 -59
- package/oclif.manifest.json +0 -876
|
@@ -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,iBAAiB;;MAsB7B,CAAC"}
|
package/dist/commands/hash.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
1
2
|
import chalk from "chalk";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { getMachineHash } from "../base.js";
|
|
4
|
+
export const createHashCommand = () => {
|
|
5
|
+
return new 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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createLogsCommand: () => Command<[], {
|
|
3
|
+
projectName?: string | undefined;
|
|
4
|
+
follow?: true | undefined;
|
|
5
|
+
since?: string | undefined;
|
|
6
|
+
tail: string;
|
|
7
|
+
until?: string | undefined;
|
|
8
|
+
}, {}>;
|
|
9
|
+
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,iBAAiB;;;;;;MA6C7B,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import { getProjectName, getServiceInfo } from "../base.js";
|
|
4
|
+
export const createLogsCommand = () => {
|
|
5
|
+
return new Command("logs")
|
|
6
|
+
.description("Show logs of a local environment.")
|
|
7
|
+
.option("--project-name <string>", "name of project (used by docker compose and cartesi-rollups-node)")
|
|
8
|
+
.option("-f, --follow", "Follow log output")
|
|
9
|
+
.option("--since <string>", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
|
|
10
|
+
.option("-n, --tail <string>", "Number of lines to show from the end of the logs", "all")
|
|
11
|
+
.option("--until <string>", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
|
|
12
|
+
.configureHelp({ showGlobalOptions: true })
|
|
13
|
+
.action(async (options) => {
|
|
14
|
+
const { follow, since, tail, until } = options;
|
|
15
|
+
const projectName = getProjectName(options);
|
|
16
|
+
const logOptions = [];
|
|
17
|
+
if (follow)
|
|
18
|
+
logOptions.push("--follow");
|
|
19
|
+
if (since)
|
|
20
|
+
logOptions.push("--since", since);
|
|
21
|
+
if (tail)
|
|
22
|
+
logOptions.push("--tail", tail);
|
|
23
|
+
if (until)
|
|
24
|
+
logOptions.push("--until", until);
|
|
25
|
+
const serviceInfo = await getServiceInfo({
|
|
26
|
+
projectName,
|
|
27
|
+
service: "rollups-node",
|
|
28
|
+
});
|
|
29
|
+
if (!serviceInfo) {
|
|
30
|
+
throw new Error(`service rollups-node not found`);
|
|
31
|
+
}
|
|
32
|
+
await execa("docker", ["container", "logs", ...logOptions, serviceInfo.ID], { stdio: "inherit" });
|
|
33
|
+
});
|
|
34
|
+
};
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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 createRunCommand: () => Command<[], {
|
|
3
|
+
blockTime: number;
|
|
4
|
+
cpus?: number | undefined;
|
|
5
|
+
defaultBlock: "latest" | "pending" | "safe" | "finalized";
|
|
6
|
+
dryRun: boolean;
|
|
7
|
+
memory?: number | undefined;
|
|
8
|
+
epochLength: number;
|
|
9
|
+
port?: number | undefined;
|
|
10
|
+
runtimeVersion: string;
|
|
11
|
+
projectName?: string | undefined;
|
|
12
|
+
services: string[];
|
|
13
|
+
verbose: boolean;
|
|
14
|
+
}, {}>;
|
|
21
15
|
//# 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,EACH,OAAO,EAGV,MAAM,6BAA6B,CAAC;AA8JrC,eAAO,MAAM,gBAAgB;;;;;;;;;;;;MA4J5B,CAAC"}
|
package/dist/commands/run.js
CHANGED
|
@@ -1,191 +1,202 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { Command, Option, } from "@commander-js/extra-typings";
|
|
2
|
+
import { ExitPromptError } from "@inquirer/core";
|
|
3
|
+
import chalk from "chalk";
|
|
4
|
+
import { ExecaError } from "execa";
|
|
5
|
+
import getPort, { portNumbers } from "get-port";
|
|
6
|
+
import ora from "ora";
|
|
7
|
+
import { numberToHex } from "viem";
|
|
8
|
+
import { getMachineHash, getProjectName } from "../base.js";
|
|
9
|
+
import { DEFAULT_SDK_VERSION, PREFERRED_PORT } from "../config.js";
|
|
10
|
+
import { AVAILABLE_SERVICES, deployApplication, removeApplication, startEnvironment, stopEnvironment, waitHealthyEnvironment, } from "../exec/rollups.js";
|
|
11
|
+
import { keySelect } from "../prompts.js";
|
|
12
|
+
const commaSeparatedList = (value) => value.split(",");
|
|
13
|
+
const shell = async (options) => {
|
|
14
|
+
const { build, epochLength, log, projectName } = options;
|
|
15
|
+
// keep track of last deployment
|
|
16
|
+
let lastDeployment;
|
|
17
|
+
let salt = 0;
|
|
18
|
+
// deploy for the first time
|
|
19
|
+
const hash = getMachineHash();
|
|
20
|
+
if (hash) {
|
|
21
|
+
lastDeployment = await deploy({
|
|
22
|
+
epochLength,
|
|
23
|
+
hash,
|
|
24
|
+
projectName,
|
|
25
|
+
salt: numberToHex(salt++, { size: 32 }),
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
console.warn(chalk.yellow("machine snapshot not found, waiting for build"));
|
|
30
|
+
}
|
|
31
|
+
while (true) {
|
|
32
|
+
try {
|
|
33
|
+
const option = await keySelect({
|
|
34
|
+
choices: [
|
|
35
|
+
{ name: "View logs", value: "l" },
|
|
36
|
+
{ name: "Build and redeploy", value: "b" },
|
|
37
|
+
{ name: "Quit", value: "q" },
|
|
38
|
+
],
|
|
39
|
+
}, {});
|
|
40
|
+
switch (option) {
|
|
41
|
+
case "l": {
|
|
42
|
+
try {
|
|
43
|
+
await log?.parseAsync(["--project-name", projectName, "--follow"], {
|
|
44
|
+
from: "user",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
if (error instanceof ExecaError) {
|
|
49
|
+
// just continue gracefully
|
|
50
|
+
if (error.exitCode === 130) {
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case "b": {
|
|
59
|
+
// build
|
|
60
|
+
await build?.parseAsync([], { from: "user" });
|
|
61
|
+
// redeploy
|
|
62
|
+
const hash = getMachineHash();
|
|
63
|
+
if (hash) {
|
|
64
|
+
if (lastDeployment) {
|
|
65
|
+
await undeploy({ projectName });
|
|
66
|
+
}
|
|
67
|
+
lastDeployment = await deploy({
|
|
68
|
+
consensus: lastDeployment?.consensus,
|
|
69
|
+
epochLength,
|
|
70
|
+
hash,
|
|
71
|
+
projectName,
|
|
72
|
+
salt: numberToHex(salt++, { size: 32 }),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case "q": {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
19
80
|
}
|
|
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
81
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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");
|
|
82
|
+
catch (error) {
|
|
83
|
+
if (error instanceof ExitPromptError) {
|
|
84
|
+
// gracefully exit
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
throw error;
|
|
81
88
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const undeploy = async (options) => {
|
|
92
|
+
const { projectName } = options;
|
|
93
|
+
const progress = ora(`${chalk.cyan(projectName)} undeploying...`).start();
|
|
94
|
+
await removeApplication({
|
|
95
|
+
application: projectName,
|
|
96
|
+
force: true,
|
|
97
|
+
projectName,
|
|
98
|
+
});
|
|
99
|
+
progress.succeed(`${chalk.cyan(projectName)} undeployed`);
|
|
100
|
+
};
|
|
101
|
+
const deploy = async (options) => {
|
|
102
|
+
const { consensus, epochLength, hash, projectName, salt } = options;
|
|
103
|
+
// deploy application to node (onchain and offchain)
|
|
104
|
+
const progress = ora(`deploying ${chalk.cyan(hash)} as ${chalk.cyan(projectName)}`);
|
|
105
|
+
const application = await deployApplication({
|
|
106
|
+
consensus,
|
|
107
|
+
epochLength,
|
|
108
|
+
name: projectName,
|
|
109
|
+
projectName,
|
|
110
|
+
salt,
|
|
111
|
+
snapshotPath: "/var/lib/cartesi-rollups-node/snapshots/image",
|
|
112
|
+
});
|
|
113
|
+
progress.succeed(`${chalk.cyan(projectName)} machine hash is ${chalk.cyan(hash)}`);
|
|
114
|
+
progress.succeed(`${chalk.cyan(projectName)} contract deployed at ${chalk.cyan(application.address)}`);
|
|
115
|
+
return application;
|
|
116
|
+
};
|
|
117
|
+
export const createRunCommand = () => {
|
|
118
|
+
return new Command("run")
|
|
119
|
+
.description("Run a local cartesi node for the application.")
|
|
120
|
+
.addOption(new Option("--block-time <number>", "interval between blocks (in seconds)")
|
|
121
|
+
.argParser(Number)
|
|
122
|
+
.default(2))
|
|
123
|
+
.addOption(new Option("--cpus <number>", "number of cpu limits for the rollups-node").argParser(Number))
|
|
124
|
+
.addOption(new Option("--default-block <string>", "default block to be used when fetching new blocks.")
|
|
125
|
+
.choices(["latest", "safe", "pending", "finalized"])
|
|
126
|
+
.default("latest"))
|
|
127
|
+
.option("--dry-run", "show the docker compose configuration", false)
|
|
128
|
+
.addOption(new Option("--memory <number>", "memory limit for the rollups-node in MB").argParser(Number))
|
|
129
|
+
.addOption(new Option("--epoch-length <number>", "length of an epoch (in blocks)")
|
|
130
|
+
.argParser(Number)
|
|
131
|
+
.default(720))
|
|
132
|
+
.option("-p, --port <number>", "port to listen on", Number)
|
|
133
|
+
.addOption(new Option("--runtime-version <version>", "version for Cartesi Rollups Runtime to use")
|
|
134
|
+
.default(DEFAULT_SDK_VERSION)
|
|
135
|
+
.hideHelp())
|
|
136
|
+
.option("--project-name <string>", "name of project (used by docker compose and cartesi-rollups-node)")
|
|
137
|
+
.option("--services <string>", `optional services to start, comma separated list from [${AVAILABLE_SERVICES.join(", ")}]`, commaSeparatedList, [])
|
|
138
|
+
.option("-v, --verbose", "verbose output", false)
|
|
139
|
+
.action(async (options, program) => {
|
|
140
|
+
const { blockTime, cpus, defaultBlock, dryRun, epochLength, memory, runtimeVersion, services, verbose, } = options;
|
|
141
|
+
const progress = ora();
|
|
142
|
+
if (defaultBlock !== "finalized") {
|
|
143
|
+
console.warn(chalk.yellow(`WARNING: default block is set to '${defaultBlock}', production configuration will likely use 'finalized'`));
|
|
85
144
|
}
|
|
86
|
-
//
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
145
|
+
// project name explicitly defined or the current directory name
|
|
146
|
+
const projectName = getProjectName(options);
|
|
147
|
+
// resolve port number, using the first free port in a range, unless explicitly set
|
|
148
|
+
const port = options.port ||
|
|
149
|
+
(await getPort({
|
|
150
|
+
port: portNumbers(PREFERRED_PORT, PREFERRED_PORT + 10),
|
|
151
|
+
}));
|
|
152
|
+
// run compose environment (detached)
|
|
153
|
+
const { address, config } = await startEnvironment({
|
|
154
|
+
blockTime,
|
|
155
|
+
cpus,
|
|
156
|
+
defaultBlock,
|
|
157
|
+
dryRun,
|
|
158
|
+
memory,
|
|
159
|
+
port,
|
|
96
160
|
projectName,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
161
|
+
runtimeVersion,
|
|
162
|
+
services,
|
|
163
|
+
verbose,
|
|
164
|
+
});
|
|
165
|
+
if (dryRun && config) {
|
|
166
|
+
// just show the docker compose configuration and quit
|
|
167
|
+
process.stdout.write(config);
|
|
168
|
+
return;
|
|
103
169
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
170
|
+
progress.succeed(`${chalk.cyan(projectName)} starting at ${chalk.cyan(`${address}`)}`);
|
|
171
|
+
// wait for the environment to be healthy
|
|
172
|
+
await waitHealthyEnvironment({
|
|
173
|
+
name: projectName,
|
|
174
|
+
port,
|
|
175
|
+
projectName,
|
|
176
|
+
services,
|
|
177
|
+
});
|
|
178
|
+
const shutdown = async () => {
|
|
179
|
+
progress.start(`${chalk.cyan(projectName)} stopping...`);
|
|
180
|
+
try {
|
|
181
|
+
await stopEnvironment({ projectName });
|
|
182
|
+
progress.succeed(`${chalk.cyan(projectName)} stopped`);
|
|
114
183
|
}
|
|
115
|
-
|
|
116
|
-
|
|
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;
|
|
184
|
+
catch (e) {
|
|
185
|
+
progress.fail(e instanceof Error ? e.message : "Unknown error");
|
|
125
186
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
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
|
-
}),
|
|
187
|
+
process.exit(0);
|
|
188
|
+
};
|
|
189
|
+
// inhibit SIGINT and SIGTERM, will be handled gracefully by the shell
|
|
190
|
+
process.on("SIGINT", () => { });
|
|
191
|
+
process.on("SIGTERM", () => { });
|
|
192
|
+
const log = program.parent?.commands.find((c) => c.name() === "logs");
|
|
193
|
+
const build = program.parent?.commands.find((c) => c.name() === "build");
|
|
194
|
+
await shell({
|
|
195
|
+
build,
|
|
196
|
+
epochLength,
|
|
197
|
+
log,
|
|
198
|
+
projectName,
|
|
199
|
+
});
|
|
200
|
+
await shutdown();
|
|
201
|
+
});
|
|
190
202
|
};
|
|
191
|
-
export default Run;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createSendCommand: () => Command<[string | undefined], {
|
|
3
|
+
from?: string | undefined;
|
|
4
|
+
application?: string | undefined;
|
|
5
|
+
encoding?: "string" | "hex" | "abi" | undefined;
|
|
6
|
+
abiParams?: string | undefined;
|
|
7
|
+
projectName?: string | undefined;
|
|
8
|
+
rpcUrl?: string | undefined;
|
|
9
|
+
}, {}>;
|
|
10
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAmG9D,eAAO,MAAM,iBAAiB;;;;;;;MA4D7B,CAAC"}
|