@cartesi/cli 2.0.0-alpha.4 → 2.0.0-alpha.6
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 +18 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +103 -0
- package/dist/builder/directory.d.ts.map +1 -1
- package/dist/builder/docker.d.ts.map +1 -1
- package/dist/builder/empty.d.ts.map +1 -1
- package/dist/builder/none.d.ts.map +1 -1
- package/dist/builder/tar.d.ts.map +1 -1
- package/dist/commands/address-book.d.ts +4 -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 +5 -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 +5 -14
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +36 -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 +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/doctor.d.ts +2 -12
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +96 -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/rollups/deploy.d.ts +16 -0
- package/dist/commands/rollups/deploy.d.ts.map +1 -0
- package/dist/commands/rollups/deploy.js +225 -0
- package/dist/commands/rollups/logs.d.ts +11 -0
- package/dist/commands/rollups/logs.d.ts.map +1 -0
- package/dist/commands/rollups/logs.js +32 -0
- package/dist/commands/rollups/start.d.ts +14 -0
- package/dist/commands/rollups/start.d.ts.map +1 -0
- package/dist/commands/rollups/start.js +209 -0
- package/dist/commands/rollups/status.d.ts +7 -0
- package/dist/commands/rollups/status.d.ts.map +1 -0
- package/dist/commands/rollups/status.js +46 -0
- package/dist/commands/rollups/stop.d.ts +5 -0
- package/dist/commands/rollups/stop.d.ts.map +1 -0
- package/dist/commands/rollups/stop.js +26 -0
- package/dist/commands/rollups.d.ts +6 -0
- package/dist/commands/rollups.d.ts.map +1 -0
- package/dist/commands/rollups.js +19 -0
- package/dist/commands/run.d.ts +2 -21
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +9 -199
- package/dist/commands/send/erc20.d.ts +11 -13
- package/dist/commands/send/erc20.d.ts.map +1 -1
- package/dist/commands/send/erc20.js +57 -52
- package/dist/commands/send/erc721.d.ts +11 -13
- package/dist/commands/send/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +51 -46
- package/dist/commands/send/ether.d.ts +11 -12
- package/dist/commands/send/ether.d.ts.map +1 -1
- package/dist/commands/send/ether.js +25 -21
- package/dist/commands/send/generic.d.ts +12 -14
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +92 -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 +6 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +21 -43
- package/dist/compose/rollups/default.env +35 -0
- package/dist/compose/rollups/docker-compose-anvil.yaml +15 -0
- package/dist/{node → compose/rollups}/docker-compose-bundler.yaml +14 -25
- package/dist/{node → compose/rollups}/docker-compose-database.yaml +4 -2
- package/dist/compose/rollups/docker-compose-espresso.yaml +103 -0
- package/dist/{node → compose/rollups}/docker-compose-explorer.yaml +23 -37
- package/dist/compose/rollups/docker-compose-graphql.yaml +52 -0
- package/dist/compose/rollups/docker-compose-node-cpus.yaml +7 -0
- package/dist/compose/rollups/docker-compose-node-memory.yaml +6 -0
- package/dist/compose/rollups/docker-compose-node.yaml +39 -0
- package/dist/compose/rollups/docker-compose-paymaster.yaml +21 -0
- package/dist/compose/rollups/docker-compose-proxy.yaml +22 -0
- package/dist/compose/rollups/proxy/bundler.yaml +17 -0
- package/dist/compose/rollups/proxy/espresso-reader.yaml +17 -0
- package/dist/compose/rollups/proxy/espresso.yaml +56 -0
- package/dist/compose/rollups/proxy/explorer-api.yaml +17 -0
- package/dist/compose/rollups/proxy/explorer.yaml +10 -0
- package/dist/compose/rollups/proxy/graphql.yaml +10 -0
- package/dist/compose/rollups/proxy/paymaster.yaml +17 -0
- package/dist/compose/rollups/proxy/rollups-node.yaml +17 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/exec/cartesi-machine.d.ts.map +1 -1
- package/dist/exec/crane.d.ts +1 -1
- package/dist/exec/crane.d.ts.map +1 -1
- package/dist/exec/genext2fs.d.ts.map +1 -1
- package/dist/exec/mksquashfs.d.ts.map +1 -1
- package/dist/exec/rollups.d.ts +17 -0
- package/dist/exec/rollups.d.ts.map +1 -0
- package/dist/exec/rollups.js +40 -0
- package/dist/exec/util.d.ts +1 -1
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +53 -1
- package/dist/machine.d.ts.map +1 -1
- package/dist/prompts.d.ts.map +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +29 -6
- package/package.json +28 -45
- 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/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/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-envfile.yaml +0 -4
- package/dist/node/docker-compose-espresso.yaml +0 -127
- 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 -883
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import pRetry from "p-retry";
|
|
6
|
+
import path from "path";
|
|
7
|
+
import { getServiceHealth } from "../../base.js";
|
|
8
|
+
import { DEFAULT_SDK } from "../../config.js";
|
|
9
|
+
const commaSeparatedList = (value) => value.split(",");
|
|
10
|
+
const host = "http://127.0.0.1";
|
|
11
|
+
// services configuration
|
|
12
|
+
const baseServices = [
|
|
13
|
+
{
|
|
14
|
+
name: "anvil",
|
|
15
|
+
file: "docker-compose-anvil.yaml",
|
|
16
|
+
healthySemaphore: "anvil",
|
|
17
|
+
healthyTitle: `${chalk.cyan("anvil")} service ready at ${chalk.cyan(`${host}:8545`)}`,
|
|
18
|
+
waitTitle: `${chalk.cyan("anvil")} service starting...`,
|
|
19
|
+
errorTitle: `${chalk.red("anvil")} service failed`,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "proxy",
|
|
23
|
+
file: "docker-compose-proxy.yaml",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: "database",
|
|
27
|
+
file: "docker-compose-database.yaml",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "rpc",
|
|
31
|
+
file: "docker-compose-node.yaml",
|
|
32
|
+
healthySemaphore: "proxy",
|
|
33
|
+
healthyTitle: (port) => `${chalk.cyan("rpc")} service ready at ${chalk.cyan(`${host}:${port}/rpc`)}`,
|
|
34
|
+
waitTitle: `${chalk.cyan("rpc")} service starting...`,
|
|
35
|
+
errorTitle: `${chalk.red("rpc")} service failed`,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "inspect",
|
|
39
|
+
file: "docker-compose-node.yaml",
|
|
40
|
+
healthySemaphore: "proxy",
|
|
41
|
+
healthyTitle: (port) => `${chalk.cyan("inspect")} service ready at ${chalk.cyan(`${host}:${port}/inspect/<application_address>`)}`,
|
|
42
|
+
waitTitle: `${chalk.cyan("inspect")} service starting...`,
|
|
43
|
+
errorTitle: `${chalk.red("inspect")} service failed`,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
const availableServices = [
|
|
47
|
+
{
|
|
48
|
+
name: "bundler",
|
|
49
|
+
file: "docker-compose-bundler.yaml",
|
|
50
|
+
healthySemaphore: "proxy",
|
|
51
|
+
healthyTitle: (port) => `Service ${chalk.cyan("bundler")} ready at ${chalk.cyan(`${host}:${port}/bundler/rpc`)}`,
|
|
52
|
+
waitTitle: `${chalk.cyan("bundler")} service starting...`,
|
|
53
|
+
errorTitle: `${chalk.red("bundler")} service failed`,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: "espresso",
|
|
57
|
+
file: "docker-compose-espresso.yaml",
|
|
58
|
+
healthySemaphore: "proxy",
|
|
59
|
+
healthyTitle: (port) => `Service ${chalk.cyan("espresso")} ready at ${chalk.cyan(`${host}:${port}/espresso`)}`,
|
|
60
|
+
waitTitle: `${chalk.cyan("espresso")} service starting...`,
|
|
61
|
+
errorTitle: `${chalk.red("espresso")} service failed`,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "explorer",
|
|
65
|
+
file: "docker-compose-explorer.yaml",
|
|
66
|
+
healthySemaphore: "proxy",
|
|
67
|
+
healthyTitle: (port) => `Service ${chalk.cyan("explorer")} ready at ${chalk.cyan(`${host}:${port}/explorer`)}`,
|
|
68
|
+
waitTitle: `${chalk.cyan("explorer")} service starting...`,
|
|
69
|
+
errorTitle: `${chalk.red("explorer")} service failed`,
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "graphql",
|
|
73
|
+
file: "docker-compose-graphql.yaml",
|
|
74
|
+
healthySemaphore: "proxy",
|
|
75
|
+
healthyTitle: (port) => `Service ${chalk.cyan("graphql")} ready at ${chalk.cyan(`${host}:${port}/graphql`)}`,
|
|
76
|
+
waitTitle: `${chalk.cyan("graphql")} service starting...`,
|
|
77
|
+
errorTitle: `${chalk.red("graphql")} service failed`,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "paymaster",
|
|
81
|
+
file: "docker-compose-paymaster.yaml",
|
|
82
|
+
healthySemaphore: "proxy",
|
|
83
|
+
healthyTitle: (port) => `Service ${chalk.cyan("paymaster")} ready at ${chalk.cyan(`${host}:${port}/paymaster`)}`,
|
|
84
|
+
waitTitle: `Starting ${chalk.cyan("paymaster")}...`,
|
|
85
|
+
errorTitle: `Service ${chalk.red("paymaster")} failed`,
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const serviceMonitorTask = (options) => {
|
|
89
|
+
const { errorTitle, healthyTitle, service, waitTitle } = options;
|
|
90
|
+
return {
|
|
91
|
+
task: async (_ctx, task) => {
|
|
92
|
+
await pRetry(async () => {
|
|
93
|
+
const health = await getServiceHealth(options);
|
|
94
|
+
if (health !== "healthy") {
|
|
95
|
+
throw new Error(errorTitle ??
|
|
96
|
+
`Service ${chalk.cyan(service)} is not healthy`);
|
|
97
|
+
}
|
|
98
|
+
}, { retries: 100, minTimeout: 500, factor: 1.1 });
|
|
99
|
+
task.title =
|
|
100
|
+
healthyTitle ?? `Service ${chalk.cyan(service)} is ready`;
|
|
101
|
+
},
|
|
102
|
+
title: waitTitle ?? `Starting ${chalk.cyan(service)}...`,
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export const createStartCommand = () => {
|
|
106
|
+
return new Command("start")
|
|
107
|
+
.description("Start a local rollups node environment.")
|
|
108
|
+
.configureHelp({ showGlobalOptions: true })
|
|
109
|
+
.addOption(new Option("--block-time <number>", "interval between blocks (in seconds)")
|
|
110
|
+
.argParser(Number)
|
|
111
|
+
.default(5))
|
|
112
|
+
.addOption(new Option("--default-block <string>", "default block to be used when fetching new blocks.")
|
|
113
|
+
.choices(["latest", "safe", "pending", "finalized"])
|
|
114
|
+
.default("latest"))
|
|
115
|
+
.addOption(new Option("--cpus <number>", "number of cpu limits for the rollups-node").argParser(Number))
|
|
116
|
+
.addOption(new Option("--memory <number>", "memory limit for the rollups-node in MB").argParser(Number))
|
|
117
|
+
.option("--services <string>", `optional services to start, comma separated list from [${availableServices.map(({ name }) => name).join(", ")}]`, commaSeparatedList, [])
|
|
118
|
+
.option("-p, --port <number>", "port to listen on", parseInt, 8080)
|
|
119
|
+
.option("--dry-run", "show the docker compose configuration", false)
|
|
120
|
+
.option("-v, --verbose", "verbose output", false)
|
|
121
|
+
.action(async (options, command) => {
|
|
122
|
+
const { environmentName } = command.optsWithGlobals();
|
|
123
|
+
const { blockTime, cpus, defaultBlock, dryRun, memory, port, services, verbose, } = options;
|
|
124
|
+
// path of the tool instalation
|
|
125
|
+
const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "../..");
|
|
126
|
+
// setup the environment variable used in docker compose
|
|
127
|
+
const env = {
|
|
128
|
+
BLOCK_TIME: blockTime.toString(),
|
|
129
|
+
CARTESI_BLOCKCHAIN_DEFAULT_BLOCK: defaultBlock,
|
|
130
|
+
CARTESI_LOG_LEVEL: verbose ? "debug" : "info",
|
|
131
|
+
CARTESI_BIN_PATH: binPath,
|
|
132
|
+
CARTESI_LISTEN_PORT: port.toString(),
|
|
133
|
+
CARTESI_ROLLUPS_NODE_CPUS: cpus?.toString(),
|
|
134
|
+
CARTESI_ROLLUPS_NODE_MEMORY: memory?.toString(),
|
|
135
|
+
CARTESI_SDK_IMAGE: DEFAULT_SDK,
|
|
136
|
+
};
|
|
137
|
+
// build a list of unique compose files
|
|
138
|
+
const composeFiles = [
|
|
139
|
+
...new Set(baseServices.map(({ file }) => file)),
|
|
140
|
+
];
|
|
141
|
+
// cpu and memory limits, mostly for testing and debuggingpurposes
|
|
142
|
+
if (cpus) {
|
|
143
|
+
composeFiles.push("docker-compose-node-cpus.yaml");
|
|
144
|
+
}
|
|
145
|
+
if (memory) {
|
|
146
|
+
composeFiles.push("docker-compose-node-memory.yaml");
|
|
147
|
+
}
|
|
148
|
+
// select subset of optional services
|
|
149
|
+
const optionalServices = services.length === 1 && services[0] === "all"
|
|
150
|
+
? availableServices
|
|
151
|
+
: availableServices.filter(({ name }) => services.includes(name));
|
|
152
|
+
// add to compose files list
|
|
153
|
+
composeFiles.push(...optionalServices.map(({ file }) => file));
|
|
154
|
+
// create the "--file <file>" list
|
|
155
|
+
const files = composeFiles
|
|
156
|
+
.map((f) => [
|
|
157
|
+
"--file",
|
|
158
|
+
path.join(binPath, "compose", "rollups", f),
|
|
159
|
+
])
|
|
160
|
+
.flat();
|
|
161
|
+
const composeArgs = [
|
|
162
|
+
"compose",
|
|
163
|
+
...files,
|
|
164
|
+
"--project-name",
|
|
165
|
+
environmentName,
|
|
166
|
+
];
|
|
167
|
+
// run in detached mode (background)
|
|
168
|
+
const upArgs = ["--detach"];
|
|
169
|
+
if (dryRun) {
|
|
170
|
+
// show the docker compose configuration
|
|
171
|
+
await execa("docker", [...composeArgs, "config"], {
|
|
172
|
+
env,
|
|
173
|
+
stdio: "inherit",
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
if (defaultBlock !== "finalized") {
|
|
178
|
+
console.warn(chalk.yellow(`WARNING: default block is set to '${defaultBlock}', production configuration will likely use 'finalized'`));
|
|
179
|
+
}
|
|
180
|
+
// pull images first
|
|
181
|
+
await execa("docker", [...composeArgs, "pull"], {
|
|
182
|
+
env,
|
|
183
|
+
stdio: "inherit",
|
|
184
|
+
});
|
|
185
|
+
// run compose environment
|
|
186
|
+
const up = execa("docker", [...composeArgs, "up", ...upArgs], {
|
|
187
|
+
env,
|
|
188
|
+
});
|
|
189
|
+
// create tasks to monitor services startup
|
|
190
|
+
const monitorTasks = [...baseServices, ...optionalServices]
|
|
191
|
+
.filter(({ healthySemaphore }) => !!healthySemaphore) // only services with a healthy semaphore
|
|
192
|
+
.map((service) => {
|
|
193
|
+
const healthyTitle = typeof service.healthyTitle === "function"
|
|
194
|
+
? service.healthyTitle(port)
|
|
195
|
+
: service.healthyTitle;
|
|
196
|
+
return serviceMonitorTask({
|
|
197
|
+
environmentName,
|
|
198
|
+
service: service.healthySemaphore,
|
|
199
|
+
errorTitle: service.errorTitle,
|
|
200
|
+
waitTitle: service.waitTitle,
|
|
201
|
+
healthyTitle,
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
const tasks = new Listr(monitorTasks, { concurrent: true });
|
|
205
|
+
await tasks.run();
|
|
206
|
+
await up;
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAOtD,eAAO,MAAM,mBAAmB;;;;EA8C/B,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import Table from "cli-table3";
|
|
4
|
+
import { getServiceState } from "../../base.js";
|
|
5
|
+
import { getDeployments } from "../../exec/rollups.js";
|
|
6
|
+
export const createStatusCommand = () => {
|
|
7
|
+
return new Command("status")
|
|
8
|
+
.description("Shows the status of a local rollups node environment.")
|
|
9
|
+
.configureHelp({ showGlobalOptions: true })
|
|
10
|
+
.option("--json", "output in JSON format")
|
|
11
|
+
.action(async ({ json }, command) => {
|
|
12
|
+
const { environmentName } = command.optsWithGlobals();
|
|
13
|
+
const status = await getServiceState({
|
|
14
|
+
environmentName,
|
|
15
|
+
service: "rollups-node",
|
|
16
|
+
});
|
|
17
|
+
const deployments = await getDeployments({ environmentName });
|
|
18
|
+
if (json) {
|
|
19
|
+
process.stdout.write(JSON.stringify({
|
|
20
|
+
status,
|
|
21
|
+
deployments,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
console.log(`${chalk.cyan(environmentName)} is ${status == "running" ? chalk.green("running") : chalk.red("not running")}`);
|
|
26
|
+
if (status === "running") {
|
|
27
|
+
if (deployments.length === 0) {
|
|
28
|
+
console.log(chalk.red("no applications deployed"));
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// print as a table
|
|
32
|
+
const table = new Table({
|
|
33
|
+
head: ["Machine", "Address", "State"],
|
|
34
|
+
style: { border: [], head: [] },
|
|
35
|
+
});
|
|
36
|
+
table.push(...deployments.map((deployment) => [
|
|
37
|
+
deployment.templateHash,
|
|
38
|
+
deployment.address,
|
|
39
|
+
deployment.state,
|
|
40
|
+
]));
|
|
41
|
+
console.log(table.toString());
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../../src/commands/rollups/stop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAMtD,eAAO,MAAM,iBAAiB;;EAwB7B,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import ora from "ora";
|
|
5
|
+
export const createStopCommand = () => {
|
|
6
|
+
return new Command("stop")
|
|
7
|
+
.description("Stop a local rollups node environment.")
|
|
8
|
+
.configureHelp({ showGlobalOptions: true })
|
|
9
|
+
.action(async (_options, command) => {
|
|
10
|
+
const { environmentName } = command.optsWithGlobals();
|
|
11
|
+
const progress = ora(`Stopping ${chalk.cyan(environmentName)} environment...`).start();
|
|
12
|
+
try {
|
|
13
|
+
await execa("docker", [
|
|
14
|
+
"compose",
|
|
15
|
+
"-p",
|
|
16
|
+
environmentName,
|
|
17
|
+
"down",
|
|
18
|
+
"--volumes",
|
|
19
|
+
]);
|
|
20
|
+
progress.succeed(`${chalk.cyan(environmentName)} environment stopped.`);
|
|
21
|
+
}
|
|
22
|
+
catch (e) {
|
|
23
|
+
progress.fail(e.message);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createRollupsCommand: () => Command<[], {
|
|
3
|
+
environmentName: string;
|
|
4
|
+
}, {}>;
|
|
5
|
+
export type RollupsCommandOpts = ReturnType<ReturnType<typeof createRollupsCommand>["opts"]>;
|
|
6
|
+
//# sourceMappingURL=rollups.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rollups.d.ts","sourceRoot":"","sources":["../../src/commands/rollups.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAOtD,eAAO,MAAM,oBAAoB;;MAgBhC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,UAAU,CACvC,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAClD,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { createDeployCommand } from "./rollups/deploy.js";
|
|
3
|
+
import { createLogsCommand } from "./rollups/logs.js";
|
|
4
|
+
import { createStartCommand } from "./rollups/start.js";
|
|
5
|
+
import { createStatusCommand } from "./rollups/status.js";
|
|
6
|
+
import { createStopCommand } from "./rollups/stop.js";
|
|
7
|
+
export const createRollupsCommand = () => {
|
|
8
|
+
const command = new Command("rollups")
|
|
9
|
+
.option("--environment-name <string>", "name of environment", "cartesi-rollups")
|
|
10
|
+
.action(async (_options, program) => {
|
|
11
|
+
program.help();
|
|
12
|
+
});
|
|
13
|
+
command.addCommand(createLogsCommand());
|
|
14
|
+
command.addCommand(createStartCommand());
|
|
15
|
+
command.addCommand(createStatusCommand());
|
|
16
|
+
command.addCommand(createStopCommand());
|
|
17
|
+
command.addCommand(createDeployCommand());
|
|
18
|
+
return command;
|
|
19
|
+
};
|
package/dist/commands/run.d.ts
CHANGED
|
@@ -1,22 +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
|
-
"enable-espresso": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
-
"epoch-length": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
13
|
-
"no-backend": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
14
|
-
verbose: import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
15
|
-
"listen-port": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
16
|
-
cpus: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
17
|
-
memory: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<number | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
18
|
-
"dry-run": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
19
|
-
};
|
|
20
|
-
run(): Promise<void>;
|
|
21
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createRunCommand: () => Command<[], {}, {}>;
|
|
22
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,EAAE,MAAM,6BAA6B,CAAC;AAGtD,eAAO,MAAM,gBAAgB,2BAW5B,CAAC"}
|
package/dist/commands/run.js
CHANGED
|
@@ -1,200 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
// espresso development node
|
|
75
|
-
if (flags["enable-espresso"]) {
|
|
76
|
-
composeFiles.push("docker-compose-espresso.yaml");
|
|
77
|
-
}
|
|
78
|
-
// load the no-backend compose file
|
|
79
|
-
if (flags["no-backend"]) {
|
|
80
|
-
composeFiles.push("docker-compose-host.yaml");
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// snapshot volume
|
|
84
|
-
composeFiles.push("docker-compose-snapshot-volume.yaml");
|
|
85
|
-
}
|
|
86
|
-
// add project env file loading
|
|
87
|
-
if (fs.existsSync("./.cartesi.env")) {
|
|
88
|
-
composeFiles.push("docker-compose-envfile.yaml");
|
|
89
|
-
}
|
|
90
|
-
// create the "--file <file>" list
|
|
91
|
-
const files = composeFiles
|
|
92
|
-
.map((f) => ["--file", path.join(binPath, "node", f)])
|
|
93
|
-
.flat();
|
|
94
|
-
const compose_args = [
|
|
95
|
-
"compose",
|
|
96
|
-
...files,
|
|
97
|
-
"--project-directory",
|
|
98
|
-
".",
|
|
99
|
-
"--project-name",
|
|
100
|
-
projectName,
|
|
101
|
-
];
|
|
102
|
-
const up_args = [];
|
|
103
|
-
if (!flags.verbose) {
|
|
104
|
-
compose_args.push("--progress", "quiet");
|
|
105
|
-
up_args.push("--attach", "validator");
|
|
106
|
-
up_args.push("--attach", "prompt");
|
|
107
|
-
}
|
|
108
|
-
// XXX: need this handler, so SIGINT can still call the finally block below
|
|
109
|
-
process.on("SIGINT", () => { });
|
|
110
|
-
try {
|
|
111
|
-
if (flags["dry-run"]) {
|
|
112
|
-
// show the docker compose configuration
|
|
113
|
-
await execa("docker", [...compose_args, "config"], {
|
|
114
|
-
env,
|
|
115
|
-
stdio: "inherit",
|
|
116
|
-
});
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
// run compose environment
|
|
120
|
-
await execa("docker", [...compose_args, "up", ...up_args], {
|
|
121
|
-
env,
|
|
122
|
-
stdio: "inherit",
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
catch (e) {
|
|
126
|
-
// 130 is a graceful shutdown, so we can swallow it
|
|
127
|
-
if (e.exitCode !== 130) {
|
|
128
|
-
throw e;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
finally {
|
|
132
|
-
// shut it down, including volumes
|
|
133
|
-
await execa("docker", [...compose_args, "down", "--volumes"], {
|
|
134
|
-
env,
|
|
135
|
-
stdio: "inherit",
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
Run.summary = "Run application node.";
|
|
141
|
-
Run.description = "Run a local cartesi node for the application.";
|
|
142
|
-
Run.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
143
|
-
Run.flags = {
|
|
144
|
-
"block-time": Flags.integer({
|
|
145
|
-
description: "interval between blocks (in seconds)",
|
|
146
|
-
default: 5,
|
|
147
|
-
}),
|
|
148
|
-
"disable-explorer": Flags.boolean({
|
|
149
|
-
default: false,
|
|
150
|
-
description: "disable local explorer service to save machine resources",
|
|
151
|
-
summary: "disable explorer service",
|
|
152
|
-
}),
|
|
153
|
-
"disable-bundler": Flags.boolean({
|
|
154
|
-
default: false,
|
|
155
|
-
description: "disable local bundler service to save machine resources",
|
|
156
|
-
summary: "disable bundler service",
|
|
157
|
-
}),
|
|
158
|
-
"disable-paymaster": Flags.boolean({
|
|
159
|
-
default: false,
|
|
160
|
-
description: "disable local paymaster service to save machine resources",
|
|
161
|
-
summary: "disable paymaster service",
|
|
162
|
-
}),
|
|
163
|
-
"enable-espresso": Flags.boolean({
|
|
164
|
-
default: false,
|
|
165
|
-
description: "enable Espresso development node ",
|
|
166
|
-
summary: "enable Espresso development node",
|
|
167
|
-
}),
|
|
168
|
-
"epoch-length": Flags.integer({
|
|
169
|
-
description: "length of an epoch (in blocks)",
|
|
170
|
-
default: 720,
|
|
171
|
-
}),
|
|
172
|
-
"no-backend": Flags.boolean({
|
|
173
|
-
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",
|
|
174
|
-
summary: "run a node without the application code",
|
|
175
|
-
default: false,
|
|
176
|
-
}),
|
|
177
|
-
verbose: Flags.boolean({
|
|
178
|
-
description: "verbose output",
|
|
179
|
-
default: false,
|
|
180
|
-
char: "v",
|
|
181
|
-
}),
|
|
182
|
-
"listen-port": Flags.integer({
|
|
183
|
-
description: "port to listen for incoming connections",
|
|
184
|
-
default: 8080,
|
|
185
|
-
}),
|
|
186
|
-
cpus: Flags.integer({
|
|
187
|
-
description: "Define the number of CPUs to use (eg.: 1) for the rollups-node",
|
|
188
|
-
summary: "number of cpu limits for the rollups-node",
|
|
189
|
-
}),
|
|
190
|
-
memory: Flags.integer({
|
|
191
|
-
description: "Define the amount of memory to use for the rollups-node in MB (eg.: 1024)",
|
|
192
|
-
summary: "memory limit for the rollups-node in MB",
|
|
193
|
-
}),
|
|
194
|
-
"dry-run": Flags.boolean({
|
|
195
|
-
description: "show the docker compose configuration",
|
|
196
|
-
default: false,
|
|
197
|
-
hidden: true,
|
|
198
|
-
}),
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
3
|
+
export const createRunCommand = () => {
|
|
4
|
+
return new Command("run")
|
|
5
|
+
.description("Run a local cartesi node for the application.")
|
|
6
|
+
.summary("DEPRECATED: use 'rollups start' instead")
|
|
7
|
+
.action(async () => {
|
|
8
|
+
console.warn(chalk.yellow("run command is deprecated, use 'rollups start' and 'rollups deploy' instead"));
|
|
9
|
+
});
|
|
199
10
|
};
|
|
200
|
-
export default Run;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
|
|
13
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createErc20Command: () => Command<[], {
|
|
3
|
+
token?: string | undefined;
|
|
4
|
+
amount?: string | undefined;
|
|
5
|
+
}, {
|
|
6
|
+
chainId: number;
|
|
7
|
+
rpcUrl?: string | undefined;
|
|
8
|
+
mnemonic?: string | undefined;
|
|
9
|
+
mnemonicIndex: number;
|
|
10
|
+
dapp?: `0x${string}` | undefined;
|
|
11
|
+
}>;
|
|
14
12
|
//# 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,kBAAkB;;;;;;;;;EAgD9B,CAAC"}
|