@cartesi/cli 2.0.0-alpha.0 → 2.0.0-alpha.11

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 (153) hide show
  1. package/dist/base.d.ts +18 -0
  2. package/dist/base.d.ts.map +1 -0
  3. package/dist/base.js +103 -0
  4. package/dist/builder/directory.d.ts.map +1 -1
  5. package/dist/builder/docker.d.ts.map +1 -1
  6. package/dist/builder/docker.js +10 -1
  7. package/dist/builder/empty.d.ts.map +1 -1
  8. package/dist/builder/none.d.ts.map +1 -1
  9. package/dist/builder/tar.d.ts.map +1 -1
  10. package/dist/commands/address-book.d.ts +4 -8
  11. package/dist/commands/address-book.d.ts.map +1 -1
  12. package/dist/commands/address-book.js +15 -14
  13. package/dist/commands/build.d.ts +5 -11
  14. package/dist/commands/build.d.ts.map +1 -1
  15. package/dist/commands/build.js +16 -28
  16. package/dist/commands/clean.d.ts +2 -7
  17. package/dist/commands/clean.d.ts.map +1 -1
  18. package/dist/commands/clean.js +9 -10
  19. package/dist/commands/create.d.ts +2 -15
  20. package/dist/commands/create.d.ts.map +1 -1
  21. package/dist/commands/create.js +7 -64
  22. package/dist/commands/deploy/build.d.ts +2 -14
  23. package/dist/commands/deploy/build.d.ts.map +1 -1
  24. package/dist/commands/deploy/build.js +8 -61
  25. package/dist/commands/deploy.d.ts +3 -0
  26. package/dist/commands/deploy.d.ts.map +1 -0
  27. package/dist/commands/deploy.js +12 -0
  28. package/dist/commands/doctor.d.ts +2 -12
  29. package/dist/commands/doctor.d.ts.map +1 -1
  30. package/dist/commands/doctor.js +96 -91
  31. package/dist/commands/hash.d.ts +4 -9
  32. package/dist/commands/hash.d.ts.map +1 -1
  33. package/dist/commands/hash.js +14 -14
  34. package/dist/commands/rollups/create.d.ts +7 -0
  35. package/dist/commands/rollups/create.d.ts.map +1 -0
  36. package/dist/commands/rollups/create.js +36 -0
  37. package/dist/commands/rollups/deploy.d.ts +16 -0
  38. package/dist/commands/rollups/deploy.d.ts.map +1 -0
  39. package/dist/commands/rollups/deploy.js +237 -0
  40. package/dist/commands/rollups/logs.d.ts +11 -0
  41. package/dist/commands/rollups/logs.d.ts.map +1 -0
  42. package/dist/commands/rollups/logs.js +32 -0
  43. package/dist/commands/rollups/start.d.ts +14 -0
  44. package/dist/commands/rollups/start.d.ts.map +1 -0
  45. package/dist/commands/rollups/start.js +211 -0
  46. package/dist/commands/rollups/status.d.ts +7 -0
  47. package/dist/commands/rollups/status.d.ts.map +1 -0
  48. package/dist/commands/rollups/status.js +46 -0
  49. package/dist/commands/rollups/stop.d.ts +5 -0
  50. package/dist/commands/rollups/stop.d.ts.map +1 -0
  51. package/dist/commands/rollups/stop.js +26 -0
  52. package/dist/commands/rollups.d.ts +6 -0
  53. package/dist/commands/rollups.d.ts.map +1 -0
  54. package/dist/commands/rollups.js +21 -0
  55. package/dist/commands/run.d.ts +2 -20
  56. package/dist/commands/run.d.ts.map +1 -1
  57. package/dist/commands/run.js +9 -190
  58. package/dist/commands/send/erc20.d.ts +11 -13
  59. package/dist/commands/send/erc20.d.ts.map +1 -1
  60. package/dist/commands/send/erc20.js +57 -52
  61. package/dist/commands/send/erc721.d.ts +11 -13
  62. package/dist/commands/send/erc721.d.ts.map +1 -1
  63. package/dist/commands/send/erc721.js +51 -46
  64. package/dist/commands/send/ether.d.ts +11 -12
  65. package/dist/commands/send/ether.d.ts.map +1 -1
  66. package/dist/commands/send/ether.js +25 -21
  67. package/dist/commands/send/generic.d.ts +12 -14
  68. package/dist/commands/send/generic.d.ts.map +1 -1
  69. package/dist/commands/send/generic.js +92 -97
  70. package/dist/commands/send.d.ts +21 -0
  71. package/dist/commands/send.d.ts.map +1 -0
  72. package/dist/commands/send.js +67 -0
  73. package/dist/commands/shell.d.ts +6 -14
  74. package/dist/commands/shell.d.ts.map +1 -1
  75. package/dist/commands/shell.js +21 -43
  76. package/dist/compose/rollups/default.env +34 -0
  77. package/dist/compose/rollups/docker-compose-anvil.yaml +17 -0
  78. package/dist/{node → compose/rollups}/docker-compose-bundler.yaml +12 -26
  79. package/dist/{node → compose/rollups}/docker-compose-database.yaml +4 -2
  80. package/dist/compose/rollups/docker-compose-espresso.yaml +68 -0
  81. package/dist/compose/rollups/docker-compose-explorer.yaml +57 -0
  82. package/dist/compose/rollups/docker-compose-graphql.yaml +23 -0
  83. package/dist/compose/rollups/docker-compose-node-cpus.yaml +6 -0
  84. package/dist/compose/rollups/docker-compose-node-memory.yaml +6 -0
  85. package/dist/compose/rollups/docker-compose-node.yaml +26 -0
  86. package/dist/compose/rollups/docker-compose-paymaster.yaml +18 -0
  87. package/dist/compose/rollups/docker-compose-proxy.yaml +24 -0
  88. package/dist/compose/rollups/proxy/anvil.yaml +17 -0
  89. package/dist/compose/rollups/proxy/bundler.yaml +17 -0
  90. package/dist/compose/rollups/proxy/espresso.yaml +17 -0
  91. package/dist/compose/rollups/proxy/explorer-api.yaml +17 -0
  92. package/dist/compose/rollups/proxy/explorer.yaml +10 -0
  93. package/dist/compose/rollups/proxy/graphql.yaml +10 -0
  94. package/dist/compose/rollups/proxy/paymaster.yaml +17 -0
  95. package/dist/compose/rollups/proxy/rollups-node.yaml +17 -0
  96. package/dist/config.d.ts +2 -1
  97. package/dist/config.d.ts.map +1 -1
  98. package/dist/config.js +7 -17
  99. package/dist/contracts.d.ts +1695 -1636
  100. package/dist/contracts.d.ts.map +1 -1
  101. package/dist/contracts.js +632 -592
  102. package/dist/exec/cartesi-machine.d.ts.map +1 -1
  103. package/dist/exec/crane.d.ts +1 -1
  104. package/dist/exec/crane.d.ts.map +1 -1
  105. package/dist/exec/genext2fs.d.ts.map +1 -1
  106. package/dist/exec/mksquashfs.d.ts.map +1 -1
  107. package/dist/exec/rollups.d.ts +16 -0
  108. package/dist/exec/rollups.d.ts.map +1 -0
  109. package/dist/exec/rollups.js +39 -0
  110. package/dist/exec/util.d.ts +1 -1
  111. package/dist/exec/util.d.ts.map +1 -1
  112. package/dist/exec/util.js +2 -0
  113. package/dist/index.d.ts +2 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +53 -1
  116. package/dist/machine.d.ts.map +1 -1
  117. package/dist/prompts.d.ts.map +1 -1
  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.map +1 -1
  122. package/dist/wallet.js +47 -6
  123. package/package.json +30 -47
  124. package/bin/dev.cmd +0 -3
  125. package/bin/dev.js +0 -25
  126. package/bin/run.cmd +0 -3
  127. package/bin/run.js +0 -8
  128. package/dist/baseCommand.d.ts +0 -22
  129. package/dist/baseCommand.d.ts.map +0 -1
  130. package/dist/baseCommand.js +0 -92
  131. package/dist/commands/deploy/index.d.ts +0 -12
  132. package/dist/commands/deploy/index.d.ts.map +0 -1
  133. package/dist/commands/deploy/index.js +0 -78
  134. package/dist/commands/send/index.d.ts +0 -28
  135. package/dist/commands/send/index.d.ts.map +0 -1
  136. package/dist/commands/send/index.js +0 -102
  137. package/dist/flags.d.ts +0 -17
  138. package/dist/flags.d.ts.map +0 -1
  139. package/dist/flags.js +0 -28
  140. package/dist/node/DockerfileDeploy.txt +0 -4
  141. package/dist/node/default.env +0 -27
  142. package/dist/node/docker-compose-anvil.yaml +0 -50
  143. package/dist/node/docker-compose-envfile.yaml +0 -4
  144. package/dist/node/docker-compose-explorer.yaml +0 -88
  145. package/dist/node/docker-compose-host.yaml +0 -30
  146. package/dist/node/docker-compose-paymaster.yaml +0 -33
  147. package/dist/node/docker-compose-prompt.yaml +0 -17
  148. package/dist/node/docker-compose-proxy.yaml +0 -48
  149. package/dist/node/docker-compose-snapshot-volume.yaml +0 -8
  150. package/dist/node/docker-compose-validator-cpus.yaml +0 -6
  151. package/dist/node/docker-compose-validator-memory.yaml +0 -6
  152. package/dist/node/docker-compose-validator.yaml +0 -59
  153. package/oclif.manifest.json +0 -876
package/dist/base.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { Address, Hash } from "viem";
2
+ import { Config } from "./config.js";
3
+ export declare const getContextPath: (...paths: string[]) => string;
4
+ export declare const getMachineHash: () => Hash | undefined;
5
+ export declare const getApplicationConfig: (configPath: string) => Config;
6
+ export type AddressBook = Record<string, Address>;
7
+ export declare const getAddressBook: () => Promise<AddressBook>;
8
+ export declare const getServiceState: (options: {
9
+ environmentName: string;
10
+ service: string;
11
+ }) => Promise<string | undefined>;
12
+ export declare const getServiceHealth: (options: {
13
+ environmentName: string;
14
+ service: string;
15
+ }) => Promise<string | undefined>;
16
+ export declare const parseAddress: (value: string) => Address | undefined;
17
+ export declare const parseHash: (value: string) => Hash;
18
+ //# sourceMappingURL=base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAc,IAAI,EAA+B,MAAM,MAAM,CAAC;AAC9E,OAAO,EAAE,MAAM,EAAS,MAAM,aAAa,CAAC;AAkB5C,eAAO,MAAM,cAAc,GAAI,GAAG,OAAO,MAAM,EAAE,KAAG,MAEnD,CAAC;AAEF,eAAO,MAAM,cAAc,QAAO,IAAI,GAAG,SAUxC,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,YAAY,MAAM,KAAG,MAIzD,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,WAAW,CAkC1D,CAAC;AAqBF,eAAO,MAAM,eAAe,GAAU,SAAS;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAG7B,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAU,SAAS;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC;CACnB,KAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAG7B,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,OAAO,GAAG,SAStD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,KAAG,IASzC,CAAC"}
package/dist/base.js ADDED
@@ -0,0 +1,103 @@
1
+ import { InvalidArgumentError } from "@commander-js/extra-typings";
2
+ import { execa } from "execa";
3
+ import fs from "fs";
4
+ import path from "path";
5
+ import { getAddress, isAddress, isHash, zeroHash } from "viem";
6
+ import { parse } from "./config.js";
7
+ import { applicationFactoryAddress, authorityFactoryAddress, erc1155BatchPortalAddress, erc1155SinglePortalAddress, erc20PortalAddress, erc721PortalAddress, etherPortalAddress, inputBoxAddress, selfHostedApplicationFactoryAddress, testMultiTokenAddress, testNftAddress, testTokenAddress, } from "./contracts.js";
8
+ import { getApplicationAddress } from "./exec/rollups.js";
9
+ export const getContextPath = (...paths) => {
10
+ return path.join(".cartesi", ...paths);
11
+ };
12
+ export const getMachineHash = () => {
13
+ // read hash of the cartesi machine snapshot, if one exists
14
+ const hashPath = getContextPath("image", "hash");
15
+ if (fs.existsSync(hashPath)) {
16
+ const hash = fs.readFileSync(hashPath).toString("hex");
17
+ if (isHash(`0x${hash}`)) {
18
+ return `0x${hash}`;
19
+ }
20
+ }
21
+ return undefined;
22
+ };
23
+ export const getApplicationConfig = (configPath) => {
24
+ return fs.existsSync(configPath)
25
+ ? parse(fs.readFileSync(configPath).toString())
26
+ : parse("");
27
+ };
28
+ export const getAddressBook = async () => {
29
+ const applicationAddress = await getApplicationAddress();
30
+ // build rollups contracts address book
31
+ const contracts = {
32
+ ApplicationFactory: applicationFactoryAddress,
33
+ AuthorityFactory: authorityFactoryAddress,
34
+ EntryPointV06: "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
35
+ EntryPointV07: "0x0000000071727De22E5E9d8BAf0edAc6f37da032",
36
+ ERC1155BatchPortal: erc1155BatchPortalAddress,
37
+ ERC1155SinglePortal: erc1155SinglePortalAddress,
38
+ ERC20Portal: erc20PortalAddress,
39
+ ERC721Portal: erc721PortalAddress,
40
+ EtherPortal: etherPortalAddress,
41
+ InputBox: inputBoxAddress,
42
+ LightAccountFactory: "0x00004EC70002a32400f8ae005A26081065620D20",
43
+ SelfHostedApplicationFactory: selfHostedApplicationFactoryAddress,
44
+ SimpleAccountFactory: "0x9406Cc6185a346906296840746125a0E44976454",
45
+ SmartAccountFactory: "0x000000a56Aaca3e9a4C479ea6b6CD0DbcB6634F5",
46
+ KernelFactoryV2: "0x5de4839a76cf55d0c90e2061ef4386d962E15ae3",
47
+ KernelFactoryV3: "0x6723b44Abeec4E71eBE3232BD5B455805baDD22f",
48
+ KernelFactoryV3_1: "0xaac5D4240AF87249B3f71BC8E4A2cae074A3E419",
49
+ TestToken: testTokenAddress,
50
+ TestNFT: testNftAddress,
51
+ TestMultiToken: testMultiTokenAddress,
52
+ VerifyingPaymasterV06: "0x28ec0633192d0cBd9E1156CE05D5FdACAcB93947",
53
+ VerifyingPaymasterV07: "0xc5c97885C67F7361aBAfD2B95067a5bBdA603608",
54
+ };
55
+ if (applicationAddress) {
56
+ contracts.Application = applicationAddress;
57
+ }
58
+ return contracts;
59
+ };
60
+ const getServiceInfo = async (options) => {
61
+ const { environmentName, service } = options;
62
+ // get service information
63
+ const { stdout } = await execa("docker", [
64
+ "compose",
65
+ "--project-name",
66
+ environmentName,
67
+ "ps",
68
+ service,
69
+ "--format",
70
+ "json",
71
+ ]);
72
+ return stdout ? JSON.parse(stdout) : undefined;
73
+ };
74
+ export const getServiceState = async (options) => {
75
+ const info = await getServiceInfo(options);
76
+ return info?.State;
77
+ };
78
+ export const getServiceHealth = async (options) => {
79
+ const info = await getServiceInfo(options);
80
+ return info?.Health;
81
+ };
82
+ export const parseAddress = (value) => {
83
+ if (isAddress(value)) {
84
+ return getAddress(value);
85
+ }
86
+ else {
87
+ if (value !== "") {
88
+ throw new InvalidArgumentError(`Invalid address: ${value}`);
89
+ }
90
+ return undefined;
91
+ }
92
+ };
93
+ export const parseHash = (value) => {
94
+ if (isHash(value)) {
95
+ return value;
96
+ }
97
+ else {
98
+ if (value !== "") {
99
+ throw new InvalidArgumentError(`Invalid hash: ${value}`);
100
+ }
101
+ return zeroHash;
102
+ }
103
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/builder/directory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,eAAO,MAAM,KAAK,SACR,MAAM,SACL,oBAAoB,YACjB,MAAM,eACH,MAAM,KACpB,OAAO,CAAC,IAAI,CAkCd,CAAC"}
1
+ {"version":3,"file":"directory.d.ts","sourceRoot":"","sources":["../../src/builder/directory.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGpD,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,oBAAoB,EAC3B,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,IAAI,CAkCd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/builder/docker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQjD,KAAK,SAAS,GAAG;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AA6DF,eAAO,MAAM,KAAK,SACR,MAAM,SACL,iBAAiB,YACd,MAAM,eACH,MAAM,KACpB,OAAO,CAAC,SAAS,GAAG,SAAS,CAsD/B,CAAC"}
1
+ {"version":3,"file":"docker.d.ts","sourceRoot":"","sources":["../../src/builder/docker.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAQjD,KAAK,SAAS,GAAG;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AA+DF,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,iBAAiB,EACxB,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,SAAS,GAAG,SAAS,CA4D/B,CAAC"}
@@ -12,6 +12,8 @@ const buildImage = async (options) => {
12
12
  const args = [
13
13
  "buildx",
14
14
  "build",
15
+ "--platform",
16
+ "linux/riscv64",
15
17
  "--file",
16
18
  dockerfile,
17
19
  "--load",
@@ -58,7 +60,14 @@ export const build = async (name, drive, sdkImage, destination) => {
58
60
  const tar = `${name}.tar`;
59
61
  const filename = `${name}.${format}`;
60
62
  // use pre-existing image or build docker image
61
- const image = drive.image || (await buildImage(drive));
63
+ let image;
64
+ if (drive.image) {
65
+ image = drive.image;
66
+ await execa("docker", ["image", "pull", image]);
67
+ }
68
+ else {
69
+ image = await buildImage(drive);
70
+ }
62
71
  // get image info
63
72
  const imageInfo = await getImageInfo(image);
64
73
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../src/builder/empty.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,KAAK,SACR,MAAM,SACL,gBAAgB,YACb,MAAM,eACH,MAAM,KACpB,OAAO,CAAC,IAAI,CAoBd,CAAC"}
1
+ {"version":3,"file":"empty.d.ts","sourceRoot":"","sources":["../../src/builder/empty.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAGhD,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,gBAAgB,EACvB,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,IAAI,CAoBd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"none.d.ts","sourceRoot":"","sources":["../../src/builder/none.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAkB,MAAM,cAAc,CAAC;AAEnE,eAAO,MAAM,KAAK,SACR,MAAM,SACL,mBAAmB,eACb,MAAM,KACpB,OAAO,CAAC,IAAI,CAQd,CAAC"}
1
+ {"version":3,"file":"none.d.ts","sourceRoot":"","sources":["../../src/builder/none.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAkB,MAAM,cAAc,CAAC;AAEnE,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,mBAAmB,EAC1B,aAAa,MAAM,KACpB,OAAO,CAAC,IAAI,CAQd,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../src/builder/tar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,eAAO,MAAM,KAAK,SACR,MAAM,SACL,cAAc,YACX,MAAM,eACH,MAAM,KACpB,OAAO,CAAC,IAAI,CA4Bd,CAAC"}
1
+ {"version":3,"file":"tar.d.ts","sourceRoot":"","sources":["../../src/builder/tar.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9C,eAAO,MAAM,KAAK,GACd,MAAM,MAAM,EACZ,OAAO,cAAc,EACrB,UAAU,MAAM,EAChB,aAAa,MAAM,KACpB,OAAO,CAAC,IAAI,CA4Bd,CAAC"}
@@ -1,9 +1,5 @@
1
- import { AddressBook as AddressBookType, BaseCommand } from "../baseCommand.js";
2
- export default class AddressBook extends BaseCommand<typeof AddressBook> {
3
- static summary: string;
4
- static description: string;
5
- static examples: string[];
6
- static enableJsonFlag: boolean;
7
- run(): Promise<AddressBookType>;
8
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const createAddressBookCommand: () => Command<[], {
3
+ json?: true | undefined;
4
+ }, {}>;
9
5
  //# sourceMappingURL=address-book.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../src/commands/address-book.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,IAAI,eAAe,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhF,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,OAAO,WAAW,CAAC;IACpE,MAAM,CAAC,OAAO,SAAmD;IAEjE,MAAM,CAAC,WAAW,SACwF;IAE1G,MAAM,CAAC,QAAQ,WAA2C;IAE1D,OAAc,cAAc,UAAQ;IAEvB,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;CA+B/C"}
1
+ {"version":3,"file":"address-book.d.ts","sourceRoot":"","sources":["../../src/commands/address-book.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,wBAAwB;;MAsCpC,CAAC"}
@@ -1,9 +1,13 @@
1
+ import { Command } from "@commander-js/extra-typings";
1
2
  import Table from "cli-table3";
2
- import { BaseCommand } from "../baseCommand.js";
3
- class AddressBook extends BaseCommand {
4
- async run() {
5
- const addressBook = await super.getAddressBook();
6
- if (!this.jsonEnabled()) {
3
+ import { getAddressBook } from "../base.js";
4
+ export const createAddressBookCommand = () => {
5
+ return new Command("address-book")
6
+ .description("Prints the addresses of all smart contracts deployed to the runtime environment of the application.")
7
+ .option("--json", "Format output as json.")
8
+ .action(async ({ json }) => {
9
+ const addressBook = await getAddressBook();
10
+ if (!json) {
7
11
  // print as a table
8
12
  const table = new Table({
9
13
  head: ["Contract", "Address"],
@@ -29,12 +33,9 @@ class AddressBook extends BaseCommand {
29
33
  table.push(...Object.entries(addressBook));
30
34
  console.log(table.toString());
31
35
  }
32
- // return (as json)
33
- return addressBook;
34
- }
35
- }
36
- AddressBook.summary = "Prints addresses of smart contracts deployed.";
37
- AddressBook.description = "Prints the addresses of all smart contracts deployed to the runtime environment of the application.";
38
- AddressBook.examples = ["<%= config.bin %> <%= command.id %>"];
39
- AddressBook.enableJsonFlag = true;
40
- export default AddressBook;
36
+ else {
37
+ // print as json
38
+ process.stdout.write(JSON.stringify(addressBook));
39
+ }
40
+ });
41
+ };
@@ -1,12 +1,6 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export default class Build extends BaseCommand<typeof Build> {
3
- static summary: string;
4
- static description: string;
5
- static examples: string[];
6
- static flags: {
7
- config: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- "drives-only": import("@oclif/core/lib/interfaces/parser.js").BooleanFlag<boolean>;
9
- };
10
- run(): Promise<void>;
11
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const createBuildCommand: () => Command<[], {
3
+ config: string;
4
+ drivesOnly?: true | undefined;
5
+ }, {}>;
12
6
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAoChD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,OAAO,SAAwB;IAEtC,MAAM,CAAC,WAAW,SAC+E;IAEjG,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;;MAUV;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CA2CpC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/commands/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAwCtD,eAAO,MAAM,kBAAkB;;;MAoD9B,CAAC"}
@@ -1,8 +1,8 @@
1
- import { Flags } from "@oclif/core";
1
+ import { Command } from "@commander-js/extra-typings";
2
2
  import fs from "fs-extra";
3
3
  import path from "path";
4
4
  import tmp from "tmp";
5
- import { BaseCommand } from "../baseCommand.js";
5
+ import { getApplicationConfig, getContextPath } from "../base.js";
6
6
  import { buildDirectory, buildDocker, buildEmpty, buildNone, buildTar, } from "../builder/index.js";
7
7
  import { bootMachine } from "../machine.js";
8
8
  const buildDrive = async (name, drive, sdkImage, destination) => {
@@ -24,25 +24,28 @@ const buildDrive = async (name, drive, sdkImage, destination) => {
24
24
  }
25
25
  }
26
26
  };
27
- class Build extends BaseCommand {
28
- async run() {
29
- const { flags } = await this.parse(Build);
27
+ export const createBuildCommand = () => {
28
+ return new Command("build")
29
+ .description("Build application by building Cartesi machine drives, configuring a machine and booting it.")
30
+ .option("-c, --config <config>", "path to the configuration file", "cartesi.toml")
31
+ .option("-d, --drives-only", "only build drives, do not boot machine")
32
+ .action(async ({ config, drivesOnly }) => {
30
33
  // clean up temp files we create along the process
31
34
  tmp.setGracefulCleanup();
32
35
  // get application configuration from 'cartesi.toml'
33
- const config = this.getApplicationConfig(flags.config);
36
+ const c = getApplicationConfig(config);
34
37
  // destination directory for image and intermediate files
35
- const destination = path.resolve(this.getContextPath());
38
+ const destination = path.resolve(getContextPath());
36
39
  // prepare context directory
37
40
  await fs.emptyDir(destination); // XXX: make it less error prone
38
41
  // start build of all drives simultaneously
39
- const results = Object.entries(config.drives).reduce((acc, [name, drive]) => {
40
- acc[name] = buildDrive(name, drive, config.sdk, destination);
42
+ const results = Object.entries(c.drives).reduce((acc, [name, drive]) => {
43
+ acc[name] = buildDrive(name, drive, c.sdk, destination);
41
44
  return acc;
42
45
  }, {});
43
46
  // await for all drives to be built
44
47
  await Promise.all(Object.values(results));
45
- if (flags["drives-only"]) {
48
+ if (drivesOnly) {
46
49
  // only build drives, so quit here
47
50
  return;
48
51
  }
@@ -50,24 +53,9 @@ class Build extends BaseCommand {
50
53
  const root = await results["root"];
51
54
  const imageInfo = root || undefined;
52
55
  // path of machine snapshot
53
- const snapshotPath = this.getContextPath("image");
56
+ const snapshotPath = getContextPath("image");
54
57
  // create machine snapshot
55
- await bootMachine(config, imageInfo, destination);
58
+ await bootMachine(c, imageInfo, destination);
56
59
  await fs.chmod(snapshotPath, 0o755);
57
- }
58
- }
59
- Build.summary = "Build application.";
60
- Build.description = "Build application by building Cartesi machine drives, configuring a machine and booting it";
61
- Build.examples = ["<%= config.bin %> <%= command.id %>"];
62
- Build.flags = {
63
- config: Flags.file({
64
- char: "c",
65
- default: "cartesi.toml",
66
- summary: "path to the configuration file",
67
- }),
68
- "drives-only": Flags.boolean({
69
- default: false,
70
- summary: "only build drives",
71
- }),
60
+ });
72
61
  };
73
- export default Build;
@@ -1,8 +1,3 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export default class Clean extends BaseCommand<typeof Clean> {
3
- static summary: string;
4
- static description: string;
5
- static examples: string[];
6
- run(): Promise<void>;
7
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const createCleanCommand: () => Command<[], {}, {}>;
8
3
  //# sourceMappingURL=clean.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,WAAW,CAAC,OAAO,KAAK,CAAC;IACxD,MAAM,CAAC,OAAO,SAA2C;IAEzD,MAAM,CAAC,WAAW,SAAwD;IAE1E,MAAM,CAAC,QAAQ,WAA2C;IAE7C,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
1
+ {"version":3,"file":"clean.d.ts","sourceRoot":"","sources":["../../src/commands/clean.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,kBAAkB,2BAM9B,CAAC"}
@@ -1,11 +1,10 @@
1
+ import { Command } from "@commander-js/extra-typings";
1
2
  import fs from "fs-extra";
2
- import { BaseCommand } from "../baseCommand.js";
3
- class Clean extends BaseCommand {
4
- async run() {
5
- await fs.emptyDir(this.getContextPath());
6
- }
7
- }
8
- Clean.summary = "Clean build artifacts of application.";
9
- Clean.description = "Deletes all cached build artifacts of application.";
10
- Clean.examples = ["<%= config.bin %> <%= command.id %>"];
11
- export default Clean;
3
+ import { getContextPath } from "../base.js";
4
+ export const createCleanCommand = () => {
5
+ return new Command("clean")
6
+ .description("Deletes all cached build artifacts of application.")
7
+ .action(async () => {
8
+ await fs.emptyDir(getContextPath());
9
+ });
10
+ };
@@ -1,16 +1,3 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export declare const DEFAULT_TEMPLATES_BRANCH = "sdk-0.9";
3
- export default class CreateCommand extends BaseCommand<typeof CreateCommand> {
4
- static description: string;
5
- static examples: string[];
6
- static args: {
7
- name: import("@oclif/core/lib/interfaces/parser.js").Arg<string, Record<string, unknown>>;
8
- };
9
- static flags: {
10
- template: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
11
- branch: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
12
- };
13
- private download;
14
- run(): Promise<void>;
15
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const createCreateCommand: () => Command<[], {}, {}>;
16
3
  //# sourceMappingURL=create.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,eAAO,MAAM,wBAAwB,YAAY,CAAC;AAElD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW,CAAC,OAAO,aAAa,CAAC;IACxE,MAAM,CAAC,WAAW,SAAwB;IAE1C,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,IAAI;;MAKT;IAEF,MAAM,CAAC,KAAK;;;MAoBV;YAEY,QAAQ;IAqBT,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAkBpC"}
1
+ {"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGtD,eAAO,MAAM,mBAAmB,2BAU/B,CAAC"}
@@ -1,66 +1,9 @@
1
- import { Args, Flags } from "@oclif/core";
1
+ import { Command } from "@commander-js/extra-typings";
2
2
  import chalk from "chalk";
3
- import { downloadTemplate } from "giget";
4
- import ora from "ora";
5
- import { BaseCommand } from "../baseCommand.js";
6
- export const DEFAULT_TEMPLATES_BRANCH = "sdk-0.9";
7
- class CreateCommand extends BaseCommand {
8
- async download(template, branch, out) {
9
- const cartesiProvider = async (input) => {
10
- return {
11
- name: "cartesi",
12
- subdir: input,
13
- url: "https://github.com/cartesi/application-templates",
14
- tar: `https://codeload.github.com/cartesi/application-templates/tar.gz/refs/heads/${branch}`,
15
- };
16
- };
17
- const input = `cartesi:${template}`;
18
- return downloadTemplate(input, {
19
- dir: out,
20
- providers: { cartesi: cartesiProvider },
21
- });
22
- }
23
- async run() {
24
- const { args, flags } = await this.parse(CreateCommand);
25
- const spinner = ora("Creating application...").start();
26
- try {
27
- const { dir } = await this.download(flags.template, flags.branch, args.name);
28
- spinner.succeed(`Application created at ${chalk.cyan(dir)}`);
29
- }
30
- catch (e) {
31
- spinner.fail(e instanceof Error
32
- ? `Error creating application: ${chalk.red(e.message)}`
33
- : String(e));
34
- }
35
- }
36
- }
37
- CreateCommand.description = "Create application";
38
- CreateCommand.examples = ["<%= config.bin %> <%= command.id %>"];
39
- CreateCommand.args = {
40
- name: Args.string({
41
- description: "application and directory name",
42
- required: true,
43
- }),
3
+ export const createCreateCommand = () => {
4
+ return new Command("create")
5
+ .summary("DEPRECATED: use 'rollups create' instead")
6
+ .action(async () => {
7
+ console.warn(chalk.yellow("create command is deprecated, use 'rollups create' instead"));
8
+ });
44
9
  };
45
- CreateCommand.flags = {
46
- template: Flags.string({
47
- description: "template name to use",
48
- required: true,
49
- options: [
50
- "cpp",
51
- "cpp-low-level",
52
- "go",
53
- "javascript",
54
- "lua",
55
- "python",
56
- "ruby",
57
- "rust",
58
- "typescript",
59
- ],
60
- }),
61
- branch: Flags.string({
62
- description: `cartesi/application-templates repository branch name to use`,
63
- default: DEFAULT_TEMPLATES_BRANCH,
64
- }),
65
- };
66
- export default CreateCommand;
@@ -1,15 +1,3 @@
1
- import { BaseCommand } from "../../baseCommand.js";
2
- export default class DeployBuild extends BaseCommand<typeof DeployBuild> {
3
- static summary: string;
4
- static description: string;
5
- static examples: string[];
6
- static flags: {
7
- platform: import("@oclif/core/lib/interfaces/parser.js").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser.js").CustomOptions>;
8
- };
9
- static enableJsonFlag: boolean;
10
- private buildRollupsImage;
11
- run(): Promise<{
12
- image: string;
13
- }>;
14
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const createBuildCommand: () => Command<[], {}, {}>;
15
3
  //# sourceMappingURL=build.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/build.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,WAAW,CAAC,OAAO,WAAW,CAAC;IACpE,MAAM,CAAC,OAAO,SAAmD;IAEjE,MAAM,CAAC,WAAW,SACoD;IAEtE,MAAM,CAAC,QAAQ,WAA2C;IAE1D,MAAM,CAAC,KAAK;;MAOV;IAEF,OAAc,cAAc,UAAQ;YAEtB,iBAAiB;IA6BlB,GAAG;;;CAwBnB"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../../src/commands/deploy/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAGtD,eAAO,MAAM,kBAAkB,2BAQ9B,CAAC"}
@@ -1,62 +1,9 @@
1
- import { Flags } from "@oclif/core";
2
- import { execa } from "execa";
3
- import fs from "fs-extra";
4
- import path from "path";
5
- import { tmpNameSync } from "tmp";
6
- import { URL } from "url";
7
- import { BaseCommand } from "../../baseCommand.js";
8
- class DeployBuild extends BaseCommand {
9
- async buildRollupsImage(platform) {
10
- const buildResult = tmpNameSync();
11
- const imagePath = this.getContextPath("image");
12
- const binPath = path.join(path.dirname(new URL(import.meta.url).pathname), "..", "..");
13
- const dockerfile = path.join(binPath, "node", "DockerfileDeploy.txt");
14
- const args = [
15
- "buildx",
16
- "build",
17
- "-f",
18
- dockerfile,
19
- "--load",
20
- "--iidfile",
21
- buildResult,
22
- imagePath,
23
- ];
24
- // optional platform, default to not defining, which will build for the host platform
25
- if (platform) {
26
- args.push("--platform", platform);
27
- }
28
- await execa("docker", args, { stdio: "inherit" });
29
- return fs.readFileSync(buildResult, "utf8");
30
- }
31
- async run() {
32
- const { flags } = await this.parse(DeployBuild);
33
- // print machine hash
34
- const templateHash = this.getMachineHash();
35
- if (!templateHash) {
36
- this.error(`Cartesi machine snapshot not found, run '${this.config.bin} build'`);
37
- }
38
- this.logPrompt({
39
- title: "Cartesi machine templateHash",
40
- value: templateHash,
41
- });
42
- this.log("Building application node Docker image...");
43
- const image = await this.buildRollupsImage(flags.platform);
44
- this.logPrompt({
45
- title: "Application node Docker image",
46
- value: image,
47
- });
48
- return { image };
49
- }
50
- }
51
- DeployBuild.summary = "Build deployment Docker image of application.";
52
- DeployBuild.description = "Package the application in a Docker image ready to be deployed.";
53
- DeployBuild.examples = ["<%= config.bin %> <%= command.id %>"];
54
- DeployBuild.flags = {
55
- platform: Flags.string({
56
- options: ["linux/amd64", "linux/arm64"],
57
- summary: "Docker image target platform",
58
- description: "Select the target platform for the produced Docker image. It depends on the platform where the application node will be deployed.",
59
- }),
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import chalk from "chalk";
3
+ export const createBuildCommand = () => {
4
+ return new Command("build")
5
+ .description("DEPRECATED: Package the application in a Docker image ready to be deployed.")
6
+ .action(async () => {
7
+ console.warn(chalk.yellow("deploy build command is deprecated"));
8
+ });
60
9
  };
61
- DeployBuild.enableJsonFlag = true;
62
- export default DeployBuild;
@@ -0,0 +1,3 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const createDeployCommand: () => Command<[], {}, {}>;
3
+ //# sourceMappingURL=deploy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAItD,eAAO,MAAM,mBAAmB,2BAc/B,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Command } from "@commander-js/extra-typings";
2
+ import chalk from "chalk";
3
+ import { createBuildCommand } from "./deploy/build.js";
4
+ export const createDeployCommand = () => {
5
+ const command = new Command("deploy")
6
+ .description("DEPRECATED: Package and deploy the application to a supported live network.")
7
+ .action(async () => {
8
+ console.warn(chalk.yellow("deploy command is deprecated, use 'rollups deploy' instead"));
9
+ });
10
+ command.addCommand(createBuildCommand(), { hidden: true });
11
+ return command;
12
+ };
@@ -1,13 +1,3 @@
1
- import { BaseCommand } from "../baseCommand.js";
2
- export default class DoctorCommand extends BaseCommand<typeof DoctorCommand> {
3
- static description: string;
4
- static examples: string[];
5
- private static MINIMUM_DOCKER_VERSION;
6
- private static MINIMUM_DOCKER_COMPOSE_VERSION;
7
- private static MINIMUM_BUILDX_VERSION;
8
- private checkDocker;
9
- private checkCompose;
10
- private checkBuildx;
11
- run(): Promise<void>;
12
- }
1
+ import { Command } from "@commander-js/extra-typings";
2
+ export declare const createDoctorCommand: () => Command<[], {}, {}>;
13
3
  //# sourceMappingURL=doctor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW,CAAC,OAAO,aAAa,CAAC;IACxE,MAAM,CAAC,WAAW,SAA2C;IAE7D,MAAM,CAAC,QAAQ,WAA2C;IAE1D,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAY;IACjD,OAAO,CAAC,MAAM,CAAC,8BAA8B,CAAY;IACzD,OAAO,CAAC,MAAM,CAAC,sBAAsB,CAAY;YAEnC,WAAW;YA+BX,YAAY;YAiCZ,WAAW;IAiDZ,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAYpC"}
1
+ {"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../src/commands/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AA4HtD,eAAO,MAAM,mBAAmB,2BAa/B,CAAC"}