genlayer 0.38.8 → 0.38.10

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 (205) hide show
  1. package/.eslintignore +2 -0
  2. package/.github/workflows/cli-docs.yml +124 -0
  3. package/.github/workflows/publish.yml +55 -0
  4. package/.github/workflows/smoke.yml +27 -0
  5. package/.github/workflows/validate-code.yml +51 -0
  6. package/.prettierignore +19 -0
  7. package/.prettierrc +12 -0
  8. package/.release-it.json +66 -0
  9. package/CHANGELOG.md +545 -0
  10. package/CLAUDE.md +55 -0
  11. package/CONTRIBUTING.md +117 -0
  12. package/dist/index.js +221 -62
  13. package/docs/api-references/_meta.json +9 -0
  14. package/docs/api-references/accounts/_meta.json +3 -0
  15. package/docs/api-references/accounts/account/create.mdx +19 -0
  16. package/docs/api-references/accounts/account/export.mdx +19 -0
  17. package/docs/api-references/accounts/account/import.mdx +22 -0
  18. package/docs/api-references/accounts/account/list.mdx +15 -0
  19. package/docs/api-references/accounts/account/lock.mdx +16 -0
  20. package/docs/api-references/accounts/account/remove.mdx +20 -0
  21. package/docs/api-references/accounts/account/send.mdx +24 -0
  22. package/docs/api-references/accounts/account/show.mdx +17 -0
  23. package/docs/api-references/accounts/account/unlock.mdx +17 -0
  24. package/docs/api-references/accounts/account/use.mdx +19 -0
  25. package/docs/api-references/accounts/account.mdx +32 -0
  26. package/docs/api-references/configuration/_meta.json +4 -0
  27. package/docs/api-references/configuration/config/get.mdx +21 -0
  28. package/docs/api-references/configuration/config/reset.mdx +21 -0
  29. package/docs/api-references/configuration/config/set.mdx +21 -0
  30. package/docs/api-references/configuration/config.mdx +25 -0
  31. package/docs/api-references/configuration/network/info.mdx +15 -0
  32. package/docs/api-references/configuration/network/list.mdx +15 -0
  33. package/docs/api-references/configuration/network/set.mdx +21 -0
  34. package/docs/api-references/configuration/network.mdx +25 -0
  35. package/docs/api-references/contracts/_meta.json +7 -0
  36. package/docs/api-references/contracts/call.mdx +21 -0
  37. package/docs/api-references/contracts/code.mdx +20 -0
  38. package/docs/api-references/contracts/deploy.mdx +17 -0
  39. package/docs/api-references/contracts/schema.mdx +20 -0
  40. package/docs/api-references/contracts/write.mdx +21 -0
  41. package/docs/api-references/environment/_meta.json +7 -0
  42. package/docs/api-references/environment/init.mdx +20 -0
  43. package/docs/api-references/environment/new.mdx +21 -0
  44. package/docs/api-references/environment/stop.mdx +15 -0
  45. package/docs/api-references/environment/up.mdx +20 -0
  46. package/docs/api-references/environment/update/ollama.mdx +16 -0
  47. package/docs/api-references/environment/update.mdx +23 -0
  48. package/docs/api-references/index.mdx +35 -0
  49. package/docs/api-references/localnet/_meta.json +3 -0
  50. package/docs/api-references/localnet/localnet/validators/count.mdx +15 -0
  51. package/docs/api-references/localnet/localnet/validators/create-random.mdx +16 -0
  52. package/docs/api-references/localnet/localnet/validators/create.mdx +19 -0
  53. package/docs/api-references/localnet/localnet/validators/delete.mdx +16 -0
  54. package/docs/api-references/localnet/localnet/validators/get.mdx +16 -0
  55. package/docs/api-references/localnet/localnet/validators/update.mdx +23 -0
  56. package/docs/api-references/localnet/localnet/validators.mdx +28 -0
  57. package/docs/api-references/localnet/localnet.mdx +23 -0
  58. package/docs/api-references/staking/_meta.json +3 -0
  59. package/docs/api-references/staking/staking/active-validators.mdx +18 -0
  60. package/docs/api-references/staking/staking/banned-validators.mdx +18 -0
  61. package/docs/api-references/staking/staking/delegation-info.mdx +25 -0
  62. package/docs/api-references/staking/staking/delegator-claim.mdx +26 -0
  63. package/docs/api-references/staking/staking/delegator-exit.mdx +26 -0
  64. package/docs/api-references/staking/staking/delegator-join.mdx +26 -0
  65. package/docs/api-references/staking/staking/epoch-info.mdx +19 -0
  66. package/docs/api-references/staking/staking/prime-all.mdx +20 -0
  67. package/docs/api-references/staking/staking/quarantined-validators.mdx +18 -0
  68. package/docs/api-references/staking/staking/set-identity.mdx +33 -0
  69. package/docs/api-references/staking/staking/set-operator.mdx +26 -0
  70. package/docs/api-references/staking/staking/validator-claim.mdx +24 -0
  71. package/docs/api-references/staking/staking/validator-deposit.mdx +25 -0
  72. package/docs/api-references/staking/staking/validator-exit.mdx +25 -0
  73. package/docs/api-references/staking/staking/validator-history.mdx +29 -0
  74. package/docs/api-references/staking/staking/validator-info.mdx +25 -0
  75. package/docs/api-references/staking/staking/validator-join.mdx +22 -0
  76. package/docs/api-references/staking/staking/validator-prime.mdx +25 -0
  77. package/docs/api-references/staking/staking/validators.mdx +19 -0
  78. package/docs/api-references/staking/staking/wizard.mdx +20 -0
  79. package/docs/api-references/staking/staking.mdx +42 -0
  80. package/docs/api-references/transactions/_meta.json +6 -0
  81. package/docs/api-references/transactions/appeal-bond.mdx +20 -0
  82. package/docs/api-references/transactions/appeal.mdx +21 -0
  83. package/docs/api-references/transactions/receipt.mdx +25 -0
  84. package/docs/api-references/transactions/trace.mdx +21 -0
  85. package/docs/delegator-guide.md +203 -0
  86. package/docs/validator-guide.md +329 -0
  87. package/esbuild.config.dev.js +17 -0
  88. package/esbuild.config.js +22 -0
  89. package/esbuild.config.prod.js +17 -0
  90. package/eslint.config.js +60 -0
  91. package/package.json +2 -11
  92. package/renovate.json +22 -0
  93. package/scripts/generate-cli-docs.mjs +68 -5
  94. package/src/commands/account/create.ts +30 -0
  95. package/src/commands/account/export.ts +106 -0
  96. package/src/commands/account/import.ts +135 -0
  97. package/src/commands/account/index.ts +129 -0
  98. package/src/commands/account/list.ts +34 -0
  99. package/src/commands/account/lock.ts +39 -0
  100. package/src/commands/account/remove.ts +30 -0
  101. package/src/commands/account/send.ts +162 -0
  102. package/src/commands/account/show.ts +74 -0
  103. package/src/commands/account/unlock.ts +56 -0
  104. package/src/commands/account/use.ts +21 -0
  105. package/src/commands/config/getSetReset.ts +51 -0
  106. package/src/commands/config/index.ts +30 -0
  107. package/src/commands/contracts/call.ts +39 -0
  108. package/src/commands/contracts/code.ts +33 -0
  109. package/src/commands/contracts/deploy.ts +161 -0
  110. package/src/commands/contracts/index.ts +150 -0
  111. package/src/commands/contracts/schema.ts +31 -0
  112. package/src/commands/contracts/write.ts +49 -0
  113. package/src/commands/general/index.ts +45 -0
  114. package/src/commands/general/init.ts +180 -0
  115. package/src/commands/general/start.ts +128 -0
  116. package/src/commands/general/stop.ts +26 -0
  117. package/src/commands/localnet/index.ts +100 -0
  118. package/src/commands/localnet/validators.ts +269 -0
  119. package/src/commands/network/index.ts +29 -0
  120. package/src/commands/network/setNetwork.ts +77 -0
  121. package/src/commands/scaffold/index.ts +16 -0
  122. package/src/commands/scaffold/new.ts +34 -0
  123. package/src/commands/staking/StakingAction.ts +279 -0
  124. package/src/commands/staking/delegatorClaim.ts +41 -0
  125. package/src/commands/staking/delegatorExit.ts +56 -0
  126. package/src/commands/staking/delegatorJoin.ts +44 -0
  127. package/src/commands/staking/index.ts +357 -0
  128. package/src/commands/staking/setIdentity.ts +78 -0
  129. package/src/commands/staking/setOperator.ts +46 -0
  130. package/src/commands/staking/stakingInfo.ts +584 -0
  131. package/src/commands/staking/validatorClaim.ts +43 -0
  132. package/src/commands/staking/validatorDeposit.ts +48 -0
  133. package/src/commands/staking/validatorExit.ts +63 -0
  134. package/src/commands/staking/validatorHistory.ts +300 -0
  135. package/src/commands/staking/validatorJoin.ts +47 -0
  136. package/src/commands/staking/validatorPrime.ts +73 -0
  137. package/src/commands/staking/wizard.ts +809 -0
  138. package/src/commands/transactions/appeal.ts +83 -0
  139. package/src/commands/transactions/index.ts +60 -0
  140. package/src/commands/transactions/receipt.ts +90 -0
  141. package/src/commands/transactions/trace.ts +42 -0
  142. package/src/commands/update/index.ts +25 -0
  143. package/src/commands/update/ollama.ts +103 -0
  144. package/src/lib/actions/BaseAction.ts +301 -0
  145. package/src/lib/clients/jsonRpcClient.ts +41 -0
  146. package/src/lib/clients/system.ts +73 -0
  147. package/src/lib/config/ConfigFileManager.ts +194 -0
  148. package/src/lib/config/KeychainManager.ts +89 -0
  149. package/src/lib/config/simulator.ts +68 -0
  150. package/src/lib/config/text.ts +2 -0
  151. package/src/lib/errors/missingRequirement.ts +9 -0
  152. package/src/lib/errors/versionRequired.ts +9 -0
  153. package/src/lib/interfaces/ISimulatorService.ts +39 -0
  154. package/src/lib/services/simulator.ts +386 -0
  155. package/src/types/node-fetch.d.ts +1 -0
  156. package/tests/actions/appeal.test.ts +141 -0
  157. package/tests/actions/call.test.ts +94 -0
  158. package/tests/actions/code.test.ts +87 -0
  159. package/tests/actions/create.test.ts +65 -0
  160. package/tests/actions/deploy.test.ts +420 -0
  161. package/tests/actions/getSetReset.test.ts +88 -0
  162. package/tests/actions/init.test.ts +483 -0
  163. package/tests/actions/lock.test.ts +86 -0
  164. package/tests/actions/new.test.ts +80 -0
  165. package/tests/actions/ollama.test.ts +193 -0
  166. package/tests/actions/receipt.test.ts +261 -0
  167. package/tests/actions/schema.test.ts +94 -0
  168. package/tests/actions/setNetwork.test.ts +161 -0
  169. package/tests/actions/staking.test.ts +280 -0
  170. package/tests/actions/start.test.ts +257 -0
  171. package/tests/actions/stop.test.ts +77 -0
  172. package/tests/actions/unlock.test.ts +139 -0
  173. package/tests/actions/validators.test.ts +750 -0
  174. package/tests/actions/write.test.ts +102 -0
  175. package/tests/commands/account.test.ts +146 -0
  176. package/tests/commands/appeal.test.ts +97 -0
  177. package/tests/commands/call.test.ts +78 -0
  178. package/tests/commands/code.test.ts +69 -0
  179. package/tests/commands/config.test.ts +54 -0
  180. package/tests/commands/deploy.test.ts +83 -0
  181. package/tests/commands/init.test.ts +101 -0
  182. package/tests/commands/localnet.test.ts +131 -0
  183. package/tests/commands/network.test.ts +60 -0
  184. package/tests/commands/new.test.ts +68 -0
  185. package/tests/commands/parseArg.test.ts +156 -0
  186. package/tests/commands/receipt.test.ts +142 -0
  187. package/tests/commands/schema.test.ts +67 -0
  188. package/tests/commands/staking.test.ts +329 -0
  189. package/tests/commands/stop.test.ts +27 -0
  190. package/tests/commands/up.test.ts +105 -0
  191. package/tests/commands/update.test.ts +45 -0
  192. package/tests/commands/write.test.ts +76 -0
  193. package/tests/index.test.ts +56 -0
  194. package/tests/libs/baseAction.test.ts +535 -0
  195. package/tests/libs/configFileManager.test.ts +118 -0
  196. package/tests/libs/jsonRpcClient.test.ts +59 -0
  197. package/tests/libs/keychainManager.test.ts +156 -0
  198. package/tests/libs/platformCommands.test.ts +78 -0
  199. package/tests/libs/system.test.ts +148 -0
  200. package/tests/services/simulator.test.ts +789 -0
  201. package/tests/smoke.test.ts +134 -0
  202. package/tests/utils.ts +13 -0
  203. package/tsconfig.json +120 -0
  204. package/vitest.config.ts +13 -0
  205. package/vitest.smoke.config.ts +17 -0
package/dist/index.js CHANGED
@@ -20078,7 +20078,7 @@ var require_cli_table3 = __commonJS({
20078
20078
  import { program } from "commander";
20079
20079
 
20080
20080
  // package.json
20081
- var version = "0.38.8";
20081
+ var version = "0.38.10";
20082
20082
  var package_default = {
20083
20083
  name: "genlayer",
20084
20084
  version,
@@ -20088,15 +20088,6 @@ var package_default = {
20088
20088
  bin: {
20089
20089
  genlayer: "./dist/index.js"
20090
20090
  },
20091
- files: [
20092
- "dist",
20093
- "scripts",
20094
- "templates",
20095
- ".env.example",
20096
- "docker-compose.yml",
20097
- "README.md",
20098
- "LICENSE"
20099
- ],
20100
20091
  scripts: {
20101
20092
  test: "vitest",
20102
20093
  "test:watch": "vitest --watch",
@@ -20157,7 +20148,7 @@ var package_default = {
20157
20148
  dotenv: "^17.0.0",
20158
20149
  ethers: "^6.13.4",
20159
20150
  "fs-extra": "^11.3.0",
20160
- "genlayer-js": "^0.23.0",
20151
+ "genlayer-js": "^0.27.9",
20161
20152
  inquirer: "^12.0.0",
20162
20153
  keytar: "^7.9.0",
20163
20154
  "node-fetch": "^3.0.0",
@@ -50653,7 +50644,7 @@ var testnetBradbury = defineChain({
50653
50644
  defaultConsensusMaxRotations: 3
50654
50645
  });
50655
50646
 
50656
- // node_modules/genlayer-js/dist/chunk-ZHBOSLFN.js
50647
+ // node_modules/genlayer-js/dist/chunk-EY35NPSE.js
50657
50648
  var CalldataAddress = class {
50658
50649
  constructor(addr) {
50659
50650
  __publicField(this, "bytes");
@@ -50780,6 +50771,12 @@ var transactionResultNumberToName = {
50780
50771
  "7": "MAJORITY_DISAGREE"
50781
50772
  /* MAJORITY_DISAGREE */
50782
50773
  };
50774
+ var executionResultNumberToName = {
50775
+ "0": "NOT_VOTED",
50776
+ "1": "FINISHED_WITH_RETURN",
50777
+ "2": "FINISHED_WITH_ERROR"
50778
+ /* FINISHED_WITH_ERROR */
50779
+ };
50783
50780
  var voteTypeNumberToName = {
50784
50781
  "0": "NOT_VOTED",
50785
50782
  "1": "AGREE",
@@ -51413,9 +51410,10 @@ function extractGenCallResult(result) {
51413
51410
  }
51414
51411
  var contractActions = (client, publicClient) => {
51415
51412
  return {
51413
+ /** Retrieves the source code of a deployed contract. Localnet only. */
51416
51414
  getContractCode: async (address) => {
51417
51415
  if (client.chain.id !== localnet.id) {
51418
- throw new Error("Getting contract code is not supported on this network");
51416
+ throw new Error(`getContractCode is only available on localnet (current chain: ${client.chain.name})`);
51419
51417
  }
51420
51418
  const result = await client.request({
51421
51419
  method: "gen_getContractCode",
@@ -51424,9 +51422,10 @@ var contractActions = (client, publicClient) => {
51424
51422
  const codeBytes = b64ToArray(result);
51425
51423
  return new TextDecoder().decode(codeBytes);
51426
51424
  },
51425
+ /** Gets the schema (methods and constructor) of a deployed contract. Localnet only. */
51427
51426
  getContractSchema: async (address) => {
51428
51427
  if (client.chain.id !== localnet.id) {
51429
- throw new Error("Contract schema is not supported on this network");
51428
+ throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
51430
51429
  }
51431
51430
  const schema = await client.request({
51432
51431
  method: "gen_getContractSchema",
@@ -51434,9 +51433,10 @@ var contractActions = (client, publicClient) => {
51434
51433
  });
51435
51434
  return schema;
51436
51435
  },
51436
+ /** Generates a schema for contract code without deploying it. Localnet only. */
51437
51437
  getContractSchemaForCode: async (contractCode) => {
51438
51438
  if (client.chain.id !== localnet.id) {
51439
- throw new Error("Contract schema is not supported on this network");
51439
+ throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
51440
51440
  }
51441
51441
  const schema = await client.request({
51442
51442
  method: "gen_getContractSchemaForCode",
@@ -51444,6 +51444,7 @@ var contractActions = (client, publicClient) => {
51444
51444
  });
51445
51445
  return schema;
51446
51446
  },
51447
+ /** Executes a read-only contract call without modifying state. */
51447
51448
  readContract: async (args) => {
51448
51449
  const {
51449
51450
  account,
@@ -51481,6 +51482,7 @@ var contractActions = (client, publicClient) => {
51481
51482
  }
51482
51483
  return toJsonSafeDeep(decoded);
51483
51484
  },
51485
+ /** Simulates a state-modifying contract call without executing on-chain. */
51484
51486
  simulateWriteContract: async (args) => {
51485
51487
  const {
51486
51488
  account,
@@ -51513,6 +51515,7 @@ var contractActions = (client, publicClient) => {
51513
51515
  const resultBinary = fromHex(prefixedResult, "bytes");
51514
51516
  return decode2(resultBinary);
51515
51517
  },
51518
+ /** Executes a state-modifying function on a contract through consensus. Returns the transaction hash. */
51516
51519
  writeContract: async (args) => {
51517
51520
  const {
51518
51521
  account,
@@ -51543,6 +51546,7 @@ var contractActions = (client, publicClient) => {
51543
51546
  value
51544
51547
  });
51545
51548
  },
51549
+ /** Deploys a new intelligent contract to GenLayer. Returns the transaction hash. */
51546
51550
  deployContract: async (args) => {
51547
51551
  const {
51548
51552
  account,
@@ -51574,6 +51578,7 @@ var contractActions = (client, publicClient) => {
51574
51578
  senderAccount
51575
51579
  });
51576
51580
  },
51581
+ /** Calculates the minimum bond required to appeal a transaction. */
51577
51582
  getMinAppealBond: async (args) => {
51578
51583
  const { txId } = args;
51579
51584
  if (!client.chain.feeManagerContract?.address || !client.chain.roundsStorageContract?.address) {
@@ -51595,6 +51600,7 @@ var contractActions = (client, publicClient) => {
51595
51600
  });
51596
51601
  return minBond;
51597
51602
  },
51603
+ /** Appeals a consensus transaction to trigger a new round of validation. */
51598
51604
  appealTransaction: async (args) => {
51599
51605
  const { account, txId } = args;
51600
51606
  let { value } = args;
@@ -51638,6 +51644,17 @@ var validateAccount = (Account4) => {
51638
51644
  }
51639
51645
  return Account4;
51640
51646
  };
51647
+ var CREATED_TRANSACTION_EVENT_ABI = [
51648
+ {
51649
+ anonymous: false,
51650
+ inputs: [
51651
+ { indexed: true, internalType: "bytes32", name: "txId", type: "bytes32" },
51652
+ { indexed: false, internalType: "uint256", name: "txSlot", type: "uint256" }
51653
+ ],
51654
+ name: "CreatedTransaction",
51655
+ type: "event"
51656
+ }
51657
+ ];
51641
51658
  var ADD_TRANSACTION_ABI_V5 = [
51642
51659
  {
51643
51660
  type: "function",
@@ -51752,6 +51769,25 @@ var isAddTransactionAbiMismatchError = (error) => {
51752
51769
  ].filter(Boolean).join(" ").toLowerCase();
51753
51770
  return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("invalid pointer") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
51754
51771
  };
51772
+ var extractTxIdFromLogs = (client, logs) => {
51773
+ const newTxEvents = parseEventLogs({
51774
+ abi: client.chain.consensusMainContract?.abi,
51775
+ eventName: "NewTransaction",
51776
+ logs
51777
+ });
51778
+ if (newTxEvents.length > 0) {
51779
+ return newTxEvents[0].args["txId"];
51780
+ }
51781
+ const createdTxEvents = parseEventLogs({
51782
+ abi: CREATED_TRANSACTION_EVENT_ABI,
51783
+ eventName: "CreatedTransaction",
51784
+ logs
51785
+ });
51786
+ if (createdTxEvents.length > 0) {
51787
+ return createdTxEvents[0].args["txId"];
51788
+ }
51789
+ return null;
51790
+ };
51755
51791
  var _sendTransaction = async ({
51756
51792
  client,
51757
51793
  publicClient,
@@ -51761,7 +51797,7 @@ var _sendTransaction = async ({
51761
51797
  value = 0n
51762
51798
  }) => {
51763
51799
  if (!client.chain.consensusMainContract?.address) {
51764
- throw new Error("Consensus main contract not initialized. Please ensure client is properly initialized.");
51800
+ throw new Error(`Consensus main contract address not found in chain config for "${client.chain.name}".`);
51765
51801
  }
51766
51802
  const validatedSenderAccount = validateAccount(senderAccount);
51767
51803
  const nonce = await client.getCurrentNonce({ address: validatedSenderAccount.address });
@@ -51780,7 +51816,7 @@ var _sendTransaction = async ({
51780
51816
  }
51781
51817
  if (validatedSenderAccount?.type === "local") {
51782
51818
  if (!validatedSenderAccount?.signTransaction) {
51783
- throw new Error("Account does not support signTransaction");
51819
+ throw new Error("Local account does not support signTransaction. Use a private key account created via privateKeyToAccount().");
51784
51820
  }
51785
51821
  const gasPriceHex2 = await client.request({
51786
51822
  method: "eth_gasPrice"
@@ -51800,17 +51836,15 @@ var _sendTransaction = async ({
51800
51836
  const txHash = await client.sendRawTransaction({ serializedTransaction });
51801
51837
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
51802
51838
  if (receipt.status === "reverted") {
51803
- throw new Error("Transaction reverted");
51839
+ throw new Error(`Transaction reverted: EVM tx ${txHash} to consensus contract ${client.chain.consensusMainContract?.address} was reverted.`);
51804
51840
  }
51805
- const newTxEvents = parseEventLogs({
51806
- abi: client.chain.consensusMainContract?.abi,
51807
- eventName: "NewTransaction",
51808
- logs: receipt.logs
51809
- });
51810
- if (newTxEvents.length === 0) {
51811
- throw new Error("Transaction not processed by consensus");
51841
+ const txId = extractTxIdFromLogs(client, receipt.logs);
51842
+ if (!txId) {
51843
+ throw new Error(
51844
+ `Transaction not processed by consensus: EVM tx ${txHash} succeeded but no NewTransaction or CreatedTransaction event was found in the receipt logs.`
51845
+ );
51812
51846
  }
51813
- return newTxEvents[0].args["txId"];
51847
+ return txId;
51814
51848
  }
51815
51849
  let gasPriceHex;
51816
51850
  try {
@@ -51836,10 +51870,21 @@ var _sendTransaction = async ({
51836
51870
  chainId: `0x${client.chain.id.toString(16)}`,
51837
51871
  ...gasPriceHex ? { gasPrice: gasPriceHex } : {}
51838
51872
  };
51839
- return await client.request({
51873
+ const evmTxHash = await client.request({
51840
51874
  method: "eth_sendTransaction",
51841
51875
  params: [formattedRequest]
51842
51876
  });
51877
+ const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
51878
+ if (externalReceipt.status === "reverted") {
51879
+ throw new Error(`Transaction reverted: EVM tx ${evmTxHash} to consensus contract ${client.chain.consensusMainContract?.address} was reverted.`);
51880
+ }
51881
+ const externalTxId = extractTxIdFromLogs(client, externalReceipt.logs);
51882
+ if (!externalTxId) {
51883
+ throw new Error(
51884
+ `Transaction not processed by consensus: EVM tx ${evmTxHash} succeeded but no NewTransaction or CreatedTransaction event was found in the receipt logs.`
51885
+ );
51886
+ }
51887
+ return externalTxId;
51843
51888
  };
51844
51889
  try {
51845
51890
  return await sendWithEncodedData(encodedData);
@@ -51960,6 +52005,8 @@ var decodeTransaction = (tx) => {
51960
52005
  },
51961
52006
  statusName: transactionsStatusNumberToName[String(tx.status)],
51962
52007
  resultName: transactionResultNumberToName[String(tx.result)],
52008
+ txExecutionResult: tx.txExecutionResult !== void 0 ? Number(tx.txExecutionResult) : void 0,
52009
+ txExecutionResultName: tx.txExecutionResult !== void 0 ? executionResultNumberToName[String(tx.txExecutionResult)] : void 0,
51963
52010
  lastRound: {
51964
52011
  ...tx.lastRound,
51965
52012
  round: tx.lastRound?.round?.toString() ?? "0",
@@ -52093,6 +52140,7 @@ var decodeLocalnetTransaction = (tx) => {
52093
52140
  return tx;
52094
52141
  };
52095
52142
  var receiptActions = (client, publicClient) => ({
52143
+ /** Polls until a transaction reaches the specified status. Returns the transaction receipt. */
52096
52144
  waitForTransactionReceipt: async ({
52097
52145
  hash: hash3,
52098
52146
  status = "ACCEPTED",
@@ -52104,7 +52152,7 @@ var receiptActions = (client, publicClient) => ({
52104
52152
  hash: hash3
52105
52153
  });
52106
52154
  if (!transaction) {
52107
- throw new Error("Transaction not found");
52155
+ throw new Error(`Transaction not found: ${hash3}`);
52108
52156
  }
52109
52157
  const transactionStatusString = String(transaction.status);
52110
52158
  const requestedStatus = transactionsStatusNameToNumber[status];
@@ -52119,7 +52167,7 @@ var receiptActions = (client, publicClient) => ({
52119
52167
  return finalTransaction;
52120
52168
  }
52121
52169
  if (retries === 0) {
52122
- throw new Error("Transaction status is not " + status);
52170
+ throw new Error(`Timed out waiting for transaction ${hash3} to reach status "${status}" (current status: ${transactionStatusString}).`);
52123
52171
  }
52124
52172
  await sleep(interval);
52125
52173
  return receiptActions(client, publicClient).waitForTransactionReceipt({
@@ -52132,6 +52180,7 @@ var receiptActions = (client, publicClient) => ({
52132
52180
  }
52133
52181
  });
52134
52182
  var transactionActions = (client, publicClient) => ({
52183
+ /** Fetches transaction data including status, execution result, and consensus details. */
52135
52184
  getTransaction: async ({ hash: hash3 }) => {
52136
52185
  if (client.chain.isStudio) {
52137
52186
  const transaction2 = await client.getTransaction({ hash: hash3 });
@@ -52140,18 +52189,62 @@ var transactionActions = (client, publicClient) => ({
52140
52189
  transaction2.statusName = localnetStatus;
52141
52190
  return decodeLocalnetTransaction(transaction2);
52142
52191
  }
52143
- const transaction = await publicClient.readContract({
52144
- address: client.chain.consensusDataContract?.address,
52145
- abi: client.chain.consensusDataContract?.abi,
52146
- functionName: "getTransactionData",
52147
- args: [
52148
- hash3,
52149
- Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)
52150
- // unix seconds
52151
- ]
52152
- });
52192
+ const contractAddress = client.chain.consensusDataContract?.address;
52193
+ const contractAbi = client.chain.consensusDataContract?.abi;
52194
+ const [txDataRaw, allDataRaw] = await Promise.all([
52195
+ publicClient.readContract({
52196
+ address: contractAddress,
52197
+ abi: contractAbi,
52198
+ functionName: "getTransactionData",
52199
+ args: [hash3, Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)]
52200
+ }),
52201
+ publicClient.readContract({
52202
+ address: contractAddress,
52203
+ abi: contractAbi,
52204
+ functionName: "getTransactionAllData",
52205
+ args: [hash3]
52206
+ })
52207
+ ]);
52208
+ const txData = txDataRaw;
52209
+ const [txAllData, _roundsData] = allDataRaw;
52210
+ const transaction = {
52211
+ ...txData,
52212
+ txExecutionResult: Number(txAllData.txExecutionResult)
52213
+ };
52153
52214
  return decodeTransaction(transaction);
52154
52215
  },
52216
+ /** Returns transaction IDs of child transactions created from emitted messages. */
52217
+ getTriggeredTransactionIds: async ({ hash: hash3 }) => {
52218
+ if (client.chain.isStudio) {
52219
+ const tx2 = await client.getTransaction({ hash: hash3 });
52220
+ return tx2.triggered_transactions ?? [];
52221
+ }
52222
+ const tx = await transactionActions(client, publicClient).getTransaction({ hash: hash3 });
52223
+ const proposalBlock = BigInt(tx.readStateBlockRange?.proposalBlock ?? "0");
52224
+ if (proposalBlock === BigInt(0)) return [];
52225
+ const scanRange = BigInt(100);
52226
+ const latestBlock = await publicClient.getBlockNumber();
52227
+ const toBlock = proposalBlock + scanRange < latestBlock ? proposalBlock + scanRange : latestBlock;
52228
+ const consensusAddress = client.chain.consensusMainContract?.address;
52229
+ const internalMessageProcessedTopic = keccak256(stringToBytes("InternalMessageProcessed(bytes32,address,address)"));
52230
+ const logs = await publicClient.getLogs({
52231
+ address: consensusAddress,
52232
+ event: void 0,
52233
+ fromBlock: proposalBlock,
52234
+ toBlock,
52235
+ topics: [internalMessageProcessedTopic, hash3]
52236
+ });
52237
+ return logs.map((log) => log.topics[1]).filter(Boolean);
52238
+ },
52239
+ /** Fetches the full execution trace including return data, stdout, stderr, and GenVM logs. */
52240
+ debugTraceTransaction: async ({ hash: hash3, round = 0 }) => {
52241
+ const result = await client.request({
52242
+ method: "gen_dbg_traceTransaction",
52243
+ params: [{ txID: hash3, round }]
52244
+ });
52245
+ return result;
52246
+ },
52247
+ /** Cancels a pending transaction. Studio networks only. */
52155
52248
  cancelTransaction: async ({ hash: hash3 }) => {
52156
52249
  if (!client.chain.isStudio) {
52157
52250
  throw new Error("cancelTransaction is only available on studio-based chains (localnet/studionet)");
@@ -52179,6 +52272,33 @@ var transactionActions = (client, publicClient) => ({
52179
52272
  params: [hash3, signature]
52180
52273
  });
52181
52274
  },
52275
+ /** Returns the queue slot position of a transaction in the pending queue. */
52276
+ getTransactionQueuePosition: async ({ hash: hash3 }) => {
52277
+ const consensusAddress = client.chain.consensusMainContract?.address;
52278
+ const consensusAbi = client.chain.consensusMainContract?.abi;
52279
+ const queuesAddress = await publicClient.readContract({
52280
+ address: consensusAddress,
52281
+ abi: consensusAbi,
52282
+ functionName: "queues"
52283
+ });
52284
+ const QUEUES_ABI = [
52285
+ {
52286
+ inputs: [{ internalType: "bytes32", name: "txId", type: "bytes32" }],
52287
+ name: "getTransactionQueuePosition",
52288
+ outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
52289
+ stateMutability: "view",
52290
+ type: "function"
52291
+ }
52292
+ ];
52293
+ const position = await publicClient.readContract({
52294
+ address: queuesAddress,
52295
+ abi: QUEUES_ABI,
52296
+ functionName: "getTransactionQueuePosition",
52297
+ args: [hash3]
52298
+ });
52299
+ return Number(position);
52300
+ },
52301
+ /** Estimates gas required for a transaction. */
52182
52302
  estimateTransactionGas: async (transactionParams) => {
52183
52303
  const formattedParams = {
52184
52304
  from: transactionParams.from || client.account?.address,
@@ -52450,6 +52570,7 @@ var stakingActions = (client, publicClient) => {
52450
52570
  });
52451
52571
  };
52452
52572
  return {
52573
+ /** Joins as a validator with the specified stake amount. */
52453
52574
  validatorJoin: async (options) => {
52454
52575
  const amount = parseStakingAmount(options.amount);
52455
52576
  const stakingAddress = getStakingAddress();
@@ -52491,6 +52612,7 @@ var stakingActions = (client, publicClient) => {
52491
52612
  amountRaw: amount
52492
52613
  };
52493
52614
  },
52615
+ /** Adds additional self-stake to an active validator position. */
52494
52616
  validatorDeposit: async (options) => {
52495
52617
  const amount = parseStakingAmount(options.amount);
52496
52618
  const data = encodeFunctionData({
@@ -52499,6 +52621,7 @@ var stakingActions = (client, publicClient) => {
52499
52621
  });
52500
52622
  return executeWrite({ to: getStakingAddress(), data, value: amount });
52501
52623
  },
52624
+ /** Exits a validator position by burning the specified shares. */
52502
52625
  validatorExit: async (options) => {
52503
52626
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
52504
52627
  const data = encodeFunctionData({
@@ -52508,6 +52631,7 @@ var stakingActions = (client, publicClient) => {
52508
52631
  });
52509
52632
  return executeWrite({ to: getStakingAddress(), data });
52510
52633
  },
52634
+ /** Claims pending validator withdrawals. */
52511
52635
  validatorClaim: async (options) => {
52512
52636
  if (!options?.validator && !client.account) {
52513
52637
  throw new Error("Either provide validator address or initialize client with an account");
@@ -52521,6 +52645,7 @@ var stakingActions = (client, publicClient) => {
52521
52645
  const result = await executeWrite({ to: getStakingAddress(), data });
52522
52646
  return { ...result, claimedAmount: 0n };
52523
52647
  },
52648
+ /** Primes a validator for participation in the next epoch. */
52524
52649
  validatorPrime: async (options) => {
52525
52650
  const data = encodeFunctionData({
52526
52651
  abi: STAKING_ABI,
@@ -52529,6 +52654,7 @@ var stakingActions = (client, publicClient) => {
52529
52654
  });
52530
52655
  return executeWrite({ to: getStakingAddress(), data });
52531
52656
  },
52657
+ /** Sets the operator address for a validator wallet. */
52532
52658
  setOperator: async (options) => {
52533
52659
  const data = encodeFunctionData({
52534
52660
  abi: VALIDATOR_WALLET_ABI,
@@ -52537,6 +52663,7 @@ var stakingActions = (client, publicClient) => {
52537
52663
  });
52538
52664
  return executeWrite({ to: options.validator, data });
52539
52665
  },
52666
+ /** Sets validator identity information (name, website, social links). */
52540
52667
  setIdentity: async (options) => {
52541
52668
  let extraCidBytes = "0x";
52542
52669
  if (options.extraCid) {
@@ -52563,6 +52690,7 @@ var stakingActions = (client, publicClient) => {
52563
52690
  });
52564
52691
  return executeWrite({ to: options.validator, data });
52565
52692
  },
52693
+ /** Delegates stake to a validator. */
52566
52694
  delegatorJoin: async (options) => {
52567
52695
  const amount = parseStakingAmount(options.amount);
52568
52696
  const data = encodeFunctionData({
@@ -52579,6 +52707,7 @@ var stakingActions = (client, publicClient) => {
52579
52707
  amountRaw: amount
52580
52708
  };
52581
52709
  },
52710
+ /** Exits a delegation by burning the specified shares. */
52582
52711
  delegatorExit: async (options) => {
52583
52712
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
52584
52713
  const data = encodeFunctionData({
@@ -52588,6 +52717,7 @@ var stakingActions = (client, publicClient) => {
52588
52717
  });
52589
52718
  return executeWrite({ to: getStakingAddress(), data });
52590
52719
  },
52720
+ /** Claims pending delegator withdrawals. */
52591
52721
  delegatorClaim: async (options) => {
52592
52722
  if (!options.delegator && !client.account) {
52593
52723
  throw new Error("Either provide delegator address or initialize client with an account");
@@ -52600,10 +52730,12 @@ var stakingActions = (client, publicClient) => {
52600
52730
  });
52601
52731
  return executeWrite({ to: getStakingAddress(), data });
52602
52732
  },
52733
+ /** Checks if an address is an active validator. */
52603
52734
  isValidator: async (address) => {
52604
52735
  const contract = getReadOnlyStakingContract();
52605
52736
  return contract.read.isValidator([address]);
52606
52737
  },
52738
+ /** Returns comprehensive information about a validator including stake, identity, and status. */
52607
52739
  getValidatorInfo: async (validator) => {
52608
52740
  const contract = getReadOnlyStakingContract();
52609
52741
  const isVal = await contract.read.isValidator([validator]);
@@ -52683,6 +52815,7 @@ var stakingActions = (client, publicClient) => {
52683
52815
  pendingWithdrawals
52684
52816
  };
52685
52817
  },
52818
+ /** Returns delegation stake information for a delegator-validator pair. */
52686
52819
  getStakeInfo: async (delegator, validator) => {
52687
52820
  const contract = getReadOnlyStakingContract();
52688
52821
  const shares = await contract.read.sharesOf([delegator, validator]);
@@ -52736,6 +52869,7 @@ var stakingActions = (client, publicClient) => {
52736
52869
  pendingWithdrawals
52737
52870
  };
52738
52871
  },
52872
+ /** Returns current epoch information including timing, stake requirements, and inflation data. */
52739
52873
  getEpochInfo: async () => {
52740
52874
  const contract = getReadOnlyStakingContract();
52741
52875
  const [
@@ -52792,6 +52926,7 @@ var stakingActions = (client, publicClient) => {
52792
52926
  delegatorMinStakeRaw: delMinStake
52793
52927
  };
52794
52928
  },
52929
+ /** Returns detailed data for a specific epoch. */
52795
52930
  getEpochData: async (epochNumber) => {
52796
52931
  const contract = getReadOnlyStakingContract();
52797
52932
  const [currentEpoch, epochOdd, epochEven] = await Promise.all([
@@ -52820,19 +52955,23 @@ var stakingActions = (client, publicClient) => {
52820
52955
  slashed: raw[10]
52821
52956
  };
52822
52957
  },
52958
+ /** Returns addresses of all currently active validators. */
52823
52959
  getActiveValidators: async () => {
52824
52960
  const contract = getReadOnlyStakingContract();
52825
52961
  const validators = await contract.read.activeValidators();
52826
52962
  return validators.filter((v) => v !== "0x0000000000000000000000000000000000000000");
52827
52963
  },
52964
+ /** Returns the count of active validators. */
52828
52965
  getActiveValidatorsCount: async () => {
52829
52966
  const contract = getReadOnlyStakingContract();
52830
52967
  return contract.read.activeValidatorsCount();
52831
52968
  },
52969
+ /** Returns addresses of validators currently in quarantine. */
52832
52970
  getQuarantinedValidators: async () => {
52833
52971
  const contract = getReadOnlyStakingContract();
52834
52972
  return contract.read.getValidatorQuarantineList();
52835
52973
  },
52974
+ /** Returns banned validators with ban duration and permanent ban status. */
52836
52975
  getBannedValidators: async (startIndex = 0n, size5 = 100n) => {
52837
52976
  const contract = getReadOnlyStakingContract();
52838
52977
  const result = await contract.read.getAllBannedValidators([startIndex, size5]);
@@ -52842,6 +52981,7 @@ var stakingActions = (client, publicClient) => {
52842
52981
  permanentlyBanned: v.permanentlyBanned
52843
52982
  }));
52844
52983
  },
52984
+ /** Returns detailed quarantine information with pagination. */
52845
52985
  getQuarantinedValidatorsDetailed: async (startIndex = 0n, size5 = 100n) => {
52846
52986
  const contract = getReadOnlyStakingContract();
52847
52987
  const result = await contract.read.getAllQuarantinedValidators([startIndex, size5]);
@@ -52869,11 +53009,19 @@ function chainActions(_client) {
52869
53009
  }
52870
53010
  };
52871
53011
  }
53012
+ var PROVIDER_METHODS = /* @__PURE__ */ new Set([
53013
+ "eth_accounts",
53014
+ "eth_requestAccounts",
53015
+ "eth_sendTransaction",
53016
+ "eth_signTransaction",
53017
+ "personal_sign",
53018
+ "eth_signTypedData_v4"
53019
+ ]);
52872
53020
  var getCustomTransportConfig = (config, chainConfig) => {
52873
53021
  const isAddress2 = typeof config.account !== "object";
52874
53022
  return {
52875
53023
  async request({ method, params = [] }) {
52876
- if (method.startsWith("eth_") && isAddress2) {
53024
+ if (PROVIDER_METHODS.has(method) && isAddress2) {
52877
53025
  const provider = config.provider || (typeof window !== "undefined" ? window.ethereum : void 0);
52878
53026
  if (provider) {
52879
53027
  try {
@@ -52884,29 +53032,27 @@ var getCustomTransportConfig = (config, chainConfig) => {
52884
53032
  }
52885
53033
  }
52886
53034
  }
52887
- {
52888
- try {
52889
- const response = await fetch(chainConfig.rpcUrls.default.http[0], {
52890
- method: "POST",
52891
- headers: {
52892
- "Content-Type": "application/json"
52893
- },
52894
- body: JSON.stringify({
52895
- jsonrpc: "2.0",
52896
- id: Date.now(),
52897
- method,
52898
- params
52899
- })
52900
- });
52901
- const data = await response.json();
52902
- if (data.error) {
52903
- throw data.error;
52904
- }
52905
- return data.result;
52906
- } catch (err) {
52907
- console.error(`Error fetching ${method} from GenLayer RPC`);
52908
- throw err;
53035
+ try {
53036
+ const response = await fetch(chainConfig.rpcUrls.default.http[0], {
53037
+ method: "POST",
53038
+ headers: {
53039
+ "Content-Type": "application/json"
53040
+ },
53041
+ body: JSON.stringify({
53042
+ jsonrpc: "2.0",
53043
+ id: Date.now(),
53044
+ method,
53045
+ params
53046
+ })
53047
+ });
53048
+ const data = await response.json();
53049
+ if (data.error) {
53050
+ throw data.error;
52909
53051
  }
53052
+ return data.result;
53053
+ } catch (err) {
53054
+ console.error(`GenLayer RPC error (${method}):`, err.message || err);
53055
+ throw err;
52910
53056
  }
52911
53057
  }
52912
53058
  };
@@ -53928,6 +54074,9 @@ Run npm install -g genlayer to update
53928
54074
  `);
53929
54075
  }
53930
54076
  }
54077
+ async ensureDockerRunning() {
54078
+ await this.docker.ping();
54079
+ }
53931
54080
  async checkInstallRequirements() {
53932
54081
  const requirementsInstalled = {
53933
54082
  docker: false
@@ -54278,6 +54427,16 @@ var StartAction = class extends BaseAction {
54278
54427
  this.simulatorService.setComposeOptions(headless, ollama);
54279
54428
  this.startSpinner("Checking CLI version...");
54280
54429
  await this.simulatorService.checkCliVersion();
54430
+ this.setSpinnerText("Checking Docker...");
54431
+ try {
54432
+ await this.simulatorService.ensureDockerRunning();
54433
+ } catch (error) {
54434
+ this.failSpinner(
54435
+ "Docker is not running. Please start Docker Desktop and try again.",
54436
+ error
54437
+ );
54438
+ return;
54439
+ }
54281
54440
  const isRunning = await this.simulatorService.isLocalnetRunning();
54282
54441
  if (isRunning) {
54283
54442
  this.stopSpinner();
@@ -0,0 +1,9 @@
1
+ {
2
+ "environment": "Environment",
3
+ "configuration": "Configuration",
4
+ "contracts": "Contracts",
5
+ "transactions": "Transactions",
6
+ "accounts": "Accounts",
7
+ "staking": "Staking",
8
+ "localnet": "Localnet"
9
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "account": "account"
3
+ }
@@ -0,0 +1,19 @@
1
+ ---
2
+ title: account create
3
+ ---
4
+
5
+ Create a new account with encrypted keystore
6
+
7
+ ### Usage
8
+
9
+ `$ genlayer account create [options]`
10
+
11
+ ### Options
12
+
13
+ | Short | Long | Description | Required | Default |
14
+ | --- | --- | --- | :---: | --- |
15
+ | | --name &lt;name&gt; | Name for the account | No | |
16
+ | | --password &lt;password&gt; | Password for the keystore (skips interactive prompt) | No | |
17
+ | | --overwrite | Overwrite existing account | No | `false` |
18
+ | | --no-set-active | Do not set as active account | No | |
19
+ | -h | --help | display help for command | No | |