genlayer-js 0.18.8 → 0.18.10
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/CHANGELOG.md +4 -0
- package/dist/chains/index.cjs +2 -2
- package/dist/chains/index.js +1 -1
- package/dist/{chunk-WTAFQOXC.cjs → chunk-PPBY3UXF.cjs} +48 -7
- package/dist/{chunk-V4ZFI4GV.js → chunk-WZNF2WK4.js} +48 -7
- package/dist/{index-C3KT8eu_.d.cts → index-D9ONjYgl.d.cts} +99 -22
- package/dist/{index-BNui_XYa.d.ts → index-ZDqJWXj0.d.ts} +99 -22
- package/dist/index.cjs +133 -94
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +88 -49
- package/dist/types/index.d.cts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/abi/staking.ts +61 -0
- package/src/chains/testnetAsimov.ts +6 -4
- package/src/client/client.ts +3 -7
- package/src/contracts/actions.ts +60 -41
- package/src/staking/actions.ts +49 -11
- package/src/types/staking.ts +4 -7
- package/src/types/transactions.ts +16 -14
- package/tests/smoke.test.ts +59 -0
package/src/types/staking.ts
CHANGED
|
@@ -114,24 +114,19 @@ export interface EpochData {
|
|
|
114
114
|
claimed: bigint;
|
|
115
115
|
stakeDeposit: bigint;
|
|
116
116
|
stakeWithdrawal: bigint;
|
|
117
|
+
slashed: bigint;
|
|
117
118
|
}
|
|
118
119
|
|
|
119
120
|
export interface EpochInfo {
|
|
120
121
|
currentEpoch: bigint;
|
|
122
|
+
lastFinalizedEpoch: bigint;
|
|
121
123
|
validatorMinStake: string;
|
|
122
124
|
validatorMinStakeRaw: bigint;
|
|
123
125
|
delegatorMinStake: string;
|
|
124
126
|
delegatorMinStakeRaw: bigint;
|
|
125
127
|
activeValidatorsCount: bigint;
|
|
126
128
|
epochMinDuration: bigint;
|
|
127
|
-
currentEpochStart: Date;
|
|
128
|
-
currentEpochEnd: Date | null;
|
|
129
129
|
nextEpochEstimate: Date | null;
|
|
130
|
-
inflation: string;
|
|
131
|
-
inflationRaw: bigint;
|
|
132
|
-
totalWeight: bigint;
|
|
133
|
-
totalClaimed: string;
|
|
134
|
-
totalClaimedRaw: bigint;
|
|
135
130
|
}
|
|
136
131
|
|
|
137
132
|
export interface StakingTransactionResult {
|
|
@@ -220,8 +215,10 @@ export interface StakingActions {
|
|
|
220
215
|
getValidatorInfo: (validator: Address) => Promise<ValidatorInfo>;
|
|
221
216
|
getStakeInfo: (delegator: Address, validator: Address) => Promise<StakeInfo>;
|
|
222
217
|
getEpochInfo: () => Promise<EpochInfo>;
|
|
218
|
+
getEpochData: (epochNumber: bigint) => Promise<EpochData>;
|
|
223
219
|
getActiveValidators: () => Promise<Address[]>;
|
|
224
220
|
getActiveValidatorsCount: () => Promise<bigint>;
|
|
221
|
+
getSlashingAddress: () => Promise<Address>;
|
|
225
222
|
getStakingContract: () => StakingContract;
|
|
226
223
|
parseStakingAmount: (amount: string | bigint) => bigint;
|
|
227
224
|
formatStakingAmount: (amount: bigint) => string;
|
|
@@ -153,6 +153,21 @@ export type DecodedCallData = {
|
|
|
153
153
|
type: TransactionType;
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
+
export interface LeaderReceipt {
|
|
157
|
+
calldata: string;
|
|
158
|
+
class_name: string;
|
|
159
|
+
contract_state: string;
|
|
160
|
+
eq_outputs: Record<string, unknown>;
|
|
161
|
+
error: string | null;
|
|
162
|
+
execution_result: string;
|
|
163
|
+
gas_used: number;
|
|
164
|
+
mode: string;
|
|
165
|
+
node_config: Record<string, unknown>;
|
|
166
|
+
pending_transactions: unknown[];
|
|
167
|
+
vote: string;
|
|
168
|
+
result: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
156
171
|
// TODO: make localnet compatible with testnet and unify the types
|
|
157
172
|
export type GenLayerTransaction = {
|
|
158
173
|
// currentTimestamp: testnet
|
|
@@ -243,20 +258,7 @@ export type GenLayerTransaction = {
|
|
|
243
258
|
// consensus_data: localnet // leader_receipt: testnet
|
|
244
259
|
consensus_data?: {
|
|
245
260
|
final: boolean;
|
|
246
|
-
leader_receipt?:
|
|
247
|
-
calldata: string;
|
|
248
|
-
class_name: string;
|
|
249
|
-
contract_state: string;
|
|
250
|
-
eq_outputs: Record<string, unknown>;
|
|
251
|
-
error: string | null;
|
|
252
|
-
execution_result: string;
|
|
253
|
-
gas_used: number;
|
|
254
|
-
mode: string;
|
|
255
|
-
node_config: Record<string, unknown>;
|
|
256
|
-
pending_transactions: unknown[];
|
|
257
|
-
vote: string;
|
|
258
|
-
result: string;
|
|
259
|
-
}[];
|
|
261
|
+
leader_receipt?: LeaderReceipt[];
|
|
260
262
|
validators?: Record<string, unknown>[];
|
|
261
263
|
votes?: Record<string, string>;
|
|
262
264
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// tests/smoke.test.ts
|
|
2
|
+
// Basic smoke tests to verify testnet chain configuration and connectivity
|
|
3
|
+
import {describe, it, expect} from "vitest";
|
|
4
|
+
import {testnetAsimov} from "@/chains/testnetAsimov";
|
|
5
|
+
import {createPublicClient, http} from "viem";
|
|
6
|
+
|
|
7
|
+
describe("Testnet Asimov Chain Config", () => {
|
|
8
|
+
it("should have valid RPC URL", () => {
|
|
9
|
+
const rpcUrl = testnetAsimov.rpcUrls.default.http[0];
|
|
10
|
+
expect(rpcUrl).toBe("https://zksync-os-testnet-genlayer.zksync.dev");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should have valid WebSocket URL", () => {
|
|
14
|
+
const wsUrl = testnetAsimov.rpcUrls.default.webSocket?.[0];
|
|
15
|
+
expect(wsUrl).toBe("wss://zksync-os-testnet-alpha.zksync.dev/ws");
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("should have consensus main contract address", () => {
|
|
19
|
+
expect(testnetAsimov.consensusMainContract?.address).toBe(
|
|
20
|
+
"0x6CAFF6769d70824745AD895663409DC70aB5B28E",
|
|
21
|
+
);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("should have consensus data contract address", () => {
|
|
25
|
+
expect(testnetAsimov.consensusDataContract?.address).toBe(
|
|
26
|
+
"0x0D9d1d74d72Fa5eB94bcf746C8FCcb312a722c9B",
|
|
27
|
+
);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("should have staking contract address", () => {
|
|
31
|
+
expect(testnetAsimov.stakingContract?.address).toBe(
|
|
32
|
+
"0x63Fa5E0bb10fb6fA98F44726C5518223F767687A",
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("should have correct chain ID", () => {
|
|
37
|
+
expect(testnetAsimov.id).toBe(0x107d);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("Testnet Asimov RPC Connectivity", () => {
|
|
42
|
+
it("should connect and fetch chain ID", async () => {
|
|
43
|
+
const client = createPublicClient({
|
|
44
|
+
chain: testnetAsimov,
|
|
45
|
+
transport: http(testnetAsimov.rpcUrls.default.http[0]),
|
|
46
|
+
});
|
|
47
|
+
const chainId = await client.getChainId();
|
|
48
|
+
expect(chainId).toBe(testnetAsimov.id);
|
|
49
|
+
}, 15000);
|
|
50
|
+
|
|
51
|
+
it("should fetch latest block number", async () => {
|
|
52
|
+
const client = createPublicClient({
|
|
53
|
+
chain: testnetAsimov,
|
|
54
|
+
transport: http(testnetAsimov.rpcUrls.default.http[0]),
|
|
55
|
+
});
|
|
56
|
+
const blockNumber = await client.getBlockNumber();
|
|
57
|
+
expect(blockNumber).toBeGreaterThan(0n);
|
|
58
|
+
}, 15000);
|
|
59
|
+
});
|