genlayer-js 0.28.4 → 0.28.6
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/chains/index.cjs +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chunk-PZEHAYIU.cjs → chunk-N74TARFY.cjs} +2282 -2954
- package/dist/{chunk-SGAVFNGA.js → chunk-XCQTIUTU.js} +2282 -2954
- package/dist/{index-DDgbU3hK.d.ts → index-BpBLcwxn.d.ts} +8 -0
- package/dist/{index-DQCfqVjw.d.cts → index-D3H572Cz.d.cts} +8 -0
- package/dist/index.cjs +177 -122
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +108 -53
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
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-
|
|
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';
|
|
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-
|
|
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';
|
|
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
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
studionet,
|
|
7
7
|
testnetAsimov,
|
|
8
8
|
testnetBradbury
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-XCQTIUTU.js";
|
|
10
10
|
import {
|
|
11
11
|
CalldataAddress,
|
|
12
12
|
executionResultNumberToName,
|
|
@@ -792,60 +792,52 @@ var contractActions = (client, publicClient) => {
|
|
|
792
792
|
}
|
|
793
793
|
const senderAccount = account || client.account;
|
|
794
794
|
const encodedData = _encodeSubmitAppealData({ client, txId });
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
let estimatedGas;
|
|
801
|
-
try {
|
|
802
|
-
estimatedGas = await client.estimateTransactionGas({
|
|
803
|
-
to: client.chain.consensusMainContract.address,
|
|
804
|
-
data: encodedData,
|
|
805
|
-
value
|
|
806
|
-
});
|
|
807
|
-
} catch (err) {
|
|
808
|
-
console.error("Gas estimation failed, using default 200_000:", err);
|
|
809
|
-
estimatedGas = 200000n;
|
|
810
|
-
}
|
|
811
|
-
const gasPriceHex = await client.request({ method: "eth_gasPrice" });
|
|
812
|
-
const txRequest = {
|
|
813
|
-
account: validatedAccount,
|
|
814
|
-
to: client.chain.consensusMainContract.address,
|
|
815
|
-
data: encodedData,
|
|
795
|
+
await _sendConsensusCall({
|
|
796
|
+
client,
|
|
797
|
+
publicClient,
|
|
798
|
+
encodedData,
|
|
799
|
+
senderAccount,
|
|
816
800
|
value,
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
nonce,
|
|
820
|
-
chainId: client.chain.id
|
|
821
|
-
};
|
|
822
|
-
if (validatedAccount.type === "local") {
|
|
823
|
-
if (!validatedAccount.signTransaction) {
|
|
824
|
-
throw new Error("Local account does not support signTransaction.");
|
|
825
|
-
}
|
|
826
|
-
const serializedTransaction = await validatedAccount.signTransaction(txRequest);
|
|
827
|
-
const evmHash = await client.sendRawTransaction({ serializedTransaction });
|
|
828
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
|
|
829
|
-
if (receipt.status === "reverted") {
|
|
830
|
-
throw new Error(`Appeal reverted: EVM tx ${evmHash}`);
|
|
831
|
-
}
|
|
832
|
-
} else {
|
|
833
|
-
const evmHash = await client.request({
|
|
834
|
-
method: "eth_sendTransaction",
|
|
835
|
-
params: [{
|
|
836
|
-
from: validatedAccount.address,
|
|
837
|
-
to: client.chain.consensusMainContract.address,
|
|
838
|
-
data: encodedData,
|
|
839
|
-
value: value ? `0x${value.toString(16)}` : void 0,
|
|
840
|
-
gas: `0x${estimatedGas.toString(16)}`
|
|
841
|
-
}]
|
|
842
|
-
});
|
|
843
|
-
const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
|
|
844
|
-
if (receipt.status === "reverted") {
|
|
845
|
-
throw new Error(`Appeal reverted: EVM tx ${evmHash}`);
|
|
846
|
-
}
|
|
847
|
-
}
|
|
801
|
+
operationName: "Appeal"
|
|
802
|
+
});
|
|
848
803
|
return txId;
|
|
804
|
+
},
|
|
805
|
+
/** Finalizes a single GenLayer transaction that is ready to be finalized. Returns the EVM transaction hash. */
|
|
806
|
+
finalizeTransaction: async (args) => {
|
|
807
|
+
const { account, txId } = args;
|
|
808
|
+
const senderAccount = account || client.account;
|
|
809
|
+
const encodedData = encodeFunctionData({
|
|
810
|
+
abi: client.chain.consensusMainContract?.abi,
|
|
811
|
+
functionName: "finalizeTransaction",
|
|
812
|
+
args: [txId]
|
|
813
|
+
});
|
|
814
|
+
return _sendConsensusCall({
|
|
815
|
+
client,
|
|
816
|
+
publicClient,
|
|
817
|
+
encodedData,
|
|
818
|
+
senderAccount,
|
|
819
|
+
operationName: "Finalize"
|
|
820
|
+
});
|
|
821
|
+
},
|
|
822
|
+
/** Batch-finalizes idle GenLayer transactions (those stuck without progressing). Returns the EVM transaction hash. */
|
|
823
|
+
finalizeIdlenessTxs: async (args) => {
|
|
824
|
+
const { account, txIds } = args;
|
|
825
|
+
if (txIds.length === 0) {
|
|
826
|
+
throw new Error("finalizeIdlenessTxs requires at least one txId.");
|
|
827
|
+
}
|
|
828
|
+
const senderAccount = account || client.account;
|
|
829
|
+
const encodedData = encodeFunctionData({
|
|
830
|
+
abi: client.chain.consensusMainContract?.abi,
|
|
831
|
+
functionName: "finalizeIdlenessTxs",
|
|
832
|
+
args: [txIds]
|
|
833
|
+
});
|
|
834
|
+
return _sendConsensusCall({
|
|
835
|
+
client,
|
|
836
|
+
publicClient,
|
|
837
|
+
encodedData,
|
|
838
|
+
senderAccount,
|
|
839
|
+
operationName: "Finalize idleness"
|
|
840
|
+
});
|
|
849
841
|
}
|
|
850
842
|
};
|
|
851
843
|
};
|
|
@@ -958,6 +950,69 @@ var _encodeSubmitAppealData = ({
|
|
|
958
950
|
args: [txId]
|
|
959
951
|
});
|
|
960
952
|
};
|
|
953
|
+
var _sendConsensusCall = async ({
|
|
954
|
+
client,
|
|
955
|
+
publicClient,
|
|
956
|
+
encodedData,
|
|
957
|
+
senderAccount,
|
|
958
|
+
value = 0n,
|
|
959
|
+
operationName = "Consensus call"
|
|
960
|
+
}) => {
|
|
961
|
+
if (!client.chain.consensusMainContract?.address) {
|
|
962
|
+
throw new Error("Consensus main contract not initialized.");
|
|
963
|
+
}
|
|
964
|
+
const validatedAccount = validateAccount(senderAccount);
|
|
965
|
+
const nonce = await client.getCurrentNonce({ address: validatedAccount.address });
|
|
966
|
+
let estimatedGas;
|
|
967
|
+
try {
|
|
968
|
+
estimatedGas = await client.estimateTransactionGas({
|
|
969
|
+
to: client.chain.consensusMainContract.address,
|
|
970
|
+
data: encodedData,
|
|
971
|
+
value
|
|
972
|
+
});
|
|
973
|
+
} catch (err) {
|
|
974
|
+
console.error("Gas estimation failed, using default 200_000:", err);
|
|
975
|
+
estimatedGas = 200000n;
|
|
976
|
+
}
|
|
977
|
+
const gasPriceHex = await client.request({ method: "eth_gasPrice" });
|
|
978
|
+
if (validatedAccount.type === "local") {
|
|
979
|
+
if (!validatedAccount.signTransaction) {
|
|
980
|
+
throw new Error("Local account does not support signTransaction.");
|
|
981
|
+
}
|
|
982
|
+
const txRequest = {
|
|
983
|
+
account: validatedAccount,
|
|
984
|
+
to: client.chain.consensusMainContract.address,
|
|
985
|
+
data: encodedData,
|
|
986
|
+
value,
|
|
987
|
+
gas: estimatedGas,
|
|
988
|
+
gasPrice: BigInt(gasPriceHex),
|
|
989
|
+
nonce,
|
|
990
|
+
chainId: client.chain.id
|
|
991
|
+
};
|
|
992
|
+
const serializedTransaction = await validatedAccount.signTransaction(txRequest);
|
|
993
|
+
const evmHash2 = await client.sendRawTransaction({ serializedTransaction });
|
|
994
|
+
const receipt2 = await publicClient.waitForTransactionReceipt({ hash: evmHash2 });
|
|
995
|
+
if (receipt2.status === "reverted") {
|
|
996
|
+
throw new Error(`${operationName} reverted: EVM tx ${evmHash2}`);
|
|
997
|
+
}
|
|
998
|
+
return evmHash2;
|
|
999
|
+
}
|
|
1000
|
+
const evmHash = await client.request({
|
|
1001
|
+
method: "eth_sendTransaction",
|
|
1002
|
+
params: [{
|
|
1003
|
+
from: validatedAccount.address,
|
|
1004
|
+
to: client.chain.consensusMainContract.address,
|
|
1005
|
+
data: encodedData,
|
|
1006
|
+
value: value ? `0x${value.toString(16)}` : void 0,
|
|
1007
|
+
gas: `0x${estimatedGas.toString(16)}`
|
|
1008
|
+
}]
|
|
1009
|
+
});
|
|
1010
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
|
|
1011
|
+
if (receipt.status === "reverted") {
|
|
1012
|
+
throw new Error(`${operationName} reverted: EVM tx ${evmHash}`);
|
|
1013
|
+
}
|
|
1014
|
+
return evmHash;
|
|
1015
|
+
};
|
|
961
1016
|
var isAddTransactionAbiMismatchError = (error) => {
|
|
962
1017
|
const seen = /* @__PURE__ */ new WeakSet();
|
|
963
1018
|
const serializedError = typeof error === "object" && error !== null ? JSON.stringify(error, (_key, value) => {
|
package/dist/types/index.d.cts
CHANGED
|
@@ -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-
|
|
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';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-D6DgvIVA.cjs';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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-
|
|
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';
|
|
3
3
|
export { G as GenLayerChain } from '../chains-D6DgvIVA.js';
|