@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/base.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type Address, type Hash } from "viem";
|
|
2
|
+
import { type Config } from "./config.js";
|
|
3
|
+
import type { PsResponse } from "./types/docker.js";
|
|
4
|
+
export declare const getContextPath: (...paths: string[]) => string;
|
|
5
|
+
export declare const getMachineHash: () => Hash | undefined;
|
|
6
|
+
export declare const getApplicationConfig: (configPaths: string[]) => Config;
|
|
7
|
+
export declare const getProjectName: (options: {
|
|
8
|
+
projectName?: string;
|
|
9
|
+
}) => string;
|
|
10
|
+
export type AddressBook = Record<string, Address>;
|
|
11
|
+
export declare const getAddressBook: (options: {
|
|
12
|
+
projectName?: string;
|
|
13
|
+
}) => Promise<AddressBook>;
|
|
14
|
+
export declare const getServiceInfo: (options: {
|
|
15
|
+
projectName: string;
|
|
16
|
+
service: string;
|
|
17
|
+
}) => Promise<PsResponse | undefined>;
|
|
18
|
+
export declare const getServiceState: (options: {
|
|
19
|
+
projectName: string;
|
|
20
|
+
service: string;
|
|
21
|
+
}) => Promise<string | undefined>;
|
|
22
|
+
export declare const getServiceHealth: (options: {
|
|
23
|
+
projectName: string;
|
|
24
|
+
service: string;
|
|
25
|
+
}) => Promise<string | undefined>;
|
|
26
|
+
export declare const parseAddress: (value: string) => Address | undefined;
|
|
27
|
+
export declare const parseHash: (value: string) => Hash;
|
|
28
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,OAAO,EAEZ,KAAK,IAAI,EAIZ,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,KAAK,MAAM,EAAS,MAAM,aAAa,CAAC;AAgBjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,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,aAAa,MAAM,EAAE,KAAG,MAW5D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,SAAS;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,WAE/D,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc,GAAU,SAAS;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,KAAG,OAAO,CAAC,WAAW,CAkCtB,CAAC;AAEF,eAAO,MAAM,cAAc,GAAU,SAAS;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAcjC,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,SAAS;IAC3C,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAG7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,SAAS;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,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
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { InvalidArgumentError } from "@commander-js/extra-typings";
|
|
2
|
+
import { execa } from "execa";
|
|
3
|
+
import fs from "node:fs";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { getAddress, isAddress, isHash, zeroHash, } from "viem";
|
|
6
|
+
import { parse } from "./config.js";
|
|
7
|
+
import { applicationFactoryAddress, authorityFactoryAddress, erc1155BatchPortalAddress, erc1155SinglePortalAddress, erc20PortalAddress, erc721PortalAddress, etherPortalAddress, inputBoxAddress, selfHostedApplicationFactoryAddress, testMultiTokenAddress, testNftAddress, testTokenAddress, } from "./contracts.js";
|
|
8
|
+
import { getApplicationAddress } from "./exec/rollups.js";
|
|
9
|
+
export const getContextPath = (...paths) => {
|
|
10
|
+
return path.join(".cartesi", ...paths);
|
|
11
|
+
};
|
|
12
|
+
export const getMachineHash = () => {
|
|
13
|
+
// read hash of the cartesi machine snapshot, if one exists
|
|
14
|
+
const hashPath = getContextPath("image", "hash");
|
|
15
|
+
if (fs.existsSync(hashPath)) {
|
|
16
|
+
const hash = fs.readFileSync(hashPath).toString("hex");
|
|
17
|
+
if (isHash(`0x${hash}`)) {
|
|
18
|
+
return `0x${hash}`;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
export const getApplicationConfig = (configPaths) => {
|
|
24
|
+
const tomls = configPaths.map((configPath) => {
|
|
25
|
+
if (fs.existsSync(configPath)) {
|
|
26
|
+
return fs.readFileSync(configPath).toString();
|
|
27
|
+
}
|
|
28
|
+
if (configPath === "cartesi.toml") {
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
throw new Error(`Config file ${configPath} does not exist`);
|
|
32
|
+
});
|
|
33
|
+
return parse(tomls);
|
|
34
|
+
};
|
|
35
|
+
export const getProjectName = (options) => {
|
|
36
|
+
return options.projectName ?? path.basename(process.cwd());
|
|
37
|
+
};
|
|
38
|
+
export const getAddressBook = async (options) => {
|
|
39
|
+
const applicationAddress = await getApplicationAddress(options);
|
|
40
|
+
// build rollups contracts address book
|
|
41
|
+
const contracts = {
|
|
42
|
+
ApplicationFactory: applicationFactoryAddress,
|
|
43
|
+
AuthorityFactory: authorityFactoryAddress,
|
|
44
|
+
EntryPointV06: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
|
|
45
|
+
EntryPointV07: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
|
|
46
|
+
ERC1155BatchPortal: erc1155BatchPortalAddress,
|
|
47
|
+
ERC1155SinglePortal: erc1155SinglePortalAddress,
|
|
48
|
+
ERC20Portal: erc20PortalAddress,
|
|
49
|
+
ERC721Portal: erc721PortalAddress,
|
|
50
|
+
EtherPortal: etherPortalAddress,
|
|
51
|
+
InputBox: inputBoxAddress,
|
|
52
|
+
LightAccountFactory: "0x00004EC70002a32400f8ae005A26081065620D20",
|
|
53
|
+
SelfHostedApplicationFactory: selfHostedApplicationFactoryAddress,
|
|
54
|
+
SimpleAccountFactory: "0x9406Cc6185a346906296840746125a0E44976454",
|
|
55
|
+
SmartAccountFactory: "0x000000a56Aaca3e9a4C479ea6b6CD0DbcB6634F5",
|
|
56
|
+
KernelFactoryV2: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3",
|
|
57
|
+
KernelFactoryV3: "0x6723b44Abeec4E71eBE3232BD5B455805baDD22f",
|
|
58
|
+
KernelFactoryV3_1: "0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419",
|
|
59
|
+
TestToken: testTokenAddress,
|
|
60
|
+
TestNFT: testNftAddress,
|
|
61
|
+
TestMultiToken: testMultiTokenAddress,
|
|
62
|
+
VerifyingPaymasterV06: "0x28ec0633192d0cBd9E1156CE05D5FdACAcB93947",
|
|
63
|
+
VerifyingPaymasterV07: "0xc5c97885C67F7361aBAfD2B95067a5bBdA603608",
|
|
64
|
+
};
|
|
65
|
+
if (applicationAddress) {
|
|
66
|
+
contracts.Application = applicationAddress;
|
|
67
|
+
}
|
|
68
|
+
return contracts;
|
|
69
|
+
};
|
|
70
|
+
export const getServiceInfo = async (options) => {
|
|
71
|
+
const { projectName, service } = options;
|
|
72
|
+
// get service information
|
|
73
|
+
const { stdout } = await execa("docker", [
|
|
74
|
+
"compose",
|
|
75
|
+
"--project-name",
|
|
76
|
+
projectName,
|
|
77
|
+
"ps",
|
|
78
|
+
service,
|
|
79
|
+
"--format",
|
|
80
|
+
"json",
|
|
81
|
+
]);
|
|
82
|
+
return stdout ? JSON.parse(stdout) : undefined;
|
|
83
|
+
};
|
|
84
|
+
export const getServiceState = async (options) => {
|
|
85
|
+
const info = await getServiceInfo(options);
|
|
86
|
+
return info?.State;
|
|
87
|
+
};
|
|
88
|
+
export const getServiceHealth = async (options) => {
|
|
89
|
+
const info = await getServiceInfo(options);
|
|
90
|
+
return info?.Health;
|
|
91
|
+
};
|
|
92
|
+
export const parseAddress = (value) => {
|
|
93
|
+
if (isAddress(value)) {
|
|
94
|
+
return getAddress(value);
|
|
95
|
+
}
|
|
96
|
+
if (value !== "") {
|
|
97
|
+
throw new InvalidArgumentError(`Invalid address: ${value}`);
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
};
|
|
101
|
+
export const parseHash = (value) => {
|
|
102
|
+
if (isHash(value)) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
if (value !== "") {
|
|
106
|
+
throw new InvalidArgumentError(`Invalid hash: ${value}`);
|
|
107
|
+
}
|
|
108
|
+
return zeroHash;
|
|
109
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { DirectoryDriveConfig } from "../config.js";
|
|
2
|
-
export declare const build: (name: string, drive: DirectoryDriveConfig, sdkImage: string, destination: string) => Promise<void>;
|
|
1
|
+
import type { DirectoryDriveConfig } from "../config.js";
|
|
2
|
+
export declare const build: (name: string, drive: DirectoryDriveConfig, sdkImage: string, destination: string, debug: boolean) => Promise<void>;
|
|
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,EACnB,OAAO,OAAO,KACf,OAAO,CAAC,IAAI,CAoCd,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "fs-extra";
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import { genext2fs, mksquashfs } from "../exec/index.js";
|
|
4
|
-
export const build = async (name, drive, sdkImage, destination) => {
|
|
4
|
+
export const build = async (name, drive, sdkImage, destination, debug) => {
|
|
5
5
|
const filename = `${name}.${drive.format}`;
|
|
6
6
|
// copy directory to destination
|
|
7
7
|
const dest = path.join(destination, name);
|
|
@@ -32,6 +32,8 @@ export const build = async (name, drive, sdkImage, destination) => {
|
|
|
32
32
|
}
|
|
33
33
|
finally {
|
|
34
34
|
// delete copied
|
|
35
|
-
|
|
35
|
+
if (!debug) {
|
|
36
|
+
await fs.remove(dest);
|
|
37
|
+
}
|
|
36
38
|
}
|
|
37
39
|
};
|
package/dist/builder/docker.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { DockerDriveConfig } from "../config.js";
|
|
1
|
+
import type { DockerDriveConfig } from "../config.js";
|
|
2
2
|
type ImageInfo = {
|
|
3
3
|
cmd: string[];
|
|
4
4
|
entrypoint: string[];
|
|
5
5
|
env: string[];
|
|
6
6
|
workdir: string;
|
|
7
7
|
};
|
|
8
|
-
export declare const build: (name: string, drive: DockerDriveConfig, sdkImage: string, destination: string) => Promise<ImageInfo | undefined>;
|
|
8
|
+
export declare const build: (name: string, drive: DockerDriveConfig, sdkImage: string, destination: string, debug: boolean) => Promise<ImageInfo | undefined>;
|
|
9
9
|
export {};
|
|
10
10
|
//# sourceMappingURL=docker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/builder/docker.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/builder/docker.ts"],"names":[],"mappings":"AAGA,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;AAiFF,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,iBAAiB,EACxB,UAAU,MAAM,EAChB,aAAa,MAAM,EACnB,OAAO,OAAO,KACf,OAAO,CAAC,SAAS,GAAG,SAAS,CAsD/B,CAAC"}
|
package/dist/builder/docker.js
CHANGED
|
@@ -1,33 +1,39 @@
|
|
|
1
1
|
import { execa } from "execa";
|
|
2
2
|
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import
|
|
5
|
-
import { crane, genext2fs, mksquashfs } from "../exec/index.js";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { genext2fs, mksquashfs } from "../exec/index.js";
|
|
6
5
|
/**
|
|
7
6
|
* Build Docker image (linux/riscv64). Returns image id.
|
|
8
7
|
*/
|
|
9
8
|
const buildImage = async (options) => {
|
|
10
|
-
const { context, dockerfile, tags, target } = options;
|
|
11
|
-
|
|
9
|
+
const { buildArgs, context, destination, dockerfile, dockerfileContent, tags, target, } = options;
|
|
10
|
+
// if dockerfileContext is specified, use it as the dockerfile passed through stdin
|
|
12
11
|
const args = [
|
|
13
12
|
"buildx",
|
|
14
13
|
"build",
|
|
15
14
|
"--platform",
|
|
16
15
|
"linux/riscv64",
|
|
17
16
|
"--file",
|
|
18
|
-
dockerfile,
|
|
19
|
-
"--
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
dockerfileContent ? "-" : dockerfile,
|
|
18
|
+
"--output",
|
|
19
|
+
"type=docker",
|
|
20
|
+
"--output",
|
|
21
|
+
`type=tar,dest=${destination}`,
|
|
22
|
+
"--progress",
|
|
23
|
+
"quiet",
|
|
23
24
|
];
|
|
24
25
|
// set tags for the image built
|
|
25
|
-
args.push(...tags.
|
|
26
|
+
args.push(...tags.flatMap((tag) => ["--tag", tag]));
|
|
27
|
+
// set build args
|
|
28
|
+
args.push(...buildArgs.flatMap((arg) => ["--build-arg", arg]));
|
|
26
29
|
if (target) {
|
|
27
30
|
args.push("--target", target);
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
args.push(context);
|
|
33
|
+
const { stdout: imageId } = await execa("docker", args, {
|
|
34
|
+
input: dockerfileContent,
|
|
35
|
+
});
|
|
36
|
+
return imageId;
|
|
31
37
|
};
|
|
32
38
|
/**
|
|
33
39
|
* Query the image using docker image inspect
|
|
@@ -43,44 +49,39 @@ const getImageInfo = async (image) => {
|
|
|
43
49
|
// parse image info from docker inspect output
|
|
44
50
|
const [imageInfo] = JSON.parse(jsonStr);
|
|
45
51
|
// validate image architecture (must be riscv64)
|
|
46
|
-
if (imageInfo
|
|
47
|
-
throw new Error(`Invalid image Architecture: ${imageInfo
|
|
52
|
+
if (imageInfo.Architecture !== "riscv64") {
|
|
53
|
+
throw new Error(`Invalid image Architecture: ${imageInfo.Architecture}. Expected riscv64`);
|
|
48
54
|
}
|
|
49
55
|
const info = {
|
|
50
|
-
cmd: imageInfo
|
|
51
|
-
entrypoint: imageInfo
|
|
52
|
-
env: imageInfo
|
|
53
|
-
workdir: imageInfo
|
|
56
|
+
cmd: imageInfo.Config.Cmd ?? [],
|
|
57
|
+
entrypoint: imageInfo.Config.Entrypoint ?? [],
|
|
58
|
+
env: imageInfo.Config.Env || [],
|
|
59
|
+
workdir: imageInfo.Config.WorkingDir,
|
|
54
60
|
};
|
|
55
61
|
return info;
|
|
56
62
|
};
|
|
57
|
-
export const build = async (name, drive, sdkImage, destination) => {
|
|
63
|
+
export const build = async (name, drive, sdkImage, destination, debug) => {
|
|
58
64
|
const { format } = drive;
|
|
59
|
-
const ocitar = `${name}.oci.tar`;
|
|
60
65
|
const tar = `${name}.tar`;
|
|
61
66
|
const filename = `${name}.${format}`;
|
|
62
67
|
// use pre-existing image or build docker image
|
|
63
68
|
let image;
|
|
64
69
|
if (drive.image) {
|
|
65
|
-
image
|
|
66
|
-
await
|
|
70
|
+
// build a docker image with `FROM <image>`
|
|
71
|
+
image = await buildImage({
|
|
72
|
+
...drive,
|
|
73
|
+
destination: path.join(destination, tar),
|
|
74
|
+
dockerfileContent: `FROM ${drive.image}`,
|
|
75
|
+
});
|
|
67
76
|
}
|
|
68
77
|
else {
|
|
69
|
-
image = await buildImage(
|
|
78
|
+
image = await buildImage({
|
|
79
|
+
...drive,
|
|
80
|
+
destination: path.join(destination, tar),
|
|
81
|
+
});
|
|
70
82
|
}
|
|
71
|
-
// get image info
|
|
72
83
|
const imageInfo = await getImageInfo(image);
|
|
73
84
|
try {
|
|
74
|
-
// create OCI Docker tarball from Docker image
|
|
75
|
-
await execa("docker", ["image", "save", image, "-o", ocitar], {
|
|
76
|
-
cwd: destination,
|
|
77
|
-
});
|
|
78
|
-
// create rootfs tar from OCI tar
|
|
79
|
-
await crane.exportImage({
|
|
80
|
-
stdin: fs.openSync(path.join(destination, ocitar), "r"),
|
|
81
|
-
stdout: fs.openSync(path.join(destination, tar), "w"),
|
|
82
|
-
image: sdkImage,
|
|
83
|
-
});
|
|
84
85
|
switch (format) {
|
|
85
86
|
case "ext2": {
|
|
86
87
|
await genext2fs.fromTar({
|
|
@@ -105,8 +106,9 @@ export const build = async (name, drive, sdkImage, destination) => {
|
|
|
105
106
|
}
|
|
106
107
|
finally {
|
|
107
108
|
// delete intermediate files
|
|
108
|
-
|
|
109
|
-
|
|
109
|
+
if (!debug) {
|
|
110
|
+
await fs.remove(path.join(destination, tar));
|
|
111
|
+
}
|
|
110
112
|
}
|
|
111
113
|
return imageInfo;
|
|
112
114
|
};
|
package/dist/builder/empty.d.ts
CHANGED
|
@@ -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,IAAI,CAoBd,CAAC"}
|
package/dist/builder/empty.js
CHANGED
package/dist/builder/none.d.ts
CHANGED
|
@@ -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,IAAI,CAQd,CAAC"}
|
package/dist/builder/none.js
CHANGED
package/dist/builder/tar.d.ts
CHANGED
|
@@ -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,IAAI,CA4Bd,CAAC"}
|
package/dist/builder/tar.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
static enableJsonFlag: boolean;
|
|
7
|
-
run(): Promise<AddressBookType>;
|
|
8
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createAddressBookCommand: () => Command<[], {
|
|
3
|
+
json?: true | undefined;
|
|
4
|
+
projectName?: string | undefined;
|
|
5
|
+
}, {}>;
|
|
9
6
|
//# sourceMappingURL=address-book.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../src/commands/address-book.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../src/commands/address-book.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,wBAAwB;;;MA4CpC,CAAC"}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
1
2
|
import Table from "cli-table3";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { getAddressBook, getProjectName } from "../base.js";
|
|
4
|
+
export const createAddressBookCommand = () => {
|
|
5
|
+
return new Command("address-book")
|
|
6
|
+
.description("Prints the addresses of all smart contracts deployed to the runtime environment of the application.")
|
|
7
|
+
.option("--json", "Format output as json.")
|
|
8
|
+
.option("--project-name <string>", "name of project (used by docker compose and cartesi-rollups-node)")
|
|
9
|
+
.action(async (options) => {
|
|
10
|
+
const { json } = options;
|
|
11
|
+
const projectName = getProjectName(options);
|
|
12
|
+
const addressBook = await getAddressBook({ projectName });
|
|
13
|
+
if (!json) {
|
|
7
14
|
// print as a table
|
|
8
15
|
const table = new Table({
|
|
9
16
|
head: ["Contract", "Address"],
|
|
@@ -29,12 +36,9 @@ class AddressBook extends BaseCommand {
|
|
|
29
36
|
table.push(...Object.entries(addressBook));
|
|
30
37
|
console.log(table.toString());
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
AddressBook.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
39
|
-
AddressBook.enableJsonFlag = true;
|
|
40
|
-
export default AddressBook;
|
|
39
|
+
else {
|
|
40
|
+
// print as json
|
|
41
|
+
process.stdout.write(JSON.stringify(addressBook));
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
package/dist/commands/build.d.ts
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"drives-only": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
9
|
-
};
|
|
10
|
-
run(): Promise<void>;
|
|
11
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createBuildCommand: () => Command<[], {
|
|
3
|
+
config: string[];
|
|
4
|
+
debug: boolean;
|
|
5
|
+
drivesOnly?: true | undefined;
|
|
6
|
+
verbose: boolean;
|
|
7
|
+
}, {}>;
|
|
12
8
|
//# sourceMappingURL=build.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAqE9D,eAAO,MAAM,kBAAkB;;;;;MAqF9B,CAAC"}
|
package/dist/commands/build.js
CHANGED
|
@@ -1,73 +1,97 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import fs from "fs-extra";
|
|
3
|
-
import
|
|
4
|
+
import { Listr } from "listr2";
|
|
5
|
+
import path from "node:path";
|
|
4
6
|
import tmp from "tmp";
|
|
5
|
-
import {
|
|
7
|
+
import { getApplicationConfig, getContextPath } from "../base.js";
|
|
6
8
|
import { buildDirectory, buildDocker, buildEmpty, buildNone, buildTar, } from "../builder/index.js";
|
|
7
9
|
import { bootMachine } from "../machine.js";
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const buildDriveTask = (name, drive) => ({
|
|
11
|
+
title: `Building drive ${chalk.cyan(name)}`,
|
|
12
|
+
task: async (ctx, task) => {
|
|
13
|
+
const { config, debug, destination } = ctx;
|
|
14
|
+
const sdk = config.sdk;
|
|
15
|
+
switch (drive.builder) {
|
|
16
|
+
case "directory": {
|
|
17
|
+
await buildDirectory(name, drive, sdk, destination, debug);
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
case "docker": {
|
|
21
|
+
const imageInfo = await buildDocker(name, drive, sdk, destination, debug);
|
|
22
|
+
if (imageInfo && name === "root") {
|
|
23
|
+
// only set image info for root drive
|
|
24
|
+
ctx.imageInfo = imageInfo;
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case "empty": {
|
|
29
|
+
await buildEmpty(name, drive, sdk, destination);
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
case "tar": {
|
|
33
|
+
await buildTar(name, drive, sdk, destination);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "none": {
|
|
37
|
+
await buildNone(name, drive, destination);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
12
40
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
class Build extends BaseCommand {
|
|
28
|
-
async run() {
|
|
29
|
-
const { flags } = await this.parse(Build);
|
|
41
|
+
task.title = `Build drive ${chalk.cyan(name)}`;
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
export const createBuildCommand = () => {
|
|
45
|
+
return new Command("build")
|
|
46
|
+
.description("Build application by building Cartesi machine drives, configuring a machine and booting it.")
|
|
47
|
+
.option("-c, --config <config>", "path to the configuration file", (value, prev) => prev.concat([value]), ["cartesi.toml"])
|
|
48
|
+
.addOption(new Option("--debug", "enable debug mode (do not remove intermediate files)")
|
|
49
|
+
.default(false)
|
|
50
|
+
.hideHelp())
|
|
51
|
+
.option("-d, --drives-only", "only build drives, do not boot machine")
|
|
52
|
+
.option("-v, --verbose", "verbose output", false)
|
|
53
|
+
.action(async (options) => {
|
|
54
|
+
const { debug, drivesOnly, verbose } = options;
|
|
30
55
|
// clean up temp files we create along the process
|
|
31
56
|
tmp.setGracefulCleanup();
|
|
32
57
|
// get application configuration from 'cartesi.toml'
|
|
33
|
-
const config =
|
|
58
|
+
const config = getApplicationConfig(options.config);
|
|
34
59
|
// destination directory for image and intermediate files
|
|
35
|
-
const destination = path.resolve(
|
|
60
|
+
const destination = path.resolve(getContextPath());
|
|
36
61
|
// prepare context directory
|
|
37
62
|
await fs.emptyDir(destination); // XXX: make it less error prone
|
|
38
|
-
//
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
63
|
+
// build context
|
|
64
|
+
const ctx = { config, debug, destination, imageInfo: undefined };
|
|
65
|
+
// tasks to build drives
|
|
66
|
+
const driveTasks = Object.entries(config.drives).map(([name, drive]) => buildDriveTask(name, drive));
|
|
67
|
+
const builds = new Listr([
|
|
68
|
+
{
|
|
69
|
+
title: "Build drives",
|
|
70
|
+
task: async (_ctx, task) => {
|
|
71
|
+
return task.newListr(driveTasks, {
|
|
72
|
+
concurrent: true,
|
|
73
|
+
rendererOptions: {
|
|
74
|
+
collapseSubtasks: false,
|
|
75
|
+
},
|
|
76
|
+
ctx,
|
|
77
|
+
});
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
], { ctx, renderer: verbose ? "verbose" : "default" });
|
|
81
|
+
const result = await builds.run();
|
|
82
|
+
// if only build drives, quit here
|
|
83
|
+
if (drivesOnly) {
|
|
47
84
|
return;
|
|
48
85
|
}
|
|
49
|
-
// get image info of root drive
|
|
50
|
-
const root = await results["root"];
|
|
51
|
-
const imageInfo = root || undefined;
|
|
52
|
-
// path of machine snapshot
|
|
53
|
-
const snapshotPath = this.getContextPath("image");
|
|
54
86
|
// create machine snapshot
|
|
55
|
-
await bootMachine(config, imageInfo,
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
default: "cartesi.toml",
|
|
66
|
-
summary: "path to the configuration file",
|
|
67
|
-
}),
|
|
68
|
-
"drives-only": Flags.boolean({
|
|
69
|
-
default: false,
|
|
70
|
-
summary: "only build drives",
|
|
71
|
-
}),
|
|
87
|
+
await bootMachine(config, result.imageInfo, {
|
|
88
|
+
finalHash: true,
|
|
89
|
+
store: "image",
|
|
90
|
+
}, {
|
|
91
|
+
cwd: destination,
|
|
92
|
+
stdio: "inherit",
|
|
93
|
+
});
|
|
94
|
+
// make snapshot readable by all users, because cartesi-machine sets to 600
|
|
95
|
+
await fs.chmod(path.join(destination, "image"), 0o755);
|
|
96
|
+
});
|
|
72
97
|
};
|
|
73
|
-
export default Build;
|