@cartesi/cli 2.0.0-alpha.2 → 2.0.0-alpha.20
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-graphql.yaml +38 -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 +383 -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
package/dist/exec/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/exec/util.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/exec/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAGxD,MAAM,MAAM,qBAAqB,GAC3B;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,IAAI,CAAA;CAAE,GACpC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,qBAAqB,CAAC;AACzE,eAAO,MAAM,mBAAmB,GAC5B,SAAS,MAAM,EACf,MAAM,SAAS,MAAM,EAAE,EACvB,SAAS,0BAA0B;YAbvB,MAAM;kBAAgB,KAAK;GA6C1C,CAAC"}
|
package/dist/exec/util.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import os from "os";
|
|
1
|
+
import { ExecaError, execa } from "execa";
|
|
2
|
+
import os from "node:os";
|
|
4
3
|
export const execaDockerFallback = async (command, args, options) => {
|
|
5
4
|
try {
|
|
6
5
|
if (options.forceDocker) {
|
|
@@ -13,9 +12,6 @@ export const execaDockerFallback = async (command, args, options) => {
|
|
|
13
12
|
catch (error) {
|
|
14
13
|
if (error instanceof ExecaError) {
|
|
15
14
|
if (error.code === "ENOENT" && options.image) {
|
|
16
|
-
if (!options.forceDocker) {
|
|
17
|
-
console.warn(`error executing '${command}', falling back to docker execution using image '${options.image}'`);
|
|
18
|
-
}
|
|
19
15
|
const userInfo = os.userInfo();
|
|
20
16
|
const dockerOpts = [
|
|
21
17
|
"--volume",
|
|
@@ -23,56 +19,13 @@ export const execaDockerFallback = async (command, args, options) => {
|
|
|
23
19
|
"--workdir",
|
|
24
20
|
"/work",
|
|
25
21
|
"--interactive",
|
|
22
|
+
"--rm",
|
|
26
23
|
"--user",
|
|
27
24
|
`${userInfo.uid}:${userInfo.gid}`,
|
|
28
25
|
];
|
|
29
26
|
return await execa("docker", ["run", ...dockerOpts, options.image, command, ...args], options);
|
|
30
27
|
}
|
|
31
|
-
else {
|
|
32
|
-
console.error(`error executing '${command}'`, error);
|
|
33
|
-
}
|
|
34
28
|
}
|
|
35
29
|
throw error;
|
|
36
30
|
}
|
|
37
31
|
};
|
|
38
|
-
export const spawnSyncDockerFallback = (command, args, options) => {
|
|
39
|
-
const result = options.forceDocker
|
|
40
|
-
? { error: { code: "ENOENT" }, stdout: "" }
|
|
41
|
-
: spawnSync(command, args, options);
|
|
42
|
-
if (result.error) {
|
|
43
|
-
const code = result.error.code;
|
|
44
|
-
if (code === "ENOENT" && options.image) {
|
|
45
|
-
if (!options.forceDocker) {
|
|
46
|
-
console.warn(`error executing '${command}', falling back to docker execution using image '${options.image}'`);
|
|
47
|
-
}
|
|
48
|
-
const userInfo = os.userInfo();
|
|
49
|
-
const dockerOpts = [
|
|
50
|
-
"--volume",
|
|
51
|
-
`${options.cwd}:/work`,
|
|
52
|
-
"--workdir",
|
|
53
|
-
"/work",
|
|
54
|
-
"--interactive",
|
|
55
|
-
"--user",
|
|
56
|
-
`${userInfo.uid}:${userInfo.gid}`,
|
|
57
|
-
];
|
|
58
|
-
const dockerArgs = [
|
|
59
|
-
"run",
|
|
60
|
-
...dockerOpts,
|
|
61
|
-
options.image,
|
|
62
|
-
command,
|
|
63
|
-
...args,
|
|
64
|
-
];
|
|
65
|
-
const dockerResult = spawnSync("docker", dockerArgs, options);
|
|
66
|
-
if (dockerResult.error) {
|
|
67
|
-
console.error(`error executing '${command}'`, dockerResult.error);
|
|
68
|
-
throw dockerResult.error;
|
|
69
|
-
}
|
|
70
|
-
return dockerResult;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
console.error(`error executing '${command}'`, result.error);
|
|
74
|
-
throw result.error;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return result;
|
|
78
|
-
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
CHANGED
|
@@ -1 +1,57 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "@commander-js/extra-typings";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { createAddressBookCommand } from "./commands/address-book.js";
|
|
5
|
+
import { createBuildCommand } from "./commands/build.js";
|
|
6
|
+
import { createCleanCommand } from "./commands/clean.js";
|
|
7
|
+
import { createCreateCommand } from "./commands/create.js";
|
|
8
|
+
import { createDeployCommand } from "./commands/deploy.js";
|
|
9
|
+
import { createDepositCommand } from "./commands/deposit.js";
|
|
10
|
+
import { createDoctorCommand } from "./commands/doctor.js";
|
|
11
|
+
import { createHashCommand } from "./commands/hash.js";
|
|
12
|
+
import { createLogsCommand } from "./commands/logs.js";
|
|
13
|
+
import { createRunCommand } from "./commands/run.js";
|
|
14
|
+
import { createSendCommand } from "./commands/send.js";
|
|
15
|
+
import { createShellCommand } from "./commands/shell.js";
|
|
16
|
+
import { createStatusCommand } from "./commands/status.js";
|
|
17
|
+
// Use `createRequire` to import JSON in ESM
|
|
18
|
+
const require = createRequire(import.meta.url);
|
|
19
|
+
const pkg = require("../package.json");
|
|
20
|
+
const splash = String.raw ` .
|
|
21
|
+
/ \
|
|
22
|
+
/ \
|
|
23
|
+
\---/---\ /----\
|
|
24
|
+
\ X \
|
|
25
|
+
\----/ \---/---\
|
|
26
|
+
\ / CARTESI
|
|
27
|
+
\ / CLI
|
|
28
|
+
'`;
|
|
29
|
+
const program = new Command()
|
|
30
|
+
.name("cartesi")
|
|
31
|
+
.version(pkg.version)
|
|
32
|
+
.addHelpText("before", splash)
|
|
33
|
+
.addCommand(createAddressBookCommand())
|
|
34
|
+
.addCommand(createBuildCommand())
|
|
35
|
+
.addCommand(createCleanCommand())
|
|
36
|
+
.addCommand(createCreateCommand())
|
|
37
|
+
.addCommand(createDeployCommand(), { hidden: true })
|
|
38
|
+
.addCommand(createDepositCommand())
|
|
39
|
+
.addCommand(createDoctorCommand())
|
|
40
|
+
.addCommand(createLogsCommand())
|
|
41
|
+
.addCommand(createHashCommand())
|
|
42
|
+
.addCommand(createRunCommand())
|
|
43
|
+
.addCommand(createSendCommand())
|
|
44
|
+
.addCommand(createShellCommand())
|
|
45
|
+
.addCommand(createStatusCommand());
|
|
46
|
+
// Global error handling
|
|
47
|
+
process.on("uncaughtException", (err) => {
|
|
48
|
+
if (process.env.NODE_ENV === "development") {
|
|
49
|
+
console.error(err);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// in production, only print the error message, not the stack trace
|
|
53
|
+
console.error(err.message);
|
|
54
|
+
}
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
57
|
+
program.parse();
|
package/dist/machine.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
-
import { Config, ImageInfo } from "./config.js";
|
|
2
|
-
|
|
1
|
+
import type { Config, ImageInfo } from "./config.js";
|
|
2
|
+
import type { ExecaOptionsDockerFallback } from "./exec/util.js";
|
|
3
|
+
export type BootMachineOptions = {
|
|
4
|
+
finalHash?: boolean;
|
|
5
|
+
interactive?: boolean;
|
|
6
|
+
store?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const bootMachine: (config: Config, info: ImageInfo | undefined, bootOptions: BootMachineOptions, options?: ExecaOptionsDockerFallback) => Promise<import("execa").Result<import("execa").Options & {
|
|
3
9
|
image?: string;
|
|
4
10
|
forceDocker?: false;
|
|
5
11
|
}>>;
|
package/dist/machine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAe,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,SAAS,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAmBjE,MAAM,MAAM,kBAAkB,GAAG;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW,GACpB,QAAQ,MAAM,EACd,MAAM,SAAS,GAAG,SAAS,EAC3B,aAAa,kBAAkB,EAC/B,UAAU,0BAA0B;;;GAkGvC,CAAC"}
|
package/dist/machine.js
CHANGED
|
@@ -15,12 +15,15 @@ const flashDrive = (label, drive) => {
|
|
|
15
15
|
// don't specify start and length
|
|
16
16
|
return `--flash-drive=${vars.join(",")}`;
|
|
17
17
|
};
|
|
18
|
-
export const bootMachine =
|
|
18
|
+
export const bootMachine = (config, info, bootOptions, options) => {
|
|
19
19
|
const { machine } = config;
|
|
20
|
-
const { assertRollingTemplate,
|
|
20
|
+
const { assertRollingTemplate, maxMCycle, noRollup, ramLength, ramImage, useDockerEnv, useDockerWorkdir, user, } = machine;
|
|
21
21
|
// list of environment variables of docker image
|
|
22
|
-
const env = info?.env ?? [];
|
|
23
|
-
const envs = env.map((variable) =>
|
|
22
|
+
const env = useDockerEnv ? (info?.env ?? []) : [];
|
|
23
|
+
const envs = env.map((variable) => {
|
|
24
|
+
const [key, value] = variable.split("=");
|
|
25
|
+
return `--env=${key}="${value}"`;
|
|
26
|
+
});
|
|
24
27
|
// check if we need a rootfstype boot arg
|
|
25
28
|
const root = config.drives.root;
|
|
26
29
|
if (root?.format === "sqfs") {
|
|
@@ -33,10 +36,15 @@ export const bootMachine = async (config, info, destination) => {
|
|
|
33
36
|
// bootargs from config string array
|
|
34
37
|
const bootargs = machine.bootargs.map((arg) => `--append-bootargs="${arg}"`);
|
|
35
38
|
// entrypoint from config or image info (Docker ENTRYPOINT + CMD)
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
let entrypoint;
|
|
40
|
+
if (machine.entrypoint) {
|
|
41
|
+
entrypoint = machine.entrypoint;
|
|
42
|
+
}
|
|
43
|
+
else if (info && (info.entrypoint.length > 0 || info.cmd.length > 0)) {
|
|
44
|
+
entrypoint = [...info.entrypoint, ...info.cmd].join(" ");
|
|
45
|
+
}
|
|
38
46
|
if (!entrypoint) {
|
|
39
|
-
throw new Error("Undefined machine entrypoint");
|
|
47
|
+
throw new Error("Undefined machine entrypoint. Please define an entrypoint in your cartesi.toml config or in your Dockerfile.");
|
|
40
48
|
}
|
|
41
49
|
const flashDrives = Object.entries(config.drives).map(([label, drive]) => flashDrive(label, drive));
|
|
42
50
|
// command to change working directory if WORKDIR is defined
|
|
@@ -44,20 +52,21 @@ export const bootMachine = async (config, info, destination) => {
|
|
|
44
52
|
...bootargs,
|
|
45
53
|
...envs,
|
|
46
54
|
...flashDrives,
|
|
47
|
-
`--ram-image=${ramImage}`,
|
|
48
55
|
`--ram-length=${ramLength}`,
|
|
49
|
-
`--append-entrypoint=${entrypoint}`,
|
|
50
56
|
];
|
|
57
|
+
if (ramImage) {
|
|
58
|
+
args.push(`--ram-image=${ramImage}`);
|
|
59
|
+
}
|
|
51
60
|
if (assertRollingTemplate) {
|
|
52
61
|
args.push("--assert-rolling-template");
|
|
53
62
|
}
|
|
54
|
-
if (finalHash) {
|
|
63
|
+
if (bootOptions.finalHash) {
|
|
55
64
|
args.push("--final-hash");
|
|
56
65
|
}
|
|
57
|
-
if (info?.workdir) {
|
|
66
|
+
if (useDockerWorkdir && info?.workdir) {
|
|
58
67
|
args.push(`--workdir="${info.workdir}"`);
|
|
59
68
|
}
|
|
60
|
-
if (interactive) {
|
|
69
|
+
if (bootOptions.interactive) {
|
|
61
70
|
args.push("-it");
|
|
62
71
|
}
|
|
63
72
|
if (noRollup) {
|
|
@@ -66,15 +75,16 @@ export const bootMachine = async (config, info, destination) => {
|
|
|
66
75
|
if (maxMCycle) {
|
|
67
76
|
args.push(`--max-mcycle=${maxMCycle.toString()}`);
|
|
68
77
|
}
|
|
69
|
-
if (store) {
|
|
70
|
-
args.push(`--store=${store}`);
|
|
78
|
+
if (bootOptions.store) {
|
|
79
|
+
args.push(`--store=${bootOptions.store}`);
|
|
71
80
|
}
|
|
72
81
|
if (user) {
|
|
73
82
|
args.push(`--user=${user}`);
|
|
74
83
|
}
|
|
84
|
+
args.push("--");
|
|
85
|
+
args.push(entrypoint);
|
|
75
86
|
return cartesiMachine.boot(args, {
|
|
76
|
-
cwd: destination,
|
|
77
87
|
image: config.sdk,
|
|
78
|
-
|
|
88
|
+
...options,
|
|
79
89
|
});
|
|
80
90
|
};
|
package/dist/prompts.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Separator } from "@inquirer/core";
|
|
2
2
|
import input from "@inquirer/input";
|
|
3
3
|
import select from "@inquirer/select";
|
|
4
|
-
import { Context } from "@inquirer/type";
|
|
5
|
-
import { Address, Hex } from "viem";
|
|
4
|
+
import type { Context } from "@inquirer/type";
|
|
5
|
+
import { type Address, type Hex } from "viem";
|
|
6
6
|
type InputConfig = Parameters<typeof input>[0];
|
|
7
7
|
type SelectConfig<ValueType> = Parameters<typeof select<ValueType>>[0];
|
|
8
8
|
/**
|
|
@@ -34,6 +34,7 @@ export declare const bigintInput: (config: BigintPromptConfig) => Promise<bigint
|
|
|
34
34
|
* @returns bytes as hex string
|
|
35
35
|
*/
|
|
36
36
|
export declare const bytesInput: (config: InputConfig & {
|
|
37
|
+
encoding?: "string" | "hex" | "abi";
|
|
37
38
|
message: string;
|
|
38
39
|
}) => Promise<Hex>;
|
|
39
40
|
/**
|
|
@@ -58,5 +59,15 @@ export type SelectAutoConfig<ValueType> = SelectConfig<ValueType> & {
|
|
|
58
59
|
export declare const selectAuto: <ValueType>(config: SelectAutoConfig<ValueType> & {
|
|
59
60
|
discardDisabled?: boolean;
|
|
60
61
|
}, context?: Context | undefined) => Promise<ValueType>;
|
|
62
|
+
export declare const keySelect: <Value>(config: {
|
|
63
|
+
choices: readonly Choice<Value>[];
|
|
64
|
+
separator?: string | undefined;
|
|
65
|
+
}, context?: Context) => Promise<Value> & {
|
|
66
|
+
cancel: () => void;
|
|
67
|
+
};
|
|
68
|
+
export declare const getInputApplicationAddress: (options: {
|
|
69
|
+
application?: string;
|
|
70
|
+
projectName?: string;
|
|
71
|
+
}) => Promise<Address>;
|
|
61
72
|
export {};
|
|
62
73
|
//# sourceMappingURL=prompts.d.ts.map
|
package/dist/prompts.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA6B,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,GAAG,EASX,MAAM,MAAM,CAAC;AAGd,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/C,KAAK,YAAY,CAAC,SAAS,IAAI,UAAU,CAAC,OAAO,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AACtE,eAAO,MAAM,YAAY,GACrB,QAAQ,mBAAmB,KAC5B,OAAO,CAAC,OAAO,CAMjB,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG;IAAE,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,CAAC;AAC9D,eAAO,MAAM,QAAQ,GAAU,QAAQ,eAAe,KAAG,OAAO,CAAC,GAAG,CAMnE,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,WAAW,GAAG;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AACF,eAAO,MAAM,WAAW,GACpB,QAAQ,kBAAkB,KAC3B,OAAO,CAAC,MAAM,CAUhB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GACnB,QAAQ,WAAW,GAAG;IAClB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;CACnB,KACF,OAAO,CAAC,GAAG,CAkDb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GACvB,QAAQ,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,KAC1C,OAAO,CAAC,KAAK,MAAM,EAAE,CA+DvB,CAAC;AAGF,MAAM,MAAM,MAAM,CAAC,SAAS,IAAI;IAC5B,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC5B,IAAI,CAAC,EAAE,KAAK,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,gBAAgB,CAAC,SAAS,IAAI,YAAY,CAAC,SAAS,CAAC,GAAG;IAChE,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC,CAAC;IACtD,QAAQ,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,eAAO,MAAM,UAAU,GAAI,SAAS,EAChC,QAAQ,gBAAgB,CAAC,SAAS,CAAC,GAAG;IAAE,eAAe,CAAC,EAAE,OAAO,CAAA;CAAE,EACnE,UAAU,OAAO,GAAG,SAAS,KAC9B,OAAO,CAAC,SAAS,CAsBnB,CAAC;AAOF,eAAO,MAAM,SAAS,GACjB,KAAK;;gBAJM,MAAM;;;CAoBrB,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAU,SAAS;IACtD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,KAAG,OAAO,CAAC,OAAO,CAoBlB,CAAC"}
|
package/dist/prompts.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import confirm from "@inquirer/confirm";
|
|
2
|
+
import { Separator, createPrompt, useKeypress } from "@inquirer/core";
|
|
2
3
|
import input from "@inquirer/input";
|
|
3
4
|
import select from "@inquirer/select";
|
|
4
5
|
import chalk from "chalk";
|
|
5
6
|
import { encodeAbiParameters, formatUnits, getAddress, isAddress, isHex, parseAbiParameters, parseUnits, stringToHex, } from "viem";
|
|
7
|
+
import { getApplicationAddress } from "./exec/rollups.js";
|
|
6
8
|
export const addressInput = async (config) => {
|
|
7
9
|
const address = await input({
|
|
8
10
|
...config,
|
|
@@ -18,7 +20,7 @@ export const hexInput = async (config) => {
|
|
|
18
20
|
return value;
|
|
19
21
|
};
|
|
20
22
|
export const bigintInput = async (config) => {
|
|
21
|
-
const defaultValue = config.default
|
|
23
|
+
const defaultValue = config.default !== undefined
|
|
22
24
|
? formatUnits(config.default, config.decimals)
|
|
23
25
|
: undefined;
|
|
24
26
|
const value = await input({
|
|
@@ -33,26 +35,27 @@ export const bigintInput = async (config) => {
|
|
|
33
35
|
* @returns bytes as hex string
|
|
34
36
|
*/
|
|
35
37
|
export const bytesInput = async (config) => {
|
|
36
|
-
const encoding =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
38
|
+
const encoding = config.encoding ??
|
|
39
|
+
(await select({
|
|
40
|
+
...config,
|
|
41
|
+
choices: [
|
|
42
|
+
{
|
|
43
|
+
value: "string",
|
|
44
|
+
name: "String encoding",
|
|
45
|
+
description: "Convert UTF-8 string to bytes",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
value: "hex",
|
|
49
|
+
name: "Hex string encoding",
|
|
50
|
+
description: "Convert a hex string to bytes (must start with 0x)",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
value: "abi",
|
|
54
|
+
name: "ABI encoding",
|
|
55
|
+
description: "Input as ABI encoding parameters https://abitype.dev/api/human#parseabiparameters",
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
}));
|
|
56
59
|
switch (encoding) {
|
|
57
60
|
case "hex": {
|
|
58
61
|
const valueHex = await hexInput({
|
|
@@ -82,13 +85,13 @@ export const bytesInput = async (config) => {
|
|
|
82
85
|
*/
|
|
83
86
|
export const abiParamsInput = async (config) => {
|
|
84
87
|
const encoding = await input({
|
|
85
|
-
message: `${config.message} (as ABI encoded https://abitype.dev/api/human
|
|
88
|
+
message: `${config.message} (as ABI encoded https://abitype.dev/api/human#parseabiparameters )`,
|
|
86
89
|
validate: (value) => {
|
|
87
90
|
try {
|
|
88
91
|
parseAbiParameters(value);
|
|
89
92
|
return true;
|
|
90
93
|
}
|
|
91
|
-
catch
|
|
94
|
+
catch {
|
|
92
95
|
return "Invalid ABI parameters";
|
|
93
96
|
}
|
|
94
97
|
},
|
|
@@ -118,7 +121,7 @@ export const abiParamsInput = async (config) => {
|
|
|
118
121
|
BigInt(value);
|
|
119
122
|
return true;
|
|
120
123
|
}
|
|
121
|
-
catch
|
|
124
|
+
catch {
|
|
122
125
|
return "Invalid number";
|
|
123
126
|
}
|
|
124
127
|
},
|
|
@@ -142,11 +145,11 @@ export const abiParamsInput = async (config) => {
|
|
|
142
145
|
export const selectAuto = (config, context) => {
|
|
143
146
|
const choices = config.choices;
|
|
144
147
|
const list = config.discardDisabled
|
|
145
|
-
? choices.filter((c) => c
|
|
148
|
+
? choices.filter((c) => !(c instanceof Separator) && !c.disabled)
|
|
146
149
|
: choices;
|
|
147
150
|
if (list.length === 1) {
|
|
148
151
|
const choice = list[0];
|
|
149
|
-
if (choice
|
|
152
|
+
if (!(choice instanceof Separator)) {
|
|
150
153
|
const output = context?.output || process.stdout;
|
|
151
154
|
const prefix = chalk.green("?");
|
|
152
155
|
const message = chalk.bold(config.message);
|
|
@@ -156,3 +159,34 @@ export const selectAuto = (config, context) => {
|
|
|
156
159
|
}
|
|
157
160
|
return select(config, context);
|
|
158
161
|
};
|
|
162
|
+
export const keySelect = createPrompt((config, done) => {
|
|
163
|
+
const choices = config.choices;
|
|
164
|
+
const separator = config.separator ?? "\t";
|
|
165
|
+
const options = choices
|
|
166
|
+
.map((c) => `(${chalk.cyan(c.value)}) ${c.name ?? ""}`)
|
|
167
|
+
.join(separator);
|
|
168
|
+
useKeypress((key) => {
|
|
169
|
+
const selected = choices.find((c) => c.value === key.name);
|
|
170
|
+
if (selected) {
|
|
171
|
+
done(selected.value);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
return `${options} `;
|
|
175
|
+
});
|
|
176
|
+
export const getInputApplicationAddress = async (options) => {
|
|
177
|
+
const { application, projectName } = options;
|
|
178
|
+
if (application && isAddress(application)) {
|
|
179
|
+
// honor the flag
|
|
180
|
+
return application;
|
|
181
|
+
}
|
|
182
|
+
// get the running container application address
|
|
183
|
+
const nodeAddress = await getApplicationAddress({ projectName });
|
|
184
|
+
if (nodeAddress) {
|
|
185
|
+
return nodeAddress;
|
|
186
|
+
}
|
|
187
|
+
// query for the address
|
|
188
|
+
const applicationAddress = await addressInput({
|
|
189
|
+
message: "Application address",
|
|
190
|
+
});
|
|
191
|
+
return applicationAddress;
|
|
192
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,sBAAsB,EAAoB,MAAM,OAAO,CAAC;AAEtE,eAAO,MAAM,QAAQ,GACjB,UAAU,MAAM,EAChB,QAAQ,MAAM,EACd,KAAK,MAAM,KACZ,OAAO,CAAC,sBAAsB,CAehC,CAAC"}
|
package/dist/template.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { downloadTemplate } from "giget";
|
|
2
|
+
export const download = async (template, branch, out) => {
|
|
3
|
+
const cartesiProvider = async (input) => {
|
|
4
|
+
return {
|
|
5
|
+
name: "cartesi",
|
|
6
|
+
subdir: input,
|
|
7
|
+
url: "https://github.com/cartesi/application-templates",
|
|
8
|
+
tar: `https://codeload.github.com/cartesi/application-templates/tar.gz/refs/heads/${branch}`,
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
const input = `cartesi:${template}`;
|
|
12
|
+
return downloadTemplate(input, {
|
|
13
|
+
dir: out,
|
|
14
|
+
providers: { cartesi: cartesiProvider },
|
|
15
|
+
});
|
|
16
|
+
};
|