@cartesi/cli 2.0.0-alpha.5 → 2.0.0-alpha.7

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.
Files changed (123) hide show
  1. package/dist/base.d.ts +10 -6
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +41 -15
  4. package/dist/builder/directory.d.ts.map +1 -1
  5. package/dist/builder/docker.d.ts.map +1 -1
  6. package/dist/builder/empty.d.ts.map +1 -1
  7. package/dist/builder/none.d.ts.map +1 -1
  8. package/dist/builder/tar.d.ts.map +1 -1
  9. package/dist/commands/address-book.d.ts +3 -1
  10. package/dist/commands/address-book.d.ts.map +1 -1
  11. package/dist/commands/address-book.js +3 -3
  12. package/dist/commands/build.d.ts +4 -1
  13. package/dist/commands/build.d.ts.map +1 -1
  14. package/dist/commands/build.js +3 -3
  15. package/dist/commands/clean.d.ts +1 -1
  16. package/dist/commands/clean.d.ts.map +1 -1
  17. package/dist/commands/clean.js +3 -3
  18. package/dist/commands/create.d.ts +4 -1
  19. package/dist/commands/create.d.ts.map +1 -1
  20. package/dist/commands/create.js +3 -4
  21. package/dist/commands/deploy/build.d.ts +1 -1
  22. package/dist/commands/deploy/build.d.ts.map +1 -1
  23. package/dist/commands/deploy/build.js +7 -54
  24. package/dist/commands/deploy.d.ts +1 -1
  25. package/dist/commands/deploy.d.ts.map +1 -1
  26. package/dist/commands/deploy.js +9 -73
  27. package/dist/commands/doctor.d.ts +1 -1
  28. package/dist/commands/doctor.d.ts.map +1 -1
  29. package/dist/commands/doctor.js +23 -11
  30. package/dist/commands/hash.d.ts +3 -1
  31. package/dist/commands/hash.d.ts.map +1 -1
  32. package/dist/commands/hash.js +3 -3
  33. package/dist/commands/rollups/deploy.d.ts +16 -0
  34. package/dist/commands/rollups/deploy.d.ts.map +1 -0
  35. package/dist/commands/rollups/deploy.js +225 -0
  36. package/dist/commands/rollups/logs.d.ts +11 -0
  37. package/dist/commands/rollups/logs.d.ts.map +1 -0
  38. package/dist/commands/rollups/logs.js +32 -0
  39. package/dist/commands/rollups/start.d.ts +14 -0
  40. package/dist/commands/rollups/start.d.ts.map +1 -0
  41. package/dist/commands/rollups/start.js +209 -0
  42. package/dist/commands/rollups/status.d.ts +7 -0
  43. package/dist/commands/rollups/status.d.ts.map +1 -0
  44. package/dist/commands/rollups/status.js +46 -0
  45. package/dist/commands/rollups/stop.d.ts +5 -0
  46. package/dist/commands/rollups/stop.d.ts.map +1 -0
  47. package/dist/commands/rollups/stop.js +26 -0
  48. package/dist/commands/rollups.d.ts +6 -0
  49. package/dist/commands/rollups.d.ts.map +1 -0
  50. package/dist/commands/rollups.js +19 -0
  51. package/dist/commands/run.d.ts +1 -1
  52. package/dist/commands/run.d.ts.map +1 -1
  53. package/dist/commands/run.js +7 -155
  54. package/dist/commands/send/erc20.d.ts +10 -1
  55. package/dist/commands/send/erc20.d.ts.map +1 -1
  56. package/dist/commands/send/erc20.js +10 -8
  57. package/dist/commands/send/erc721.d.ts +10 -1
  58. package/dist/commands/send/erc721.d.ts.map +1 -1
  59. package/dist/commands/send/erc721.js +10 -8
  60. package/dist/commands/send/ether.d.ts +10 -1
  61. package/dist/commands/send/ether.d.ts.map +1 -1
  62. package/dist/commands/send/ether.js +10 -8
  63. package/dist/commands/send/generic.d.ts +11 -1
  64. package/dist/commands/send/generic.d.ts.map +1 -1
  65. package/dist/commands/send/generic.js +10 -9
  66. package/dist/commands/send.d.ts +4 -4
  67. package/dist/commands/send.d.ts.map +1 -1
  68. package/dist/commands/send.js +19 -19
  69. package/dist/commands/shell.d.ts +5 -1
  70. package/dist/commands/shell.d.ts.map +1 -1
  71. package/dist/commands/shell.js +3 -3
  72. package/dist/compose/rollups/default.env +35 -0
  73. package/dist/compose/rollups/docker-compose-anvil.yaml +15 -0
  74. package/dist/{node → compose/rollups}/docker-compose-bundler.yaml +12 -26
  75. package/dist/{node → compose/rollups}/docker-compose-database.yaml +4 -2
  76. package/dist/compose/rollups/docker-compose-espresso.yaml +94 -0
  77. package/dist/{node → compose/rollups}/docker-compose-explorer.yaml +18 -37
  78. package/dist/compose/rollups/docker-compose-graphql.yaml +49 -0
  79. package/dist/compose/rollups/docker-compose-node-cpus.yaml +7 -0
  80. package/dist/compose/rollups/docker-compose-node-memory.yaml +6 -0
  81. package/dist/compose/rollups/docker-compose-node.yaml +36 -0
  82. package/dist/compose/rollups/docker-compose-paymaster.yaml +18 -0
  83. package/dist/compose/rollups/docker-compose-proxy.yaml +24 -0
  84. package/dist/compose/rollups/proxy/bundler.yaml +17 -0
  85. package/dist/compose/rollups/proxy/espresso.yaml +17 -0
  86. package/dist/compose/rollups/proxy/explorer-api.yaml +17 -0
  87. package/dist/compose/rollups/proxy/explorer.yaml +10 -0
  88. package/dist/compose/rollups/proxy/graphql.yaml +10 -0
  89. package/dist/compose/rollups/proxy/paymaster.yaml +17 -0
  90. package/dist/compose/rollups/proxy/rollups-node.yaml +17 -0
  91. package/dist/config.d.ts +1 -1
  92. package/dist/config.d.ts.map +1 -1
  93. package/dist/config.js +1 -1
  94. package/dist/contracts.d.ts.map +1 -1
  95. package/dist/exec/cartesi-machine.d.ts.map +1 -1
  96. package/dist/exec/crane.d.ts +1 -1
  97. package/dist/exec/crane.d.ts.map +1 -1
  98. package/dist/exec/genext2fs.d.ts.map +1 -1
  99. package/dist/exec/mksquashfs.d.ts.map +1 -1
  100. package/dist/exec/rollups.d.ts +17 -0
  101. package/dist/exec/rollups.d.ts.map +1 -0
  102. package/dist/exec/rollups.js +40 -0
  103. package/dist/exec/util.d.ts +1 -1
  104. package/dist/exec/util.d.ts.map +1 -1
  105. package/dist/index.js +23 -21
  106. package/dist/machine.d.ts.map +1 -1
  107. package/dist/prompts.d.ts.map +1 -1
  108. package/dist/wallet.d.ts.map +1 -1
  109. package/dist/wallet.js +29 -6
  110. package/package.json +24 -22
  111. package/dist/node/DockerfileDeploy.txt +0 -4
  112. package/dist/node/default.env +0 -27
  113. package/dist/node/docker-compose-anvil.yaml +0 -50
  114. package/dist/node/docker-compose-envfile.yaml +0 -4
  115. package/dist/node/docker-compose-espresso.yaml +0 -127
  116. package/dist/node/docker-compose-host.yaml +0 -30
  117. package/dist/node/docker-compose-paymaster.yaml +0 -33
  118. package/dist/node/docker-compose-prompt.yaml +0 -17
  119. package/dist/node/docker-compose-proxy.yaml +0 -48
  120. package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
  121. package/dist/node/docker-compose-validator-cpus.yaml +0 -6
  122. package/dist/node/docker-compose-validator-memory.yaml +0 -6
  123. package/dist/node/docker-compose-validator.yaml +0 -59
@@ -1,158 +1,10 @@
1
- import { Option } from "@commander-js/extra-typings";
2
- import { execa } from "execa";
3
- import fs from "fs-extra";
4
- import path from "path";
5
- import { getMachineHash } from "../base.js";
6
- export const registerRunCommand = (program) => {
7
- program
8
- .command("run")
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import chalk from "chalk";
3
+ export const createRunCommand = () => {
4
+ return new Command("run")
9
5
  .description("Run a local cartesi node for the application.")
10
- .addOption(new Option("--block-time <number>", "interval between blocks (in seconds)")
11
- .argParser(Number)
12
- .default(5))
13
- .addOption(new Option("--epoch-length <number>", "length of an epoch (in blocks)")
14
- .argParser(Number)
15
- .default(720))
16
- .option("--disable-explorer", "disable local explorer service to save machine resources", false)
17
- .option("--disable-bundler", "disable local bundler service to save machine resources", false)
18
- .option("--disable-paymaster", "disable local paymaster service to save machine resources", false)
19
- .option("--enable-espresso", "enable espresso development node", false)
20
- .option("--no-backend", "run a node without the application code", false)
21
- .option("-v, --verbose", "verbose output", false)
22
- .addOption(new Option("--port <number>", "port to listen for incoming connections")
23
- .argParser(Number)
24
- .default(8080))
25
- .addOption(new Option("--cpus <number>", "number of cpu limits for the rollups-node").argParser(Number))
26
- .addOption(new Option("--memory <number>", "memory limit for the rollups-node in MB").argParser(Number))
27
- .option("--dry-run", "show the docker compose configuration", false)
28
- .action(async ({ blockTime, epochLength, disableExplorer, disableBundler, disablePaymaster, enableEspresso, backend, verbose, port, dryRun, cpus, memory, }) => {
29
- let projectName;
30
- if (backend) {
31
- projectName = "cartesi-node";
32
- }
33
- else {
34
- // get machine hash
35
- const hash = getMachineHash();
36
- // Check if snapshot exists
37
- if (!hash) {
38
- throw new Error(`Cartesi machine snapshot not found, run 'build'`);
39
- }
40
- projectName = hash.substring(2, 10);
41
- }
42
- // path of the tool instalation
43
- const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..");
44
- // setup the environment variable used in docker compose
45
- const blockInterval = blockTime;
46
- const listenPort = port;
47
- const env = {
48
- ANVIL_VERBOSITY: verbose ? "--steps-tracing" : "--silent",
49
- BLOCK_TIME: blockInterval.toString(),
50
- BLOCK_TIMEOUT: (blockInterval + 3).toString(),
51
- CARTESI_EPOCH_LENGTH: epochLength.toString(),
52
- CARTESI_EXPERIMENTAL_DISABLE_CONFIG_LOG: verbose
53
- ? "false"
54
- : "true",
55
- CARTESI_EXPERIMENTAL_SERVER_MANAGER_BYPASS_LOG: verbose
56
- ? "false"
57
- : "true",
58
- CARTESI_LOG_LEVEL: verbose ? "info" : "error",
59
- CARTESI_SNAPSHOT_DIR: "/usr/share/rollups-node/snapshot",
60
- CARTESI_BIN_PATH: binPath,
61
- CARTESI_LISTEN_PORT: listenPort.toString(),
62
- CARTESI_VALIDATOR_CPUS: cpus?.toString(),
63
- CARTESI_VALIDATOR_MEMORY: memory?.toString(),
64
- };
65
- // validator
66
- const composeFiles = ["docker-compose-validator.yaml"];
67
- if (cpus) {
68
- composeFiles.push("docker-compose-validator-cpus.yaml");
69
- }
70
- if (memory) {
71
- composeFiles.push("docker-compose-validator-memory.yaml");
72
- }
73
- // prompt
74
- composeFiles.push("docker-compose-prompt.yaml");
75
- // database
76
- composeFiles.push("docker-compose-database.yaml");
77
- // proxy
78
- composeFiles.push("docker-compose-proxy.yaml");
79
- // anvil
80
- composeFiles.push("docker-compose-anvil.yaml");
81
- // explorer
82
- if (!disableExplorer) {
83
- composeFiles.push("docker-compose-explorer.yaml");
84
- }
85
- // account abstraction
86
- if (!disableBundler) {
87
- composeFiles.push("docker-compose-bundler.yaml");
88
- }
89
- if (!disablePaymaster && !disableBundler) {
90
- // only add paymaster if bundler is enabled
91
- composeFiles.push("docker-compose-paymaster.yaml");
92
- }
93
- // espresso development node
94
- if (enableEspresso) {
95
- composeFiles.push("docker-compose-espresso.yaml");
96
- }
97
- // load the no-backend compose file
98
- if (backend) {
99
- composeFiles.push("docker-compose-host.yaml");
100
- }
101
- else {
102
- // snapshot volume
103
- composeFiles.push("docker-compose-snapshot-volume.yaml");
104
- }
105
- // add project env file loading
106
- if (fs.existsSync("./.cartesi.env")) {
107
- composeFiles.push("docker-compose-envfile.yaml");
108
- }
109
- // create the "--file <file>" list
110
- const files = composeFiles
111
- .map((f) => ["--file", path.join(binPath, "node", f)])
112
- .flat();
113
- const compose_args = [
114
- "compose",
115
- ...files,
116
- "--project-directory",
117
- ".",
118
- "--project-name",
119
- projectName,
120
- ];
121
- const up_args = [];
122
- if (!verbose) {
123
- compose_args.push("--progress", "quiet");
124
- up_args.push("--attach", "validator");
125
- up_args.push("--attach", "prompt");
126
- }
127
- // XXX: need this handler, so SIGINT can still call the finally block below
128
- process.on("SIGINT", () => { });
129
- try {
130
- if (dryRun) {
131
- // show the docker compose configuration
132
- await execa("docker", [...compose_args, "config"], {
133
- env,
134
- stdio: "inherit",
135
- });
136
- return;
137
- }
138
- // run compose environment
139
- await execa("docker", [...compose_args, "up", ...up_args], {
140
- env,
141
- stdio: "inherit",
142
- });
143
- }
144
- catch (e) {
145
- // 130 is a graceful shutdown, so we can swallow it
146
- if (e.exitCode !== 130) {
147
- throw e;
148
- }
149
- }
150
- finally {
151
- // shut it down, including volumes
152
- await execa("docker", [...compose_args, "down", "--volumes"], {
153
- env,
154
- stdio: "inherit",
155
- });
156
- }
6
+ .summary("DEPRECATED: use 'rollups start' instead")
7
+ .action(async () => {
8
+ console.warn(chalk.yellow("run command is deprecated, use 'rollups start' and 'rollups deploy' instead"));
157
9
  });
158
10
  };
@@ -1,3 +1,12 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
- export declare const registerErc20Command: (program: Command) => void;
2
+ export declare const createErc20Command: () => Command<[], {
3
+ token?: string | undefined;
4
+ amount?: string | undefined;
5
+ }, {
6
+ chainId: number;
7
+ rpcUrl?: string | undefined;
8
+ mnemonic?: string | undefined;
9
+ mnemonicIndex: number;
10
+ dapp?: `0x${string}` | undefined;
11
+ }>;
3
12
  //# sourceMappingURL=erc20.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc20.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AA8DtD,eAAO,MAAM,oBAAoB,YAAa,OAAO,SA8CpD,CAAC"}
1
+ {"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc20.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AA8DtD,eAAO,MAAM,kBAAkB;;;;;;;;;EAgD9B,CAAC"}
@@ -1,8 +1,9 @@
1
+ import { Command } from "@commander-js/extra-typings";
1
2
  import input from "@inquirer/input";
2
3
  import ora from "ora";
3
4
  import { erc20Abi, getAddress, isAddress, parseEther, } from "viem";
4
5
  import { erc20PortalAbi, erc20PortalAddress } from "../../contracts.js";
5
- import { addCommonOptions, connect, getInputApplicationAddress, } from "../send.js";
6
+ import { connect, getInputApplicationAddress, } from "../send.js";
6
7
  const readToken = async (publicClient, address) => {
7
8
  const args = { abi: erc20Abi, address };
8
9
  const symbol = await publicClient.readContract({
@@ -35,17 +36,18 @@ const ercValidator = (publicClient) => async (value) => {
35
36
  }
36
37
  return true;
37
38
  };
38
- export const registerErc20Command = (program) => {
39
- addCommonOptions(program
40
- .command("erc20")
41
- .description("Sends ERC-20 deposits to the application, optionally in interactive mode."))
39
+ export const createErc20Command = () => {
40
+ return new Command("erc20")
41
+ .description("Sends ERC-20 deposits to the application, optionally in interactive mode.")
42
+ .configureHelp({ showGlobalOptions: true })
42
43
  .option("--token <address>", "token address")
43
44
  .option("--amount <number>", "amount to send")
44
- .action(async (options) => {
45
+ .action(async (options, command) => {
46
+ const sendOptions = command.optsWithGlobals();
45
47
  // connect to RPC provider
46
- const { publicClient, walletClient } = await connect(options);
48
+ const { publicClient, walletClient } = await connect(sendOptions);
47
49
  // get dapp address from local node, or ask
48
- const applicationAddress = await getInputApplicationAddress();
50
+ const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
49
51
  const tokenAddress = options.token && isAddress(options.token)
50
52
  ? getAddress(options.token)
51
53
  : (await input({
@@ -1,3 +1,12 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
- export declare const registerErc721Command: (program: Command) => void;
2
+ export declare const createErc721Command: () => Command<[], {
3
+ token?: string | undefined;
4
+ tokenId?: string | undefined;
5
+ }, {
6
+ chainId: number;
7
+ rpcUrl?: string | undefined;
8
+ mnemonic?: string | undefined;
9
+ mnemonicIndex: number;
10
+ dapp?: `0x${string}` | undefined;
11
+ }>;
3
12
  //# sourceMappingURL=erc721.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"erc721.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc721.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAiDtD,eAAO,MAAM,qBAAqB,YAAa,OAAO,SAqDrD,CAAC"}
1
+ {"version":3,"file":"erc721.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc721.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAiDtD,eAAO,MAAM,mBAAmB;;;;;;;;;EAuD/B,CAAC"}
@@ -1,8 +1,9 @@
1
+ import { Command } from "@commander-js/extra-typings";
1
2
  import input from "@inquirer/input";
2
3
  import ora from "ora";
3
4
  import { erc721Abi, getAddress, isAddress } from "viem";
4
5
  import { erc721PortalAbi, erc721PortalAddress } from "../../contracts.js";
5
- import { addCommonOptions, connect, getInputApplicationAddress, } from "../send.js";
6
+ import { connect, getInputApplicationAddress, } from "../send.js";
6
7
  const readToken = async (publicClient, address) => {
7
8
  const args = { abi: erc721Abi, address };
8
9
  const symbol = await publicClient.readContract({
@@ -30,17 +31,18 @@ const ercValidator = (publicClient) => async (value) => {
30
31
  }
31
32
  return true;
32
33
  };
33
- export const registerErc721Command = (program) => {
34
- addCommonOptions(program
35
- .command("erc721")
36
- .description("Sends ERC-721 deposits to the application, optionally in interactive mode."))
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 })
37
38
  .option("--token <address>", "token address")
38
39
  .option("--token-id <number>", "token ID")
39
- .action(async (options) => {
40
+ .action(async (options, command) => {
41
+ const sendOptions = command.optsWithGlobals();
40
42
  // connect to RPC provider
41
- const { publicClient, walletClient } = await connect(options);
43
+ const { publicClient, walletClient } = await connect(sendOptions);
42
44
  // get dapp address from local node, or ask
43
- const applicationAddress = await getInputApplicationAddress();
45
+ const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
44
46
  const token = options.token && isAddress(options.token)
45
47
  ? getAddress(options.token)
46
48
  : (await input({
@@ -1,3 +1,12 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
- export declare const registerEtherCommand: (program: Command) => void;
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
+ }>;
3
12
  //# sourceMappingURL=ether.d.ts.map
@@ -1 +1 @@
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,oBAAoB,YAAa,OAAO,SAqCpD,CAAC"}
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,19 +1,21 @@
1
+ import { Command } from "@commander-js/extra-typings";
1
2
  import input from "@inquirer/input";
2
3
  import ora from "ora";
3
4
  import { isHex, parseEther } from "viem";
4
5
  import { etherPortalAbi, etherPortalAddress } from "../../contracts.js";
5
- import { addCommonOptions, connect, getInputApplicationAddress, } from "../send.js";
6
- export const registerEtherCommand = (program) => {
7
- addCommonOptions(program
8
- .command("ether")
9
- .description("Sends ether deposits to the application, optionally in interactive mode."))
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 })
10
11
  .option("--amount <number>", "amount, in ETH units")
11
12
  .option("--exec-layer-data <hex>", "exec layer data", "0x")
12
- .action(async (options) => {
13
+ .action(async (options, command) => {
14
+ const sendOptions = command.optsWithGlobals();
13
15
  // connect to RPC provider
14
- const { publicClient, walletClient } = await connect(options);
16
+ const { publicClient, walletClient } = await connect(sendOptions);
15
17
  // get dapp address from local node, or ask
16
- const applicationAddress = await getInputApplicationAddress();
18
+ const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
17
19
  const amount = options.amount || (await input({ message: "Amount" }));
18
20
  const { request } = await publicClient.simulateContract({
19
21
  address: etherPortalAddress,
@@ -1,3 +1,13 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
- export declare const registerGenericCommand: (program: Command) => void;
2
+ export declare const createGenericCommand: () => Command<[], {
3
+ input?: string | undefined;
4
+ inputEncoding?: "string" | "hex" | "abi" | undefined;
5
+ inputAbiParams?: string | undefined;
6
+ }, {
7
+ chainId: number;
8
+ rpcUrl?: string | undefined;
9
+ mnemonic?: string | undefined;
10
+ mnemonicIndex: number;
11
+ dapp?: `0x${string}` | undefined;
12
+ }>;
3
13
  //# sourceMappingURL=generic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/commands/send/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAoG9D,eAAO,MAAM,sBAAsB,YAAa,OAAO,SAuCtD,CAAC"}
1
+ {"version":3,"file":"generic.d.ts","sourceRoot":"","sources":["../../../src/commands/send/generic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAoG9D,eAAO,MAAM,oBAAoB;;;;;;;;;;EAyChC,CAAC"}
@@ -1,9 +1,9 @@
1
- import { Option } from "@commander-js/extra-typings";
1
+ import { Command, Option } from "@commander-js/extra-typings";
2
2
  import ora from "ora";
3
3
  import { encodeAbiParameters, getAddress, isAddress, isHex, parseAbiParameters, stringToHex, } from "viem";
4
4
  import { inputBoxAbi, inputBoxAddress } from "../../contracts.js";
5
5
  import { bytesInput } from "../../prompts.js";
6
- import { addCommonOptions, connect, getInputApplicationAddress, } from "../send.js";
6
+ import { connect, getInputApplicationAddress, } from "../send.js";
7
7
  const getInput = async (options) => {
8
8
  const input = options.input;
9
9
  const encoding = options.inputEncoding;
@@ -84,18 +84,19 @@ const getInput = async (options) => {
84
84
  }
85
85
  return undefined;
86
86
  };
87
- export const registerGenericCommand = (program) => {
88
- addCommonOptions(program
89
- .command("generic")
90
- .description("Sends generics inputs to the application, optionally in interactive mode."))
87
+ export const createGenericCommand = () => {
88
+ return new Command("generic")
89
+ .description("Sends generics inputs to the application, optionally in interactive mode.")
90
+ .configureHelp({ showGlobalOptions: true })
91
91
  .option("--input <input>", "input payload")
92
92
  .addOption(new Option("--input-encoding <input-encoding>", "input encoding").choices(["hex", "string", "abi"]))
93
93
  .option("--input-abi-params <input-abi-params>", "input abi params")
94
- .action(async (options) => {
94
+ .action(async (options, command) => {
95
+ const sendOptions = command.optsWithGlobals();
95
96
  // connect to RPC provider
96
- const { publicClient, walletClient } = await connect(options);
97
+ const { publicClient, walletClient } = await connect(sendOptions);
97
98
  // get dapp address from local node, or ask
98
- const applicationAddress = await getInputApplicationAddress();
99
+ const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
99
100
  const payload = (await getInput(options)) ||
100
101
  (await bytesInput({ message: "Input" }));
101
102
  const { request } = await publicClient.simulateContract({
@@ -10,12 +10,12 @@ export declare const connect: (options: {
10
10
  walletClient: WalletClient;
11
11
  }>;
12
12
  export declare const getInputApplicationAddress: (dapp?: string) => Promise<Address>;
13
- export declare const addCommonOptions: (command: Command) => Command<[], {
14
- dapp?: string | undefined;
15
- chainId?: number | undefined;
13
+ export declare const createSendCommand: () => Command<[], {
14
+ chainId: number;
16
15
  rpcUrl?: string | undefined;
17
16
  mnemonic?: string | undefined;
18
17
  mnemonicIndex: number;
18
+ dapp?: `0x${string}` | undefined;
19
19
  }, {}>;
20
- export declare const registerSendCommand: (program: Command) => void;
20
+ export type SendCommandOpts = ReturnType<ReturnType<typeof createSendCommand>["opts"]>;
21
21
  //# sourceMappingURL=send.d.ts.map
@@ -1 +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,EAAE,OAAO,EAAa,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAQtE,eAAO,MAAM,OAAO,YAAa;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,UAC5B,MAAM,KACd,OAAO,CAAC,OAAO,CAiBjB,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAAa,OAAO;;;;;;MAYhD,CAAC;AAEF,eAAO,MAAM,mBAAmB,YAAa,OAAO,SA+BnD,CAAC"}
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,EAAE,OAAO,EAAa,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAStE,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"}
@@ -1,12 +1,14 @@
1
+ import { Command } from "@commander-js/extra-typings";
1
2
  import input from "@inquirer/input";
2
3
  import select from "@inquirer/select";
3
4
  import { isAddress } from "viem";
4
- import { getApplicationAddress } from "../base.js";
5
+ import { parseAddress } from "../base.js";
6
+ import { getApplicationAddress } from "../exec/rollups.js";
5
7
  import createClients, { supportedChains } from "../wallet.js";
6
- import { registerErc20Command } from "./send/erc20.js";
7
- import { registerErc721Command } from "./send/erc721.js";
8
- import { registerEtherCommand } from "./send/ether.js";
9
- import { registerGenericCommand } from "./send/generic.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";
10
12
  export const connect = (options) => {
11
13
  const { chainId, rpcUrl, mnemonic, mnemonicIndex } = options;
12
14
  // create viem clients
@@ -32,18 +34,15 @@ export const getInputApplicationAddress = async (dapp) => {
32
34
  });
33
35
  return applicationAddress;
34
36
  };
35
- export const addCommonOptions = (command) => {
36
- return command
37
- .option("--dapp <address>", "Application address")
38
- .option("--chain-id <id>", "Chain ID", parseInt)
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", parseInt, 31337)
39
41
  .option("--rpc-url <url>", "RPC URL")
40
42
  .option("--mnemonic <phrase>", "Mnemonic passphrase")
41
- .option("--mnemonic-index <index>", "Mnemonic account index", parseInt, 0);
42
- };
43
- export const registerSendCommand = (program) => {
44
- const sendCommand = addCommonOptions(program
45
- .command("send")
46
- .description("Sends different kinds of input to the application in interactive mode.")).action(async (options, program) => {
43
+ .option("--mnemonic-index <index>", "Mnemonic account index", parseInt, 0)
44
+ .option("--dapp <address>", "Application address", parseAddress, undefined)
45
+ .action(async (options, program) => {
47
46
  // Get the registered subcommands from the program
48
47
  const commands = program.commands;
49
48
  // Create choices for the select prompt based on registered commands
@@ -60,8 +59,9 @@ export const registerSendCommand = (program) => {
60
59
  // Execute the selected subcommand
61
60
  subcommand.parseAsync(program.args);
62
61
  });
63
- registerErc20Command(sendCommand);
64
- registerErc721Command(sendCommand);
65
- registerEtherCommand(sendCommand);
66
- registerGenericCommand(sendCommand);
62
+ command.addCommand(createGenericCommand());
63
+ command.addCommand(createErc20Command());
64
+ command.addCommand(createErc721Command());
65
+ command.addCommand(createEtherCommand());
66
+ return command;
67
67
  };
@@ -1,3 +1,7 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
- export declare const registerShellCommand: (program: Command) => void;
2
+ export declare const createShellCommand: () => Command<[string | undefined], {
3
+ command: string;
4
+ config: string;
5
+ runAsRoot: boolean;
6
+ }, {}>;
3
7
  //# sourceMappingURL=shell.d.ts.map
@@ -1 +1 @@
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,oBAAoB,YAAa,OAAO,SAkDpD,CAAC"}
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"}
@@ -1,10 +1,10 @@
1
+ import { Command } from "@commander-js/extra-typings";
1
2
  import fs from "fs-extra";
2
3
  import path from "path";
3
4
  import { getApplicationConfig, getContextPath } from "../base.js";
4
5
  import { bootMachine } from "../machine.js";
5
- export const registerShellCommand = (program) => {
6
- program
7
- .command("shell")
6
+ export const createShellCommand = () => {
7
+ return new Command("shell")
8
8
  .argument("[image]", "image ID|name")
9
9
  .option("--command <command>", "shell command to run", "/bin/sh")
10
10
  .option("-c, --config <config>", "path to the configuration file", "cartesi.toml")
@@ -0,0 +1,35 @@
1
+ # cartesi/rollups-node
2
+
3
+ #logs
4
+ CARTESI_LOG_LEVEL="${CARTESI_LOG_LEVEL:-info}"
5
+
6
+ # features
7
+ CARTESI_FEATURE_INPUT_READER_ENABLED="${CARTESI_FEATURE_INPUT_READER_ENABLED:-true}"
8
+ CARTESI_FEATURE_CLAIM_SUBMISSION_ENABLED="${CARTESI_FEATURE_CLAIM_SUBMISSION_ENABLED:-true}"
9
+ CARTESI_FEATURE_MACHINE_HASH_CHECK_ENABLED="${CARTESI_FEATURE_MACHINE_HASH_CHECK_ENABLED:-false}"
10
+
11
+ # rollups
12
+ CARTESI_EVM_READER_RETRY_POLICY_MAX_RETRIES="${CARTESI_EVM_READER_RETRY_POLICY_MAX_RETRIES:-3}"
13
+ CARTESI_EVM_READER_RETRY_POLICY_MAX_DELAY="${CARTESI_EVM_READER_RETRY_POLICY_MAX_DELAY:-3}"
14
+ CARTESI_ADVANCER_POLLING_INTERVAL="${CARTESI_ADVANCER_POLLING_INTERVAL:-3}"
15
+ CARTESI_VALIDATOR_POLLING_INTERVAL="${CARTESI_VALIDATOR_POLLING_INTERVAL:-3}"
16
+ CARTESI_CLAIMER_POLLING_INTERVAL="${CARTESI_CLAIMER_POLLING_INTERVAL:-3}"
17
+ CARTESI_MAX_STARTUP_TIME="${CARTESI_MAX_STARTUP_TIME:-15}"
18
+
19
+ # blockchain
20
+ CARTESI_BLOCKCHAIN_ID="${CARTESI_BLOCKCHAIN_ID:-31337}"
21
+ CARTESI_BLOCKCHAIN_HTTP_ENDPOINT="${CARTESI_BLOCKCHAIN_HTTP_ENDPOINT:-http://anvil:8545}"
22
+ CARTESI_BLOCKCHAIN_WS_ENDPOINT="${CARTESI_BLOCKCHAIN_WS_ENDPOINT:-ws://anvil:8545}"
23
+ CARTESI_BLOCKCHAIN_DEFAULT_BLOCK="${CARTESI_BLOCKCHAIN_DEFAULT_BLOCK:-finalized}"
24
+
25
+ # contracts
26
+ CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="${CARTESI_CONTRACTS_INPUT_BOX_ADDRESS:-0x593E5BCf894D6829Dd26D0810DA7F064406aebB6}"
27
+ CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER="${CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER:-1}"
28
+ CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS="${CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS:-0xd7d4d184b82b1a4e08f304DDaB0A2A7a301C2620}"
29
+ CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS="${CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS:-0xB897F7Fe78f220aE34B7FA9493092701a873Ed45}"
30
+
31
+ # auth
32
+ CARTESI_AUTH_MNEMONIC="${CARTESI_AUTH_MNEMONIC:-test test test test test test test test test test test junk}"
33
+
34
+ # postgres
35
+ CARTESI_DATABASE_CONNECTION="postgres://postgres:password@database:5432/postgres?sslmode=disable"
@@ -0,0 +1,15 @@
1
+ services:
2
+ anvil:
3
+ image: ${CARTESI_SDK_IMAGE}
4
+ command: ["devnet", "--block-time", "${BLOCK_TIME:-5}"]
5
+ healthcheck:
6
+ test: ["CMD", "eth_isready"]
7
+ start_period: 10s
8
+ start_interval: 200ms
9
+ interval: 10s
10
+ timeout: 1s
11
+ retries: 5
12
+ environment:
13
+ ANVIL_IP_ADDR: 0.0.0.0
14
+ ports:
15
+ - 8545:8545
@@ -1,6 +1,6 @@
1
1
  services:
2
- alto:
3
- image: cartesi/sdk:0.12.0-alpha.3
2
+ bundler:
3
+ image: ${CARTESI_SDK_IMAGE}
4
4
  command:
5
5
  - "alto"
6
6
  - "--entrypoints"
@@ -30,28 +30,14 @@ services:
30
30
  - "--polling-interval"
31
31
  - "100"
32
32
  - "--enable-debug-endpoints"
33
- prompt:
34
- image: debian:bookworm-slim
35
- environment:
36
- PROMPT_TXT_06_BUNDLER: "Bundler running at http://localhost:${CARTESI_LISTEN_PORT}/bundler/rpc"
33
+ healthcheck:
34
+ test: ["CMD", "curl", "-fsS", "http://127.0.0.1:4337/health"]
35
+ start_period: 10s
36
+ start_interval: 200ms
37
+ interval: 10s
38
+ timeout: 1s
39
+ retries: 5
37
40
 
38
- traefik-config-generator:
39
- environment:
40
- TRAEFIK_CONFIG_BUNDLER: |
41
- http:
42
- routers:
43
- bundler:
44
- rule: "PathPrefix(`/bundler`)"
45
- middlewares:
46
- - "remove-bundler-prefix"
47
- service: bundler
48
- middlewares:
49
- remove-bundler-prefix:
50
- replacePathRegex:
51
- regex: "^/bundler/(.*)"
52
- replacement: "/$1"
53
- services:
54
- bundler:
55
- loadBalancer:
56
- servers:
57
- - url: "http://alto:4337"
41
+ proxy:
42
+ volumes:
43
+ - ./proxy/bundler.yaml:/etc/traefik/conf.d/bundler.yaml
@@ -1,10 +1,12 @@
1
1
  services:
2
2
  database:
3
- image: postgres:16-alpine
3
+ image: postgres:16
4
4
  healthcheck:
5
5
  test: ["CMD-SHELL", "pg_isready -U postgres || exit 1"]
6
+ start_period: 10s
7
+ start_interval: 200ms
6
8
  interval: 10s
7
- timeout: 5s
9
+ timeout: 1s
8
10
  retries: 5
9
11
  environment:
10
12
  - POSTGRES_PASSWORD=password