genlayer-js 0.28.7 → 1.1.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.
@@ -2708,9 +2708,11 @@ interface ValidatorJoinOptions {
2708
2708
  }
2709
2709
  interface ValidatorDepositOptions {
2710
2710
  amount: bigint | string;
2711
+ validator: Address;
2711
2712
  }
2712
2713
  interface ValidatorExitOptions {
2713
2714
  shares: bigint | string;
2715
+ validator: Address;
2714
2716
  }
2715
2717
  interface ValidatorClaimOptions {
2716
2718
  validator?: Address;
@@ -2782,13 +2784,19 @@ type GenLayerMethod = {
2782
2784
  params: [signedTransaction: string];
2783
2785
  } | {
2784
2786
  method: "gen_getContractSchema";
2785
- params: [address: Address];
2787
+ params: [address: Address] | [{
2788
+ address: Address;
2789
+ }] | [{
2790
+ code: string;
2791
+ }];
2786
2792
  } | {
2787
2793
  method: "gen_getContractSchemaForCode";
2788
2794
  params: [contractCode: string];
2789
2795
  } | {
2790
2796
  method: "gen_getContractCode";
2791
- params: [address: Address];
2797
+ params: [address: Address] | [{
2798
+ address: Address;
2799
+ }];
2792
2800
  } | {
2793
2801
  method: "sim_getTransactionsForAddress";
2794
2802
  params: [address: Address, filter?: "all" | "from" | "to"];
@@ -2708,9 +2708,11 @@ interface ValidatorJoinOptions {
2708
2708
  }
2709
2709
  interface ValidatorDepositOptions {
2710
2710
  amount: bigint | string;
2711
+ validator: Address;
2711
2712
  }
2712
2713
  interface ValidatorExitOptions {
2713
2714
  shares: bigint | string;
2715
+ validator: Address;
2714
2716
  }
2715
2717
  interface ValidatorClaimOptions {
2716
2718
  validator?: Address;
@@ -2782,13 +2784,19 @@ type GenLayerMethod = {
2782
2784
  params: [signedTransaction: string];
2783
2785
  } | {
2784
2786
  method: "gen_getContractSchema";
2785
- params: [address: Address];
2787
+ params: [address: Address] | [{
2788
+ address: Address;
2789
+ }] | [{
2790
+ code: string;
2791
+ }];
2786
2792
  } | {
2787
2793
  method: "gen_getContractSchemaForCode";
2788
2794
  params: [contractCode: string];
2789
2795
  } | {
2790
2796
  method: "gen_getContractCode";
2791
- params: [address: Address];
2797
+ params: [address: Address] | [{
2798
+ address: Address;
2799
+ }];
2792
2800
  } | {
2793
2801
  method: "sim_getTransactionsForAddress";
2794
2802
  params: [address: Address, filter?: "all" | "from" | "to"];
package/dist/index.cjs CHANGED
@@ -430,6 +430,13 @@ var transactions = transactions_exports;
430
430
  function b64ToArray(b64) {
431
431
  return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
432
432
  }
433
+ function arrayToB64(bytes) {
434
+ let binary = "";
435
+ for (let i = 0; i < bytes.length; i++) {
436
+ binary += String.fromCharCode(bytes[i]);
437
+ }
438
+ return btoa(binary);
439
+ }
433
440
  function calldataToUserFriendlyJson(cd) {
434
441
  return {
435
442
  raw: Array.from(cd),
@@ -530,37 +537,49 @@ function extractGenCallResult(result) {
530
537
  }
531
538
  var contractActions = (client, publicClient) => {
532
539
  return {
533
- /** Retrieves the source code of a deployed contract. Studio only. */
540
+ /** Retrieves the source code of a deployed contract. */
534
541
  getContractCode: async (address) => {
535
- if (!client.chain.isStudio) {
536
- throw new Error(`getContractCode is only available on Studio networks (current chain: ${client.chain.name})`);
537
- }
542
+ const params = client.chain.isStudio ? [address] : [{ address }];
538
543
  const result = await client.request({
539
544
  method: "gen_getContractCode",
540
- params: [address]
545
+ params
541
546
  });
542
547
  const codeBytes = b64ToArray(result);
543
548
  return new TextDecoder().decode(codeBytes);
544
549
  },
545
- /** Gets the schema (methods and constructor) of a deployed contract. Studio only. */
550
+ /** Gets the schema (methods and constructor) of a deployed contract. */
546
551
  getContractSchema: async (address) => {
547
- if (!client.chain.isStudio) {
548
- throw new Error(`getContractSchema is only available on Studio networks (current chain: ${client.chain.name})`);
552
+ if (client.chain.isStudio) {
553
+ const schema2 = await client.request({
554
+ method: "gen_getContractSchema",
555
+ params: [address]
556
+ });
557
+ return schema2;
549
558
  }
559
+ const codeB64 = await client.request({
560
+ method: "gen_getContractCode",
561
+ params: [{ address }]
562
+ });
550
563
  const schema = await client.request({
551
564
  method: "gen_getContractSchema",
552
- params: [address]
565
+ params: [{ code: codeB64 }]
553
566
  });
554
567
  return schema;
555
568
  },
556
- /** Generates a schema for contract code without deploying it. Studio only. */
569
+ /** Generates a schema for contract code without deploying it. */
557
570
  getContractSchemaForCode: async (contractCode) => {
558
- if (!client.chain.isStudio) {
559
- throw new Error(`getContractSchemaForCode is only available on Studio networks (current chain: ${client.chain.name})`);
571
+ if (client.chain.isStudio) {
572
+ const schema2 = await client.request({
573
+ method: "gen_getContractSchemaForCode",
574
+ params: [_viem.toHex.call(void 0, contractCode)]
575
+ });
576
+ return schema2;
560
577
  }
578
+ const bytes = typeof contractCode === "string" ? new TextEncoder().encode(contractCode) : contractCode;
579
+ const codeB64 = arrayToB64(bytes);
561
580
  const schema = await client.request({
562
- method: "gen_getContractSchemaForCode",
563
- params: [_viem.toHex.call(void 0, contractCode)]
581
+ method: "gen_getContractSchema",
582
+ params: [{ code: codeB64 }]
564
583
  });
565
584
  return schema;
566
585
  },
@@ -1911,24 +1930,32 @@ var stakingActions = (client, publicClient) => {
1911
1930
  amountRaw: amount
1912
1931
  };
1913
1932
  },
1914
- /** Adds additional self-stake to an active validator position. */
1933
+ /**
1934
+ * Adds additional self-stake to an active validator position. The
1935
+ * underlying Staking contract requires msg.sender == ValidatorWallet,
1936
+ * so the call is routed through the wallet's own validatorDeposit
1937
+ * forwarder (which re-enters Staking with the correct sender).
1938
+ */
1915
1939
  validatorDeposit: async (options) => {
1916
1940
  const amount = parseStakingAmount(options.amount);
1917
1941
  const data = _viem.encodeFunctionData.call(void 0, {
1918
- abi: _chunkN74TARFYcjs.STAKING_ABI,
1942
+ abi: _chunkN74TARFYcjs.VALIDATOR_WALLET_ABI,
1919
1943
  functionName: "validatorDeposit"
1920
1944
  });
1921
- return executeWrite({ to: getStakingAddress(), data, value: amount });
1945
+ return executeWrite({ to: options.validator, data, value: amount });
1922
1946
  },
1923
- /** Exits a validator position by burning the specified shares. */
1947
+ /**
1948
+ * Exits a validator position by burning the specified shares. Same
1949
+ * msg.sender constraint as validatorDeposit — routed via the wallet.
1950
+ */
1924
1951
  validatorExit: async (options) => {
1925
1952
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1926
1953
  const data = _viem.encodeFunctionData.call(void 0, {
1927
- abi: _chunkN74TARFYcjs.STAKING_ABI,
1954
+ abi: _chunkN74TARFYcjs.VALIDATOR_WALLET_ABI,
1928
1955
  functionName: "validatorExit",
1929
1956
  args: [shares]
1930
1957
  });
1931
- return executeWrite({ to: getStakingAddress(), data });
1958
+ return executeWrite({ to: options.validator, data });
1932
1959
  },
1933
1960
  /** Claims pending validator withdrawals. */
1934
1961
  validatorClaim: async (options) => {
package/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as viem from 'viem';
2
2
  import { Account, Address, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-D6DgvIVA.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-D3H572Cz.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-Cf770kyK.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, Hex } from 'viem';
3
3
  import { G as GenLayerChain } from './chains-D6DgvIVA.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-BpBLcwxn.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-C3Ul1Rte.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
@@ -430,6 +430,13 @@ import { toHex as toHex2 } from "viem";
430
430
  function b64ToArray(b64) {
431
431
  return Uint8Array.from(atob(b64), (c) => c.charCodeAt(0));
432
432
  }
433
+ function arrayToB64(bytes) {
434
+ let binary = "";
435
+ for (let i = 0; i < bytes.length; i++) {
436
+ binary += String.fromCharCode(bytes[i]);
437
+ }
438
+ return btoa(binary);
439
+ }
433
440
  function calldataToUserFriendlyJson(cd) {
434
441
  return {
435
442
  raw: Array.from(cd),
@@ -530,37 +537,49 @@ function extractGenCallResult(result) {
530
537
  }
531
538
  var contractActions = (client, publicClient) => {
532
539
  return {
533
- /** Retrieves the source code of a deployed contract. Studio only. */
540
+ /** Retrieves the source code of a deployed contract. */
534
541
  getContractCode: async (address) => {
535
- if (!client.chain.isStudio) {
536
- throw new Error(`getContractCode is only available on Studio networks (current chain: ${client.chain.name})`);
537
- }
542
+ const params = client.chain.isStudio ? [address] : [{ address }];
538
543
  const result = await client.request({
539
544
  method: "gen_getContractCode",
540
- params: [address]
545
+ params
541
546
  });
542
547
  const codeBytes = b64ToArray(result);
543
548
  return new TextDecoder().decode(codeBytes);
544
549
  },
545
- /** Gets the schema (methods and constructor) of a deployed contract. Studio only. */
550
+ /** Gets the schema (methods and constructor) of a deployed contract. */
546
551
  getContractSchema: async (address) => {
547
- if (!client.chain.isStudio) {
548
- throw new Error(`getContractSchema is only available on Studio networks (current chain: ${client.chain.name})`);
552
+ if (client.chain.isStudio) {
553
+ const schema2 = await client.request({
554
+ method: "gen_getContractSchema",
555
+ params: [address]
556
+ });
557
+ return schema2;
549
558
  }
559
+ const codeB64 = await client.request({
560
+ method: "gen_getContractCode",
561
+ params: [{ address }]
562
+ });
550
563
  const schema = await client.request({
551
564
  method: "gen_getContractSchema",
552
- params: [address]
565
+ params: [{ code: codeB64 }]
553
566
  });
554
567
  return schema;
555
568
  },
556
- /** Generates a schema for contract code without deploying it. Studio only. */
569
+ /** Generates a schema for contract code without deploying it. */
557
570
  getContractSchemaForCode: async (contractCode) => {
558
- if (!client.chain.isStudio) {
559
- throw new Error(`getContractSchemaForCode is only available on Studio networks (current chain: ${client.chain.name})`);
571
+ if (client.chain.isStudio) {
572
+ const schema2 = await client.request({
573
+ method: "gen_getContractSchemaForCode",
574
+ params: [toHex3(contractCode)]
575
+ });
576
+ return schema2;
560
577
  }
578
+ const bytes = typeof contractCode === "string" ? new TextEncoder().encode(contractCode) : contractCode;
579
+ const codeB64 = arrayToB64(bytes);
561
580
  const schema = await client.request({
562
- method: "gen_getContractSchemaForCode",
563
- params: [toHex3(contractCode)]
581
+ method: "gen_getContractSchema",
582
+ params: [{ code: codeB64 }]
564
583
  });
565
584
  return schema;
566
585
  },
@@ -1911,24 +1930,32 @@ var stakingActions = (client, publicClient) => {
1911
1930
  amountRaw: amount
1912
1931
  };
1913
1932
  },
1914
- /** Adds additional self-stake to an active validator position. */
1933
+ /**
1934
+ * Adds additional self-stake to an active validator position. The
1935
+ * underlying Staking contract requires msg.sender == ValidatorWallet,
1936
+ * so the call is routed through the wallet's own validatorDeposit
1937
+ * forwarder (which re-enters Staking with the correct sender).
1938
+ */
1915
1939
  validatorDeposit: async (options) => {
1916
1940
  const amount = parseStakingAmount(options.amount);
1917
1941
  const data = encodeFunctionData2({
1918
- abi: STAKING_ABI,
1942
+ abi: VALIDATOR_WALLET_ABI,
1919
1943
  functionName: "validatorDeposit"
1920
1944
  });
1921
- return executeWrite({ to: getStakingAddress(), data, value: amount });
1945
+ return executeWrite({ to: options.validator, data, value: amount });
1922
1946
  },
1923
- /** Exits a validator position by burning the specified shares. */
1947
+ /**
1948
+ * Exits a validator position by burning the specified shares. Same
1949
+ * msg.sender constraint as validatorDeposit — routed via the wallet.
1950
+ */
1924
1951
  validatorExit: async (options) => {
1925
1952
  const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
1926
1953
  const data = encodeFunctionData2({
1927
- abi: STAKING_ABI,
1954
+ abi: VALIDATOR_WALLET_ABI,
1928
1955
  functionName: "validatorExit",
1929
1956
  args: [shares]
1930
1957
  });
1931
- return executeWrite({ to: getStakingAddress(), data });
1958
+ return executeWrite({ to: options.validator, data });
1932
1959
  },
1933
1960
  /** Claims pending validator withdrawals. */
1934
1961
  validatorClaim: async (options) => {
@@ -1,3 +1,3 @@
1
1
  export { Account, Address } from 'viem';
2
- export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-D3H572Cz.cjs';
2
+ export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-Cf770kyK.cjs';
3
3
  export { G as GenLayerChain } from '../chains-D6DgvIVA.cjs';
@@ -1,3 +1,3 @@
1
1
  export { Account, Address } from 'viem';
2
- export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-BpBLcwxn.js';
2
+ export { O 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, z as DebugTraceResult, a as DecodedCallData, D as DecodedDeployData, a7 as DelegatorClaimOptions, a6 as DelegatorExitOptions, a5 as DelegatorJoinOptions, Z as DelegatorJoinResult, R as EpochData, U as EpochInfo, E as ExecutionResult, 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, K as PendingWithdrawal, a4 as SetIdentityOptions, a3 as SetOperatorOptions, A as SnapSource, Q as StakeInfo, a8 as StakingActions, B as StakingContract, X as StakingTransactionResult, k as TransactionHash, y as TransactionHashVariant, m as TransactionResult, r as TransactionResultNameToNumber, l as TransactionStatus, x as TransactionType, a1 as ValidatorClaimOptions, $ as ValidatorDepositOptions, a0 as ValidatorExitOptions, I as ValidatorIdentity, J as ValidatorInfo, _ as ValidatorJoinOptions, Y as ValidatorJoinResult, a2 as ValidatorPrimeOptions, F as ValidatorView, u as VoteType, W as WithdrawalCommit, s as executionResultNumberToName, p as isDecidedState, q as transactionResultNumberToName, n as transactionsStatusNameToNumber, t as transactionsStatusNumberToName, w as voteTypeNameToNumber, v as voteTypeNumberToName } from '../index-C3Ul1Rte.js';
3
3
  export { G as GenLayerChain } from '../chains-D6DgvIVA.js';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "genlayer-js",
3
3
  "type": "module",
4
- "version": "0.28.7",
4
+ "version": "1.1.0",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",