genlayer 0.38.11 → 0.38.12
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 +2 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/tests/smoke.test.ts +32 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -20078,7 +20078,7 @@ var require_cli_table3 = __commonJS({
|
|
|
20078
20078
|
import { program } from "commander";
|
|
20079
20079
|
|
|
20080
20080
|
// package.json
|
|
20081
|
-
var version = "0.38.
|
|
20081
|
+
var version = "0.38.12";
|
|
20082
20082
|
var package_default = {
|
|
20083
20083
|
name: "genlayer",
|
|
20084
20084
|
version,
|
package/package.json
CHANGED
package/tests/smoke.test.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {describe, it, expect, beforeAll} from "vitest";
|
|
2
|
-
import {createClient, parseStakingAmount, formatStakingAmount} from "genlayer-js";
|
|
2
|
+
import {createClient, parseStakingAmount, formatStakingAmount, abi} from "genlayer-js";
|
|
3
3
|
import {testnetAsimov, testnetBradbury} from "genlayer-js/chains";
|
|
4
4
|
import type {Address, GenLayerChain} from "genlayer-js/types";
|
|
5
|
+
import {createPublicClient, http} from "viem";
|
|
5
6
|
|
|
6
7
|
const TIMEOUT = 30_000;
|
|
7
8
|
|
|
@@ -120,6 +121,36 @@ describe(`Testnet ${name} - CLI Staking Smoke Tests`, () => {
|
|
|
120
121
|
}
|
|
121
122
|
}, TIMEOUT);
|
|
122
123
|
|
|
124
|
+
it("viem createPublicClient can call staking contract directly", async () => {
|
|
125
|
+
const rpcUrl = chain.rpcUrls.default.http[0];
|
|
126
|
+
const stakingAddress = chain.stakingContract?.address;
|
|
127
|
+
if (!stakingAddress) return;
|
|
128
|
+
|
|
129
|
+
// Use the same id-fix workaround as StakingAction (GenLayer RPC rejects id=0)
|
|
130
|
+
const publicClient = createPublicClient({
|
|
131
|
+
chain,
|
|
132
|
+
transport: http(rpcUrl, {
|
|
133
|
+
async fetchFn(url, init) {
|
|
134
|
+
if (init?.body) {
|
|
135
|
+
const body = JSON.parse(init.body as string);
|
|
136
|
+
if (body.id === 0) body.id = 1;
|
|
137
|
+
init = {...init, body: JSON.stringify(body)};
|
|
138
|
+
}
|
|
139
|
+
return fetch(url, init);
|
|
140
|
+
},
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const count = await publicClient.readContract({
|
|
145
|
+
address: stakingAddress as `0x${string}`,
|
|
146
|
+
abi: abi.STAKING_ABI,
|
|
147
|
+
functionName: "activeValidatorsCount",
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
expect(typeof count).toBe("bigint");
|
|
151
|
+
expect(count as bigint >= 0n).toBe(true);
|
|
152
|
+
}, TIMEOUT);
|
|
153
|
+
|
|
123
154
|
it("parseStakingAmount and formatStakingAmount round-trip", () => {
|
|
124
155
|
const parsed = parseStakingAmount("1.5gen");
|
|
125
156
|
expect(typeof parsed).toBe("bigint");
|