@cartesi/cli 2.0.0-alpha.1 → 2.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.d.ts +18 -0
- package/dist/base.d.ts.map +1 -0
- package/dist/base.js +99 -0
- package/dist/builder/directory.d.ts +2 -2
- package/dist/builder/directory.d.ts.map +1 -1
- package/dist/builder/directory.js +1 -1
- package/dist/builder/docker.d.ts +1 -1
- package/dist/builder/docker.d.ts.map +1 -1
- package/dist/builder/docker.js +8 -8
- package/dist/builder/empty.d.ts +2 -2
- package/dist/builder/empty.d.ts.map +1 -1
- package/dist/builder/empty.js +1 -1
- package/dist/builder/none.d.ts +2 -2
- package/dist/builder/none.d.ts.map +1 -1
- package/dist/builder/none.js +1 -1
- package/dist/builder/tar.d.ts +2 -2
- package/dist/builder/tar.d.ts.map +1 -1
- package/dist/builder/tar.js +1 -1
- package/dist/commands/address-book.d.ts +4 -8
- package/dist/commands/address-book.d.ts.map +1 -1
- package/dist/commands/address-book.js +15 -14
- package/dist/commands/build.d.ts +5 -11
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +18 -30
- package/dist/commands/clean.d.ts +2 -7
- package/dist/commands/clean.d.ts.map +1 -1
- package/dist/commands/clean.js +9 -10
- package/dist/commands/create.d.ts +6 -15
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +24 -54
- package/dist/commands/deploy/build.d.ts +2 -14
- package/dist/commands/deploy/build.d.ts.map +1 -1
- package/dist/commands/deploy/build.js +8 -61
- package/dist/commands/deploy.d.ts +18 -0
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +271 -0
- package/dist/commands/doctor.d.ts +2 -12
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +90 -91
- package/dist/commands/hash.d.ts +4 -9
- package/dist/commands/hash.d.ts.map +1 -1
- package/dist/commands/hash.js +14 -14
- package/dist/commands/logs.d.ts +10 -0
- package/dist/commands/logs.d.ts.map +1 -0
- package/dist/commands/logs.js +33 -0
- package/dist/commands/run.d.ts +2 -20
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +9 -190
- package/dist/commands/send/eip712.d.ts +34 -0
- package/dist/commands/send/eip712.d.ts.map +1 -0
- package/dist/commands/send/eip712.js +81 -0
- package/dist/commands/send/erc20.d.ts +11 -13
- package/dist/commands/send/erc20.d.ts.map +1 -1
- package/dist/commands/send/erc20.js +57 -52
- package/dist/commands/send/erc721.d.ts +11 -13
- package/dist/commands/send/erc721.d.ts.map +1 -1
- package/dist/commands/send/erc721.js +51 -46
- package/dist/commands/send/ether.d.ts +11 -12
- package/dist/commands/send/ether.d.ts.map +1 -1
- package/dist/commands/send/ether.js +25 -21
- package/dist/commands/send/generic.d.ts +14 -14
- package/dist/commands/send/generic.d.ts.map +1 -1
- package/dist/commands/send/generic.js +102 -99
- package/dist/commands/send.d.ts +21 -0
- package/dist/commands/send.d.ts.map +1 -0
- package/dist/commands/send.js +67 -0
- package/dist/commands/shell.d.ts +6 -14
- package/dist/commands/shell.d.ts.map +1 -1
- package/dist/commands/shell.js +22 -44
- package/dist/commands/start.d.ts +14 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +220 -0
- package/dist/commands/status.d.ts +6 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +47 -0
- package/dist/commands/stop.d.ts +5 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +27 -0
- package/dist/compose/default.env +35 -0
- package/dist/compose/docker-compose-anvil.yaml +17 -0
- package/dist/compose/docker-compose-bundler.yaml +37 -0
- package/dist/{node → compose}/docker-compose-database.yaml +4 -2
- package/dist/compose/docker-compose-espresso.yaml +59 -0
- package/dist/compose/docker-compose-explorer.yaml +57 -0
- package/dist/compose/docker-compose-graphql.yaml +23 -0
- package/dist/compose/docker-compose-node-cpus.yaml +6 -0
- package/dist/compose/docker-compose-node-memory.yaml +6 -0
- package/dist/compose/docker-compose-node.yaml +31 -0
- package/dist/compose/docker-compose-passkey-server.yaml +15 -0
- package/dist/compose/docker-compose-paymaster.yaml +18 -0
- package/dist/compose/docker-compose-proxy.yaml +24 -0
- package/dist/compose/proxy/anvil.yaml +17 -0
- package/dist/compose/proxy/bundler.yaml +29 -0
- package/dist/compose/proxy/espresso.yaml +17 -0
- package/dist/compose/proxy/explorer-api.yaml +17 -0
- package/dist/compose/proxy/explorer.yaml +10 -0
- package/dist/compose/proxy/graphql.yaml +10 -0
- package/dist/compose/proxy/passkey-server.yaml +17 -0
- package/dist/compose/proxy/paymaster.yaml +17 -0
- package/dist/compose/proxy/rollups-node.yaml +17 -0
- package/dist/config.d.ts +5 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +26 -35
- package/dist/contracts.d.ts +1695 -1636
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +632 -592
- package/dist/exec/cartesi-machine.d.ts +2 -2
- package/dist/exec/cartesi-machine.d.ts.map +1 -1
- package/dist/exec/cartesi-machine.js +1 -1
- package/dist/exec/crane.d.ts +4 -4
- package/dist/exec/crane.d.ts.map +1 -1
- package/dist/exec/crane.js +1 -1
- package/dist/exec/genext2fs.d.ts +2 -2
- package/dist/exec/genext2fs.d.ts.map +1 -1
- package/dist/exec/genext2fs.js +2 -2
- package/dist/exec/mksquashfs.d.ts +2 -2
- package/dist/exec/mksquashfs.d.ts.map +1 -1
- package/dist/exec/mksquashfs.js +2 -2
- package/dist/exec/rollups.d.ts +16 -0
- package/dist/exec/rollups.d.ts.map +1 -0
- package/dist/exec/rollups.js +39 -0
- package/dist/exec/util.d.ts +3 -3
- package/dist/exec/util.d.ts.map +1 -1
- package/dist/exec/util.js +8 -10
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -1
- package/dist/machine.d.ts +1 -1
- package/dist/machine.d.ts.map +1 -1
- package/dist/prompts.d.ts +3 -3
- package/dist/prompts.d.ts.map +1 -1
- package/dist/prompts.js +1 -1
- package/dist/template.d.ts +3 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +16 -0
- package/dist/wallet.d.ts +1 -1
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +109 -84
- package/package.json +32 -50
- package/bin/dev.cmd +0 -3
- package/bin/dev.js +0 -25
- package/bin/run.cmd +0 -3
- package/bin/run.js +0 -8
- package/dist/baseCommand.d.ts +0 -22
- package/dist/baseCommand.d.ts.map +0 -1
- package/dist/baseCommand.js +0 -92
- package/dist/commands/deploy/index.d.ts +0 -12
- package/dist/commands/deploy/index.d.ts.map +0 -1
- package/dist/commands/deploy/index.js +0 -78
- package/dist/commands/send/index.d.ts +0 -28
- package/dist/commands/send/index.d.ts.map +0 -1
- package/dist/commands/send/index.js +0 -102
- package/dist/flags.d.ts +0 -17
- package/dist/flags.d.ts.map +0 -1
- package/dist/flags.js +0 -28
- package/dist/node/DockerfileDeploy.txt +0 -4
- package/dist/node/default.env +0 -27
- package/dist/node/docker-compose-anvil.yaml +0 -50
- package/dist/node/docker-compose-bundler.yaml +0 -57
- package/dist/node/docker-compose-envfile.yaml +0 -4
- package/dist/node/docker-compose-explorer.yaml +0 -88
- package/dist/node/docker-compose-host.yaml +0 -30
- package/dist/node/docker-compose-paymaster.yaml +0 -33
- package/dist/node/docker-compose-prompt.yaml +0 -17
- package/dist/node/docker-compose-proxy.yaml +0 -48
- package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
- package/dist/node/docker-compose-validator-cpus.yaml +0 -6
- package/dist/node/docker-compose-validator-memory.yaml +0 -6
- package/dist/node/docker-compose-validator.yaml +0 -59
- package/oclif.manifest.json +0 -876
|
@@ -1,45 +1,55 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
1
2
|
import input from "@inquirer/input";
|
|
2
|
-
import
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { erc721Abi, getAddress, isAddress, } from "viem";
|
|
3
5
|
import { erc721PortalAbi, erc721PortalAddress } from "../../contracts.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
import { connect, getInputApplicationAddress, } from "../send.js";
|
|
7
|
+
const readToken = async (publicClient, address) => {
|
|
8
|
+
const args = { abi: erc721Abi, address };
|
|
9
|
+
const symbol = await publicClient.readContract({
|
|
10
|
+
...args,
|
|
11
|
+
functionName: "symbol",
|
|
12
|
+
});
|
|
13
|
+
const name = await publicClient.readContract({
|
|
14
|
+
...args,
|
|
15
|
+
functionName: "name",
|
|
16
|
+
});
|
|
17
|
+
return {
|
|
18
|
+
name,
|
|
19
|
+
symbol,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
const ercValidator = (publicClient) => async (value) => {
|
|
23
|
+
if (!isAddress(value)) {
|
|
24
|
+
return "Invalid address";
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
await readToken(publicClient, value);
|
|
21
28
|
}
|
|
22
|
-
|
|
29
|
+
catch (e) {
|
|
30
|
+
return "Invalid token";
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
33
|
+
};
|
|
34
|
+
export const createErc721Command = () => {
|
|
35
|
+
return new Command("erc721")
|
|
36
|
+
.description("Sends ERC-721 deposits to the application, optionally in interactive mode.")
|
|
37
|
+
.configureHelp({ showGlobalOptions: true })
|
|
38
|
+
.option("--token <address>", "token address")
|
|
39
|
+
.option("--token-id <number>", "token ID")
|
|
40
|
+
.action(async (options, command) => {
|
|
41
|
+
const sendOptions = command.optsWithGlobals();
|
|
42
|
+
// connect to RPC provider
|
|
43
|
+
const { publicClient, walletClient } = await connect(sendOptions);
|
|
23
44
|
// get dapp address from local node, or ask
|
|
24
|
-
const applicationAddress = await
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
try {
|
|
30
|
-
await this.readToken(publicClient, value);
|
|
31
|
-
}
|
|
32
|
-
catch (e) {
|
|
33
|
-
return "Invalid token";
|
|
34
|
-
}
|
|
35
|
-
return true;
|
|
36
|
-
};
|
|
37
|
-
const token = this.flags.token ||
|
|
38
|
-
(await input({
|
|
45
|
+
const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
|
|
46
|
+
const token = options.token && isAddress(options.token)
|
|
47
|
+
? getAddress(options.token)
|
|
48
|
+
: (await input({
|
|
39
49
|
message: "Token address",
|
|
40
|
-
validate: ercValidator,
|
|
50
|
+
validate: ercValidator(publicClient),
|
|
41
51
|
}));
|
|
42
|
-
const tokenId =
|
|
52
|
+
const tokenId = options.tokenId ||
|
|
43
53
|
(await input({
|
|
44
54
|
message: "Token ID",
|
|
45
55
|
validate: (value) => {
|
|
@@ -60,14 +70,9 @@ class SendERC721 extends SendBaseCommand {
|
|
|
60
70
|
account: walletClient.account,
|
|
61
71
|
});
|
|
62
72
|
// XXX: add support for baseLayerData and execLayerData
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
SendERC721.flags = {
|
|
69
|
-
token: CustomFlags.address({ description: "token address" }),
|
|
70
|
-
tokenId: CustomFlags.bigint({ description: "token ID" }),
|
|
73
|
+
const hash = await walletClient.writeContract(request);
|
|
74
|
+
const progress = ora("Sending input...").start();
|
|
75
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
76
|
+
progress.succeed(`Input sent: ${hash}`);
|
|
77
|
+
});
|
|
71
78
|
};
|
|
72
|
-
SendERC721.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
73
|
-
export default SendERC721;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createEtherCommand: () => Command<[], {
|
|
3
|
+
amount?: string | undefined;
|
|
4
|
+
execLayerData: string;
|
|
5
|
+
}, {
|
|
6
|
+
chainId: number;
|
|
7
|
+
rpcUrl?: string | undefined;
|
|
8
|
+
mnemonic?: string | undefined;
|
|
9
|
+
mnemonicIndex: number;
|
|
10
|
+
dapp?: `0x${string}` | undefined;
|
|
11
|
+
}>;
|
|
13
12
|
//# sourceMappingURL=ether.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ether.d.ts","sourceRoot":"","sources":["../../../src/commands/send/ether.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ether.d.ts","sourceRoot":"","sources":["../../../src/commands/send/ether.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAWtD,eAAO,MAAM,kBAAkB;;;;;;;;;EAuC9B,CAAC"}
|
|
@@ -1,32 +1,36 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
1
2
|
import input from "@inquirer/input";
|
|
2
|
-
import
|
|
3
|
+
import ora from "ora";
|
|
4
|
+
import { isHex, parseEther } from "viem";
|
|
3
5
|
import { etherPortalAbi, etherPortalAddress } from "../../contracts.js";
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { connect, getInputApplicationAddress, } from "../send.js";
|
|
7
|
+
export const createEtherCommand = () => {
|
|
8
|
+
return new Command("ether")
|
|
9
|
+
.description("Sends ether deposits to the application, optionally in interactive mode.")
|
|
10
|
+
.configureHelp({ showGlobalOptions: true })
|
|
11
|
+
.option("--amount <number>", "amount, in ETH units")
|
|
12
|
+
.option("--exec-layer-data <hex>", "exec layer data", "0x")
|
|
13
|
+
.action(async (options, command) => {
|
|
14
|
+
const sendOptions = command.optsWithGlobals();
|
|
15
|
+
// connect to RPC provider
|
|
16
|
+
const { publicClient, walletClient } = await connect(sendOptions);
|
|
8
17
|
// get dapp address from local node, or ask
|
|
9
|
-
const applicationAddress = await
|
|
10
|
-
const amount =
|
|
18
|
+
const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
|
|
19
|
+
const amount = options.amount || (await input({ message: "Amount" }));
|
|
11
20
|
const { request } = await publicClient.simulateContract({
|
|
12
21
|
address: etherPortalAddress,
|
|
13
22
|
abi: etherPortalAbi,
|
|
14
23
|
functionName: "depositEther",
|
|
15
|
-
args: [
|
|
24
|
+
args: [
|
|
25
|
+
applicationAddress,
|
|
26
|
+
isHex(options.execLayerData) ? options.execLayerData : "0x", // XXX: validate before this
|
|
27
|
+
],
|
|
16
28
|
value: parseEther(amount),
|
|
17
29
|
account: walletClient.account,
|
|
18
30
|
});
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
}),
|
|
31
|
+
const hash = await walletClient.writeContract(request);
|
|
32
|
+
const progress = ora("Sending input...").start();
|
|
33
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
34
|
+
progress.succeed(`Input sent: ${hash}`);
|
|
35
|
+
});
|
|
30
36
|
};
|
|
31
|
-
SendEther.examples = ["<%= config.bin %> <%= command.id %>"];
|
|
32
|
-
export default SendEther;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createGenericCommand: () => Command<[], {
|
|
3
|
+
input?: string | undefined;
|
|
4
|
+
inputEncoding?: "string" | "hex" | "abi" | undefined;
|
|
5
|
+
type: "evm" | "eip712";
|
|
6
|
+
eip712TxUrl: string;
|
|
7
|
+
inputAbiParams?: string | undefined;
|
|
8
|
+
}, {
|
|
9
|
+
chainId: number;
|
|
10
|
+
rpcUrl?: string | undefined;
|
|
11
|
+
mnemonic?: string | undefined;
|
|
12
|
+
mnemonicIndex: number;
|
|
13
|
+
dapp?: `0x${string}` | undefined;
|
|
14
|
+
}>;
|
|
15
15
|
//# sourceMappingURL=generic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/commands/send/generic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/commands/send/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAqG9D,eAAO,MAAM,oBAAoB;;;;;;;;;;;;EA8DhC,CAAC"}
|
|
@@ -1,93 +1,112 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Command, Option } from "@commander-js/extra-typings";
|
|
2
|
+
import ora from "ora";
|
|
2
3
|
import { encodeAbiParameters, getAddress, isAddress, isHex, parseAbiParameters, stringToHex, } from "viem";
|
|
3
4
|
import { inputBoxAbi, inputBoxAddress } from "../../contracts.js";
|
|
4
5
|
import { bytesInput } from "../../prompts.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
return input;
|
|
6
|
+
import { connect, getInputApplicationAddress, } from "../send.js";
|
|
7
|
+
import { DEFAULT_SEND_CONFIG, sendEip712 } from "./eip712.js";
|
|
8
|
+
const getInput = async (options) => {
|
|
9
|
+
const input = options.input;
|
|
10
|
+
const encoding = options.inputEncoding;
|
|
11
|
+
if (input) {
|
|
12
|
+
if (encoding === "hex") {
|
|
13
|
+
// validate if is a hex value
|
|
14
|
+
if (!isHex(input)) {
|
|
15
|
+
throw new Error("input encoded as hex must start with 0x");
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
return input;
|
|
18
|
+
}
|
|
19
|
+
if (encoding === "string") {
|
|
20
|
+
// encode UTF-8 string as hex
|
|
21
|
+
return stringToHex(input);
|
|
22
|
+
}
|
|
23
|
+
if (encoding === "abi") {
|
|
24
|
+
const abiParams = options.inputAbiParams;
|
|
25
|
+
if (!abiParams) {
|
|
26
|
+
throw new Error("Undefined input-abi-params");
|
|
21
27
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
const abiParameters = parseAbiParameters(abiParams);
|
|
29
|
+
// TODO: decode values
|
|
30
|
+
const values = input.split(",").map((v, index) => {
|
|
31
|
+
if (index >= abiParameters.length) {
|
|
32
|
+
throw new Error(`Too many values, expected ${abiParameters.length} values based on --input-abi-params '${abiParams}', parsing value at index ${index} from input '${input}'`);
|
|
26
33
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
const param = abiParameters[index];
|
|
35
|
+
switch (param.type) {
|
|
36
|
+
case "string":
|
|
37
|
+
return v;
|
|
38
|
+
case "bool":
|
|
39
|
+
if (v === "true")
|
|
40
|
+
return true;
|
|
41
|
+
if (v === "false")
|
|
42
|
+
return false;
|
|
43
|
+
throw new Error(`Invalid boolean value: ${v}`);
|
|
44
|
+
case "uint":
|
|
45
|
+
case "uint8":
|
|
46
|
+
case "uint16":
|
|
47
|
+
case "uint32":
|
|
48
|
+
case "uint64":
|
|
49
|
+
case "uint128":
|
|
50
|
+
case "uint256":
|
|
51
|
+
try {
|
|
52
|
+
return BigInt(v);
|
|
53
|
+
}
|
|
54
|
+
catch (e) {
|
|
55
|
+
throw new Error(`Invalid uint value: ${v}`);
|
|
56
|
+
}
|
|
57
|
+
case "bytes":
|
|
58
|
+
if (isHex(v)) {
|
|
36
59
|
return v;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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);
|
|
60
|
+
}
|
|
61
|
+
throw new Error(`Invalid bytes value: ${v}`);
|
|
62
|
+
case "address":
|
|
63
|
+
if (isAddress(v)) {
|
|
64
|
+
return getAddress(v);
|
|
65
|
+
}
|
|
66
|
+
throw new Error(`Invalid address value: ${v}`);
|
|
67
|
+
default:
|
|
68
|
+
throw new Error(`Unsupported type ${param.type}`);
|
|
82
69
|
}
|
|
70
|
+
});
|
|
71
|
+
if (values.length !== abiParameters.length) {
|
|
72
|
+
throw new Error(`Not enough values, expected ${abiParameters.length} values based on --input-abi-params '${abiParams}', parsed ${values.length} values from input '${input}'`);
|
|
83
73
|
}
|
|
74
|
+
return encodeAbiParameters(abiParameters, values);
|
|
75
|
+
}
|
|
76
|
+
if (isHex(input)) {
|
|
77
|
+
return input;
|
|
84
78
|
}
|
|
85
|
-
|
|
79
|
+
// encode UTF-8 string as hex
|
|
80
|
+
return stringToHex(input);
|
|
86
81
|
}
|
|
87
|
-
|
|
82
|
+
return undefined;
|
|
83
|
+
};
|
|
84
|
+
export const createGenericCommand = () => {
|
|
85
|
+
return new Command("generic")
|
|
86
|
+
.description("Sends generics inputs to the application, optionally in interactive mode.")
|
|
87
|
+
.configureHelp({ showGlobalOptions: true })
|
|
88
|
+
.option("--input <input>", "input payload")
|
|
89
|
+
.addOption(new Option("--input-encoding <input-encoding>", "input encoding").choices(["hex", "string", "abi"]))
|
|
90
|
+
.addOption(new Option("--type <type>", "Transaction type").choices(["evm", "eip712"])
|
|
91
|
+
.default("evm"))
|
|
92
|
+
.addOption(new Option("--eip712-tx-url <url>", "EIP-712 base url").default(DEFAULT_SEND_CONFIG.eip712TxUrl))
|
|
93
|
+
.option("--input-abi-params <input-abi-params>", "input abi params")
|
|
94
|
+
.action(async (options, command) => {
|
|
95
|
+
const sendOptions = command.optsWithGlobals();
|
|
96
|
+
// connect to RPC provider
|
|
97
|
+
const { publicClient, walletClient } = await connect(sendOptions);
|
|
88
98
|
// get dapp address from local node, or ask
|
|
89
|
-
const applicationAddress = await
|
|
90
|
-
const payload = (await
|
|
99
|
+
const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
|
|
100
|
+
const payload = (await getInput(options)) ||
|
|
101
|
+
(await bytesInput({ message: "Input" }));
|
|
102
|
+
if (options.type === 'eip712') {
|
|
103
|
+
const progress = ora("Sending input...").start();
|
|
104
|
+
const hash = await sendEip712(walletClient, applicationAddress, payload, {
|
|
105
|
+
eip712TxUrl: options.eip712TxUrl,
|
|
106
|
+
});
|
|
107
|
+
progress.succeed(`Input sent: ${hash}`);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
91
110
|
const { request } = await publicClient.simulateContract({
|
|
92
111
|
address: inputBoxAddress,
|
|
93
112
|
abi: inputBoxAbi,
|
|
@@ -95,25 +114,9 @@ class SendGeneric extends SendBaseCommand {
|
|
|
95
114
|
args: [applicationAddress, payload],
|
|
96
115
|
account: walletClient.account,
|
|
97
116
|
});
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
}),
|
|
117
|
+
const hash = await walletClient.writeContract(request);
|
|
118
|
+
const progress = ora("Sending input...").start();
|
|
119
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
120
|
+
progress.succeed(`Input sent: ${hash}`);
|
|
121
|
+
});
|
|
118
122
|
};
|
|
119
|
-
export default SendGeneric;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import { type Address, type PublicClient, type WalletClient } from "viem";
|
|
3
|
+
export declare const connect: (options: {
|
|
4
|
+
chainId?: number;
|
|
5
|
+
rpcUrl?: string;
|
|
6
|
+
mnemonic?: string;
|
|
7
|
+
mnemonicIndex: number;
|
|
8
|
+
}) => Promise<{
|
|
9
|
+
publicClient: PublicClient;
|
|
10
|
+
walletClient: WalletClient;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const getInputApplicationAddress: (dapp?: string) => Promise<Address>;
|
|
13
|
+
export declare const createSendCommand: () => Command<[], {
|
|
14
|
+
chainId: number;
|
|
15
|
+
rpcUrl?: string | undefined;
|
|
16
|
+
mnemonic?: string | undefined;
|
|
17
|
+
mnemonicIndex: number;
|
|
18
|
+
dapp?: `0x${string}` | undefined;
|
|
19
|
+
}, {}>;
|
|
20
|
+
export type SendCommandOpts = ReturnType<ReturnType<typeof createSendCommand>["opts"]>;
|
|
21
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../src/commands/send.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGtD,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,YAAY,EACjB,KAAK,YAAY,EAEpB,MAAM,MAAM,CAAC;AASd,eAAO,MAAM,OAAO,GAAI,SAAS;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC;IACR,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,EAAE,YAAY,CAAC;CAC9B,CAYA,CAAC;AAEF,eAAO,MAAM,0BAA0B,GACnC,OAAO,MAAM,KACd,OAAO,CAAC,OAAO,CAiBjB,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;MA6C7B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,UAAU,CACpC,UAAU,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAC/C,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
import input from "@inquirer/input";
|
|
3
|
+
import select from "@inquirer/select";
|
|
4
|
+
import { isAddress, } from "viem";
|
|
5
|
+
import { parseAddress } from "../base.js";
|
|
6
|
+
import { getApplicationAddress } from "../exec/rollups.js";
|
|
7
|
+
import createClients, { supportedChains } from "../wallet.js";
|
|
8
|
+
import { createErc20Command } from "./send/erc20.js";
|
|
9
|
+
import { createErc721Command } from "./send/erc721.js";
|
|
10
|
+
import { createEtherCommand } from "./send/ether.js";
|
|
11
|
+
import { createGenericCommand } from "./send/generic.js";
|
|
12
|
+
export const connect = (options) => {
|
|
13
|
+
const { chainId, rpcUrl, mnemonic, mnemonicIndex } = options;
|
|
14
|
+
// create viem clients
|
|
15
|
+
return createClients({
|
|
16
|
+
chain: supportedChains({ includeDevnet: true }).find((c) => c.id === chainId),
|
|
17
|
+
rpcUrl,
|
|
18
|
+
mnemonicPassphrase: mnemonic,
|
|
19
|
+
mnemonicIndex,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export const getInputApplicationAddress = async (dapp) => {
|
|
23
|
+
if (dapp && isAddress(dapp)) {
|
|
24
|
+
// honor the flag
|
|
25
|
+
return dapp;
|
|
26
|
+
}
|
|
27
|
+
// get the running container dapp address
|
|
28
|
+
const nodeAddress = await getApplicationAddress();
|
|
29
|
+
// query for the address
|
|
30
|
+
const applicationAddress = await input({
|
|
31
|
+
message: "Application address",
|
|
32
|
+
validate: (value) => isAddress(value) || "Invalid address",
|
|
33
|
+
default: nodeAddress,
|
|
34
|
+
});
|
|
35
|
+
return applicationAddress;
|
|
36
|
+
};
|
|
37
|
+
export const createSendCommand = () => {
|
|
38
|
+
const command = new Command("send")
|
|
39
|
+
.description("Sends different kinds of input to the application in interactive mode.")
|
|
40
|
+
.option("--chain-id <id>", "Chain ID", Number.parseInt, 13370)
|
|
41
|
+
.option("--rpc-url <url>", "RPC URL")
|
|
42
|
+
.option("--mnemonic <phrase>", "Mnemonic passphrase")
|
|
43
|
+
.option("--mnemonic-index <index>", "Mnemonic account index", Number.parseInt, 0)
|
|
44
|
+
.option("--dapp <address>", "Application address", parseAddress, undefined)
|
|
45
|
+
.action(async (options, program) => {
|
|
46
|
+
// Get the registered subcommands from the program
|
|
47
|
+
const commands = program.commands;
|
|
48
|
+
// Create choices for the select prompt based on registered commands
|
|
49
|
+
const choices = commands.map((cmd) => ({
|
|
50
|
+
name: cmd.name(),
|
|
51
|
+
value: cmd,
|
|
52
|
+
description: cmd.description(),
|
|
53
|
+
}));
|
|
54
|
+
// Present the list of subcommands using @inquirer/select
|
|
55
|
+
const subcommand = await select({
|
|
56
|
+
message: "Select the type of input to send",
|
|
57
|
+
choices,
|
|
58
|
+
});
|
|
59
|
+
// Execute the selected subcommand
|
|
60
|
+
subcommand.parseAsync(program.args);
|
|
61
|
+
});
|
|
62
|
+
command.addCommand(createGenericCommand());
|
|
63
|
+
command.addCommand(createErc20Command());
|
|
64
|
+
command.addCommand(createErc721Command());
|
|
65
|
+
command.addCommand(createEtherCommand());
|
|
66
|
+
return command;
|
|
67
|
+
};
|
package/dist/commands/shell.d.ts
CHANGED
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
}
|
|
1
|
+
import { Command } from "@commander-js/extra-typings";
|
|
2
|
+
export declare const createShellCommand: () => Command<[string | undefined], {
|
|
3
|
+
command: string;
|
|
4
|
+
config: string;
|
|
5
|
+
runAsRoot: boolean;
|
|
6
|
+
}, {}>;
|
|
15
7
|
//# sourceMappingURL=shell.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/commands/shell.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/commands/shell.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAOtD,eAAO,MAAM,kBAAkB;;;;MAiD9B,CAAC"}
|