genlayer-js 0.20.3 → 0.21.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.
@@ -218,7 +218,8 @@ type GenLayerRawTransaction = {
218
218
  currentTimestamp: bigint;
219
219
  sender: Address;
220
220
  recipient: Address;
221
- numOfInitialValidators: bigint;
221
+ numOfInitialValidators?: bigint;
222
+ initialRotations?: bigint;
222
223
  txSlot: bigint;
223
224
  createdTimestamp: bigint;
224
225
  lastVoteTimestamp: bigint;
@@ -279,7 +280,7 @@ type ContractSchema = {
279
280
  methods: Record<string, ContractMethod>;
280
281
  };
281
282
 
282
- type Network = "localnet" | "studionet" | "testnetAsimov" | "mainnet";
283
+ type Network = "localnet" | "studionet" | "testnetAsimov" | "testnetBradbury" | "mainnet";
283
284
 
284
285
  type SnapSource = 'npm' | 'local';
285
286
 
@@ -6,11 +6,14 @@ declare const studionet: GenLayerChain;
6
6
 
7
7
  declare const testnetAsimov: GenLayerChain;
8
8
 
9
+ declare const testnetBradbury: GenLayerChain;
10
+
9
11
  declare const index_localnet: typeof localnet;
10
12
  declare const index_studionet: typeof studionet;
11
13
  declare const index_testnetAsimov: typeof testnetAsimov;
14
+ declare const index_testnetBradbury: typeof testnetBradbury;
12
15
  declare namespace index {
13
- export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov };
16
+ export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov, index_testnetBradbury as testnetBradbury };
14
17
  }
15
18
 
16
- export { index as i, localnet as l, studionet as s, testnetAsimov as t };
19
+ export { testnetBradbury as a, index as i, localnet as l, studionet as s, testnetAsimov as t };
@@ -218,7 +218,8 @@ type GenLayerRawTransaction = {
218
218
  currentTimestamp: bigint;
219
219
  sender: Address;
220
220
  recipient: Address;
221
- numOfInitialValidators: bigint;
221
+ numOfInitialValidators?: bigint;
222
+ initialRotations?: bigint;
222
223
  txSlot: bigint;
223
224
  createdTimestamp: bigint;
224
225
  lastVoteTimestamp: bigint;
@@ -279,7 +280,7 @@ type ContractSchema = {
279
280
  methods: Record<string, ContractMethod>;
280
281
  };
281
282
 
282
- type Network = "localnet" | "studionet" | "testnetAsimov" | "mainnet";
283
+ type Network = "localnet" | "studionet" | "testnetAsimov" | "testnetBradbury" | "mainnet";
283
284
 
284
285
  type SnapSource = 'npm' | 'local';
285
286
 
@@ -6,11 +6,14 @@ declare const studionet: GenLayerChain;
6
6
 
7
7
  declare const testnetAsimov: GenLayerChain;
8
8
 
9
+ declare const testnetBradbury: GenLayerChain;
10
+
9
11
  declare const index_localnet: typeof localnet;
10
12
  declare const index_studionet: typeof studionet;
11
13
  declare const index_testnetAsimov: typeof testnetAsimov;
14
+ declare const index_testnetBradbury: typeof testnetBradbury;
12
15
  declare namespace index {
13
- export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov };
16
+ export { index_localnet as localnet, index_studionet as studionet, index_testnetAsimov as testnetAsimov, index_testnetBradbury as testnetBradbury };
14
17
  }
15
18
 
16
- export { index as i, localnet as l, studionet as s, testnetAsimov as t };
19
+ export { testnetBradbury as a, index as i, localnet as l, studionet as s, testnetAsimov as t };
package/dist/index.cjs CHANGED
@@ -5,7 +5,8 @@
5
5
 
6
6
 
7
7
 
8
- var _chunk5TKVNHAOcjs = require('./chunk-5TKVNHAO.cjs');
8
+
9
+ var _chunkTCAQ6AVFcjs = require('./chunk-TCAQ6AVF.cjs');
9
10
 
10
11
 
11
12
 
@@ -31,7 +32,7 @@ var _viem = require('viem');
31
32
  function accountActions(client) {
32
33
  return {
33
34
  fundAccount: async ({ address, amount }) => {
34
- if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunk5TKVNHAOcjs.localnet.id) {
35
+ if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunkTCAQ6AVFcjs.localnet.id) {
35
36
  throw new Error("Client is not connected to the localnet");
36
37
  }
37
38
  return client.request({
@@ -415,8 +416,8 @@ function serialize(data) {
415
416
  // src/abi/index.ts
416
417
  var abi_exports = {};
417
418
  _chunk75ZPJI57cjs.__export.call(void 0, abi_exports, {
418
- STAKING_ABI: () => _chunk5TKVNHAOcjs.STAKING_ABI,
419
- VALIDATOR_WALLET_ABI: () => _chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI,
419
+ STAKING_ABI: () => _chunkTCAQ6AVFcjs.STAKING_ABI,
420
+ VALIDATOR_WALLET_ABI: () => _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
420
421
  calldata: () => calldata,
421
422
  transactions: () => transactions
422
423
  });
@@ -516,7 +517,7 @@ function _toJsonSafeDeep(value, seen) {
516
517
  var contractActions = (client, publicClient) => {
517
518
  return {
518
519
  getContractCode: async (address) => {
519
- if (client.chain.id !== _chunk5TKVNHAOcjs.localnet.id) {
520
+ if (client.chain.id !== _chunkTCAQ6AVFcjs.localnet.id) {
520
521
  throw new Error("Getting contract code is not supported on this network");
521
522
  }
522
523
  const result = await client.request({
@@ -527,7 +528,7 @@ var contractActions = (client, publicClient) => {
527
528
  return new TextDecoder().decode(codeBytes);
528
529
  },
529
530
  getContractSchema: async (address) => {
530
- if (client.chain.id !== _chunk5TKVNHAOcjs.localnet.id) {
531
+ if (client.chain.id !== _chunkTCAQ6AVFcjs.localnet.id) {
531
532
  throw new Error("Contract schema is not supported on this network");
532
533
  }
533
534
  const schema = await client.request({
@@ -537,7 +538,7 @@ var contractActions = (client, publicClient) => {
537
538
  return schema;
538
539
  },
539
540
  getContractSchemaForCode: async (contractCode) => {
540
- if (client.chain.id !== _chunk5TKVNHAOcjs.localnet.id) {
541
+ if (client.chain.id !== _chunkTCAQ6AVFcjs.localnet.id) {
541
542
  throw new Error("Contract schema is not supported on this network");
542
543
  }
543
544
  const schema = await client.request({
@@ -1010,30 +1011,31 @@ var decodeTransaction = (tx) => {
1010
1011
  ...tx,
1011
1012
  txData: tx.txData,
1012
1013
  txDataDecoded,
1013
- currentTimestamp: tx.currentTimestamp.toString(),
1014
- numOfInitialValidators: tx.numOfInitialValidators.toString(),
1015
- txSlot: tx.txSlot.toString(),
1016
- createdTimestamp: tx.createdTimestamp.toString(),
1017
- lastVoteTimestamp: tx.lastVoteTimestamp.toString(),
1018
- queuePosition: tx.queuePosition.toString(),
1019
- numOfRounds: tx.numOfRounds.toString(),
1014
+ currentTimestamp: _nullishCoalesce(_optionalChain([tx, 'access', _38 => _38.currentTimestamp, 'optionalAccess', _39 => _39.toString, 'call', _40 => _40()]), () => ( "0")),
1015
+ // Bradbury uses `initialRotations`; older chains use `numOfInitialValidators`
1016
+ numOfInitialValidators: _nullishCoalesce(_optionalChain([(_nullishCoalesce(tx.numOfInitialValidators, () => ( tx.initialRotations))), 'optionalAccess', _41 => _41.toString, 'call', _42 => _42()]), () => ( "0")),
1017
+ txSlot: _nullishCoalesce(_optionalChain([tx, 'access', _43 => _43.txSlot, 'optionalAccess', _44 => _44.toString, 'call', _45 => _45()]), () => ( "0")),
1018
+ createdTimestamp: _nullishCoalesce(_optionalChain([tx, 'access', _46 => _46.createdTimestamp, 'optionalAccess', _47 => _47.toString, 'call', _48 => _48()]), () => ( "0")),
1019
+ lastVoteTimestamp: _nullishCoalesce(_optionalChain([tx, 'access', _49 => _49.lastVoteTimestamp, 'optionalAccess', _50 => _50.toString, 'call', _51 => _51()]), () => ( "0")),
1020
+ queuePosition: _nullishCoalesce(_optionalChain([tx, 'access', _52 => _52.queuePosition, 'optionalAccess', _53 => _53.toString, 'call', _54 => _54()]), () => ( "0")),
1021
+ numOfRounds: _nullishCoalesce(_optionalChain([tx, 'access', _55 => _55.numOfRounds, 'optionalAccess', _56 => _56.toString, 'call', _57 => _57()]), () => ( "0")),
1020
1022
  readStateBlockRange: {
1021
1023
  ...tx.readStateBlockRange,
1022
- activationBlock: tx.readStateBlockRange.activationBlock.toString(),
1023
- processingBlock: tx.readStateBlockRange.processingBlock.toString(),
1024
- proposalBlock: tx.readStateBlockRange.proposalBlock.toString()
1024
+ activationBlock: _nullishCoalesce(_optionalChain([tx, 'access', _58 => _58.readStateBlockRange, 'optionalAccess', _59 => _59.activationBlock, 'optionalAccess', _60 => _60.toString, 'call', _61 => _61()]), () => ( "0")),
1025
+ processingBlock: _nullishCoalesce(_optionalChain([tx, 'access', _62 => _62.readStateBlockRange, 'optionalAccess', _63 => _63.processingBlock, 'optionalAccess', _64 => _64.toString, 'call', _65 => _65()]), () => ( "0")),
1026
+ proposalBlock: _nullishCoalesce(_optionalChain([tx, 'access', _66 => _66.readStateBlockRange, 'optionalAccess', _67 => _67.proposalBlock, 'optionalAccess', _68 => _68.toString, 'call', _69 => _69()]), () => ( "0"))
1025
1027
  },
1026
1028
  statusName: _chunkW4V73RPNcjs.transactionsStatusNumberToName[String(tx.status)],
1027
1029
  resultName: _chunkW4V73RPNcjs.transactionResultNumberToName[String(tx.result)],
1028
1030
  lastRound: {
1029
1031
  ...tx.lastRound,
1030
- round: tx.lastRound.round.toString(),
1031
- leaderIndex: tx.lastRound.leaderIndex.toString(),
1032
- votesCommitted: tx.lastRound.votesCommitted.toString(),
1033
- votesRevealed: tx.lastRound.votesRevealed.toString(),
1034
- appealBond: tx.lastRound.appealBond.toString(),
1035
- rotationsLeft: tx.lastRound.rotationsLeft.toString(),
1036
- validatorVotesName: tx.lastRound.validatorVotes.map(
1032
+ round: _nullishCoalesce(_optionalChain([tx, 'access', _70 => _70.lastRound, 'optionalAccess', _71 => _71.round, 'optionalAccess', _72 => _72.toString, 'call', _73 => _73()]), () => ( "0")),
1033
+ leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access', _74 => _74.lastRound, 'optionalAccess', _75 => _75.leaderIndex, 'optionalAccess', _76 => _76.toString, 'call', _77 => _77()]), () => ( "0")),
1034
+ votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access', _78 => _78.lastRound, 'optionalAccess', _79 => _79.votesCommitted, 'optionalAccess', _80 => _80.toString, 'call', _81 => _81()]), () => ( "0")),
1035
+ votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access', _82 => _82.lastRound, 'optionalAccess', _83 => _83.votesRevealed, 'optionalAccess', _84 => _84.toString, 'call', _85 => _85()]), () => ( "0")),
1036
+ appealBond: _nullishCoalesce(_optionalChain([tx, 'access', _86 => _86.lastRound, 'optionalAccess', _87 => _87.appealBond, 'optionalAccess', _88 => _88.toString, 'call', _89 => _89()]), () => ( "0")),
1037
+ rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access', _90 => _90.lastRound, 'optionalAccess', _91 => _91.rotationsLeft, 'optionalAccess', _92 => _92.toString, 'call', _93 => _93()]), () => ( "0")),
1038
+ validatorVotesName: (_nullishCoalesce(_optionalChain([tx, 'access', _94 => _94.lastRound, 'optionalAccess', _95 => _95.validatorVotes]), () => ( []))).map(
1037
1039
  (vote) => _chunkW4V73RPNcjs.voteTypeNumberToName[String(vote)]
1038
1040
  )
1039
1041
  }
@@ -1115,7 +1117,7 @@ var simplifyTransactionReceipt = (tx) => {
1115
1117
  var decodeLocalnetTransaction = (tx) => {
1116
1118
  if (!tx.data) return tx;
1117
1119
  try {
1118
- const leaderReceipt = _optionalChain([tx, 'access', _38 => _38.consensus_data, 'optionalAccess', _39 => _39.leader_receipt]);
1120
+ const leaderReceipt = _optionalChain([tx, 'access', _96 => _96.consensus_data, 'optionalAccess', _97 => _97.leader_receipt]);
1119
1121
  if (leaderReceipt) {
1120
1122
  const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
1121
1123
  receipts.forEach((receipt) => {
@@ -1146,7 +1148,7 @@ var decodeLocalnetTransaction = (tx) => {
1146
1148
  }
1147
1149
  });
1148
1150
  }
1149
- if (_optionalChain([tx, 'access', _40 => _40.data, 'optionalAccess', _41 => _41.calldata]) && typeof tx.data.calldata === "string") {
1151
+ if (_optionalChain([tx, 'access', _98 => _98.data, 'optionalAccess', _99 => _99.calldata]) && typeof tx.data.calldata === "string") {
1150
1152
  tx.data.calldata = {
1151
1153
  base64: tx.data.calldata,
1152
1154
  ...calldataToUserFriendlyJson(b64ToArray(tx.data.calldata))
@@ -1177,7 +1179,7 @@ var receiptActions = (client, publicClient) => ({
1177
1179
  const requestedStatus = _chunkW4V73RPNcjs.transactionsStatusNameToNumber[status];
1178
1180
  if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && _chunkW4V73RPNcjs.isDecidedState.call(void 0, transactionStatusString)) {
1179
1181
  let finalTransaction = transaction;
1180
- if (client.chain.id === _chunk5TKVNHAOcjs.localnet.id) {
1182
+ if (client.chain.id === _chunkTCAQ6AVFcjs.localnet.id) {
1181
1183
  finalTransaction = decodeLocalnetTransaction(transaction);
1182
1184
  }
1183
1185
  if (!fullTransaction) {
@@ -1208,8 +1210,8 @@ var transactionActions = (client, publicClient) => ({
1208
1210
  return decodeLocalnetTransaction(transaction2);
1209
1211
  }
1210
1212
  const transaction = await publicClient.readContract({
1211
- address: _optionalChain([client, 'access', _42 => _42.chain, 'access', _43 => _43.consensusDataContract, 'optionalAccess', _44 => _44.address]),
1212
- abi: _optionalChain([client, 'access', _45 => _45.chain, 'access', _46 => _46.consensusDataContract, 'optionalAccess', _47 => _47.abi]),
1213
+ address: _optionalChain([client, 'access', _100 => _100.chain, 'access', _101 => _101.consensusDataContract, 'optionalAccess', _102 => _102.address]),
1214
+ abi: _optionalChain([client, 'access', _103 => _103.chain, 'access', _104 => _104.consensusDataContract, 'optionalAccess', _105 => _105.abi]),
1213
1215
  functionName: "getTransactionData",
1214
1216
  args: [
1215
1217
  hash,
@@ -1248,7 +1250,7 @@ var transactionActions = (client, publicClient) => ({
1248
1250
  },
1249
1251
  estimateTransactionGas: async (transactionParams) => {
1250
1252
  const formattedParams = {
1251
- from: transactionParams.from || _optionalChain([client, 'access', _48 => _48.account, 'optionalAccess', _49 => _49.address]),
1253
+ from: transactionParams.from || _optionalChain([client, 'access', _106 => _106.account, 'optionalAccess', _107 => _107.address]),
1252
1254
  to: transactionParams.to,
1253
1255
  data: transactionParams.data || "0x",
1254
1256
  value: transactionParams.value ? `0x${transactionParams.value.toString(16)}` : "0x0"
@@ -1269,9 +1271,10 @@ var snapID = {
1269
1271
 
1270
1272
  // src/wallet/connect.ts
1271
1273
  var networks = {
1272
- localnet: _chunk5TKVNHAOcjs.localnet,
1273
- studionet: _chunk5TKVNHAOcjs.studionet,
1274
- testnetAsimov: _chunk5TKVNHAOcjs.testnetAsimov
1274
+ localnet: _chunkTCAQ6AVFcjs.localnet,
1275
+ studionet: _chunkTCAQ6AVFcjs.studionet,
1276
+ testnetAsimov: _chunkTCAQ6AVFcjs.testnetAsimov,
1277
+ testnetBradbury: _chunkTCAQ6AVFcjs.testnetBradbury
1275
1278
  };
1276
1279
  var connect = async (client, network = "studionet", snapSource = "npm") => {
1277
1280
  if (!window.ethereum) {
@@ -1290,7 +1293,7 @@ var connect = async (client, network = "studionet", snapSource = "npm") => {
1290
1293
  chainName: selectedNetwork.name,
1291
1294
  rpcUrls: selectedNetwork.rpcUrls.default.http,
1292
1295
  nativeCurrency: selectedNetwork.nativeCurrency,
1293
- blockExplorerUrls: [_optionalChain([selectedNetwork, 'access', _50 => _50.blockExplorers, 'optionalAccess', _51 => _51.default, 'access', _52 => _52.url])]
1296
+ blockExplorerUrls: [_optionalChain([selectedNetwork, 'access', _108 => _108.blockExplorers, 'optionalAccess', _109 => _109.default, 'access', _110 => _110.url])]
1294
1297
  };
1295
1298
  const currentChainId = await window.ethereum.request({ method: "eth_chainId" });
1296
1299
  if (currentChainId !== chainIdHex) {
@@ -1324,10 +1327,10 @@ var metamaskClient = async (snapSource = "npm") => {
1324
1327
  }
1325
1328
  const isFlask = async () => {
1326
1329
  try {
1327
- const clientVersion = await _optionalChain([window, 'access', _53 => _53.ethereum, 'optionalAccess', _54 => _54.request, 'call', _55 => _55({
1330
+ const clientVersion = await _optionalChain([window, 'access', _111 => _111.ethereum, 'optionalAccess', _112 => _112.request, 'call', _113 => _113({
1328
1331
  method: "web3_clientVersion"
1329
1332
  })]);
1330
- return _optionalChain([clientVersion, 'optionalAccess', _56 => _56.includes, 'call', _57 => _57("flask")]);
1333
+ return _optionalChain([clientVersion, 'optionalAccess', _114 => _114.includes, 'call', _115 => _115("flask")]);
1331
1334
  } catch (error) {
1332
1335
  console.error("Error detecting Flask:", error);
1333
1336
  return false;
@@ -1335,7 +1338,7 @@ var metamaskClient = async (snapSource = "npm") => {
1335
1338
  };
1336
1339
  const installedSnaps = async () => {
1337
1340
  try {
1338
- return await _optionalChain([window, 'access', _58 => _58.ethereum, 'optionalAccess', _59 => _59.request, 'call', _60 => _60({
1341
+ return await _optionalChain([window, 'access', _116 => _116.ethereum, 'optionalAccess', _117 => _117.request, 'call', _118 => _118({
1339
1342
  method: "wallet_getSnaps"
1340
1343
  })]);
1341
1344
  } catch (error) {
@@ -1387,7 +1390,7 @@ function formatStakingAmount(amount) {
1387
1390
  // src/staking/actions.ts
1388
1391
  var FALLBACK_GAS = 1000000n;
1389
1392
  var GAS_BUFFER_MULTIPLIER = 2n;
1390
- var COMBINED_ERROR_ABI = [..._chunk5TKVNHAOcjs.STAKING_ABI, ..._chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI];
1393
+ var COMBINED_ERROR_ABI = [..._chunkTCAQ6AVFcjs.STAKING_ABI, ..._chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI];
1391
1394
  function extractRevertReason(err) {
1392
1395
  if (err instanceof _viem.BaseError) {
1393
1396
  const rawError = err.walk((e) => e instanceof _viem.RawContractError);
@@ -1422,7 +1425,7 @@ function extractRevertReason(err) {
1422
1425
  }
1423
1426
  const revertError = err.walk((e) => e instanceof _viem.ContractFunctionRevertedError);
1424
1427
  if (revertError instanceof _viem.ContractFunctionRevertedError) {
1425
- if (_optionalChain([revertError, 'access', _61 => _61.data, 'optionalAccess', _62 => _62.errorName])) {
1428
+ if (_optionalChain([revertError, 'access', _119 => _119.data, 'optionalAccess', _120 => _120.errorName])) {
1426
1429
  return revertError.data.errorName;
1427
1430
  }
1428
1431
  return revertError.reason || "Unknown reason";
@@ -1510,7 +1513,7 @@ var stakingActions = (client, publicClient) => {
1510
1513
  };
1511
1514
  const getStakingAddress = () => {
1512
1515
  const stakingConfig = client.chain.stakingContract;
1513
- if (!_optionalChain([stakingConfig, 'optionalAccess', _63 => _63.address]) || stakingConfig.address === "0x0000000000000000000000000000000000000000") {
1516
+ if (!_optionalChain([stakingConfig, 'optionalAccess', _121 => _121.address]) || stakingConfig.address === "0x0000000000000000000000000000000000000000") {
1514
1517
  throw new Error("Staking is not supported on studio-based networks. Use testnet-asimov for staking operations.");
1515
1518
  }
1516
1519
  return stakingConfig.address;
@@ -1519,7 +1522,7 @@ var stakingActions = (client, publicClient) => {
1519
1522
  const address = getStakingAddress();
1520
1523
  return _viem.getContract.call(void 0, {
1521
1524
  address,
1522
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1525
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1523
1526
  client: { public: publicClient, wallet: client }
1524
1527
  });
1525
1528
  };
@@ -1527,7 +1530,7 @@ var stakingActions = (client, publicClient) => {
1527
1530
  const address = getStakingAddress();
1528
1531
  return _viem.getContract.call(void 0, {
1529
1532
  address,
1530
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1533
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1531
1534
  client: publicClient
1532
1535
  });
1533
1536
  };
@@ -1536,11 +1539,11 @@ var stakingActions = (client, publicClient) => {
1536
1539
  const amount = parseStakingAmount(options.amount);
1537
1540
  const stakingAddress = getStakingAddress();
1538
1541
  const data = options.operator ? _viem.encodeFunctionData.call(void 0, {
1539
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1542
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1540
1543
  functionName: "validatorJoin",
1541
1544
  args: [options.operator]
1542
1545
  }) : _viem.encodeFunctionData.call(void 0, {
1543
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1546
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1544
1547
  functionName: "validatorJoin"
1545
1548
  });
1546
1549
  const result = await executeWrite({ to: stakingAddress, data, value: amount });
@@ -1549,7 +1552,7 @@ var stakingActions = (client, publicClient) => {
1549
1552
  let eventFound = false;
1550
1553
  for (const log of receipt.logs) {
1551
1554
  try {
1552
- const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunk5TKVNHAOcjs.STAKING_ABI, data: log.data, topics: log.topics });
1555
+ const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunkTCAQ6AVFcjs.STAKING_ABI, data: log.data, topics: log.topics });
1553
1556
  if (decoded.eventName === "ValidatorJoin") {
1554
1557
  validatorWallet = decoded.args.validator;
1555
1558
  eventFound = true;
@@ -1576,7 +1579,7 @@ var stakingActions = (client, publicClient) => {
1576
1579
  validatorDeposit: async (options) => {
1577
1580
  const amount = parseStakingAmount(options.amount);
1578
1581
  const data = _viem.encodeFunctionData.call(void 0, {
1579
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1582
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1580
1583
  functionName: "validatorDeposit"
1581
1584
  });
1582
1585
  return executeWrite({ to: getStakingAddress(), data, value: amount });
@@ -1584,19 +1587,19 @@ var stakingActions = (client, publicClient) => {
1584
1587
  validatorExit: async (options) => {
1585
1588
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1586
1589
  const data = _viem.encodeFunctionData.call(void 0, {
1587
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1590
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1588
1591
  functionName: "validatorExit",
1589
1592
  args: [shares]
1590
1593
  });
1591
1594
  return executeWrite({ to: getStakingAddress(), data });
1592
1595
  },
1593
1596
  validatorClaim: async (options) => {
1594
- if (!_optionalChain([options, 'optionalAccess', _64 => _64.validator]) && !client.account) {
1597
+ if (!_optionalChain([options, 'optionalAccess', _122 => _122.validator]) && !client.account) {
1595
1598
  throw new Error("Either provide validator address or initialize client with an account");
1596
1599
  }
1597
- const validatorAddress = _optionalChain([options, 'optionalAccess', _65 => _65.validator]) || client.account.address;
1600
+ const validatorAddress = _optionalChain([options, 'optionalAccess', _123 => _123.validator]) || client.account.address;
1598
1601
  const data = _viem.encodeFunctionData.call(void 0, {
1599
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1602
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1600
1603
  functionName: "validatorClaim",
1601
1604
  args: [validatorAddress]
1602
1605
  });
@@ -1605,7 +1608,7 @@ var stakingActions = (client, publicClient) => {
1605
1608
  },
1606
1609
  validatorPrime: async (options) => {
1607
1610
  const data = _viem.encodeFunctionData.call(void 0, {
1608
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1611
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1609
1612
  functionName: "validatorPrime",
1610
1613
  args: [options.validator]
1611
1614
  });
@@ -1613,7 +1616,7 @@ var stakingActions = (client, publicClient) => {
1613
1616
  },
1614
1617
  setOperator: async (options) => {
1615
1618
  const data = _viem.encodeFunctionData.call(void 0, {
1616
- abi: _chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI,
1619
+ abi: _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
1617
1620
  functionName: "setOperator",
1618
1621
  args: [options.operator]
1619
1622
  });
@@ -1629,7 +1632,7 @@ var stakingActions = (client, publicClient) => {
1629
1632
  }
1630
1633
  }
1631
1634
  const data = _viem.encodeFunctionData.call(void 0, {
1632
- abi: _chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI,
1635
+ abi: _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
1633
1636
  functionName: "setIdentity",
1634
1637
  args: [
1635
1638
  options.moniker,
@@ -1648,7 +1651,7 @@ var stakingActions = (client, publicClient) => {
1648
1651
  delegatorJoin: async (options) => {
1649
1652
  const amount = parseStakingAmount(options.amount);
1650
1653
  const data = _viem.encodeFunctionData.call(void 0, {
1651
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1654
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1652
1655
  functionName: "delegatorJoin",
1653
1656
  args: [options.validator]
1654
1657
  });
@@ -1664,7 +1667,7 @@ var stakingActions = (client, publicClient) => {
1664
1667
  delegatorExit: async (options) => {
1665
1668
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1666
1669
  const data = _viem.encodeFunctionData.call(void 0, {
1667
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1670
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1668
1671
  functionName: "delegatorExit",
1669
1672
  args: [options.validator, shares]
1670
1673
  });
@@ -1676,7 +1679,7 @@ var stakingActions = (client, publicClient) => {
1676
1679
  }
1677
1680
  const delegatorAddress = options.delegator || client.account.address;
1678
1681
  const data = _viem.encodeFunctionData.call(void 0, {
1679
- abi: _chunk5TKVNHAOcjs.STAKING_ABI,
1682
+ abi: _chunkTCAQ6AVFcjs.STAKING_ABI,
1680
1683
  functionName: "delegatorClaim",
1681
1684
  args: [delegatorAddress, options.validator]
1682
1685
  });
@@ -1694,7 +1697,7 @@ var stakingActions = (client, publicClient) => {
1694
1697
  }
1695
1698
  const walletContract = _viem.getContract.call(void 0, {
1696
1699
  address: validator,
1697
- abi: _chunk5TKVNHAOcjs.VALIDATOR_WALLET_ABI,
1700
+ abi: _chunkTCAQ6AVFcjs.VALIDATOR_WALLET_ABI,
1698
1701
  client: publicClient
1699
1702
  });
1700
1703
  const [view, owner, operator, identityRaw, currentEpoch] = await Promise.all([
@@ -1989,8 +1992,8 @@ var getCustomTransportConfig = (config, chainConfig) => {
1989
1992
  }
1990
1993
  };
1991
1994
  };
1992
- var createClient = (config = { chain: _chunk5TKVNHAOcjs.localnet }) => {
1993
- const chainConfig = config.chain || _chunk5TKVNHAOcjs.localnet;
1995
+ var createClient = (config = { chain: _chunkTCAQ6AVFcjs.localnet }) => {
1996
+ const chainConfig = config.chain || _chunkTCAQ6AVFcjs.localnet;
1994
1997
  if (config.endpoint) {
1995
1998
  chainConfig.rpcUrls.default.http = [config.endpoint];
1996
1999
  }
@@ -2127,4 +2130,4 @@ function validateValueAgainstType(value, type) {
2127
2130
 
2128
2131
 
2129
2132
 
2130
- exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains = _chunk5TKVNHAOcjs.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;
2133
+ exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains = _chunkTCAQ6AVFcjs.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;
package/dist/index.d.cts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as viem from 'viem';
2
2
  import { Account, Address, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-B7B7UXdn.cjs';
4
- import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-C3rDLBIN.cjs';
4
+ import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-Dja_Xmq_.cjs';
5
5
  import * as abitype from 'abitype';
6
6
  import * as viem__types_types_authorization from 'viem/_types/types/authorization';
7
7
  import * as viem_accounts from 'viem/accounts';
8
- export { i as chains } from './index-BVDASTaU.cjs';
8
+ export { i as chains } from './index-DjR-MFPr.cjs';
9
9
 
10
10
  interface ClientConfig {
11
11
  chain?: {
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import * as viem from 'viem';
2
2
  import { Account, Address, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-B7B7UXdn.js';
4
- import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-B6107TBT.js';
4
+ import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement, S as STAKING_ABI, V as VALIDATOR_WALLET_ABI, d as ContractSchema } from './index-CsIdmK96.js';
5
5
  import * as abitype from 'abitype';
6
6
  import * as viem__types_types_authorization from 'viem/_types/types/authorization';
7
7
  import * as viem_accounts from 'viem/accounts';
8
- export { i as chains } from './index-ucNO2REF.js';
8
+ export { i as chains } from './index-HRqj9M3K.js';
9
9
 
10
10
  interface ClientConfig {
11
11
  chain?: {
package/dist/index.js CHANGED
@@ -4,8 +4,9 @@ import {
4
4
  chains_exports,
5
5
  localnet,
6
6
  studionet,
7
- testnetAsimov
8
- } from "./chunk-NOFMB7RP.js";
7
+ testnetAsimov,
8
+ testnetBradbury
9
+ } from "./chunk-5KRGDGMO.js";
9
10
  import {
10
11
  CalldataAddress,
11
12
  isDecidedState,
@@ -1010,30 +1011,31 @@ var decodeTransaction = (tx) => {
1010
1011
  ...tx,
1011
1012
  txData: tx.txData,
1012
1013
  txDataDecoded,
1013
- currentTimestamp: tx.currentTimestamp.toString(),
1014
- numOfInitialValidators: tx.numOfInitialValidators.toString(),
1015
- txSlot: tx.txSlot.toString(),
1016
- createdTimestamp: tx.createdTimestamp.toString(),
1017
- lastVoteTimestamp: tx.lastVoteTimestamp.toString(),
1018
- queuePosition: tx.queuePosition.toString(),
1019
- numOfRounds: tx.numOfRounds.toString(),
1014
+ currentTimestamp: tx.currentTimestamp?.toString() ?? "0",
1015
+ // Bradbury uses `initialRotations`; older chains use `numOfInitialValidators`
1016
+ numOfInitialValidators: (tx.numOfInitialValidators ?? tx.initialRotations)?.toString() ?? "0",
1017
+ txSlot: tx.txSlot?.toString() ?? "0",
1018
+ createdTimestamp: tx.createdTimestamp?.toString() ?? "0",
1019
+ lastVoteTimestamp: tx.lastVoteTimestamp?.toString() ?? "0",
1020
+ queuePosition: tx.queuePosition?.toString() ?? "0",
1021
+ numOfRounds: tx.numOfRounds?.toString() ?? "0",
1020
1022
  readStateBlockRange: {
1021
1023
  ...tx.readStateBlockRange,
1022
- activationBlock: tx.readStateBlockRange.activationBlock.toString(),
1023
- processingBlock: tx.readStateBlockRange.processingBlock.toString(),
1024
- proposalBlock: tx.readStateBlockRange.proposalBlock.toString()
1024
+ activationBlock: tx.readStateBlockRange?.activationBlock?.toString() ?? "0",
1025
+ processingBlock: tx.readStateBlockRange?.processingBlock?.toString() ?? "0",
1026
+ proposalBlock: tx.readStateBlockRange?.proposalBlock?.toString() ?? "0"
1025
1027
  },
1026
1028
  statusName: transactionsStatusNumberToName[String(tx.status)],
1027
1029
  resultName: transactionResultNumberToName[String(tx.result)],
1028
1030
  lastRound: {
1029
1031
  ...tx.lastRound,
1030
- round: tx.lastRound.round.toString(),
1031
- leaderIndex: tx.lastRound.leaderIndex.toString(),
1032
- votesCommitted: tx.lastRound.votesCommitted.toString(),
1033
- votesRevealed: tx.lastRound.votesRevealed.toString(),
1034
- appealBond: tx.lastRound.appealBond.toString(),
1035
- rotationsLeft: tx.lastRound.rotationsLeft.toString(),
1036
- validatorVotesName: tx.lastRound.validatorVotes.map(
1032
+ round: tx.lastRound?.round?.toString() ?? "0",
1033
+ leaderIndex: tx.lastRound?.leaderIndex?.toString() ?? "0",
1034
+ votesCommitted: tx.lastRound?.votesCommitted?.toString() ?? "0",
1035
+ votesRevealed: tx.lastRound?.votesRevealed?.toString() ?? "0",
1036
+ appealBond: tx.lastRound?.appealBond?.toString() ?? "0",
1037
+ rotationsLeft: tx.lastRound?.rotationsLeft?.toString() ?? "0",
1038
+ validatorVotesName: (tx.lastRound?.validatorVotes ?? []).map(
1037
1039
  (vote) => voteTypeNumberToName[String(vote)]
1038
1040
  )
1039
1041
  }
@@ -1271,7 +1273,8 @@ var snapID = {
1271
1273
  var networks = {
1272
1274
  localnet,
1273
1275
  studionet,
1274
- testnetAsimov
1276
+ testnetAsimov,
1277
+ testnetBradbury
1275
1278
  };
1276
1279
  var connect = async (client, network = "studionet", snapSource = "npm") => {
1277
1280
  if (!window.ethereum) {
@@ -1,3 +1,3 @@
1
1
  export { Account, Address } from 'viem';
2
- export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-C3rDLBIN.cjs';
2
+ export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-Dja_Xmq_.cjs';
3
3
  export { G as GenLayerChain } from '../chains-B7B7UXdn.cjs';
@@ -1,3 +1,3 @@
1
1
  export { Account, Address } from 'viem';
2
- export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-B6107TBT.js';
2
+ export { I as BannedValidatorInfo, e as CalldataAddress, C as CalldataEncodable, j as ContractMethod, i as ContractMethodBase, g as ContractParamsArraySchemaElement, h as ContractParamsSchema, d as ContractSchema, o as DECIDED_STATES, a as DecodedCallData, D as DecodedDeployData, a4 as DelegatorClaimOptions, a3 as DelegatorExitOptions, a2 as DelegatorJoinOptions, U as DelegatorJoinResult, K as EpochData, O as EpochInfo, G as GenLayerClient, f as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, L as LeaderReceipt, M as MethodDescription, N as Network, P as PendingDeposit, F as PendingWithdrawal, a1 as SetIdentityOptions, a0 as SetOperatorOptions, y as SnapSource, J as StakeInfo, a5 as StakingActions, z as StakingContract, Q as StakingTransactionResult, k as TransactionHash, x as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, w as TransactionType, _ as ValidatorClaimOptions, Y as ValidatorDepositOptions, Z as ValidatorExitOptions, B as ValidatorIdentity, E as ValidatorInfo, X as ValidatorJoinOptions, R as ValidatorJoinResult, $ as ValidatorPrimeOptions, A as ValidatorView, s as VoteType, W as WithdrawalCommit, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, u as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-CsIdmK96.js';
3
3
  export { G as GenLayerChain } from '../chains-B7B7UXdn.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.20.3",
4
+ "version": "0.21.1",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",