@cartesi/cli 2.0.0-alpha.20 → 2.0.0-alpha.22

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 (132) hide show
  1. package/dist/index.js +685 -50
  2. package/dist/index.js.map +785 -0
  3. package/package.json +80 -84
  4. package/LICENSE +0 -202
  5. package/dist/base.d.ts +0 -28
  6. package/dist/base.d.ts.map +0 -1
  7. package/dist/base.js +0 -109
  8. package/dist/builder/directory.d.ts +0 -3
  9. package/dist/builder/directory.d.ts.map +0 -1
  10. package/dist/builder/directory.js +0 -39
  11. package/dist/builder/docker.d.ts +0 -10
  12. package/dist/builder/docker.d.ts.map +0 -1
  13. package/dist/builder/docker.js +0 -114
  14. package/dist/builder/empty.d.ts +0 -3
  15. package/dist/builder/empty.d.ts.map +0 -1
  16. package/dist/builder/empty.js +0 -21
  17. package/dist/builder/index.d.ts +0 -6
  18. package/dist/builder/index.d.ts.map +0 -1
  19. package/dist/builder/index.js +0 -5
  20. package/dist/builder/none.d.ts +0 -3
  21. package/dist/builder/none.d.ts.map +0 -1
  22. package/dist/builder/none.js +0 -11
  23. package/dist/builder/tar.d.ts +0 -3
  24. package/dist/builder/tar.d.ts.map +0 -1
  25. package/dist/builder/tar.js +0 -30
  26. package/dist/commands/address-book.d.ts +0 -6
  27. package/dist/commands/address-book.d.ts.map +0 -1
  28. package/dist/commands/address-book.js +0 -44
  29. package/dist/commands/build.d.ts +0 -8
  30. package/dist/commands/build.d.ts.map +0 -1
  31. package/dist/commands/build.js +0 -97
  32. package/dist/commands/clean.d.ts +0 -3
  33. package/dist/commands/clean.d.ts.map +0 -1
  34. package/dist/commands/clean.js +0 -10
  35. package/dist/commands/create.d.ts +0 -7
  36. package/dist/commands/create.d.ts.map +0 -1
  37. package/dist/commands/create.js +0 -37
  38. package/dist/commands/deploy/build.d.ts +0 -3
  39. package/dist/commands/deploy/build.d.ts.map +0 -1
  40. package/dist/commands/deploy/build.js +0 -9
  41. package/dist/commands/deploy.d.ts +0 -3
  42. package/dist/commands/deploy.d.ts.map +0 -1
  43. package/dist/commands/deploy.js +0 -12
  44. package/dist/commands/deposit/erc1155.d.ts +0 -18
  45. package/dist/commands/deposit/erc1155.d.ts.map +0 -1
  46. package/dist/commands/deposit/erc1155.js +0 -254
  47. package/dist/commands/deposit/erc20.d.ts +0 -10
  48. package/dist/commands/deposit/erc20.d.ts.map +0 -1
  49. package/dist/commands/deposit/erc20.js +0 -125
  50. package/dist/commands/deposit/erc721.d.ts +0 -10
  51. package/dist/commands/deposit/erc721.d.ts.map +0 -1
  52. package/dist/commands/deposit/erc721.js +0 -143
  53. package/dist/commands/deposit/ether.d.ts +0 -10
  54. package/dist/commands/deposit/ether.d.ts.map +0 -1
  55. package/dist/commands/deposit/ether.js +0 -65
  56. package/dist/commands/deposit.d.ts +0 -9
  57. package/dist/commands/deposit.d.ts.map +0 -1
  58. package/dist/commands/deposit.js +0 -37
  59. package/dist/commands/doctor.d.ts +0 -3
  60. package/dist/commands/doctor.d.ts.map +0 -1
  61. package/dist/commands/doctor.js +0 -105
  62. package/dist/commands/hash.d.ts +0 -5
  63. package/dist/commands/hash.d.ts.map +0 -1
  64. package/dist/commands/hash.js +0 -22
  65. package/dist/commands/logs.d.ts +0 -9
  66. package/dist/commands/logs.d.ts.map +0 -1
  67. package/dist/commands/logs.js +0 -34
  68. package/dist/commands/run.d.ts +0 -15
  69. package/dist/commands/run.d.ts.map +0 -1
  70. package/dist/commands/run.js +0 -202
  71. package/dist/commands/send.d.ts +0 -10
  72. package/dist/commands/send.d.ts.map +0 -1
  73. package/dist/commands/send.js +0 -130
  74. package/dist/commands/shell.d.ts +0 -7
  75. package/dist/commands/shell.d.ts.map +0 -1
  76. package/dist/commands/shell.js +0 -48
  77. package/dist/commands/status.d.ts +0 -6
  78. package/dist/commands/status.d.ts.map +0 -1
  79. package/dist/commands/status.js +0 -50
  80. package/dist/compose/default.env +0 -36
  81. package/dist/compose/docker-compose-anvil.yaml +0 -39
  82. package/dist/compose/docker-compose-bundler.yaml +0 -71
  83. package/dist/compose/docker-compose-database.yaml +0 -12
  84. package/dist/compose/docker-compose-explorer.yaml +0 -96
  85. package/dist/compose/docker-compose-graphql.yaml +0 -38
  86. package/dist/compose/docker-compose-node-cpus.yaml +0 -6
  87. package/dist/compose/docker-compose-node-memory.yaml +0 -6
  88. package/dist/compose/docker-compose-node.yaml +0 -50
  89. package/dist/compose/docker-compose-passkey-server.yaml +0 -37
  90. package/dist/compose/docker-compose-paymaster.yaml +0 -40
  91. package/dist/compose/docker-compose-proxy.yaml +0 -24
  92. package/dist/config.d.ts +0 -124
  93. package/dist/config.d.ts.map +0 -1
  94. package/dist/config.js +0 -418
  95. package/dist/contracts.d.ts +0 -4376
  96. package/dist/contracts.d.ts.map +0 -1
  97. package/dist/contracts.js +0 -1839
  98. package/dist/exec/cartesi-machine.d.ts +0 -9
  99. package/dist/exec/cartesi-machine.d.ts.map +0 -1
  100. package/dist/exec/cartesi-machine.js +0 -18
  101. package/dist/exec/genext2fs.d.ts +0 -31
  102. package/dist/exec/genext2fs.d.ts.map +0 -1
  103. package/dist/exec/genext2fs.js +0 -44
  104. package/dist/exec/index.d.ts +0 -4
  105. package/dist/exec/index.d.ts.map +0 -1
  106. package/dist/exec/index.js +0 -3
  107. package/dist/exec/mksquashfs.d.ts +0 -21
  108. package/dist/exec/mksquashfs.d.ts.map +0 -1
  109. package/dist/exec/mksquashfs.js +0 -47
  110. package/dist/exec/rollups.d.ts +0 -105
  111. package/dist/exec/rollups.d.ts.map +0 -1
  112. package/dist/exec/rollups.js +0 -383
  113. package/dist/exec/util.d.ts +0 -21
  114. package/dist/exec/util.d.ts.map +0 -1
  115. package/dist/exec/util.js +0 -31
  116. package/dist/index.d.ts +0 -3
  117. package/dist/index.d.ts.map +0 -1
  118. package/dist/machine.d.ts +0 -12
  119. package/dist/machine.d.ts.map +0 -1
  120. package/dist/machine.js +0 -90
  121. package/dist/prompts.d.ts +0 -73
  122. package/dist/prompts.d.ts.map +0 -1
  123. package/dist/prompts.js +0 -192
  124. package/dist/template.d.ts +0 -3
  125. package/dist/template.d.ts.map +0 -1
  126. package/dist/template.js +0 -16
  127. package/dist/types/docker.d.ts +0 -22
  128. package/dist/types/docker.d.ts.map +0 -1
  129. package/dist/types/docker.js +0 -1
  130. package/dist/wallet.d.ts +0 -9225
  131. package/dist/wallet.d.ts.map +0 -1
  132. package/dist/wallet.js +0 -41
@@ -1,383 +0,0 @@
1
- import chalk from "chalk";
2
- import { execa } from "execa";
3
- import { Listr } from "listr2";
4
- import path from "node:path";
5
- import pRetry from "p-retry";
6
- import { getAddress, hexToNumber, } from "viem";
7
- import { getContextPath, getMachineHash, getProjectName, getServiceHealth, } from "../base.js";
8
- import { DEFAULT_SDK_IMAGE } from "../config.js";
9
- const parseDeployment = (deployment) => ({
10
- address: deployment.iapplication_address,
11
- consensus: deployment.iconsensus_address,
12
- epochLength: hexToNumber(deployment.epoch_length),
13
- name: deployment.name,
14
- state: deployment.state,
15
- templateHash: deployment.template_hash,
16
- });
17
- export const getDeployments = async (options) => {
18
- try {
19
- const { stdout } = await execa("docker", [
20
- "compose",
21
- "--project-name",
22
- options.projectName,
23
- "exec",
24
- "rollups-node",
25
- "cartesi-rollups-cli",
26
- "app",
27
- "list",
28
- ]);
29
- return JSON.parse(stdout).map(parseDeployment);
30
- }
31
- catch {
32
- return [];
33
- }
34
- };
35
- export const getApplicationDeployment = async (options) => {
36
- const machineHash = getMachineHash();
37
- if (!machineHash) {
38
- return undefined;
39
- }
40
- const deployments = await getDeployments(options);
41
- return deployments.find((deployment) => deployment.templateHash === machineHash);
42
- };
43
- export const getApplicationAddress = async (options) => {
44
- const projectName = getProjectName(options ?? {});
45
- const deployment = await getApplicationDeployment({ projectName });
46
- return deployment?.address;
47
- };
48
- const host = "http://127.0.0.1";
49
- // services configuration
50
- const baseServices = [
51
- {
52
- name: "anvil",
53
- file: "docker-compose-anvil.yaml",
54
- healthySemaphore: "anvil",
55
- healthyTitle: (port) => `${chalk.cyan("anvil")} service ready at ${chalk.cyan(`${host}:${port}/anvil`)}`,
56
- waitTitle: `${chalk.cyan("anvil")} service starting...`,
57
- errorTitle: `${chalk.red("anvil")} service failed`,
58
- },
59
- {
60
- name: "proxy",
61
- file: "docker-compose-proxy.yaml",
62
- },
63
- {
64
- name: "database",
65
- file: "docker-compose-database.yaml",
66
- },
67
- {
68
- name: "rpc",
69
- file: "docker-compose-node.yaml",
70
- healthySemaphore: "rollups-node",
71
- healthyTitle: (port) => `${chalk.cyan("rpc")} service ready at ${chalk.cyan(`${host}:${port}/rpc`)}`,
72
- waitTitle: `${chalk.cyan("rpc")} service starting...`,
73
- errorTitle: `${chalk.red("rpc")} service failed`,
74
- },
75
- {
76
- name: "inspect",
77
- file: "docker-compose-node.yaml",
78
- healthySemaphore: "rollups-node",
79
- healthyTitle: (port, name) => `${chalk.cyan("inspect")} service ready at ${chalk.cyan(`${host}:${port}/inspect/${name ?? "<application_address>"}`)}`,
80
- waitTitle: `${chalk.cyan("inspect")} service starting...`,
81
- errorTitle: `${chalk.red("inspect")} service failed`,
82
- },
83
- ];
84
- const availableServices = [
85
- {
86
- name: "bundler",
87
- file: "docker-compose-bundler.yaml",
88
- healthySemaphore: "bundler",
89
- healthyTitle: (port) => `${chalk.cyan("bundler")} service ready at ${chalk.cyan(`${host}:${port}/bundler/rpc`)}`,
90
- waitTitle: `${chalk.cyan("bundler")} service starting...`,
91
- errorTitle: `${chalk.red("bundler")} service failed`,
92
- },
93
- {
94
- name: "explorer",
95
- file: "docker-compose-explorer.yaml",
96
- healthySemaphore: "explorer_api",
97
- healthyTitle: (port) => `${chalk.cyan("explorer")} service ready at ${chalk.cyan(`${host}:${port}/explorer`)}`,
98
- waitTitle: `${chalk.cyan("explorer")} service starting...`,
99
- errorTitle: `${chalk.red("explorer")} service failed`,
100
- },
101
- {
102
- name: "graphql",
103
- file: "docker-compose-graphql.yaml",
104
- healthySemaphore: "graphql",
105
- healthyTitle: (port) => `${chalk.cyan("graphql")} service ready at ${chalk.cyan(`${host}:${port}/graphql`)}`,
106
- waitTitle: `${chalk.cyan("graphql")} service starting...`,
107
- errorTitle: `${chalk.red("graphql")} service failed`,
108
- },
109
- {
110
- name: "paymaster",
111
- file: "docker-compose-paymaster.yaml",
112
- healthySemaphore: "paymaster",
113
- healthyTitle: (port) => `${chalk.cyan("paymaster")} service ready at ${chalk.cyan(`${host}:${port}/paymaster`)}`,
114
- waitTitle: `${chalk.cyan("paymaster")} service starting...`,
115
- errorTitle: `${chalk.red("paymaster")} service failed`,
116
- },
117
- {
118
- name: "passkey",
119
- file: "docker-compose-passkey-server.yaml",
120
- healthySemaphore: "passkey-server",
121
- healthyTitle: (port) => `${chalk.cyan("passkey")} service ready at ${chalk.cyan(`${host}:${port}/passkey`)}`,
122
- waitTitle: `${chalk.cyan("passkey")} service starting...`,
123
- errorTitle: `${chalk.red("passkey")} service failed`,
124
- },
125
- ];
126
- export const AVAILABLE_SERVICES = availableServices.map(({ name }) => name);
127
- const serviceMonitorTask = (options) => {
128
- const { errorTitle, healthyTitle, service, waitTitle } = options;
129
- return {
130
- task: async (_ctx, task) => {
131
- await pRetry(async () => {
132
- const health = await getServiceHealth(options);
133
- if (health !== "healthy") {
134
- throw new Error(errorTitle ??
135
- `Service ${chalk.cyan(service)} is not healthy`);
136
- }
137
- }, { retries: 100, minTimeout: 500, factor: 1.1 });
138
- task.title =
139
- healthyTitle ?? `Service ${chalk.cyan(service)} is ready`;
140
- },
141
- title: waitTitle ?? `Starting ${chalk.cyan(service)}...`,
142
- };
143
- };
144
- export const startEnvironment = async (options) => {
145
- const { blockTime, cpus, defaultBlock, dryRun, memory, port, projectName, runtimeVersion, services, verbose, } = options;
146
- const address = `${host}:${port}`;
147
- // path of the tool instalation
148
- const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..");
149
- // setup the environment variable used in docker compose
150
- const env = {
151
- CARTESI_BIN_PATH: binPath,
152
- CARTESI_BLOCK_TIME: blockTime.toString(),
153
- CARTESI_BLOCKCHAIN_DEFAULT_BLOCK: defaultBlock,
154
- CARTESI_LISTEN_PORT: port.toString(),
155
- CARTESI_LOG_LEVEL: verbose ? "debug" : "info",
156
- CARTESI_ROLLUPS_NODE_CPUS: cpus?.toString(),
157
- CARTESI_ROLLUPS_NODE_MEMORY: memory?.toString(),
158
- CARTESI_SDK_IMAGE: `${DEFAULT_SDK_IMAGE}:${runtimeVersion}`,
159
- CARTESI_SDK_VERSION: runtimeVersion,
160
- };
161
- // build a list of unique compose files
162
- const composeFiles = [...new Set(baseServices.map(({ file }) => file))];
163
- // cpu and memory limits, mostly for testing and debuggingpurposes
164
- if (cpus) {
165
- composeFiles.push("docker-compose-node-cpus.yaml");
166
- }
167
- if (memory) {
168
- composeFiles.push("docker-compose-node-memory.yaml");
169
- }
170
- // select subset of optional services
171
- const optionalServices = services.length === 1 && services[0] === "all"
172
- ? availableServices
173
- : availableServices.filter(({ name }) => services.includes(name));
174
- // add to compose files list
175
- composeFiles.push(...optionalServices.map(({ file }) => file));
176
- // create the "--file <file>" list
177
- const files = composeFiles.flatMap((f) => [
178
- "--file",
179
- path.join(binPath, "compose", f),
180
- ]);
181
- const composeArgs = [
182
- "compose",
183
- ...files,
184
- "--project-directory",
185
- ".",
186
- "--project-name",
187
- projectName,
188
- ];
189
- // run in detached mode (background)
190
- const upArgs = ["--detach"];
191
- // if only dry run, just return the config
192
- if (dryRun) {
193
- // parse, resolve and render compose file in canonical format
194
- const { stdout: config } = await execa("docker", [...composeArgs, "config", "--format", "yaml"], { env });
195
- return { address, config };
196
- }
197
- // pull images first
198
- const pullArgs = ["--policy", "missing"];
199
- await execa("docker", [...composeArgs, "pull", ...pullArgs], {
200
- env,
201
- stdio: "inherit",
202
- });
203
- // run compose
204
- await execa("docker", [...composeArgs, "up", ...upArgs], {
205
- env,
206
- });
207
- return { address };
208
- };
209
- /**
210
- * Wait for the environment to be healthy
211
- * @param options
212
- */
213
- export const waitHealthyEnvironment = async (options) => {
214
- const { name, port, projectName, services } = options;
215
- // select subset of optional services
216
- const optionalServices = services.length === 1 && services[0] === "all"
217
- ? availableServices
218
- : availableServices.filter(({ name }) => services.includes(name));
219
- // create tasks to monitor services startup
220
- const monitorTasks = [...baseServices, ...optionalServices]
221
- .filter(({ healthySemaphore }) => !!healthySemaphore) // only services with a healthy semaphore
222
- .map((service) => {
223
- const healthyTitle = typeof service.healthyTitle === "function"
224
- ? service.healthyTitle(port, name)
225
- : service.healthyTitle;
226
- return serviceMonitorTask({
227
- projectName,
228
- service: service.healthySemaphore,
229
- errorTitle: service.errorTitle,
230
- waitTitle: service.waitTitle,
231
- healthyTitle,
232
- });
233
- });
234
- const tasks = new Listr(monitorTasks, { concurrent: true });
235
- await tasks.run();
236
- };
237
- /**
238
- * Publish machine snapshot to rollups node by copying it to the rollups node container
239
- * @param options
240
- * @returns path to the snapshot in the rollups node
241
- */
242
- export const publishMachine = async (options) => {
243
- const { projectName, templateHash } = options;
244
- const snapshotPath = getContextPath("image");
245
- const containerSnapshotPath = `/var/lib/cartesi-rollups-node/snapshots/${templateHash}/`;
246
- await execa("docker", [
247
- "compose",
248
- "--project-name",
249
- projectName,
250
- "cp",
251
- snapshotPath,
252
- `rollups-node:${containerSnapshotPath}`,
253
- ]);
254
- return containerSnapshotPath;
255
- };
256
- /**
257
- * Stop an environment by removing the containers and volumes
258
- * @param options
259
- * @returns
260
- */
261
- export const stopEnvironment = async (options) => {
262
- const { projectName } = options;
263
- return execa("docker", [
264
- "compose",
265
- "--project-name",
266
- projectName,
267
- "down",
268
- "--volumes",
269
- ]);
270
- };
271
- /**
272
- * Deploy application to rollups node
273
- * @param options
274
- * @returns address of the application
275
- */
276
- export const deployAuthority = async (options) => {
277
- const { epochLength, projectName } = options;
278
- // deploy application
279
- const { stdout } = await execa("docker", [
280
- "compose",
281
- "--project-name",
282
- projectName,
283
- "exec",
284
- "rollups-node",
285
- "cartesi-rollups-cli",
286
- "deploy",
287
- "authority",
288
- "--epoch-length",
289
- epochLength.toString(),
290
- "--json",
291
- ]);
292
- return getAddress(JSON.parse(stdout).address);
293
- };
294
- /**
295
- * Deploy application to rollups node
296
- * @param options
297
- * @returns address of the application
298
- */
299
- export const deployApplication = async (options) => {
300
- const { consensus, epochLength, name, projectName, salt, snapshotPath } = options;
301
- // app deploy args
302
- const deployArgs = [name, snapshotPath];
303
- if (consensus) {
304
- deployArgs.push("--consensus", consensus);
305
- }
306
- else {
307
- deployArgs.push("--epoch-length", epochLength.toString());
308
- }
309
- if (salt) {
310
- deployArgs.push("--salt", salt);
311
- }
312
- deployArgs.push("--json");
313
- // deploy application
314
- const { stdout } = await execa("docker", [
315
- "compose",
316
- "--project-name",
317
- projectName,
318
- "exec",
319
- "rollups-node",
320
- "cartesi-rollups-cli",
321
- "deploy",
322
- "application",
323
- ...deployArgs,
324
- ]);
325
- const deployment = stdout ? parseDeployment(JSON.parse(stdout)) : undefined;
326
- if (deployment) {
327
- return deployment;
328
- }
329
- throw new Error("Failed to deploy application");
330
- };
331
- /**
332
- * Remove application from rollups node
333
- * @param options
334
- * @returns
335
- */
336
- export const removeApplication = async (options) => {
337
- const { application, force, projectName } = options;
338
- // disable application first so we can remove it
339
- await execa("docker", [
340
- "compose",
341
- "--project-name",
342
- projectName,
343
- "exec",
344
- "rollups-node",
345
- "cartesi-rollups-cli",
346
- "app",
347
- "status",
348
- application,
349
- "disabled",
350
- ]);
351
- const removeArgs = [application];
352
- if (force) {
353
- removeArgs.push("--force");
354
- }
355
- return execa("docker", [
356
- "compose",
357
- "--project-name",
358
- projectName,
359
- "exec",
360
- "rollups-node",
361
- "cartesi-rollups-cli",
362
- "app",
363
- "remove",
364
- ...removeArgs,
365
- ]);
366
- };
367
- /**
368
- * Get the host and port of the docker compose project entrypoint
369
- * @param options
370
- * @returns port of the proxy service
371
- */
372
- export const getProjectPort = async (options) => {
373
- const { projectName } = options;
374
- const { stdout } = await execa("docker", [
375
- "compose",
376
- "--project-name",
377
- projectName,
378
- "port",
379
- "proxy",
380
- "8088",
381
- ]);
382
- return stdout;
383
- };
@@ -1,21 +0,0 @@
1
- import { type Options } from "execa";
2
- export type DockerFallbackOptions = {
3
- image: string;
4
- forceDocker: true;
5
- } | {
6
- image?: string;
7
- forceDocker?: false;
8
- };
9
- /**
10
- * Calls execa and falls back to docker run if command (on the host) fails
11
- * @param command command to be executed
12
- * @param args arguments to be passed to the command
13
- * @param options execution options
14
- * @returns return of execa
15
- */
16
- export type ExecaOptionsDockerFallback = Options & DockerFallbackOptions;
17
- export declare const execaDockerFallback: (command: string, args: readonly string[], options: ExecaOptionsDockerFallback) => Promise<import("execa").Result<Options & {
18
- image?: string;
19
- forceDocker?: false;
20
- }>>;
21
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/exec/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,OAAO,CAAC;AAGxD,MAAM,MAAM,qBAAqB,GAC3B;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,IAAI,CAAA;CAAE,GACpC;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,KAAK,CAAA;CAAE,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,MAAM,0BAA0B,GAAG,OAAO,GAAG,qBAAqB,CAAC;AACzE,eAAO,MAAM,mBAAmB,GAC5B,SAAS,MAAM,EACf,MAAM,SAAS,MAAM,EAAE,EACvB,SAAS,0BAA0B;YAbvB,MAAM;kBAAgB,KAAK;GA6C1C,CAAC"}
package/dist/exec/util.js DELETED
@@ -1,31 +0,0 @@
1
- import { ExecaError, execa } from "execa";
2
- import os from "node:os";
3
- export const execaDockerFallback = async (command, args, options) => {
4
- try {
5
- if (options.forceDocker) {
6
- const error = new ExecaError();
7
- error.code = "ENOENT";
8
- throw error;
9
- }
10
- return await execa(command, args, options);
11
- }
12
- catch (error) {
13
- if (error instanceof ExecaError) {
14
- if (error.code === "ENOENT" && options.image) {
15
- const userInfo = os.userInfo();
16
- const dockerOpts = [
17
- "--volume",
18
- `${options.cwd}:/work`,
19
- "--workdir",
20
- "/work",
21
- "--interactive",
22
- "--rm",
23
- "--user",
24
- `${userInfo.uid}:${userInfo.gid}`,
25
- ];
26
- return await execa("docker", ["run", ...dockerOpts, options.image, command, ...args], options);
27
- }
28
- }
29
- throw error;
30
- }
31
- };
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/machine.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import type { Config, ImageInfo } from "./config.js";
2
- import type { ExecaOptionsDockerFallback } from "./exec/util.js";
3
- export type BootMachineOptions = {
4
- finalHash?: boolean;
5
- interactive?: boolean;
6
- store?: string;
7
- };
8
- export declare const bootMachine: (config: Config, info: ImageInfo | undefined, bootOptions: BootMachineOptions, options?: ExecaOptionsDockerFallback) => Promise<import("execa").Result<import("execa").Options & {
9
- image?: string;
10
- forceDocker?: false;
11
- }>>;
12
- //# sourceMappingURL=machine.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"machine.d.ts","sourceRoot":"","sources":["../src/machine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAe,SAAS,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAmBjE,MAAM,MAAM,kBAAkB,GAAG;IAC7B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW,GACpB,QAAQ,MAAM,EACd,MAAM,SAAS,GAAG,SAAS,EAC3B,aAAa,kBAAkB,EAC/B,UAAU,0BAA0B;;;GAkGvC,CAAC"}
package/dist/machine.js DELETED
@@ -1,90 +0,0 @@
1
- import { cartesiMachine } from "./exec/index.js";
2
- const flashDrive = (label, drive) => {
3
- const { format, mount, shared, user } = drive;
4
- const filename = `${label}.${format}`;
5
- const vars = [`label:${label}`, `filename:${filename}`];
6
- if (mount !== undefined) {
7
- vars.push(`mount:${mount}`);
8
- }
9
- if (user) {
10
- vars.push(`user:${user}`);
11
- }
12
- if (shared) {
13
- vars.push("shared");
14
- }
15
- // don't specify start and length
16
- return `--flash-drive=${vars.join(",")}`;
17
- };
18
- export const bootMachine = (config, info, bootOptions, options) => {
19
- const { machine } = config;
20
- const { assertRollingTemplate, maxMCycle, noRollup, ramLength, ramImage, useDockerEnv, useDockerWorkdir, user, } = machine;
21
- // list of environment variables of docker image
22
- const env = useDockerEnv ? (info?.env ?? []) : [];
23
- const envs = env.map((variable) => {
24
- const [key, value] = variable.split("=");
25
- return `--env=${key}="${value}"`;
26
- });
27
- // check if we need a rootfstype boot arg
28
- const root = config.drives.root;
29
- if (root?.format === "sqfs") {
30
- const definedRootfsType = config.machine.bootargs.find((arg) => arg.startsWith("rootfstype="));
31
- // not checking here if user intentionally defined wrong type
32
- if (!definedRootfsType) {
33
- config.machine.bootargs.push("rootfstype=squashfs");
34
- }
35
- }
36
- // bootargs from config string array
37
- const bootargs = machine.bootargs.map((arg) => `--append-bootargs="${arg}"`);
38
- // entrypoint from config or image info (Docker ENTRYPOINT + CMD)
39
- let entrypoint;
40
- if (machine.entrypoint) {
41
- entrypoint = machine.entrypoint;
42
- }
43
- else if (info && (info.entrypoint.length > 0 || info.cmd.length > 0)) {
44
- entrypoint = [...info.entrypoint, ...info.cmd].join(" ");
45
- }
46
- if (!entrypoint) {
47
- throw new Error("Undefined machine entrypoint. Please define an entrypoint in your cartesi.toml config or in your Dockerfile.");
48
- }
49
- const flashDrives = Object.entries(config.drives).map(([label, drive]) => flashDrive(label, drive));
50
- // command to change working directory if WORKDIR is defined
51
- const args = [
52
- ...bootargs,
53
- ...envs,
54
- ...flashDrives,
55
- `--ram-length=${ramLength}`,
56
- ];
57
- if (ramImage) {
58
- args.push(`--ram-image=${ramImage}`);
59
- }
60
- if (assertRollingTemplate) {
61
- args.push("--assert-rolling-template");
62
- }
63
- if (bootOptions.finalHash) {
64
- args.push("--final-hash");
65
- }
66
- if (useDockerWorkdir && info?.workdir) {
67
- args.push(`--workdir="${info.workdir}"`);
68
- }
69
- if (bootOptions.interactive) {
70
- args.push("-it");
71
- }
72
- if (noRollup) {
73
- args.push("--no-rollup");
74
- }
75
- if (maxMCycle) {
76
- args.push(`--max-mcycle=${maxMCycle.toString()}`);
77
- }
78
- if (bootOptions.store) {
79
- args.push(`--store=${bootOptions.store}`);
80
- }
81
- if (user) {
82
- args.push(`--user=${user}`);
83
- }
84
- args.push("--");
85
- args.push(entrypoint);
86
- return cartesiMachine.boot(args, {
87
- image: config.sdk,
88
- ...options,
89
- });
90
- };
package/dist/prompts.d.ts DELETED
@@ -1,73 +0,0 @@
1
- import { Separator } from "@inquirer/core";
2
- import input from "@inquirer/input";
3
- import select from "@inquirer/select";
4
- import type { Context } from "@inquirer/type";
5
- import { type Address, type Hex } from "viem";
6
- type InputConfig = Parameters<typeof input>[0];
7
- type SelectConfig<ValueType> = Parameters<typeof select<ValueType>>[0];
8
- /**
9
- * Prompt for an address value.
10
- * @param config inquirer config
11
- * @returns address
12
- */
13
- export type AddressPromptConfig = InputConfig & {
14
- default?: Address;
15
- };
16
- export declare const addressInput: (config: AddressPromptConfig) => Promise<Address>;
17
- /**
18
- * Prompt for a hex value.
19
- * @param config inquirer config
20
- * @returns hex
21
- */
22
- export type HexPromptConfig = InputConfig & {
23
- default?: Hex;
24
- };
25
- export declare const hexInput: (config: HexPromptConfig) => Promise<Hex>;
26
- export type BigintPromptConfig = InputConfig & {
27
- decimals: number;
28
- default?: bigint;
29
- };
30
- export declare const bigintInput: (config: BigintPromptConfig) => Promise<bigint>;
31
- /**
32
- * Prompt for a bytes input, by choosing from different encoding options.
33
- * @param config inquirer config
34
- * @returns bytes as hex string
35
- */
36
- export declare const bytesInput: (config: InputConfig & {
37
- encoding?: "string" | "hex" | "abi";
38
- message: string;
39
- }) => Promise<Hex>;
40
- /**
41
- * Prompt for ABI encoded parameters.
42
- * @param config inquirer config
43
- * @returns ABI encoded parameters as hex string
44
- */
45
- export declare const abiParamsInput: (config: InputConfig & {
46
- message: string;
47
- }) => Promise<`0x${string}`>;
48
- export type Choice<ValueType> = {
49
- value: ValueType;
50
- name?: string;
51
- description?: string;
52
- disabled?: boolean | string;
53
- type?: never;
54
- };
55
- export type SelectAutoConfig<ValueType> = SelectConfig<ValueType> & {
56
- choices: ReadonlyArray<Choice<ValueType> | Separator>;
57
- pageSize?: number;
58
- };
59
- export declare const selectAuto: <ValueType>(config: SelectAutoConfig<ValueType> & {
60
- discardDisabled?: boolean;
61
- }, context?: Context | undefined) => Promise<ValueType>;
62
- export declare const keySelect: <Value>(config: {
63
- choices: readonly Choice<Value>[];
64
- separator?: string | undefined;
65
- }, context?: Context) => Promise<Value> & {
66
- cancel: () => void;
67
- };
68
- export declare const getInputApplicationAddress: (options: {
69
- application?: string;
70
- projectName?: string;
71
- }) => Promise<Address>;
72
- export {};
73
- //# sourceMappingURL=prompts.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../src/prompts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAA6B,MAAM,gBAAgB,CAAC;AACtE,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EACH,KAAK,OAAO,EACZ,KAAK,GAAG,EASX,MAAM,MAAM,CAAC;AAGd,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,KAAK,CAA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