genlayer-js 0.28.4 → 0.28.6

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
@@ -6,7 +6,7 @@
6
6
 
7
7
 
8
8
 
9
- var _chunkPZEHAYIUcjs = require('./chunk-PZEHAYIU.cjs');
9
+ var _chunkN74TARFYcjs = require('./chunk-N74TARFY.cjs');
10
10
 
11
11
 
12
12
 
@@ -33,7 +33,7 @@ var _viem = require('viem');
33
33
  function accountActions(client) {
34
34
  return {
35
35
  fundAccount: async ({ address, amount }) => {
36
- if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunkPZEHAYIUcjs.localnet.id) {
36
+ if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunkN74TARFYcjs.localnet.id) {
37
37
  throw new Error("Client is not connected to the localnet");
38
38
  }
39
39
  return client.request({
@@ -417,8 +417,8 @@ function serialize(data) {
417
417
  // src/abi/index.ts
418
418
  var abi_exports = {};
419
419
  _chunk75ZPJI57cjs.__export.call(void 0, abi_exports, {
420
- STAKING_ABI: () => _chunkPZEHAYIUcjs.STAKING_ABI,
421
- VALIDATOR_WALLET_ABI: () => _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
420
+ STAKING_ABI: () => _chunkN74TARFYcjs.STAKING_ABI,
421
+ VALIDATOR_WALLET_ABI: () => _chunkN74TARFYcjs.VALIDATOR_WALLET_ABI,
422
422
  calldata: () => calldata,
423
423
  transactions: () => transactions
424
424
  });
@@ -792,60 +792,52 @@ var contractActions = (client, publicClient) => {
792
792
  }
793
793
  const senderAccount = account || client.account;
794
794
  const encodedData = _encodeSubmitAppealData({ client, txId });
795
- const validatedAccount = validateAccount(senderAccount);
796
- if (!_optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.address])) {
797
- throw new Error("Consensus main contract not initialized.");
798
- }
799
- const nonce = await client.getCurrentNonce({ address: validatedAccount.address });
800
- let estimatedGas;
801
- try {
802
- estimatedGas = await client.estimateTransactionGas({
803
- to: client.chain.consensusMainContract.address,
804
- data: encodedData,
805
- value
806
- });
807
- } catch (err) {
808
- console.error("Gas estimation failed, using default 200_000:", err);
809
- estimatedGas = 200000n;
810
- }
811
- const gasPriceHex = await client.request({ method: "eth_gasPrice" });
812
- const txRequest = {
813
- account: validatedAccount,
814
- to: client.chain.consensusMainContract.address,
815
- data: encodedData,
795
+ await _sendConsensusCall({
796
+ client,
797
+ publicClient,
798
+ encodedData,
799
+ senderAccount,
816
800
  value,
817
- gas: estimatedGas,
818
- gasPrice: BigInt(gasPriceHex),
819
- nonce,
820
- chainId: client.chain.id
821
- };
822
- if (validatedAccount.type === "local") {
823
- if (!validatedAccount.signTransaction) {
824
- throw new Error("Local account does not support signTransaction.");
825
- }
826
- const serializedTransaction = await validatedAccount.signTransaction(txRequest);
827
- const evmHash = await client.sendRawTransaction({ serializedTransaction });
828
- const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
829
- if (receipt.status === "reverted") {
830
- throw new Error(`Appeal reverted: EVM tx ${evmHash}`);
831
- }
832
- } else {
833
- const evmHash = await client.request({
834
- method: "eth_sendTransaction",
835
- params: [{
836
- from: validatedAccount.address,
837
- to: client.chain.consensusMainContract.address,
838
- data: encodedData,
839
- value: value ? `0x${value.toString(16)}` : void 0,
840
- gas: `0x${estimatedGas.toString(16)}`
841
- }]
842
- });
843
- const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
844
- if (receipt.status === "reverted") {
845
- throw new Error(`Appeal reverted: EVM tx ${evmHash}`);
846
- }
847
- }
801
+ operationName: "Appeal"
802
+ });
848
803
  return txId;
804
+ },
805
+ /** Finalizes a single GenLayer transaction that is ready to be finalized. Returns the EVM transaction hash. */
806
+ finalizeTransaction: async (args) => {
807
+ const { account, txId } = args;
808
+ const senderAccount = account || client.account;
809
+ const encodedData = _viem.encodeFunctionData.call(void 0, {
810
+ abi: _optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.abi]),
811
+ functionName: "finalizeTransaction",
812
+ args: [txId]
813
+ });
814
+ return _sendConsensusCall({
815
+ client,
816
+ publicClient,
817
+ encodedData,
818
+ senderAccount,
819
+ operationName: "Finalize"
820
+ });
821
+ },
822
+ /** Batch-finalizes idle GenLayer transactions (those stuck without progressing). Returns the EVM transaction hash. */
823
+ finalizeIdlenessTxs: async (args) => {
824
+ const { account, txIds } = args;
825
+ if (txIds.length === 0) {
826
+ throw new Error("finalizeIdlenessTxs requires at least one txId.");
827
+ }
828
+ const senderAccount = account || client.account;
829
+ const encodedData = _viem.encodeFunctionData.call(void 0, {
830
+ abi: _optionalChain([client, 'access', _38 => _38.chain, 'access', _39 => _39.consensusMainContract, 'optionalAccess', _40 => _40.abi]),
831
+ functionName: "finalizeIdlenessTxs",
832
+ args: [txIds]
833
+ });
834
+ return _sendConsensusCall({
835
+ client,
836
+ publicClient,
837
+ encodedData,
838
+ senderAccount,
839
+ operationName: "Finalize idleness"
840
+ });
849
841
  }
850
842
  };
851
843
  };
@@ -910,7 +902,7 @@ var getAddTransactionInputCount = (abi) => {
910
902
  const candidate = item;
911
903
  return candidate.type === "function" && candidate.name === "addTransaction";
912
904
  });
913
- return Array.isArray(_optionalChain([addTransactionFunction, 'optionalAccess', _38 => _38.inputs])) ? addTransactionFunction.inputs.length : 0;
905
+ return Array.isArray(_optionalChain([addTransactionFunction, 'optionalAccess', _41 => _41.inputs])) ? addTransactionFunction.inputs.length : 0;
914
906
  };
915
907
  var _encodeAddTransactionData = ({
916
908
  client,
@@ -937,7 +929,7 @@ var _encodeAddTransactionData = ({
937
929
  functionName: "addTransaction",
938
930
  args: [...addTransactionArgs, 0n]
939
931
  });
940
- if (getAddTransactionInputCount(_optionalChain([client, 'access', _39 => _39.chain, 'access', _40 => _40.consensusMainContract, 'optionalAccess', _41 => _41.abi])) >= 6) {
932
+ if (getAddTransactionInputCount(_optionalChain([client, 'access', _42 => _42.chain, 'access', _43 => _43.consensusMainContract, 'optionalAccess', _44 => _44.abi])) >= 6) {
941
933
  return {
942
934
  primaryEncodedData: encodedDataV6,
943
935
  fallbackEncodedData: encodedDataV5
@@ -953,11 +945,74 @@ var _encodeSubmitAppealData = ({
953
945
  txId
954
946
  }) => {
955
947
  return _viem.encodeFunctionData.call(void 0, {
956
- abi: _optionalChain([client, 'access', _42 => _42.chain, 'access', _43 => _43.consensusMainContract, 'optionalAccess', _44 => _44.abi]),
948
+ abi: _optionalChain([client, 'access', _45 => _45.chain, 'access', _46 => _46.consensusMainContract, 'optionalAccess', _47 => _47.abi]),
957
949
  functionName: "submitAppeal",
958
950
  args: [txId]
959
951
  });
960
952
  };
953
+ var _sendConsensusCall = async ({
954
+ client,
955
+ publicClient,
956
+ encodedData,
957
+ senderAccount,
958
+ value = 0n,
959
+ operationName = "Consensus call"
960
+ }) => {
961
+ if (!_optionalChain([client, 'access', _48 => _48.chain, 'access', _49 => _49.consensusMainContract, 'optionalAccess', _50 => _50.address])) {
962
+ throw new Error("Consensus main contract not initialized.");
963
+ }
964
+ const validatedAccount = validateAccount(senderAccount);
965
+ const nonce = await client.getCurrentNonce({ address: validatedAccount.address });
966
+ let estimatedGas;
967
+ try {
968
+ estimatedGas = await client.estimateTransactionGas({
969
+ to: client.chain.consensusMainContract.address,
970
+ data: encodedData,
971
+ value
972
+ });
973
+ } catch (err) {
974
+ console.error("Gas estimation failed, using default 200_000:", err);
975
+ estimatedGas = 200000n;
976
+ }
977
+ const gasPriceHex = await client.request({ method: "eth_gasPrice" });
978
+ if (validatedAccount.type === "local") {
979
+ if (!validatedAccount.signTransaction) {
980
+ throw new Error("Local account does not support signTransaction.");
981
+ }
982
+ const txRequest = {
983
+ account: validatedAccount,
984
+ to: client.chain.consensusMainContract.address,
985
+ data: encodedData,
986
+ value,
987
+ gas: estimatedGas,
988
+ gasPrice: BigInt(gasPriceHex),
989
+ nonce,
990
+ chainId: client.chain.id
991
+ };
992
+ const serializedTransaction = await validatedAccount.signTransaction(txRequest);
993
+ const evmHash2 = await client.sendRawTransaction({ serializedTransaction });
994
+ const receipt2 = await publicClient.waitForTransactionReceipt({ hash: evmHash2 });
995
+ if (receipt2.status === "reverted") {
996
+ throw new Error(`${operationName} reverted: EVM tx ${evmHash2}`);
997
+ }
998
+ return evmHash2;
999
+ }
1000
+ const evmHash = await client.request({
1001
+ method: "eth_sendTransaction",
1002
+ params: [{
1003
+ from: validatedAccount.address,
1004
+ to: client.chain.consensusMainContract.address,
1005
+ data: encodedData,
1006
+ value: value ? `0x${value.toString(16)}` : void 0,
1007
+ gas: `0x${estimatedGas.toString(16)}`
1008
+ }]
1009
+ });
1010
+ const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
1011
+ if (receipt.status === "reverted") {
1012
+ throw new Error(`${operationName} reverted: EVM tx ${evmHash}`);
1013
+ }
1014
+ return evmHash;
1015
+ };
961
1016
  var isAddTransactionAbiMismatchError = (error) => {
962
1017
  const seen = /* @__PURE__ */ new WeakSet();
963
1018
  const serializedError = typeof error === "object" && error !== null ? JSON.stringify(error, (_key, value) => {
@@ -974,9 +1029,9 @@ var isAddTransactionAbiMismatchError = (error) => {
974
1029
  }) : "";
975
1030
  const errorObject = error;
976
1031
  const errorMessage = [
977
- _optionalChain([errorObject, 'optionalAccess', _45 => _45.shortMessage]),
978
- _optionalChain([errorObject, 'optionalAccess', _46 => _46.details]),
979
- _optionalChain([errorObject, 'optionalAccess', _47 => _47.message]),
1032
+ _optionalChain([errorObject, 'optionalAccess', _51 => _51.shortMessage]),
1033
+ _optionalChain([errorObject, 'optionalAccess', _52 => _52.details]),
1034
+ _optionalChain([errorObject, 'optionalAccess', _53 => _53.message]),
980
1035
  serializedError,
981
1036
  String(_nullishCoalesce(error, () => ( "")))
982
1037
  ].filter(Boolean).join(" ").toLowerCase();
@@ -984,7 +1039,7 @@ var isAddTransactionAbiMismatchError = (error) => {
984
1039
  };
985
1040
  var extractTxIdFromLogs = (client, logs) => {
986
1041
  const newTxEvents = _viem.parseEventLogs.call(void 0, {
987
- abi: _optionalChain([client, 'access', _48 => _48.chain, 'access', _49 => _49.consensusMainContract, 'optionalAccess', _50 => _50.abi]),
1042
+ abi: _optionalChain([client, 'access', _54 => _54.chain, 'access', _55 => _55.consensusMainContract, 'optionalAccess', _56 => _56.abi]),
988
1043
  eventName: "NewTransaction",
989
1044
  logs
990
1045
  });
@@ -1009,7 +1064,7 @@ var _sendTransaction = async ({
1009
1064
  senderAccount,
1010
1065
  value = 0n
1011
1066
  }) => {
1012
- if (!_optionalChain([client, 'access', _51 => _51.chain, 'access', _52 => _52.consensusMainContract, 'optionalAccess', _53 => _53.address])) {
1067
+ if (!_optionalChain([client, 'access', _57 => _57.chain, 'access', _58 => _58.consensusMainContract, 'optionalAccess', _59 => _59.address])) {
1013
1068
  throw new Error(`Consensus main contract address not found in chain config for "${client.chain.name}".`);
1014
1069
  }
1015
1070
  const validatedSenderAccount = validateAccount(senderAccount);
@@ -1019,7 +1074,7 @@ var _sendTransaction = async ({
1019
1074
  try {
1020
1075
  estimatedGas = await client.estimateTransactionGas({
1021
1076
  from: validatedSenderAccount.address,
1022
- to: _optionalChain([client, 'access', _54 => _54.chain, 'access', _55 => _55.consensusMainContract, 'optionalAccess', _56 => _56.address]),
1077
+ to: _optionalChain([client, 'access', _60 => _60.chain, 'access', _61 => _61.consensusMainContract, 'optionalAccess', _62 => _62.address]),
1023
1078
  data: encodedDataForSend,
1024
1079
  value
1025
1080
  });
@@ -1027,8 +1082,8 @@ var _sendTransaction = async ({
1027
1082
  console.error("Gas estimation failed, using default 200_000:", err);
1028
1083
  estimatedGas = 200000n;
1029
1084
  }
1030
- if (_optionalChain([validatedSenderAccount, 'optionalAccess', _57 => _57.type]) === "local") {
1031
- if (!_optionalChain([validatedSenderAccount, 'optionalAccess', _58 => _58.signTransaction])) {
1085
+ if (_optionalChain([validatedSenderAccount, 'optionalAccess', _63 => _63.type]) === "local") {
1086
+ if (!_optionalChain([validatedSenderAccount, 'optionalAccess', _64 => _64.signTransaction])) {
1032
1087
  throw new Error("Local account does not support signTransaction. Use a private key account created via privateKeyToAccount().");
1033
1088
  }
1034
1089
  const gasPriceHex2 = await client.request({
@@ -1036,7 +1091,7 @@ var _sendTransaction = async ({
1036
1091
  });
1037
1092
  const transactionRequest = {
1038
1093
  account: validatedSenderAccount,
1039
- to: _optionalChain([client, 'access', _59 => _59.chain, 'access', _60 => _60.consensusMainContract, 'optionalAccess', _61 => _61.address]),
1094
+ to: _optionalChain([client, 'access', _65 => _65.chain, 'access', _66 => _66.consensusMainContract, 'optionalAccess', _67 => _67.address]),
1040
1095
  data: encodedDataForSend,
1041
1096
  type: "legacy",
1042
1097
  nonce: Number(nonce),
@@ -1049,7 +1104,7 @@ var _sendTransaction = async ({
1049
1104
  const txHash = await client.sendRawTransaction({ serializedTransaction });
1050
1105
  const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
1051
1106
  if (receipt.status === "reverted") {
1052
- throw new Error(`Transaction reverted: EVM tx ${txHash} to consensus contract ${_optionalChain([client, 'access', _62 => _62.chain, 'access', _63 => _63.consensusMainContract, 'optionalAccess', _64 => _64.address])} was reverted.`);
1107
+ throw new Error(`Transaction reverted: EVM tx ${txHash} to consensus contract ${_optionalChain([client, 'access', _68 => _68.chain, 'access', _69 => _69.consensusMainContract, 'optionalAccess', _70 => _70.address])} was reverted.`);
1053
1108
  }
1054
1109
  const txId = extractTxIdFromLogs(client, receipt.logs);
1055
1110
  if (!txId) {
@@ -1073,7 +1128,7 @@ var _sendTransaction = async ({
1073
1128
  const nonceBigInt = typeof nonce === "bigint" ? nonce : typeof nonce === "string" ? BigInt(nonce) : BigInt(Number(nonce));
1074
1129
  const formattedRequest = {
1075
1130
  from: validatedSenderAccount.address,
1076
- to: _optionalChain([client, 'access', _65 => _65.chain, 'access', _66 => _66.consensusMainContract, 'optionalAccess', _67 => _67.address]),
1131
+ to: _optionalChain([client, 'access', _71 => _71.chain, 'access', _72 => _72.consensusMainContract, 'optionalAccess', _73 => _73.address]),
1077
1132
  data: encodedDataForSend,
1078
1133
  value: `0x${value.toString(16)}`,
1079
1134
  gas: `0x${estimatedGas.toString(16)}`,
@@ -1092,7 +1147,7 @@ var _sendTransaction = async ({
1092
1147
  }
1093
1148
  const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
1094
1149
  if (externalReceipt.status === "reverted") {
1095
- throw new Error(`Transaction reverted: EVM tx ${evmTxHash} to consensus contract ${_optionalChain([client, 'access', _68 => _68.chain, 'access', _69 => _69.consensusMainContract, 'optionalAccess', _70 => _70.address])} was reverted.`);
1150
+ throw new Error(`Transaction reverted: EVM tx ${evmTxHash} to consensus contract ${_optionalChain([client, 'access', _74 => _74.chain, 'access', _75 => _75.consensusMainContract, 'optionalAccess', _76 => _76.address])} was reverted.`);
1096
1151
  }
1097
1152
  const externalTxId = extractTxIdFromLogs(client, externalReceipt.logs);
1098
1153
  if (!externalTxId) {
@@ -1217,7 +1272,7 @@ var decodeTransaction = (tx) => {
1217
1272
  txData,
1218
1273
  txDataDecoded,
1219
1274
  currentTimestamp: tx.currentTimestamp.toString(),
1220
- numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess', _71 => _71.toString, 'call', _72 => _72()]), () => ( "0")),
1275
+ numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess', _77 => _77.toString, 'call', _78 => _78()]), () => ( "0")),
1221
1276
  txSlot: tx.txSlot.toString(),
1222
1277
  createdTimestamp: tx.createdTimestamp.toString(),
1223
1278
  lastVoteTimestamp: tx.lastVoteTimestamp.toString(),
@@ -1225,9 +1280,9 @@ var decodeTransaction = (tx) => {
1225
1280
  numOfRounds: tx.numOfRounds.toString(),
1226
1281
  readStateBlockRange: {
1227
1282
  ...tx.readStateBlockRange,
1228
- activationBlock: _nullishCoalesce(_optionalChain([tx, 'access', _73 => _73.readStateBlockRange, 'optionalAccess', _74 => _74.activationBlock, 'optionalAccess', _75 => _75.toString, 'call', _76 => _76()]), () => ( "0")),
1229
- processingBlock: _nullishCoalesce(_optionalChain([tx, 'access', _77 => _77.readStateBlockRange, 'optionalAccess', _78 => _78.processingBlock, 'optionalAccess', _79 => _79.toString, 'call', _80 => _80()]), () => ( "0")),
1230
- proposalBlock: _nullishCoalesce(_optionalChain([tx, 'access', _81 => _81.readStateBlockRange, 'optionalAccess', _82 => _82.proposalBlock, 'optionalAccess', _83 => _83.toString, 'call', _84 => _84()]), () => ( "0"))
1283
+ activationBlock: _nullishCoalesce(_optionalChain([tx, 'access', _79 => _79.readStateBlockRange, 'optionalAccess', _80 => _80.activationBlock, 'optionalAccess', _81 => _81.toString, 'call', _82 => _82()]), () => ( "0")),
1284
+ processingBlock: _nullishCoalesce(_optionalChain([tx, 'access', _83 => _83.readStateBlockRange, 'optionalAccess', _84 => _84.processingBlock, 'optionalAccess', _85 => _85.toString, 'call', _86 => _86()]), () => ( "0")),
1285
+ proposalBlock: _nullishCoalesce(_optionalChain([tx, 'access', _87 => _87.readStateBlockRange, 'optionalAccess', _88 => _88.proposalBlock, 'optionalAccess', _89 => _89.toString, 'call', _90 => _90()]), () => ( "0"))
1231
1286
  },
1232
1287
  statusName: _chunkGJXSECNHcjs.transactionsStatusNumberToName[String(tx.status)],
1233
1288
  resultName: _chunkGJXSECNHcjs.transactionResultNumberToName[String(tx.result)],
@@ -1235,13 +1290,13 @@ var decodeTransaction = (tx) => {
1235
1290
  txExecutionResultName: tx.txExecutionResult !== void 0 ? _chunkGJXSECNHcjs.executionResultNumberToName[String(tx.txExecutionResult)] : void 0,
1236
1291
  lastRound: {
1237
1292
  ...tx.lastRound,
1238
- round: _nullishCoalesce(_optionalChain([tx, 'access', _85 => _85.lastRound, 'optionalAccess', _86 => _86.round, 'optionalAccess', _87 => _87.toString, 'call', _88 => _88()]), () => ( "0")),
1239
- leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access', _89 => _89.lastRound, 'optionalAccess', _90 => _90.leaderIndex, 'optionalAccess', _91 => _91.toString, 'call', _92 => _92()]), () => ( "0")),
1240
- votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access', _93 => _93.lastRound, 'optionalAccess', _94 => _94.votesCommitted, 'optionalAccess', _95 => _95.toString, 'call', _96 => _96()]), () => ( "0")),
1241
- votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access', _97 => _97.lastRound, 'optionalAccess', _98 => _98.votesRevealed, 'optionalAccess', _99 => _99.toString, 'call', _100 => _100()]), () => ( "0")),
1242
- appealBond: _nullishCoalesce(_optionalChain([tx, 'access', _101 => _101.lastRound, 'optionalAccess', _102 => _102.appealBond, 'optionalAccess', _103 => _103.toString, 'call', _104 => _104()]), () => ( "0")),
1243
- rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access', _105 => _105.lastRound, 'optionalAccess', _106 => _106.rotationsLeft, 'optionalAccess', _107 => _107.toString, 'call', _108 => _108()]), () => ( "0")),
1244
- validatorVotesName: (_nullishCoalesce(_optionalChain([tx, 'access', _109 => _109.lastRound, 'optionalAccess', _110 => _110.validatorVotes]), () => ( []))).map(
1293
+ round: _nullishCoalesce(_optionalChain([tx, 'access', _91 => _91.lastRound, 'optionalAccess', _92 => _92.round, 'optionalAccess', _93 => _93.toString, 'call', _94 => _94()]), () => ( "0")),
1294
+ leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access', _95 => _95.lastRound, 'optionalAccess', _96 => _96.leaderIndex, 'optionalAccess', _97 => _97.toString, 'call', _98 => _98()]), () => ( "0")),
1295
+ votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access', _99 => _99.lastRound, 'optionalAccess', _100 => _100.votesCommitted, 'optionalAccess', _101 => _101.toString, 'call', _102 => _102()]), () => ( "0")),
1296
+ votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access', _103 => _103.lastRound, 'optionalAccess', _104 => _104.votesRevealed, 'optionalAccess', _105 => _105.toString, 'call', _106 => _106()]), () => ( "0")),
1297
+ appealBond: _nullishCoalesce(_optionalChain([tx, 'access', _107 => _107.lastRound, 'optionalAccess', _108 => _108.appealBond, 'optionalAccess', _109 => _109.toString, 'call', _110 => _110()]), () => ( "0")),
1298
+ rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access', _111 => _111.lastRound, 'optionalAccess', _112 => _112.rotationsLeft, 'optionalAccess', _113 => _113.toString, 'call', _114 => _114()]), () => ( "0")),
1299
+ validatorVotesName: (_nullishCoalesce(_optionalChain([tx, 'access', _115 => _115.lastRound, 'optionalAccess', _116 => _116.validatorVotes]), () => ( []))).map(
1245
1300
  (vote) => _chunkGJXSECNHcjs.voteTypeNumberToName[String(vote)]
1246
1301
  )
1247
1302
  }
@@ -1323,7 +1378,7 @@ var simplifyTransactionReceipt = (tx) => {
1323
1378
  var decodeLocalnetTransaction = (tx) => {
1324
1379
  if (!tx.data) return tx;
1325
1380
  try {
1326
- const leaderReceipt = _optionalChain([tx, 'access', _111 => _111.consensus_data, 'optionalAccess', _112 => _112.leader_receipt]);
1381
+ const leaderReceipt = _optionalChain([tx, 'access', _117 => _117.consensus_data, 'optionalAccess', _118 => _118.leader_receipt]);
1327
1382
  if (leaderReceipt) {
1328
1383
  const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
1329
1384
  receipts.forEach((receipt) => {
@@ -1354,7 +1409,7 @@ var decodeLocalnetTransaction = (tx) => {
1354
1409
  }
1355
1410
  });
1356
1411
  }
1357
- if (_optionalChain([tx, 'access', _113 => _113.data, 'optionalAccess', _114 => _114.calldata]) && typeof tx.data.calldata === "string") {
1412
+ if (_optionalChain([tx, 'access', _119 => _119.data, 'optionalAccess', _120 => _120.calldata]) && typeof tx.data.calldata === "string") {
1358
1413
  tx.data.calldata = {
1359
1414
  base64: tx.data.calldata,
1360
1415
  ...calldataToUserFriendlyJson(b64ToArray(tx.data.calldata))
@@ -1417,8 +1472,8 @@ var transactionActions = (client, publicClient) => ({
1417
1472
  transaction2.statusName = localnetStatus;
1418
1473
  return decodeLocalnetTransaction(transaction2);
1419
1474
  }
1420
- const contractAddress = _optionalChain([client, 'access', _115 => _115.chain, 'access', _116 => _116.consensusDataContract, 'optionalAccess', _117 => _117.address]);
1421
- const contractAbi = _optionalChain([client, 'access', _118 => _118.chain, 'access', _119 => _119.consensusDataContract, 'optionalAccess', _120 => _120.abi]);
1475
+ const contractAddress = _optionalChain([client, 'access', _121 => _121.chain, 'access', _122 => _122.consensusDataContract, 'optionalAccess', _123 => _123.address]);
1476
+ const contractAbi = _optionalChain([client, 'access', _124 => _124.chain, 'access', _125 => _125.consensusDataContract, 'optionalAccess', _126 => _126.abi]);
1422
1477
  const [txDataRaw, allDataRaw] = await Promise.all([
1423
1478
  publicClient.readContract({
1424
1479
  address: contractAddress,
@@ -1448,12 +1503,12 @@ var transactionActions = (client, publicClient) => ({
1448
1503
  return _nullishCoalesce(tx2.triggered_transactions, () => ( []));
1449
1504
  }
1450
1505
  const tx = await transactionActions(client, publicClient).getTransaction({ hash });
1451
- const proposalBlock = BigInt(_nullishCoalesce(_optionalChain([tx, 'access', _121 => _121.readStateBlockRange, 'optionalAccess', _122 => _122.proposalBlock]), () => ( "0")));
1506
+ const proposalBlock = BigInt(_nullishCoalesce(_optionalChain([tx, 'access', _127 => _127.readStateBlockRange, 'optionalAccess', _128 => _128.proposalBlock]), () => ( "0")));
1452
1507
  if (proposalBlock === BigInt(0)) return [];
1453
1508
  const scanRange = BigInt(100);
1454
1509
  const latestBlock = await publicClient.getBlockNumber();
1455
1510
  const toBlock = proposalBlock + scanRange < latestBlock ? proposalBlock + scanRange : latestBlock;
1456
- const consensusAddress = _optionalChain([client, 'access', _123 => _123.chain, 'access', _124 => _124.consensusMainContract, 'optionalAccess', _125 => _125.address]);
1511
+ const consensusAddress = _optionalChain([client, 'access', _129 => _129.chain, 'access', _130 => _130.consensusMainContract, 'optionalAccess', _131 => _131.address]);
1457
1512
  const internalMessageProcessedTopic = _viem.keccak256.call(void 0, _viem.stringToBytes.call(void 0, "InternalMessageProcessed(bytes32,address,address)"));
1458
1513
  const logs = await publicClient.getLogs({
1459
1514
  address: consensusAddress,
@@ -1502,8 +1557,8 @@ var transactionActions = (client, publicClient) => ({
1502
1557
  },
1503
1558
  /** Returns the queue slot position of a transaction in the pending queue. */
1504
1559
  getTransactionQueuePosition: async ({ hash }) => {
1505
- const consensusAddress = _optionalChain([client, 'access', _126 => _126.chain, 'access', _127 => _127.consensusMainContract, 'optionalAccess', _128 => _128.address]);
1506
- const consensusAbi = _optionalChain([client, 'access', _129 => _129.chain, 'access', _130 => _130.consensusMainContract, 'optionalAccess', _131 => _131.abi]);
1560
+ const consensusAddress = _optionalChain([client, 'access', _132 => _132.chain, 'access', _133 => _133.consensusMainContract, 'optionalAccess', _134 => _134.address]);
1561
+ const consensusAbi = _optionalChain([client, 'access', _135 => _135.chain, 'access', _136 => _136.consensusMainContract, 'optionalAccess', _137 => _137.abi]);
1507
1562
  const queuesAddress = await publicClient.readContract({
1508
1563
  address: consensusAddress,
1509
1564
  abi: consensusAbi,
@@ -1529,7 +1584,7 @@ var transactionActions = (client, publicClient) => ({
1529
1584
  /** Estimates gas required for a transaction. */
1530
1585
  estimateTransactionGas: async (transactionParams) => {
1531
1586
  const formattedParams = {
1532
- from: transactionParams.from || _optionalChain([client, 'access', _132 => _132.account, 'optionalAccess', _133 => _133.address]),
1587
+ from: transactionParams.from || _optionalChain([client, 'access', _138 => _138.account, 'optionalAccess', _139 => _139.address]),
1533
1588
  to: transactionParams.to,
1534
1589
  data: transactionParams.data || "0x",
1535
1590
  value: transactionParams.value ? `0x${transactionParams.value.toString(16)}` : "0x0"
@@ -1550,10 +1605,10 @@ var snapID = {
1550
1605
 
1551
1606
  // src/wallet/connect.ts
1552
1607
  var networks = {
1553
- localnet: _chunkPZEHAYIUcjs.localnet,
1554
- studionet: _chunkPZEHAYIUcjs.studionet,
1555
- testnetAsimov: _chunkPZEHAYIUcjs.testnetAsimov,
1556
- testnetBradbury: _chunkPZEHAYIUcjs.testnetBradbury
1608
+ localnet: _chunkN74TARFYcjs.localnet,
1609
+ studionet: _chunkN74TARFYcjs.studionet,
1610
+ testnetAsimov: _chunkN74TARFYcjs.testnetAsimov,
1611
+ testnetBradbury: _chunkN74TARFYcjs.testnetBradbury
1557
1612
  };
1558
1613
  var connect = async (client, network = "studionet", snapSource = "npm") => {
1559
1614
  if (!window.ethereum) {
@@ -1572,7 +1627,7 @@ var connect = async (client, network = "studionet", snapSource = "npm") => {
1572
1627
  chainName: selectedNetwork.name,
1573
1628
  rpcUrls: selectedNetwork.rpcUrls.default.http,
1574
1629
  nativeCurrency: selectedNetwork.nativeCurrency,
1575
- blockExplorerUrls: [_optionalChain([selectedNetwork, 'access', _134 => _134.blockExplorers, 'optionalAccess', _135 => _135.default, 'access', _136 => _136.url])]
1630
+ blockExplorerUrls: [_optionalChain([selectedNetwork, 'access', _140 => _140.blockExplorers, 'optionalAccess', _141 => _141.default, 'access', _142 => _142.url])]
1576
1631
  };
1577
1632
  const currentChainId = await window.ethereum.request({ method: "eth_chainId" });
1578
1633
  if (currentChainId !== chainIdHex) {
@@ -1606,10 +1661,10 @@ var metamaskClient = async (snapSource = "npm") => {
1606
1661
  }
1607
1662
  const isFlask = async () => {
1608
1663
  try {
1609
- const clientVersion = await _optionalChain([window, 'access', _137 => _137.ethereum, 'optionalAccess', _138 => _138.request, 'call', _139 => _139({
1664
+ const clientVersion = await _optionalChain([window, 'access', _143 => _143.ethereum, 'optionalAccess', _144 => _144.request, 'call', _145 => _145({
1610
1665
  method: "web3_clientVersion"
1611
1666
  })]);
1612
- return _optionalChain([clientVersion, 'optionalAccess', _140 => _140.includes, 'call', _141 => _141("flask")]);
1667
+ return _optionalChain([clientVersion, 'optionalAccess', _146 => _146.includes, 'call', _147 => _147("flask")]);
1613
1668
  } catch (error) {
1614
1669
  console.error("Error detecting Flask:", error);
1615
1670
  return false;
@@ -1617,7 +1672,7 @@ var metamaskClient = async (snapSource = "npm") => {
1617
1672
  };
1618
1673
  const installedSnaps = async () => {
1619
1674
  try {
1620
- return await _optionalChain([window, 'access', _142 => _142.ethereum, 'optionalAccess', _143 => _143.request, 'call', _144 => _144({
1675
+ return await _optionalChain([window, 'access', _148 => _148.ethereum, 'optionalAccess', _149 => _149.request, 'call', _150 => _150({
1621
1676
  method: "wallet_getSnaps"
1622
1677
  })]);
1623
1678
  } catch (error) {
@@ -1669,7 +1724,7 @@ function formatStakingAmount(amount) {
1669
1724
  // src/staking/actions.ts
1670
1725
  var FALLBACK_GAS = 1000000n;
1671
1726
  var GAS_BUFFER_MULTIPLIER = 2n;
1672
- var COMBINED_ERROR_ABI = [..._chunkPZEHAYIUcjs.STAKING_ABI, ..._chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI];
1727
+ var COMBINED_ERROR_ABI = [..._chunkN74TARFYcjs.STAKING_ABI, ..._chunkN74TARFYcjs.VALIDATOR_WALLET_ABI];
1673
1728
  function extractRevertReason(err) {
1674
1729
  if (err instanceof _viem.BaseError) {
1675
1730
  const rawError = err.walk((e) => e instanceof _viem.RawContractError);
@@ -1704,7 +1759,7 @@ function extractRevertReason(err) {
1704
1759
  }
1705
1760
  const revertError = err.walk((e) => e instanceof _viem.ContractFunctionRevertedError);
1706
1761
  if (revertError instanceof _viem.ContractFunctionRevertedError) {
1707
- if (_optionalChain([revertError, 'access', _145 => _145.data, 'optionalAccess', _146 => _146.errorName])) {
1762
+ if (_optionalChain([revertError, 'access', _151 => _151.data, 'optionalAccess', _152 => _152.errorName])) {
1708
1763
  return revertError.data.errorName;
1709
1764
  }
1710
1765
  return revertError.reason || "Unknown reason";
@@ -1792,7 +1847,7 @@ var stakingActions = (client, publicClient) => {
1792
1847
  };
1793
1848
  const getStakingAddress = () => {
1794
1849
  const stakingConfig = client.chain.stakingContract;
1795
- if (!_optionalChain([stakingConfig, 'optionalAccess', _147 => _147.address]) || stakingConfig.address === "0x0000000000000000000000000000000000000000") {
1850
+ if (!_optionalChain([stakingConfig, 'optionalAccess', _153 => _153.address]) || stakingConfig.address === "0x0000000000000000000000000000000000000000") {
1796
1851
  throw new Error("Staking is not supported on studio-based networks. Use testnet-asimov for staking operations.");
1797
1852
  }
1798
1853
  return stakingConfig.address;
@@ -1801,7 +1856,7 @@ var stakingActions = (client, publicClient) => {
1801
1856
  const address = getStakingAddress();
1802
1857
  return _viem.getContract.call(void 0, {
1803
1858
  address,
1804
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1859
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1805
1860
  client: { public: publicClient, wallet: client }
1806
1861
  });
1807
1862
  };
@@ -1809,7 +1864,7 @@ var stakingActions = (client, publicClient) => {
1809
1864
  const address = getStakingAddress();
1810
1865
  return _viem.getContract.call(void 0, {
1811
1866
  address,
1812
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1867
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1813
1868
  client: publicClient
1814
1869
  });
1815
1870
  };
@@ -1819,11 +1874,11 @@ var stakingActions = (client, publicClient) => {
1819
1874
  const amount = parseStakingAmount(options.amount);
1820
1875
  const stakingAddress = getStakingAddress();
1821
1876
  const data = options.operator ? _viem.encodeFunctionData.call(void 0, {
1822
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1877
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1823
1878
  functionName: "validatorJoin",
1824
1879
  args: [options.operator]
1825
1880
  }) : _viem.encodeFunctionData.call(void 0, {
1826
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1881
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1827
1882
  functionName: "validatorJoin"
1828
1883
  });
1829
1884
  const result = await executeWrite({ to: stakingAddress, data, value: amount });
@@ -1832,7 +1887,7 @@ var stakingActions = (client, publicClient) => {
1832
1887
  let eventFound = false;
1833
1888
  for (const log of receipt.logs) {
1834
1889
  try {
1835
- const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunkPZEHAYIUcjs.STAKING_ABI, data: log.data, topics: log.topics });
1890
+ const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunkN74TARFYcjs.STAKING_ABI, data: log.data, topics: log.topics });
1836
1891
  if (decoded.eventName === "ValidatorJoin") {
1837
1892
  validatorWallet = decoded.args.validator;
1838
1893
  eventFound = true;
@@ -1860,7 +1915,7 @@ var stakingActions = (client, publicClient) => {
1860
1915
  validatorDeposit: async (options) => {
1861
1916
  const amount = parseStakingAmount(options.amount);
1862
1917
  const data = _viem.encodeFunctionData.call(void 0, {
1863
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1918
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1864
1919
  functionName: "validatorDeposit"
1865
1920
  });
1866
1921
  return executeWrite({ to: getStakingAddress(), data, value: amount });
@@ -1869,7 +1924,7 @@ var stakingActions = (client, publicClient) => {
1869
1924
  validatorExit: async (options) => {
1870
1925
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1871
1926
  const data = _viem.encodeFunctionData.call(void 0, {
1872
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1927
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1873
1928
  functionName: "validatorExit",
1874
1929
  args: [shares]
1875
1930
  });
@@ -1877,12 +1932,12 @@ var stakingActions = (client, publicClient) => {
1877
1932
  },
1878
1933
  /** Claims pending validator withdrawals. */
1879
1934
  validatorClaim: async (options) => {
1880
- if (!_optionalChain([options, 'optionalAccess', _148 => _148.validator]) && !client.account) {
1935
+ if (!_optionalChain([options, 'optionalAccess', _154 => _154.validator]) && !client.account) {
1881
1936
  throw new Error("Either provide validator address or initialize client with an account");
1882
1937
  }
1883
- const validatorAddress = _optionalChain([options, 'optionalAccess', _149 => _149.validator]) || client.account.address;
1938
+ const validatorAddress = _optionalChain([options, 'optionalAccess', _155 => _155.validator]) || client.account.address;
1884
1939
  const data = _viem.encodeFunctionData.call(void 0, {
1885
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1940
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1886
1941
  functionName: "validatorClaim",
1887
1942
  args: [validatorAddress]
1888
1943
  });
@@ -1892,7 +1947,7 @@ var stakingActions = (client, publicClient) => {
1892
1947
  /** Primes a validator for participation in the next epoch. */
1893
1948
  validatorPrime: async (options) => {
1894
1949
  const data = _viem.encodeFunctionData.call(void 0, {
1895
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1950
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1896
1951
  functionName: "validatorPrime",
1897
1952
  args: [options.validator]
1898
1953
  });
@@ -1901,7 +1956,7 @@ var stakingActions = (client, publicClient) => {
1901
1956
  /** Sets the operator address for a validator wallet. */
1902
1957
  setOperator: async (options) => {
1903
1958
  const data = _viem.encodeFunctionData.call(void 0, {
1904
- abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
1959
+ abi: _chunkN74TARFYcjs.VALIDATOR_WALLET_ABI,
1905
1960
  functionName: "setOperator",
1906
1961
  args: [options.operator]
1907
1962
  });
@@ -1918,7 +1973,7 @@ var stakingActions = (client, publicClient) => {
1918
1973
  }
1919
1974
  }
1920
1975
  const data = _viem.encodeFunctionData.call(void 0, {
1921
- abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
1976
+ abi: _chunkN74TARFYcjs.VALIDATOR_WALLET_ABI,
1922
1977
  functionName: "setIdentity",
1923
1978
  args: [
1924
1979
  options.moniker,
@@ -1938,7 +1993,7 @@ var stakingActions = (client, publicClient) => {
1938
1993
  delegatorJoin: async (options) => {
1939
1994
  const amount = parseStakingAmount(options.amount);
1940
1995
  const data = _viem.encodeFunctionData.call(void 0, {
1941
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
1996
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1942
1997
  functionName: "delegatorJoin",
1943
1998
  args: [options.validator]
1944
1999
  });
@@ -1955,7 +2010,7 @@ var stakingActions = (client, publicClient) => {
1955
2010
  delegatorExit: async (options) => {
1956
2011
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1957
2012
  const data = _viem.encodeFunctionData.call(void 0, {
1958
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
2013
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1959
2014
  functionName: "delegatorExit",
1960
2015
  args: [options.validator, shares]
1961
2016
  });
@@ -1968,7 +2023,7 @@ var stakingActions = (client, publicClient) => {
1968
2023
  }
1969
2024
  const delegatorAddress = options.delegator || client.account.address;
1970
2025
  const data = _viem.encodeFunctionData.call(void 0, {
1971
- abi: _chunkPZEHAYIUcjs.STAKING_ABI,
2026
+ abi: _chunkN74TARFYcjs.STAKING_ABI,
1972
2027
  functionName: "delegatorClaim",
1973
2028
  args: [delegatorAddress, options.validator]
1974
2029
  });
@@ -1988,7 +2043,7 @@ var stakingActions = (client, publicClient) => {
1988
2043
  }
1989
2044
  const walletContract = _viem.getContract.call(void 0, {
1990
2045
  address: validator,
1991
- abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
2046
+ abi: _chunkN74TARFYcjs.VALIDATOR_WALLET_ABI,
1992
2047
  client: publicClient
1993
2048
  });
1994
2049
  const [view, owner, operator, identityRaw, currentEpoch] = await Promise.all([
@@ -2323,8 +2378,8 @@ var getCustomTransportConfig = (config, chainConfig) => {
2323
2378
  }
2324
2379
  };
2325
2380
  };
2326
- var createClient = (config = { chain: _chunkPZEHAYIUcjs.localnet }) => {
2327
- const chainConfig = config.chain || _chunkPZEHAYIUcjs.localnet;
2381
+ var createClient = (config = { chain: _chunkN74TARFYcjs.localnet }) => {
2382
+ const chainConfig = config.chain || _chunkN74TARFYcjs.localnet;
2328
2383
  if (config.endpoint) {
2329
2384
  chainConfig.rpcUrls.default.http = [config.endpoint];
2330
2385
  }
@@ -2461,4 +2516,4 @@ function validateValueAgainstType(value, type) {
2461
2516
 
2462
2517
 
2463
2518
 
2464
- exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains = _chunkPZEHAYIUcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.decodeInputData = decodeInputData; exports.decodeLocalnetTransaction = decodeLocalnetTransaction; exports.decodeTransaction = decodeTransaction; exports.formatStakingAmount = formatStakingAmount; exports.generatePrivateKey = generatePrivateKey; exports.parseStakingAmount = parseStakingAmount; exports.simplifyTransactionReceipt = simplifyTransactionReceipt;
2519
+ exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains = _chunkN74TARFYcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.decodeInputData = decodeInputData; exports.decodeLocalnetTransaction = decodeLocalnetTransaction; exports.decodeTransaction = decodeTransaction; exports.formatStakingAmount = formatStakingAmount; exports.generatePrivateKey = generatePrivateKey; exports.parseStakingAmount = parseStakingAmount; exports.simplifyTransactionReceipt = simplifyTransactionReceipt;