@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,67 +1,130 @@
1
- import { Command } from "@commander-js/extra-typings";
2
- import input from "@inquirer/input";
3
- import select from "@inquirer/select";
4
- import { isAddress, } from "viem";
5
- import { parseAddress } from "../base.js";
6
- import { getApplicationAddress } from "../exec/rollups.js";
7
- import createClients, { supportedChains } from "../wallet.js";
8
- import { createErc20Command } from "./send/erc20.js";
9
- import { createErc721Command } from "./send/erc721.js";
10
- import { createEtherCommand } from "./send/ether.js";
11
- import { createGenericCommand } from "./send/generic.js";
12
- export const connect = (options) => {
13
- const { chainId, rpcUrl, mnemonic, mnemonicIndex } = options;
14
- // create viem clients
15
- return createClients({
16
- chain: supportedChains({ includeDevnet: true }).find((c) => c.id === chainId),
17
- rpcUrl,
18
- mnemonicPassphrase: mnemonic,
19
- mnemonicIndex,
20
- });
21
- };
22
- export const getInputApplicationAddress = async (dapp) => {
23
- if (dapp && isAddress(dapp)) {
24
- // honor the flag
25
- return dapp;
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 { getProjectName } from "../base.js";
5
+ import { inputBoxAbi, inputBoxAddress } from "../contracts.js";
6
+ import { bytesInput, getInputApplicationAddress } from "../prompts.js";
7
+ import { connect } from "../wallet.js";
8
+ const getInput = async (input, options) => {
9
+ const { encoding } = options;
10
+ if (input) {
11
+ if (encoding === "hex") {
12
+ // validate if is a hex value
13
+ if (!isHex(input)) {
14
+ throw new Error("input encoded as hex must start with 0x");
15
+ }
16
+ return input;
17
+ }
18
+ if (encoding === "string") {
19
+ // encode UTF-8 string as hex
20
+ return stringToHex(input);
21
+ }
22
+ if (encoding === "abi") {
23
+ const abiParams = options.abiParams;
24
+ if (!abiParams) {
25
+ throw new Error("Undefined input-abi-params");
26
+ }
27
+ const abiParameters = parseAbiParameters(abiParams);
28
+ // TODO: decode values
29
+ const values = input.split(",").map((v, index) => {
30
+ if (index >= abiParameters.length) {
31
+ throw new Error(`Too many values, expected ${abiParameters.length} values based on --input-abi-params '${abiParams}', parsing value at index ${index} from input '${input}'`);
32
+ }
33
+ const param = abiParameters[index];
34
+ switch (param.type) {
35
+ case "string":
36
+ return v;
37
+ case "bool":
38
+ if (v === "true")
39
+ return true;
40
+ if (v === "false")
41
+ return false;
42
+ throw new Error(`Invalid boolean value: ${v}`);
43
+ case "uint":
44
+ case "uint8":
45
+ case "uint16":
46
+ case "uint32":
47
+ case "uint64":
48
+ case "uint128":
49
+ case "uint256":
50
+ try {
51
+ return BigInt(v);
52
+ }
53
+ catch (e) {
54
+ throw new Error(`Invalid uint value: ${v}`);
55
+ }
56
+ case "bytes":
57
+ if (isHex(v)) {
58
+ return v;
59
+ }
60
+ throw new Error(`Invalid bytes value: ${v}`);
61
+ case "address":
62
+ if (isAddress(v)) {
63
+ return getAddress(v);
64
+ }
65
+ throw new Error(`Invalid address value: ${v}`);
66
+ default:
67
+ throw new Error(`Unsupported type ${param.type}`);
68
+ }
69
+ });
70
+ if (values.length !== abiParameters.length) {
71
+ throw new Error(`Not enough values, expected ${abiParameters.length} values based on --input-abi-params '${abiParams}', parsed ${values.length} values from input '${input}'`);
72
+ }
73
+ return encodeAbiParameters(abiParameters, values);
74
+ }
75
+ if (isHex(input)) {
76
+ // encoding not specified, if starts with 0x, assume hex
77
+ return input;
78
+ }
79
+ // encode UTF-8 string as hex
80
+ return stringToHex(input);
26
81
  }
27
- // get the running container dapp address
28
- const nodeAddress = await getApplicationAddress();
29
- // query for the address
30
- const applicationAddress = await input({
31
- message: "Application address",
32
- validate: (value) => isAddress(value) || "Invalid address",
33
- default: nodeAddress,
34
- });
35
- return applicationAddress;
82
+ return undefined;
36
83
  };
37
84
  export const createSendCommand = () => {
38
85
  const command = new Command("send")
39
- .description("Sends different kinds of input to the application in interactive mode.")
40
- .option("--chain-id <id>", "Chain ID", Number.parseInt, 13370)
41
- .option("--rpc-url <url>", "RPC URL")
42
- .option("--mnemonic <phrase>", "Mnemonic passphrase")
43
- .option("--mnemonic-index <index>", "Mnemonic account index", Number.parseInt, 0)
44
- .option("--dapp <address>", "Application address", parseAddress, undefined)
45
- .action(async (options, program) => {
46
- // Get the registered subcommands from the program
47
- const commands = program.commands;
48
- // Create choices for the select prompt based on registered commands
49
- const choices = commands.map((cmd) => ({
50
- name: cmd.name(),
51
- value: cmd,
52
- description: cmd.description(),
53
- }));
54
- // Present the list of subcommands using @inquirer/select
55
- const subcommand = await select({
56
- message: "Select the type of input to send",
57
- choices,
86
+ .description("Send input to the application")
87
+ .argument("[input]", "input payload")
88
+ .option("--from <address>", "input sender address")
89
+ .option("--application <address>", "application address")
90
+ .addOption(new Option("--encoding <encoding>", "input encoding").choices([
91
+ "hex",
92
+ "string",
93
+ "abi",
94
+ ]))
95
+ .option("--abi-params <abi-params>", "input abi params")
96
+ .option("--project-name <string>", "name of project (used by docker compose and cartesi-rollups-node)")
97
+ .option("--rpc-url <url>", "RPC URL of the Cartesi Devnet")
98
+ .action(async (input, options, program) => {
99
+ const { application, from } = options;
100
+ const projectName = getProjectName(options);
101
+ // connect to anvil
102
+ const testClient = await connect(options);
103
+ // the input sender, impersonated
104
+ const account = from && isAddress(from)
105
+ ? getAddress(from)
106
+ : (await testClient.getAddresses())[0];
107
+ // get dapp address from local node, or ask
108
+ const applicationAddress = await getInputApplicationAddress({
109
+ application,
110
+ projectName,
111
+ });
112
+ const payload = (await getInput(input, options)) ||
113
+ (await bytesInput({
114
+ encoding: options.encoding,
115
+ message: "Input",
116
+ }));
117
+ const { request } = await testClient.simulateContract({
118
+ address: inputBoxAddress,
119
+ abi: inputBoxAbi,
120
+ account,
121
+ args: [applicationAddress, payload],
122
+ functionName: "addInput",
58
123
  });
59
- // Execute the selected subcommand
60
- subcommand.parseAsync(program.args);
124
+ const hash = await testClient.writeContract(request);
125
+ const progress = ora("Sending input...").start();
126
+ await testClient.waitForTransactionReceipt({ hash });
127
+ progress.succeed(`Input sent: ${hash}`);
61
128
  });
62
- command.addCommand(createGenericCommand());
63
- command.addCommand(createErc20Command());
64
- command.addCommand(createErc721Command());
65
- command.addCommand(createEtherCommand());
66
129
  return command;
67
130
  };
@@ -1,6 +1,6 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
2
  export declare const createStatusCommand: () => Command<[], {
3
- environmentName: string;
3
+ projectName?: string | undefined;
4
4
  json?: true | undefined;
5
5
  }, {}>;
6
6
  //# sourceMappingURL=status.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAOtD,eAAO,MAAM,mBAAmB;;;MAkD/B,CAAC"}
1
+ {"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/commands/status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAMtD,eAAO,MAAM,mBAAmB;;;MAuD/B,CAAC"}
@@ -1,21 +1,24 @@
1
1
  import { Command } from "@commander-js/extra-typings";
2
2
  import chalk from "chalk";
3
3
  import Table from "cli-table3";
4
- import { getServiceState } from "../base.js";
5
- import { DEFAULT_COMPOSE_ENVIRONMENT_NAME } from "../config.js";
4
+ import { getProjectName, getServiceState } from "../base.js";
6
5
  import { getDeployments } from "../exec/rollups.js";
7
6
  export const createStatusCommand = () => {
8
7
  return new Command("status")
9
8
  .description("Shows the status of a local environment.")
10
9
  .configureHelp({ showGlobalOptions: true })
11
- .option("--environment-name <string>", "name of environment", DEFAULT_COMPOSE_ENVIRONMENT_NAME)
10
+ .option("--project-name <string>", "name of project (used by docker compose and cartesi-rollups-node)")
12
11
  .option("--json", "output in JSON format")
13
- .action(async ({ environmentName, json }, command) => {
12
+ .action(async (options) => {
13
+ const { json } = options;
14
+ const projectName = getProjectName(options);
14
15
  const status = await getServiceState({
15
- environmentName,
16
+ projectName,
16
17
  service: "rollups-node",
17
18
  });
18
- const deployments = await getDeployments({ environmentName });
19
+ const deployments = await getDeployments({
20
+ projectName,
21
+ });
19
22
  if (json) {
20
23
  process.stdout.write(JSON.stringify({
21
24
  status,
@@ -23,7 +26,7 @@ export const createStatusCommand = () => {
23
26
  }));
24
27
  }
25
28
  else {
26
- console.log(`${chalk.cyan(environmentName)} is ${status === "running" ? chalk.green("running") : chalk.red("not running")}`);
29
+ console.log(`${chalk.cyan(projectName)} is ${status === "running" ? chalk.green("running") : chalk.red("not running")}`);
27
30
  if (status === "running") {
28
31
  if (deployments.length === 0) {
29
32
  console.log(chalk.red("no applications deployed"));
@@ -24,7 +24,7 @@ CARTESI_BLOCKCHAIN_WS_ENDPOINT="${CARTESI_BLOCKCHAIN_WS_ENDPOINT:-ws://anvil:854
24
24
  CARTESI_BLOCKCHAIN_DEFAULT_BLOCK="${CARTESI_BLOCKCHAIN_DEFAULT_BLOCK:-latest}"
25
25
 
26
26
  # contracts
27
- CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS="${CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS:-0xc700285Ab555eeB5201BC00CFD4b2CC8DED90051}"
27
+ CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS="${CARTESI_CONTRACTS_APPLICATION_FACTORY_ADDRESS:-0xc7006f70875BaDe89032001262A846D3Ee160051}"
28
28
  CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS="${CARTESI_CONTRACTS_AUTHORITY_FACTORY_ADDRESS:-0xC7003566dD09Aa0fC0Ce201aC2769aFAe3BF0051}"
29
29
  CARTESI_CONTRACTS_INPUT_BOX_ADDRESS="${CARTESI_CONTRACTS_INPUT_BOX_ADDRESS:-0xc70074BDD26d8cF983Ca6A5b89b8db52D5850051}"
30
30
  CARTESI_CONTRACTS_SELF_HOSTED_APPLICATION_FACTORY_ADDRESS="${CARTESI_CONTRACTS_SELF_HOSTED_APPLICATION_FACTORY_ADDRESS:-0xc700285Ab555eeB5201BC00CFD4b2CC8DED90051}"
@@ -22,7 +22,7 @@ configs:
22
22
  services:
23
23
  anvil:
24
24
  image: ${CARTESI_SDK_IMAGE}
25
- command: ["devnet", "--block-time", "${CARTESI_BLOCK_TIME:-5}"]
25
+ command: ["devnet", "--block-time", "${CARTESI_BLOCK_TIME:-2}"]
26
26
  healthcheck:
27
27
  test: ["CMD", "eth_isready"]
28
28
  start_period: 10s
@@ -42,12 +42,9 @@ services:
42
42
  env_file:
43
43
  - ${CARTESI_BIN_PATH}/compose/default.env
44
44
  volumes:
45
- - snapshots:/var/lib/cartesi-rollups-node/snapshots
45
+ - ./.cartesi:/var/lib/cartesi-rollups-node/snapshots:ro
46
46
 
47
47
  proxy:
48
48
  configs:
49
49
  - source: rollups_node_proxy
50
50
  target: /etc/traefik/conf.d/rollups-node.yaml
51
-
52
- volumes:
53
- snapshots:
package/dist/config.d.ts CHANGED
@@ -29,9 +29,9 @@ export declare class RequiredFieldError extends Error {
29
29
  export declare class InvalidStringArrayError extends Error {
30
30
  constructor();
31
31
  }
32
- export declare const DEFAULT_COMPOSE_ENVIRONMENT_NAME = "cartesi-rollups";
33
- export declare const DEFAULT_SDK_VERSION = "0.12.0-alpha.19";
32
+ export declare const DEFAULT_SDK_VERSION = "0.12.0-alpha.20";
34
33
  export declare const DEFAULT_SDK_IMAGE = "cartesi/sdk";
34
+ export declare const PREFERRED_PORT = 6751;
35
35
  type DriveFormat = "ext2" | "sqfs";
36
36
  export type ImageInfo = {
37
37
  cmd: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,WAAW,CAAC;AAEnE;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;gBAC9B,OAAO,EAAE,aAAa;CAIrC;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBAClC,MAAM,EAAE,aAAa;CAIpC;AAED,qBAAa,4BAA6B,SAAQ,KAAK;gBACvC,MAAM,EAAE,aAAa;CAIpC;AAED,qBAAa,uBAAwB,SAAQ,KAAK;gBAClC,KAAK,EAAE,aAAa;CAInC;AAED,qBAAa,wBAAyB,SAAQ,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EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IACxB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACpC,OAAO,EAAE,aAAa,CAAC;IACvB,GAAG,EAAE,MAAM,CAAC;CACf,CAAC;AAIF,eAAO,MAAM,sBAAsB,QAAO,WAOxC,CAAC;AAEH,eAAO,MAAM,oBAAoB,QAAO,aAYtC,CAAC;AAEH,eAAO,MAAM,aAAa,QAAO,MAI/B,CAAC;AA+LH,eAAO,MAAM,cAAc,GAAI,UAAU,MAAM,KAAG,WAUjD,CAAC;AA0GF,eAAO,MAAM,KAAK,GAAI,KAAK,MAAM,KAAG,MAanC,CAAC"}
package/dist/config.js CHANGED
@@ -58,15 +58,15 @@ export class InvalidStringArrayError extends Error {
58
58
  this.name = "InvalidStringArrayError";
59
59
  }
60
60
  }
61
- export const DEFAULT_COMPOSE_ENVIRONMENT_NAME = "cartesi-rollups";
62
61
  /**
63
62
  * Configuration for drives of a Cartesi Machine. A drive may already exist or be built by a builder
64
63
  */
65
64
  const DEFAULT_FORMAT = "ext2";
66
65
  const DEFAULT_RAM = "128Mi";
67
66
  const DEFAULT_RAM_IMAGE = "/usr/share/cartesi-machine/images/linux.bin";
68
- export const DEFAULT_SDK_VERSION = "0.12.0-alpha.19";
67
+ export const DEFAULT_SDK_VERSION = "0.12.0-alpha.20";
69
68
  export const DEFAULT_SDK_IMAGE = "cartesi/sdk";
69
+ export const PREFERRED_PORT = 6751;
70
70
  export const defaultRootDriveConfig = () => ({
71
71
  builder: "docker",
72
72
  context: ".",
@@ -1,6 +1,6 @@
1
1
  import { Range, parse } from "semver";
2
2
  import { execaDockerFallback, } from "./util.js";
3
- export const requiredVersion = new Range("^0.18.1");
3
+ export const requiredVersion = new Range("^0.19.0");
4
4
  export const boot = async (args, options) => {
5
5
  return execaDockerFallback("cartesi-machine", args, options);
6
6
  };
@@ -1,16 +1,105 @@
1
- import type { Address, Hash } from "viem";
1
+ import { type Address, type Hash, type Hex } from "viem";
2
2
  export type RollupsDeployment = {
3
3
  name: string;
4
4
  address: Address;
5
+ consensus: Address;
5
6
  templateHash: Hash;
6
7
  epochLength: number;
7
8
  state: "ENABLED" | "DISABLED";
8
9
  };
9
10
  type ComposeParams = {
10
- environmentName?: string;
11
+ projectName: string;
11
12
  };
12
- export declare const getDeployments: (options?: ComposeParams) => Promise<RollupsDeployment[]>;
13
- export declare const getApplicationDeployment: (options?: ComposeParams) => Promise<RollupsDeployment | undefined>;
14
- export declare const getApplicationAddress: () => Promise<Address | undefined>;
13
+ export declare const getDeployments: (options: ComposeParams) => Promise<RollupsDeployment[]>;
14
+ export declare const getApplicationDeployment: (options: ComposeParams) => Promise<RollupsDeployment | undefined>;
15
+ export declare const getApplicationAddress: (options: {
16
+ projectName?: string;
17
+ }) => Promise<Address | undefined>;
18
+ export declare const AVAILABLE_SERVICES: string[];
19
+ export declare const startEnvironment: (options: {
20
+ blockTime: number;
21
+ cpus?: number;
22
+ defaultBlock: string;
23
+ dryRun: boolean;
24
+ memory?: number;
25
+ port: number;
26
+ projectName: string;
27
+ runtimeVersion: string;
28
+ services: string[];
29
+ verbose: boolean;
30
+ }) => Promise<{
31
+ address: string;
32
+ config: string;
33
+ } | {
34
+ address: string;
35
+ config?: undefined;
36
+ }>;
37
+ /**
38
+ * Wait for the environment to be healthy
39
+ * @param options
40
+ */
41
+ export declare const waitHealthyEnvironment: (options: {
42
+ name?: string;
43
+ port: number;
44
+ projectName: string;
45
+ services: string[];
46
+ }) => Promise<void>;
47
+ /**
48
+ * Publish machine snapshot to rollups node by copying it to the rollups node container
49
+ * @param options
50
+ * @returns path to the snapshot in the rollups node
51
+ */
52
+ export declare const publishMachine: (options: {
53
+ projectName: string;
54
+ templateHash: Hash;
55
+ }) => Promise<string>;
56
+ /**
57
+ * Stop an environment by removing the containers and volumes
58
+ * @param options
59
+ * @returns
60
+ */
61
+ export declare const stopEnvironment: (options: {
62
+ projectName: string;
63
+ }) => Promise<import("execa").Result<{}>>;
64
+ /**
65
+ * Deploy application to rollups node
66
+ * @param options
67
+ * @returns address of the application
68
+ */
69
+ export declare const deployAuthority: (options: {
70
+ epochLength: number;
71
+ projectName: string;
72
+ }) => Promise<Address>;
73
+ /**
74
+ * Deploy application to rollups node
75
+ * @param options
76
+ * @returns address of the application
77
+ */
78
+ export declare const deployApplication: (options: {
79
+ consensus?: Address;
80
+ epochLength: number;
81
+ name: string;
82
+ projectName: string;
83
+ salt?: Hex;
84
+ snapshotPath: string;
85
+ }) => Promise<RollupsDeployment>;
86
+ /**
87
+ * Remove application from rollups node
88
+ * @param options
89
+ * @returns
90
+ */
91
+ export declare const removeApplication: (options: {
92
+ application: string | Address;
93
+ force: boolean;
94
+ projectName: string;
95
+ }) => Promise<import("execa").Result<{}>>;
96
+ /**
97
+ * Get the host and port of the docker compose project entrypoint
98
+ * @param options
99
+ * @returns port of the proxy service
100
+ */
101
+ export declare const getProjectPort: (options: {
102
+ projectName: string;
103
+ }) => Promise<string>;
15
104
  export {};
16
105
  //# sourceMappingURL=rollups.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollups.d.ts","sourceRoot":"","sources":["../../src/exec/rollups.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,IA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