genlayer-js 0.27.9 → 0.28.1
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/README.md +29 -0
- 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-CX8nErk-.d.cts → index-DDgbU3hK.d.ts} +14 -1
- package/dist/{index-DPzGu_2l.d.ts → index-DQCfqVjw.d.cts} +14 -1
- package/dist/{index-BvRcfXce.d.cts → index-_c6eHw3s.d.cts} +1 -1
- package/dist/index.cjs +195 -82
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +121 -8
- package/dist/types/index.d.cts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,6 +213,35 @@ const receipt = await readClient.waitForTransactionReceipt({
|
|
|
213
213
|
});
|
|
214
214
|
```
|
|
215
215
|
|
|
216
|
+
### Switching the wallet to the correct network
|
|
217
|
+
|
|
218
|
+
When using MetaMask or another browser wallet, the wallet may be connected to a different chain than what your client is configured for. Use `client.connect()` to switch the wallet to the correct GenLayer network before sending transactions:
|
|
219
|
+
|
|
220
|
+
```typescript
|
|
221
|
+
import { createClient } from "genlayer-js";
|
|
222
|
+
import { studionet } from "genlayer-js/chains";
|
|
223
|
+
|
|
224
|
+
const client = createClient({
|
|
225
|
+
chain: studionet,
|
|
226
|
+
account: address as `0x${string}`,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
// Switch MetaMask to the correct chain (adds the network if not present)
|
|
230
|
+
await client.connect("studionet");
|
|
231
|
+
|
|
232
|
+
// Now transactions will go to the right network
|
|
233
|
+
const txHash = await client.writeContract({
|
|
234
|
+
address: contractAddress,
|
|
235
|
+
functionName: "create_profile",
|
|
236
|
+
args: ["alice", "Hello world"],
|
|
237
|
+
value: BigInt(0),
|
|
238
|
+
});
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Available networks: `"localnet"`, `"studionet"`, `"testnetAsimov"`, `"testnetBradbury"`.
|
|
242
|
+
|
|
243
|
+
> **Note:** If the wallet is on the wrong chain when you call `writeContract`, the SDK will throw a clear error telling you which chain the wallet is on vs. which chain the client expects. Call `client.connect()` to resolve this.
|
|
244
|
+
|
|
216
245
|
### Staking Operations
|
|
217
246
|
|
|
218
247
|
The SDK provides staking functionality for validators and delegators on testnet-bradbury (and testnet-asimov).
|
package/dist/chains/index.cjs
CHANGED
|
@@ -3,11 +3,11 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkPZEHAYIUcjs = require('../chunk-PZEHAYIU.cjs');
|
|
7
7
|
require('../chunk-75ZPJI57.cjs');
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
exports.localnet =
|
|
13
|
+
exports.localnet = _chunkPZEHAYIUcjs.localnet; exports.studionet = _chunkPZEHAYIUcjs.studionet; exports.testnetAsimov = _chunkPZEHAYIUcjs.testnetAsimov; exports.testnetBradbury = _chunkPZEHAYIUcjs.testnetBradbury;
|
package/dist/chains/index.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { l as localnet, s as studionet, t as testnetAsimov, a as testnetBradbury } from '../index-
|
|
2
|
-
import '../chains-
|
|
1
|
+
export { l as localnet, s as studionet, t as testnetAsimov, a as testnetBradbury } from '../index-_c6eHw3s.cjs';
|
|
2
|
+
import '../chains-D6DgvIVA.cjs';
|
|
3
3
|
import 'viem';
|
package/dist/chains/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { l as localnet, s as studionet, t as testnetAsimov, a as testnetBradbury } from '../index-
|
|
2
|
-
import '../chains-
|
|
1
|
+
export { l as localnet, s as studionet, t as testnetAsimov, a as testnetBradbury } from '../index-BCPb0x30.js';
|
|
2
|
+
import '../chains-D6DgvIVA.js';
|
|
3
3
|
import 'viem';
|
package/dist/chains/index.js
CHANGED
|
@@ -24,6 +24,10 @@ type GenLayerChain = Chain & {
|
|
|
24
24
|
address: Address;
|
|
25
25
|
abi: readonly unknown[];
|
|
26
26
|
} | null;
|
|
27
|
+
appealsContract: {
|
|
28
|
+
address: Address;
|
|
29
|
+
abi: readonly unknown[];
|
|
30
|
+
} | null;
|
|
27
31
|
defaultNumberOfInitialValidators: number;
|
|
28
32
|
defaultConsensusMaxRotations: number;
|
|
29
33
|
};
|
|
@@ -24,6 +24,10 @@ type GenLayerChain = Chain & {
|
|
|
24
24
|
address: Address;
|
|
25
25
|
abi: readonly unknown[];
|
|
26
26
|
} | null;
|
|
27
|
+
appealsContract: {
|
|
28
|
+
address: Address;
|
|
29
|
+
abi: readonly unknown[];
|
|
30
|
+
} | null;
|
|
27
31
|
defaultNumberOfInitialValidators: number;
|
|
28
32
|
defaultConsensusMaxRotations: number;
|
|
29
33
|
};
|
|
@@ -4022,6 +4022,7 @@ var localnet = _viem.defineChain.call(void 0, {
|
|
|
4022
4022
|
stakingContract: null,
|
|
4023
4023
|
feeManagerContract: null,
|
|
4024
4024
|
roundsStorageContract: null,
|
|
4025
|
+
appealsContract: null,
|
|
4025
4026
|
defaultNumberOfInitialValidators: 5,
|
|
4026
4027
|
defaultConsensusMaxRotations: 3
|
|
4027
4028
|
});
|
|
@@ -8038,6 +8039,7 @@ var studionet = _viem.defineChain.call(void 0, {
|
|
|
8038
8039
|
stakingContract: null,
|
|
8039
8040
|
feeManagerContract: null,
|
|
8040
8041
|
roundsStorageContract: null,
|
|
8042
|
+
appealsContract: null,
|
|
8041
8043
|
defaultNumberOfInitialValidators: 5,
|
|
8042
8044
|
defaultConsensusMaxRotations: 3
|
|
8043
8045
|
});
|
|
@@ -13538,6 +13540,7 @@ var testnetAsimov = _viem.defineChain.call(void 0, {
|
|
|
13538
13540
|
stakingContract: STAKING_CONTRACT,
|
|
13539
13541
|
feeManagerContract: null,
|
|
13540
13542
|
roundsStorageContract: null,
|
|
13543
|
+
appealsContract: null,
|
|
13541
13544
|
defaultNumberOfInitialValidators: 5,
|
|
13542
13545
|
defaultConsensusMaxRotations: 3
|
|
13543
13546
|
});
|
|
@@ -13574,6 +13577,70 @@ var ROUNDS_STORAGE_CONTRACT = {
|
|
|
13574
13577
|
stateMutability: "view",
|
|
13575
13578
|
inputs: [{ name: "_txId", type: "bytes32" }],
|
|
13576
13579
|
outputs: [{ name: "", type: "uint256" }]
|
|
13580
|
+
},
|
|
13581
|
+
{
|
|
13582
|
+
type: "function",
|
|
13583
|
+
name: "getRoundData",
|
|
13584
|
+
stateMutability: "view",
|
|
13585
|
+
inputs: [
|
|
13586
|
+
{ name: "_txId", type: "bytes32" },
|
|
13587
|
+
{ name: "_round", type: "uint256" }
|
|
13588
|
+
],
|
|
13589
|
+
outputs: [{
|
|
13590
|
+
name: "",
|
|
13591
|
+
type: "tuple",
|
|
13592
|
+
components: [
|
|
13593
|
+
{ name: "round", type: "uint256" },
|
|
13594
|
+
{ name: "leaderIndex", type: "uint256" },
|
|
13595
|
+
{ name: "votesCommitted", type: "uint256" },
|
|
13596
|
+
{ name: "votesRevealed", type: "uint256" },
|
|
13597
|
+
{ name: "appealBond", type: "uint256" },
|
|
13598
|
+
{ name: "rotationsLeft", type: "uint256" },
|
|
13599
|
+
{ name: "result", type: "uint8" },
|
|
13600
|
+
{ name: "roundValidators", type: "address[]" },
|
|
13601
|
+
{ name: "validatorVotes", type: "uint8[]" },
|
|
13602
|
+
{ name: "validatorVotesHash", type: "bytes32[]" },
|
|
13603
|
+
{ name: "validatorResultHash", type: "bytes32[]" }
|
|
13604
|
+
]
|
|
13605
|
+
}]
|
|
13606
|
+
},
|
|
13607
|
+
{
|
|
13608
|
+
type: "function",
|
|
13609
|
+
name: "getLastRoundData",
|
|
13610
|
+
stateMutability: "view",
|
|
13611
|
+
inputs: [{ name: "_txId", type: "bytes32" }],
|
|
13612
|
+
outputs: [
|
|
13613
|
+
{ name: "", type: "uint256" },
|
|
13614
|
+
{
|
|
13615
|
+
name: "",
|
|
13616
|
+
type: "tuple",
|
|
13617
|
+
components: [
|
|
13618
|
+
{ name: "round", type: "uint256" },
|
|
13619
|
+
{ name: "leaderIndex", type: "uint256" },
|
|
13620
|
+
{ name: "votesCommitted", type: "uint256" },
|
|
13621
|
+
{ name: "votesRevealed", type: "uint256" },
|
|
13622
|
+
{ name: "appealBond", type: "uint256" },
|
|
13623
|
+
{ name: "rotationsLeft", type: "uint256" },
|
|
13624
|
+
{ name: "result", type: "uint8" },
|
|
13625
|
+
{ name: "roundValidators", type: "address[]" },
|
|
13626
|
+
{ name: "validatorVotes", type: "uint8[]" },
|
|
13627
|
+
{ name: "validatorVotesHash", type: "bytes32[]" },
|
|
13628
|
+
{ name: "validatorResultHash", type: "bytes32[]" }
|
|
13629
|
+
]
|
|
13630
|
+
}
|
|
13631
|
+
]
|
|
13632
|
+
}
|
|
13633
|
+
]
|
|
13634
|
+
};
|
|
13635
|
+
var APPEALS_CONTRACT = {
|
|
13636
|
+
address: "0xbb8C35AA878D09b9830aFF9e5aAC6492BFbd5471",
|
|
13637
|
+
abi: [
|
|
13638
|
+
{
|
|
13639
|
+
type: "function",
|
|
13640
|
+
name: "canAppeal",
|
|
13641
|
+
stateMutability: "view",
|
|
13642
|
+
inputs: [{ name: "_txId", type: "bytes32" }],
|
|
13643
|
+
outputs: [{ name: "", type: "bool" }]
|
|
13577
13644
|
}
|
|
13578
13645
|
]
|
|
13579
13646
|
};
|
|
@@ -16920,6 +16987,7 @@ var testnetBradbury = _viem.defineChain.call(void 0, {
|
|
|
16920
16987
|
stakingContract: STAKING_CONTRACT2,
|
|
16921
16988
|
feeManagerContract: FEE_MANAGER_CONTRACT,
|
|
16922
16989
|
roundsStorageContract: ROUNDS_STORAGE_CONTRACT,
|
|
16990
|
+
appealsContract: APPEALS_CONTRACT,
|
|
16923
16991
|
defaultNumberOfInitialValidators: 5,
|
|
16924
16992
|
defaultConsensusMaxRotations: 3
|
|
16925
16993
|
});
|
|
@@ -4022,6 +4022,7 @@ var localnet = defineChain({
|
|
|
4022
4022
|
stakingContract: null,
|
|
4023
4023
|
feeManagerContract: null,
|
|
4024
4024
|
roundsStorageContract: null,
|
|
4025
|
+
appealsContract: null,
|
|
4025
4026
|
defaultNumberOfInitialValidators: 5,
|
|
4026
4027
|
defaultConsensusMaxRotations: 3
|
|
4027
4028
|
});
|
|
@@ -8038,6 +8039,7 @@ var studionet = defineChain2({
|
|
|
8038
8039
|
stakingContract: null,
|
|
8039
8040
|
feeManagerContract: null,
|
|
8040
8041
|
roundsStorageContract: null,
|
|
8042
|
+
appealsContract: null,
|
|
8041
8043
|
defaultNumberOfInitialValidators: 5,
|
|
8042
8044
|
defaultConsensusMaxRotations: 3
|
|
8043
8045
|
});
|
|
@@ -13538,6 +13540,7 @@ var testnetAsimov = defineChain3({
|
|
|
13538
13540
|
stakingContract: STAKING_CONTRACT,
|
|
13539
13541
|
feeManagerContract: null,
|
|
13540
13542
|
roundsStorageContract: null,
|
|
13543
|
+
appealsContract: null,
|
|
13541
13544
|
defaultNumberOfInitialValidators: 5,
|
|
13542
13545
|
defaultConsensusMaxRotations: 3
|
|
13543
13546
|
});
|
|
@@ -13574,6 +13577,70 @@ var ROUNDS_STORAGE_CONTRACT = {
|
|
|
13574
13577
|
stateMutability: "view",
|
|
13575
13578
|
inputs: [{ name: "_txId", type: "bytes32" }],
|
|
13576
13579
|
outputs: [{ name: "", type: "uint256" }]
|
|
13580
|
+
},
|
|
13581
|
+
{
|
|
13582
|
+
type: "function",
|
|
13583
|
+
name: "getRoundData",
|
|
13584
|
+
stateMutability: "view",
|
|
13585
|
+
inputs: [
|
|
13586
|
+
{ name: "_txId", type: "bytes32" },
|
|
13587
|
+
{ name: "_round", type: "uint256" }
|
|
13588
|
+
],
|
|
13589
|
+
outputs: [{
|
|
13590
|
+
name: "",
|
|
13591
|
+
type: "tuple",
|
|
13592
|
+
components: [
|
|
13593
|
+
{ name: "round", type: "uint256" },
|
|
13594
|
+
{ name: "leaderIndex", type: "uint256" },
|
|
13595
|
+
{ name: "votesCommitted", type: "uint256" },
|
|
13596
|
+
{ name: "votesRevealed", type: "uint256" },
|
|
13597
|
+
{ name: "appealBond", type: "uint256" },
|
|
13598
|
+
{ name: "rotationsLeft", type: "uint256" },
|
|
13599
|
+
{ name: "result", type: "uint8" },
|
|
13600
|
+
{ name: "roundValidators", type: "address[]" },
|
|
13601
|
+
{ name: "validatorVotes", type: "uint8[]" },
|
|
13602
|
+
{ name: "validatorVotesHash", type: "bytes32[]" },
|
|
13603
|
+
{ name: "validatorResultHash", type: "bytes32[]" }
|
|
13604
|
+
]
|
|
13605
|
+
}]
|
|
13606
|
+
},
|
|
13607
|
+
{
|
|
13608
|
+
type: "function",
|
|
13609
|
+
name: "getLastRoundData",
|
|
13610
|
+
stateMutability: "view",
|
|
13611
|
+
inputs: [{ name: "_txId", type: "bytes32" }],
|
|
13612
|
+
outputs: [
|
|
13613
|
+
{ name: "", type: "uint256" },
|
|
13614
|
+
{
|
|
13615
|
+
name: "",
|
|
13616
|
+
type: "tuple",
|
|
13617
|
+
components: [
|
|
13618
|
+
{ name: "round", type: "uint256" },
|
|
13619
|
+
{ name: "leaderIndex", type: "uint256" },
|
|
13620
|
+
{ name: "votesCommitted", type: "uint256" },
|
|
13621
|
+
{ name: "votesRevealed", type: "uint256" },
|
|
13622
|
+
{ name: "appealBond", type: "uint256" },
|
|
13623
|
+
{ name: "rotationsLeft", type: "uint256" },
|
|
13624
|
+
{ name: "result", type: "uint8" },
|
|
13625
|
+
{ name: "roundValidators", type: "address[]" },
|
|
13626
|
+
{ name: "validatorVotes", type: "uint8[]" },
|
|
13627
|
+
{ name: "validatorVotesHash", type: "bytes32[]" },
|
|
13628
|
+
{ name: "validatorResultHash", type: "bytes32[]" }
|
|
13629
|
+
]
|
|
13630
|
+
}
|
|
13631
|
+
]
|
|
13632
|
+
}
|
|
13633
|
+
]
|
|
13634
|
+
};
|
|
13635
|
+
var APPEALS_CONTRACT = {
|
|
13636
|
+
address: "0xbb8C35AA878D09b9830aFF9e5aAC6492BFbd5471",
|
|
13637
|
+
abi: [
|
|
13638
|
+
{
|
|
13639
|
+
type: "function",
|
|
13640
|
+
name: "canAppeal",
|
|
13641
|
+
stateMutability: "view",
|
|
13642
|
+
inputs: [{ name: "_txId", type: "bytes32" }],
|
|
13643
|
+
outputs: [{ name: "", type: "bool" }]
|
|
13577
13644
|
}
|
|
13578
13645
|
]
|
|
13579
13646
|
};
|
|
@@ -16920,6 +16987,7 @@ var testnetBradbury = defineChain4({
|
|
|
16920
16987
|
stakingContract: STAKING_CONTRACT2,
|
|
16921
16988
|
feeManagerContract: FEE_MANAGER_CONTRACT,
|
|
16922
16989
|
roundsStorageContract: ROUNDS_STORAGE_CONTRACT,
|
|
16990
|
+
appealsContract: APPEALS_CONTRACT,
|
|
16923
16991
|
defaultNumberOfInitialValidators: 5,
|
|
16924
16992
|
defaultConsensusMaxRotations: 3
|
|
16925
16993
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hex, Address, GetContractReturnType, PublicClient, Client, Transport, Chain, Account, WalletActions, PublicActions } from 'viem';
|
|
2
|
-
import { G as GenLayerChain } from './chains-
|
|
2
|
+
import { G as GenLayerChain } from './chains-D6DgvIVA.js';
|
|
3
3
|
|
|
4
4
|
declare class CalldataAddress {
|
|
5
5
|
bytes: Uint8Array;
|
|
@@ -2898,6 +2898,19 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
|
|
|
2898
2898
|
transaction_hash: string;
|
|
2899
2899
|
status: string;
|
|
2900
2900
|
}>;
|
|
2901
|
+
getRoundNumber: (args: {
|
|
2902
|
+
txId: `0x${string}`;
|
|
2903
|
+
}) => Promise<bigint>;
|
|
2904
|
+
getRoundData: (args: {
|
|
2905
|
+
txId: `0x${string}`;
|
|
2906
|
+
round: bigint;
|
|
2907
|
+
}) => Promise<any>;
|
|
2908
|
+
getLastRoundData: (args: {
|
|
2909
|
+
txId: `0x${string}`;
|
|
2910
|
+
}) => Promise<any>;
|
|
2911
|
+
canAppeal: (args: {
|
|
2912
|
+
txId: `0x${string}`;
|
|
2913
|
+
}) => Promise<boolean>;
|
|
2901
2914
|
appealTransaction: (args: {
|
|
2902
2915
|
account?: Account;
|
|
2903
2916
|
txId: `0x${string}`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Hex, Address, GetContractReturnType, PublicClient, Client, Transport, Chain, Account, WalletActions, PublicActions } from 'viem';
|
|
2
|
-
import { G as GenLayerChain } from './chains-
|
|
2
|
+
import { G as GenLayerChain } from './chains-D6DgvIVA.cjs';
|
|
3
3
|
|
|
4
4
|
declare class CalldataAddress {
|
|
5
5
|
bytes: Uint8Array;
|
|
@@ -2898,6 +2898,19 @@ type GenLayerClient<TGenLayerChain extends GenLayerChain> = Omit<Client<Transpor
|
|
|
2898
2898
|
transaction_hash: string;
|
|
2899
2899
|
status: string;
|
|
2900
2900
|
}>;
|
|
2901
|
+
getRoundNumber: (args: {
|
|
2902
|
+
txId: `0x${string}`;
|
|
2903
|
+
}) => Promise<bigint>;
|
|
2904
|
+
getRoundData: (args: {
|
|
2905
|
+
txId: `0x${string}`;
|
|
2906
|
+
round: bigint;
|
|
2907
|
+
}) => Promise<any>;
|
|
2908
|
+
getLastRoundData: (args: {
|
|
2909
|
+
txId: `0x${string}`;
|
|
2910
|
+
}) => Promise<any>;
|
|
2911
|
+
canAppeal: (args: {
|
|
2912
|
+
txId: `0x${string}`;
|
|
2913
|
+
}) => Promise<boolean>;
|
|
2901
2914
|
appealTransaction: (args: {
|
|
2902
2915
|
account?: Account;
|
|
2903
2916
|
txId: `0x${string}`;
|
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,7 +532,7 @@ 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 !==
|
|
535
|
+
if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
|
|
536
536
|
throw new Error(`getContractCode is only available on localnet (current chain: ${client.chain.name})`);
|
|
537
537
|
}
|
|
538
538
|
const result = await client.request({
|
|
@@ -544,7 +544,7 @@ 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 !==
|
|
547
|
+
if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
|
|
548
548
|
throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
|
|
549
549
|
}
|
|
550
550
|
const schema = await client.request({
|
|
@@ -555,7 +555,7 @@ 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 !==
|
|
558
|
+
if (client.chain.id !== _chunkPZEHAYIUcjs.localnet.id) {
|
|
559
559
|
throw new Error(`getContractSchema is only available on localnet (current chain: ${client.chain.name})`);
|
|
560
560
|
}
|
|
561
561
|
const schema = await client.request({
|
|
@@ -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
|
};
|
|
@@ -815,7 +911,7 @@ var getAddTransactionInputCount = (abi) => {
|
|
|
815
911
|
const candidate = item;
|
|
816
912
|
return candidate.type === "function" && candidate.name === "addTransaction";
|
|
817
913
|
});
|
|
818
|
-
return Array.isArray(_optionalChain([addTransactionFunction, 'optionalAccess',
|
|
914
|
+
return Array.isArray(_optionalChain([addTransactionFunction, 'optionalAccess', _38 => _38.inputs])) ? addTransactionFunction.inputs.length : 0;
|
|
819
915
|
};
|
|
820
916
|
var _encodeAddTransactionData = ({
|
|
821
917
|
client,
|
|
@@ -842,7 +938,7 @@ var _encodeAddTransactionData = ({
|
|
|
842
938
|
functionName: "addTransaction",
|
|
843
939
|
args: [...addTransactionArgs, 0n]
|
|
844
940
|
});
|
|
845
|
-
if (getAddTransactionInputCount(_optionalChain([client, 'access',
|
|
941
|
+
if (getAddTransactionInputCount(_optionalChain([client, 'access', _39 => _39.chain, 'access', _40 => _40.consensusMainContract, 'optionalAccess', _41 => _41.abi])) >= 6) {
|
|
846
942
|
return {
|
|
847
943
|
primaryEncodedData: encodedDataV6,
|
|
848
944
|
fallbackEncodedData: encodedDataV5
|
|
@@ -858,7 +954,7 @@ var _encodeSubmitAppealData = ({
|
|
|
858
954
|
txId
|
|
859
955
|
}) => {
|
|
860
956
|
return _viem.encodeFunctionData.call(void 0, {
|
|
861
|
-
abi: _optionalChain([client, 'access',
|
|
957
|
+
abi: _optionalChain([client, 'access', _42 => _42.chain, 'access', _43 => _43.consensusMainContract, 'optionalAccess', _44 => _44.abi]),
|
|
862
958
|
functionName: "submitAppeal",
|
|
863
959
|
args: [txId]
|
|
864
960
|
});
|
|
@@ -879,9 +975,9 @@ var isAddTransactionAbiMismatchError = (error) => {
|
|
|
879
975
|
}) : "";
|
|
880
976
|
const errorObject = error;
|
|
881
977
|
const errorMessage = [
|
|
882
|
-
_optionalChain([errorObject, 'optionalAccess',
|
|
883
|
-
_optionalChain([errorObject, 'optionalAccess',
|
|
884
|
-
_optionalChain([errorObject, 'optionalAccess',
|
|
978
|
+
_optionalChain([errorObject, 'optionalAccess', _45 => _45.shortMessage]),
|
|
979
|
+
_optionalChain([errorObject, 'optionalAccess', _46 => _46.details]),
|
|
980
|
+
_optionalChain([errorObject, 'optionalAccess', _47 => _47.message]),
|
|
885
981
|
serializedError,
|
|
886
982
|
String(_nullishCoalesce(error, () => ( "")))
|
|
887
983
|
].filter(Boolean).join(" ").toLowerCase();
|
|
@@ -889,7 +985,7 @@ var isAddTransactionAbiMismatchError = (error) => {
|
|
|
889
985
|
};
|
|
890
986
|
var extractTxIdFromLogs = (client, logs) => {
|
|
891
987
|
const newTxEvents = _viem.parseEventLogs.call(void 0, {
|
|
892
|
-
abi: _optionalChain([client, 'access',
|
|
988
|
+
abi: _optionalChain([client, 'access', _48 => _48.chain, 'access', _49 => _49.consensusMainContract, 'optionalAccess', _50 => _50.abi]),
|
|
893
989
|
eventName: "NewTransaction",
|
|
894
990
|
logs
|
|
895
991
|
});
|
|
@@ -914,7 +1010,7 @@ var _sendTransaction = async ({
|
|
|
914
1010
|
senderAccount,
|
|
915
1011
|
value = 0n
|
|
916
1012
|
}) => {
|
|
917
|
-
if (!_optionalChain([client, 'access',
|
|
1013
|
+
if (!_optionalChain([client, 'access', _51 => _51.chain, 'access', _52 => _52.consensusMainContract, 'optionalAccess', _53 => _53.address])) {
|
|
918
1014
|
throw new Error(`Consensus main contract address not found in chain config for "${client.chain.name}".`);
|
|
919
1015
|
}
|
|
920
1016
|
const validatedSenderAccount = validateAccount(senderAccount);
|
|
@@ -924,7 +1020,7 @@ var _sendTransaction = async ({
|
|
|
924
1020
|
try {
|
|
925
1021
|
estimatedGas = await client.estimateTransactionGas({
|
|
926
1022
|
from: validatedSenderAccount.address,
|
|
927
|
-
to: _optionalChain([client, 'access',
|
|
1023
|
+
to: _optionalChain([client, 'access', _54 => _54.chain, 'access', _55 => _55.consensusMainContract, 'optionalAccess', _56 => _56.address]),
|
|
928
1024
|
data: encodedDataForSend,
|
|
929
1025
|
value
|
|
930
1026
|
});
|
|
@@ -932,8 +1028,8 @@ var _sendTransaction = async ({
|
|
|
932
1028
|
console.error("Gas estimation failed, using default 200_000:", err);
|
|
933
1029
|
estimatedGas = 200000n;
|
|
934
1030
|
}
|
|
935
|
-
if (_optionalChain([validatedSenderAccount, 'optionalAccess',
|
|
936
|
-
if (!_optionalChain([validatedSenderAccount, 'optionalAccess',
|
|
1031
|
+
if (_optionalChain([validatedSenderAccount, 'optionalAccess', _57 => _57.type]) === "local") {
|
|
1032
|
+
if (!_optionalChain([validatedSenderAccount, 'optionalAccess', _58 => _58.signTransaction])) {
|
|
937
1033
|
throw new Error("Local account does not support signTransaction. Use a private key account created via privateKeyToAccount().");
|
|
938
1034
|
}
|
|
939
1035
|
const gasPriceHex2 = await client.request({
|
|
@@ -941,7 +1037,7 @@ var _sendTransaction = async ({
|
|
|
941
1037
|
});
|
|
942
1038
|
const transactionRequest = {
|
|
943
1039
|
account: validatedSenderAccount,
|
|
944
|
-
to: _optionalChain([client, 'access',
|
|
1040
|
+
to: _optionalChain([client, 'access', _59 => _59.chain, 'access', _60 => _60.consensusMainContract, 'optionalAccess', _61 => _61.address]),
|
|
945
1041
|
data: encodedDataForSend,
|
|
946
1042
|
type: "legacy",
|
|
947
1043
|
nonce: Number(nonce),
|
|
@@ -954,7 +1050,7 @@ var _sendTransaction = async ({
|
|
|
954
1050
|
const txHash = await client.sendRawTransaction({ serializedTransaction });
|
|
955
1051
|
const receipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
|
|
956
1052
|
if (receipt.status === "reverted") {
|
|
957
|
-
throw new Error(`Transaction reverted: EVM tx ${txHash} to consensus contract ${_optionalChain([client, 'access',
|
|
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.`);
|
|
958
1054
|
}
|
|
959
1055
|
const txId = extractTxIdFromLogs(client, receipt.logs);
|
|
960
1056
|
if (!txId) {
|
|
@@ -978,7 +1074,7 @@ var _sendTransaction = async ({
|
|
|
978
1074
|
const nonceBigInt = typeof nonce === "bigint" ? nonce : typeof nonce === "string" ? BigInt(nonce) : BigInt(Number(nonce));
|
|
979
1075
|
const formattedRequest = {
|
|
980
1076
|
from: validatedSenderAccount.address,
|
|
981
|
-
to: _optionalChain([client, 'access',
|
|
1077
|
+
to: _optionalChain([client, 'access', _65 => _65.chain, 'access', _66 => _66.consensusMainContract, 'optionalAccess', _67 => _67.address]),
|
|
982
1078
|
data: encodedDataForSend,
|
|
983
1079
|
value: `0x${value.toString(16)}`,
|
|
984
1080
|
gas: `0x${estimatedGas.toString(16)}`,
|
|
@@ -994,7 +1090,7 @@ var _sendTransaction = async ({
|
|
|
994
1090
|
});
|
|
995
1091
|
const externalReceipt = await publicClient.waitForTransactionReceipt({ hash: evmTxHash });
|
|
996
1092
|
if (externalReceipt.status === "reverted") {
|
|
997
|
-
throw new Error(`Transaction reverted: EVM tx ${evmTxHash} to consensus contract ${_optionalChain([client, 'access',
|
|
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.`);
|
|
998
1094
|
}
|
|
999
1095
|
const externalTxId = extractTxIdFromLogs(client, externalReceipt.logs);
|
|
1000
1096
|
if (!externalTxId) {
|
|
@@ -1119,7 +1215,7 @@ var decodeTransaction = (tx) => {
|
|
|
1119
1215
|
txData,
|
|
1120
1216
|
txDataDecoded,
|
|
1121
1217
|
currentTimestamp: tx.currentTimestamp.toString(),
|
|
1122
|
-
numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess',
|
|
1218
|
+
numOfInitialValidators: _nullishCoalesce(_optionalChain([numOfInitialValidators, 'optionalAccess', _71 => _71.toString, 'call', _72 => _72()]), () => ( "0")),
|
|
1123
1219
|
txSlot: tx.txSlot.toString(),
|
|
1124
1220
|
createdTimestamp: tx.createdTimestamp.toString(),
|
|
1125
1221
|
lastVoteTimestamp: tx.lastVoteTimestamp.toString(),
|
|
@@ -1127,9 +1223,9 @@ var decodeTransaction = (tx) => {
|
|
|
1127
1223
|
numOfRounds: tx.numOfRounds.toString(),
|
|
1128
1224
|
readStateBlockRange: {
|
|
1129
1225
|
...tx.readStateBlockRange,
|
|
1130
|
-
activationBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1131
|
-
processingBlock: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1132
|
-
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"))
|
|
1133
1229
|
},
|
|
1134
1230
|
statusName: _chunkGJXSECNHcjs.transactionsStatusNumberToName[String(tx.status)],
|
|
1135
1231
|
resultName: _chunkGJXSECNHcjs.transactionResultNumberToName[String(tx.result)],
|
|
@@ -1137,13 +1233,13 @@ var decodeTransaction = (tx) => {
|
|
|
1137
1233
|
txExecutionResultName: tx.txExecutionResult !== void 0 ? _chunkGJXSECNHcjs.executionResultNumberToName[String(tx.txExecutionResult)] : void 0,
|
|
1138
1234
|
lastRound: {
|
|
1139
1235
|
...tx.lastRound,
|
|
1140
|
-
round: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1141
|
-
leaderIndex: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1142
|
-
votesCommitted: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1143
|
-
votesRevealed: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1144
|
-
appealBond: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1145
|
-
rotationsLeft: _nullishCoalesce(_optionalChain([tx, 'access',
|
|
1146
|
-
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(
|
|
1147
1243
|
(vote) => _chunkGJXSECNHcjs.voteTypeNumberToName[String(vote)]
|
|
1148
1244
|
)
|
|
1149
1245
|
}
|
|
@@ -1225,7 +1321,7 @@ var simplifyTransactionReceipt = (tx) => {
|
|
|
1225
1321
|
var decodeLocalnetTransaction = (tx) => {
|
|
1226
1322
|
if (!tx.data) return tx;
|
|
1227
1323
|
try {
|
|
1228
|
-
const leaderReceipt = _optionalChain([tx, 'access',
|
|
1324
|
+
const leaderReceipt = _optionalChain([tx, 'access', _111 => _111.consensus_data, 'optionalAccess', _112 => _112.leader_receipt]);
|
|
1229
1325
|
if (leaderReceipt) {
|
|
1230
1326
|
const receipts = Array.isArray(leaderReceipt) ? leaderReceipt : [leaderReceipt];
|
|
1231
1327
|
receipts.forEach((receipt) => {
|
|
@@ -1256,7 +1352,7 @@ var decodeLocalnetTransaction = (tx) => {
|
|
|
1256
1352
|
}
|
|
1257
1353
|
});
|
|
1258
1354
|
}
|
|
1259
|
-
if (_optionalChain([tx, 'access',
|
|
1355
|
+
if (_optionalChain([tx, 'access', _113 => _113.data, 'optionalAccess', _114 => _114.calldata]) && typeof tx.data.calldata === "string") {
|
|
1260
1356
|
tx.data.calldata = {
|
|
1261
1357
|
base64: tx.data.calldata,
|
|
1262
1358
|
...calldataToUserFriendlyJson(b64ToArray(tx.data.calldata))
|
|
@@ -1288,7 +1384,7 @@ var receiptActions = (client, publicClient) => ({
|
|
|
1288
1384
|
const requestedStatus = _chunkGJXSECNHcjs.transactionsStatusNameToNumber[status];
|
|
1289
1385
|
if (transactionStatusString === requestedStatus || status === "ACCEPTED" /* ACCEPTED */ && _chunkGJXSECNHcjs.isDecidedState.call(void 0, transactionStatusString)) {
|
|
1290
1386
|
let finalTransaction = transaction;
|
|
1291
|
-
if (client.chain.id ===
|
|
1387
|
+
if (client.chain.id === _chunkPZEHAYIUcjs.localnet.id) {
|
|
1292
1388
|
finalTransaction = decodeLocalnetTransaction(transaction);
|
|
1293
1389
|
}
|
|
1294
1390
|
if (!fullTransaction) {
|
|
@@ -1319,8 +1415,8 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1319
1415
|
transaction2.statusName = localnetStatus;
|
|
1320
1416
|
return decodeLocalnetTransaction(transaction2);
|
|
1321
1417
|
}
|
|
1322
|
-
const contractAddress = _optionalChain([client, 'access',
|
|
1323
|
-
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]);
|
|
1324
1420
|
const [txDataRaw, allDataRaw] = await Promise.all([
|
|
1325
1421
|
publicClient.readContract({
|
|
1326
1422
|
address: contractAddress,
|
|
@@ -1350,12 +1446,12 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1350
1446
|
return _nullishCoalesce(tx2.triggered_transactions, () => ( []));
|
|
1351
1447
|
}
|
|
1352
1448
|
const tx = await transactionActions(client, publicClient).getTransaction({ hash });
|
|
1353
|
-
const proposalBlock = BigInt(_nullishCoalesce(_optionalChain([tx, 'access',
|
|
1449
|
+
const proposalBlock = BigInt(_nullishCoalesce(_optionalChain([tx, 'access', _121 => _121.readStateBlockRange, 'optionalAccess', _122 => _122.proposalBlock]), () => ( "0")));
|
|
1354
1450
|
if (proposalBlock === BigInt(0)) return [];
|
|
1355
1451
|
const scanRange = BigInt(100);
|
|
1356
1452
|
const latestBlock = await publicClient.getBlockNumber();
|
|
1357
1453
|
const toBlock = proposalBlock + scanRange < latestBlock ? proposalBlock + scanRange : latestBlock;
|
|
1358
|
-
const consensusAddress = _optionalChain([client, 'access',
|
|
1454
|
+
const consensusAddress = _optionalChain([client, 'access', _123 => _123.chain, 'access', _124 => _124.consensusMainContract, 'optionalAccess', _125 => _125.address]);
|
|
1359
1455
|
const internalMessageProcessedTopic = _viem.keccak256.call(void 0, _viem.stringToBytes.call(void 0, "InternalMessageProcessed(bytes32,address,address)"));
|
|
1360
1456
|
const logs = await publicClient.getLogs({
|
|
1361
1457
|
address: consensusAddress,
|
|
@@ -1404,8 +1500,8 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1404
1500
|
},
|
|
1405
1501
|
/** Returns the queue slot position of a transaction in the pending queue. */
|
|
1406
1502
|
getTransactionQueuePosition: async ({ hash }) => {
|
|
1407
|
-
const consensusAddress = _optionalChain([client, 'access',
|
|
1408
|
-
const consensusAbi = _optionalChain([client, 'access',
|
|
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]);
|
|
1409
1505
|
const queuesAddress = await publicClient.readContract({
|
|
1410
1506
|
address: consensusAddress,
|
|
1411
1507
|
abi: consensusAbi,
|
|
@@ -1431,7 +1527,7 @@ var transactionActions = (client, publicClient) => ({
|
|
|
1431
1527
|
/** Estimates gas required for a transaction. */
|
|
1432
1528
|
estimateTransactionGas: async (transactionParams) => {
|
|
1433
1529
|
const formattedParams = {
|
|
1434
|
-
from: transactionParams.from || _optionalChain([client, 'access',
|
|
1530
|
+
from: transactionParams.from || _optionalChain([client, 'access', _132 => _132.account, 'optionalAccess', _133 => _133.address]),
|
|
1435
1531
|
to: transactionParams.to,
|
|
1436
1532
|
data: transactionParams.data || "0x",
|
|
1437
1533
|
value: transactionParams.value ? `0x${transactionParams.value.toString(16)}` : "0x0"
|
|
@@ -1452,10 +1548,10 @@ var snapID = {
|
|
|
1452
1548
|
|
|
1453
1549
|
// src/wallet/connect.ts
|
|
1454
1550
|
var networks = {
|
|
1455
|
-
localnet:
|
|
1456
|
-
studionet:
|
|
1457
|
-
testnetAsimov:
|
|
1458
|
-
testnetBradbury:
|
|
1551
|
+
localnet: _chunkPZEHAYIUcjs.localnet,
|
|
1552
|
+
studionet: _chunkPZEHAYIUcjs.studionet,
|
|
1553
|
+
testnetAsimov: _chunkPZEHAYIUcjs.testnetAsimov,
|
|
1554
|
+
testnetBradbury: _chunkPZEHAYIUcjs.testnetBradbury
|
|
1459
1555
|
};
|
|
1460
1556
|
var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
1461
1557
|
if (!window.ethereum) {
|
|
@@ -1474,7 +1570,7 @@ var connect = async (client, network = "studionet", snapSource = "npm") => {
|
|
|
1474
1570
|
chainName: selectedNetwork.name,
|
|
1475
1571
|
rpcUrls: selectedNetwork.rpcUrls.default.http,
|
|
1476
1572
|
nativeCurrency: selectedNetwork.nativeCurrency,
|
|
1477
|
-
blockExplorerUrls: [_optionalChain([selectedNetwork, 'access',
|
|
1573
|
+
blockExplorerUrls: [_optionalChain([selectedNetwork, 'access', _134 => _134.blockExplorers, 'optionalAccess', _135 => _135.default, 'access', _136 => _136.url])]
|
|
1478
1574
|
};
|
|
1479
1575
|
const currentChainId = await window.ethereum.request({ method: "eth_chainId" });
|
|
1480
1576
|
if (currentChainId !== chainIdHex) {
|
|
@@ -1508,10 +1604,10 @@ var metamaskClient = async (snapSource = "npm") => {
|
|
|
1508
1604
|
}
|
|
1509
1605
|
const isFlask = async () => {
|
|
1510
1606
|
try {
|
|
1511
|
-
const clientVersion = await _optionalChain([window, 'access',
|
|
1607
|
+
const clientVersion = await _optionalChain([window, 'access', _137 => _137.ethereum, 'optionalAccess', _138 => _138.request, 'call', _139 => _139({
|
|
1512
1608
|
method: "web3_clientVersion"
|
|
1513
1609
|
})]);
|
|
1514
|
-
return _optionalChain([clientVersion, 'optionalAccess',
|
|
1610
|
+
return _optionalChain([clientVersion, 'optionalAccess', _140 => _140.includes, 'call', _141 => _141("flask")]);
|
|
1515
1611
|
} catch (error) {
|
|
1516
1612
|
console.error("Error detecting Flask:", error);
|
|
1517
1613
|
return false;
|
|
@@ -1519,7 +1615,7 @@ var metamaskClient = async (snapSource = "npm") => {
|
|
|
1519
1615
|
};
|
|
1520
1616
|
const installedSnaps = async () => {
|
|
1521
1617
|
try {
|
|
1522
|
-
return await _optionalChain([window, 'access',
|
|
1618
|
+
return await _optionalChain([window, 'access', _142 => _142.ethereum, 'optionalAccess', _143 => _143.request, 'call', _144 => _144({
|
|
1523
1619
|
method: "wallet_getSnaps"
|
|
1524
1620
|
})]);
|
|
1525
1621
|
} catch (error) {
|
|
@@ -1571,7 +1667,7 @@ function formatStakingAmount(amount) {
|
|
|
1571
1667
|
// src/staking/actions.ts
|
|
1572
1668
|
var FALLBACK_GAS = 1000000n;
|
|
1573
1669
|
var GAS_BUFFER_MULTIPLIER = 2n;
|
|
1574
|
-
var COMBINED_ERROR_ABI = [...
|
|
1670
|
+
var COMBINED_ERROR_ABI = [..._chunkPZEHAYIUcjs.STAKING_ABI, ..._chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI];
|
|
1575
1671
|
function extractRevertReason(err) {
|
|
1576
1672
|
if (err instanceof _viem.BaseError) {
|
|
1577
1673
|
const rawError = err.walk((e) => e instanceof _viem.RawContractError);
|
|
@@ -1606,7 +1702,7 @@ function extractRevertReason(err) {
|
|
|
1606
1702
|
}
|
|
1607
1703
|
const revertError = err.walk((e) => e instanceof _viem.ContractFunctionRevertedError);
|
|
1608
1704
|
if (revertError instanceof _viem.ContractFunctionRevertedError) {
|
|
1609
|
-
if (_optionalChain([revertError, 'access',
|
|
1705
|
+
if (_optionalChain([revertError, 'access', _145 => _145.data, 'optionalAccess', _146 => _146.errorName])) {
|
|
1610
1706
|
return revertError.data.errorName;
|
|
1611
1707
|
}
|
|
1612
1708
|
return revertError.reason || "Unknown reason";
|
|
@@ -1694,7 +1790,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1694
1790
|
};
|
|
1695
1791
|
const getStakingAddress = () => {
|
|
1696
1792
|
const stakingConfig = client.chain.stakingContract;
|
|
1697
|
-
if (!_optionalChain([stakingConfig, 'optionalAccess',
|
|
1793
|
+
if (!_optionalChain([stakingConfig, 'optionalAccess', _147 => _147.address]) || stakingConfig.address === "0x0000000000000000000000000000000000000000") {
|
|
1698
1794
|
throw new Error("Staking is not supported on studio-based networks. Use testnet-asimov for staking operations.");
|
|
1699
1795
|
}
|
|
1700
1796
|
return stakingConfig.address;
|
|
@@ -1703,7 +1799,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1703
1799
|
const address = getStakingAddress();
|
|
1704
1800
|
return _viem.getContract.call(void 0, {
|
|
1705
1801
|
address,
|
|
1706
|
-
abi:
|
|
1802
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1707
1803
|
client: { public: publicClient, wallet: client }
|
|
1708
1804
|
});
|
|
1709
1805
|
};
|
|
@@ -1711,7 +1807,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1711
1807
|
const address = getStakingAddress();
|
|
1712
1808
|
return _viem.getContract.call(void 0, {
|
|
1713
1809
|
address,
|
|
1714
|
-
abi:
|
|
1810
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1715
1811
|
client: publicClient
|
|
1716
1812
|
});
|
|
1717
1813
|
};
|
|
@@ -1721,11 +1817,11 @@ var stakingActions = (client, publicClient) => {
|
|
|
1721
1817
|
const amount = parseStakingAmount(options.amount);
|
|
1722
1818
|
const stakingAddress = getStakingAddress();
|
|
1723
1819
|
const data = options.operator ? _viem.encodeFunctionData.call(void 0, {
|
|
1724
|
-
abi:
|
|
1820
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1725
1821
|
functionName: "validatorJoin",
|
|
1726
1822
|
args: [options.operator]
|
|
1727
1823
|
}) : _viem.encodeFunctionData.call(void 0, {
|
|
1728
|
-
abi:
|
|
1824
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1729
1825
|
functionName: "validatorJoin"
|
|
1730
1826
|
});
|
|
1731
1827
|
const result = await executeWrite({ to: stakingAddress, data, value: amount });
|
|
@@ -1734,7 +1830,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1734
1830
|
let eventFound = false;
|
|
1735
1831
|
for (const log of receipt.logs) {
|
|
1736
1832
|
try {
|
|
1737
|
-
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 });
|
|
1738
1834
|
if (decoded.eventName === "ValidatorJoin") {
|
|
1739
1835
|
validatorWallet = decoded.args.validator;
|
|
1740
1836
|
eventFound = true;
|
|
@@ -1762,7 +1858,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1762
1858
|
validatorDeposit: async (options) => {
|
|
1763
1859
|
const amount = parseStakingAmount(options.amount);
|
|
1764
1860
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1765
|
-
abi:
|
|
1861
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1766
1862
|
functionName: "validatorDeposit"
|
|
1767
1863
|
});
|
|
1768
1864
|
return executeWrite({ to: getStakingAddress(), data, value: amount });
|
|
@@ -1771,7 +1867,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1771
1867
|
validatorExit: async (options) => {
|
|
1772
1868
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1773
1869
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1774
|
-
abi:
|
|
1870
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1775
1871
|
functionName: "validatorExit",
|
|
1776
1872
|
args: [shares]
|
|
1777
1873
|
});
|
|
@@ -1779,12 +1875,12 @@ var stakingActions = (client, publicClient) => {
|
|
|
1779
1875
|
},
|
|
1780
1876
|
/** Claims pending validator withdrawals. */
|
|
1781
1877
|
validatorClaim: async (options) => {
|
|
1782
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
1878
|
+
if (!_optionalChain([options, 'optionalAccess', _148 => _148.validator]) && !client.account) {
|
|
1783
1879
|
throw new Error("Either provide validator address or initialize client with an account");
|
|
1784
1880
|
}
|
|
1785
|
-
const validatorAddress = _optionalChain([options, 'optionalAccess',
|
|
1881
|
+
const validatorAddress = _optionalChain([options, 'optionalAccess', _149 => _149.validator]) || client.account.address;
|
|
1786
1882
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1787
|
-
abi:
|
|
1883
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1788
1884
|
functionName: "validatorClaim",
|
|
1789
1885
|
args: [validatorAddress]
|
|
1790
1886
|
});
|
|
@@ -1794,7 +1890,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1794
1890
|
/** Primes a validator for participation in the next epoch. */
|
|
1795
1891
|
validatorPrime: async (options) => {
|
|
1796
1892
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1797
|
-
abi:
|
|
1893
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1798
1894
|
functionName: "validatorPrime",
|
|
1799
1895
|
args: [options.validator]
|
|
1800
1896
|
});
|
|
@@ -1803,7 +1899,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1803
1899
|
/** Sets the operator address for a validator wallet. */
|
|
1804
1900
|
setOperator: async (options) => {
|
|
1805
1901
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1806
|
-
abi:
|
|
1902
|
+
abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
|
|
1807
1903
|
functionName: "setOperator",
|
|
1808
1904
|
args: [options.operator]
|
|
1809
1905
|
});
|
|
@@ -1820,7 +1916,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1820
1916
|
}
|
|
1821
1917
|
}
|
|
1822
1918
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1823
|
-
abi:
|
|
1919
|
+
abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
|
|
1824
1920
|
functionName: "setIdentity",
|
|
1825
1921
|
args: [
|
|
1826
1922
|
options.moniker,
|
|
@@ -1840,7 +1936,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1840
1936
|
delegatorJoin: async (options) => {
|
|
1841
1937
|
const amount = parseStakingAmount(options.amount);
|
|
1842
1938
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1843
|
-
abi:
|
|
1939
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1844
1940
|
functionName: "delegatorJoin",
|
|
1845
1941
|
args: [options.validator]
|
|
1846
1942
|
});
|
|
@@ -1857,7 +1953,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1857
1953
|
delegatorExit: async (options) => {
|
|
1858
1954
|
const shares = typeof options.shares === "string" ? BigInt(options.shares) : options.shares;
|
|
1859
1955
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1860
|
-
abi:
|
|
1956
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1861
1957
|
functionName: "delegatorExit",
|
|
1862
1958
|
args: [options.validator, shares]
|
|
1863
1959
|
});
|
|
@@ -1870,7 +1966,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1870
1966
|
}
|
|
1871
1967
|
const delegatorAddress = options.delegator || client.account.address;
|
|
1872
1968
|
const data = _viem.encodeFunctionData.call(void 0, {
|
|
1873
|
-
abi:
|
|
1969
|
+
abi: _chunkPZEHAYIUcjs.STAKING_ABI,
|
|
1874
1970
|
functionName: "delegatorClaim",
|
|
1875
1971
|
args: [delegatorAddress, options.validator]
|
|
1876
1972
|
});
|
|
@@ -1890,7 +1986,7 @@ var stakingActions = (client, publicClient) => {
|
|
|
1890
1986
|
}
|
|
1891
1987
|
const walletContract = _viem.getContract.call(void 0, {
|
|
1892
1988
|
address: validator,
|
|
1893
|
-
abi:
|
|
1989
|
+
abi: _chunkPZEHAYIUcjs.VALIDATOR_WALLET_ABI,
|
|
1894
1990
|
client: publicClient
|
|
1895
1991
|
});
|
|
1896
1992
|
const [view, owner, operator, identityRaw, currentEpoch] = await Promise.all([
|
|
@@ -2167,6 +2263,20 @@ var PROVIDER_METHODS = /* @__PURE__ */ new Set([
|
|
|
2167
2263
|
"personal_sign",
|
|
2168
2264
|
"eth_signTypedData_v4"
|
|
2169
2265
|
]);
|
|
2266
|
+
var assertChainMatch = async (provider, chainConfig) => {
|
|
2267
|
+
const expectedChainIdHex = `0x${chainConfig.id.toString(16)}`;
|
|
2268
|
+
try {
|
|
2269
|
+
const currentChainId = await provider.request({ method: "eth_chainId" });
|
|
2270
|
+
if (currentChainId !== expectedChainIdHex) {
|
|
2271
|
+
const currentId = parseInt(currentChainId, 16);
|
|
2272
|
+
throw new Error(
|
|
2273
|
+
`Wallet is on chain ${currentId} but client is configured for chain ${chainConfig.id} (${chainConfig.name}). Call client.connect("${chainConfig.name}") or switch your wallet to the correct network before sending transactions.`
|
|
2274
|
+
);
|
|
2275
|
+
}
|
|
2276
|
+
} catch (err) {
|
|
2277
|
+
if (err instanceof Error && err.message.startsWith("Wallet is on chain")) throw err;
|
|
2278
|
+
}
|
|
2279
|
+
};
|
|
2170
2280
|
var getCustomTransportConfig = (config, chainConfig) => {
|
|
2171
2281
|
const isAddress = typeof config.account !== "object";
|
|
2172
2282
|
return {
|
|
@@ -2175,6 +2285,9 @@ var getCustomTransportConfig = (config, chainConfig) => {
|
|
|
2175
2285
|
const provider = config.provider || (typeof window !== "undefined" ? window.ethereum : void 0);
|
|
2176
2286
|
if (provider) {
|
|
2177
2287
|
try {
|
|
2288
|
+
if (method === "eth_sendTransaction" || method === "eth_signTransaction") {
|
|
2289
|
+
await assertChainMatch(provider, chainConfig);
|
|
2290
|
+
}
|
|
2178
2291
|
return await provider.request({ method, params });
|
|
2179
2292
|
} catch (err) {
|
|
2180
2293
|
console.warn(`Error using provider for method ${method}:`, err);
|
|
@@ -2207,8 +2320,8 @@ var getCustomTransportConfig = (config, chainConfig) => {
|
|
|
2207
2320
|
}
|
|
2208
2321
|
};
|
|
2209
2322
|
};
|
|
2210
|
-
var createClient = (config = { chain:
|
|
2211
|
-
const chainConfig = config.chain ||
|
|
2323
|
+
var createClient = (config = { chain: _chunkPZEHAYIUcjs.localnet }) => {
|
|
2324
|
+
const chainConfig = config.chain || _chunkPZEHAYIUcjs.localnet;
|
|
2212
2325
|
if (config.endpoint) {
|
|
2213
2326
|
chainConfig.rpcUrls.default.http = [config.endpoint];
|
|
2214
2327
|
}
|
|
@@ -2345,4 +2458,4 @@ function validateValueAgainstType(value, type) {
|
|
|
2345
2458
|
|
|
2346
2459
|
|
|
2347
2460
|
|
|
2348
|
-
exports.abi = abi_exports; exports.buildGenVmPositionalArgs = buildGenVmPositionalArgs; exports.chains =
|
|
2461
|
+
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;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account, Address, Hex } from 'viem';
|
|
3
|
-
import { G as GenLayerChain } from './chains-
|
|
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-
|
|
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-DQCfqVjw.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';
|
|
8
|
-
export { i as chains } from './index-
|
|
8
|
+
export { i as chains } from './index-_c6eHw3s.cjs';
|
|
9
9
|
|
|
10
10
|
interface ClientConfig {
|
|
11
11
|
chain?: {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as viem from 'viem';
|
|
2
2
|
import { Account, Address, Hex } from 'viem';
|
|
3
|
-
import { G as GenLayerChain } from './chains-
|
|
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-
|
|
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-DDgbU3hK.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';
|
|
8
|
-
export { i as chains } from './index-
|
|
8
|
+
export { i as chains } from './index-BCPb0x30.js';
|
|
9
9
|
|
|
10
10
|
interface ClientConfig {
|
|
11
11
|
chain?: {
|
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-SGAVFNGA.js";
|
|
10
10
|
import {
|
|
11
11
|
CalldataAddress,
|
|
12
12
|
executionResultNumberToName,
|
|
@@ -718,6 +718,54 @@ 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 (!client.chain.roundsStorageContract?.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 (!client.chain.roundsStorageContract?.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 (!client.chain.roundsStorageContract?.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 (!client.chain.appealsContract?.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;
|
|
@@ -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 (!client.chain.consensusMainContract?.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
|
};
|
|
@@ -2167,6 +2263,20 @@ var PROVIDER_METHODS = /* @__PURE__ */ new Set([
|
|
|
2167
2263
|
"personal_sign",
|
|
2168
2264
|
"eth_signTypedData_v4"
|
|
2169
2265
|
]);
|
|
2266
|
+
var assertChainMatch = async (provider, chainConfig) => {
|
|
2267
|
+
const expectedChainIdHex = `0x${chainConfig.id.toString(16)}`;
|
|
2268
|
+
try {
|
|
2269
|
+
const currentChainId = await provider.request({ method: "eth_chainId" });
|
|
2270
|
+
if (currentChainId !== expectedChainIdHex) {
|
|
2271
|
+
const currentId = parseInt(currentChainId, 16);
|
|
2272
|
+
throw new Error(
|
|
2273
|
+
`Wallet is on chain ${currentId} but client is configured for chain ${chainConfig.id} (${chainConfig.name}). Call client.connect("${chainConfig.name}") or switch your wallet to the correct network before sending transactions.`
|
|
2274
|
+
);
|
|
2275
|
+
}
|
|
2276
|
+
} catch (err) {
|
|
2277
|
+
if (err instanceof Error && err.message.startsWith("Wallet is on chain")) throw err;
|
|
2278
|
+
}
|
|
2279
|
+
};
|
|
2170
2280
|
var getCustomTransportConfig = (config, chainConfig) => {
|
|
2171
2281
|
const isAddress = typeof config.account !== "object";
|
|
2172
2282
|
return {
|
|
@@ -2175,6 +2285,9 @@ var getCustomTransportConfig = (config, chainConfig) => {
|
|
|
2175
2285
|
const provider = config.provider || (typeof window !== "undefined" ? window.ethereum : void 0);
|
|
2176
2286
|
if (provider) {
|
|
2177
2287
|
try {
|
|
2288
|
+
if (method === "eth_sendTransaction" || method === "eth_signTransaction") {
|
|
2289
|
+
await assertChainMatch(provider, chainConfig);
|
|
2290
|
+
}
|
|
2178
2291
|
return await provider.request({ method, params });
|
|
2179
2292
|
} catch (err) {
|
|
2180
2293
|
console.warn(`Error using provider for method ${method}:`, err);
|
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-
|
|
3
|
-
export { G as GenLayerChain } from '../chains-
|
|
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-DQCfqVjw.cjs';
|
|
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-
|
|
3
|
-
export { G as GenLayerChain } from '../chains-
|
|
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-DDgbU3hK.js';
|
|
3
|
+
export { G as GenLayerChain } from '../chains-D6DgvIVA.js';
|