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.
- package/dist/{index-DmoVRP1E.d.ts → index-B6107TBT.d.ts} +1 -0
- package/dist/{index-TroH9NJL.d.cts → index-C3rDLBIN.d.cts} +1 -0
- package/dist/index.cjs +9 -44
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -44
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -1
|
@@ -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(
|
|
1935
|
+
function chainActions(_client) {
|
|
1938
1936
|
return {
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
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-
|
|
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-
|
|
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(
|
|
1935
|
+
function chainActions(_client) {
|
|
1938
1936
|
return {
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
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) => {
|
package/dist/types/index.d.cts
CHANGED
|
@@ -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-
|
|
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';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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-
|
|
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.
|
|
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",
|