@cartesi/cli 2.0.0-alpha.13 → 2.0.0-alpha.14

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 (76) hide show
  1. package/dist/base.d.ts +8 -3
  2. package/dist/base.d.ts.map +1 -1
  3. package/dist/base.js +7 -4
  4. package/dist/commands/address-book.d.ts +1 -0
  5. package/dist/commands/address-book.d.ts.map +1 -1
  6. package/dist/commands/address-book.js +6 -3
  7. package/dist/commands/create.d.ts +1 -1
  8. package/dist/commands/create.d.ts.map +1 -1
  9. package/dist/commands/create.js +1 -0
  10. package/dist/commands/deploy.d.ts +1 -16
  11. package/dist/commands/deploy.d.ts.map +1 -1
  12. package/dist/commands/deploy.js +8 -267
  13. package/dist/commands/deposit/erc20.d.ts +11 -0
  14. package/dist/commands/deposit/erc20.d.ts.map +1 -0
  15. package/dist/commands/deposit/erc20.js +126 -0
  16. package/dist/commands/deposit/erc721.d.ts +12 -0
  17. package/dist/commands/deposit/erc721.d.ts.map +1 -0
  18. package/dist/commands/deposit/erc721.js +144 -0
  19. package/dist/commands/deposit/ether.d.ts +10 -0
  20. package/dist/commands/deposit/ether.d.ts.map +1 -0
  21. package/dist/commands/deposit/ether.js +66 -0
  22. package/dist/commands/deposit.d.ts +9 -0
  23. package/dist/commands/deposit.d.ts.map +1 -0
  24. package/dist/commands/deposit.js +36 -0
  25. package/dist/commands/logs.d.ts +1 -1
  26. package/dist/commands/logs.d.ts.map +1 -1
  27. package/dist/commands/logs.js +6 -4
  28. package/dist/commands/run.d.ts +13 -1
  29. package/dist/commands/run.d.ts.map +1 -1
  30. package/dist/commands/run.js +196 -4
  31. package/dist/commands/send.d.ts +6 -17
  32. package/dist/commands/send.d.ts.map +1 -1
  33. package/dist/commands/send.js +122 -59
  34. package/dist/commands/status.d.ts +1 -1
  35. package/dist/commands/status.d.ts.map +1 -1
  36. package/dist/commands/status.js +10 -7
  37. package/dist/compose/default.env +1 -1
  38. package/dist/compose/docker-compose-anvil.yaml +1 -1
  39. package/dist/compose/docker-compose-node.yaml +1 -4
  40. package/dist/config.d.ts +2 -2
  41. package/dist/config.d.ts.map +1 -1
  42. package/dist/config.js +2 -2
  43. package/dist/exec/cartesi-machine.js +1 -1
  44. package/dist/exec/rollups.d.ts +94 -5
  45. package/dist/exec/rollups.d.ts.map +1 -1
  46. package/dist/exec/rollups.js +356 -12
  47. package/dist/index.js +5 -7
  48. package/dist/prompts.d.ts +12 -1
  49. package/dist/prompts.d.ts.map +1 -1
  50. package/dist/prompts.js +58 -23
  51. package/dist/wallet.d.ts +15948 -21
  52. package/dist/wallet.d.ts.map +1 -1
  53. package/dist/wallet.js +33 -221
  54. package/package.json +24 -23
  55. package/dist/commands/send/eip712.d.ts +0 -34
  56. package/dist/commands/send/eip712.d.ts.map +0 -1
  57. package/dist/commands/send/eip712.js +0 -81
  58. package/dist/commands/send/erc20.d.ts +0 -12
  59. package/dist/commands/send/erc20.d.ts.map +0 -1
  60. package/dist/commands/send/erc20.js +0 -75
  61. package/dist/commands/send/erc721.d.ts +0 -12
  62. package/dist/commands/send/erc721.d.ts.map +0 -1
  63. package/dist/commands/send/erc721.js +0 -78
  64. package/dist/commands/send/ether.d.ts +0 -12
  65. package/dist/commands/send/ether.d.ts.map +0 -1
  66. package/dist/commands/send/ether.js +0 -36
  67. package/dist/commands/send/generic.d.ts +0 -15
  68. package/dist/commands/send/generic.d.ts.map +0 -1
  69. package/dist/commands/send/generic.js +0 -122
  70. package/dist/commands/start.d.ts +0 -14
  71. package/dist/commands/start.d.ts.map +0 -1
  72. package/dist/commands/start.js +0 -220
  73. package/dist/commands/stop.d.ts +0 -5
  74. package/dist/commands/stop.d.ts.map +0 -1
  75. package/dist/commands/stop.js +0 -27
  76. package/dist/compose/docker-compose-espresso.yaml +0 -81
@@ -1,78 +0,0 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- import input from "@inquirer/input";
3
- import ora from "ora";
4
- import { erc721Abi, getAddress, isAddress, } from "viem";
5
- import { erc721PortalAbi, erc721PortalAddress } from "../../contracts.js";
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);
28
- }
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);
44
- // get dapp address from local node, or ask
45
- const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
46
- const token = options.token && isAddress(options.token)
47
- ? getAddress(options.token)
48
- : (await input({
49
- message: "Token address",
50
- validate: ercValidator(publicClient),
51
- }));
52
- const tokenId = options.tokenId ||
53
- (await input({
54
- message: "Token ID",
55
- validate: (value) => {
56
- try {
57
- BigInt(value);
58
- return true;
59
- }
60
- catch (e) {
61
- return "Invalid number";
62
- }
63
- },
64
- }));
65
- const { request } = await publicClient.simulateContract({
66
- address: erc721PortalAddress,
67
- abi: erc721PortalAbi,
68
- functionName: "depositERC721Token",
69
- args: [token, applicationAddress, BigInt(tokenId), "0x", "0x"],
70
- account: walletClient.account,
71
- });
72
- // XXX: add support for baseLayerData and execLayerData
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
- });
78
- };
@@ -1,12 +0,0 @@
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
- }>;
12
- //# sourceMappingURL=ether.d.ts.map
@@ -1 +0,0 @@
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,36 +0,0 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- import input from "@inquirer/input";
3
- import ora from "ora";
4
- import { isHex, parseEther } from "viem";
5
- import { etherPortalAbi, etherPortalAddress } from "../../contracts.js";
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);
17
- // get dapp address from local node, or ask
18
- const applicationAddress = await getInputApplicationAddress(sendOptions.dapp);
19
- const amount = options.amount || (await input({ message: "Amount" }));
20
- const { request } = await publicClient.simulateContract({
21
- address: etherPortalAddress,
22
- abi: etherPortalAbi,
23
- functionName: "depositEther",
24
- args: [
25
- applicationAddress,
26
- isHex(options.execLayerData) ? options.execLayerData : "0x", // XXX: validate before this
27
- ],
28
- value: parseEther(amount),
29
- account: walletClient.account,
30
- });
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
- });
36
- };
@@ -1,15 +0,0 @@
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
- //# sourceMappingURL=generic.d.ts.map
@@ -1 +0,0 @@
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,122 +0,0 @@
1
- import { Command, Option } from "@commander-js/extra-typings";
2
- import ora from "ora";
3
- import { encodeAbiParameters, getAddress, isAddress, isHex, parseAbiParameters, stringToHex, } from "viem";
4
- import { inputBoxAbi, inputBoxAddress } from "../../contracts.js";
5
- import { bytesInput } from "../../prompts.js";
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");
16
- }
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");
27
- }
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}'`);
33
- }
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)) {
59
- return v;
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}`);
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}'`);
73
- }
74
- return encodeAbiParameters(abiParameters, values);
75
- }
76
- if (isHex(input)) {
77
- return input;
78
- }
79
- // encode UTF-8 string as hex
80
- return stringToHex(input);
81
- }
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);
98
- // get dapp address from local node, or ask
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
- }
110
- const { request } = await publicClient.simulateContract({
111
- address: inputBoxAddress,
112
- abi: inputBoxAbi,
113
- functionName: "addInput",
114
- args: [applicationAddress, payload],
115
- account: walletClient.account,
116
- });
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
- });
122
- };
@@ -1,14 +0,0 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- export declare const createStartCommand: () => Command<[], {
3
- runtimeVersion: string;
4
- environmentName: string;
5
- blockTime: number;
6
- defaultBlock: "latest" | "pending" | "safe" | "finalized";
7
- cpus?: number | undefined;
8
- memory?: number | undefined;
9
- services: string[];
10
- port: number;
11
- dryRun: boolean;
12
- verbose: boolean;
13
- }, {}>;
14
- //# sourceMappingURL=start.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAU,MAAM,6BAA6B,CAAC;AAwJ9D,eAAO,MAAM,kBAAkB;;;;;;;;;;;MA8K9B,CAAC"}
@@ -1,220 +0,0 @@
1
- import { Command, Option } from "@commander-js/extra-typings";
2
- import chalk from "chalk";
3
- import { execa } from "execa";
4
- import { Listr } from "listr2";
5
- import path from "node:path";
6
- import pRetry from "p-retry";
7
- import { getServiceHealth } from "../base.js";
8
- import { DEFAULT_COMPOSE_ENVIRONMENT_NAME, DEFAULT_SDK_IMAGE, DEFAULT_SDK_VERSION, } from "../config.js";
9
- const commaSeparatedList = (value) => value.split(",");
10
- const host = "http://127.0.0.1";
11
- // services configuration
12
- const baseServices = [
13
- {
14
- name: "anvil",
15
- file: "docker-compose-anvil.yaml",
16
- healthySemaphore: "anvil",
17
- healthyTitle: (port) => `${chalk.cyan("anvil")} service ready at ${chalk.cyan(`${host}:${port}/anvil`)}`,
18
- waitTitle: `${chalk.cyan("anvil")} service starting...`,
19
- errorTitle: `${chalk.red("anvil")} service failed`,
20
- },
21
- {
22
- name: "proxy",
23
- file: "docker-compose-proxy.yaml",
24
- },
25
- {
26
- name: "database",
27
- file: "docker-compose-database.yaml",
28
- },
29
- {
30
- name: "rpc",
31
- file: "docker-compose-node.yaml",
32
- healthySemaphore: "rollups-node",
33
- healthyTitle: (port) => `${chalk.cyan("rpc")} service ready at ${chalk.cyan(`${host}:${port}/rpc`)}`,
34
- waitTitle: `${chalk.cyan("rpc")} service starting...`,
35
- errorTitle: `${chalk.red("rpc")} service failed`,
36
- },
37
- {
38
- name: "inspect",
39
- file: "docker-compose-node.yaml",
40
- healthySemaphore: "rollups-node",
41
- healthyTitle: (port) => `${chalk.cyan("inspect")} service ready at ${chalk.cyan(`${host}:${port}/inspect/<application_address>`)}`,
42
- waitTitle: `${chalk.cyan("inspect")} service starting...`,
43
- errorTitle: `${chalk.red("inspect")} service failed`,
44
- },
45
- ];
46
- const availableServices = [
47
- {
48
- name: "bundler",
49
- file: "docker-compose-bundler.yaml",
50
- healthySemaphore: "bundler",
51
- healthyTitle: (port) => `${chalk.cyan("bundler")} service ready at ${chalk.cyan(`${host}:${port}/bundler/rpc`)}`,
52
- waitTitle: `${chalk.cyan("bundler")} service starting...`,
53
- errorTitle: `${chalk.red("bundler")} service failed`,
54
- },
55
- {
56
- name: "espresso",
57
- file: "docker-compose-espresso.yaml",
58
- healthySemaphore: "espresso",
59
- healthyTitle: (port) => `${chalk.cyan("espresso")} service ready at ${chalk.cyan(`${host}:${port}/transaction`)}`,
60
- waitTitle: `${chalk.cyan("espresso")} service starting...`,
61
- errorTitle: `${chalk.red("espresso")} service failed`,
62
- },
63
- {
64
- name: "explorer",
65
- file: "docker-compose-explorer.yaml",
66
- healthySemaphore: "explorer_api",
67
- healthyTitle: (port) => `${chalk.cyan("explorer")} service ready at ${chalk.cyan(`${host}:${port}/explorer`)}`,
68
- waitTitle: `${chalk.cyan("explorer")} service starting...`,
69
- errorTitle: `${chalk.red("explorer")} service failed`,
70
- },
71
- {
72
- name: "graphql",
73
- file: "docker-compose-graphql.yaml",
74
- healthySemaphore: "graphql",
75
- healthyTitle: (port) => `${chalk.cyan("graphql")} service ready at ${chalk.cyan(`${host}:${port}/graphql`)}`,
76
- waitTitle: `${chalk.cyan("graphql")} service starting...`,
77
- errorTitle: `${chalk.red("graphql")} service failed`,
78
- },
79
- {
80
- name: "paymaster",
81
- file: "docker-compose-paymaster.yaml",
82
- healthySemaphore: "paymaster",
83
- healthyTitle: (port) => `${chalk.cyan("paymaster")} service ready at ${chalk.cyan(`${host}:${port}/paymaster`)}`,
84
- waitTitle: `${chalk.cyan("paymaster")} service starting...`,
85
- errorTitle: `${chalk.red("paymaster")} service failed`,
86
- },
87
- {
88
- name: "passkey",
89
- file: "docker-compose-passkey-server.yaml",
90
- healthySemaphore: "passkey-server",
91
- healthyTitle: (port) => `${chalk.cyan("passkey")} service ready at ${chalk.cyan(`${host}:${port}/passkey`)}`,
92
- waitTitle: `${chalk.cyan("passkey")} service starting...`,
93
- errorTitle: `${chalk.red("passkey")} service failed`,
94
- },
95
- ];
96
- const serviceMonitorTask = (options) => {
97
- const { errorTitle, healthyTitle, service, waitTitle } = options;
98
- return {
99
- task: async (_ctx, task) => {
100
- await pRetry(async () => {
101
- const health = await getServiceHealth(options);
102
- if (health !== "healthy") {
103
- throw new Error(errorTitle ??
104
- `Service ${chalk.cyan(service)} is not healthy`);
105
- }
106
- }, { retries: 100, minTimeout: 500, factor: 1.1 });
107
- task.title =
108
- healthyTitle ?? `Service ${chalk.cyan(service)} is ready`;
109
- },
110
- title: waitTitle ?? `Starting ${chalk.cyan(service)}...`,
111
- };
112
- };
113
- export const createStartCommand = () => {
114
- return new Command("start")
115
- .description("Start a local environment.")
116
- .configureHelp({ showGlobalOptions: true })
117
- .addOption(new Option("--runtime-version <version>", "version for Cartesi Rollups Runtime to use")
118
- .default(DEFAULT_SDK_VERSION)
119
- .hideHelp())
120
- .option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
121
- .addOption(new Option("--block-time <number>", "interval between blocks (in seconds)")
122
- .argParser(Number)
123
- .default(5))
124
- .addOption(new Option("--default-block <string>", "default block to be used when fetching new blocks.")
125
- .choices(["latest", "safe", "pending", "finalized"])
126
- .default("latest"))
127
- .addOption(new Option("--cpus <number>", "number of cpu limits for the rollups-node").argParser(Number))
128
- .addOption(new Option("--memory <number>", "memory limit for the rollups-node in MB").argParser(Number))
129
- .option("--services <string>", `optional services to start, comma separated list from [${availableServices.map(({ name }) => name).join(", ")}]`, commaSeparatedList, [])
130
- .option("-p, --port <number>", "port to listen on", Number, 6751)
131
- .option("--dry-run", "show the docker compose configuration", false)
132
- .option("-v, --verbose", "verbose output", false)
133
- .action(async (options, command) => {
134
- const { blockTime, cpus, defaultBlock, dryRun, environmentName, memory, port, services, verbose, runtimeVersion, } = options;
135
- // path of the tool instalation
136
- const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..");
137
- // setup the environment variable used in docker compose
138
- const env = {
139
- CARTESI_BLOCK_TIME: blockTime.toString(),
140
- CARTESI_BLOCKCHAIN_DEFAULT_BLOCK: defaultBlock,
141
- CARTESI_LOG_LEVEL: verbose ? "debug" : "info",
142
- CARTESI_BIN_PATH: binPath,
143
- CARTESI_LISTEN_PORT: port.toString(),
144
- CARTESI_ROLLUPS_NODE_CPUS: cpus?.toString(),
145
- CARTESI_ROLLUPS_NODE_MEMORY: memory?.toString(),
146
- CARTESI_SDK_IMAGE: `${DEFAULT_SDK_IMAGE}:${runtimeVersion}`,
147
- CARTESI_SDK_VERSION: runtimeVersion,
148
- };
149
- // build a list of unique compose files
150
- const composeFiles = [
151
- ...new Set(baseServices.map(({ file }) => file)),
152
- ];
153
- // cpu and memory limits, mostly for testing and debuggingpurposes
154
- if (cpus) {
155
- composeFiles.push("docker-compose-node-cpus.yaml");
156
- }
157
- if (memory) {
158
- composeFiles.push("docker-compose-node-memory.yaml");
159
- }
160
- // select subset of optional services
161
- const optionalServices = services.length === 1 && services[0] === "all"
162
- ? availableServices
163
- : availableServices.filter(({ name }) => services.includes(name));
164
- // add to compose files list
165
- composeFiles.push(...optionalServices.map(({ file }) => file));
166
- // create the "--file <file>" list
167
- const files = composeFiles.flatMap((f) => [
168
- "--file",
169
- path.join(binPath, "compose", f),
170
- ]);
171
- const composeArgs = [
172
- "compose",
173
- ...files,
174
- "--project-name",
175
- environmentName,
176
- ];
177
- // run in detached mode (background)
178
- const upArgs = ["--detach"];
179
- if (dryRun) {
180
- // show the docker compose configuration
181
- await execa("docker", [...composeArgs, "config"], {
182
- env,
183
- stdio: "inherit",
184
- });
185
- }
186
- else {
187
- if (defaultBlock !== "finalized") {
188
- console.warn(chalk.yellow(`WARNING: default block is set to '${defaultBlock}', production configuration will likely use 'finalized'`));
189
- }
190
- // pull images first
191
- const pullArgs = ["--policy", "missing"];
192
- await execa("docker", [...composeArgs, "pull", ...pullArgs], {
193
- env,
194
- stdio: "inherit",
195
- });
196
- // run compose environment
197
- const up = execa("docker", [...composeArgs, "up", ...upArgs], {
198
- env,
199
- });
200
- // create tasks to monitor services startup
201
- const monitorTasks = [...baseServices, ...optionalServices]
202
- .filter(({ healthySemaphore }) => !!healthySemaphore) // only services with a healthy semaphore
203
- .map((service) => {
204
- const healthyTitle = typeof service.healthyTitle === "function"
205
- ? service.healthyTitle(port)
206
- : service.healthyTitle;
207
- return serviceMonitorTask({
208
- environmentName,
209
- service: service.healthySemaphore,
210
- errorTitle: service.errorTitle,
211
- waitTitle: service.waitTitle,
212
- healthyTitle,
213
- });
214
- });
215
- const tasks = new Listr(monitorTasks, { concurrent: true });
216
- await tasks.run();
217
- await up;
218
- }
219
- });
220
- };
@@ -1,5 +0,0 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- export declare const createStopCommand: () => Command<[], {
3
- environmentName: string;
4
- }, {}>;
5
- //# sourceMappingURL=stop.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stop.d.ts","sourceRoot":"","sources":["../../src/commands/stop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAMtD,eAAO,MAAM,iBAAiB;;MA4B7B,CAAC"}
@@ -1,27 +0,0 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- import chalk from "chalk";
3
- import { execa } from "execa";
4
- import ora from "ora";
5
- import { DEFAULT_COMPOSE_ENVIRONMENT_NAME } from "../config.js";
6
- export const createStopCommand = () => {
7
- return new Command("stop")
8
- .description("Stop a local environment.")
9
- .configureHelp({ showGlobalOptions: true })
10
- .option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
11
- .action(async ({ environmentName }, command) => {
12
- const progress = ora(`Stopping ${chalk.cyan(environmentName)} environment...`).start();
13
- try {
14
- await execa("docker", [
15
- "compose",
16
- "-p",
17
- environmentName,
18
- "down",
19
- "--volumes",
20
- ]);
21
- progress.succeed(`${chalk.cyan(environmentName)} environment stopped.`);
22
- }
23
- catch (e) {
24
- progress.fail(e.message);
25
- }
26
- });
27
- };
@@ -1,81 +0,0 @@
1
- configs:
2
- espresso_proxy:
3
- content: |
4
- http:
5
- routers:
6
- espresso-reader:
7
- rule: "PathPrefix(`/transaction`)"
8
- middlewares:
9
- - "remove-espresso-reader-prefix"
10
- service: espresso-reader
11
- middlewares:
12
- remove-espresso-reader-prefix:
13
- replacePathRegex:
14
- regex: "^/transaction/(.*)"
15
- replacement: "/$1"
16
- services:
17
- espresso-reader:
18
- loadBalancer:
19
- servers:
20
- - url: "http://espresso_reader:8081"
21
-
22
- services:
23
- espresso:
24
- image: ${CARTESI_SDK_IMAGE}
25
- command: ["espresso-dev-node"]
26
- init: true
27
- deploy:
28
- resources:
29
- limits:
30
- cpus: "4"
31
- memory: "1G"
32
- depends_on:
33
- database:
34
- condition: service_healthy
35
- anvil:
36
- condition: service_healthy
37
- environment:
38
- ESPRESSO_SEQUENCER_L1_PROVIDER: ${CARTESI_BLOCKCHAIN_HTTP_ENDPOINT:-http://anvil:8545}
39
- ESPRESSO_SEQUENCER_API_PORT: 24000
40
- ESPRESSO_BUILDER_PORT: 23000
41
- ESPRESSO_DEV_NODE_PORT: 20000
42
- ESPRESSO_SEQUENCER_ETH_MNEMONIC: ${CARTESI_AUTH_MNEMONIC:-test test test test test test test test test test test junk}
43
- ESPRESSO_SEQUENCER_L1_POLLING_INTERVAL: "${CARTESI_BLOCK_TIME}s"
44
- ESPRESSO_STATE_PROVER_UPDATE_INTERVAL: "10s"
45
- ESPRESSO_SEQUENCER_DATABASE_MAX_CONNECTIONS: 25
46
- ESPRESSO_SEQUENCER_STORAGE_PATH: /data/espresso
47
- healthcheck:
48
- test:
49
- [
50
- "CMD",
51
- "curl",
52
- "-fsS",
53
- "http://127.0.0.1:24000/status/block-height",
54
- ]
55
- start_period: 10s
56
- start_interval: 200ms
57
- interval: 10s
58
- timeout: 1s
59
- retries: 5
60
-
61
- espresso_reader:
62
- image: ${CARTESI_SDK_IMAGE}
63
- command: ["cartesi-rollups-espresso-reader"]
64
- env_file:
65
- - ${CARTESI_BIN_PATH}/compose/default.env
66
- ports:
67
- - 8081
68
- depends_on:
69
- database:
70
- condition: service_healthy
71
- espresso:
72
- condition: service_healthy
73
- environment:
74
- CARTESI_DATABASE_CONNECTION: postgres://postgres:password@database:5432/rollupsdb?sslmode=disable
75
- ESPRESSO_SERVICE_ENDPOINT: ":8081"
76
- ESPRESSO_BASE_URL: http://espresso:24000
77
-
78
- proxy:
79
- configs:
80
- - source: espresso_proxy
81
- target: /etc/traefik/conf.d/espresso.yaml