genlayer-js 0.20.2 → 0.20.3

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.
@@ -2830,6 +2830,7 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
2830
2830
  getContractSchema: (address: Address) => Promise<ContractSchema>;
2831
2831
  getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
2832
2832
  getContractCode: (address: Address) => Promise<string>;
2833
+ /** @deprecated This method is deprecated. The consensus contract is now resolved from the static chain definition. */
2833
2834
  initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
2834
2835
  connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
2835
2836
  metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
@@ -2830,6 +2830,7 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
2830
2830
  getContractSchema: (address: Address) => Promise<ContractSchema>;
2831
2831
  getContractSchemaForCode: (contractCode: string | Uint8Array) => Promise<ContractSchema>;
2832
2832
  getContractCode: (address: Address) => Promise<string>;
2833
+ /** @deprecated This method is deprecated. The consensus contract is now resolved from the static chain definition. */
2833
2834
  initializeConsensusSmartContract: (forceReset?: boolean) => Promise<void>;
2834
2835
  connect: (network?: Network, snapSource?: SnapSource) => Promise<void>;
2835
2836
  metamaskClient: (snapSource?: SnapSource) => Promise<MetaMaskClientResult>;
package/dist/index.cjs CHANGED
@@ -624,7 +624,6 @@ var contractActions = (client, publicClient) => {
624
624
  leaderOnly = false,
625
625
  consensusMaxRotations = client.chain.defaultConsensusMaxRotations
626
626
  } = args;
627
- await client.initializeConsensusSmartContract();
628
627
  const data = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
629
628
  const serializedData = serialize(data);
630
629
  const senderAccount = account || client.account;
@@ -653,7 +652,6 @@ var contractActions = (client, publicClient) => {
653
652
  leaderOnly = false,
654
653
  consensusMaxRotations = client.chain.defaultConsensusMaxRotations
655
654
  } = args;
656
- await client.initializeConsensusSmartContract();
657
655
  const data = [
658
656
  code,
659
657
  encode(makeCalldataObject(void 0, constructorArgs, kwargs)),
@@ -1934,46 +1932,16 @@ var stakingActions = (client, publicClient) => {
1934
1932
  };
1935
1933
 
1936
1934
  // src/chains/actions.ts
1937
- function chainActions(client) {
1935
+ function chainActions(_client) {
1938
1936
  return {
1939
- initializeConsensusSmartContract: async (forceReset = false) => {
1940
- if (_optionalChain([client, 'access', _66 => _66.chain, 'optionalAccess', _67 => _67.id]) === _chunk5TKVNHAOcjs.testnetAsimov.id) {
1941
- return;
1942
- }
1943
- const hasStaticConsensusContract = !!_optionalChain([client, 'access', _68 => _68.chain, 'access', _69 => _69.consensusMainContract, 'optionalAccess', _70 => _70.address]) && !!_optionalChain([client, 'access', _71 => _71.chain, 'access', _72 => _72.consensusMainContract, 'optionalAccess', _73 => _73.abi]);
1944
- const isLocalOrStudioChain = _optionalChain([client, 'access', _74 => _74.chain, 'optionalAccess', _75 => _75.id]) === _chunk5TKVNHAOcjs.localnet.id || _optionalChain([client, 'access', _76 => _76.chain, 'optionalAccess', _77 => _77.id]) === _chunk5TKVNHAOcjs.studionet.id;
1945
- if (!forceReset && hasStaticConsensusContract && !isLocalOrStudioChain) {
1946
- return;
1947
- }
1948
- try {
1949
- const contractsResponse = await fetch(client.chain.rpcUrls.default.http[0], {
1950
- method: "POST",
1951
- headers: {
1952
- "Content-Type": "application/json"
1953
- },
1954
- body: JSON.stringify({
1955
- jsonrpc: "2.0",
1956
- id: Date.now(),
1957
- method: "sim_getConsensusContract",
1958
- params: ["ConsensusMain"]
1959
- })
1960
- });
1961
- if (!contractsResponse.ok) {
1962
- throw new Error("Failed to fetch ConsensusMain contract");
1963
- }
1964
- const consensusMainContract = await contractsResponse.json();
1965
- if (_optionalChain([consensusMainContract, 'optionalAccess', _78 => _78.error]) || !_optionalChain([consensusMainContract, 'optionalAccess', _79 => _79.result, 'optionalAccess', _80 => _80.address]) || !_optionalChain([consensusMainContract, 'optionalAccess', _81 => _81.result, 'optionalAccess', _82 => _82.abi])) {
1966
- throw new Error("ConsensusMain response did not include a valid contract");
1967
- }
1968
- client.chain.consensusMainContract = consensusMainContract.result;
1969
- client.chain.__consensusAbiFetchedFromRpc = true;
1970
- } catch (error) {
1971
- if (hasStaticConsensusContract) {
1972
- client.chain.__consensusAbiFetchedFromRpc = false;
1973
- return;
1974
- }
1975
- throw error;
1976
- }
1937
+ /**
1938
+ * @deprecated This method is deprecated and will be removed in a future release.
1939
+ * The consensus contract is now resolved from the static chain definition.
1940
+ */
1941
+ initializeConsensusSmartContract: async (_forceReset = false) => {
1942
+ console.warn(
1943
+ "[genlayer-js] initializeConsensusSmartContract() is deprecated and will be removed in a future release. The consensus contract is now resolved from the static chain definition."
1944
+ );
1977
1945
  }
1978
1946
  };
1979
1947
  }
@@ -2054,9 +2022,6 @@ var createClient = (config = { chain: _chunk5TKVNHAOcjs.localnet }) => {
2054
2022
  ...clientWithReceiptActions,
2055
2023
  ...stakingActions(clientWithReceiptActions, publicClient)
2056
2024
  };
2057
- finalClient.initializeConsensusSmartContract().catch((error) => {
2058
- console.error("Failed to initialize consensus smart contract:", error);
2059
- });
2060
2025
  return finalClient;
2061
2026
  };
2062
2027
  var createPublicClient = (chainConfig, customTransport) => {
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-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-TroH9NJL.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';
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-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-DmoVRP1E.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';
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
@@ -624,7 +624,6 @@ var contractActions = (client, publicClient) => {
624
624
  leaderOnly = false,
625
625
  consensusMaxRotations = client.chain.defaultConsensusMaxRotations
626
626
  } = args;
627
- await client.initializeConsensusSmartContract();
628
627
  const data = [encode(makeCalldataObject(functionName, callArgs, kwargs)), leaderOnly];
629
628
  const serializedData = serialize(data);
630
629
  const senderAccount = account || client.account;
@@ -653,7 +652,6 @@ var contractActions = (client, publicClient) => {
653
652
  leaderOnly = false,
654
653
  consensusMaxRotations = client.chain.defaultConsensusMaxRotations
655
654
  } = args;
656
- await client.initializeConsensusSmartContract();
657
655
  const data = [
658
656
  code,
659
657
  encode(makeCalldataObject(void 0, constructorArgs, kwargs)),
@@ -1934,46 +1932,16 @@ var stakingActions = (client, publicClient) => {
1934
1932
  };
1935
1933
 
1936
1934
  // src/chains/actions.ts
1937
- function chainActions(client) {
1935
+ function chainActions(_client) {
1938
1936
  return {
1939
- initializeConsensusSmartContract: async (forceReset = false) => {
1940
- if (client.chain?.id === testnetAsimov.id) {
1941
- return;
1942
- }
1943
- const hasStaticConsensusContract = !!client.chain.consensusMainContract?.address && !!client.chain.consensusMainContract?.abi;
1944
- const isLocalOrStudioChain = client.chain?.id === localnet.id || client.chain?.id === studionet.id;
1945
- if (!forceReset && hasStaticConsensusContract && !isLocalOrStudioChain) {
1946
- return;
1947
- }
1948
- try {
1949
- const contractsResponse = await fetch(client.chain.rpcUrls.default.http[0], {
1950
- method: "POST",
1951
- headers: {
1952
- "Content-Type": "application/json"
1953
- },
1954
- body: JSON.stringify({
1955
- jsonrpc: "2.0",
1956
- id: Date.now(),
1957
- method: "sim_getConsensusContract",
1958
- params: ["ConsensusMain"]
1959
- })
1960
- });
1961
- if (!contractsResponse.ok) {
1962
- throw new Error("Failed to fetch ConsensusMain contract");
1963
- }
1964
- const consensusMainContract = await contractsResponse.json();
1965
- if (consensusMainContract?.error || !consensusMainContract?.result?.address || !consensusMainContract?.result?.abi) {
1966
- throw new Error("ConsensusMain response did not include a valid contract");
1967
- }
1968
- client.chain.consensusMainContract = consensusMainContract.result;
1969
- client.chain.__consensusAbiFetchedFromRpc = true;
1970
- } catch (error) {
1971
- if (hasStaticConsensusContract) {
1972
- client.chain.__consensusAbiFetchedFromRpc = false;
1973
- return;
1974
- }
1975
- throw error;
1976
- }
1937
+ /**
1938
+ * @deprecated This method is deprecated and will be removed in a future release.
1939
+ * The consensus contract is now resolved from the static chain definition.
1940
+ */
1941
+ initializeConsensusSmartContract: async (_forceReset = false) => {
1942
+ console.warn(
1943
+ "[genlayer-js] initializeConsensusSmartContract() is deprecated and will be removed in a future release. The consensus contract is now resolved from the static chain definition."
1944
+ );
1977
1945
  }
1978
1946
  };
1979
1947
  }
@@ -2054,9 +2022,6 @@ var createClient = (config = { chain: localnet }) => {
2054
2022
  ...clientWithReceiptActions,
2055
2023
  ...stakingActions(clientWithReceiptActions, publicClient)
2056
2024
  };
2057
- finalClient.initializeConsensusSmartContract().catch((error) => {
2058
- console.error("Failed to initialize consensus smart contract:", error);
2059
- });
2060
2025
  return finalClient;
2061
2026
  };
2062
2027
  var createPublicClient = (chainConfig, customTransport) => {
@@ -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-TroH9NJL.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-C3rDLBIN.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-DmoVRP1E.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-B6107TBT.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.2",
4
+ "version": "0.20.3",
5
5
  "description": "GenLayer JavaScript SDK",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -46,6 +46,7 @@
46
46
  "@types/node": "^22.5.5",
47
47
  "@typescript-eslint/eslint-plugin": "^8.5.0",
48
48
  "@typescript-eslint/parser": "^8.5.0",
49
+ "@vitest/coverage-v8": "^2.1.1",
49
50
  "cross-env": "^7.0.3",
50
51
  "eslint": "^8.57.0",
51
52
  "eslint-config-prettier": "^9.1.0",