@cartesi/cli 2.0.0-alpha.3 → 2.0.0-alpha.30
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/index.js +704 -1
- package/dist/index.js.map +791 -0
- package/package.json +77 -101
- package/LICENSE +0 -202
- 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/builder/directory.d.ts +0 -3
- package/dist/builder/directory.d.ts.map +0 -1
- package/dist/builder/directory.js +0 -37
- package/dist/builder/docker.d.ts +0 -10
- package/dist/builder/docker.d.ts.map +0 -1
- package/dist/builder/docker.js +0 -112
- package/dist/builder/empty.d.ts +0 -3
- package/dist/builder/empty.d.ts.map +0 -1
- package/dist/builder/empty.js +0 -21
- package/dist/builder/index.d.ts +0 -6
- package/dist/builder/index.d.ts.map +0 -1
- package/dist/builder/index.js +0 -5
- package/dist/builder/none.d.ts +0 -3
- package/dist/builder/none.d.ts.map +0 -1
- package/dist/builder/none.js +0 -11
- package/dist/builder/tar.d.ts +0 -3
- package/dist/builder/tar.d.ts.map +0 -1
- package/dist/builder/tar.js +0 -30
- package/dist/commands/address-book.d.ts +0 -9
- package/dist/commands/address-book.d.ts.map +0 -1
- package/dist/commands/address-book.js +0 -40
- package/dist/commands/build.d.ts +0 -12
- package/dist/commands/build.d.ts.map +0 -1
- package/dist/commands/build.js +0 -73
- package/dist/commands/clean.d.ts +0 -8
- package/dist/commands/clean.d.ts.map +0 -1
- package/dist/commands/clean.js +0 -11
- package/dist/commands/create.d.ts +0 -16
- package/dist/commands/create.d.ts.map +0 -1
- package/dist/commands/create.js +0 -66
- package/dist/commands/deploy/build.d.ts +0 -15
- package/dist/commands/deploy/build.d.ts.map +0 -1
- package/dist/commands/deploy/build.js +0 -62
- 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/doctor.d.ts +0 -13
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -106
- package/dist/commands/hash.d.ts +0 -10
- package/dist/commands/hash.d.ts.map +0 -1
- package/dist/commands/hash.js +0 -22
- package/dist/commands/run.d.ts +0 -21
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js +0 -191
- 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/commands/shell.d.ts +0 -15
- package/dist/commands/shell.d.ts.map +0 -1
- package/dist/commands/shell.js +0 -65
- package/dist/config.d.ts +0 -102
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -367
- package/dist/contracts.d.ts +0 -4317
- package/dist/contracts.d.ts.map +0 -1
- package/dist/contracts.js +0 -1799
- package/dist/exec/cartesi-machine.d.ts +0 -9
- package/dist/exec/cartesi-machine.d.ts.map +0 -1
- package/dist/exec/cartesi-machine.js +0 -20
- 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/exec/genext2fs.d.ts +0 -28
- package/dist/exec/genext2fs.d.ts.map +0 -1
- package/dist/exec/genext2fs.js +0 -44
- package/dist/exec/index.d.ts +0 -5
- package/dist/exec/index.d.ts.map +0 -1
- package/dist/exec/index.js +0 -4
- package/dist/exec/mksquashfs.d.ts +0 -21
- package/dist/exec/mksquashfs.d.ts.map +0 -1
- package/dist/exec/mksquashfs.js +0 -45
- package/dist/exec/util.d.ts +0 -36
- package/dist/exec/util.d.ts.map +0 -1
- package/dist/exec/util.js +0 -80
- package/dist/flags.d.ts +0 -17
- package/dist/flags.d.ts.map +0 -1
- package/dist/flags.js +0 -28
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +0 -1
- package/dist/machine.d.ts +0 -6
- package/dist/machine.d.ts.map +0 -1
- package/dist/machine.js +0 -80
- 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-database.yaml +0 -10
- 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/dist/prompts.d.ts +0 -62
- package/dist/prompts.d.ts.map +0 -1
- package/dist/prompts.js +0 -158
- package/dist/types/docker.d.ts +0 -22
- package/dist/types/docker.d.ts.map +0 -1
- package/dist/types/docker.js +0 -1
- package/dist/wallet.d.ts +0 -24
- package/dist/wallet.d.ts.map +0 -1
- package/dist/wallet.js +0 -204
- package/oclif.manifest.json +0 -876
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import input from "@inquirer/input";
|
|
2
|
-
import { parseEther } from "viem";
|
|
3
|
-
import { etherPortalAbi, etherPortalAddress } from "../../contracts.js";
|
|
4
|
-
import * as CustomFlags from "../../flags.js";
|
|
5
|
-
import { SendBaseCommand } from "./index.js";
|
|
6
|
-
class SendEther extends SendBaseCommand {
|
|
7
|
-
async send(publicClient, walletClient) {
|
|
8
|
-
// get dapp address from local node, or ask
|
|
9
|
-
const applicationAddress = await super.getApplicationAddress();
|
|
10
|
-
const amount = this.flags.amount || (await input({ message: "Amount" }));
|
|
11
|
-
const { request } = await publicClient.simulateContract({
|
|
12
|
-
address: etherPortalAddress,
|
|
13
|
-
abi: etherPortalAbi,
|
|
14
|
-
functionName: "depositEther",
|
|
15
|
-
args: [applicationAddress, this.flags.execLayerData],
|
|
16
|
-
value: parseEther(amount),
|
|
17
|
-
account: walletClient.account,
|
|
18
|
-
});
|
|
19
|
-
return walletClient.writeContract(request);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
SendEther.summary = "Send ether deposit to the application.";
|
|
23
|
-
SendEther.description = "Sends ether deposits to the application, optionally in interactive mode.";
|
|
24
|
-
SendEther.flags = {
|
|
25
|
-
amount: CustomFlags.number({ description: "amount, in ETH units" }),
|
|
26
|
-
execLayerData: CustomFlags.hex({
|
|
27
|
-
description: "exec layer data",
|
|
28
|
-
default: "0x",
|
|
29
|
-
}),
|
|
30
|
-
};
|
|
31
|
-
SendEther.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
32
|
-
export default SendEther;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Address, PublicClient, WalletClient } from "viem";
|
|
2
|
-
import { SendBaseCommand } from "./index.js";
|
|
3
|
-
export default class SendGeneric extends SendBaseCommand<typeof SendGeneric> {
|
|
4
|
-
static summary: string;
|
|
5
|
-
static description: string;
|
|
6
|
-
static examples: string[];
|
|
7
|
-
static flags: {
|
|
8
|
-
input: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
9
|
-
"input-encoding": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
-
"input-abi-params": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
-
};
|
|
12
|
-
protected getInput(): Promise<`0x${string}` | undefined>;
|
|
13
|
-
send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/commands/send/generic.ts"],"names":[],"mappings":"AACA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,YAAY,EAOf,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,eAAe,CAAC,OAAO,WAAW,CAAC;IACxE,MAAM,CAAC,OAAO,SAA4C;IAE1D,MAAM,CAAC,WAAW,SAC8D;IAEhF,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;;;MAgBV;cAEc,QAAQ,IAAI,OAAO,CAAC,KAAK,MAAM,EAAE,GAAG,SAAS,CAAC;IA8EjD,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CAgBtB"}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { Flags } from "@oclif/core";
|
|
2
|
-
import { encodeAbiParameters, getAddress, isAddress, isHex, parseAbiParameters, stringToHex, } from "viem";
|
|
3
|
-
import { inputBoxAbi, inputBoxAddress } from "../../contracts.js";
|
|
4
|
-
import { bytesInput } from "../../prompts.js";
|
|
5
|
-
import { SendBaseCommand } from "./index.js";
|
|
6
|
-
class SendGeneric extends SendBaseCommand {
|
|
7
|
-
async getInput() {
|
|
8
|
-
const input = this.flags.input;
|
|
9
|
-
const encoding = this.flags["input-encoding"];
|
|
10
|
-
if (input) {
|
|
11
|
-
if (encoding === "hex") {
|
|
12
|
-
// validate if is a hex value
|
|
13
|
-
if (!isHex(input)) {
|
|
14
|
-
throw new Error("input encoded as hex must start with 0x");
|
|
15
|
-
}
|
|
16
|
-
return input;
|
|
17
|
-
}
|
|
18
|
-
else if (encoding === "string") {
|
|
19
|
-
// encode UTF-8 string as hex
|
|
20
|
-
return stringToHex(input);
|
|
21
|
-
}
|
|
22
|
-
else if (encoding === "abi") {
|
|
23
|
-
const abiParams = this.flags["input-abi-params"];
|
|
24
|
-
if (!abiParams) {
|
|
25
|
-
throw new Error("Undefined input-abi-params");
|
|
26
|
-
}
|
|
27
|
-
const abiParameters = parseAbiParameters(abiParams);
|
|
28
|
-
// TODO: decode values
|
|
29
|
-
const values = input.split(",").map((v, index) => {
|
|
30
|
-
if (index >= abiParameters.length) {
|
|
31
|
-
throw new Error(`Too many values, expected ${abiParameters.length} values based on --input-abi-params '${abiParams}', parsing value at index ${index} from input '${input}'`);
|
|
32
|
-
}
|
|
33
|
-
const param = abiParameters[index];
|
|
34
|
-
switch (param.type) {
|
|
35
|
-
case "string":
|
|
36
|
-
return v;
|
|
37
|
-
case "bool":
|
|
38
|
-
if (v === "true")
|
|
39
|
-
return true;
|
|
40
|
-
if (v === "false")
|
|
41
|
-
return false;
|
|
42
|
-
throw new Error(`Invalid boolean value: ${v}`);
|
|
43
|
-
case "uint":
|
|
44
|
-
case "uint8":
|
|
45
|
-
case "uint16":
|
|
46
|
-
case "uint32":
|
|
47
|
-
case "uint64":
|
|
48
|
-
case "uint128":
|
|
49
|
-
case "uint256":
|
|
50
|
-
try {
|
|
51
|
-
return BigInt(v);
|
|
52
|
-
}
|
|
53
|
-
catch (e) {
|
|
54
|
-
throw new Error(`Invalid uint value: ${v}`);
|
|
55
|
-
}
|
|
56
|
-
case "bytes":
|
|
57
|
-
if (isHex(v)) {
|
|
58
|
-
return v;
|
|
59
|
-
}
|
|
60
|
-
throw new Error(`Invalid bytes value: ${v}`);
|
|
61
|
-
case "address":
|
|
62
|
-
if (isAddress(v)) {
|
|
63
|
-
return getAddress(v);
|
|
64
|
-
}
|
|
65
|
-
throw new Error(`Invalid address value: ${v}`);
|
|
66
|
-
default:
|
|
67
|
-
throw new Error(`Unsupported type ${param.type}`);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
if (values.length !== abiParameters.length) {
|
|
71
|
-
throw new Error(`Not enough values, expected ${abiParameters.length} values based on --input-abi-params '${abiParams}', parsed ${values.length} values from input '${input}'`);
|
|
72
|
-
}
|
|
73
|
-
return encodeAbiParameters(abiParameters, values);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
if (isHex(input)) {
|
|
77
|
-
return input;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
// encode UTF-8 string as hex
|
|
81
|
-
return stringToHex(input);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return undefined;
|
|
86
|
-
}
|
|
87
|
-
async send(publicClient, walletClient) {
|
|
88
|
-
// get dapp address from local node, or ask
|
|
89
|
-
const applicationAddress = await super.getApplicationAddress();
|
|
90
|
-
const payload = (await this.getInput()) || (await bytesInput({ message: "Input" }));
|
|
91
|
-
const { request } = await publicClient.simulateContract({
|
|
92
|
-
address: inputBoxAddress,
|
|
93
|
-
abi: inputBoxAbi,
|
|
94
|
-
functionName: "addInput",
|
|
95
|
-
args: [applicationAddress, payload],
|
|
96
|
-
account: walletClient.account,
|
|
97
|
-
});
|
|
98
|
-
return walletClient.writeContract(request);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
SendGeneric.summary = "Send generic input to the application.";
|
|
102
|
-
SendGeneric.description = "Sends generics inputs to the application, optionally in interactive mode.";
|
|
103
|
-
SendGeneric.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
104
|
-
SendGeneric.flags = {
|
|
105
|
-
input: Flags.string({
|
|
106
|
-
description: "input payload",
|
|
107
|
-
summary: "see input-encoding for definition on how input is parsed",
|
|
108
|
-
}),
|
|
109
|
-
"input-encoding": Flags.string({
|
|
110
|
-
description: "input encoding",
|
|
111
|
-
summary: "if input-encoding is undefined, the input is parsed as a hex-string if it starts with 0x or else is parsed as a UTF-8 encoding",
|
|
112
|
-
options: ["hex", "string", "abi"],
|
|
113
|
-
}),
|
|
114
|
-
"input-abi-params": Flags.string({
|
|
115
|
-
description: "input abi params",
|
|
116
|
-
summary: "ABI params definition for input, following human-readable format specified at https://abitype.dev/api/human.html#parseabiparameters",
|
|
117
|
-
}),
|
|
118
|
-
};
|
|
119
|
-
export default SendGeneric;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Command, Interfaces } from "@oclif/core";
|
|
2
|
-
import { Address, PublicClient, WalletClient } from "viem";
|
|
3
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
4
|
-
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof SendBaseCommand)["baseFlags"] & T["flags"]>;
|
|
5
|
-
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
|
|
6
|
-
export declare abstract class SendBaseCommand<T extends typeof Command> extends BaseCommand<typeof SendBaseCommand> {
|
|
7
|
-
static baseFlags: {
|
|
8
|
-
dapp: Interfaces.OptionFlag<`0x${string}` | undefined, Interfaces.CustomOptions>;
|
|
9
|
-
"chain-id": Interfaces.OptionFlag<number | undefined, Interfaces.CustomOptions>;
|
|
10
|
-
"rpc-url": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
11
|
-
"mnemonic-passphrase": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
12
|
-
"mnemonic-index": Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
|
|
13
|
-
};
|
|
14
|
-
protected flags: Flags<T>;
|
|
15
|
-
protected args: Args<T>;
|
|
16
|
-
private connect;
|
|
17
|
-
protected getApplicationAddress(): Promise<Address>;
|
|
18
|
-
init(): Promise<void>;
|
|
19
|
-
protected abstract send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
|
|
20
|
-
run(): Promise<void>;
|
|
21
|
-
}
|
|
22
|
-
export default class Send extends Command {
|
|
23
|
-
static summary: string;
|
|
24
|
-
static description: string;
|
|
25
|
-
static examples: string[];
|
|
26
|
-
run(): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/send/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAa,MAAM,MAAM,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,aAAa,CAClE,CAAC,OAAO,eAAe,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CACrD,CAAC;AACF,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGhF,8BAAsB,eAAe,CACjC,CAAC,SAAS,OAAO,OAAO,CAC1B,SAAQ,WAAW,CAAC,OAAO,eAAe,CAAC;IACzC,MAAM,CAAC,SAAS;;;;;;MA8Bd;IAEF,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAEX,OAAO;cAeL,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;IAmB5C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAYlC,SAAS,CAAC,QAAQ,CAAC,IAAI,CACnB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;IAEN,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC;AAED,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACrC,MAAM,CAAC,OAAO,SAAoC;IAElD,MAAM,CAAC,WAAW,SAC2D;IAE7E,MAAM,CAAC,QAAQ,WAA2C;IAE7C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBpC"}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import input from "@inquirer/input";
|
|
2
|
-
import select from "@inquirer/select";
|
|
3
|
-
import { Command, Flags as StandardFlags } from "@oclif/core";
|
|
4
|
-
import ora from "ora";
|
|
5
|
-
import { isAddress } from "viem";
|
|
6
|
-
import { BaseCommand } from "../../baseCommand.js";
|
|
7
|
-
import * as CustomFlags from "../../flags.js";
|
|
8
|
-
import createClients, { supportedChains } from "../../wallet.js";
|
|
9
|
-
// base command for sending input to the application
|
|
10
|
-
export class SendBaseCommand extends BaseCommand {
|
|
11
|
-
async connect() {
|
|
12
|
-
// create viem clients
|
|
13
|
-
return createClients({
|
|
14
|
-
chain: supportedChains({ includeDevnet: true }).find((c) => c.id == this.flags["chain-id"]),
|
|
15
|
-
rpcUrl: this.flags["rpc-url"],
|
|
16
|
-
mnemonicPassphrase: this.flags["mnemonic-passphrase"],
|
|
17
|
-
mnemonicIndex: this.flags["mnemonic-index"],
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async getApplicationAddress() {
|
|
21
|
-
if (this.flags.dapp) {
|
|
22
|
-
// honor the flag
|
|
23
|
-
return this.flags.dapp;
|
|
24
|
-
}
|
|
25
|
-
// get the running container dapp address
|
|
26
|
-
const nodeAddress = await super.getApplicationAddress();
|
|
27
|
-
// query for the address
|
|
28
|
-
const applicationAddress = await input({
|
|
29
|
-
message: "Application address",
|
|
30
|
-
validate: (value) => isAddress(value) || "Invalid address",
|
|
31
|
-
default: nodeAddress,
|
|
32
|
-
});
|
|
33
|
-
return applicationAddress;
|
|
34
|
-
}
|
|
35
|
-
async init() {
|
|
36
|
-
await super.init();
|
|
37
|
-
const { args, flags } = await this.parse({
|
|
38
|
-
flags: this.ctor.flags,
|
|
39
|
-
baseFlags: super.ctor.baseFlags,
|
|
40
|
-
args: this.ctor.args,
|
|
41
|
-
strict: this.ctor.strict,
|
|
42
|
-
});
|
|
43
|
-
this.flags = flags;
|
|
44
|
-
this.args = args;
|
|
45
|
-
}
|
|
46
|
-
async run() {
|
|
47
|
-
const { publicClient, walletClient } = await this.connect();
|
|
48
|
-
const hash = await this.send(publicClient, walletClient);
|
|
49
|
-
const progress = ora("Sending input...").start();
|
|
50
|
-
await publicClient.waitForTransactionReceipt({ hash });
|
|
51
|
-
progress.succeed(`Input sent: ${hash}`);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
SendBaseCommand.baseFlags = {
|
|
55
|
-
dapp: CustomFlags.address({
|
|
56
|
-
summary: "dapp address.",
|
|
57
|
-
description: "the address of the DApp, defaults to the deployed DApp address if application is running.",
|
|
58
|
-
}),
|
|
59
|
-
"chain-id": StandardFlags.integer({
|
|
60
|
-
description: "The EIP-155 chain ID.",
|
|
61
|
-
char: "c",
|
|
62
|
-
env: "CHAIN",
|
|
63
|
-
helpGroup: "Ethereum",
|
|
64
|
-
options: supportedChains({ includeDevnet: true }).map((c) => c.id.toString()),
|
|
65
|
-
}),
|
|
66
|
-
"rpc-url": StandardFlags.string({
|
|
67
|
-
description: "The RPC endpoint.",
|
|
68
|
-
char: "r",
|
|
69
|
-
env: "ETH_RPC_URL",
|
|
70
|
-
helpGroup: "Ethereum",
|
|
71
|
-
}),
|
|
72
|
-
"mnemonic-passphrase": StandardFlags.string({
|
|
73
|
-
description: "Use a BIP39 passphrase for the mnemonic.",
|
|
74
|
-
helpGroup: "Wallet",
|
|
75
|
-
}),
|
|
76
|
-
"mnemonic-index": StandardFlags.integer({
|
|
77
|
-
description: "Use the private key from the given mnemonic index.",
|
|
78
|
-
helpGroup: "Wallet",
|
|
79
|
-
default: 0,
|
|
80
|
-
}),
|
|
81
|
-
};
|
|
82
|
-
class Send extends Command {
|
|
83
|
-
async run() {
|
|
84
|
-
// get all send sub-commands
|
|
85
|
-
const sendCommands = this.config.commands.filter((command) => command.id.startsWith("send:"));
|
|
86
|
-
// select the send sub-command
|
|
87
|
-
const commandId = await select({
|
|
88
|
-
message: "Select send sub-command",
|
|
89
|
-
choices: sendCommands.map((command) => ({
|
|
90
|
-
value: command.id,
|
|
91
|
-
name: command.summary,
|
|
92
|
-
description: command.description,
|
|
93
|
-
})),
|
|
94
|
-
});
|
|
95
|
-
// invoke the sub-command
|
|
96
|
-
await this.config.runCommand(commandId, this.argv);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
Send.summary = "Send input to the application.";
|
|
100
|
-
Send.description = "Sends different kinds of input to the application in interactive mode.";
|
|
101
|
-
Send.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
102
|
-
export default Send;
|
package/dist/commands/shell.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
2
|
-
export default class Shell extends BaseCommand<typeof Shell> {
|
|
3
|
-
static description: string;
|
|
4
|
-
static examples: string[];
|
|
5
|
-
static args: {
|
|
6
|
-
image: import("@oclif/core/lib/interfaces/parser.js").Arg<string | undefined, Record<string, unknown>>;
|
|
7
|
-
};
|
|
8
|
-
static flags: {
|
|
9
|
-
command: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
10
|
-
config: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
|
|
11
|
-
"run-as-root": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
|
|
12
|
-
};
|
|
13
|
-
run(): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/commands/shell.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,WAAW,SAAqD;IAEvE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,KAAK;;;;MAgBV;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2CpC"}
|
package/dist/commands/shell.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Args, Flags } from "@oclif/core";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { BaseCommand } from "../baseCommand.js";
|
|
5
|
-
import { bootMachine } from "../machine.js";
|
|
6
|
-
class Shell extends BaseCommand {
|
|
7
|
-
async run() {
|
|
8
|
-
const { flags } = await this.parse(Shell);
|
|
9
|
-
// get application configuration from 'cartesi.toml'
|
|
10
|
-
const config = this.getApplicationConfig(flags.config);
|
|
11
|
-
// destination directory for image and intermediate files
|
|
12
|
-
const destination = path.resolve(this.getContextPath());
|
|
13
|
-
// check if all drives are built
|
|
14
|
-
for (const [name, drive] of Object.entries(config.drives)) {
|
|
15
|
-
const filename = `${name}.${drive.format}`;
|
|
16
|
-
const pathname = this.getContextPath(filename);
|
|
17
|
-
if (!fs.existsSync(pathname)) {
|
|
18
|
-
throw new Error(`drive '${name}' not built, run '${this.config.bin} build'`);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
// create shell entrypoint
|
|
22
|
-
const info = {
|
|
23
|
-
cmd: [],
|
|
24
|
-
entrypoint: [this.flags.command],
|
|
25
|
-
env: [],
|
|
26
|
-
workdir: "/",
|
|
27
|
-
};
|
|
28
|
-
// start with interactive mode on
|
|
29
|
-
config.machine.interactive = true;
|
|
30
|
-
// interactive mode can't have final hash
|
|
31
|
-
config.machine.finalHash = false;
|
|
32
|
-
// do not store machine in interactive mode
|
|
33
|
-
config.machine.store = undefined;
|
|
34
|
-
// run as root if flag is set
|
|
35
|
-
config.machine.user = flags["run-as-root"] ? "root" : undefined;
|
|
36
|
-
// boot machine
|
|
37
|
-
await bootMachine(config, info, destination);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
Shell.description = "Start a shell in cartesi machine of application";
|
|
41
|
-
Shell.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
42
|
-
Shell.args = {
|
|
43
|
-
image: Args.string({
|
|
44
|
-
description: "image ID|name",
|
|
45
|
-
required: false,
|
|
46
|
-
}),
|
|
47
|
-
};
|
|
48
|
-
Shell.flags = {
|
|
49
|
-
command: Flags.string({
|
|
50
|
-
default: "/bin/sh",
|
|
51
|
-
description: "shell command to run",
|
|
52
|
-
summary: "shell to run",
|
|
53
|
-
}),
|
|
54
|
-
config: Flags.file({
|
|
55
|
-
char: "c",
|
|
56
|
-
default: "cartesi.toml",
|
|
57
|
-
summary: "path to the configuration file",
|
|
58
|
-
}),
|
|
59
|
-
"run-as-root": Flags.boolean({
|
|
60
|
-
default: false,
|
|
61
|
-
description: "run as root user",
|
|
62
|
-
summary: "run the cartesi machine as the root user",
|
|
63
|
-
}),
|
|
64
|
-
};
|
|
65
|
-
export default Shell;
|
package/dist/config.d.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { TomlPrimitive } from "smol-toml";
|
|
2
|
-
/**
|
|
3
|
-
* Typed Errors
|
|
4
|
-
*/
|
|
5
|
-
export declare class InvalidBuilderError extends Error {
|
|
6
|
-
constructor(builder: TomlPrimitive);
|
|
7
|
-
}
|
|
8
|
-
export declare class InvalidDriveFormatError extends Error {
|
|
9
|
-
constructor(format: TomlPrimitive);
|
|
10
|
-
}
|
|
11
|
-
export declare class InvalidEmptyDriveFormatError extends Error {
|
|
12
|
-
constructor(format: TomlPrimitive);
|
|
13
|
-
}
|
|
14
|
-
export declare class InvalidStringValueError extends Error {
|
|
15
|
-
constructor(value: TomlPrimitive);
|
|
16
|
-
}
|
|
17
|
-
export declare class InvalidBooleanValueError extends Error {
|
|
18
|
-
constructor(value: TomlPrimitive);
|
|
19
|
-
}
|
|
20
|
-
export declare class InvalidNumberValueError extends Error {
|
|
21
|
-
constructor(value: TomlPrimitive);
|
|
22
|
-
}
|
|
23
|
-
export declare class InvalidBytesValueError extends Error {
|
|
24
|
-
constructor(value: TomlPrimitive);
|
|
25
|
-
}
|
|
26
|
-
export declare class RequiredFieldError extends Error {
|
|
27
|
-
constructor(key: TomlPrimitive);
|
|
28
|
-
}
|
|
29
|
-
export declare class InvalidStringArrayError extends Error {
|
|
30
|
-
constructor();
|
|
31
|
-
}
|
|
32
|
-
export declare const DEFAULT_SDK = "cartesi/sdk:0.12.0-alpha.1";
|
|
33
|
-
type DriveFormat = "ext2" | "sqfs";
|
|
34
|
-
export type ImageInfo = {
|
|
35
|
-
cmd: string[];
|
|
36
|
-
entrypoint: string[];
|
|
37
|
-
env: string[];
|
|
38
|
-
workdir: string;
|
|
39
|
-
};
|
|
40
|
-
export type DriveResult = ImageInfo | undefined | void;
|
|
41
|
-
export type DirectoryDriveConfig = {
|
|
42
|
-
builder: "directory";
|
|
43
|
-
extraSize: number;
|
|
44
|
-
format: DriveFormat;
|
|
45
|
-
directory: string;
|
|
46
|
-
};
|
|
47
|
-
export type DockerDriveConfig = {
|
|
48
|
-
builder: "docker";
|
|
49
|
-
context: string;
|
|
50
|
-
dockerfile: string;
|
|
51
|
-
extraSize: number;
|
|
52
|
-
format: DriveFormat;
|
|
53
|
-
image?: string;
|
|
54
|
-
tags: string[];
|
|
55
|
-
target?: string;
|
|
56
|
-
};
|
|
57
|
-
export type EmptyDriveConfig = {
|
|
58
|
-
builder: "empty";
|
|
59
|
-
format: "ext2" | "raw";
|
|
60
|
-
size: number;
|
|
61
|
-
};
|
|
62
|
-
export type ExistingDriveConfig = {
|
|
63
|
-
builder: "none";
|
|
64
|
-
filename: string;
|
|
65
|
-
format: DriveFormat;
|
|
66
|
-
};
|
|
67
|
-
export type TarDriveConfig = {
|
|
68
|
-
builder: "tar";
|
|
69
|
-
filename: string;
|
|
70
|
-
format: DriveFormat;
|
|
71
|
-
extraSize: number;
|
|
72
|
-
};
|
|
73
|
-
export type DriveConfig = (DirectoryDriveConfig | DockerDriveConfig | EmptyDriveConfig | ExistingDriveConfig | TarDriveConfig) & {
|
|
74
|
-
mount?: string | boolean;
|
|
75
|
-
shared?: boolean;
|
|
76
|
-
user?: string;
|
|
77
|
-
};
|
|
78
|
-
export type MachineConfig = {
|
|
79
|
-
assertRollingTemplate?: boolean;
|
|
80
|
-
bootargs: string[];
|
|
81
|
-
entrypoint?: string;
|
|
82
|
-
finalHash: boolean;
|
|
83
|
-
interactive?: boolean;
|
|
84
|
-
maxMCycle?: bigint;
|
|
85
|
-
noRollup?: boolean;
|
|
86
|
-
ramLength: string;
|
|
87
|
-
ramImage: string;
|
|
88
|
-
store?: string;
|
|
89
|
-
user?: string;
|
|
90
|
-
};
|
|
91
|
-
export type Config = {
|
|
92
|
-
drives: Record<string, DriveConfig>;
|
|
93
|
-
machine: MachineConfig;
|
|
94
|
-
sdk: string;
|
|
95
|
-
};
|
|
96
|
-
export declare const defaultRootDriveConfig: () => DriveConfig;
|
|
97
|
-
export declare const defaultMachineConfig: () => MachineConfig;
|
|
98
|
-
export declare const defaultConfig: () => Config;
|
|
99
|
-
export declare const getDriveFormat: (filename: string) => DriveFormat;
|
|
100
|
-
export declare const parse: (str: string) => Config;
|
|
101
|
-
export {};
|
|
102
|
-
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|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