genlayer-js 0.25.0 → 0.26.1

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.
package/dist/index.cjs CHANGED
@@ -530,6 +530,7 @@ function extractGenCallResult(result) {
530
530
  }
531
531
  var contractActions = (client, publicClient) => {
532
532
  return {
533
+ /** Retrieves the source code of a deployed contract. Localnet only. */
533
534
  getContractCode: async (address) => {
534
535
  if (client.chain.id !== _chunkNOMVZBCRcjs.localnet.id) {
535
536
  throw new Error("Getting contract code is not supported on this network");
@@ -541,6 +542,7 @@ var contractActions = (client, publicClient) => {
541
542
  const codeBytes = b64ToArray(result);
542
543
  return new TextDecoder().decode(codeBytes);
543
544
  },
545
+ /** Gets the schema (methods and constructor) of a deployed contract. Localnet only. */
544
546
  getContractSchema: async (address) => {
545
547
  if (client.chain.id !== _chunkNOMVZBCRcjs.localnet.id) {
546
548
  throw new Error("Contract schema is not supported on this network");
@@ -551,6 +553,7 @@ var contractActions = (client, publicClient) => {
551
553
  });
552
554
  return schema;
553
555
  },
556
+ /** Generates a schema for contract code without deploying it. Localnet only. */
554
557
  getContractSchemaForCode: async (contractCode) => {
555
558
  if (client.chain.id !== _chunkNOMVZBCRcjs.localnet.id) {
556
559
  throw new Error("Contract schema is not supported on this network");
@@ -561,6 +564,7 @@ var contractActions = (client, publicClient) => {
561
564
  });
562
565
  return schema;
563
566
  },
567
+ /** Executes a read-only contract call without modifying state. */
564
568
  readContract: async (args) => {
565
569
  const {
566
570
  account,
@@ -597,6 +601,7 @@ var contractActions = (client, publicClient) => {
597
601
  }
598
602
  return toJsonSafeDeep(decoded);
599
603
  },
604
+ /** Simulates a state-modifying contract call without executing on-chain. */
600
605
  simulateWriteContract: async (args) => {
601
606
  const {
602
607
  account,
@@ -628,6 +633,7 @@ var contractActions = (client, publicClient) => {
628
633
  const resultBinary = _viem.fromHex.call(void 0, prefixedResult, "bytes");
629
634
  return decode(resultBinary);
630
635
  },
636
+ /** Executes a state-modifying function on a contract through consensus. Returns the transaction hash. */
631
637
  writeContract: async (args) => {
632
638
  const {
633
639
  account,
@@ -658,6 +664,7 @@ var contractActions = (client, publicClient) => {
658
664
  value
659
665
  });
660
666
  },
667
+ /** Deploys a new intelligent contract to GenLayer. Returns the transaction hash. */
661
668
  deployContract: async (args) => {
662
669
  const {
663
670
  account,
@@ -689,6 +696,7 @@ var contractActions = (client, publicClient) => {
689
696
  senderAccount
690
697
  });
691
698
  },
699
+ /** Calculates the minimum bond required to appeal a transaction. */
692
700
  getMinAppealBond: async (args) => {
693
701
  const { txId } = args;
694
702
  if (!_optionalChain([client, 'access', _11 => _11.chain, 'access', _12 => _12.feeManagerContract, 'optionalAccess', _13 => _13.address]) || !_optionalChain([client, 'access', _14 => _14.chain, 'access', _15 => _15.roundsStorageContract, 'optionalAccess', _16 => _16.address])) {
@@ -710,6 +718,7 @@ var contractActions = (client, publicClient) => {
710
718
  });
711
719
  return minBond;
712
720
  },
721
+ /** Appeals a consensus transaction to trigger a new round of validation. */
713
722
  appealTransaction: async (args) => {
714
723
  const { account, txId } = args;
715
724
  let { value } = args;
@@ -1235,6 +1244,7 @@ var decodeLocalnetTransaction = (tx) => {
1235
1244
 
1236
1245
  // src/transactions/actions.ts
1237
1246
  var receiptActions = (client, publicClient) => ({
1247
+ /** Polls until a transaction reaches the specified status. Returns the transaction receipt. */
1238
1248
  waitForTransactionReceipt: async ({
1239
1249
  hash,
1240
1250
  status = "ACCEPTED" /* ACCEPTED */,
@@ -1274,6 +1284,7 @@ var receiptActions = (client, publicClient) => ({
1274
1284
  }
1275
1285
  });
1276
1286
  var transactionActions = (client, publicClient) => ({
1287
+ /** Fetches transaction data including status, execution result, and consensus details. */
1277
1288
  getTransaction: async ({ hash }) => {
1278
1289
  if (client.chain.isStudio) {
1279
1290
  const transaction2 = await client.getTransaction({ hash });
@@ -1306,6 +1317,7 @@ var transactionActions = (client, publicClient) => ({
1306
1317
  };
1307
1318
  return decodeTransaction(transaction);
1308
1319
  },
1320
+ /** Returns transaction IDs of child transactions created from emitted messages. */
1309
1321
  getTriggeredTransactionIds: async ({ hash }) => {
1310
1322
  if (client.chain.isStudio) {
1311
1323
  const tx2 = await client.getTransaction({ hash });
@@ -1328,6 +1340,7 @@ var transactionActions = (client, publicClient) => ({
1328
1340
  });
1329
1341
  return logs.map((log) => log.topics[1]).filter(Boolean);
1330
1342
  },
1343
+ /** Fetches the full execution trace including return data, stdout, stderr, and GenVM logs. */
1331
1344
  debugTraceTransaction: async ({ hash, round = 0 }) => {
1332
1345
  const result = await client.request({
1333
1346
  method: "gen_dbg_traceTransaction",
@@ -1335,6 +1348,7 @@ var transactionActions = (client, publicClient) => ({
1335
1348
  });
1336
1349
  return result;
1337
1350
  },
1351
+ /** Cancels a pending transaction. Studio networks only. */
1338
1352
  cancelTransaction: async ({ hash }) => {
1339
1353
  if (!client.chain.isStudio) {
1340
1354
  throw new Error("cancelTransaction is only available on studio-based chains (localnet/studionet)");
@@ -1362,6 +1376,7 @@ var transactionActions = (client, publicClient) => ({
1362
1376
  params: [hash, signature]
1363
1377
  });
1364
1378
  },
1379
+ /** Estimates gas required for a transaction. */
1365
1380
  estimateTransactionGas: async (transactionParams) => {
1366
1381
  const formattedParams = {
1367
1382
  from: transactionParams.from || _optionalChain([client, 'access', _108 => _108.account, 'optionalAccess', _109 => _109.address]),
@@ -1649,6 +1664,7 @@ var stakingActions = (client, publicClient) => {
1649
1664
  });
1650
1665
  };
1651
1666
  return {
1667
+ /** Joins as a validator with the specified stake amount. */
1652
1668
  validatorJoin: async (options) => {
1653
1669
  const amount = parseStakingAmount(options.amount);
1654
1670
  const stakingAddress = getStakingAddress();
@@ -1690,6 +1706,7 @@ var stakingActions = (client, publicClient) => {
1690
1706
  amountRaw: amount
1691
1707
  };
1692
1708
  },
1709
+ /** Adds additional self-stake to an active validator position. */
1693
1710
  validatorDeposit: async (options) => {
1694
1711
  const amount = parseStakingAmount(options.amount);
1695
1712
  const data = _viem.encodeFunctionData.call(void 0, {
@@ -1698,6 +1715,7 @@ var stakingActions = (client, publicClient) => {
1698
1715
  });
1699
1716
  return executeWrite({ to: getStakingAddress(), data, value: amount });
1700
1717
  },
1718
+ /** Exits a validator position by burning the specified shares. */
1701
1719
  validatorExit: async (options) => {
1702
1720
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1703
1721
  const data = _viem.encodeFunctionData.call(void 0, {
@@ -1707,6 +1725,7 @@ var stakingActions = (client, publicClient) => {
1707
1725
  });
1708
1726
  return executeWrite({ to: getStakingAddress(), data });
1709
1727
  },
1728
+ /** Claims pending validator withdrawals. */
1710
1729
  validatorClaim: async (options) => {
1711
1730
  if (!_optionalChain([options, 'optionalAccess', _124 => _124.validator]) && !client.account) {
1712
1731
  throw new Error("Either provide validator address or initialize client with an account");
@@ -1720,6 +1739,7 @@ var stakingActions = (client, publicClient) => {
1720
1739
  const result = await executeWrite({ to: getStakingAddress(), data });
1721
1740
  return { ...result, claimedAmount: 0n };
1722
1741
  },
1742
+ /** Primes a validator for participation in the next epoch. */
1723
1743
  validatorPrime: async (options) => {
1724
1744
  const data = _viem.encodeFunctionData.call(void 0, {
1725
1745
  abi: _chunkNOMVZBCRcjs.STAKING_ABI,
@@ -1728,6 +1748,7 @@ var stakingActions = (client, publicClient) => {
1728
1748
  });
1729
1749
  return executeWrite({ to: getStakingAddress(), data });
1730
1750
  },
1751
+ /** Sets the operator address for a validator wallet. */
1731
1752
  setOperator: async (options) => {
1732
1753
  const data = _viem.encodeFunctionData.call(void 0, {
1733
1754
  abi: _chunkNOMVZBCRcjs.VALIDATOR_WALLET_ABI,
@@ -1736,6 +1757,7 @@ var stakingActions = (client, publicClient) => {
1736
1757
  });
1737
1758
  return executeWrite({ to: options.validator, data });
1738
1759
  },
1760
+ /** Sets validator identity information (name, website, social links). */
1739
1761
  setIdentity: async (options) => {
1740
1762
  let extraCidBytes = "0x";
1741
1763
  if (options.extraCid) {
@@ -1762,6 +1784,7 @@ var stakingActions = (client, publicClient) => {
1762
1784
  });
1763
1785
  return executeWrite({ to: options.validator, data });
1764
1786
  },
1787
+ /** Delegates stake to a validator. */
1765
1788
  delegatorJoin: async (options) => {
1766
1789
  const amount = parseStakingAmount(options.amount);
1767
1790
  const data = _viem.encodeFunctionData.call(void 0, {
@@ -1778,6 +1801,7 @@ var stakingActions = (client, publicClient) => {
1778
1801
  amountRaw: amount
1779
1802
  };
1780
1803
  },
1804
+ /** Exits a delegation by burning the specified shares. */
1781
1805
  delegatorExit: async (options) => {
1782
1806
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1783
1807
  const data = _viem.encodeFunctionData.call(void 0, {
@@ -1787,6 +1811,7 @@ var stakingActions = (client, publicClient) => {
1787
1811
  });
1788
1812
  return executeWrite({ to: getStakingAddress(), data });
1789
1813
  },
1814
+ /** Claims pending delegator withdrawals. */
1790
1815
  delegatorClaim: async (options) => {
1791
1816
  if (!options.delegator && !client.account) {
1792
1817
  throw new Error("Either provide delegator address or initialize client with an account");
@@ -1799,10 +1824,12 @@ var stakingActions = (client, publicClient) => {
1799
1824
  });
1800
1825
  return executeWrite({ to: getStakingAddress(), data });
1801
1826
  },
1827
+ /** Checks if an address is an active validator. */
1802
1828
  isValidator: async (address) => {
1803
1829
  const contract = getReadOnlyStakingContract();
1804
1830
  return contract.read.isValidator([address]);
1805
1831
  },
1832
+ /** Returns comprehensive information about a validator including stake, identity, and status. */
1806
1833
  getValidatorInfo: async (validator) => {
1807
1834
  const contract = getReadOnlyStakingContract();
1808
1835
  const isVal = await contract.read.isValidator([validator]);
@@ -1882,6 +1909,7 @@ var stakingActions = (client, publicClient) => {
1882
1909
  pendingWithdrawals
1883
1910
  };
1884
1911
  },
1912
+ /** Returns delegation stake information for a delegator-validator pair. */
1885
1913
  getStakeInfo: async (delegator, validator) => {
1886
1914
  const contract = getReadOnlyStakingContract();
1887
1915
  const shares = await contract.read.sharesOf([delegator, validator]);
@@ -1935,6 +1963,7 @@ var stakingActions = (client, publicClient) => {
1935
1963
  pendingWithdrawals
1936
1964
  };
1937
1965
  },
1966
+ /** Returns current epoch information including timing, stake requirements, and inflation data. */
1938
1967
  getEpochInfo: async () => {
1939
1968
  const contract = getReadOnlyStakingContract();
1940
1969
  const [
@@ -1991,6 +2020,7 @@ var stakingActions = (client, publicClient) => {
1991
2020
  delegatorMinStakeRaw: delMinStake
1992
2021
  };
1993
2022
  },
2023
+ /** Returns detailed data for a specific epoch. */
1994
2024
  getEpochData: async (epochNumber) => {
1995
2025
  const contract = getReadOnlyStakingContract();
1996
2026
  const [currentEpoch, epochOdd, epochEven] = await Promise.all([
@@ -2019,19 +2049,23 @@ var stakingActions = (client, publicClient) => {
2019
2049
  slashed: raw[10]
2020
2050
  };
2021
2051
  },
2052
+ /** Returns addresses of all currently active validators. */
2022
2053
  getActiveValidators: async () => {
2023
2054
  const contract = getReadOnlyStakingContract();
2024
2055
  const validators = await contract.read.activeValidators();
2025
2056
  return validators.filter((v) => v !== "0x0000000000000000000000000000000000000000");
2026
2057
  },
2058
+ /** Returns the count of active validators. */
2027
2059
  getActiveValidatorsCount: async () => {
2028
2060
  const contract = getReadOnlyStakingContract();
2029
2061
  return contract.read.activeValidatorsCount();
2030
2062
  },
2063
+ /** Returns addresses of validators currently in quarantine. */
2031
2064
  getQuarantinedValidators: async () => {
2032
2065
  const contract = getReadOnlyStakingContract();
2033
2066
  return contract.read.getValidatorQuarantineList();
2034
2067
  },
2068
+ /** Returns banned validators with ban duration and permanent ban status. */
2035
2069
  getBannedValidators: async (startIndex = 0n, size = 100n) => {
2036
2070
  const contract = getReadOnlyStakingContract();
2037
2071
  const result = await contract.read.getAllBannedValidators([startIndex, size]);
@@ -2041,6 +2075,7 @@ var stakingActions = (client, publicClient) => {
2041
2075
  permanentlyBanned: v.permanentlyBanned
2042
2076
  }));
2043
2077
  },
2078
+ /** Returns detailed quarantine information with pagination. */
2044
2079
  getQuarantinedValidatorsDetailed: async (startIndex = 0n, size = 100n) => {
2045
2080
  const contract = getReadOnlyStakingContract();
2046
2081
  const result = await contract.read.getAllQuarantinedValidators([startIndex, size]);
package/dist/index.d.cts CHANGED
@@ -32,6 +32,16 @@ interface ClientConfig {
32
32
  account?: Account | Address;
33
33
  provider?: EthereumProvider;
34
34
  }
35
+ /**
36
+ * Creates a GenLayer client instance for interacting with the network.
37
+ *
38
+ * @param config - Client configuration options
39
+ * @param config.chain - Chain to connect to (localnet, testnetBradbury, etc.)
40
+ * @param config.endpoint - Custom RPC endpoint URL
41
+ * @param config.account - Account or address for signing transactions
42
+ * @param config.provider - EthereumProvider for wallet integration
43
+ * @returns Configured client with contract, transaction, and staking methods
44
+ */
35
45
  declare const createClient: (config?: ClientConfig) => GenLayerClient<GenLayerChain>;
36
46
 
37
47
  declare const generatePrivateKey: () => `0x${string}`;
package/dist/index.d.ts CHANGED
@@ -32,6 +32,16 @@ interface ClientConfig {
32
32
  account?: Account | Address;
33
33
  provider?: EthereumProvider;
34
34
  }
35
+ /**
36
+ * Creates a GenLayer client instance for interacting with the network.
37
+ *
38
+ * @param config - Client configuration options
39
+ * @param config.chain - Chain to connect to (localnet, testnetBradbury, etc.)
40
+ * @param config.endpoint - Custom RPC endpoint URL
41
+ * @param config.account - Account or address for signing transactions
42
+ * @param config.provider - EthereumProvider for wallet integration
43
+ * @returns Configured client with contract, transaction, and staking methods
44
+ */
35
45
  declare const createClient: (config?: ClientConfig) => GenLayerClient<GenLayerChain>;
36
46
 
37
47
  declare const generatePrivateKey: () => `0x${string}`;
package/dist/index.js CHANGED
@@ -530,6 +530,7 @@ function extractGenCallResult(result) {
530
530
  }
531
531
  var contractActions = (client, publicClient) => {
532
532
  return {
533
+ /** Retrieves the source code of a deployed contract. Localnet only. */
533
534
  getContractCode: async (address) => {
534
535
  if (client.chain.id !== localnet.id) {
535
536
  throw new Error("Getting contract code is not supported on this network");
@@ -541,6 +542,7 @@ var contractActions = (client, publicClient) => {
541
542
  const codeBytes = b64ToArray(result);
542
543
  return new TextDecoder().decode(codeBytes);
543
544
  },
545
+ /** Gets the schema (methods and constructor) of a deployed contract. Localnet only. */
544
546
  getContractSchema: async (address) => {
545
547
  if (client.chain.id !== localnet.id) {
546
548
  throw new Error("Contract schema is not supported on this network");
@@ -551,6 +553,7 @@ var contractActions = (client, publicClient) => {
551
553
  });
552
554
  return schema;
553
555
  },
556
+ /** Generates a schema for contract code without deploying it. Localnet only. */
554
557
  getContractSchemaForCode: async (contractCode) => {
555
558
  if (client.chain.id !== localnet.id) {
556
559
  throw new Error("Contract schema is not supported on this network");
@@ -561,6 +564,7 @@ var contractActions = (client, publicClient) => {
561
564
  });
562
565
  return schema;
563
566
  },
567
+ /** Executes a read-only contract call without modifying state. */
564
568
  readContract: async (args) => {
565
569
  const {
566
570
  account,
@@ -597,6 +601,7 @@ var contractActions = (client, publicClient) => {
597
601
  }
598
602
  return toJsonSafeDeep(decoded);
599
603
  },
604
+ /** Simulates a state-modifying contract call without executing on-chain. */
600
605
  simulateWriteContract: async (args) => {
601
606
  const {
602
607
  account,
@@ -628,6 +633,7 @@ var contractActions = (client, publicClient) => {
628
633
  const resultBinary = fromHex(prefixedResult, "bytes");
629
634
  return decode(resultBinary);
630
635
  },
636
+ /** Executes a state-modifying function on a contract through consensus. Returns the transaction hash. */
631
637
  writeContract: async (args) => {
632
638
  const {
633
639
  account,
@@ -658,6 +664,7 @@ var contractActions = (client, publicClient) => {
658
664
  value
659
665
  });
660
666
  },
667
+ /** Deploys a new intelligent contract to GenLayer. Returns the transaction hash. */
661
668
  deployContract: async (args) => {
662
669
  const {
663
670
  account,
@@ -689,6 +696,7 @@ var contractActions = (client, publicClient) => {
689
696
  senderAccount
690
697
  });
691
698
  },
699
+ /** Calculates the minimum bond required to appeal a transaction. */
692
700
  getMinAppealBond: async (args) => {
693
701
  const { txId } = args;
694
702
  if (!client.chain.feeManagerContract?.address || !client.chain.roundsStorageContract?.address) {
@@ -710,6 +718,7 @@ var contractActions = (client, publicClient) => {
710
718
  });
711
719
  return minBond;
712
720
  },
721
+ /** Appeals a consensus transaction to trigger a new round of validation. */
713
722
  appealTransaction: async (args) => {
714
723
  const { account, txId } = args;
715
724
  let { value } = args;
@@ -1235,6 +1244,7 @@ var decodeLocalnetTransaction = (tx) => {
1235
1244
 
1236
1245
  // src/transactions/actions.ts
1237
1246
  var receiptActions = (client, publicClient) => ({
1247
+ /** Polls until a transaction reaches the specified status. Returns the transaction receipt. */
1238
1248
  waitForTransactionReceipt: async ({
1239
1249
  hash,
1240
1250
  status = "ACCEPTED" /* ACCEPTED */,
@@ -1274,6 +1284,7 @@ var receiptActions = (client, publicClient) => ({
1274
1284
  }
1275
1285
  });
1276
1286
  var transactionActions = (client, publicClient) => ({
1287
+ /** Fetches transaction data including status, execution result, and consensus details. */
1277
1288
  getTransaction: async ({ hash }) => {
1278
1289
  if (client.chain.isStudio) {
1279
1290
  const transaction2 = await client.getTransaction({ hash });
@@ -1306,6 +1317,7 @@ var transactionActions = (client, publicClient) => ({
1306
1317
  };
1307
1318
  return decodeTransaction(transaction);
1308
1319
  },
1320
+ /** Returns transaction IDs of child transactions created from emitted messages. */
1309
1321
  getTriggeredTransactionIds: async ({ hash }) => {
1310
1322
  if (client.chain.isStudio) {
1311
1323
  const tx2 = await client.getTransaction({ hash });
@@ -1328,6 +1340,7 @@ var transactionActions = (client, publicClient) => ({
1328
1340
  });
1329
1341
  return logs.map((log) => log.topics[1]).filter(Boolean);
1330
1342
  },
1343
+ /** Fetches the full execution trace including return data, stdout, stderr, and GenVM logs. */
1331
1344
  debugTraceTransaction: async ({ hash, round = 0 }) => {
1332
1345
  const result = await client.request({
1333
1346
  method: "gen_dbg_traceTransaction",
@@ -1335,6 +1348,7 @@ var transactionActions = (client, publicClient) => ({
1335
1348
  });
1336
1349
  return result;
1337
1350
  },
1351
+ /** Cancels a pending transaction. Studio networks only. */
1338
1352
  cancelTransaction: async ({ hash }) => {
1339
1353
  if (!client.chain.isStudio) {
1340
1354
  throw new Error("cancelTransaction is only available on studio-based chains (localnet/studionet)");
@@ -1362,6 +1376,7 @@ var transactionActions = (client, publicClient) => ({
1362
1376
  params: [hash, signature]
1363
1377
  });
1364
1378
  },
1379
+ /** Estimates gas required for a transaction. */
1365
1380
  estimateTransactionGas: async (transactionParams) => {
1366
1381
  const formattedParams = {
1367
1382
  from: transactionParams.from || client.account?.address,
@@ -1649,6 +1664,7 @@ var stakingActions = (client, publicClient) => {
1649
1664
  });
1650
1665
  };
1651
1666
  return {
1667
+ /** Joins as a validator with the specified stake amount. */
1652
1668
  validatorJoin: async (options) => {
1653
1669
  const amount = parseStakingAmount(options.amount);
1654
1670
  const stakingAddress = getStakingAddress();
@@ -1690,6 +1706,7 @@ var stakingActions = (client, publicClient) => {
1690
1706
  amountRaw: amount
1691
1707
  };
1692
1708
  },
1709
+ /** Adds additional self-stake to an active validator position. */
1693
1710
  validatorDeposit: async (options) => {
1694
1711
  const amount = parseStakingAmount(options.amount);
1695
1712
  const data = encodeFunctionData2({
@@ -1698,6 +1715,7 @@ var stakingActions = (client, publicClient) => {
1698
1715
  });
1699
1716
  return executeWrite({ to: getStakingAddress(), data, value: amount });
1700
1717
  },
1718
+ /** Exits a validator position by burning the specified shares. */
1701
1719
  validatorExit: async (options) => {
1702
1720
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1703
1721
  const data = encodeFunctionData2({
@@ -1707,6 +1725,7 @@ var stakingActions = (client, publicClient) => {
1707
1725
  });
1708
1726
  return executeWrite({ to: getStakingAddress(), data });
1709
1727
  },
1728
+ /** Claims pending validator withdrawals. */
1710
1729
  validatorClaim: async (options) => {
1711
1730
  if (!options?.validator && !client.account) {
1712
1731
  throw new Error("Either provide validator address or initialize client with an account");
@@ -1720,6 +1739,7 @@ var stakingActions = (client, publicClient) => {
1720
1739
  const result = await executeWrite({ to: getStakingAddress(), data });
1721
1740
  return { ...result, claimedAmount: 0n };
1722
1741
  },
1742
+ /** Primes a validator for participation in the next epoch. */
1723
1743
  validatorPrime: async (options) => {
1724
1744
  const data = encodeFunctionData2({
1725
1745
  abi: STAKING_ABI,
@@ -1728,6 +1748,7 @@ var stakingActions = (client, publicClient) => {
1728
1748
  });
1729
1749
  return executeWrite({ to: getStakingAddress(), data });
1730
1750
  },
1751
+ /** Sets the operator address for a validator wallet. */
1731
1752
  setOperator: async (options) => {
1732
1753
  const data = encodeFunctionData2({
1733
1754
  abi: VALIDATOR_WALLET_ABI,
@@ -1736,6 +1757,7 @@ var stakingActions = (client, publicClient) => {
1736
1757
  });
1737
1758
  return executeWrite({ to: options.validator, data });
1738
1759
  },
1760
+ /** Sets validator identity information (name, website, social links). */
1739
1761
  setIdentity: async (options) => {
1740
1762
  let extraCidBytes = "0x";
1741
1763
  if (options.extraCid) {
@@ -1762,6 +1784,7 @@ var stakingActions = (client, publicClient) => {
1762
1784
  });
1763
1785
  return executeWrite({ to: options.validator, data });
1764
1786
  },
1787
+ /** Delegates stake to a validator. */
1765
1788
  delegatorJoin: async (options) => {
1766
1789
  const amount = parseStakingAmount(options.amount);
1767
1790
  const data = encodeFunctionData2({
@@ -1778,6 +1801,7 @@ var stakingActions = (client, publicClient) => {
1778
1801
  amountRaw: amount
1779
1802
  };
1780
1803
  },
1804
+ /** Exits a delegation by burning the specified shares. */
1781
1805
  delegatorExit: async (options) => {
1782
1806
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1783
1807
  const data = encodeFunctionData2({
@@ -1787,6 +1811,7 @@ var stakingActions = (client, publicClient) => {
1787
1811
  });
1788
1812
  return executeWrite({ to: getStakingAddress(), data });
1789
1813
  },
1814
+ /** Claims pending delegator withdrawals. */
1790
1815
  delegatorClaim: async (options) => {
1791
1816
  if (!options.delegator && !client.account) {
1792
1817
  throw new Error("Either provide delegator address or initialize client with an account");
@@ -1799,10 +1824,12 @@ var stakingActions = (client, publicClient) => {
1799
1824
  });
1800
1825
  return executeWrite({ to: getStakingAddress(), data });
1801
1826
  },
1827
+ /** Checks if an address is an active validator. */
1802
1828
  isValidator: async (address) => {
1803
1829
  const contract = getReadOnlyStakingContract();
1804
1830
  return contract.read.isValidator([address]);
1805
1831
  },
1832
+ /** Returns comprehensive information about a validator including stake, identity, and status. */
1806
1833
  getValidatorInfo: async (validator) => {
1807
1834
  const contract = getReadOnlyStakingContract();
1808
1835
  const isVal = await contract.read.isValidator([validator]);
@@ -1882,6 +1909,7 @@ var stakingActions = (client, publicClient) => {
1882
1909
  pendingWithdrawals
1883
1910
  };
1884
1911
  },
1912
+ /** Returns delegation stake information for a delegator-validator pair. */
1885
1913
  getStakeInfo: async (delegator, validator) => {
1886
1914
  const contract = getReadOnlyStakingContract();
1887
1915
  const shares = await contract.read.sharesOf([delegator, validator]);
@@ -1935,6 +1963,7 @@ var stakingActions = (client, publicClient) => {
1935
1963
  pendingWithdrawals
1936
1964
  };
1937
1965
  },
1966
+ /** Returns current epoch information including timing, stake requirements, and inflation data. */
1938
1967
  getEpochInfo: async () => {
1939
1968
  const contract = getReadOnlyStakingContract();
1940
1969
  const [
@@ -1991,6 +2020,7 @@ var stakingActions = (client, publicClient) => {
1991
2020
  delegatorMinStakeRaw: delMinStake
1992
2021
  };
1993
2022
  },
2023
+ /** Returns detailed data for a specific epoch. */
1994
2024
  getEpochData: async (epochNumber) => {
1995
2025
  const contract = getReadOnlyStakingContract();
1996
2026
  const [currentEpoch, epochOdd, epochEven] = await Promise.all([
@@ -2019,19 +2049,23 @@ var stakingActions = (client, publicClient) => {
2019
2049
  slashed: raw[10]
2020
2050
  };
2021
2051
  },
2052
+ /** Returns addresses of all currently active validators. */
2022
2053
  getActiveValidators: async () => {
2023
2054
  const contract = getReadOnlyStakingContract();
2024
2055
  const validators = await contract.read.activeValidators();
2025
2056
  return validators.filter((v) => v !== "0x0000000000000000000000000000000000000000");
2026
2057
  },
2058
+ /** Returns the count of active validators. */
2027
2059
  getActiveValidatorsCount: async () => {
2028
2060
  const contract = getReadOnlyStakingContract();
2029
2061
  return contract.read.activeValidatorsCount();
2030
2062
  },
2063
+ /** Returns addresses of validators currently in quarantine. */
2031
2064
  getQuarantinedValidators: async () => {
2032
2065
  const contract = getReadOnlyStakingContract();
2033
2066
  return contract.read.getValidatorQuarantineList();
2034
2067
  },
2068
+ /** Returns banned validators with ban duration and permanent ban status. */
2035
2069
  getBannedValidators: async (startIndex = 0n, size = 100n) => {
2036
2070
  const contract = getReadOnlyStakingContract();
2037
2071
  const result = await contract.read.getAllBannedValidators([startIndex, size]);
@@ -2041,6 +2075,7 @@ var stakingActions = (client, publicClient) => {
2041
2075
  permanentlyBanned: v.permanentlyBanned
2042
2076
  }));
2043
2077
  },
2078
+ /** Returns detailed quarantine information with pagination. */
2044
2079
  getQuarantinedValidatorsDetailed: async (startIndex = 0n, size = 100n) => {
2045
2080
  const contract = getReadOnlyStakingContract();
2046
2081
  const result = await contract.read.getAllQuarantinedValidators([startIndex, size]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.25.0",
4
+ "version": "0.26.1",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,7 +17,8 @@
17
17
  "test:smoke": "vitest run --config vitest.smoke.config.ts",
18
18
  "test:watch": "vitest --watch",
19
19
  "lint": "eslint . --fix --ext .ts",
20
- "release": "release-it --ci"
20
+ "release": "release-it --ci",
21
+ "docs": "typedoc"
21
22
  },
22
23
  "exports": {
23
24
  ".": {
@@ -55,6 +56,8 @@
55
56
  "release-it": "^17.6.0",
56
57
  "ts-node": "^10.9.2",
57
58
  "tsup": "^8.2.4",
59
+ "typedoc": "^0.28.18",
60
+ "typedoc-plugin-markdown": "^4.11.0",
58
61
  "typescript": "^5.6.2",
59
62
  "vitest": "^2.1.1"
60
63
  },