genlayer-js 0.11.1 → 0.12.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,19 @@
1
1
 
2
2
 
3
+ ## 0.12.0 (2025-07-15)
4
+
5
+
6
+ ### Features
7
+
8
+ * add payable to ContractMethod ([#96](https://github.com/genlayerlabs/genlayer-js/issues/96)) ([011a749](https://github.com/genlayerlabs/genlayer-js/commit/011a7498ffce22a34d20d9fb88a72e7c56badaf9))
9
+
10
+ ## 0.11.2 (2025-07-10)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * handle new leader receipt and decode eq outputs ([#98](https://github.com/genlayerlabs/genlayer-js/issues/98)) ([fadb53d](https://github.com/genlayerlabs/genlayer-js/commit/fadb53d5f8946074a80047003323a0bd3d4f8108))
16
+
3
17
  ## 0.11.1 (2025-07-09)
4
18
 
5
19
  ## 0.11.0 (2025-05-28)
@@ -198,7 +198,7 @@ type GenLayerTransaction = {
198
198
  pending_transactions: unknown[];
199
199
  vote: string;
200
200
  result: string;
201
- };
201
+ }[];
202
202
  validators?: Record<string, unknown>[];
203
203
  votes?: Record<string, string>;
204
204
  };
@@ -269,6 +269,7 @@ interface ContractMethodBase {
269
269
  interface ContractMethod extends ContractMethodBase {
270
270
  ret: ContractParamsSchema;
271
271
  readonly: boolean;
272
+ payable?: boolean;
272
273
  }
273
274
  type ContractSchema = {
274
275
  ctor: ContractMethodBase;
@@ -198,7 +198,7 @@ type GenLayerTransaction = {
198
198
  pending_transactions: unknown[];
199
199
  vote: string;
200
200
  result: string;
201
- };
201
+ }[];
202
202
  validators?: Record<string, unknown>[];
203
203
  votes?: Record<string, string>;
204
204
  };
@@ -269,6 +269,7 @@ interface ContractMethodBase {
269
269
  interface ContractMethod extends ContractMethodBase {
270
270
  ret: ContractParamsSchema;
271
271
  readonly: boolean;
272
+ payable?: boolean;
272
273
  }
273
274
  type ContractSchema = {
274
275
  ctor: ContractMethodBase;
package/dist/index.cjs CHANGED
@@ -819,23 +819,25 @@ var _decodeLocalnetTransaction = (tx) => {
819
819
  try {
820
820
  const leaderReceipt = _optionalChain([tx, 'access', _31 => _31.consensus_data, 'optionalAccess', _32 => _32.leader_receipt]);
821
821
  if (leaderReceipt) {
822
- if (leaderReceipt.result && typeof leaderReceipt.result === "string") {
823
- leaderReceipt.result = resultToUserFriendlyJson(leaderReceipt.result);
824
- }
825
- if (leaderReceipt.calldata && typeof leaderReceipt.calldata === "string") {
826
- leaderReceipt.calldata = {
827
- base64: leaderReceipt.calldata,
828
- ...calldataToUserFriendlyJson(b64ToArray(leaderReceipt.calldata))
829
- };
830
- }
831
- if (leaderReceipt.eq_outputs) {
832
- leaderReceipt.eq_outputs = Object.fromEntries(
833
- Object.entries(leaderReceipt.eq_outputs).map(([key, value]) => {
834
- const decodedValue = new TextDecoder().decode(b64ToArray(String(value)));
835
- return [key, resultToUserFriendlyJson(decodedValue)];
836
- })
837
- );
838
- }
822
+ const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
823
+ receipts.forEach((receipt) => {
824
+ if (receipt.result && typeof receipt.result === "string") {
825
+ receipt.result = resultToUserFriendlyJson(receipt.result);
826
+ }
827
+ if (receipt.calldata && typeof receipt.calldata === "string") {
828
+ receipt.calldata = {
829
+ base64: receipt.calldata,
830
+ ...calldataToUserFriendlyJson(b64ToArray(receipt.calldata))
831
+ };
832
+ }
833
+ if (receipt.eq_outputs) {
834
+ receipt.eq_outputs = Object.fromEntries(
835
+ Object.entries(receipt.eq_outputs).map(([key, value]) => {
836
+ return [key, resultToUserFriendlyJson(String(value))];
837
+ })
838
+ );
839
+ }
840
+ });
839
841
  }
840
842
  if (_optionalChain([tx, 'access', _33 => _33.data, 'optionalAccess', _34 => _34.calldata]) && typeof tx.data.calldata === "string") {
841
843
  tx.data.calldata = {
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as viem from 'viem';
2
2
  import { Account, Address } 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-BhRfI25e.cjs';
4
+ import { G as GenLayerClient, C as CalldataEncodable, T as TransactionDataElement } from './index-icLJcrDm.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';
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as viem from 'viem';
2
2
  import { Account, Address } 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-dnt5ldCd.js';
4
+ import { G as GenLayerClient, C as CalldataEncodable, T as TransactionDataElement } from './index-TWCEN45Z.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';
package/dist/index.js CHANGED
@@ -819,23 +819,25 @@ var _decodeLocalnetTransaction = (tx) => {
819
819
  try {
820
820
  const leaderReceipt = tx.consensus_data?.leader_receipt;
821
821
  if (leaderReceipt) {
822
- if (leaderReceipt.result && typeof leaderReceipt.result === "string") {
823
- leaderReceipt.result = resultToUserFriendlyJson(leaderReceipt.result);
824
- }
825
- if (leaderReceipt.calldata && typeof leaderReceipt.calldata === "string") {
826
- leaderReceipt.calldata = {
827
- base64: leaderReceipt.calldata,
828
- ...calldataToUserFriendlyJson(b64ToArray(leaderReceipt.calldata))
829
- };
830
- }
831
- if (leaderReceipt.eq_outputs) {
832
- leaderReceipt.eq_outputs = Object.fromEntries(
833
- Object.entries(leaderReceipt.eq_outputs).map(([key, value]) => {
834
- const decodedValue = new TextDecoder().decode(b64ToArray(String(value)));
835
- return [key, resultToUserFriendlyJson(decodedValue)];
836
- })
837
- );
838
- }
822
+ const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
823
+ receipts.forEach((receipt) => {
824
+ if (receipt.result && typeof receipt.result === "string") {
825
+ receipt.result = resultToUserFriendlyJson(receipt.result);
826
+ }
827
+ if (receipt.calldata && typeof receipt.calldata === "string") {
828
+ receipt.calldata = {
829
+ base64: receipt.calldata,
830
+ ...calldataToUserFriendlyJson(b64ToArray(receipt.calldata))
831
+ };
832
+ }
833
+ if (receipt.eq_outputs) {
834
+ receipt.eq_outputs = Object.fromEntries(
835
+ Object.entries(receipt.eq_outputs).map(([key, value]) => {
836
+ return [key, resultToUserFriendlyJson(String(value))];
837
+ })
838
+ );
839
+ }
840
+ });
839
841
  }
840
842
  if (tx.data?.calldata && typeof tx.data.calldata === "string") {
841
843
  tx.data.calldata = {
@@ -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-BhRfI25e.cjs';
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';
3
3
  export { G as GenLayerChain } from '../chains-BYSCF33g.cjs';
@@ -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-dnt5ldCd.js';
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-TWCEN45Z.js';
3
3
  export { G as GenLayerChain } from '../chains-BYSCF33g.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.11.1",
4
+ "version": "0.12.0",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -188,23 +188,25 @@ const _decodeLocalnetTransaction = (tx: GenLayerTransaction): GenLayerTransactio
188
188
  try {
189
189
  const leaderReceipt = tx.consensus_data?.leader_receipt;
190
190
  if (leaderReceipt) {
191
- if (leaderReceipt.result && typeof leaderReceipt.result === "string") {
192
- leaderReceipt.result = resultToUserFriendlyJson(leaderReceipt.result);
193
- }
194
- if (leaderReceipt.calldata && typeof leaderReceipt.calldata === "string") {
195
- leaderReceipt.calldata = {
196
- base64: leaderReceipt.calldata as string,
197
- ...calldataToUserFriendlyJson(b64ToArray(leaderReceipt.calldata as string)),
198
- };
199
- }
200
- if (leaderReceipt.eq_outputs) {
201
- leaderReceipt.eq_outputs = Object.fromEntries(
202
- Object.entries(leaderReceipt.eq_outputs).map(([key, value]) => {
203
- const decodedValue = new TextDecoder().decode(b64ToArray(String(value)));
204
- return [key, resultToUserFriendlyJson(decodedValue)];
205
- }),
206
- );
207
- }
191
+ const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
192
+ receipts.forEach((receipt) => {
193
+ if (receipt.result && typeof receipt.result === "string") {
194
+ receipt.result = resultToUserFriendlyJson(receipt.result);
195
+ }
196
+ if (receipt.calldata && typeof receipt.calldata === "string") {
197
+ receipt.calldata = {
198
+ base64: receipt.calldata as string,
199
+ ...calldataToUserFriendlyJson(b64ToArray(receipt.calldata as string)),
200
+ };
201
+ }
202
+ if (receipt.eq_outputs) {
203
+ receipt.eq_outputs = Object.fromEntries(
204
+ Object.entries(receipt.eq_outputs).map(([key, value]) => {
205
+ return [key, resultToUserFriendlyJson(String(value))];
206
+ }),
207
+ );
208
+ }
209
+ });
208
210
  }
209
211
  if (tx.data?.calldata && typeof tx.data.calldata === "string") {
210
212
  tx.data.calldata = {
@@ -23,6 +23,7 @@ export interface ContractMethodBase {
23
23
  export interface ContractMethod extends ContractMethodBase {
24
24
  ret: ContractParamsSchema;
25
25
  readonly: boolean;
26
+ payable?: boolean;
26
27
  }
27
28
 
28
29
  export type ContractSchema = {
@@ -241,7 +241,7 @@ export type GenLayerTransaction = {
241
241
  pending_transactions: unknown[];
242
242
  vote: string;
243
243
  result: string;
244
- };
244
+ }[];
245
245
  validators?: Record<string, unknown>[];
246
246
  votes?: Record<string, string>;
247
247
  };