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

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 (170) hide show
  1. package/dist/base.d.ts +28 -0
  2. package/dist/base.d.ts.map +1 -0
  3. package/dist/base.js +109 -0
  4. package/dist/builder/directory.d.ts +2 -2
  5. package/dist/builder/directory.d.ts.map +1 -1
  6. package/dist/builder/directory.js +5 -3
  7. package/dist/builder/docker.d.ts +2 -2
  8. package/dist/builder/docker.d.ts.map +1 -1
  9. package/dist/builder/docker.js +39 -37
  10. package/dist/builder/empty.d.ts +1 -1
  11. package/dist/builder/empty.d.ts.map +1 -1
  12. package/dist/builder/empty.js +1 -1
  13. package/dist/builder/none.d.ts +1 -1
  14. package/dist/builder/none.d.ts.map +1 -1
  15. package/dist/builder/none.js +1 -1
  16. package/dist/builder/tar.d.ts +1 -1
  17. package/dist/builder/tar.d.ts.map +1 -1
  18. package/dist/builder/tar.js +1 -1
  19. package/dist/commands/address-book.d.ts +5 -8
  20. package/dist/commands/address-book.d.ts.map +1 -1
  21. package/dist/commands/address-book.js +18 -14
  22. package/dist/commands/build.d.ts +7 -11
  23. package/dist/commands/build.d.ts.map +1 -1
  24. package/dist/commands/build.js +82 -58
  25. package/dist/commands/clean.d.ts +2 -7
  26. package/dist/commands/clean.d.ts.map +1 -1
  27. package/dist/commands/clean.js +9 -10
  28. package/dist/commands/create.d.ts +6 -15
  29. package/dist/commands/create.d.ts.map +1 -1
  30. package/dist/commands/create.js +25 -54
  31. package/dist/commands/deploy/build.d.ts +2 -14
  32. package/dist/commands/deploy/build.d.ts.map +1 -1
  33. package/dist/commands/deploy/build.js +8 -61
  34. package/dist/commands/deploy.d.ts +3 -0
  35. package/dist/commands/deploy.d.ts.map +1 -0
  36. package/dist/commands/deploy.js +12 -0
  37. package/dist/commands/deposit/erc1155.d.ts +18 -0
  38. package/dist/commands/deposit/erc1155.d.ts.map +1 -0
  39. package/dist/commands/deposit/erc1155.js +254 -0
  40. package/dist/commands/deposit/erc20.d.ts +10 -0
  41. package/dist/commands/deposit/erc20.d.ts.map +1 -0
  42. package/dist/commands/deposit/erc20.js +125 -0
  43. package/dist/commands/deposit/erc721.d.ts +10 -0
  44. package/dist/commands/deposit/erc721.d.ts.map +1 -0
  45. package/dist/commands/deposit/erc721.js +143 -0
  46. package/dist/commands/deposit/ether.d.ts +10 -0
  47. package/dist/commands/deposit/ether.d.ts.map +1 -0
  48. package/dist/commands/deposit/ether.js +65 -0
  49. package/dist/commands/deposit.d.ts +9 -0
  50. package/dist/commands/deposit.d.ts.map +1 -0
  51. package/dist/commands/deposit.js +37 -0
  52. package/dist/commands/doctor.d.ts +2 -12
  53. package/dist/commands/doctor.d.ts.map +1 -1
  54. package/dist/commands/doctor.js +90 -91
  55. package/dist/commands/hash.d.ts +4 -9
  56. package/dist/commands/hash.d.ts.map +1 -1
  57. package/dist/commands/hash.js +14 -14
  58. package/dist/commands/logs.d.ts +9 -0
  59. package/dist/commands/logs.d.ts.map +1 -0
  60. package/dist/commands/logs.js +34 -0
  61. package/dist/commands/run.d.ts +14 -20
  62. package/dist/commands/run.d.ts.map +1 -1
  63. package/dist/commands/run.js +193 -182
  64. package/dist/commands/send.d.ts +10 -0
  65. package/dist/commands/send.d.ts.map +1 -0
  66. package/dist/commands/send.js +130 -0
  67. package/dist/commands/shell.d.ts +6 -14
  68. package/dist/commands/shell.d.ts.map +1 -1
  69. package/dist/commands/shell.js +34 -51
  70. package/dist/commands/status.d.ts +6 -0
  71. package/dist/commands/status.d.ts.map +1 -0
  72. package/dist/commands/status.js +50 -0
  73. package/dist/compose/default.env +36 -0
  74. package/dist/compose/docker-compose-anvil.yaml +39 -0
  75. package/dist/compose/docker-compose-bundler.yaml +71 -0
  76. package/dist/{node → compose}/docker-compose-database.yaml +4 -2
  77. package/dist/compose/docker-compose-explorer.yaml +96 -0
  78. package/dist/compose/docker-compose-graphql.yaml +38 -0
  79. package/dist/compose/docker-compose-node-cpus.yaml +6 -0
  80. package/dist/compose/docker-compose-node-memory.yaml +6 -0
  81. package/dist/compose/docker-compose-node.yaml +50 -0
  82. package/dist/compose/docker-compose-passkey-server.yaml +37 -0
  83. package/dist/compose/docker-compose-paymaster.yaml +40 -0
  84. package/dist/compose/docker-compose-proxy.yaml +24 -0
  85. package/dist/config.d.ts +30 -9
  86. package/dist/config.d.ts.map +1 -1
  87. package/dist/config.js +93 -53
  88. package/dist/contracts.d.ts +1695 -1636
  89. package/dist/contracts.d.ts.map +1 -1
  90. package/dist/contracts.js +632 -592
  91. package/dist/exec/cartesi-machine.d.ts +2 -2
  92. package/dist/exec/cartesi-machine.d.ts.map +1 -1
  93. package/dist/exec/cartesi-machine.js +3 -5
  94. package/dist/exec/genext2fs.d.ts +6 -3
  95. package/dist/exec/genext2fs.d.ts.map +1 -1
  96. package/dist/exec/genext2fs.js +5 -5
  97. package/dist/exec/index.d.ts +0 -1
  98. package/dist/exec/index.d.ts.map +1 -1
  99. package/dist/exec/index.js +0 -1
  100. package/dist/exec/mksquashfs.d.ts +2 -2
  101. package/dist/exec/mksquashfs.d.ts.map +1 -1
  102. package/dist/exec/mksquashfs.js +4 -2
  103. package/dist/exec/rollups.d.ts +105 -0
  104. package/dist/exec/rollups.d.ts.map +1 -0
  105. package/dist/exec/rollups.js +383 -0
  106. package/dist/exec/util.d.ts +1 -16
  107. package/dist/exec/util.d.ts.map +1 -1
  108. package/dist/exec/util.js +3 -50
  109. package/dist/index.d.ts +2 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +57 -1
  112. package/dist/machine.d.ts +8 -2
  113. package/dist/machine.d.ts.map +1 -1
  114. package/dist/machine.js +26 -16
  115. package/dist/prompts.d.ts +13 -2
  116. package/dist/prompts.d.ts.map +1 -1
  117. package/dist/prompts.js +60 -26
  118. package/dist/template.d.ts +3 -0
  119. package/dist/template.d.ts.map +1 -0
  120. package/dist/template.js +16 -0
  121. package/dist/wallet.d.ts +9222 -21
  122. package/dist/wallet.d.ts.map +1 -1
  123. package/dist/wallet.js +35 -198
  124. package/package.json +39 -57
  125. package/bin/dev.cmd +0 -3
  126. package/bin/dev.js +0 -25
  127. package/bin/run.cmd +0 -3
  128. package/bin/run.js +0 -8
  129. package/dist/baseCommand.d.ts +0 -22
  130. package/dist/baseCommand.d.ts.map +0 -1
  131. package/dist/baseCommand.js +0 -92
  132. package/dist/commands/deploy/index.d.ts +0 -12
  133. package/dist/commands/deploy/index.d.ts.map +0 -1
  134. package/dist/commands/deploy/index.js +0 -78
  135. package/dist/commands/send/erc20.d.ts +0 -14
  136. package/dist/commands/send/erc20.d.ts.map +0 -1
  137. package/dist/commands/send/erc20.js +0 -70
  138. package/dist/commands/send/erc721.d.ts +0 -14
  139. package/dist/commands/send/erc721.d.ts.map +0 -1
  140. package/dist/commands/send/erc721.js +0 -73
  141. package/dist/commands/send/ether.d.ts +0 -13
  142. package/dist/commands/send/ether.d.ts.map +0 -1
  143. package/dist/commands/send/ether.js +0 -32
  144. package/dist/commands/send/generic.d.ts +0 -15
  145. package/dist/commands/send/generic.d.ts.map +0 -1
  146. package/dist/commands/send/generic.js +0 -119
  147. package/dist/commands/send/index.d.ts +0 -28
  148. package/dist/commands/send/index.d.ts.map +0 -1
  149. package/dist/commands/send/index.js +0 -102
  150. package/dist/exec/crane.d.ts +0 -15
  151. package/dist/exec/crane.d.ts.map +0 -1
  152. package/dist/exec/crane.js +0 -17
  153. package/dist/flags.d.ts +0 -17
  154. package/dist/flags.d.ts.map +0 -1
  155. package/dist/flags.js +0 -28
  156. package/dist/node/DockerfileDeploy.txt +0 -4
  157. package/dist/node/default.env +0 -27
  158. package/dist/node/docker-compose-anvil.yaml +0 -50
  159. package/dist/node/docker-compose-bundler.yaml +0 -57
  160. package/dist/node/docker-compose-envfile.yaml +0 -4
  161. package/dist/node/docker-compose-explorer.yaml +0 -88
  162. package/dist/node/docker-compose-host.yaml +0 -30
  163. package/dist/node/docker-compose-paymaster.yaml +0 -33
  164. package/dist/node/docker-compose-prompt.yaml +0 -17
  165. package/dist/node/docker-compose-proxy.yaml +0 -48
  166. package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
  167. package/dist/node/docker-compose-validator-cpus.yaml +0 -6
  168. package/dist/node/docker-compose-validator-memory.yaml +0 -6
  169. package/dist/node/docker-compose-validator.yaml +0 -59
  170. package/oclif.manifest.json +0 -876
@@ -1,78 +0,0 @@
1
- import confirm from "@inquirer/confirm";
2
- import select from "@inquirer/select";
3
- import { Flags } from "@oclif/core";
4
- import chalk from "chalk";
5
- import open, { apps } from "open";
6
- import { BaseCommand } from "../../baseCommand.js";
7
- class Deploy extends BaseCommand {
8
- async run() {
9
- const { flags } = await this.parse(Deploy);
10
- // print machine hash
11
- const templateHash = this.getMachineHash();
12
- if (!templateHash) {
13
- this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
14
- }
15
- this.logPrompt({
16
- title: "Cartesi machine templateHash",
17
- value: templateHash,
18
- });
19
- // ask for deployment type
20
- const hosting = flags.hosting ||
21
- (await select({
22
- message: "Select hosting type",
23
- choices: [
24
- {
25
- name: "Self-hosting",
26
- description: `Select this option if you want to run the node for your application.
27
- You will need the following infrastructure:
28
-
29
- - a cloud server for the application node
30
- - a postgres database
31
- - a web3 node provider
32
- - a funded wallet
33
- `,
34
- value: "self-hosted",
35
- },
36
- {
37
- name: "Use third-party provider",
38
- description: "Select this option to use a third-party service provider to run a node for your application.",
39
- value: "third-party",
40
- disabled: "(coming soon)",
41
- },
42
- ],
43
- }));
44
- let queryString = "";
45
- switch (hosting) {
46
- case "self-hosted": {
47
- // build docker image
48
- await this.config.runCommand("deploy:build");
49
- queryString = `?templateHash=${templateHash}`;
50
- break;
51
- }
52
- case "third-party": {
53
- this.error("Third-party provider deployment not supported yet");
54
- }
55
- }
56
- // prompt user to open webapp for onchain deployment
57
- const deployUrl = `${flags.webapp}${queryString}`;
58
- if (await confirm({ message: `Open ${chalk.cyan(deployUrl)}?` })) {
59
- open(deployUrl, { app: { name: apps.chrome } });
60
- }
61
- return;
62
- }
63
- }
64
- Deploy.summary = "Deploy application to a live network.";
65
- Deploy.description = "Package and deploy the application to a supported live network.";
66
- Deploy.examples = ["<%= config.bin %> <%= command.id %>"];
67
- Deploy.flags = {
68
- hosting: Flags.string({
69
- options: ["self-hosted", "third-party"],
70
- summary: "hosting type",
71
- description: "Select wheather the user will host an application node himself, or use a third-party node provider",
72
- }),
73
- webapp: Flags.url({
74
- description: "address of deploy webapp",
75
- required: true,
76
- }),
77
- };
78
- export default Deploy;
@@ -1,14 +0,0 @@
1
- import { Address, PublicClient, WalletClient } from "viem";
2
- import { SendBaseCommand } from "./index.js";
3
- export default class SendERC20 extends SendBaseCommand<typeof SendERC20> {
4
- static summary: string;
5
- static description: string;
6
- static flags: {
7
- token: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`0x${string}` | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- amount: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`${number}` | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- };
10
- static examples: string[];
11
- private readToken;
12
- send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
13
- }
14
- //# sourceMappingURL=erc20.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"erc20.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc20.ts"],"names":[],"mappings":"AACA,OAAO,EACH,OAAO,EAIP,YAAY,EACZ,YAAY,EACf,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAQ7C,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,eAAe,CAAC,OAAO,SAAS,CAAC;IACpE,MAAM,CAAC,OAAO,SAA6C;IAE3D,MAAM,CAAC,WAAW,SAC8D;IAEhF,MAAM,CAAC,KAAK;;;MAGV;IAEF,MAAM,CAAC,QAAQ,WAA2C;YAE5C,SAAS;IAwBV,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CA2CtB"}
@@ -1,70 +0,0 @@
1
- import input from "@inquirer/input";
2
- import { erc20Abi, isAddress, parseEther, } from "viem";
3
- import { erc20PortalAbi, erc20PortalAddress } from "../../contracts.js";
4
- import * as CustomFlags from "../../flags.js";
5
- import { SendBaseCommand } from "./index.js";
6
- class SendERC20 extends SendBaseCommand {
7
- async readToken(publicClient, address) {
8
- const args = { abi: erc20Abi, 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
- const decimals = await publicClient.readContract({
18
- ...args,
19
- functionName: "decimals",
20
- });
21
- return {
22
- name,
23
- symbol,
24
- decimals,
25
- };
26
- }
27
- async send(publicClient, walletClient) {
28
- // get dapp address from local node, or ask
29
- const applicationAddress = await super.getApplicationAddress();
30
- const ercValidator = async (value) => {
31
- if (!isAddress(value)) {
32
- return "Invalid address";
33
- }
34
- try {
35
- await this.readToken(publicClient, value);
36
- }
37
- catch (e) {
38
- return "Invalid token";
39
- }
40
- return true;
41
- };
42
- const tokenAddress = this.flags.token ||
43
- (await input({
44
- message: "Token address",
45
- validate: ercValidator,
46
- }));
47
- const amount = this.flags.amount || (await input({ message: "Amount" }));
48
- const { request } = await publicClient.simulateContract({
49
- address: erc20PortalAddress,
50
- abi: erc20PortalAbi,
51
- functionName: "depositERC20Tokens",
52
- args: [
53
- tokenAddress,
54
- applicationAddress,
55
- parseEther(amount),
56
- "0x",
57
- ],
58
- account: walletClient.account,
59
- });
60
- return walletClient.writeContract(request);
61
- }
62
- }
63
- SendERC20.summary = "Send ERC-20 deposit to the application.";
64
- SendERC20.description = "Sends ERC-20 deposits to the application, optionally in interactive mode.";
65
- SendERC20.flags = {
66
- token: CustomFlags.address({ description: "token address" }),
67
- amount: CustomFlags.number({ description: "amount" }),
68
- };
69
- SendERC20.examples = ["<%= config.bin %> <%= command.id %>"];
70
- export default SendERC20;
@@ -1,14 +0,0 @@
1
- import { Address, PublicClient, WalletClient } from "viem";
2
- import { SendBaseCommand } from "./index.js";
3
- export default class SendERC721 extends SendBaseCommand<typeof SendERC721> {
4
- static summary: string;
5
- static description: string;
6
- static flags: {
7
- token: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`0x${string}` | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- tokenId: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<bigint | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- };
10
- static examples: string[];
11
- private readToken;
12
- send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
13
- }
14
- //# sourceMappingURL=erc721.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"erc721.d.ts","sourceRoot":"","sources":["../../../src/commands/send/erc721.ts"],"names":[],"mappings":"AACA,OAAO,EACH,OAAO,EAGP,YAAY,EACZ,YAAY,EACf,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAO7C,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,eAAe,CAAC,OAAO,UAAU,CAAC;IACtE,MAAM,CAAC,OAAO,SAA8C;IAE5D,MAAM,CAAC,WAAW,SAC+D;IAEjF,MAAM,CAAC,KAAK;;;MAGV;IAEF,MAAM,CAAC,QAAQ,WAA2C;YAE5C,SAAS;IAmBV,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CAkDtB"}
@@ -1,73 +0,0 @@
1
- import input from "@inquirer/input";
2
- import { erc721Abi, isAddress, } from "viem";
3
- import { erc721PortalAbi, erc721PortalAddress } from "../../contracts.js";
4
- import * as CustomFlags from "../../flags.js";
5
- import { SendBaseCommand } from "./index.js";
6
- class SendERC721 extends SendBaseCommand {
7
- async readToken(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
- async send(publicClient, walletClient) {
23
- // get dapp address from local node, or ask
24
- const applicationAddress = await super.getApplicationAddress();
25
- const ercValidator = async (value) => {
26
- if (!isAddress(value)) {
27
- return "Invalid address";
28
- }
29
- try {
30
- await this.readToken(publicClient, value);
31
- }
32
- catch (e) {
33
- return "Invalid token";
34
- }
35
- return true;
36
- };
37
- const token = this.flags.token ||
38
- (await input({
39
- message: "Token address",
40
- validate: ercValidator,
41
- }));
42
- const tokenId = this.flags.tokenId ||
43
- (await input({
44
- message: "Token ID",
45
- validate: (value) => {
46
- try {
47
- BigInt(value);
48
- return true;
49
- }
50
- catch (e) {
51
- return "Invalid number";
52
- }
53
- },
54
- }));
55
- const { request } = await publicClient.simulateContract({
56
- address: erc721PortalAddress,
57
- abi: erc721PortalAbi,
58
- functionName: "depositERC721Token",
59
- args: [token, applicationAddress, BigInt(tokenId), "0x", "0x"],
60
- account: walletClient.account,
61
- });
62
- // XXX: add support for baseLayerData and execLayerData
63
- return walletClient.writeContract(request);
64
- }
65
- }
66
- SendERC721.summary = "Send ERC-721 deposit to the application.";
67
- SendERC721.description = "Sends ERC-721 deposits to the application, optionally in interactive mode.";
68
- SendERC721.flags = {
69
- token: CustomFlags.address({ description: "token address" }),
70
- tokenId: CustomFlags.bigint({ description: "token ID" }),
71
- };
72
- SendERC721.examples = ["<%= config.bin %> <%= command.id %>"];
73
- export default SendERC721;
@@ -1,13 +0,0 @@
1
- import { Address, PublicClient, WalletClient } from "viem";
2
- import { SendBaseCommand } from "./index.js";
3
- export default class SendEther extends SendBaseCommand<typeof SendEther> {
4
- static summary: string;
5
- static description: string;
6
- static flags: {
7
- amount: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`${number}` | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- execLayerData: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<`0x${string}`, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- };
10
- static examples: string[];
11
- send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
12
- }
13
- //# sourceMappingURL=ether.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ether.d.ts","sourceRoot":"","sources":["../../../src/commands/send/ether.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAc,YAAY,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAIvE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,eAAe,CAAC,OAAO,SAAS,CAAC;IACpE,MAAM,CAAC,OAAO,SAA4C;IAE1D,MAAM,CAAC,WAAW,SAC6D;IAE/E,MAAM,CAAC,KAAK;;;MAMV;IAEF,MAAM,CAAC,QAAQ,WAA2C;IAE7C,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CAkBtB"}
@@ -1,32 +0,0 @@
1
- import input from "@inquirer/input";
2
- import { parseEther } from "viem";
3
- import { etherPortalAbi, etherPortalAddress } from "../../contracts.js";
4
- import * as CustomFlags from "../../flags.js";
5
- import { SendBaseCommand } from "./index.js";
6
- class SendEther extends SendBaseCommand {
7
- async send(publicClient, walletClient) {
8
- // get dapp address from local node, or ask
9
- const applicationAddress = await super.getApplicationAddress();
10
- const amount = this.flags.amount || (await input({ message: "Amount" }));
11
- const { request } = await publicClient.simulateContract({
12
- address: etherPortalAddress,
13
- abi: etherPortalAbi,
14
- functionName: "depositEther",
15
- args: [applicationAddress, this.flags.execLayerData],
16
- value: parseEther(amount),
17
- account: walletClient.account,
18
- });
19
- return walletClient.writeContract(request);
20
- }
21
- }
22
- SendEther.summary = "Send ether deposit to the application.";
23
- SendEther.description = "Sends ether deposits to the application, optionally in interactive mode.";
24
- SendEther.flags = {
25
- amount: CustomFlags.number({ description: "amount, in ETH units" }),
26
- execLayerData: CustomFlags.hex({
27
- description: "exec layer data",
28
- default: "0x",
29
- }),
30
- };
31
- SendEther.examples = ["<%= config.bin %> <%= command.id %>"];
32
- export default SendEther;
@@ -1,15 +0,0 @@
1
- import { Address, PublicClient, WalletClient } from "viem";
2
- import { SendBaseCommand } from "./index.js";
3
- export default class SendGeneric extends SendBaseCommand<typeof SendGeneric> {
4
- static summary: string;
5
- static description: string;
6
- static examples: string[];
7
- static flags: {
8
- input: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
9
- "input-encoding": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
10
- "input-abi-params": import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
- };
12
- protected getInput(): Promise<`0x${string}` | undefined>;
13
- send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
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":"AACA,OAAO,EACH,OAAO,EACP,YAAY,EACZ,YAAY,EAOf,MAAM,MAAM,CAAC;AAId,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,eAAe,CAAC,OAAO,WAAW,CAAC;IACxE,MAAM,CAAC,OAAO,SAA4C;IAE1D,MAAM,CAAC,WAAW,SAC8D;IAEhF,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;;;MAgBV;cAEc,QAAQ,IAAI,OAAO,CAAC,KAAK,MAAM,EAAE,GAAG,SAAS,CAAC;IA8EjD,IAAI,CACb,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;CAgBtB"}
@@ -1,119 +0,0 @@
1
- import { Flags } from "@oclif/core";
2
- import { encodeAbiParameters, getAddress, isAddress, isHex, parseAbiParameters, stringToHex, } from "viem";
3
- import { inputBoxAbi, inputBoxAddress } from "../../contracts.js";
4
- import { bytesInput } from "../../prompts.js";
5
- import { SendBaseCommand } from "./index.js";
6
- class SendGeneric extends SendBaseCommand {
7
- async getInput() {
8
- const input = this.flags.input;
9
- const encoding = this.flags["input-encoding"];
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
- else if (encoding === "string") {
19
- // encode UTF-8 string as hex
20
- return stringToHex(input);
21
- }
22
- else if (encoding === "abi") {
23
- const abiParams = this.flags["input-abi-params"];
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
- else {
76
- if (isHex(input)) {
77
- return input;
78
- }
79
- else {
80
- // encode UTF-8 string as hex
81
- return stringToHex(input);
82
- }
83
- }
84
- }
85
- return undefined;
86
- }
87
- async send(publicClient, walletClient) {
88
- // get dapp address from local node, or ask
89
- const applicationAddress = await super.getApplicationAddress();
90
- const payload = (await this.getInput()) || (await bytesInput({ message: "Input" }));
91
- const { request } = await publicClient.simulateContract({
92
- address: inputBoxAddress,
93
- abi: inputBoxAbi,
94
- functionName: "addInput",
95
- args: [applicationAddress, payload],
96
- account: walletClient.account,
97
- });
98
- return walletClient.writeContract(request);
99
- }
100
- }
101
- SendGeneric.summary = "Send generic input to the application.";
102
- SendGeneric.description = "Sends generics inputs to the application, optionally in interactive mode.";
103
- SendGeneric.examples = ["<%= config.bin %> <%= command.id %>"];
104
- SendGeneric.flags = {
105
- input: Flags.string({
106
- description: "input payload",
107
- summary: "see input-encoding for definition on how input is parsed",
108
- }),
109
- "input-encoding": Flags.string({
110
- description: "input encoding",
111
- summary: "if input-encoding is undefined, the input is parsed as a hex-string if it starts with 0x or else is parsed as a UTF-8 encoding",
112
- options: ["hex", "string", "abi"],
113
- }),
114
- "input-abi-params": Flags.string({
115
- description: "input abi params",
116
- summary: "ABI params definition for input, following human-readable format specified at https://abitype.dev/api/human.html#parseabiparameters",
117
- }),
118
- };
119
- export default SendGeneric;
@@ -1,28 +0,0 @@
1
- import { Command, Interfaces } from "@oclif/core";
2
- import { Address, PublicClient, WalletClient } from "viem";
3
- import { BaseCommand } from "../../baseCommand.js";
4
- export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof SendBaseCommand)["baseFlags"] & T["flags"]>;
5
- export type Args<T extends typeof Command> = Interfaces.InferredArgs<T["args"]>;
6
- export declare abstract class SendBaseCommand<T extends typeof Command> extends BaseCommand<typeof SendBaseCommand> {
7
- static baseFlags: {
8
- dapp: Interfaces.OptionFlag<`0x${string}` | undefined, Interfaces.CustomOptions>;
9
- "chain-id": Interfaces.OptionFlag<number | undefined, Interfaces.CustomOptions>;
10
- "rpc-url": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
11
- "mnemonic-passphrase": Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
12
- "mnemonic-index": Interfaces.OptionFlag<number, Interfaces.CustomOptions>;
13
- };
14
- protected flags: Flags<T>;
15
- protected args: Args<T>;
16
- private connect;
17
- protected getApplicationAddress(): Promise<Address>;
18
- init(): Promise<void>;
19
- protected abstract send(publicClient: PublicClient, walletClient: WalletClient): Promise<Address>;
20
- run(): Promise<void>;
21
- }
22
- export default class Send extends Command {
23
- static summary: string;
24
- static description: string;
25
- static examples: string[];
26
- run(): Promise<void>;
27
- }
28
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/send/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AAE1E,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAa,MAAM,MAAM,CAAC;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAInD,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,aAAa,CAClE,CAAC,OAAO,eAAe,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CACrD,CAAC;AACF,MAAM,MAAM,IAAI,CAAC,CAAC,SAAS,OAAO,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAGhF,8BAAsB,eAAe,CACjC,CAAC,SAAS,OAAO,OAAO,CAC1B,SAAQ,WAAW,CAAC,OAAO,eAAe,CAAC;IACzC,MAAM,CAAC,SAAS;;;;;;MA8Bd;IAEF,SAAS,CAAC,KAAK,EAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,EAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAEX,OAAO;cAeL,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC;IAmB5C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAYlC,SAAS,CAAC,QAAQ,CAAC,IAAI,CACnB,YAAY,EAAE,YAAY,EAC1B,YAAY,EAAE,YAAY,GAC3B,OAAO,CAAC,OAAO,CAAC;IAEN,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAOpC;AAED,MAAM,CAAC,OAAO,OAAO,IAAK,SAAQ,OAAO;IACrC,MAAM,CAAC,OAAO,SAAoC;IAElD,MAAM,CAAC,WAAW,SAC2D;IAE7E,MAAM,CAAC,QAAQ,WAA2C;IAE7C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAmBpC"}
@@ -1,102 +0,0 @@
1
- import input from "@inquirer/input";
2
- import select from "@inquirer/select";
3
- import { Command, Flags as StandardFlags } from "@oclif/core";
4
- import ora from "ora";
5
- import { isAddress } from "viem";
6
- import { BaseCommand } from "../../baseCommand.js";
7
- import * as CustomFlags from "../../flags.js";
8
- import createClients, { supportedChains } from "../../wallet.js";
9
- // base command for sending input to the application
10
- export class SendBaseCommand extends BaseCommand {
11
- async connect() {
12
- // create viem clients
13
- return createClients({
14
- chain: supportedChains({ includeDevnet: true }).find((c) => c.id == this.flags["chain-id"]),
15
- rpcUrl: this.flags["rpc-url"],
16
- mnemonicPassphrase: this.flags["mnemonic-passphrase"],
17
- mnemonicIndex: this.flags["mnemonic-index"],
18
- });
19
- }
20
- async getApplicationAddress() {
21
- if (this.flags.dapp) {
22
- // honor the flag
23
- return this.flags.dapp;
24
- }
25
- // get the running container dapp address
26
- const nodeAddress = await super.getApplicationAddress();
27
- // query for the address
28
- const applicationAddress = await input({
29
- message: "Application address",
30
- validate: (value) => isAddress(value) || "Invalid address",
31
- default: nodeAddress,
32
- });
33
- return applicationAddress;
34
- }
35
- async init() {
36
- await super.init();
37
- const { args, flags } = await this.parse({
38
- flags: this.ctor.flags,
39
- baseFlags: super.ctor.baseFlags,
40
- args: this.ctor.args,
41
- strict: this.ctor.strict,
42
- });
43
- this.flags = flags;
44
- this.args = args;
45
- }
46
- async run() {
47
- const { publicClient, walletClient } = await this.connect();
48
- const hash = await this.send(publicClient, walletClient);
49
- const progress = ora("Sending input...").start();
50
- await publicClient.waitForTransactionReceipt({ hash });
51
- progress.succeed(`Input sent: ${hash}`);
52
- }
53
- }
54
- SendBaseCommand.baseFlags = {
55
- dapp: CustomFlags.address({
56
- summary: "dapp address.",
57
- description: "the address of the DApp, defaults to the deployed DApp address if application is running.",
58
- }),
59
- "chain-id": StandardFlags.integer({
60
- description: "The EIP-155 chain ID.",
61
- char: "c",
62
- env: "CHAIN",
63
- helpGroup: "Ethereum",
64
- options: supportedChains({ includeDevnet: true }).map((c) => c.id.toString()),
65
- }),
66
- "rpc-url": StandardFlags.string({
67
- description: "The RPC endpoint.",
68
- char: "r",
69
- env: "ETH_RPC_URL",
70
- helpGroup: "Ethereum",
71
- }),
72
- "mnemonic-passphrase": StandardFlags.string({
73
- description: "Use a BIP39 passphrase for the mnemonic.",
74
- helpGroup: "Wallet",
75
- }),
76
- "mnemonic-index": StandardFlags.integer({
77
- description: "Use the private key from the given mnemonic index.",
78
- helpGroup: "Wallet",
79
- default: 0,
80
- }),
81
- };
82
- class Send extends Command {
83
- async run() {
84
- // get all send sub-commands
85
- const sendCommands = this.config.commands.filter((command) => command.id.startsWith("send:"));
86
- // select the send sub-command
87
- const commandId = await select({
88
- message: "Select send sub-command",
89
- choices: sendCommands.map((command) => ({
90
- value: command.id,
91
- name: command.summary,
92
- description: command.description,
93
- })),
94
- });
95
- // invoke the sub-command
96
- await this.config.runCommand(commandId, this.argv);
97
- }
98
- }
99
- Send.summary = "Send input to the application.";
100
- Send.description = "Sends different kinds of input to the application in interactive mode.";
101
- Send.examples = ["<%= config.bin %> <%= command.id %>"];
102
- export default Send;
@@ -1,15 +0,0 @@
1
- import { Range, SemVer } from "semver";
2
- import { Stream } from "stream";
3
- import { DockerFallbackOptions } from "./util.js";
4
- export declare const requiredVersion: Range;
5
- export declare const exportImage: (options: {
6
- stdin: Stream | number;
7
- stdout: Stream | number;
8
- } & DockerFallbackOptions) => Promise<import("child_process").SpawnSyncReturns<string | Buffer> | {
9
- error: {
10
- code: string;
11
- };
12
- stdout: string;
13
- }>;
14
- export declare const version: (options?: DockerFallbackOptions) => Promise<SemVer | null>;
15
- //# sourceMappingURL=crane.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crane.d.ts","sourceRoot":"","sources":["../../src/exec/crane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,qBAAqB,EAA2B,MAAM,WAAW,CAAC;AAE3E,eAAO,MAAM,eAAe,OAAuB,CAAC;AAEpD,eAAO,MAAM,WAAW,YACX;IACL,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CAC3B,GAAG,qBAAqB;;;;;EAO5B,CAAC;AAEF,eAAO,MAAM,OAAO,aACN,qBAAqB,KAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAMvB,CAAC"}
@@ -1,17 +0,0 @@
1
- import { parse, Range } from "semver";
2
- import { spawnSyncDockerFallback } from "./util.js";
3
- export const requiredVersion = new Range("^0.19.1");
4
- export const exportImage = async (options) => {
5
- const { image, stdin, stdout } = options;
6
- return spawnSyncDockerFallback("crane", ["export", "-", "-"], {
7
- image,
8
- stdio: [stdin, stdout, "inherit"],
9
- });
10
- };
11
- export const version = async (options) => {
12
- const result = spawnSyncDockerFallback("crane", ["version"], options || {});
13
- if (result.error) {
14
- return null;
15
- }
16
- return parse(result.stdout.toString());
17
- };
package/dist/flags.d.ts DELETED
@@ -1,17 +0,0 @@
1
- export declare const address: import("@oclif/core/lib/interfaces").FlagDefinition<`0x${string}`, import("@oclif/core/lib/interfaces").CustomOptions, {
2
- multiple: false;
3
- requiredOrDefaulted: false;
4
- }>;
5
- export declare const bigint: import("@oclif/core/lib/interfaces").FlagDefinition<bigint, import("@oclif/core/lib/interfaces").CustomOptions, {
6
- multiple: false;
7
- requiredOrDefaulted: false;
8
- }>;
9
- export declare const number: import("@oclif/core/lib/interfaces").FlagDefinition<`${number}`, import("@oclif/core/lib/interfaces").CustomOptions, {
10
- multiple: false;
11
- requiredOrDefaulted: false;
12
- }>;
13
- export declare const hex: import("@oclif/core/lib/interfaces").FlagDefinition<`0x${string}`, import("@oclif/core/lib/interfaces").CustomOptions, {
14
- multiple: false;
15
- requiredOrDefaulted: false;
16
- }>;
17
- //# sourceMappingURL=flags.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO;;;EAOlB,CAAC;AAGH,eAAO,MAAM,MAAM;;;EAEjB,CAAC;AAGH,eAAO,MAAM,MAAM;;;EAEjB,CAAC;AAGH,eAAO,MAAM,GAAG;;;EAOd,CAAC"}