@cartesi/cli 2.0.0-alpha.11 → 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 +2 -2
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +9 -13
- 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/build.js +2 -2
- package/dist/commands/create.d.ts +5 -1
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +31 -4
- package/dist/commands/deploy.d.ts +16 -1
- package/dist/commands/deploy.d.ts.map +1 -1
- package/dist/commands/deploy.js +267 -8
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +3 -9
- package/dist/commands/{rollups/logs.d.ts → logs.d.ts} +2 -3
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/{rollups/logs.js → logs.js} +4 -3
- package/dist/commands/run.js +2 -2
- 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/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +1 -1
- package/dist/commands/send/generic.d.ts +2 -0
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +18 -10
- package/dist/commands/send.d.ts +1 -1
- package/dist/commands/send.d.ts.map +1 -1
- package/dist/commands/send.js +4 -4
- package/dist/commands/shell.js +1 -1
- package/dist/commands/{rollups/start.d.ts → start.d.ts} +3 -3
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/{rollups/start.js → start.js} +24 -15
- package/dist/commands/{rollups/status.d.ts → status.d.ts} +2 -3
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/{rollups/status.js → status.js} +7 -6
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/{rollups/stop.js → stop.js} +4 -3
- package/dist/compose/{rollups/default.env → default.env} +1 -0
- package/dist/compose/{rollups/docker-compose-bundler.yaml → docker-compose-bundler.yaml} +0 -6
- package/dist/compose/{rollups/docker-compose-espresso.yaml → docker-compose-espresso.yaml} +11 -20
- package/dist/compose/{rollups/docker-compose-graphql.yaml → docker-compose-graphql.yaml} +2 -2
- package/dist/compose/{rollups/docker-compose-node.yaml → docker-compose-node.yaml} +6 -1
- package/dist/compose/docker-compose-passkey-server.yaml +15 -0
- package/dist/compose/{rollups/proxy → proxy}/bundler.yaml +12 -0
- package/dist/compose/proxy/passkey-server.yaml +17 -0
- package/dist/compose/{rollups/proxy → proxy}/rollups-node.yaml +2 -2
- package/dist/config.d.ts +4 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +22 -21
- 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 +3 -3
- 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 +1 -1
- package/dist/exec/rollups.d.ts.map +1 -1
- package/dist/exec/util.d.ts +2 -2
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +6 -10
- package/dist/index.js +10 -4
- 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 +2 -2
- package/dist/template.d.ts.map +1 -1
- package/dist/template.js +2 -2
- package/dist/wallet.d.ts +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +77 -93
- package/package.json +5 -6
- package/dist/commands/rollups/create.d.ts +0 -7
- package/dist/commands/rollups/create.d.ts.map +0 -1
- package/dist/commands/rollups/create.js +0 -36
- package/dist/commands/rollups/deploy.d.ts +0 -16
- package/dist/commands/rollups/deploy.d.ts.map +0 -1
- package/dist/commands/rollups/deploy.js +0 -237
- package/dist/commands/rollups/logs.d.ts.map +0 -1
- package/dist/commands/rollups/start.d.ts.map +0 -1
- package/dist/commands/rollups/status.d.ts.map +0 -1
- package/dist/commands/rollups/stop.d.ts +0 -5
- package/dist/commands/rollups/stop.d.ts.map +0 -1
- package/dist/commands/rollups.d.ts +0 -6
- package/dist/commands/rollups.d.ts.map +0 -1
- package/dist/commands/rollups.js +0 -21
- /package/dist/compose/{rollups/docker-compose-anvil.yaml → docker-compose-anvil.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-database.yaml → docker-compose-database.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-explorer.yaml → docker-compose-explorer.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-node-cpus.yaml → docker-compose-node-cpus.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-node-memory.yaml → docker-compose-node-memory.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-paymaster.yaml → docker-compose-paymaster.yaml} +0 -0
- /package/dist/compose/{rollups/docker-compose-proxy.yaml → docker-compose-proxy.yaml} +0 -0
- /package/dist/compose/{rollups/proxy → proxy}/anvil.yaml +0 -0
- /package/dist/compose/{rollups/proxy → proxy}/espresso.yaml +0 -0
- /package/dist/compose/{rollups/proxy → proxy}/explorer-api.yaml +0 -0
- /package/dist/compose/{rollups/proxy → proxy}/explorer.yaml +0 -0
- /package/dist/compose/{rollups/proxy → proxy}/graphql.yaml +0 -0
- /package/dist/compose/{rollups/proxy → proxy}/paymaster.yaml +0 -0
package/dist/base.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Address, Hash } from "viem";
|
|
2
|
-
import { Config } from "./config.js";
|
|
1
|
+
import { type Address, type Hash } from "viem";
|
|
2
|
+
import { type Config } from "./config.js";
|
|
3
3
|
export declare const getContextPath: (...paths: string[]) => string;
|
|
4
4
|
export declare const getMachineHash: () => Hash | undefined;
|
|
5
5
|
export declare const getApplicationConfig: (configPath: string) => Config;
|
package/dist/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAIA,OAAO,
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,IAAI,EAKZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,KAAK,MAAM,EAAS,MAAM,aAAa,CAAC;AAkBjD,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,MAAM,EAAE,KAAG,MAEnD,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,IAAI,GAAG,SAUxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,KAAG,MAIzD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,WAAW,CAkC1D,CAAC;AAqBF,eAAO,MAAM,eAAe,GAAU,SAAS;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAG7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,SAAS;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAG7B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAAO,GAAG,SAQtD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,IAQzC,CAAC"}
|
package/dist/base.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InvalidArgumentError } from "@commander-js/extra-typings";
|
|
2
2
|
import { execa } from "execa";
|
|
3
|
-
import fs from "fs";
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { getAddress, isAddress, isHash, zeroHash } from "viem";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { getAddress, isAddress, isHash, zeroHash, } from "viem";
|
|
6
6
|
import { parse } from "./config.js";
|
|
7
7
|
import { applicationFactoryAddress, authorityFactoryAddress, erc1155BatchPortalAddress, erc1155SinglePortalAddress, erc20PortalAddress, erc721PortalAddress, etherPortalAddress, inputBoxAddress, selfHostedApplicationFactoryAddress, testMultiTokenAddress, testNftAddress, testTokenAddress, } from "./contracts.js";
|
|
8
8
|
import { getApplicationAddress } from "./exec/rollups.js";
|
|
@@ -83,21 +83,17 @@ export const parseAddress = (value) => {
|
|
|
83
83
|
if (isAddress(value)) {
|
|
84
84
|
return getAddress(value);
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
throw new InvalidArgumentError(`Invalid address: ${value}`);
|
|
89
|
-
}
|
|
90
|
-
return undefined;
|
|
86
|
+
if (value !== "") {
|
|
87
|
+
throw new InvalidArgumentError(`Invalid address: ${value}`);
|
|
91
88
|
}
|
|
89
|
+
return undefined;
|
|
92
90
|
};
|
|
93
91
|
export const parseHash = (value) => {
|
|
94
92
|
if (isHash(value)) {
|
|
95
93
|
return value;
|
|
96
94
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
throw new InvalidArgumentError(`Invalid hash: ${value}`);
|
|
100
|
-
}
|
|
101
|
-
return zeroHash;
|
|
95
|
+
if (value !== "") {
|
|
96
|
+
throw new InvalidArgumentError(`Invalid hash: ${value}`);
|
|
102
97
|
}
|
|
98
|
+
return zeroHash;
|
|
103
99
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DirectoryDriveConfig } from "../config.js";
|
|
2
|
-
export declare const build: (name: string, drive: DirectoryDriveConfig, sdkImage: string, destination: string) => Promise<
|
|
1
|
+
import type { DirectoryDriveConfig } from "../config.js";
|
|
2
|
+
export declare const build: (name: string, drive: DirectoryDriveConfig, sdkImage: string, destination: string) => Promise<undefined>;
|
|
3
3
|
//# sourceMappingURL=directory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/builder/directory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/builder/directory.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGzD,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,oBAAoB,EAC3B,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,SAAS,CAkCnB,CAAC"}
|
package/dist/builder/docker.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/builder/docker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/builder/docker.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQtD,KAAK,SAAS,GAAG;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AA+DF,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,iBAAiB,EACxB,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,SAAS,GAAG,SAAS,CA4D/B,CAAC"}
|
package/dist/builder/docker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
import tmp from "tmp";
|
|
5
5
|
import { crane, genext2fs, mksquashfs } from "../exec/index.js";
|
|
6
6
|
/**
|
|
@@ -22,7 +22,7 @@ const buildImage = async (options) => {
|
|
|
22
22
|
context,
|
|
23
23
|
];
|
|
24
24
|
// set tags for the image built
|
|
25
|
-
args.push(...tags.
|
|
25
|
+
args.push(...tags.flatMap((tag) => ["--tag", tag]));
|
|
26
26
|
if (target) {
|
|
27
27
|
args.push("--target", target);
|
|
28
28
|
}
|
|
@@ -43,14 +43,14 @@ const getImageInfo = async (image) => {
|
|
|
43
43
|
// parse image info from docker inspect output
|
|
44
44
|
const [imageInfo] = JSON.parse(jsonStr);
|
|
45
45
|
// validate image architecture (must be riscv64)
|
|
46
|
-
if (imageInfo
|
|
47
|
-
throw new Error(`Invalid image Architecture: ${imageInfo
|
|
46
|
+
if (imageInfo.Architecture !== "riscv64") {
|
|
47
|
+
throw new Error(`Invalid image Architecture: ${imageInfo.Architecture}. Expected riscv64`);
|
|
48
48
|
}
|
|
49
49
|
const info = {
|
|
50
|
-
cmd: imageInfo
|
|
51
|
-
entrypoint: imageInfo
|
|
52
|
-
env: imageInfo
|
|
53
|
-
workdir: imageInfo
|
|
50
|
+
cmd: imageInfo.Config.Cmd ?? [],
|
|
51
|
+
entrypoint: imageInfo.Config.Entrypoint ?? [],
|
|
52
|
+
env: imageInfo.Config.Env || [],
|
|
53
|
+
workdir: imageInfo.Config.WorkingDir,
|
|
54
54
|
};
|
|
55
55
|
return info;
|
|
56
56
|
};
|
package/dist/builder/empty.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { EmptyDriveConfig } from "../config.js";
|
|
2
|
-
export declare const build: (name: string, drive: EmptyDriveConfig, sdkImage: string, destination: string) => Promise<
|
|
1
|
+
import type { EmptyDriveConfig } from "../config.js";
|
|
2
|
+
export declare const build: (name: string, drive: EmptyDriveConfig, sdkImage: string, destination: string) => Promise<undefined>;
|
|
3
3
|
//# sourceMappingURL=empty.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../src/builder/empty.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../src/builder/empty.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGrD,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,gBAAgB,EACvB,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,SAAS,CAoBnB,CAAC"}
|
package/dist/builder/empty.js
CHANGED
package/dist/builder/none.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ExistingDriveConfig } from "../config.js";
|
|
2
|
-
export declare const build: (name: string, drive: ExistingDriveConfig, destination: string) => Promise<
|
|
1
|
+
import { type ExistingDriveConfig } from "../config.js";
|
|
2
|
+
export declare const build: (name: string, drive: ExistingDriveConfig, destination: string) => Promise<undefined>;
|
|
3
3
|
//# sourceMappingURL=none.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"none.d.ts","sourceRoot":"","sources":["../../src/builder/none.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAkB,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"none.d.ts","sourceRoot":"","sources":["../../src/builder/none.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,mBAAmB,EAAkB,MAAM,cAAc,CAAC;AAExE,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,mBAAmB,EAC1B,aAAa,MAAM,KACpB,OAAO,CAAC,SAAS,CAQnB,CAAC"}
|
package/dist/builder/none.js
CHANGED
package/dist/builder/tar.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TarDriveConfig } from "../config.js";
|
|
2
|
-
export declare const build: (name: string, drive: TarDriveConfig, sdkImage: string, destination: string) => Promise<
|
|
1
|
+
import type { TarDriveConfig } from "../config.js";
|
|
2
|
+
export declare const build: (name: string, drive: TarDriveConfig, sdkImage: string, destination: string) => Promise<undefined>;
|
|
3
3
|
//# sourceMappingURL=tar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../src/builder/tar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../src/builder/tar.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGnD,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,cAAc,EACrB,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,SAAS,CA4BnB,CAAC"}
|
package/dist/builder/tar.js
CHANGED
package/dist/commands/build.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Command } from "@commander-js/extra-typings";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
import tmp from "tmp";
|
|
5
5
|
import { getApplicationConfig, getContextPath } from "../base.js";
|
|
6
6
|
import { buildDirectory, buildDocker, buildEmpty, buildNone, buildTar, } from "../builder/index.js";
|
|
@@ -50,7 +50,7 @@ export const createBuildCommand = () => {
|
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
52
|
// get image info of root drive
|
|
53
|
-
const root = await results
|
|
53
|
+
const root = await results.root;
|
|
54
54
|
const imageInfo = root || undefined;
|
|
55
55
|
// path of machine snapshot
|
|
56
56
|
const snapshotPath = getContextPath("image");
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import { Command } from "@commander-js/extra-typings";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const DEFAULT_TEMPLATES_BRANCH = "prerelease/sdk-12";
|
|
3
|
+
export declare const createCreateCommand: () => Command<[string], {
|
|
4
|
+
template: "cpp" | "cpp-low-level" | "go" | "javascript" | "lua" | "python" | "ruby" | "rust" | "typescript";
|
|
5
|
+
branch: string;
|
|
6
|
+
}, {}>;
|
|
3
7
|
//# sourceMappingURL=create.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAK9D,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAc5D,eAAO,MAAM,mBAAmB;;;MA0B/B,CAAC"}
|
package/dist/commands/create.js
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
|
-
import { Command } from "@commander-js/extra-typings";
|
|
1
|
+
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { download } from "../template.js";
|
|
5
|
+
export const DEFAULT_TEMPLATES_BRANCH = "prerelease/sdk-12";
|
|
6
|
+
const TEMPLATES = [
|
|
7
|
+
"cpp",
|
|
8
|
+
"cpp-low-level",
|
|
9
|
+
"go",
|
|
10
|
+
"javascript",
|
|
11
|
+
"lua",
|
|
12
|
+
"python",
|
|
13
|
+
"ruby",
|
|
14
|
+
"rust",
|
|
15
|
+
"typescript",
|
|
16
|
+
];
|
|
3
17
|
export const createCreateCommand = () => {
|
|
4
18
|
return new Command("create")
|
|
5
|
-
.
|
|
6
|
-
.
|
|
7
|
-
|
|
19
|
+
.argument("<name>", "application and directory name")
|
|
20
|
+
.addOption(new Option("-t, --template <template>", "template name to use")
|
|
21
|
+
.choices(TEMPLATES)
|
|
22
|
+
.makeOptionMandatory())
|
|
23
|
+
.option("-b, --branch <branch>", "cartesi/application-templates repository branch name to use", DEFAULT_TEMPLATES_BRANCH)
|
|
24
|
+
.action(async (name, { branch, template }) => {
|
|
25
|
+
const spinner = ora("Creating application...").start();
|
|
26
|
+
try {
|
|
27
|
+
const { dir } = await download(template, branch, name);
|
|
28
|
+
spinner.succeed(`Application created at ${chalk.cyan(dir)}`);
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
spinner.fail(e instanceof Error
|
|
32
|
+
? `Error creating application: ${chalk.red(e.message)}`
|
|
33
|
+
: String(e));
|
|
34
|
+
}
|
|
8
35
|
});
|
|
9
36
|
};
|
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
import { Command } from "@commander-js/extra-typings";
|
|
2
|
-
export declare const createDeployCommand: () => Command<[], {
|
|
2
|
+
export declare const createDeployCommand: () => Command<[], {
|
|
3
|
+
environmentName: string;
|
|
4
|
+
chainId: number;
|
|
5
|
+
rpcUrl?: string | undefined;
|
|
6
|
+
mnemonic?: string | undefined;
|
|
7
|
+
mnemonicIndex: number;
|
|
8
|
+
name?: string | undefined;
|
|
9
|
+
authorityOwner?: `0x${string}` | undefined;
|
|
10
|
+
applicationOwner?: `0x${string}` | undefined;
|
|
11
|
+
epochLength: number;
|
|
12
|
+
salt: `0x${string}`;
|
|
13
|
+
json?: true | undefined;
|
|
14
|
+
dataAvailability: "input-box" | "espresso";
|
|
15
|
+
espressoBlock: number;
|
|
16
|
+
espressoNamespace: number;
|
|
17
|
+
}, {}>;
|
|
3
18
|
//# sourceMappingURL=deploy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAyQ9D,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;MAuJ/B,CAAC"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -1,12 +1,271 @@
|
|
|
1
|
-
import { Command } from "@commander-js/extra-typings";
|
|
1
|
+
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
+
import input from "@inquirer/input";
|
|
2
3
|
import chalk from "chalk";
|
|
3
|
-
import {
|
|
4
|
+
import { execa } from "execa";
|
|
5
|
+
import ora from "ora";
|
|
6
|
+
import { encodeFunctionData, zeroHash } from "viem";
|
|
7
|
+
import { cannon } from "viem/chains";
|
|
8
|
+
import { getContextPath, getMachineHash, parseAddress, parseHash, } from "../base.js";
|
|
9
|
+
import { DEFAULT_COMPOSE_ENVIRONMENT_NAME } from "../config.js";
|
|
10
|
+
import { applicationFactoryAbi, applicationFactoryAddress, authorityFactoryAbi, authorityFactoryAddress, dataAvailabilityAbi, inputBoxAddress, } from "../contracts.js";
|
|
11
|
+
import { addressInput } from "../prompts.js";
|
|
12
|
+
import { connect } from "./send.js";
|
|
13
|
+
/**
|
|
14
|
+
* Deploy authority contract (if not already deployed)
|
|
15
|
+
* @param options
|
|
16
|
+
* @returns address of the authority
|
|
17
|
+
*/
|
|
18
|
+
const deployAuthority = async (publicClient, walletClient, options) => {
|
|
19
|
+
const { epochLength, progress, salt } = options;
|
|
20
|
+
// deploy authority contract (if not already deployed)
|
|
21
|
+
const authorityOwner = options.authorityOwner ||
|
|
22
|
+
(await addressInput({
|
|
23
|
+
message: "Authority Owner",
|
|
24
|
+
default: walletClient.account?.address,
|
|
25
|
+
}));
|
|
26
|
+
const authorityAddress = await publicClient.readContract({
|
|
27
|
+
abi: authorityFactoryAbi,
|
|
28
|
+
address: authorityFactoryAddress,
|
|
29
|
+
functionName: "calculateAuthorityAddress",
|
|
30
|
+
args: [authorityOwner, BigInt(epochLength), salt],
|
|
31
|
+
});
|
|
32
|
+
// check if authority is already deployed
|
|
33
|
+
const authorityCode = await publicClient.getCode({
|
|
34
|
+
address: authorityAddress,
|
|
35
|
+
});
|
|
36
|
+
if (authorityCode === undefined) {
|
|
37
|
+
// deploy authority
|
|
38
|
+
const { request } = await publicClient.simulateContract({
|
|
39
|
+
abi: authorityFactoryAbi,
|
|
40
|
+
address: authorityFactoryAddress,
|
|
41
|
+
account: walletClient.account,
|
|
42
|
+
functionName: "newAuthority",
|
|
43
|
+
args: [authorityOwner, BigInt(epochLength), salt],
|
|
44
|
+
});
|
|
45
|
+
progress.start("Deploying authority...");
|
|
46
|
+
const hash = await walletClient.writeContract(request);
|
|
47
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
48
|
+
progress.succeed(`Authority ${chalk.cyan(authorityAddress)}`);
|
|
49
|
+
}
|
|
50
|
+
return authorityAddress;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Deploy application contract
|
|
54
|
+
* @param options
|
|
55
|
+
* @returns address of the application
|
|
56
|
+
*/
|
|
57
|
+
const deployApplication = async (publicClient, walletClient, options) => {
|
|
58
|
+
const { authorityAddress, progress, salt, templateHash, dataAvailability } = options;
|
|
59
|
+
const applicationOwner = options.applicationOwner ||
|
|
60
|
+
(await addressInput({
|
|
61
|
+
message: "Application Owner",
|
|
62
|
+
default: walletClient.account?.address,
|
|
63
|
+
}));
|
|
64
|
+
const applicationAddress = await publicClient.readContract({
|
|
65
|
+
abi: applicationFactoryAbi,
|
|
66
|
+
address: applicationFactoryAddress,
|
|
67
|
+
functionName: "calculateApplicationAddress",
|
|
68
|
+
args: [
|
|
69
|
+
authorityAddress,
|
|
70
|
+
applicationOwner,
|
|
71
|
+
templateHash,
|
|
72
|
+
dataAvailability,
|
|
73
|
+
salt,
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
// check if application is already deployed
|
|
77
|
+
const applicationCode = await publicClient.getCode({
|
|
78
|
+
address: applicationAddress,
|
|
79
|
+
});
|
|
80
|
+
if (applicationCode === undefined) {
|
|
81
|
+
// deploy application
|
|
82
|
+
const { request } = await publicClient.simulateContract({
|
|
83
|
+
abi: applicationFactoryAbi,
|
|
84
|
+
address: applicationFactoryAddress,
|
|
85
|
+
account: walletClient.account,
|
|
86
|
+
functionName: "newApplication",
|
|
87
|
+
args: [
|
|
88
|
+
authorityAddress,
|
|
89
|
+
applicationOwner,
|
|
90
|
+
templateHash,
|
|
91
|
+
dataAvailability,
|
|
92
|
+
salt,
|
|
93
|
+
],
|
|
94
|
+
});
|
|
95
|
+
progress.start("Deploying application...");
|
|
96
|
+
const hash = await walletClient.writeContract(request);
|
|
97
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
98
|
+
progress.succeed(`Application ${chalk.cyan(applicationAddress)}`);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
// abort, because application is already deployed
|
|
102
|
+
throw new Error(`Application ${chalk.cyan(templateHash)} already deployed to ${chalk.cyan(applicationAddress)}`);
|
|
103
|
+
}
|
|
104
|
+
return applicationAddress;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Publish machine snapshot to rollups node by copying it to the rollups node container
|
|
108
|
+
* @param options
|
|
109
|
+
* @returns path to the snapshot in the rollups node
|
|
110
|
+
*/
|
|
111
|
+
const publishMachine = async (options) => {
|
|
112
|
+
const { progress, environmentName, templateHash } = options;
|
|
113
|
+
const snapshotPath = getContextPath("image");
|
|
114
|
+
const containerSnapshotPath = `/var/lib/cartesi-rollups-node/snapshots/${templateHash}/`;
|
|
115
|
+
progress.start("Publishing machine snapshot...");
|
|
116
|
+
await execa("docker", [
|
|
117
|
+
"compose",
|
|
118
|
+
"--project-name",
|
|
119
|
+
environmentName,
|
|
120
|
+
"cp",
|
|
121
|
+
snapshotPath,
|
|
122
|
+
`rollups-node:${containerSnapshotPath}`,
|
|
123
|
+
]);
|
|
124
|
+
progress.succeed(`Machine snapshot ${chalk.cyan(containerSnapshotPath)}`);
|
|
125
|
+
return containerSnapshotPath;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Register application in rollups node
|
|
129
|
+
* @param options
|
|
130
|
+
* @returns name of the application
|
|
131
|
+
*/
|
|
132
|
+
const registerApplication = async (options) => {
|
|
133
|
+
const { applicationAddress, progress, environmentName, snapshotPath, dataAvailability, } = options;
|
|
134
|
+
// use application address as the name of the deployment
|
|
135
|
+
const name = options.name ??
|
|
136
|
+
(await input({
|
|
137
|
+
message: "Application Name",
|
|
138
|
+
default: applicationAddress.toLowerCase(),
|
|
139
|
+
}));
|
|
140
|
+
// common app register args
|
|
141
|
+
const registerArgs = [
|
|
142
|
+
"--name",
|
|
143
|
+
name,
|
|
144
|
+
"--address",
|
|
145
|
+
applicationAddress,
|
|
146
|
+
"--template-path",
|
|
147
|
+
snapshotPath,
|
|
148
|
+
"--data-availability",
|
|
149
|
+
dataAvailability,
|
|
150
|
+
"--print-json",
|
|
151
|
+
];
|
|
152
|
+
// deploy application
|
|
153
|
+
progress.start("Registering application...");
|
|
154
|
+
const { stdout } = await execa("docker", [
|
|
155
|
+
"compose",
|
|
156
|
+
"--project-name",
|
|
157
|
+
environmentName,
|
|
158
|
+
"exec",
|
|
159
|
+
"rollups-node",
|
|
160
|
+
"cartesi-rollups-cli",
|
|
161
|
+
"app",
|
|
162
|
+
"register",
|
|
163
|
+
...registerArgs,
|
|
164
|
+
]);
|
|
165
|
+
const registration = stdout ? JSON.parse(stdout) : undefined;
|
|
166
|
+
if (registration) {
|
|
167
|
+
if (registration.state !== "ENABLED") {
|
|
168
|
+
throw new Error(registration.reason);
|
|
169
|
+
}
|
|
170
|
+
progress.succeed(`Registration ${chalk.cyan(name)}`);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
throw new Error("Failed to deploy application");
|
|
174
|
+
}
|
|
175
|
+
return name;
|
|
176
|
+
};
|
|
177
|
+
const parseDataAvailability = (type, espressoBlock, espressoNamespace) => {
|
|
178
|
+
if (type === "espresso") {
|
|
179
|
+
return encodeFunctionData({
|
|
180
|
+
abi: dataAvailabilityAbi,
|
|
181
|
+
functionName: "InputBoxAndEspresso",
|
|
182
|
+
args: [inputBoxAddress, BigInt(espressoBlock), espressoNamespace],
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
return encodeFunctionData({
|
|
186
|
+
abi: dataAvailabilityAbi,
|
|
187
|
+
functionName: "InputBox",
|
|
188
|
+
args: [inputBoxAddress],
|
|
189
|
+
});
|
|
190
|
+
};
|
|
4
191
|
export const createDeployCommand = () => {
|
|
5
|
-
|
|
6
|
-
.description("
|
|
7
|
-
.
|
|
8
|
-
|
|
192
|
+
return new Command("deploy")
|
|
193
|
+
.description("Deploy a rollups application to a rollups node.")
|
|
194
|
+
.configureHelp({ showGlobalOptions: true })
|
|
195
|
+
.option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
|
|
196
|
+
.option("--chain-id <id>", "Chain ID", Number.parseInt, 13370)
|
|
197
|
+
.option("--rpc-url <url>", "RPC URL")
|
|
198
|
+
.option("--mnemonic <phrase>", "Mnemonic passphrase")
|
|
199
|
+
.option("--mnemonic-index <index>", "Mnemonic account index", Number.parseInt, 0)
|
|
200
|
+
.option("--name <string>", "application name")
|
|
201
|
+
.option("--authority-owner <address>", "authority owner", parseAddress, undefined)
|
|
202
|
+
.option("--application-owner <address>", "application owner", parseAddress, undefined)
|
|
203
|
+
.addOption(new Option("--epoch-length <number>", "length of an epoch (in blocks)")
|
|
204
|
+
.argParser(Number)
|
|
205
|
+
.default(720))
|
|
206
|
+
.option("--salt <hash>", "salt for deployment", parseHash, zeroHash)
|
|
207
|
+
.option("--json", "output in JSON format")
|
|
208
|
+
.addOption(new Option("--data-availability <type>", "Data availability layer to use (input-box or espresso)")
|
|
209
|
+
.choices(["input-box", "espresso"])
|
|
210
|
+
.default("input-box"))
|
|
211
|
+
.addOption(new Option("--espresso-block <number>", "espresso starting block")
|
|
212
|
+
.argParser(Number)
|
|
213
|
+
.default(1))
|
|
214
|
+
.addOption(new Option("--espresso-namespace <number>", "espresso namespace Id")
|
|
215
|
+
.argParser(Number)
|
|
216
|
+
.default(1))
|
|
217
|
+
.action(async (options, command) => {
|
|
218
|
+
const { json, dataAvailability: daType, environmentName, espressoBlock, espressoNamespace, } = options;
|
|
219
|
+
// If inputbox is chosen, warn if espresso args are provided
|
|
220
|
+
if (daType === "input-box" &&
|
|
221
|
+
(espressoBlock !== undefined || espressoNamespace !== undefined)) {
|
|
222
|
+
console.warn(chalk.yellow("WARNING: --espresso-block and --espresso-namespace-id are ignored when --data-availability is input-box"));
|
|
223
|
+
}
|
|
224
|
+
const progress = ora();
|
|
225
|
+
// get cartesi machine snapshot hash, produced by 'build'
|
|
226
|
+
const templateHash = getMachineHash();
|
|
227
|
+
if (!templateHash) {
|
|
228
|
+
progress.fail(`Cartesi machine snapshot not found, run 'build'`);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
progress.succeed(`Cartesi machine template hash ${chalk.cyan(templateHash)}`);
|
|
232
|
+
// connect to some chain
|
|
233
|
+
const { publicClient, walletClient } = await connect(options);
|
|
234
|
+
try {
|
|
235
|
+
// parse dataAvailability
|
|
236
|
+
const dataAvailability = parseDataAvailability(daType, espressoBlock, espressoNamespace);
|
|
237
|
+
// deploy authority contract (if not already deployed)
|
|
238
|
+
const authorityAddress = await deployAuthority(publicClient, walletClient, { progress, ...options });
|
|
239
|
+
// deploy application contract
|
|
240
|
+
const applicationAddress = await deployApplication(publicClient, walletClient, {
|
|
241
|
+
authorityAddress,
|
|
242
|
+
progress,
|
|
243
|
+
templateHash,
|
|
244
|
+
...options,
|
|
245
|
+
dataAvailability,
|
|
246
|
+
});
|
|
247
|
+
if (publicClient.chain?.id === cannon.id) {
|
|
248
|
+
// copy machine snapshot to rollups node container
|
|
249
|
+
const containerSnapshotPath = await publishMachine({
|
|
250
|
+
progress,
|
|
251
|
+
templateHash,
|
|
252
|
+
environmentName,
|
|
253
|
+
});
|
|
254
|
+
const name = await registerApplication({
|
|
255
|
+
applicationAddress,
|
|
256
|
+
progress,
|
|
257
|
+
snapshotPath: containerSnapshotPath,
|
|
258
|
+
...options,
|
|
259
|
+
dataAvailability,
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
const snapshotPath = getContextPath("image");
|
|
264
|
+
progress.succeed(`Done. Manually copy machine to rollups node ${chalk.cyan(snapshotPath)}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (e) {
|
|
268
|
+
progress.fail(e instanceof Error ? e.message : "Unknown error");
|
|
269
|
+
}
|
|
9
270
|
});
|
|
10
|
-
command.addCommand(createBuildCommand(), { hidden: true });
|
|
11
|
-
return command;
|
|
12
271
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAyHtD,eAAO,MAAM,mBAAmB,2BAa/B,CAAC"}
|
package/dist/commands/doctor.js
CHANGED
|
@@ -25,9 +25,7 @@ const checkDocker = async (progress) => {
|
|
|
25
25
|
e.code === "ENOENT") {
|
|
26
26
|
throw new Error("Docker not found");
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
throw e;
|
|
30
|
-
}
|
|
28
|
+
throw e;
|
|
31
29
|
}
|
|
32
30
|
return true;
|
|
33
31
|
};
|
|
@@ -50,9 +48,7 @@ const checkCompose = async (progress) => {
|
|
|
50
48
|
e.exitCode === 125) {
|
|
51
49
|
throw new Error("Docker Compose is required but not installed or the command execution failed. Please refer to the Docker Compose documentation for installation instructions: https://docs.docker.com/compose/install/");
|
|
52
50
|
}
|
|
53
|
-
|
|
54
|
-
throw e;
|
|
55
|
-
}
|
|
51
|
+
throw e;
|
|
56
52
|
}
|
|
57
53
|
return true;
|
|
58
54
|
};
|
|
@@ -88,9 +84,7 @@ const checkBuildx = async (progress) => {
|
|
|
88
84
|
e.exitCode === 125) {
|
|
89
85
|
throw new Error("Docker Buildx is required but not installed. Please refer to the Docker Desktop documentation for installation instructions: https://docs.docker.com/desktop/");
|
|
90
86
|
}
|
|
91
|
-
|
|
92
|
-
throw e;
|
|
93
|
-
}
|
|
87
|
+
throw e;
|
|
94
88
|
}
|
|
95
89
|
return true;
|
|
96
90
|
};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { Command } from "@commander-js/extra-typings";
|
|
2
2
|
export declare const createLogsCommand: () => Command<[], {
|
|
3
|
+
environmentName: string;
|
|
3
4
|
follow?: true | undefined;
|
|
4
5
|
color: boolean;
|
|
5
6
|
since?: string | undefined;
|
|
6
7
|
tail: string;
|
|
7
8
|
until?: string | undefined;
|
|
8
|
-
}, {
|
|
9
|
-
environmentName: string;
|
|
10
|
-
}>;
|
|
9
|
+
}, {}>;
|
|
11
10
|
//# sourceMappingURL=logs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logs.d.ts","sourceRoot":"","sources":["../../src/commands/logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,iBAAiB;;;;;;;MAgD7B,CAAC"}
|