genlayer-js 0.13.0 → 0.14.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
 
2
2
 
3
+ ## 0.14.0 (2025-07-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * expose encode and decode methods ([#102](https://github.com/genlayerlabs/genlayer-js/issues/102)) ([c9e0719](https://github.com/genlayerlabs/genlayer-js/commit/c9e07191c52cd4fecc9295172a7087ade896ccd7))
9
+
3
10
  ## 0.13.0 (2025-07-23)
4
11
 
5
12
 
@@ -376,4 +376,4 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
376
376
  }) => Promise<any>;
377
377
  };
378
378
 
379
- export { type CalldataEncodable as C, type DecodedDeployData as D, type GenLayerClient as G, type Hash as H, type MethodDescription as M, type Network as N, type SnapSource as S, type TransactionDataElement as T, VoteType as V, CalldataAddress as a, type GenLayerMethod as b, type ContractParamsArraySchemaElement as c, type ContractParamsSchema as d, type ContractMethodBase as e, type ContractMethod as f, type ContractSchema as g, type TransactionHash as h, TransactionStatus as i, TransactionResult as j, transactionsStatusNameToNumber as k, transactionResultNumberToName as l, TransactionResultNameToNumber as m, voteTypeNameToNumber as n, type TransactionType as o, TransactionHashVariant as p, type DecodedCallData as q, type GenLayerTransaction as r, type GenLayerRawTransaction as s, transactionsStatusNumberToName as t, voteTypeNumberToName as v };
379
+ export { type CalldataEncodable as C, type DecodedDeployData as D, type GenLayerClient as G, type Hash as H, type MethodDescription as M, type Network as N, type SnapSource as S, type TransactionDataElement as T, VoteType as V, type DecodedCallData as a, type GenLayerRawTransaction as b, type GenLayerTransaction as c, CalldataAddress as d, type GenLayerMethod as e, type ContractParamsArraySchemaElement as f, type ContractParamsSchema as g, type ContractMethodBase as h, type ContractMethod as i, type ContractSchema as j, type TransactionHash as k, TransactionStatus as l, TransactionResult as m, transactionsStatusNameToNumber as n, transactionResultNumberToName as o, TransactionResultNameToNumber as p, voteTypeNameToNumber as q, type TransactionType as r, TransactionHashVariant as s, transactionsStatusNumberToName as t, voteTypeNumberToName as v };
@@ -376,4 +376,4 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
376
376
  }) => Promise<any>;
377
377
  };
378
378
 
379
- export { type CalldataEncodable as C, type DecodedDeployData as D, type GenLayerClient as G, type Hash as H, type MethodDescription as M, type Network as N, type SnapSource as S, type TransactionDataElement as T, VoteType as V, CalldataAddress as a, type GenLayerMethod as b, type ContractParamsArraySchemaElement as c, type ContractParamsSchema as d, type ContractMethodBase as e, type ContractMethod as f, type ContractSchema as g, type TransactionHash as h, TransactionStatus as i, TransactionResult as j, transactionsStatusNameToNumber as k, transactionResultNumberToName as l, TransactionResultNameToNumber as m, voteTypeNameToNumber as n, type TransactionType as o, TransactionHashVariant as p, type DecodedCallData as q, type GenLayerTransaction as r, type GenLayerRawTransaction as s, transactionsStatusNumberToName as t, voteTypeNumberToName as v };
379
+ export { type CalldataEncodable as C, type DecodedDeployData as D, type GenLayerClient as G, type Hash as H, type MethodDescription as M, type Network as N, type SnapSource as S, type TransactionDataElement as T, VoteType as V, type DecodedCallData as a, type GenLayerRawTransaction as b, type GenLayerTransaction as c, CalldataAddress as d, type GenLayerMethod as e, type ContractParamsArraySchemaElement as f, type ContractParamsSchema as g, type ContractMethodBase as h, type ContractMethod as i, type ContractSchema as j, type TransactionHash as k, TransactionStatus as l, TransactionResult as m, transactionsStatusNameToNumber as n, transactionResultNumberToName as o, TransactionResultNameToNumber as p, voteTypeNameToNumber as q, type TransactionType as r, TransactionHashVariant as s, transactionsStatusNumberToName as t, voteTypeNumberToName as v };
package/dist/index.cjs CHANGED
@@ -57,6 +57,7 @@ var calldata_exports = {};
57
57
  _chunk75ZPJI57cjs.__export.call(void 0, calldata_exports, {
58
58
  decode: () => decode,
59
59
  encode: () => encode,
60
+ makeCalldataObject: () => makeCalldataObject,
60
61
  toString: () => toString
61
62
  });
62
63
 
@@ -203,6 +204,32 @@ function encode(data) {
203
204
  encodeImpl(arr, data);
204
205
  return new Uint8Array(arr);
205
206
  }
207
+ function makeCalldataObject(method, args, kwargs) {
208
+ let ret = {};
209
+ if (method) {
210
+ ret["method"] = method;
211
+ }
212
+ if (args && args.length > 0) {
213
+ ret["args"] = args;
214
+ }
215
+ if (kwargs) {
216
+ if (kwargs instanceof Map) {
217
+ if (kwargs.size > 0) {
218
+ ret["kwargs"] = kwargs;
219
+ }
220
+ } else {
221
+ let hasVal = false;
222
+ for (const _k in kwargs) {
223
+ hasVal = true;
224
+ break;
225
+ }
226
+ if (hasVal) {
227
+ ret["kwargs"] = kwargs;
228
+ }
229
+ }
230
+ }
231
+ return ret;
232
+ }
206
233
 
207
234
  // src/abi/calldata/decoder.ts
208
235
  function readULeb128(data, index) {
@@ -381,32 +408,6 @@ function serialize(data) {
381
408
 
382
409
  // src/contracts/actions.ts
383
410
 
384
- function makeCalldataObject(method, args, kwargs) {
385
- let ret = {};
386
- if (method) {
387
- ret["method"] = method;
388
- }
389
- if (args && args.length > 0) {
390
- ret["args"] = args;
391
- }
392
- if (kwargs) {
393
- if (kwargs instanceof Map) {
394
- if (kwargs.size > 0) {
395
- ret["kwargs"] = kwargs;
396
- }
397
- } else {
398
- let hasVal = false;
399
- for (const _k in kwargs) {
400
- hasVal = true;
401
- break;
402
- }
403
- if (hasVal) {
404
- ret["kwargs"] = kwargs;
405
- }
406
- }
407
- }
408
- return ret;
409
- }
410
411
  var contractActions = (client, publicClient) => {
411
412
  return {
412
413
  getContractSchema: async (address) => {
@@ -682,7 +683,7 @@ function resultToUserFriendlyJson(cd64) {
682
683
  };
683
684
  }
684
685
 
685
- // src/transactions/actions.ts
686
+ // src/transactions/decoders.ts
686
687
 
687
688
  var FIELDS_TO_REMOVE = [
688
689
  "raw",
@@ -726,69 +727,7 @@ var FIELD_NAME_MAPPINGS = {
726
727
  statusName: "status_name",
727
728
  typeHex: "type"
728
729
  };
729
- var receiptActions = (client, publicClient) => ({
730
- waitForTransactionReceipt: async ({
731
- hash,
732
- status = "ACCEPTED" /* ACCEPTED */,
733
- interval = transactionsConfig.waitInterval,
734
- retries = transactionsConfig.retries,
735
- fullTransaction = false
736
- }) => {
737
- const transaction = await client.getTransaction({
738
- hash
739
- });
740
- if (!transaction) {
741
- throw new Error("Transaction not found");
742
- }
743
- const transactionStatusString = String(transaction.status);
744
- const transactionStatusFinalized = _chunkH4ZYXVV2cjs.transactionsStatusNameToNumber["FINALIZED" /* FINALIZED */];
745
- const requestedStatus = _chunkH4ZYXVV2cjs.transactionsStatusNameToNumber[status];
746
- if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && transactionStatusString === transactionStatusFinalized) {
747
- let finalTransaction = transaction;
748
- if (client.chain.id === _chunkZKBMABRAcjs.localnet.id) {
749
- finalTransaction = _decodeLocalnetTransaction(transaction);
750
- }
751
- if (!fullTransaction) {
752
- return _simplifyTransactionReceipt(finalTransaction);
753
- }
754
- return finalTransaction;
755
- }
756
- if (retries === 0) {
757
- throw new Error("Transaction status is not " + status);
758
- }
759
- await sleep(interval);
760
- return receiptActions(client, publicClient).waitForTransactionReceipt({
761
- hash,
762
- status,
763
- interval,
764
- retries: retries - 1,
765
- fullTransaction
766
- });
767
- }
768
- });
769
- var transactionActions = (client, publicClient) => ({
770
- getTransaction: async ({ hash }) => {
771
- if (client.chain.id === _chunkZKBMABRAcjs.localnet.id) {
772
- const transaction2 = await client.getTransaction({ hash });
773
- const localnetStatus = transaction2.status === "ACTIVATED" ? "PENDING" /* PENDING */ : transaction2.status;
774
- transaction2.status = Number(_chunkH4ZYXVV2cjs.transactionsStatusNameToNumber[localnetStatus]);
775
- transaction2.statusName = localnetStatus;
776
- return _decodeLocalnetTransaction(transaction2);
777
- }
778
- const transaction = await publicClient.readContract({
779
- address: _optionalChain([client, 'access', _25 => _25.chain, 'access', _26 => _26.consensusDataContract, 'optionalAccess', _27 => _27.address]),
780
- abi: _optionalChain([client, 'access', _28 => _28.chain, 'access', _29 => _29.consensusDataContract, 'optionalAccess', _30 => _30.abi]),
781
- functionName: "getTransactionData",
782
- args: [
783
- hash,
784
- Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)
785
- // unix seconds
786
- ]
787
- });
788
- return _decodeTransaction(transaction);
789
- }
790
- });
791
- var _decodeInputData = (rlpEncodedAppData, recipient) => {
730
+ var decodeInputData = (rlpEncodedAppData, recipient) => {
792
731
  if (!rlpEncodedAppData || rlpEncodedAppData === "0x" || rlpEncodedAppData.length <= 2) {
793
732
  return null;
794
733
  }
@@ -826,8 +765,8 @@ var _decodeInputData = (rlpEncodedAppData, recipient) => {
826
765
  return null;
827
766
  }
828
767
  };
829
- var _decodeTransaction = (tx) => {
830
- const txDataDecoded = _decodeInputData(tx.txData, tx.recipient);
768
+ var decodeTransaction = (tx) => {
769
+ const txDataDecoded = decodeInputData(tx.txData, tx.recipient);
831
770
  const decodedTx = {
832
771
  ...tx,
833
772
  txData: tx.txData,
@@ -862,7 +801,7 @@ var _decodeTransaction = (tx) => {
862
801
  };
863
802
  return decodedTx;
864
803
  };
865
- var _simplifyTransactionReceipt = (tx) => {
804
+ var simplifyTransactionReceipt = (tx) => {
866
805
  const simplifyObject = (obj, path = "") => {
867
806
  if (obj === null || obj === void 0) return obj;
868
807
  if (Array.isArray(obj)) {
@@ -933,10 +872,10 @@ var _simplifyTransactionReceipt = (tx) => {
933
872
  };
934
873
  return simplifyObject({ ...tx });
935
874
  };
936
- var _decodeLocalnetTransaction = (tx) => {
875
+ var decodeLocalnetTransaction = (tx) => {
937
876
  if (!tx.data) return tx;
938
877
  try {
939
- const leaderReceipt = _optionalChain([tx, 'access', _31 => _31.consensus_data, 'optionalAccess', _32 => _32.leader_receipt]);
878
+ const leaderReceipt = _optionalChain([tx, 'access', _25 => _25.consensus_data, 'optionalAccess', _26 => _26.leader_receipt]);
940
879
  if (leaderReceipt) {
941
880
  const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
942
881
  receipts.forEach((receipt) => {
@@ -967,18 +906,82 @@ var _decodeLocalnetTransaction = (tx) => {
967
906
  }
968
907
  });
969
908
  }
970
- if (_optionalChain([tx, 'access', _33 => _33.data, 'optionalAccess', _34 => _34.calldata]) && typeof tx.data.calldata === "string") {
909
+ if (_optionalChain([tx, 'access', _27 => _27.data, 'optionalAccess', _28 => _28.calldata]) && typeof tx.data.calldata === "string") {
971
910
  tx.data.calldata = {
972
911
  base64: tx.data.calldata,
973
912
  ...calldataToUserFriendlyJson(b64ToArray(tx.data.calldata))
974
913
  };
975
914
  }
976
915
  } catch (e) {
977
- console.error("Error in _decodeLocalnetTransaction:", e);
916
+ console.error("Error in decodeLocalnetTransaction:", e);
978
917
  }
979
918
  return tx;
980
919
  };
981
920
 
921
+ // src/transactions/actions.ts
922
+ var receiptActions = (client, publicClient) => ({
923
+ waitForTransactionReceipt: async ({
924
+ hash,
925
+ status = "ACCEPTED" /* ACCEPTED */,
926
+ interval = transactionsConfig.waitInterval,
927
+ retries = transactionsConfig.retries,
928
+ fullTransaction = false
929
+ }) => {
930
+ const transaction = await client.getTransaction({
931
+ hash
932
+ });
933
+ if (!transaction) {
934
+ throw new Error("Transaction not found");
935
+ }
936
+ const transactionStatusString = String(transaction.status);
937
+ const transactionStatusFinalized = _chunkH4ZYXVV2cjs.transactionsStatusNameToNumber["FINALIZED" /* FINALIZED */];
938
+ const requestedStatus = _chunkH4ZYXVV2cjs.transactionsStatusNameToNumber[status];
939
+ if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && transactionStatusString === transactionStatusFinalized) {
940
+ let finalTransaction = transaction;
941
+ if (client.chain.id === _chunkZKBMABRAcjs.localnet.id) {
942
+ finalTransaction = decodeLocalnetTransaction(transaction);
943
+ }
944
+ if (!fullTransaction) {
945
+ return simplifyTransactionReceipt(finalTransaction);
946
+ }
947
+ return finalTransaction;
948
+ }
949
+ if (retries === 0) {
950
+ throw new Error("Transaction status is not " + status);
951
+ }
952
+ await sleep(interval);
953
+ return receiptActions(client, publicClient).waitForTransactionReceipt({
954
+ hash,
955
+ status,
956
+ interval,
957
+ retries: retries - 1,
958
+ fullTransaction
959
+ });
960
+ }
961
+ });
962
+ var transactionActions = (client, publicClient) => ({
963
+ getTransaction: async ({ hash }) => {
964
+ if (client.chain.id === _chunkZKBMABRAcjs.localnet.id) {
965
+ const transaction2 = await client.getTransaction({ hash });
966
+ const localnetStatus = transaction2.status === "ACTIVATED" ? "PENDING" /* PENDING */ : transaction2.status;
967
+ transaction2.status = Number(_chunkH4ZYXVV2cjs.transactionsStatusNameToNumber[localnetStatus]);
968
+ transaction2.statusName = localnetStatus;
969
+ return decodeLocalnetTransaction(transaction2);
970
+ }
971
+ const transaction = await publicClient.readContract({
972
+ address: _optionalChain([client, 'access', _29 => _29.chain, 'access', _30 => _30.consensusDataContract, 'optionalAccess', _31 => _31.address]),
973
+ abi: _optionalChain([client, 'access', _32 => _32.chain, 'access', _33 => _33.consensusDataContract, 'optionalAccess', _34 => _34.abi]),
974
+ functionName: "getTransactionData",
975
+ args: [
976
+ hash,
977
+ Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)
978
+ // unix seconds
979
+ ]
980
+ });
981
+ return decodeTransaction(transaction);
982
+ }
983
+ });
984
+
982
985
  // src/config/snapID.ts
983
986
  var snapID = {
984
987
  local: "local:http://localhost:8081",
@@ -1206,4 +1209,8 @@ var createAccount = (accountPrivateKey) => {
1206
1209
 
1207
1210
 
1208
1211
 
1209
- exports.abi = abi_exports; exports.chains = _chunkZKBMABRAcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.generatePrivateKey = generatePrivateKey;
1212
+
1213
+
1214
+
1215
+
1216
+ exports.abi = abi_exports; exports.chains = _chunkZKBMABRAcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.decodeInputData = decodeInputData; exports.decodeLocalnetTransaction = decodeLocalnetTransaction; exports.decodeTransaction = decodeTransaction; exports.generatePrivateKey = generatePrivateKey; exports.simplifyTransactionReceipt = simplifyTransactionReceipt;
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as viem from 'viem';
2
- import { Account, Address } from 'viem';
2
+ import { Account, Address, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-BYSCF33g.cjs';
4
- import { G as GenLayerClient, C as CalldataEncodable, T as TransactionDataElement } from './index-icLJcrDm.cjs';
4
+ import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement } from './index-IViMPpkl.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';
@@ -53,7 +53,15 @@ declare const createAccount: (accountPrivateKey?: `0x${string}`) => {
53
53
  type: "local";
54
54
  };
55
55
 
56
+ declare const decodeInputData: (rlpEncodedAppData: Hex | undefined | null, recipient: Address) => DecodedDeployData | DecodedCallData | null;
57
+ declare const decodeTransaction: (tx: GenLayerRawTransaction) => GenLayerTransaction;
58
+ declare const simplifyTransactionReceipt: (tx: GenLayerTransaction) => GenLayerTransaction;
59
+ declare const decodeLocalnetTransaction: (tx: GenLayerTransaction) => GenLayerTransaction;
60
+
56
61
  declare function encode(data: CalldataEncodable): Uint8Array;
62
+ declare function makeCalldataObject(method: string | undefined, args: CalldataEncodable[] | undefined, kwargs: {
63
+ [key: string]: CalldataEncodable;
64
+ } | Map<string, CalldataEncodable> | undefined): CalldataEncodable;
57
65
 
58
66
  declare function decode(data: Uint8Array): CalldataEncodable;
59
67
 
@@ -61,9 +69,10 @@ declare function toString(data: CalldataEncodable): string;
61
69
 
62
70
  declare const cd_decode: typeof decode;
63
71
  declare const cd_encode: typeof encode;
72
+ declare const cd_makeCalldataObject: typeof makeCalldataObject;
64
73
  declare const cd_toString: typeof toString;
65
74
  declare namespace cd {
66
- export { cd_decode as decode, cd_encode as encode, cd_toString as toString };
75
+ export { cd_decode as decode, cd_encode as encode, cd_makeCalldataObject as makeCalldataObject, cd_toString as toString };
67
76
  }
68
77
 
69
78
  declare function serializeOne(data: TransactionDataElement): `0x${string}`;
@@ -84,4 +93,4 @@ declare namespace index {
84
93
  export { index_calldata as calldata, index_transactions as transactions };
85
94
  }
86
95
 
87
- export { index as abi, createAccount, createClient, generatePrivateKey };
96
+ export { index as abi, createAccount, createClient, decodeInputData, decodeLocalnetTransaction, decodeTransaction, generatePrivateKey, simplifyTransactionReceipt };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as viem from 'viem';
2
- import { Account, Address } from 'viem';
2
+ import { Account, Address, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-BYSCF33g.js';
4
- import { G as GenLayerClient, C as CalldataEncodable, T as TransactionDataElement } from './index-TWCEN45Z.js';
4
+ import { G as GenLayerClient, D as DecodedDeployData, a as DecodedCallData, b as GenLayerRawTransaction, c as GenLayerTransaction, C as CalldataEncodable, T as TransactionDataElement } from './index-CgHl4W-5.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';
@@ -53,7 +53,15 @@ declare const createAccount: (accountPrivateKey?: `0x${string}`) => {
53
53
  type: "local";
54
54
  };
55
55
 
56
+ declare const decodeInputData: (rlpEncodedAppData: Hex | undefined | null, recipient: Address) => DecodedDeployData | DecodedCallData | null;
57
+ declare const decodeTransaction: (tx: GenLayerRawTransaction) => GenLayerTransaction;
58
+ declare const simplifyTransactionReceipt: (tx: GenLayerTransaction) => GenLayerTransaction;
59
+ declare const decodeLocalnetTransaction: (tx: GenLayerTransaction) => GenLayerTransaction;
60
+
56
61
  declare function encode(data: CalldataEncodable): Uint8Array;
62
+ declare function makeCalldataObject(method: string | undefined, args: CalldataEncodable[] | undefined, kwargs: {
63
+ [key: string]: CalldataEncodable;
64
+ } | Map<string, CalldataEncodable> | undefined): CalldataEncodable;
57
65
 
58
66
  declare function decode(data: Uint8Array): CalldataEncodable;
59
67
 
@@ -61,9 +69,10 @@ declare function toString(data: CalldataEncodable): string;
61
69
 
62
70
  declare const cd_decode: typeof decode;
63
71
  declare const cd_encode: typeof encode;
72
+ declare const cd_makeCalldataObject: typeof makeCalldataObject;
64
73
  declare const cd_toString: typeof toString;
65
74
  declare namespace cd {
66
- export { cd_decode as decode, cd_encode as encode, cd_toString as toString };
75
+ export { cd_decode as decode, cd_encode as encode, cd_makeCalldataObject as makeCalldataObject, cd_toString as toString };
67
76
  }
68
77
 
69
78
  declare function serializeOne(data: TransactionDataElement): `0x${string}`;
@@ -84,4 +93,4 @@ declare namespace index {
84
93
  export { index_calldata as calldata, index_transactions as transactions };
85
94
  }
86
95
 
87
- export { index as abi, createAccount, createClient, generatePrivateKey };
96
+ export { index as abi, createAccount, createClient, decodeInputData, decodeLocalnetTransaction, decodeTransaction, generatePrivateKey, simplifyTransactionReceipt };
package/dist/index.js CHANGED
@@ -57,6 +57,7 @@ var calldata_exports = {};
57
57
  __export(calldata_exports, {
58
58
  decode: () => decode,
59
59
  encode: () => encode,
60
+ makeCalldataObject: () => makeCalldataObject,
60
61
  toString: () => toString
61
62
  });
62
63
 
@@ -203,6 +204,32 @@ function encode(data) {
203
204
  encodeImpl(arr, data);
204
205
  return new Uint8Array(arr);
205
206
  }
207
+ function makeCalldataObject(method, args, kwargs) {
208
+ let ret = {};
209
+ if (method) {
210
+ ret["method"] = method;
211
+ }
212
+ if (args && args.length > 0) {
213
+ ret["args"] = args;
214
+ }
215
+ if (kwargs) {
216
+ if (kwargs instanceof Map) {
217
+ if (kwargs.size > 0) {
218
+ ret["kwargs"] = kwargs;
219
+ }
220
+ } else {
221
+ let hasVal = false;
222
+ for (const _k in kwargs) {
223
+ hasVal = true;
224
+ break;
225
+ }
226
+ if (hasVal) {
227
+ ret["kwargs"] = kwargs;
228
+ }
229
+ }
230
+ }
231
+ return ret;
232
+ }
206
233
 
207
234
  // src/abi/calldata/decoder.ts
208
235
  function readULeb128(data, index) {
@@ -381,32 +408,6 @@ function serialize(data) {
381
408
 
382
409
  // src/contracts/actions.ts
383
410
  import { fromHex, toHex as toHex2, zeroAddress, encodeFunctionData, parseEventLogs } from "viem";
384
- function makeCalldataObject(method, args, kwargs) {
385
- let ret = {};
386
- if (method) {
387
- ret["method"] = method;
388
- }
389
- if (args && args.length > 0) {
390
- ret["args"] = args;
391
- }
392
- if (kwargs) {
393
- if (kwargs instanceof Map) {
394
- if (kwargs.size > 0) {
395
- ret["kwargs"] = kwargs;
396
- }
397
- } else {
398
- let hasVal = false;
399
- for (const _k in kwargs) {
400
- hasVal = true;
401
- break;
402
- }
403
- if (hasVal) {
404
- ret["kwargs"] = kwargs;
405
- }
406
- }
407
- }
408
- return ret;
409
- }
410
411
  var contractActions = (client, publicClient) => {
411
412
  return {
412
413
  getContractSchema: async (address) => {
@@ -682,7 +683,7 @@ function resultToUserFriendlyJson(cd64) {
682
683
  };
683
684
  }
684
685
 
685
- // src/transactions/actions.ts
686
+ // src/transactions/decoders.ts
686
687
  import { fromRlp, fromHex as fromHex2 } from "viem";
687
688
  var FIELDS_TO_REMOVE = [
688
689
  "raw",
@@ -726,69 +727,7 @@ var FIELD_NAME_MAPPINGS = {
726
727
  statusName: "status_name",
727
728
  typeHex: "type"
728
729
  };
729
- var receiptActions = (client, publicClient) => ({
730
- waitForTransactionReceipt: async ({
731
- hash,
732
- status = "ACCEPTED" /* ACCEPTED */,
733
- interval = transactionsConfig.waitInterval,
734
- retries = transactionsConfig.retries,
735
- fullTransaction = false
736
- }) => {
737
- const transaction = await client.getTransaction({
738
- hash
739
- });
740
- if (!transaction) {
741
- throw new Error("Transaction not found");
742
- }
743
- const transactionStatusString = String(transaction.status);
744
- const transactionStatusFinalized = transactionsStatusNameToNumber["FINALIZED" /* FINALIZED */];
745
- const requestedStatus = transactionsStatusNameToNumber[status];
746
- if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && transactionStatusString === transactionStatusFinalized) {
747
- let finalTransaction = transaction;
748
- if (client.chain.id === localnet.id) {
749
- finalTransaction = _decodeLocalnetTransaction(transaction);
750
- }
751
- if (!fullTransaction) {
752
- return _simplifyTransactionReceipt(finalTransaction);
753
- }
754
- return finalTransaction;
755
- }
756
- if (retries === 0) {
757
- throw new Error("Transaction status is not " + status);
758
- }
759
- await sleep(interval);
760
- return receiptActions(client, publicClient).waitForTransactionReceipt({
761
- hash,
762
- status,
763
- interval,
764
- retries: retries - 1,
765
- fullTransaction
766
- });
767
- }
768
- });
769
- var transactionActions = (client, publicClient) => ({
770
- getTransaction: async ({ hash }) => {
771
- if (client.chain.id === localnet.id) {
772
- const transaction2 = await client.getTransaction({ hash });
773
- const localnetStatus = transaction2.status === "ACTIVATED" ? "PENDING" /* PENDING */ : transaction2.status;
774
- transaction2.status = Number(transactionsStatusNameToNumber[localnetStatus]);
775
- transaction2.statusName = localnetStatus;
776
- return _decodeLocalnetTransaction(transaction2);
777
- }
778
- const transaction = await publicClient.readContract({
779
- address: client.chain.consensusDataContract?.address,
780
- abi: client.chain.consensusDataContract?.abi,
781
- functionName: "getTransactionData",
782
- args: [
783
- hash,
784
- Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)
785
- // unix seconds
786
- ]
787
- });
788
- return _decodeTransaction(transaction);
789
- }
790
- });
791
- var _decodeInputData = (rlpEncodedAppData, recipient) => {
730
+ var decodeInputData = (rlpEncodedAppData, recipient) => {
792
731
  if (!rlpEncodedAppData || rlpEncodedAppData === "0x" || rlpEncodedAppData.length <= 2) {
793
732
  return null;
794
733
  }
@@ -826,8 +765,8 @@ var _decodeInputData = (rlpEncodedAppData, recipient) => {
826
765
  return null;
827
766
  }
828
767
  };
829
- var _decodeTransaction = (tx) => {
830
- const txDataDecoded = _decodeInputData(tx.txData, tx.recipient);
768
+ var decodeTransaction = (tx) => {
769
+ const txDataDecoded = decodeInputData(tx.txData, tx.recipient);
831
770
  const decodedTx = {
832
771
  ...tx,
833
772
  txData: tx.txData,
@@ -862,7 +801,7 @@ var _decodeTransaction = (tx) => {
862
801
  };
863
802
  return decodedTx;
864
803
  };
865
- var _simplifyTransactionReceipt = (tx) => {
804
+ var simplifyTransactionReceipt = (tx) => {
866
805
  const simplifyObject = (obj, path = "") => {
867
806
  if (obj === null || obj === void 0) return obj;
868
807
  if (Array.isArray(obj)) {
@@ -933,7 +872,7 @@ var _simplifyTransactionReceipt = (tx) => {
933
872
  };
934
873
  return simplifyObject({ ...tx });
935
874
  };
936
- var _decodeLocalnetTransaction = (tx) => {
875
+ var decodeLocalnetTransaction = (tx) => {
937
876
  if (!tx.data) return tx;
938
877
  try {
939
878
  const leaderReceipt = tx.consensus_data?.leader_receipt;
@@ -974,11 +913,75 @@ var _decodeLocalnetTransaction = (tx) => {
974
913
  };
975
914
  }
976
915
  } catch (e) {
977
- console.error("Error in _decodeLocalnetTransaction:", e);
916
+ console.error("Error in decodeLocalnetTransaction:", e);
978
917
  }
979
918
  return tx;
980
919
  };
981
920
 
921
+ // src/transactions/actions.ts
922
+ var receiptActions = (client, publicClient) => ({
923
+ waitForTransactionReceipt: async ({
924
+ hash,
925
+ status = "ACCEPTED" /* ACCEPTED */,
926
+ interval = transactionsConfig.waitInterval,
927
+ retries = transactionsConfig.retries,
928
+ fullTransaction = false
929
+ }) => {
930
+ const transaction = await client.getTransaction({
931
+ hash
932
+ });
933
+ if (!transaction) {
934
+ throw new Error("Transaction not found");
935
+ }
936
+ const transactionStatusString = String(transaction.status);
937
+ const transactionStatusFinalized = transactionsStatusNameToNumber["FINALIZED" /* FINALIZED */];
938
+ const requestedStatus = transactionsStatusNameToNumber[status];
939
+ if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && transactionStatusString === transactionStatusFinalized) {
940
+ let finalTransaction = transaction;
941
+ if (client.chain.id === localnet.id) {
942
+ finalTransaction = decodeLocalnetTransaction(transaction);
943
+ }
944
+ if (!fullTransaction) {
945
+ return simplifyTransactionReceipt(finalTransaction);
946
+ }
947
+ return finalTransaction;
948
+ }
949
+ if (retries === 0) {
950
+ throw new Error("Transaction status is not " + status);
951
+ }
952
+ await sleep(interval);
953
+ return receiptActions(client, publicClient).waitForTransactionReceipt({
954
+ hash,
955
+ status,
956
+ interval,
957
+ retries: retries - 1,
958
+ fullTransaction
959
+ });
960
+ }
961
+ });
962
+ var transactionActions = (client, publicClient) => ({
963
+ getTransaction: async ({ hash }) => {
964
+ if (client.chain.id === localnet.id) {
965
+ const transaction2 = await client.getTransaction({ hash });
966
+ const localnetStatus = transaction2.status === "ACTIVATED" ? "PENDING" /* PENDING */ : transaction2.status;
967
+ transaction2.status = Number(transactionsStatusNameToNumber[localnetStatus]);
968
+ transaction2.statusName = localnetStatus;
969
+ return decodeLocalnetTransaction(transaction2);
970
+ }
971
+ const transaction = await publicClient.readContract({
972
+ address: client.chain.consensusDataContract?.address,
973
+ abi: client.chain.consensusDataContract?.abi,
974
+ functionName: "getTransactionData",
975
+ args: [
976
+ hash,
977
+ Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3)
978
+ // unix seconds
979
+ ]
980
+ });
981
+ return decodeTransaction(transaction);
982
+ }
983
+ });
984
+
982
985
  // src/config/snapID.ts
983
986
  var snapID = {
984
987
  local: "local:http://localhost:8081",
@@ -1205,5 +1208,9 @@ export {
1205
1208
  chains_exports as chains,
1206
1209
  createAccount,
1207
1210
  createClient,
1208
- generatePrivateKey
1211
+ decodeInputData,
1212
+ decodeLocalnetTransaction,
1213
+ decodeTransaction,
1214
+ generatePrivateKey,
1215
+ simplifyTransactionReceipt
1209
1216
  };
@@ -1,3 +1,3 @@
1
1
  export { Account, Address } from 'viem';
2
- export { a as CalldataAddress, C as CalldataEncodable, f as ContractMethod, e as ContractMethodBase, c as ContractParamsArraySchemaElement, d as ContractParamsSchema, g as ContractSchema, q as DecodedCallData, D as DecodedDeployData, G as GenLayerClient, b as GenLayerMethod, s as GenLayerRawTransaction, r as GenLayerTransaction, H as Hash, M as MethodDescription, N as Network, S as SnapSource, h as TransactionHash, p as TransactionHashVariant, j as TransactionResult, m as TransactionResultNameToNumber, i as TransactionStatus, o as TransactionType, V as VoteType, l as transactionResultNumberToName, k as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, n as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-icLJcrDm.cjs';
2
+ export { d as CalldataAddress, C as CalldataEncodable, i as ContractMethod, h as ContractMethodBase, f as ContractParamsArraySchemaElement, g as ContractParamsSchema, j as ContractSchema, a as DecodedCallData, D as DecodedDeployData, G as GenLayerClient, e as GenLayerMethod, b as GenLayerRawTransaction, c as GenLayerTransaction, H as Hash, M as MethodDescription, N as Network, S as SnapSource, k as TransactionHash, s as TransactionHashVariant, m as TransactionResult, p as TransactionResultNameToNumber, l as TransactionStatus, r as TransactionType, V as VoteType, o as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, q as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-IViMPpkl.cjs';
3
3
  export { G as GenLayerChain } from '../chains-BYSCF33g.cjs';