genlayer-js 0.27.8 → 0.28.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/dist/chains/index.cjs +2 -2
- package/dist/chains/index.d.cts +2 -2
- package/dist/chains/index.d.ts +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chains-DqSbucSW.d.cts → chains-D6DgvIVA.d.cts} +4 -0
- package/dist/{chains-DqSbucSW.d.ts → chains-D6DgvIVA.d.ts} +4 -0
- package/dist/{chunk-NOMVZBCR.cjs → chunk-PZEHAYIU.cjs} +68 -0
- package/dist/{chunk-C4Z24PT6.js → chunk-SGAVFNGA.js} +68 -0
- package/dist/{index-BZj9d30J.d.ts → index-BCPb0x30.d.ts} +1 -1
- package/dist/{index-9P6HoP_s.d.cts → index-DDgbU3hK.d.ts} +17 -1
- package/dist/{index-Bf1V-aai.d.ts → index-DQCfqVjw.d.cts} +17 -1
- package/dist/{index-BvRcfXce.d.cts → index-_c6eHw3s.d.cts} +1 -1
- package/dist/index.cjs +250 -102
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +181 -33
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkPZEHAYIUcjs = require('./chunk-PZEHAYIU.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
@@ -33,7 +33,7 @@ var _viem = require('viem');
|
|
|
33
33
|
function accountActions(client) {
|
|
34
34
|
return {
|
|
35
35
|
fundAccount: async ({ address, amount }) => {
|
|
36
|
-
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !==
|
|
36
|
+
if (_optionalChain([client, 'access', _ => _.chain, 'optionalAccess', _2 => _2.id]) !== _chunkPZEHAYIUcjs.localnet.id) {
|
|
37
37
|
throw new Error("Client is not connected to the localnet");
|
|
38
38
|
}
|
|
39
39
|
return client.request({
|
|
@@ -417,8 +417,8 @@ function serialize(data) {
|
|
|
417
417
|
// src/abi/index.ts
|
|
418
418
|
var abi_exports = {};
|
|
419
419
|
_chunk75ZPJI57cjs.__export.call(void 0, abi_exports, {
|
|
420
|
-
STAKING_ABI: () =>
|
|
421
|
-
VALIDATOR_WALLET_ABI: () =>
|
|
420
|
+
STAKING_ABI: () => _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
421
|
+
VALIDATOR_WALLET_ABI: () => _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
|
|
422
422
|
calldata: () => calldata,
|
|
423
423
|
transactions: () => transactions
|
|
424
424
|
});
|
|
@@ -532,8 +532,8 @@ var contractActions = (client, publicClient) => {
|
|
|
532
532
|
return {
|
|
533
533
|
/** Retrieves the source code of a deployed contract. Localnet only. */
|
|
534
534
|
getContractCode: async (address) => {
|
|
535
|
-
if (client.chain.id !==
|
|
536
|
-
throw new Error(
|
|
535
|
+
if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
|
|
536
|
+
throw new Error(`getContractCode is only available on localnet (current chain: ${client.chain.name})`);
|
|
537
537
|
}
|
|
538
538
|
const result = await client.request({
|
|
539
539
|
method: "gen_getContractCode",
|
|
@@ -544,8 +544,8 @@ var contractActions = (client, publicClient) => {
|
|
|
544
544
|
},
|
|
545
545
|
/** Gets the schema (methods and constructor) of a deployed contract. Localnet only. */
|
|
546
546
|
getContractSchema: async (address) => {
|
|
547
|
-
if (client.chain.id !==
|
|
548
|
-
throw new Error(
|
|
547
|
+
if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
|
|
548
|
+
throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
|
|
549
549
|
}
|
|
550
550
|
const schema = await client.request({
|
|
551
551
|
method: "gen_getContractSchema",
|
|
@@ -555,8 +555,8 @@ var contractActions = (client, publicClient) => {
|
|
|
555
555
|
},
|
|
556
556
|
/** Generates a schema for contract code without deploying it. Localnet only. */
|
|
557
557
|
getContractSchemaForCode: async (contractCode) => {
|
|
558
|
-
if (client.chain.id !==
|
|
559
|
-
throw new Error(
|
|
558
|
+
if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
|
|
559
|
+
throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
|
|
560
560
|
}
|
|
561
561
|
const schema = await client.request({
|
|
562
562
|
method: "gen_getContractSchemaForCode",
|
|
@@ -718,12 +718,60 @@ var contractActions = (client, publicClient) => {
|
|
|
718
718
|
});
|
|
719
719
|
return minBond;
|
|
720
720
|
},
|
|
721
|
+
/** Returns the current consensus round number for a transaction. */
|
|
722
|
+
getRoundNumber: async (args) => {
|
|
723
|
+
if (!_optionalChain([client, 'access', _17 => _17.chain, 'access', _18 => _18.roundsStorageContract, 'optionalAccess', _19 => _19.address])) {
|
|
724
|
+
throw new Error("getRoundNumber not supported on this chain (missing roundsStorageContract)");
|
|
725
|
+
}
|
|
726
|
+
return publicClient.readContract({
|
|
727
|
+
address: client.chain.roundsStorageContract.address,
|
|
728
|
+
abi: client.chain.roundsStorageContract.abi,
|
|
729
|
+
functionName: "getRoundNumber",
|
|
730
|
+
args: [args.txId]
|
|
731
|
+
});
|
|
732
|
+
},
|
|
733
|
+
/** Returns detailed data for a specific consensus round. */
|
|
734
|
+
getRoundData: async (args) => {
|
|
735
|
+
if (!_optionalChain([client, 'access', _20 => _20.chain, 'access', _21 => _21.roundsStorageContract, 'optionalAccess', _22 => _22.address])) {
|
|
736
|
+
throw new Error("getRoundData not supported on this chain (missing roundsStorageContract)");
|
|
737
|
+
}
|
|
738
|
+
return publicClient.readContract({
|
|
739
|
+
address: client.chain.roundsStorageContract.address,
|
|
740
|
+
abi: client.chain.roundsStorageContract.abi,
|
|
741
|
+
functionName: "getRoundData",
|
|
742
|
+
args: [args.txId, args.round]
|
|
743
|
+
});
|
|
744
|
+
},
|
|
745
|
+
/** Returns the current round number and its data for a transaction. */
|
|
746
|
+
getLastRoundData: async (args) => {
|
|
747
|
+
if (!_optionalChain([client, 'access', _23 => _23.chain, 'access', _24 => _24.roundsStorageContract, 'optionalAccess', _25 => _25.address])) {
|
|
748
|
+
throw new Error("getLastRoundData not supported on this chain (missing roundsStorageContract)");
|
|
749
|
+
}
|
|
750
|
+
return publicClient.readContract({
|
|
751
|
+
address: client.chain.roundsStorageContract.address,
|
|
752
|
+
abi: client.chain.roundsStorageContract.abi,
|
|
753
|
+
functionName: "getLastRoundData",
|
|
754
|
+
args: [args.txId]
|
|
755
|
+
});
|
|
756
|
+
},
|
|
757
|
+
/** Checks if a transaction can be appealed. */
|
|
758
|
+
canAppeal: async (args) => {
|
|
759
|
+
if (!_optionalChain([client, 'access', _26 => _26.chain, 'access', _27 => _27.appealsContract, 'optionalAccess', _28 => _28.address])) {
|
|
760
|
+
throw new Error("canAppeal not supported on this chain (missing appealsContract)");
|
|
761
|
+
}
|
|
762
|
+
return publicClient.readContract({
|
|
763
|
+
address: client.chain.appealsContract.address,
|
|
764
|
+
abi: client.chain.appealsContract.abi,
|
|
765
|
+
functionName: "canAppeal",
|
|
766
|
+
args: [args.txId]
|
|
767
|
+
});
|
|
768
|
+
},
|
|
721
769
|
/** Appeals a consensus transaction to trigger a new round of validation. */
|
|
722
770
|
appealTransaction: async (args) => {
|
|
723
771
|
const { account, txId } = args;
|
|
724
772
|
let { value } = args;
|
|
725
773
|
if (value === void 0) {
|
|
726
|
-
if (_optionalChain([client, 'access',
|
|
774
|
+
if (_optionalChain([client, 'access', _29 => _29.chain, 'access', _30 => _30.feeManagerContract, 'optionalAccess', _31 => _31.address]) && _optionalChain([client, 'access', _32 => _32.chain, 'access', _33 => _33.roundsStorageContract, 'optionalAccess', _34 => _34.address])) {
|
|
727
775
|
const roundNumber = await publicClient.readContract({
|
|
728
776
|
address: client.chain.roundsStorageContract.address,
|
|
729
777
|
abi: client.chain.roundsStorageContract.abi,
|
|
@@ -744,13 +792,61 @@ var contractActions = (client, publicClient) => {
|
|
|
744
792
|
}
|
|
745
793
|
const senderAccount = account || client.account;
|
|
746
794
|
const encodedData = _encodeSubmitAppealData({ client, txId });
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
795
|
+
const validatedAccount = validateAccount(senderAccount);
|
|
796
|
+
if (!_optionalChain([client, 'access', _35 => _35.chain, 'access', _36 => _36.consensusMainContract, 'optionalAccess', _37 => _37.address])) {
|
|
797
|
+
throw new Error("Consensus main contract not initialized.");
|
|
798
|
+
}
|
|
799
|
+
const nonce = await client.getCurrentNonce({ address: validatedAccount.address });
|
|
800
|
+
let estimatedGas;
|
|
801
|
+
try {
|
|
802
|
+
estimatedGas = await client.estimateTransactionGas({
|
|
803
|
+
to: client.chain.consensusMainContract.address,
|
|
804
|
+
data: encodedData,
|
|
805
|
+
value,
|
|
806
|
+
nonce
|
|
807
|
+
});
|
|
808
|
+
} catch (err) {
|
|
809
|
+
console.error("Gas estimation failed, using default 200_000:", err);
|
|
810
|
+
estimatedGas = 200000n;
|
|
811
|
+
}
|
|
812
|
+
const gasPriceHex = await client.request({ method: "eth_gasPrice" });
|
|
813
|
+
const txRequest = {
|
|
814
|
+
account: validatedAccount,
|
|
815
|
+
to: client.chain.consensusMainContract.address,
|
|
816
|
+
data: encodedData,
|
|
817
|
+
value,
|
|
818
|
+
gas: estimatedGas,
|
|
819
|
+
gasPrice: BigInt(gasPriceHex),
|
|
820
|
+
nonce,
|
|
821
|
+
chainId: client.chain.id
|
|
822
|
+
};
|
|
823
|
+
if (validatedAccount.type === "local") {
|
|
824
|
+
if (!validatedAccount.signTransaction) {
|
|
825
|
+
throw new Error("Local account does not support signTransaction.");
|
|
826
|
+
}
|
|
827
|
+
const serializedTransaction = await validatedAccount.signTransaction(txRequest);
|
|
828
|
+
const evmHash = await client.sendRawTransaction({ serializedTransaction });
|
|
829
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
|
|
830
|
+
if (receipt.status === "reverted") {
|
|
831
|
+
throw new Error(`Appeal reverted: EVM tx ${evmHash}`);
|
|
832
|
+
}
|
|
833
|
+
} else {
|
|
834
|
+
const evmHash = await client.request({
|
|
835
|
+
method: "eth_sendTransaction",
|
|
836
|
+
params: [{
|
|
837
|
+
from: validatedAccount.address,
|
|
838
|
+
to: client.chain.consensusMainContract.address,
|
|
839
|
+
data: encodedData,
|
|
840
|
+
value: value ? `0x${value.toString(16)}` : void 0,
|
|
841
|
+
gas: `0x${estimatedGas.toString(16)}`
|
|
842
|
+
}]
|
|
843
|
+
});
|
|
844
|
+
const receipt = await publicClient.waitForTransactionReceipt({ hash: evmHash });
|
|
845
|
+
if (receipt.status === "reverted") {
|
|
846
|
+
throw new Error(`Appeal reverted: EVM tx ${evmHash}`);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
return txId;
|
|
754
850
|
}
|
|
755
851
|
};
|
|
756
852
|
};
|
|
@@ -762,6 +858,17 @@ var validateAccount = (Account4) => {
|
|
|
762
858
|
}
|
|
763
859
|
return Account4;
|
|
764
860
|
};
|
|
861
|
+
var CREATED_TRANSACTION_EVENT_ABI = [
|
|
862
|
+
{
|
|
863
|
+
anonymous: false,
|
|
864
|
+
inputs: [
|
|
865
|
+
{ indexed: true, internalType: "bytes32", name: "txId", type: "bytes32" },
|
|
866
|
+
{ indexed: false, internalType: "uint256", name: "txSlot", type: "uint256" }
|
|
867
|
+
],
|
|
868
|
+
name: "CreatedTransaction",
|
|
869
|
+
type: "event"
|
|
870
|
+
}
|
|
871
|
+
];
|
|
765
872
|
var ADD_TRANSACTION_ABI_V5 = [
|
|
766
873
|
{
|
|
767
874
|
type: "function",
|
|
@@ -804,7 +911,7 @@ var getAddTransactionInputCount = (abi) => {
|
|
|
804
911
|
const candidate = item;
|
|
805
912
|
return candidate.type === "function" && candidate.name === "addTransaction";
|
|
806
913
|
});
|
|
807
|
-
return Array.isArray(_optionalChain([addTransactionFunction, 'optionalAccess',
|
|
914
|
+
return Array.isArray(_optionalChain([addTransactionFunction, 'optionalAccess', _38 => _38.inputs])) ? addTransactionFunction.inputs.length : 0;
|
|
808
915
|
};
|
|
809
916
|
var _encodeAddTransactionData = ({
|
|
810
917
|
client,
|
|
@@ -831,7 +938,7 @@ var _encodeAddTransactionData = ({
|
|
|
831
938
|
functionName: "addTransaction",
|
|
832
939
|
args: [...addTransactionArgs, 0n]
|
|
833
940
|
});
|
|
834
|
-
if (getAddTransactionInputCount(_optionalChain([client, 'access',
|
|
941
|
+
if (getAddTransactionInputCount(_optionalChain([client, 'access', _39 => _39.chain, 'access', _40 => _40.consensusMainContract, 'optionalAccess', _41 => _41.abi])) >= 6) {
|
|
835
942
|
return {
|
|
836
943
|
primaryEncodedData: encodedDataV6,
|
|
837
944
|
fallbackEncodedData: encodedDataV5
|
|
@@ -847,7 +954,7 @@ var _encodeSubmitAppealData = ({
|
|
|
847
954
|
txId
|
|
848
955
|
}) => {
|
|
849
956
|
return _viem.encodeFunctionData.call(void 0, {
|
|
850
|
-
abi: _optionalChain([client, 'access',
|
|
957
|
+
abi: _optionalChain([client, 'access', _42 => _42.chain, 'access', _43 => _43.consensusMainContract, 'optionalAccess', _44 => _44.abi]),
|
|
851
958
|
functionName: "submitAppeal",
|
|
852
959
|
args: [txId]
|
|
853
960
|
});
|
|
@@ -868,14 +975,33 @@ var isAddTransactionAbiMismatchError = (error) => {
|
|
|
868
975
|
}) : "";
|
|
869
976
|
const errorObject = error;
|
|
870
977
|
const errorMessage = [
|
|
871
|
-
_optionalChain([errorObject, 'optionalAccess',
|
|
872
|
-
_optionalChain([errorObject, 'optionalAccess',
|
|
873
|
-
_optionalChain([errorObject, 'optionalAccess',
|
|
978
|
+
_optionalChain([errorObject, 'optionalAccess', _45 => _45.shortMessage]),
|
|
979
|
+
_optionalChain([errorObject, 'optionalAccess', _46 => _46.details]),
|
|
980
|
+
_optionalChain([errorObject, 'optionalAccess', _47 => _47.message]),
|
|
874
981
|
serializedError,
|
|
875
982
|
String(_nullishCoalesce(error, () => ( "")))
|
|
876
983
|
].filter(Boolean).join(" ").toLowerCase();
|
|
877
984
|
return errorMessage.includes("invalid pointer in tuple") || errorMessage.includes("invalid pointer") || errorMessage.includes("could not decode") || errorMessage.includes("invalid arrayify value") || errorMessage.includes("types/value length mismatch");
|
|
878
985
|
};
|
|
986
|
+
var extractTxIdFromLogs = (client, logs) => {
|
|
987
|
+
const newTxEvents = _viem.parseEventLogs.call(void 0, {
|
|
988
|
+
abi: _optionalChain([client, 'access', _48 => _48.chain, 'access', _49 => _49.consensusMainContract, 'optionalAccess', _50 => _50.abi]),
|
|
989
|
+
eventName: "NewTransaction",
|
|
990
|
+
logs
|
|
991
|
+
});
|
|
992
|
+
if (newTxEvents.length > 0) {
|
|
993
|
+
return newTxEvents[0].args["txId"];
|
|
994
|
+
}
|
|
995
|
+
const createdTxEvents = _viem.parseEventLogs.call(void 0, {
|
|
996
|
+
abi: CREATED_TRANSACTION_EVENT_ABI,
|
|
997
|
+
eventName: "CreatedTransaction",
|
|
998
|
+
logs
|
|
999
|
+
});
|
|
1000
|
+
if (createdTxEvents.length > 0) {
|
|
1001
|
+
return createdTxEvents[0].args["txId"];
|
|
1002
|
+
}
|
|
1003
|
+
return null;
|
|
1004
|
+
};
|
|
879
1005
|
var _sendTransaction = async ({
|
|
880
1006
|
client,
|
|
881
1007
|
publicClient,
|
|
@@ -884,8 +1010,8 @@ var _sendTransaction = async ({
|
|
|
884
1010
|
senderAccount,
|
|
885
1011
|
value = 0n
|
|
886
1012
|
}) => {
|
|
887
|
-
if (!_optionalChain([client, 'access',
|
|
888
|
-
throw new Error(
|
|
1013
|
+
if (!_optionalChain([client, 'access', _51 => _51.chain, 'access', _52 => _52.consensusMainContract, 'optionalAccess', _53 => _53.address])) {
|
|
1014
|
+
throw new Error(`Consensus main contract address not found in chain config for "${client.chain.name}".`);
|
|
889
1015
|
}
|
|
890
1016
|
const validatedSenderAccount = validateAccount(senderAccount);
|
|
891
1017
|
const nonce = await client.getCurrentNonce({ address: validatedSenderAccount.address });
|
|
@@ -894,7 +1020,7 @@ var _sendTransaction = async ({
|
|
|
894
1020
|
try {
|
|
895
1021
|
estimatedGas = await client.estimateTransactionGas({
|
|
896
1022
|
from: validatedSenderAccount.address,
|
|
897
|
-
to: _optionalChain([client, 'access',
|
|
1023
|
+
to: _optionalChain([client, 'access', _54 => _54.chain, 'access', _55 => _55.consensusMainContract, 'optionalAccess', _56 => _56.address]),
|
|
898
1024
|
data: encodedDataForSend,
|
|
899
1025
|
value
|
|
900
1026
|
});
|
|
@@ -902,16 +1028,16 @@ var _sendTransaction = async ({
|
|
|
902
1028
|
console.error("Gas estimation failed, using default 200_000:", err);
|
|
903
1029
|
estimatedGas = 200000n;
|
|
904
1030
|
}
|
|
905
|
-
if (_optionalChain([validatedSenderAccount, 'optionalAccess',
|
|
906
|
-
if (!_optionalChain([validatedSenderAccount, 'optionalAccess',
|
|
907
|
-
throw new Error("
|
|
1031
|
+
if (_optionalChain([validatedSenderAccount, 'optionalAccess', _57 => _57.type]) === "local") {
|
|
1032
|
+
if (!_optionalChain([validatedSenderAccount, 'optionalAccess', _58 => _58.signTransaction])) {
|
|
1033
|
+
throw new Error("Local account does not support signTransaction. Use a private key account created via privateKeyToAccount().");
|
|
908
1034
|
}
|
|
909
1035
|
const gasPriceHex2 = await client.request({
|
|
910
1036
|
method: "eth_gasPrice"
|
|
911
1037
|
});
|
|
912
1038
|
const transactionRequest = {
|
|
913
1039
|
account: validatedSenderAccount,
|
|
914
|
-
to: _optionalChain([client, 'access',
|
|
1040
|
+
to: _optionalChain([client, 'access', _59 => _59.chain, 'access', _60 => _60.consensusMainContract, 'optionalAccess', _61 => _61.address]),
|
|
915
1041
|
data: encodedDataForSend,
|
|
916
1042
|
type: "legacy",
|
|
917
1043
|
nonce: Number(nonce),
|
|
@@ -924,17 +1050,15 @@ var _sendTransaction = async ({
|
|
|
924
1050
|
const txHash = await client.sendRawTransaction({ serializedTransaction });
|
|
925
1051
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
926
1052
|
if (receipt.status === "reverted") {
|
|
927
|
-
throw new Error(
|
|
1053
|
+
throw new Error(`Transaction reverted: EVM tx ${txHash} to consensus contract ${_optionalChain([client, 'access', _62 => _62.chain, 'access', _63 => _63.consensusMainContract, 'optionalAccess', _64 => _64.address])} was reverted.`);
|
|
928
1054
|
}
|
|
929
|
-
const
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
if (newTxEvents.length === 0) {
|
|
935
|
-
throw new Error("Transaction not processed by consensus");
|
|
1055
|
+
const txId = extractTxIdFromLogs(client, receipt.logs);
|
|
1056
|
+
if (!txId) {
|
|
1057
|
+
throw new Error(
|
|
1058
|
+
`Transaction not processed by consensus: EVM tx ${txHash} succeeded but no NewTransaction or CreatedTransaction event was found in the receipt logs.`
|
|
1059
|
+
);
|
|
936
1060
|
}
|
|
937
|
-
return
|
|
1061
|
+
return txId;
|
|
938
1062
|
}
|
|
939
1063
|
let gasPriceHex;
|
|
940
1064
|
try {
|
|
@@ -950,7 +1074,7 @@ var _sendTransaction = async ({
|
|
|
950
1074
|
const nonceBigInt = typeof nonce === "bigint" ? nonce : typeof nonce === "string" ? BigInt(nonce) : BigInt(Number(nonce));
|
|
951
1075
|
const formattedRequest = {
|
|
952
1076
|
from: validatedSenderAccount.address,
|
|
953
|
-
to: _optionalChain([client, 'access',
|
|
1077
|
+
to: _optionalChain([client, 'access', _65 => _65.chain, 'access', _66 => _66.consensusMainContract, 'optionalAccess', _67 => _67.address]),
|
|
954
1078
|
data: encodedDataForSend,
|
|
955
1079
|
value: `0x${value.toString(16)}`,
|
|
956
1080
|
gas: `0x${estimatedGas.toString(16)}`,
|
|
@@ -966,17 +1090,15 @@ var _sendTransaction = async ({
|
|
|
966
1090
|
});
|
|
967
1091
|
const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
|
|
968
1092
|
if (externalReceipt.status === "reverted") {
|
|
969
|
-
throw new Error(
|
|
1093
|
+
throw new Error(`Transaction reverted: EVM tx ${evmTxHash} to consensus contract ${_optionalChain([client, 'access', _68 => _68.chain, 'access', _69 => _69.consensusMainContract, 'optionalAccess', _70 => _70.address])} was reverted.`);
|
|
970
1094
|
}
|
|
971
|
-
const
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
if (externalNewTxEvents.length === 0) {
|
|
977
|
-
throw new Error("Transaction not processed by consensus");
|
|
1095
|
+
const externalTxId = extractTxIdFromLogs(client, externalReceipt.logs);
|
|
1096
|
+
if (!externalTxId) {
|
|
1097
|
+
throw new Error(
|
|
1098
|
+
`Transaction not processed by consensus: EVM tx ${evmTxHash} succeeded but no NewTransaction or CreatedTransaction event was found in the receipt logs.`
|
|
1099
|
+
);
|
|
978
1100
|
}
|
|
979
|
-
return
|
|
1101
|
+
return externalTxId;
|
|
980
1102
|
};
|
|
981
1103
|
try {
|
|
982
1104
|
return await sendWithEncodedData(encodedData);
|
|
@@ -1093,7 +1215,7 @@ var decodeTransaction = (tx) => {
|
|
|
1093
1215
|
txData,
|
|
1094
1216
|
txDataDecoded,
|
|
1095
1217
|
currentTimestamp: tx.currentTimestamp.toString(),
|
|
1096
|
-
numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess',
|
|
1218
|
+
numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess', _71 => _71.toString, 'call', _72 => _72()]), () => ( "0")),
|
|
1097
1219
|
txSlot: tx.txSlot.toString(),
|
|
1098
1220
|
createdTimestamp: tx.createdTimestamp.toString(),
|
|
1099
1221
|
lastVoteTimestamp: tx.lastVoteTimestamp.toString(),
|
|
@@ -1101,9 +1223,9 @@ var decodeTransaction = (tx) => {
|
|
|
1101
1223
|
numOfRounds: tx.numOfRounds.toString(),
|
|
1102
1224
|
readStateBlockRange: {
|
|
1103
1225
|
...tx.readStateBlockRange,
|
|
1104
|
-
activationBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1105
|
-
processingBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1106
|
-
proposalBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1226
|
+
activationBlock: _nullishCoalesce(_optionalChain([tx, 'access', _73 => _73.readStateBlockRange, 'optionalAccess', _74 => _74.activationBlock, 'optionalAccess', _75 => _75.toString, 'call', _76 => _76()]), () => ( "0")),
|
|
1227
|
+
processingBlock: _nullishCoalesce(_optionalChain([tx, 'access', _77 => _77.readStateBlockRange, 'optionalAccess', _78 => _78.processingBlock, 'optionalAccess', _79 => _79.toString, 'call', _80 => _80()]), () => ( "0")),
|
|
1228
|
+
proposalBlock: _nullishCoalesce(_optionalChain([tx, 'access', _81 => _81.readStateBlockRange, 'optionalAccess', _82 => _82.proposalBlock, 'optionalAccess', _83 => _83.toString, 'call', _84 => _84()]), () => ( "0"))
|
|
1107
1229
|
},
|
|
1108
1230
|
statusName: _chunkGJXSECNHcjs.transactionsStatusNumberToName[String(tx.status)],
|
|
1109
1231
|
resultName: _chunkGJXSECNHcjs.transactionResultNumberToName[String(tx.result)],
|
|
@@ -1111,13 +1233,13 @@ var decodeTransaction = (tx) => {
|
|
|
1111
1233
|
txExecutionResultName: tx.txExecutionResult !== void 0 ? _chunkGJXSECNHcjs.executionResultNumberToName[String(tx.txExecutionResult)] : void 0,
|
|
1112
1234
|
lastRound: {
|
|
1113
1235
|
...tx.lastRound,
|
|
1114
|
-
round: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1115
|
-
leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1116
|
-
votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1117
|
-
votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1118
|
-
appealBond: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1119
|
-
rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1120
|
-
validatorVotesName: (_nullishCoalesce(_optionalChain([tx, 'access',
|
|
1236
|
+
round: _nullishCoalesce(_optionalChain([tx, 'access', _85 => _85.lastRound, 'optionalAccess', _86 => _86.round, 'optionalAccess', _87 => _87.toString, 'call', _88 => _88()]), () => ( "0")),
|
|
1237
|
+
leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access', _89 => _89.lastRound, 'optionalAccess', _90 => _90.leaderIndex, 'optionalAccess', _91 => _91.toString, 'call', _92 => _92()]), () => ( "0")),
|
|
1238
|
+
votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access', _93 => _93.lastRound, 'optionalAccess', _94 => _94.votesCommitted, 'optionalAccess', _95 => _95.toString, 'call', _96 => _96()]), () => ( "0")),
|
|
1239
|
+
votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access', _97 => _97.lastRound, 'optionalAccess', _98 => _98.votesRevealed, 'optionalAccess', _99 => _99.toString, 'call', _100 => _100()]), () => ( "0")),
|
|
1240
|
+
appealBond: _nullishCoalesce(_optionalChain([tx, 'access', _101 => _101.lastRound, 'optionalAccess', _102 => _102.appealBond, 'optionalAccess', _103 => _103.toString, 'call', _104 => _104()]), () => ( "0")),
|
|
1241
|
+
rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access', _105 => _105.lastRound, 'optionalAccess', _106 => _106.rotationsLeft, 'optionalAccess', _107 => _107.toString, 'call', _108 => _108()]), () => ( "0")),
|
|
1242
|
+
validatorVotesName: (_nullishCoalesce(_optionalChain([tx, 'access', _109 => _109.lastRound, 'optionalAccess', _110 => _110.validatorVotes]), () => ( []))).map(
|
|
1121
1243
|
(vote) => _chunkGJXSECNHcjs.voteTypeNumberToName[String(vote)]
|
|
1122
1244
|
)
|
|
1123
1245
|
}
|
|
@@ -1199,7 +1321,7 @@ var simplifyTransactionReceipt = (tx) => {
|
|
|
1199
1321
|
var decodeLocalnetTransaction = (tx) => {
|
|
1200
1322
|
if (!tx.data) return tx;
|
|
1201
1323
|
try {
|
|
1202
|
-
const leaderReceipt = _optionalChain([tx, 'access',
|
|
1324
|
+
const leaderReceipt = _optionalChain([tx, 'access', _111 => _111.consensus_data, 'optionalAccess', _112 => _112.leader_receipt]);
|
|
1203
1325
|
if (leaderReceipt) {
|
|
1204
1326
|
const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
|
|
1205
1327
|
receipts.forEach((receipt) => {
|
|
@@ -1230,7 +1352,7 @@ var decodeLocalnetTransaction = (tx) => {
|
|
|
1230
1352
|
}
|
|
1231
1353
|
});
|
|
1232
1354
|
}
|
|
1233
|
-
if (_optionalChain([tx, 'access',
|
|
1355
|
+
if (_optionalChain([tx, 'access', _113 => _113.data, 'optionalAccess', _114 => _114.calldata]) && typeof tx.data.calldata === "string") {
|
|
1234
1356
|
tx.data.calldata = {
|
|
1235
1357
|
base64: tx.data.calldata,
|
|
1236
1358
|
...calldataToUserFriendlyJson(b64ToArray(tx.data.calldata))
|
|
@@ -1256,13 +1378,13 @@ var receiptActions = (client, publicClient) => ({
|
|
|
1256
1378
|
hash
|
|
1257
1379
|
});
|
|
1258
1380
|
if (!transaction) {
|
|
1259
|
-
throw new Error(
|
|
1381
|
+
throw new Error(`Transaction not found: ${hash}`);
|
|
1260
1382
|
}
|
|
1261
1383
|
const transactionStatusString = String(transaction.status);
|
|
1262
1384
|
const requestedStatus = _chunkGJXSECNHcjs.transactionsStatusNameToNumber[status];
|
|
1263
1385
|
if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && _chunkGJXSECNHcjs.isDecidedState.call(void 0, transactionStatusString)) {
|
|
1264
1386
|
let finalTransaction = transaction;
|
|
1265
|
-
if (client.chain.id ===
|
|
1387
|
+
if (client.chain.id === _chunkPZEHAYIUcjs.localnet.id) {
|
|
1266
1388
|
finalTransaction = decodeLocalnetTransaction(transaction);
|
|
1267
1389
|
}
|
|
1268
1390
|
if (!fullTransaction) {
|
|
@@ -1271,7 +1393,7 @@ var receiptActions = (client, publicClient) => ({
|
|
|
1271
1393
|
return finalTransaction;
|
|
1272
1394
|
}
|
|
1273
1395
|
if (retries === 0) {
|
|
1274
|
-
throw new Error(
|
|
1396
|
+
throw new Error(`Timed out waiting for transaction ${hash} to reach status "${status}" (current status: ${transactionStatusString}).`);
|
|
1275
1397
|
}
|
|
1276
1398
|
await sleep(interval);
|
|
1277
1399
|
return receiptActions(client, publicClient).waitForTransactionReceipt({
|
|
@@ -1293,8 +1415,8 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1293
1415
|
transaction2.statusName = localnetStatus;
|
|
1294
1416
|
return decodeLocalnetTransaction(transaction2);
|
|
1295
1417
|
}
|
|
1296
|
-
const contractAddress = _optionalChain([client, 'access',
|
|
1297
|
-
const contractAbi = _optionalChain([client, 'access',
|
|
1418
|
+
const contractAddress = _optionalChain([client, 'access', _115 => _115.chain, 'access', _116 => _116.consensusDataContract, 'optionalAccess', _117 => _117.address]);
|
|
1419
|
+
const contractAbi = _optionalChain([client, 'access', _118 => _118.chain, 'access', _119 => _119.consensusDataContract, 'optionalAccess', _120 => _120.abi]);
|
|
1298
1420
|
const [txDataRaw, allDataRaw] = await Promise.all([
|
|
1299
1421
|
publicClient.readContract({
|
|
1300
1422
|
address: contractAddress,
|
|
@@ -1324,12 +1446,12 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1324
1446
|
return _nullishCoalesce(tx2.triggered_transactions, () => ( []));
|
|
1325
1447
|
}
|
|
1326
1448
|
const tx = await transactionActions(client, publicClient).getTransaction({ hash });
|
|
1327
|
-
const proposalBlock = BigInt(_nullishCoalesce(_optionalChain([tx, 'access',
|
|
1449
|
+
const proposalBlock = BigInt(_nullishCoalesce(_optionalChain([tx, 'access', _121 => _121.readStateBlockRange, 'optionalAccess', _122 => _122.proposalBlock]), () => ( "0")));
|
|
1328
1450
|
if (proposalBlock === BigInt(0)) return [];
|
|
1329
1451
|
const scanRange = BigInt(100);
|
|
1330
1452
|
const latestBlock = await publicClient.getBlockNumber();
|
|
1331
1453
|
const toBlock = proposalBlock + scanRange < latestBlock ? proposalBlock + scanRange : latestBlock;
|
|
1332
|
-
const consensusAddress = _optionalChain([client, 'access',
|
|
1454
|
+
const consensusAddress = _optionalChain([client, 'access', _123 => _123.chain, 'access', _124 => _124.consensusMainContract, 'optionalAccess', _125 => _125.address]);
|
|
1333
1455
|
const internalMessageProcessedTopic = _viem.keccak256.call(void 0, _viem.stringToBytes.call(void 0, "InternalMessageProcessed(bytes32,address,address)"));
|
|
1334
1456
|
const logs = await publicClient.getLogs({
|
|
1335
1457
|
address: consensusAddress,
|
|
@@ -1376,10 +1498,36 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1376
1498
|
params: [hash, signature]
|
|
1377
1499
|
});
|
|
1378
1500
|
},
|
|
1501
|
+
/** Returns the queue slot position of a transaction in the pending queue. */
|
|
1502
|
+
getTransactionQueuePosition: async ({ hash }) => {
|
|
1503
|
+
const consensusAddress = _optionalChain([client, 'access', _126 => _126.chain, 'access', _127 => _127.consensusMainContract, 'optionalAccess', _128 => _128.address]);
|
|
1504
|
+
const consensusAbi = _optionalChain([client, 'access', _129 => _129.chain, 'access', _130 => _130.consensusMainContract, 'optionalAccess', _131 => _131.abi]);
|
|
1505
|
+
const queuesAddress = await publicClient.readContract({
|
|
1506
|
+
address: consensusAddress,
|
|
1507
|
+
abi: consensusAbi,
|
|
1508
|
+
functionName: "queues"
|
|
1509
|
+
});
|
|
1510
|
+
const QUEUES_ABI = [
|
|
1511
|
+
{
|
|
1512
|
+
inputs: [{ internalType: "bytes32", name: "txId", type: "bytes32" }],
|
|
1513
|
+
name: "getTransactionQueuePosition",
|
|
1514
|
+
outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
|
|
1515
|
+
stateMutability: "view",
|
|
1516
|
+
type: "function"
|
|
1517
|
+
}
|
|
1518
|
+
];
|
|
1519
|
+
const position = await publicClient.readContract({
|
|
1520
|
+
address: queuesAddress,
|
|
1521
|
+
abi: QUEUES_ABI,
|
|
1522
|
+
functionName: "getTransactionQueuePosition",
|
|
1523
|
+
args: [hash]
|
|
1524
|
+
});
|
|
1525
|
+
return Number(position);
|
|
1526
|
+
},
|
|
1379
1527
|
/** Estimates gas required for a transaction. */
|
|
1380
1528
|
estimateTransactionGas: async (transactionParams) => {
|
|
1381
1529
|
const formattedParams = {
|
|
1382
|
-
from: transactionParams.from || _optionalChain([client, 'access',
|
|
1530
|
+
from: transactionParams.from || _optionalChain([client, 'access', _132 => _132.account, 'optionalAccess', _133 => _133.address]),
|
|
1383
1531
|
to: transactionParams.to,
|
|
1384
1532
|
data: transactionParams.data || "0x",
|
|
1385
1533
|
value: transactionParams.value ? `0x${transactionParams.value.toString(16)}` : "0x0"
|
|
@@ -1400,10 +1548,10 @@ var snapID = {
|
|
|
1400
1548
|
|
|
1401
1549
|
// src/wallet/connect.ts
|
|
1402
1550
|
var networks = {
|
|
1403
|
-
localnet:
|
|
1404
|
-
studionet:
|
|
1405
|
-
testnetAsimov:
|
|
1406
|
-
testnetBradbury:
|
|
1551
|
+
localnet: _chunkPZEHAYIUcjs.localnet,
|
|
1552
|
+
studionet: _chunkPZEHAYIUcjs.studionet,
|
|
1553
|
+
testnetAsimov: _chunkPZEHAYIUcjs.testnetAsimov,
|
|
1554
|
+
testnetBradbury: _chunkPZEHAYIUcjs.testnetBradbury
|
|
1407
1555
|
};
|
|
1408
1556
|
var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
1409
1557
|
if (!window.ethereum) {
|
|
@@ -1422,7 +1570,7 @@ var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
|
1422
1570
|
chainName: selectedNetwork.name,
|
|
1423
1571
|
rpcUrls: selectedNetwork.rpcUrls.default.http,
|
|
1424
1572
|
nativeCurrency: selectedNetwork.nativeCurrency,
|
|
1425
|
-
blockExplorerUrls: [_optionalChain([selectedNetwork, 'access',
|
|
1573
|
+
blockExplorerUrls: [_optionalChain([selectedNetwork, 'access', _134 => _134.blockExplorers, 'optionalAccess', _135 => _135.default, 'access', _136 => _136.url])]
|
|
1426
1574
|
};
|
|
1427
1575
|
const currentChainId = await window.ethereum.request({ method: "eth_chainId" });
|
|
1428
1576
|
if (currentChainId !== chainIdHex) {
|
|
@@ -1456,10 +1604,10 @@ var metamaskClient = async (snapSource = "npm") => {
|
|
|
1456
1604
|
}
|
|
1457
1605
|
const isFlask = async () => {
|
|
1458
1606
|
try {
|
|
1459
|
-
const clientVersion = await _optionalChain([window, 'access',
|
|
1607
|
+
const clientVersion = await _optionalChain([window, 'access', _137 => _137.ethereum, 'optionalAccess', _138 => _138.request, 'call', _139 => _139({
|
|
1460
1608
|
method: "web3_clientVersion"
|
|
1461
1609
|
})]);
|
|
1462
|
-
return _optionalChain([clientVersion, 'optionalAccess',
|
|
1610
|
+
return _optionalChain([clientVersion, 'optionalAccess', _140 => _140.includes, 'call', _141 => _141("flask")]);
|
|
1463
1611
|
} catch (error) {
|
|
1464
1612
|
console.error("Error detecting Flask:", error);
|
|
1465
1613
|
return false;
|
|
@@ -1467,7 +1615,7 @@ var metamaskClient = async (snapSource = "npm") => {
|
|
|
1467
1615
|
};
|
|
1468
1616
|
const installedSnaps = async () => {
|
|
1469
1617
|
try {
|
|
1470
|
-
return await _optionalChain([window, 'access',
|
|
1618
|
+
return await _optionalChain([window, 'access', _142 => _142.ethereum, 'optionalAccess', _143 => _143.request, 'call', _144 => _144({
|
|
1471
1619
|
method: "wallet_getSnaps"
|
|
1472
1620
|
})]);
|
|
1473
1621
|
} catch (error) {
|
|
@@ -1519,7 +1667,7 @@ function formatStakingAmount(amount) {
|
|
|
1519
1667
|
// src/staking/actions.ts
|
|
1520
1668
|
var FALLBACK_GAS = 1000000n;
|
|
1521
1669
|
var GAS_BUFFER_MULTIPLIER = 2n;
|
|
1522
|
-
var COMBINED_ERROR_ABI = [...
|
|
1670
|
+
var COMBINED_ERROR_ABI = [..._chunkPZEHAYIUcjs.STAKING_ABI, ..._chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI];
|
|
1523
1671
|
function extractRevertReason(err) {
|
|
1524
1672
|
if (err instanceof _viem.BaseError) {
|
|
1525
1673
|
const rawError = err.walk((e) => e instanceof _viem.RawContractError);
|
|
@@ -1554,7 +1702,7 @@ function extractRevertReason(err) {
|
|
|
1554
1702
|
}
|
|
1555
1703
|
const revertError = err.walk((e) => e instanceof _viem.ContractFunctionRevertedError);
|
|
1556
1704
|
if (revertError instanceof _viem.ContractFunctionRevertedError) {
|
|
1557
|
-
if (_optionalChain([revertError, 'access',
|
|
1705
|
+
if (_optionalChain([revertError, 'access', _145 => _145.data, 'optionalAccess', _146 => _146.errorName])) {
|
|
1558
1706
|
return revertError.data.errorName;
|
|
1559
1707
|
}
|
|
1560
1708
|
return revertError.reason || "Unknown reason";
|
|
@@ -1642,7 +1790,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1642
1790
|
};
|
|
1643
1791
|
const getStakingAddress = () => {
|
|
1644
1792
|
const stakingConfig = client.chain.stakingContract;
|
|
1645
|
-
if (!_optionalChain([stakingConfig, 'optionalAccess',
|
|
1793
|
+
if (!_optionalChain([stakingConfig, 'optionalAccess', _147 => _147.address]) || stakingConfig.address === "0x0000000000000000000000000000000000000000") {
|
|
1646
1794
|
throw new Error("Staking is not supported on studio-based networks. Use testnet-asimov for staking operations.");
|
|
1647
1795
|
}
|
|
1648
1796
|
return stakingConfig.address;
|
|
@@ -1651,7 +1799,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1651
1799
|
const address = getStakingAddress();
|
|
1652
1800
|
return _viem.getContract.call(void 0, {
|
|
1653
1801
|
address,
|
|
1654
|
-
abi:
|
|
1802
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1655
1803
|
client: { public: publicClient, wallet: client }
|
|
1656
1804
|
});
|
|
1657
1805
|
};
|
|
@@ -1659,7 +1807,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1659
1807
|
const address = getStakingAddress();
|
|
1660
1808
|
return _viem.getContract.call(void 0, {
|
|
1661
1809
|
address,
|
|
1662
|
-
abi:
|
|
1810
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1663
1811
|
client: publicClient
|
|
1664
1812
|
});
|
|
1665
1813
|
};
|
|
@@ -1669,11 +1817,11 @@ var stakingActions = (client, publicClient) => {
|
|
|
1669
1817
|
const amount = parseStakingAmount(options.amount);
|
|
1670
1818
|
const stakingAddress = getStakingAddress();
|
|
1671
1819
|
const data = options.operator ? _viem.encodeFunctionData.call(void 0, {
|
|
1672
|
-
abi:
|
|
1820
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1673
1821
|
functionName: "validatorJoin",
|
|
1674
1822
|
args: [options.operator]
|
|
1675
1823
|
}) : _viem.encodeFunctionData.call(void 0, {
|
|
1676
|
-
abi:
|
|
1824
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1677
1825
|
functionName: "validatorJoin"
|
|
1678
1826
|
});
|
|
1679
1827
|
const result = await executeWrite({ to: stakingAddress, data, value: amount });
|
|
@@ -1682,7 +1830,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1682
1830
|
let eventFound = false;
|
|
1683
1831
|
for (const log of receipt.logs) {
|
|
1684
1832
|
try {
|
|
1685
|
-
const decoded = _viem.decodeEventLog.call(void 0, { abi:
|
|
1833
|
+
const decoded = _viem.decodeEventLog.call(void 0, { abi: _chunkPZEHAYIUcjs.STAKING_ABI, data: log.data, topics: log.topics });
|
|
1686
1834
|
if (decoded.eventName === "ValidatorJoin") {
|
|
1687
1835
|
validatorWallet = decoded.args.validator;
|
|
1688
1836
|
eventFound = true;
|
|
@@ -1710,7 +1858,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1710
1858
|
validatorDeposit: async (options) => {
|
|
1711
1859
|
const amount = parseStakingAmount(options.amount);
|
|
1712
1860
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1713
|
-
abi:
|
|
1861
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1714
1862
|
functionName: "validatorDeposit"
|
|
1715
1863
|
});
|
|
1716
1864
|
return executeWrite({ to: getStakingAddress(), data, value: amount });
|
|
@@ -1719,7 +1867,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1719
1867
|
validatorExit: async (options) => {
|
|
1720
1868
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1721
1869
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1722
|
-
abi:
|
|
1870
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1723
1871
|
functionName: "validatorExit",
|
|
1724
1872
|
args: [shares]
|
|
1725
1873
|
});
|
|
@@ -1727,12 +1875,12 @@ var stakingActions = (client, publicClient) => {
|
|
|
1727
1875
|
},
|
|
1728
1876
|
/** Claims pending validator withdrawals. */
|
|
1729
1877
|
validatorClaim: async (options) => {
|
|
1730
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
1878
|
+
if (!_optionalChain([options, 'optionalAccess', _148 => _148.validator]) && !client.account) {
|
|
1731
1879
|
throw new Error("Either provide validator address or initialize client with an account");
|
|
1732
1880
|
}
|
|
1733
|
-
const validatorAddress = _optionalChain([options, 'optionalAccess',
|
|
1881
|
+
const validatorAddress = _optionalChain([options, 'optionalAccess', _149 => _149.validator]) || client.account.address;
|
|
1734
1882
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1735
|
-
abi:
|
|
1883
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1736
1884
|
functionName: "validatorClaim",
|
|
1737
1885
|
args: [validatorAddress]
|
|
1738
1886
|
});
|
|
@@ -1742,7 +1890,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1742
1890
|
/** Primes a validator for participation in the next epoch. */
|
|
1743
1891
|
validatorPrime: async (options) => {
|
|
1744
1892
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1745
|
-
abi:
|
|
1893
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1746
1894
|
functionName: "validatorPrime",
|
|
1747
1895
|
args: [options.validator]
|
|
1748
1896
|
});
|
|
@@ -1751,7 +1899,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1751
1899
|
/** Sets the operator address for a validator wallet. */
|
|
1752
1900
|
setOperator: async (options) => {
|
|
1753
1901
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1754
|
-
abi:
|
|
1902
|
+
abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
|
|
1755
1903
|
functionName: "setOperator",
|
|
1756
1904
|
args: [options.operator]
|
|
1757
1905
|
});
|
|
@@ -1768,7 +1916,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1768
1916
|
}
|
|
1769
1917
|
}
|
|
1770
1918
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1771
|
-
abi:
|
|
1919
|
+
abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
|
|
1772
1920
|
functionName: "setIdentity",
|
|
1773
1921
|
args: [
|
|
1774
1922
|
options.moniker,
|
|
@@ -1788,7 +1936,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1788
1936
|
delegatorJoin: async (options) => {
|
|
1789
1937
|
const amount = parseStakingAmount(options.amount);
|
|
1790
1938
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1791
|
-
abi:
|
|
1939
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1792
1940
|
functionName: "delegatorJoin",
|
|
1793
1941
|
args: [options.validator]
|
|
1794
1942
|
});
|
|
@@ -1805,7 +1953,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1805
1953
|
delegatorExit: async (options) => {
|
|
1806
1954
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1807
1955
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1808
|
-
abi:
|
|
1956
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1809
1957
|
functionName: "delegatorExit",
|
|
1810
1958
|
args: [options.validator, shares]
|
|
1811
1959
|
});
|
|
@@ -1818,7 +1966,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1818
1966
|
}
|
|
1819
1967
|
const delegatorAddress = options.delegator || client.account.address;
|
|
1820
1968
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1821
|
-
abi:
|
|
1969
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1822
1970
|
functionName: "delegatorClaim",
|
|
1823
1971
|
args: [delegatorAddress, options.validator]
|
|
1824
1972
|
});
|
|
@@ -1838,7 +1986,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1838
1986
|
}
|
|
1839
1987
|
const walletContract = _viem.getContract.call(void 0, {
|
|
1840
1988
|
address: validator,
|
|
1841
|
-
abi:
|
|
1989
|
+
abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
|
|
1842
1990
|
client: publicClient
|
|
1843
1991
|
});
|
|
1844
1992
|
const [view, owner, operator, identityRaw, currentEpoch] = await Promise.all([
|
|
@@ -2155,8 +2303,8 @@ var getCustomTransportConfig = (config, chainConfig) => {
|
|
|
2155
2303
|
}
|
|
2156
2304
|
};
|
|
2157
2305
|
};
|
|
2158
|
-
var createClient = (config = { chain:
|
|
2159
|
-
const chainConfig = config.chain ||
|
|
2306
|
+
var createClient = (config = { chain: _chunkPZEHAYIUcjs.localnet }) => {
|
|
2307
|
+
const chainConfig = config.chain || _chunkPZEHAYIUcjs.localnet;
|
|
2160
2308
|
if (config.endpoint) {
|
|
2161
2309
|
chainConfig.rpcUrls.default.http = [config.endpoint];
|
|
2162
2310
|
}
|
|
@@ -2293,4 +2441,4 @@ function validateValueAgainstType(value, type) {
|
|
|
2293
2441
|
|
|
2294
2442
|
|
|
2295
2443
|
|
|
2296
|
-
exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains =
|
|
2444
|
+
exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains = _chunkPZEHAYIUcjs.chains_exports; exports.createAccount = createAccount; exports.createClient = createClient; exports.decodeInputData = decodeInputData; exports.decodeLocalnetTransaction = decodeLocalnetTransaction; exports.decodeTransaction = decodeTransaction; exports.formatStakingAmount = formatStakingAmount; exports.generatePrivateKey = generatePrivateKey; exports.parseStakingAmount = parseStakingAmount; exports.simplifyTransactionReceipt = simplifyTransactionReceipt;
|