@cartesi/cli 2.0.0-alpha.1 → 2.0.0-alpha.12
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 +99 -0
- package/dist/builder/directory.d.ts +2 -2
- package/dist/builder/directory.d.ts.map +1 -1
- package/dist/builder/directory.js +1 -1
- package/dist/builder/docker.d.ts +1 -1
- package/dist/builder/docker.d.ts.map +1 -1
- package/dist/builder/docker.js +8 -8
- package/dist/builder/empty.d.ts +2 -2
- package/dist/builder/empty.d.ts.map +1 -1
- package/dist/builder/empty.js +1 -1
- package/dist/builder/none.d.ts +2 -2
- package/dist/builder/none.d.ts.map +1 -1
- package/dist/builder/none.js +1 -1
- package/dist/builder/tar.d.ts +2 -2
- package/dist/builder/tar.d.ts.map +1 -1
- package/dist/builder/tar.js +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 +18 -30
- 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 +24 -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 +18 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +271 -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 +10 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +33 -0
- package/dist/commands/run.d.ts +2 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +9 -190
- package/dist/commands/send/eip712.d.ts +34 -0
- package/dist/commands/send/eip712.d.ts.map +1 -0
- package/dist/commands/send/eip712.js +81 -0
- 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 +14 -14
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +102 -99
- 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 +22 -44
- package/dist/commands/start.d.ts +14 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +220 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +47 -0
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +27 -0
- package/dist/compose/default.env +35 -0
- package/dist/compose/docker-compose-anvil.yaml +17 -0
- package/dist/compose/docker-compose-bundler.yaml +37 -0
- package/dist/{node → compose}/docker-compose-database.yaml +4 -2
- package/dist/compose/docker-compose-espresso.yaml +59 -0
- package/dist/compose/docker-compose-explorer.yaml +57 -0
- package/dist/compose/docker-compose-graphql.yaml +23 -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 +31 -0
- package/dist/compose/docker-compose-passkey-server.yaml +15 -0
- package/dist/compose/docker-compose-paymaster.yaml +18 -0
- package/dist/compose/docker-compose-proxy.yaml +24 -0
- package/dist/compose/proxy/anvil.yaml +17 -0
- package/dist/compose/proxy/bundler.yaml +29 -0
- package/dist/compose/proxy/espresso.yaml +17 -0
- package/dist/compose/proxy/explorer-api.yaml +17 -0
- package/dist/compose/proxy/explorer.yaml +10 -0
- package/dist/compose/proxy/graphql.yaml +10 -0
- package/dist/compose/proxy/passkey-server.yaml +17 -0
- package/dist/compose/proxy/paymaster.yaml +17 -0
- package/dist/compose/proxy/rollups-node.yaml +17 -0
- package/dist/config.d.ts +5 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -35
- 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 +1 -1
- package/dist/exec/crane.d.ts +4 -4
- package/dist/exec/crane.d.ts.map +1 -1
- package/dist/exec/crane.js +1 -1
- package/dist/exec/genext2fs.d.ts +2 -2
- package/dist/exec/genext2fs.d.ts.map +1 -1
- package/dist/exec/genext2fs.js +2 -2
- package/dist/exec/mksquashfs.d.ts +2 -2
- package/dist/exec/mksquashfs.d.ts.map +1 -1
- package/dist/exec/mksquashfs.js +2 -2
- package/dist/exec/rollups.d.ts +16 -0
- package/dist/exec/rollups.d.ts.map +1 -0
- package/dist/exec/rollups.js +39 -0
- package/dist/exec/util.d.ts +3 -3
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +8 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -1
- package/dist/machine.d.ts +1 -1
- package/dist/machine.d.ts.map +1 -1
- package/dist/prompts.d.ts +3 -3
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +1 -1
- 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 +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +109 -84
- package/package.json +32 -50
- 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-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
|
@@ -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;;;;;;;MAgD7B,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import { DEFAULT_COMPOSE_ENVIRONMENT_NAME } from "../config.js";
|
|
4
|
+
export const createLogsCommand = () => {
|
|
5
|
+
return new Command("logs")
|
|
6
|
+
.description("Show logs of a local environment.")
|
|
7
|
+
.option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
|
|
8
|
+
.option("-f, --follow", "Follow log output")
|
|
9
|
+
.option("--no-color", "Produce monochrome output")
|
|
10
|
+
.option("--since <string>", "Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
|
|
11
|
+
.option("-n, --tail <string>", "Number of lines to show from the end of the logs", "all")
|
|
12
|
+
.option("--until <string>", "Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative (e.g. 42m for 42 minutes)")
|
|
13
|
+
.configureHelp({ showGlobalOptions: true })
|
|
14
|
+
.action(async ({ environmentName, follow, color, since, tail, until }, command) => {
|
|
15
|
+
const logOptions = ["--no-log-prefix"];
|
|
16
|
+
if (follow)
|
|
17
|
+
logOptions.push("--follow");
|
|
18
|
+
if (color === false)
|
|
19
|
+
logOptions.push("--no-color");
|
|
20
|
+
if (since)
|
|
21
|
+
logOptions.push("--since", since);
|
|
22
|
+
if (tail)
|
|
23
|
+
logOptions.push("--tail", tail);
|
|
24
|
+
await execa("docker", [
|
|
25
|
+
"compose",
|
|
26
|
+
"--project-name",
|
|
27
|
+
environmentName,
|
|
28
|
+
"logs",
|
|
29
|
+
...logOptions,
|
|
30
|
+
"rollups-node",
|
|
31
|
+
], { stdio: "inherit" });
|
|
32
|
+
});
|
|
33
|
+
};
|
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 createRunCommand: () => Command<[], {}, {}>;
|
|
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,EAAE,MAAM,6BAA6B,CAAC;AAGtD,eAAO,MAAM,gBAAgB,2BAW5B,CAAC"}
|
package/dist/commands/run.js
CHANGED
|
@@ -1,191 +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
|
-
// 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
|
-
}),
|
|
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 'start' instead")
|
|
7
|
+
.action(async () => {
|
|
8
|
+
console.warn(chalk.yellow("run command is deprecated, use 'start' and 'deploy' instead"));
|
|
9
|
+
});
|
|
190
10
|
};
|
|
191
|
-
export default Run;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Hex, WalletClient } from "viem";
|
|
2
|
+
import type { Address } from "viem/accounts";
|
|
3
|
+
type SendOptions = {
|
|
4
|
+
eip712TxUrl: string;
|
|
5
|
+
chainId: number;
|
|
6
|
+
maxGasPrice: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const DEFAULT_SEND_CONFIG: Readonly<SendOptions>;
|
|
9
|
+
type TypedData = {
|
|
10
|
+
domain: {
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
chainId: number;
|
|
14
|
+
verifyingContract: Address;
|
|
15
|
+
};
|
|
16
|
+
types: Record<string, {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}[]>;
|
|
20
|
+
primaryType: string;
|
|
21
|
+
message: Record<string, unknown>;
|
|
22
|
+
};
|
|
23
|
+
/** Fetches the nonce for a given user and application */
|
|
24
|
+
export declare const getNonceForEip712: (application: Address, user: Address, sendOptions: SendOptions) => Promise<number>;
|
|
25
|
+
/** Submits a transaction to L2 */
|
|
26
|
+
export declare const postEip712Transaction: (data: Record<string, unknown>, sendOptions: SendOptions) => Promise<{
|
|
27
|
+
id: string;
|
|
28
|
+
}>;
|
|
29
|
+
/** Creates a Typed Data object for signing */
|
|
30
|
+
export declare const createEip712TypedData: (app: Address, data: Hex, nonce: number, sendOptions: SendOptions) => Promise<TypedData>;
|
|
31
|
+
/** Sends a transaction to L2 */
|
|
32
|
+
export declare const sendEip712: (walletClient: WalletClient, applicationAddress: Address, payload: Hex, sendOptions?: Partial<SendOptions>) => Promise<string>;
|
|
33
|
+
export {};
|
|
34
|
+
//# sourceMappingURL=eip712.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip712.d.ts","sourceRoot":"","sources":["../../../src/commands/send/eip712.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,KAAK,WAAW,GAAG;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,WAAW,CAI5C,CAAC;AAEX,KAAK,SAAS,GAAG;IACb,MAAM,EAAE;QACJ,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,iBAAiB,EAAE,OAAO,CAAC;KAC9B,CAAC;IACF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC,CAAC;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,CAAC;AA2CF,yDAAyD;AACzD,eAAO,MAAM,iBAAiB,GAC1B,aAAa,OAAO,EACpB,MAAM,OAAO,EACb,aAAa,WAAW,KACzB,OAAO,CAAC,MAAM,CAMhB,CAAC;AAEF,kCAAkC;AAClC,eAAO,MAAM,qBAAqB,GAC9B,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,aAAa,WAAW,KACzB,OAAO,CAAC;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAMxB,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,qBAAqB,GAC9B,KAAK,OAAO,EACZ,MAAM,GAAG,EACT,OAAO,MAAM,EACb,aAAa,WAAW,KACzB,OAAO,CAAC,SAAS,CAUnB,CAAC;AAEF,gCAAgC;AAChC,eAAO,MAAM,UAAU,GACnB,cAAc,YAAY,EAC1B,oBAAoB,OAAO,EAC3B,SAAS,GAAG,EACZ,cAAc,OAAO,CAAC,WAAW,CAAC,KACnC,OAAO,CAAC,MAAM,CAyBhB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
export const DEFAULT_SEND_CONFIG = {
|
|
2
|
+
eip712TxUrl: "http://localhost:8080/transaction",
|
|
3
|
+
chainId: 31337,
|
|
4
|
+
maxGasPrice: 10,
|
|
5
|
+
};
|
|
6
|
+
const fetchJSON = async (url, options) => {
|
|
7
|
+
const response = await fetch(url, options);
|
|
8
|
+
if (!response.ok) {
|
|
9
|
+
throw new Error(`HTTP Error: ${response.status} - ${await response.text()}`);
|
|
10
|
+
}
|
|
11
|
+
return response.json();
|
|
12
|
+
};
|
|
13
|
+
const serializeBigInt = (_key, value) => typeof value === "bigint" ? value.toString() : value;
|
|
14
|
+
const createTypedDataTemplate = (chainId, verifyingContract) => ({
|
|
15
|
+
domain: {
|
|
16
|
+
name: "Cartesi",
|
|
17
|
+
version: "0.1.0",
|
|
18
|
+
chainId,
|
|
19
|
+
verifyingContract,
|
|
20
|
+
},
|
|
21
|
+
types: {
|
|
22
|
+
EIP712Domain: [
|
|
23
|
+
{ name: "name", type: "string" },
|
|
24
|
+
{ name: "version", type: "string" },
|
|
25
|
+
{ name: "chainId", type: "uint256" },
|
|
26
|
+
{ name: "verifyingContract", type: "address" },
|
|
27
|
+
],
|
|
28
|
+
CartesiMessage: [
|
|
29
|
+
{ name: "app", type: "address" },
|
|
30
|
+
{ name: "nonce", type: "uint64" },
|
|
31
|
+
{ name: "max_gas_price", type: "uint128" },
|
|
32
|
+
{ name: "data", type: "bytes" },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
primaryType: "CartesiMessage",
|
|
36
|
+
message: {},
|
|
37
|
+
});
|
|
38
|
+
/** Fetches the nonce for a given user and application */
|
|
39
|
+
export const getNonceForEip712 = async (application, user, sendOptions) => {
|
|
40
|
+
return fetchJSON(`${sendOptions.eip712TxUrl}/nonce`, {
|
|
41
|
+
method: "POST",
|
|
42
|
+
headers: { "Content-Type": "application/json" },
|
|
43
|
+
body: JSON.stringify({ msg_sender: user, app_contract: application }),
|
|
44
|
+
}).then((res) => res.nonce);
|
|
45
|
+
};
|
|
46
|
+
/** Submits a transaction to L2 */
|
|
47
|
+
export const postEip712Transaction = async (data, sendOptions) => {
|
|
48
|
+
return fetchJSON(`${sendOptions.eip712TxUrl}/submit`, {
|
|
49
|
+
method: "POST",
|
|
50
|
+
headers: { "Content-Type": "application/json" },
|
|
51
|
+
body: JSON.stringify(data, serializeBigInt),
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
/** Creates a Typed Data object for signing */
|
|
55
|
+
export const createEip712TypedData = async (app, data, nonce, sendOptions) => {
|
|
56
|
+
return {
|
|
57
|
+
...createTypedDataTemplate(sendOptions.chainId, app),
|
|
58
|
+
message: {
|
|
59
|
+
app,
|
|
60
|
+
nonce,
|
|
61
|
+
data,
|
|
62
|
+
max_gas_price: BigInt(sendOptions.maxGasPrice),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
/** Sends a transaction to L2 */
|
|
67
|
+
export const sendEip712 = async (walletClient, applicationAddress, payload, sendOptions) => {
|
|
68
|
+
if (!walletClient.account) {
|
|
69
|
+
throw new Error("Wallet account is missing.");
|
|
70
|
+
}
|
|
71
|
+
const options = { ...DEFAULT_SEND_CONFIG, ...sendOptions };
|
|
72
|
+
const account = walletClient.account.address;
|
|
73
|
+
const nonce = await getNonceForEip712(applicationAddress, account, options);
|
|
74
|
+
const typedData = await createEip712TypedData(applicationAddress, payload, nonce, options);
|
|
75
|
+
const signature = await walletClient.signTypedData({
|
|
76
|
+
account,
|
|
77
|
+
...typedData,
|
|
78
|
+
});
|
|
79
|
+
const { id } = await postEip712Transaction({ typedData, account, signature }, options);
|
|
80
|
+
return id;
|
|
81
|
+
};
|
|
@@ -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"}
|
|
@@ -1,50 +1,60 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
1
2
|
import input from "@inquirer/input";
|
|
2
|
-
import
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { erc20Abi, getAddress, isAddress, parseEther, } from "viem";
|
|
3
5
|
import { erc20PortalAbi, erc20PortalAddress } from "../../contracts.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
6
|
+
import { connect, getInputApplicationAddress, } from "../send.js";
|
|
7
|
+
const readToken = async (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
|
+
const ercValidator = (publicClient) => async (value) => {
|
|
28
|
+
if (!isAddress(value)) {
|
|
29
|
+
return "Invalid address";
|
|
26
30
|
}
|
|
27
|
-
|
|
31
|
+
try {
|
|
32
|
+
await readToken(publicClient, value);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
return "Invalid token";
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
};
|
|
39
|
+
export const createErc20Command = () => {
|
|
40
|
+
return new Command("erc20")
|
|
41
|
+
.description("Sends ERC-20 deposits to the application, optionally in interactive mode.")
|
|
42
|
+
.configureHelp({ showGlobalOptions: true })
|
|
43
|
+
.option("--token <address>", "token address")
|
|
44
|
+
.option("--amount <number>", "amount to send")
|
|
45
|
+
.action(async (options, command) => {
|
|
46
|
+
const sendOptions = command.optsWithGlobals();
|
|
47
|
+
// connect to RPC provider
|
|
48
|
+
const { publicClient, walletClient } = await connect(sendOptions);
|
|
28
49
|
// get dapp address from local node, or ask
|
|
29
|
-
const applicationAddress = await
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
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({
|
|
50
|
+
const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
|
|
51
|
+
const tokenAddress = options.token && isAddress(options.token)
|
|
52
|
+
? getAddress(options.token)
|
|
53
|
+
: (await input({
|
|
44
54
|
message: "Token address",
|
|
45
|
-
validate: ercValidator,
|
|
55
|
+
validate: ercValidator(publicClient),
|
|
46
56
|
}));
|
|
47
|
-
const amount =
|
|
57
|
+
const amount = options.amount || (await input({ message: "Amount" }));
|
|
48
58
|
const { request } = await publicClient.simulateContract({
|
|
49
59
|
address: erc20PortalAddress,
|
|
50
60
|
abi: erc20PortalAbi,
|
|
@@ -52,19 +62,14 @@ class SendERC20 extends SendBaseCommand {
|
|
|
52
62
|
args: [
|
|
53
63
|
tokenAddress,
|
|
54
64
|
applicationAddress,
|
|
55
|
-
parseEther(amount),
|
|
65
|
+
parseEther(amount), // XXX: we need to use the token decimals here!
|
|
56
66
|
"0x",
|
|
57
67
|
],
|
|
58
68
|
account: walletClient.account,
|
|
59
69
|
});
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
SendERC20.flags = {
|
|
66
|
-
token: CustomFlags.address({ description: "token address" }),
|
|
67
|
-
amount: CustomFlags.number({ description: "amount" }),
|
|
70
|
+
const hash = await walletClient.writeContract(request);
|
|
71
|
+
const progress = ora("Sending input...").start();
|
|
72
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
73
|
+
progress.succeed(`Input sent: ${hash}`);
|
|
74
|
+
});
|
|
68
75
|
};
|
|
69
|
-
SendERC20.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
70
|
-
export default SendERC20;
|
|
@@ -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 createErc721Command: () => Command<[], {
|
|
3
|
+
token?: string | undefined;
|
|
4
|
+
tokenId?: 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=erc721.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erc721.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc721.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"erc721.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc721.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAuDtD,eAAO,MAAM,mBAAmB;;;;;;;;;EAuD/B,CAAC"}
|