@monolythium/core-sdk 0.2.1 → 0.3.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.
@@ -1,2107 +0,0 @@
1
- import { JsonRpcApiProvider, Network, AbstractSigner } from 'ethers';
2
- import '@noble/hashes/blake3.js';
3
- import '@noble/post-quantum/ml-kem.js';
4
- import '@noble/ciphers/chacha.js';
5
- import '@noble/hashes/sha3.js';
6
- import '@noble/hashes/utils.js';
7
- import '@noble/post-quantum/ml-dsa.js';
8
-
9
- // src/ethers/provider.ts
10
-
11
- // src/address.ts
12
- var ADDRESS_KIND_HRPS = {
13
- user: "mono",
14
- smartAccount: "monos",
15
- contract: "monoc",
16
- cluster: "monok",
17
- multisig: "monom",
18
- systemModule: "monox"
19
- };
20
- var RESERVED_ADDRESS_HRPS = ["monor", "monop", "monoi", "monoa"];
21
- var CHARSET = "qpzry9x8gf2tvdw0s3jn54khce6mua7l";
22
- var CHARSET_MAP = new Map([...CHARSET].map((c, i) => [c, i]));
23
- var BECH32M_CONST = 734539939;
24
- var AddressError = class extends Error {
25
- constructor(message) {
26
- super(message);
27
- this.name = "AddressError";
28
- }
29
- };
30
- function addressBytesToHex(address) {
31
- const bytes = expectLength(address, 20, "address");
32
- return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
33
- }
34
- function typedBech32ToAddress(address, expectedKind) {
35
- const parsed = decodeBech32m(address);
36
- if (RESERVED_ADDRESS_HRPS.includes(parsed.hrp)) {
37
- throw new AddressError(`reserved address hrp '${parsed.hrp}'`);
38
- }
39
- const kind = addressKindFromHrp(parsed.hrp);
40
- if (kind === void 0) {
41
- throw new AddressError(`unknown address hrp '${parsed.hrp}'`);
42
- }
43
- if (expectedKind !== void 0 && kind !== expectedKind) {
44
- throw new AddressError(`unexpected hrp '${parsed.hrp}', expected '${ADDRESS_KIND_HRPS[expectedKind]}'`);
45
- }
46
- const bytes = convertBits(parsed.data, 5, 8);
47
- if (bytes.length !== 20) {
48
- throw new AddressError(`expected 20-byte payload, got ${bytes.length} bytes`);
49
- }
50
- const out = Uint8Array.from(bytes);
51
- return { kind, address: address.toLowerCase(), bytes: out, hex: addressBytesToHex(out) };
52
- }
53
- function requireTypedAddress(address, expectedKind, label = "address") {
54
- if (address.startsWith("0x") || address.startsWith("0X")) {
55
- throw new AddressError(
56
- `${label} raw 0x addresses are retired; use typed ${ADDRESS_KIND_HRPS[expectedKind]} bech32m addresses`
57
- );
58
- }
59
- try {
60
- return typedBech32ToAddress(address, expectedKind).address;
61
- } catch (err) {
62
- const message = err instanceof Error ? err.message : String(err);
63
- throw new AddressError(
64
- `${label} must be typed ${ADDRESS_KIND_HRPS[expectedKind]} bech32m address: ${message}`
65
- );
66
- }
67
- }
68
- function decodeBech32m(input) {
69
- if (input.length < 8) {
70
- throw new AddressError("bech32m address is too short");
71
- }
72
- const hasLower = input !== input.toUpperCase();
73
- const hasUpper = input !== input.toLowerCase();
74
- if (hasLower && hasUpper) {
75
- throw new AddressError("bech32m address cannot mix upper and lower case");
76
- }
77
- const s = input.toLowerCase();
78
- const sep = s.lastIndexOf("1");
79
- if (sep <= 0 || sep + 7 > s.length) {
80
- throw new AddressError("bech32m separator/checksum shape is invalid");
81
- }
82
- const hrp = s.slice(0, sep);
83
- const values = [];
84
- for (const c of s.slice(sep + 1)) {
85
- const v = CHARSET_MAP.get(c);
86
- if (v === void 0) {
87
- throw new AddressError(`invalid bech32m character '${c}'`);
88
- }
89
- values.push(v);
90
- }
91
- if (!verifyChecksum(hrp, values)) {
92
- throw new AddressError("bech32m checksum mismatch");
93
- }
94
- return { hrp, data: values.slice(0, -6) };
95
- }
96
- function addressKindFromHrp(hrp) {
97
- for (const [kind, kindHrp] of Object.entries(ADDRESS_KIND_HRPS)) {
98
- if (kindHrp === hrp) return kind;
99
- }
100
- return void 0;
101
- }
102
- function hrpExpand(hrp) {
103
- const high = [...hrp].map((c) => c.charCodeAt(0) >> 5);
104
- const low = [...hrp].map((c) => c.charCodeAt(0) & 31);
105
- return [...high, 0, ...low];
106
- }
107
- function polymod(values) {
108
- const generators = [996825010, 642813549, 513874426, 1027748829, 705979059];
109
- let chk = 1;
110
- for (const value of values) {
111
- const top = chk >> 25;
112
- chk = (chk & 33554431) << 5 ^ value;
113
- for (let i = 0; i < 5; i++) {
114
- if ((top >> i & 1) === 1) {
115
- chk ^= generators[i];
116
- }
117
- }
118
- }
119
- return chk >>> 0;
120
- }
121
- function verifyChecksum(hrp, values) {
122
- return polymod([...hrpExpand(hrp), ...values]) === BECH32M_CONST;
123
- }
124
- function convertBits(data, fromBits, toBits, pad) {
125
- let acc = 0;
126
- let bits = 0;
127
- const ret = [];
128
- const maxv = (1 << toBits) - 1;
129
- const maxAcc = (1 << fromBits + toBits - 1) - 1;
130
- for (const value of data) {
131
- if (value < 0 || value >> fromBits !== 0) {
132
- throw new AddressError("invalid address payload value");
133
- }
134
- acc = (acc << fromBits | value) & maxAcc;
135
- bits += fromBits;
136
- while (bits >= toBits) {
137
- bits -= toBits;
138
- ret.push(acc >> bits & maxv);
139
- }
140
- }
141
- if (bits >= fromBits || (acc << toBits - bits & maxv) !== 0) {
142
- throw new AddressError("invalid bech32m padding");
143
- }
144
- return ret;
145
- }
146
- function expectLength(value, len, name) {
147
- if (value.length !== len) {
148
- throw new AddressError(`${name} must be ${len} bytes`);
149
- }
150
- return value instanceof Uint8Array ? value : Uint8Array.from(value);
151
- }
152
-
153
- // src/error.ts
154
- var SdkError = class _SdkError extends Error {
155
- kind;
156
- code;
157
- data;
158
- constructor(kind, message, opts) {
159
- super(message, opts?.cause ? { cause: opts.cause } : void 0);
160
- this.name = "SdkError";
161
- this.kind = kind;
162
- this.code = opts?.code;
163
- this.data = opts?.data;
164
- }
165
- static transport(message, cause) {
166
- return new _SdkError("transport", message, { cause });
167
- }
168
- static rpc(code, message, data) {
169
- return new _SdkError("rpc", `rpc error ${code}: ${message}`, { code, data });
170
- }
171
- static malformed(message) {
172
- return new _SdkError("malformed", message);
173
- }
174
- static endpoint(message) {
175
- return new _SdkError("endpoint", message);
176
- }
177
- };
178
-
179
- // src/native-events.ts
180
- var NATIVE_MARKET_EVENT_FAMILY = "market";
181
- function nativeMarketEventFilter(filter = {}) {
182
- return { ...filter, family: NATIVE_MARKET_EVENT_FAMILY };
183
- }
184
- function isNativeDecodedEvent(value) {
185
- const row = asRecord(value);
186
- return row !== null && typeof row["block_height"] === "number" && typeof row["tx_index"] === "number" && typeof row["sequence"] === "number" && typeof row["family"] === "string" && typeof row["event_name"] === "string" && typeof row["payload_hash"] === "string";
187
- }
188
- function parseNativeDecodedEvent(event) {
189
- if (isNativeDecodedEvent(event.decoded)) {
190
- return event.decoded;
191
- }
192
- try {
193
- const parsed = JSON.parse(event.decodedJson);
194
- if (isNativeDecodedEvent(parsed)) {
195
- return parsed;
196
- }
197
- } catch {
198
- }
199
- throw SdkError.malformed(
200
- `native event ${event.eventTopic} at logIndex ${event.logIndex} is missing a typed decoded payload`
201
- );
202
- }
203
- function nativeEventMatches(event, filter = {}) {
204
- if (filter.address !== void 0 && event.address !== filter.address) return false;
205
- if (filter.eventTopic !== void 0 && event.eventTopic !== filter.eventTopic) return false;
206
- if (filter.family === void 0 && filter.eventName === void 0) return true;
207
- let decoded;
208
- try {
209
- decoded = parseNativeDecodedEvent(event);
210
- } catch {
211
- return false;
212
- }
213
- if (filter.family !== void 0 && decoded.family !== filter.family) return false;
214
- if (filter.eventName !== void 0 && decoded.event_name !== filter.eventName) return false;
215
- return true;
216
- }
217
- function nativeEventsFromReceipt(receipt, filter = {}) {
218
- return receipt.events.filter((event) => nativeEventMatches(event, filter)).map((event) => ({
219
- ...event,
220
- decoded: parseNativeDecodedEvent(event)
221
- }));
222
- }
223
- function nativeMarketEventsFromReceipt(receipt, filter = {}) {
224
- return nativeEventsFromReceipt(receipt, nativeMarketEventFilter(filter));
225
- }
226
- function nativeEventsFromHistory(response) {
227
- return {
228
- ...response,
229
- events: response.events.map((event) => ({
230
- ...event,
231
- decoded: parseNativeDecodedEvent(event)
232
- }))
233
- };
234
- }
235
- function nativeMarketEventsFromHistory(response) {
236
- return {
237
- ...response,
238
- filters: { ...response.filters, family: NATIVE_MARKET_EVENT_FAMILY },
239
- events: response.events.filter((event) => nativeEventMatches(event, { family: NATIVE_MARKET_EVENT_FAMILY })).map((event) => ({
240
- ...event,
241
- decoded: parseNativeDecodedEvent(event)
242
- }))
243
- };
244
- }
245
- function asRecord(value) {
246
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
247
- return value;
248
- }
249
- var SERVICE_PROBE_STATUS = {
250
- REACHABLE: 1,
251
- DEGRADED: 2,
252
- UNREACHABLE: 3
253
- };
254
- function isValidPublicServiceProbeMask(mask) {
255
- return Number.isInteger(mask) && mask > 0 && (mask & -284) === 0;
256
- }
257
- function isSinglePublicServiceProbeMask(mask) {
258
- return isValidPublicServiceProbeMask(mask) && bitCount(mask) === 1;
259
- }
260
- function isConcreteServiceProbeStatus(status) {
261
- return status === SERVICE_PROBE_STATUS.REACHABLE || status === SERVICE_PROBE_STATUS.DEGRADED || status === SERVICE_PROBE_STATUS.UNREACHABLE;
262
- }
263
- function bitCount(value) {
264
- let n = value >>> 0;
265
- let count = 0;
266
- while (n !== 0) {
267
- count += n & 1;
268
- n >>>= 1;
269
- }
270
- return count;
271
- }
272
- var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
273
- new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
274
-
275
- // src/crypto/envelope.ts
276
- new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
277
- var LYTH_DECIMALS = 8;
278
- var NATIVE_LYTH_DECIMALS = LYTH_DECIMALS;
279
- var LYTHOSHI_PER_LYTH = 100000000n;
280
- new TextEncoder().encode("MONO_MRV_CODE_V1");
281
- new TextEncoder().encode("mono:riscv:contract-address:v1");
282
- var SYSCALLS = [
283
- [257, "storage_read"],
284
- [258, "storage_write"],
285
- [259, "storage_delete"],
286
- [513, "caller"],
287
- [514, "contract_address"],
288
- [515, "block_height"],
289
- [516, "block_hash"],
290
- [769, "call_contract"],
291
- [770, "emit_event"],
292
- [771, "transfer_native"],
293
- [1025, "verify_signature"],
294
- [1026, "hash"],
295
- [1281, "revert"]
296
- ];
297
- new Map(SYSCALLS);
298
- new Map(SYSCALLS.map(([id, name]) => [name, id]));
299
- var MrvValidationError = class extends Error {
300
- constructor(message) {
301
- super(message);
302
- this.name = "MrvValidationError";
303
- }
304
- };
305
- var MRV_STRUCTURED_FEE_FIELDS = [
306
- "total_lythoshi",
307
- "cycles_used",
308
- "base_price_per_cycle_lythoshi",
309
- "state_io_units",
310
- "state_io_price_per_unit_lythoshi",
311
- "priority_tip_lythoshi"
312
- ];
313
- function formatLyth(lythoshi, options = {}) {
314
- const amount = BigInt(normalizeDecimalLike("lythoshi", lythoshi));
315
- const whole = amount / LYTHOSHI_PER_LYTH;
316
- const fraction = amount % LYTHOSHI_PER_LYTH;
317
- let formatted = formatWholeWithCommas(whole);
318
- if (fraction !== 0n) {
319
- formatted += `.${fraction.toString().padStart(NATIVE_LYTH_DECIMALS, "0").replace(/0+$/, "")}`;
320
- }
321
- if (options.includeUnit !== false) {
322
- formatted += " LYTH";
323
- }
324
- return formatted;
325
- }
326
- function parseLythToLythoshi(input) {
327
- const numeric = stripLythUnit(input);
328
- const parts = numeric.split(".");
329
- if (parts.length > 2) {
330
- throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
331
- }
332
- const [wholeRaw, fractionRaw = ""] = parts;
333
- if (!isCanonicalWholeLyth(wholeRaw)) {
334
- throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
335
- }
336
- if (numeric.includes(".") && fractionRaw.length === 0) {
337
- throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
338
- }
339
- if (fractionRaw.length > NATIVE_LYTH_DECIMALS || !/^[0-9]*$/.test(fractionRaw)) {
340
- throw new MrvValidationError("lyth amount supports at most 8 decimal places");
341
- }
342
- const whole = BigInt(wholeRaw.replaceAll(",", ""));
343
- const fraction = fractionRaw === "" ? 0n : BigInt(fractionRaw.padEnd(NATIVE_LYTH_DECIMALS, "0"));
344
- return whole * LYTHOSHI_PER_LYTH + fraction;
345
- }
346
- function checkMrvStructuredFeeConformance(value, options = {}) {
347
- const failures = [];
348
- const expectedTotalLythoshi = options.expectedTotalLythoshi === void 0 ? void 0 : normalizeDecimalLike("expectedTotalLythoshi", options.expectedTotalLythoshi);
349
- checkStructuredFeeObject(
350
- value,
351
- expectedTotalLythoshi,
352
- failures,
353
- options.label ?? "structuredFee"
354
- );
355
- return {
356
- passed: failures.length === 0,
357
- failures
358
- };
359
- }
360
- function assertMrvStructuredFeeConformance(value, options = {}) {
361
- const report = checkMrvStructuredFeeConformance(value, options);
362
- if (!report.passed) {
363
- throw new MrvValidationError(`structured fee conformance failed: ${report.failures.join("; ")}`);
364
- }
365
- }
366
- function formatWholeWithCommas(value) {
367
- const digits = value.toString();
368
- const firstGroupLen = digits.length % 3;
369
- const groups = [];
370
- let index = 0;
371
- if (firstGroupLen !== 0) {
372
- groups.push(digits.slice(0, firstGroupLen));
373
- index = firstGroupLen;
374
- }
375
- while (index < digits.length) {
376
- groups.push(digits.slice(index, index + 3));
377
- index += 3;
378
- }
379
- return groups.join(",");
380
- }
381
- function stripLythUnit(input) {
382
- const trimmed = input.trim();
383
- const withoutUnit = trimmed.replace(/\s+LYTH$/i, "").trim();
384
- if (withoutUnit.length === 0) {
385
- throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
386
- }
387
- return withoutUnit;
388
- }
389
- function isCanonicalWholeLyth(value) {
390
- if (/^(0|[1-9][0-9]*)$/.test(value)) {
391
- return true;
392
- }
393
- return /^[1-9][0-9]{0,2}(,[0-9]{3})+$/.test(value);
394
- }
395
- function checkStructuredFeeObject(value, expectedTotalLythoshi, failures, label = "structuredFee") {
396
- if (!isRecord(value)) {
397
- failures.push(`${label} must be an object`);
398
- return;
399
- }
400
- const expectedFields = /* @__PURE__ */ new Set([...MRV_STRUCTURED_FEE_FIELDS, "total_lyth"]);
401
- const actualFields = Object.keys(value);
402
- for (const field of MRV_STRUCTURED_FEE_FIELDS) {
403
- if (!(field in value)) failures.push(`${label} is missing '${field}'`);
404
- }
405
- for (const field of actualFields) {
406
- if (!expectedFields.has(field)) failures.push(`${label} has unexpected field '${field}'`);
407
- }
408
- const totalLythoshi = stringField(value, "total_lythoshi", failures, label);
409
- const expectedTotal = expectedTotalLythoshi ?? totalLythoshi;
410
- if (totalLythoshi !== void 0 && expectedTotalLythoshi !== void 0 && totalLythoshi !== expectedTotalLythoshi) {
411
- failures.push(`${label}.total_lythoshi must be ${expectedTotalLythoshi}`);
412
- }
413
- const totalLyth = "total_lyth" in value ? lythDecimalField(value, "total_lyth", failures, label) : void 0;
414
- if (totalLyth !== void 0 && expectedTotal !== void 0) {
415
- const expectedTotalLyth = formatLyth(expectedTotal, { includeUnit: false });
416
- if (totalLyth !== expectedTotalLyth) {
417
- failures.push(`${label}.total_lyth must be ${expectedTotalLyth}`);
418
- }
419
- }
420
- for (const field of [
421
- "base_price_per_cycle_lythoshi",
422
- "state_io_price_per_unit_lythoshi",
423
- "priority_tip_lythoshi"
424
- ]) {
425
- stringField(value, field, failures, label);
426
- }
427
- for (const field of ["cycles_used", "state_io_units"]) {
428
- integerField(value, field, failures, label);
429
- }
430
- }
431
- function isRecord(value) {
432
- return typeof value === "object" && value !== null && !Array.isArray(value);
433
- }
434
- function stringField(value, field, failures, label) {
435
- const fieldValue = value[field];
436
- if (typeof fieldValue !== "string" || !isCanonicalUnsignedDecimalString(fieldValue)) {
437
- failures.push(`${label}.${field} must be a canonical unsigned decimal string`);
438
- return void 0;
439
- }
440
- return fieldValue;
441
- }
442
- function lythDecimalField(value, field, failures, label) {
443
- const fieldValue = value[field];
444
- if (typeof fieldValue !== "string") {
445
- failures.push(`${label}.${field} must be a canonical LYTH decimal string`);
446
- return void 0;
447
- }
448
- try {
449
- parseLythToLythoshi(`${fieldValue} LYTH`);
450
- } catch {
451
- failures.push(`${label}.${field} must be a canonical LYTH decimal string`);
452
- return void 0;
453
- }
454
- return fieldValue;
455
- }
456
- function integerField(value, field, failures, label) {
457
- const fieldValue = value[field];
458
- if (typeof fieldValue !== "number" || !Number.isSafeInteger(fieldValue) || fieldValue < 0) {
459
- failures.push(`${label}.${field} must be a non-negative safe integer`);
460
- }
461
- }
462
- function isCanonicalUnsignedDecimalString(value) {
463
- if (!/^(0|[1-9][0-9]*)$/.test(value)) return false;
464
- try {
465
- BigInt(value);
466
- return true;
467
- } catch {
468
- return false;
469
- }
470
- }
471
- function normalizeDecimalLike(field, value, defaultValue) {
472
- if (value === void 0) {
473
- throw new MrvValidationError(`${field} is required`);
474
- }
475
- if (typeof value === "string") {
476
- validateDecimal(field, value);
477
- return value;
478
- }
479
- if (typeof value === "number" && !Number.isSafeInteger(value)) {
480
- throw new MrvValidationError(`${field} must be a safe unsigned integer`);
481
- }
482
- const out = BigInt(value);
483
- if (out < 0n) throw new MrvValidationError(`${field} must be a canonical unsigned decimal string`);
484
- return out.toString();
485
- }
486
- function validateDecimal(field, value) {
487
- if (!/^(0|[1-9][0-9]*)$/.test(value)) {
488
- throw new MrvValidationError(`${field} must be a canonical unsigned decimal string`);
489
- }
490
- try {
491
- BigInt(value);
492
- } catch {
493
- throw new MrvValidationError(`${field} must be a canonical unsigned decimal string`);
494
- }
495
- }
496
-
497
- // src/registry.ts
498
- var TESTNET_69420 = {
499
- chain_id: 69420,
500
- network: "testnet-69420",
501
- display_name: "Monolythium Testnet",
502
- description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
503
- genesis_hash: "0x325057e476b7be3730a22c92b9289f4a14a3414a2a081bd279b43eeba36b0075",
504
- binary_sha: "44a9ec4",
505
- rpc: [
506
- {
507
- url: "https://rpc.monolythium.com",
508
- provider: "monolythium",
509
- tier: "official"
510
- }
511
- ],
512
- p2p: []
513
- };
514
- var CHAIN_REGISTRY = {
515
- "testnet-69420": TESTNET_69420
516
- };
517
- function getChainInfo(network) {
518
- const info = CHAIN_REGISTRY[network];
519
- if (!info) {
520
- throw new Error(`unknown Monolythium network: ${network}`);
521
- }
522
- return info;
523
- }
524
-
525
- // src/types.ts
526
- function encodeBlockSelector(b) {
527
- if (typeof b === "number") return `0x${b.toString(16)}`;
528
- if (typeof b === "bigint") return `0x${b.toString(16)}`;
529
- return b;
530
- }
531
-
532
- // src/client.ts
533
- var SDK_VERSION = "0.1.0";
534
- var ETH_COMPAT_RPC_PREFIX = "eth_";
535
- var ethCompatMethod = (name) => `${ETH_COMPAT_RPC_PREFIX}${name}`;
536
- function resolveChainInfo(network, registry) {
537
- if (registry) {
538
- const info = registry[network];
539
- if (!info) {
540
- throw SdkError.endpoint(`unknown Monolythium network: ${network}`);
541
- }
542
- return info;
543
- }
544
- try {
545
- return getChainInfo(network);
546
- } catch (err) {
547
- throw SdkError.endpoint(err?.message ?? String(err));
548
- }
549
- }
550
- var RpcClient = class _RpcClient {
551
- endpoint;
552
- #fetch;
553
- #headers;
554
- #nextId;
555
- constructor(endpoint, options = {}) {
556
- if (!endpoint || endpoint.length === 0) {
557
- throw SdkError.endpoint("endpoint cannot be empty");
558
- }
559
- this.endpoint = endpoint;
560
- this.#fetch = options.fetch ?? globalThis.fetch.bind(globalThis);
561
- this.#headers = {
562
- "content-type": "application/json",
563
- "user-agent": `monolythium-core-sdk/${SDK_VERSION}`,
564
- ...options.headers ?? {}
565
- };
566
- this.#nextId = 1;
567
- }
568
- /**
569
- * Construct a client from the chain-registry network slug.
570
- *
571
- * Defaults to the SDK-bundled registry snapshot from
572
- * `monolythium/chain-registry`. Set `probe: true` to walk the
573
- * registry endpoints in order and return the first endpoint whose
574
- * `eth_chainId` matches the registry chain id.
575
- */
576
- static async forNetwork(network = "testnet-69420", options = {}) {
577
- const info = resolveChainInfo(network, options.registry);
578
- if (info.rpc.length === 0) {
579
- throw SdkError.endpoint(`network ${network} has no RPC endpoints`);
580
- }
581
- if (options.probe) {
582
- return this.fromFirstReachable(info, options);
583
- }
584
- return new _RpcClient(info.rpc[0].url, options);
585
- }
586
- /**
587
- * Walk a chain-registry entry in order and return the first endpoint
588
- * whose `eth_chainId` matches the registry `chain_id`.
589
- */
590
- static async fromFirstReachable(chain, options = {}) {
591
- const errors = [];
592
- for (const endpoint of chain.rpc) {
593
- const client = new _RpcClient(endpoint.url, options);
594
- try {
595
- const chainId = await client.ethChainId();
596
- if (chainId === BigInt(chain.chain_id)) {
597
- return client;
598
- }
599
- errors.push(`${endpoint.url}: chain id ${chainId} != ${chain.chain_id}`);
600
- } catch (err) {
601
- errors.push(`${endpoint.url}: ${err?.message ?? err}`);
602
- }
603
- }
604
- throw SdkError.endpoint(
605
- `no reachable RPC endpoint for ${chain.network}; tried ${errors.join("; ")}`
606
- );
607
- }
608
- /**
609
- * Send an arbitrary JSON-RPC method. Most callers should prefer the
610
- * typed wrappers below; this is the escape hatch for methods the
611
- * SDK does not yet wrap.
612
- */
613
- async call(method, params = []) {
614
- const id = this.#nextId++;
615
- const body = { jsonrpc: "2.0", id, method, params };
616
- let resp;
617
- try {
618
- resp = await this.#fetch(this.endpoint, {
619
- method: "POST",
620
- headers: this.#headers,
621
- body: JSON.stringify(body)
622
- });
623
- } catch (cause) {
624
- throw SdkError.transport(
625
- `transport failure calling ${method}: ${cause?.message ?? cause}`,
626
- cause
627
- );
628
- }
629
- let parsed;
630
- try {
631
- parsed = await resp.json();
632
- } catch (cause) {
633
- throw SdkError.malformed(
634
- `non-JSON response (HTTP ${resp.status}): ${cause?.message ?? cause}`
635
- );
636
- }
637
- if (parsed.error) {
638
- throw SdkError.rpc(parsed.error.code, parsed.error.message, parsed.error.data);
639
- }
640
- if (!("result" in parsed) || parsed.result === void 0) {
641
- if (!resp.ok) {
642
- throw SdkError.malformed(`HTTP ${resp.status} with no JSON-RPC result`);
643
- }
644
- throw SdkError.malformed("response is missing both `result` and `error`");
645
- }
646
- return parsed.result;
647
- }
648
- // ---- eth_* / net_* / web3_* ---------------------------------------
649
- /** `eth_chainId` — configured chain id. */
650
- async ethChainId() {
651
- return parseQuantityBig(await this.call("eth_chainId", []));
652
- }
653
- /** Compatibility block-height read. */
654
- async ethBlockNumber() {
655
- return parseQuantityBig(await this.call(ethCompatMethod("blockNumber"), []));
656
- }
657
- /** `eth_getBalance` — balance + Merkle proof envelope. */
658
- async ethGetBalance(address, block = "latest") {
659
- return this.call("eth_getBalance", [address, encodeBlockSelector(block)]);
660
- }
661
- /** `eth_getStorageAt` — storage word + Merkle proof. */
662
- async ethGetStorageAt(address, slot, block = "latest") {
663
- return this.call("eth_getStorageAt", [
664
- address,
665
- slot,
666
- encodeBlockSelector(block)
667
- ]);
668
- }
669
- /** `eth_getTransactionCount` — sender nonce. */
670
- async ethGetTransactionCount(address, block = "latest") {
671
- return parseQuantityBig(
672
- await this.call("eth_getTransactionCount", [
673
- address,
674
- encodeBlockSelector(block)
675
- ])
676
- );
677
- }
678
- /** `eth_getCode` — deployed bytecode (`0x` for an EOA, `0xfe` for a precompile). */
679
- async ethGetCode(address, block = "latest") {
680
- return this.call("eth_getCode", [address, encodeBlockSelector(block)]);
681
- }
682
- /** Compatibility block-header read by height/tag. */
683
- async ethGetBlockByNumber(block = "latest") {
684
- return normalizeBlockHeader(await this.call(ethCompatMethod("getBlockByNumber"), [encodeBlockSelector(block)]));
685
- }
686
- /** Compatibility block-header read by hash. */
687
- async ethGetBlockByHash(hash) {
688
- return normalizeBlockHeader(await this.call(ethCompatMethod("getBlockByHash"), [hash]));
689
- }
690
- /** `eth_getTransactionByHash` — fetch an included transaction by hash. */
691
- async ethGetTransactionByHash(txHash) {
692
- return this.call("eth_getTransactionByHash", [txHash]);
693
- }
694
- /** `eth_getTransactionReceipt` — receipt for a confirmed tx. */
695
- async ethGetTransactionReceipt(txHash) {
696
- return normalizeTransactionReceipt(await this.call("eth_getTransactionReceipt", [txHash]));
697
- }
698
- /** `eth_sendRawTransaction` — submit a signed raw tx. */
699
- async ethSendRawTransaction(rawTx) {
700
- return this.call("eth_sendRawTransaction", [rawTx]);
701
- }
702
- /** `eth_call` — dry-run a transaction. */
703
- async ethCall(request, block = "latest") {
704
- return this.call("eth_call", [request, encodeBlockSelector(block)]);
705
- }
706
- /** `eth_estimateGas` — gas estimate for a dry-run. */
707
- async ethEstimateGas(request, block = "latest") {
708
- return parseQuantityBig(
709
- await this.call("eth_estimateGas", [request, encodeBlockSelector(block)])
710
- );
711
- }
712
- /**
713
- * `eth_gasPrice` — legacy compatibility fee quote for ethers/viem shims.
714
- * Native v4.1 surfaces should use execution-unit and lythoshi fee fields.
715
- */
716
- async ethGasPrice() {
717
- return parseQuantityBig(await this.call("eth_gasPrice", []));
718
- }
719
- /** `eth_feeHistory` — base-fee + gas-used history. */
720
- async ethFeeHistory(blockCount, newestBlock = "latest", rewardPercentiles = []) {
721
- return this.call("eth_feeHistory", [
722
- `0x${blockCount.toString(16)}`,
723
- encodeBlockSelector(newestBlock),
724
- rewardPercentiles
725
- ]);
726
- }
727
- /** `eth_syncing` — `null` when caught up. */
728
- async ethSyncing() {
729
- const v = await this.call("eth_syncing", []);
730
- if (v === false || v === null || v === void 0) return null;
731
- return v;
732
- }
733
- /** `net_version` — chain id as a decimal string. */
734
- async netVersion() {
735
- return this.call("net_version", []);
736
- }
737
- /** `net_peerCount` — number of connected peers. */
738
- async netPeerCount() {
739
- return parseQuantityBig(await this.call("net_peerCount", []));
740
- }
741
- /** `net_listening` — whether the node accepts inbound peers. */
742
- async netListening() {
743
- return this.call("net_listening", []);
744
- }
745
- /** `web3_clientVersion` — server's client-version string. */
746
- async web3ClientVersion() {
747
- return this.call("web3_clientVersion", []);
748
- }
749
- /** `web3_sha3` — Keccak-256 of `data`. */
750
- async web3Sha3(data) {
751
- return this.call("web3_sha3", [data]);
752
- }
753
- // ---- lyth_* (Law §13.2 native namespace) --------------------------
754
- /** `lyth_listProviders` — paged registry enumeration. */
755
- async lythListProviders(capabilityMask, cursor = null, limit = 100) {
756
- return this.call("lyth_listProviders", [capabilityMask, cursor, limit]);
757
- }
758
- /** `lyth_getRegistration` — single registry lookup. */
759
- async lythGetRegistration(peerId) {
760
- return this.call("lyth_getRegistration", [peerId]);
761
- }
762
- /** `lyth_registryStateProof` — Merkle proof for a registry entry. */
763
- async lythRegistryStateProof(peerId) {
764
- return this.call("lyth_registryStateProof", [peerId]);
765
- }
766
- /** `lyth_getAccountPolicy` — privacy posture for an account. */
767
- async lythGetAccountPolicy(address) {
768
- return this.call("lyth_getAccountPolicy", [sdkTypedAddress(address, "user", "address")]);
769
- }
770
- /** `lyth_getAssetPolicy` — privacy posture for an asset. */
771
- async lythGetAssetPolicy(tokenId) {
772
- return this.call("lyth_getAssetPolicy", [tokenId]);
773
- }
774
- /** `lyth_getTokenBalances` — indexed per-asset balances for one address. */
775
- async lythGetTokenBalances(address) {
776
- return this.call("lyth_getTokenBalances", [sdkTypedAddress(address, "user", "address")]);
777
- }
778
- /** `lyth_bridgeRoutes` — read-only bridge route-selection/readiness. */
779
- async lythBridgeRoutes(request) {
780
- return this.call("lyth_bridgeRoutes", [request]);
781
- }
782
- /** `lyth_mrcMetadata` — exact current-state native MRC metadata lookup. */
783
- async lythMrcMetadata(assetId, tokenId) {
784
- const params = tokenId == null ? [assetId] : [assetId, tokenId];
785
- return this.call("lyth_mrcMetadata", params);
786
- }
787
- /** `lyth_mrcAccount` — exact current-state native MRC account lookup. */
788
- async lythMrcAccount(account, spendLimit) {
789
- const request = {
790
- account: sdkTypedAddress(account, "smartAccount", "account")
791
- };
792
- if (spendLimit != null) request.spendLimit = spendLimit;
793
- const params = request.spendLimit == null ? [request.account] : [request.account, request.spendLimit];
794
- return this.call("lyth_mrcAccount", params);
795
- }
796
- /** `lyth_mrcHolders` — top holders for a native MRC asset/token key. */
797
- async lythMrcHolders(standard, assetId, tokenId, limit) {
798
- return this.lythMrcHoldersScoped(standard, assetId, tokenId, limit);
799
- }
800
- /**
801
- * `lyth_mrcHolders` — top holders for a native MRC asset/vault key.
802
- *
803
- * This is the asset-scoped form used by MRC-4626 vault share balances.
804
- */
805
- async lythMrcAssetHolders(standard, assetId, limit) {
806
- return this.lythMrcHoldersScoped(standard, assetId, null, limit);
807
- }
808
- /** `lyth_mrcHolders` — top holders for MRC-4626 vault shares. */
809
- async lythMrc4626Holders(vaultId, limit) {
810
- return this.lythMrcAssetHolders("mrc4626", vaultId, limit);
811
- }
812
- async lythMrcHoldersScoped(standard, assetId, tokenId, limit) {
813
- const request = {
814
- standard,
815
- assetId,
816
- tokenId
817
- };
818
- if (limit != null) request.limit = limit;
819
- const params = request.limit == null ? [request.standard, request.assetId, request.tokenId] : [request.standard, request.assetId, request.tokenId, request.limit];
820
- return this.call("lyth_mrcHolders", params);
821
- }
822
- /** `lyth_getAddressLabel` — indexed display/category label for one address. */
823
- async lythGetAddressLabel(address) {
824
- const v = await this.call("lyth_getAddressLabel", [
825
- sdkTypedAddress(address, "user", "address")
826
- ]);
827
- if (v === null || v === void 0) return null;
828
- return v;
829
- }
830
- /** `lyth_getAddressActivity` — indexed per-address activity timeline. */
831
- async lythGetAddressActivity(address, limit = 50, cursor) {
832
- const userAddress = sdkTypedAddress(address, "user", "address");
833
- const params = cursor === void 0 ? [userAddress, limit] : [userAddress, limit, cursor];
834
- return this.call("lyth_getAddressActivity", params);
835
- }
836
- /** `lyth_addressActivityKind` — activity index coverage for one address. */
837
- async lythAddressActivityKind(address) {
838
- return this.call("lyth_addressActivityKind", [sdkTypedAddress(address, "user", "address")]);
839
- }
840
- /** `lyth_agentReputation` — reputation accumulators for an agent provider. */
841
- async lythAgentReputation(provider, categoryId = 0) {
842
- return this.call("lyth_agentReputation", [
843
- sdkTypedAddress(provider, "user", "provider address"),
844
- categoryId
845
- ]);
846
- }
847
- /** `lyth_decodeTx` — explorer-grade decoded transaction envelope. */
848
- async lythDecodeTx(txHash) {
849
- return this.call("lyth_decodeTx", [txHash]);
850
- }
851
- /** `lyth_nativeReceipt` — native RISC-V receipt metadata and typed native event rows. */
852
- async lythNativeReceipt(txHash) {
853
- return decodeNativeReceiptResponse(
854
- await this.call("lyth_nativeReceipt", [txHash])
855
- );
856
- }
857
- /**
858
- * Typed native event rows from `lyth_nativeReceipt`.
859
- *
860
- * This helper intentionally consumes the existing receipt RPC surface;
861
- * it does not require a separate `lyth_nativeEvents` node method.
862
- */
863
- async lythNativeReceiptEvents(txHash, filter = {}) {
864
- const receipt = await this.lythNativeReceipt(txHash);
865
- return nativeEventsFromReceipt(receipt, filter);
866
- }
867
- /** Typed native market event rows from `lyth_nativeReceipt`. */
868
- async lythNativeReceiptMarketEvents(txHash, filter = {}) {
869
- const receipt = await this.lythNativeReceipt(txHash);
870
- return nativeMarketEventsFromReceipt(receipt, filter);
871
- }
872
- /** `lyth_nativeEvents` — historical indexed native event rows. */
873
- async lythNativeEvents(filter) {
874
- return this.call("lyth_nativeEvents", [nativeEventsFilterParams(filter)]);
875
- }
876
- /** `lyth_nativeEvents` with decoded rows converted into a caller-selected type. */
877
- async lythNativeEventsTyped(filter) {
878
- const response = await this.lythNativeEvents(filter);
879
- return nativeEventsFromHistory(response);
880
- }
881
- /** `lyth_nativeEvents` restricted to native marketplace event rows. */
882
- async lythNativeMarketEvents(filter) {
883
- return this.lythNativeEvents({
884
- ...filter,
885
- family: "market"
886
- });
887
- }
888
- /** `lyth_nativeEvents` market rows with decoded rows converted into a caller-selected type. */
889
- async lythNativeMarketEventsTyped(filter) {
890
- const response = await this.lythNativeEvents({
891
- ...filter,
892
- family: "market"
893
- });
894
- return nativeMarketEventsFromHistory(response);
895
- }
896
- /** `lyth_nativeAgentState` — current-state native agent policy and escrow rows. */
897
- async lythNativeAgentState(filter = {}) {
898
- const response = await this.call("lyth_nativeAgentState", [
899
- nativeAgentStateFilterParams(filter)
900
- ]);
901
- return decodeNativeAgentStateResponse(response);
902
- }
903
- /** `lyth_nativeMarketState` — current-state native spot and NFT market rows. */
904
- async lythNativeMarketState(filter = {}) {
905
- return this.call("lyth_nativeMarketState", [nativeMarketStateFilterParams(filter)]);
906
- }
907
- /** `lyth_gapRecords` — retained ingestion/indexing gaps for a block range. */
908
- async lythGapRecords(fromBlock, toBlock) {
909
- return this.call("lyth_gapRecords", [
910
- encodeRpcU64Number(fromBlock, "fromBlock"),
911
- encodeRpcU64Number(toBlock, "toBlock")
912
- ]);
913
- }
914
- /** `lyth_dagParents` — parent vertices for a DAG round. */
915
- async lythDagParents(round) {
916
- return this.call("lyth_dagParents", [encodeRpcU64Number(round, "round")]);
917
- }
918
- /** `lyth_richList` — top holders for a token id. */
919
- async lythRichList(tokenId, limit) {
920
- const params = limit == null ? [tokenId] : [tokenId, limit];
921
- return this.call("lyth_richList", params);
922
- }
923
- /** `lyth_clobMarket` — live CLOB market metadata for a market id. */
924
- async lythClobMarket(marketId) {
925
- return this.call("lyth_clobMarket", [marketId]);
926
- }
927
- /** `lyth_clobMarkets` — CLOB markets observed through indexed trades. */
928
- async lythClobMarkets(limit) {
929
- const params = limit == null ? [] : [limit];
930
- return this.call("lyth_clobMarkets", params);
931
- }
932
- /** `lyth_clobTrades` — CLOB fills for one market. */
933
- async lythClobTrades(marketId, limit = 50, cursor) {
934
- const params = cursor === void 0 ? [marketId, limit] : [marketId, limit, cursor];
935
- return this.call("lyth_clobTrades", params);
936
- }
937
- /** `lyth_clobOhlc` — CLOB OHLC candles for a market over a block range. */
938
- async lythClobOhlc(marketId, fromBlock, toBlock, bucketBlocks) {
939
- const params = fromBlock == null && toBlock == null && bucketBlocks == null ? [marketId] : [
940
- marketId,
941
- fromBlock == null ? null : encodeRpcU64Number(fromBlock, "fromBlock"),
942
- toBlock == null ? null : encodeRpcU64Number(toBlock, "toBlock"),
943
- bucketBlocks == null ? null : encodeRpcU64Number(bucketBlocks, "bucketBlocks")
944
- ];
945
- return this.call("lyth_clobOhlc", params);
946
- }
947
- /** `lyth_clobOrderBook` — live CLOB depth from canonical state. */
948
- async lythClobOrderBook(marketId, levels) {
949
- const params = levels == null ? [marketId] : [marketId, levels];
950
- return this.call("lyth_clobOrderBook", params);
951
- }
952
- /** `lyth_txFeed` — paged global transaction feed. */
953
- async lythTxFeed(limit = 50, cursor) {
954
- const params = cursor === void 0 ? [limit] : [limit, cursor];
955
- return decodeTxFeedResponse(await this.call("lyth_txFeed", params));
956
- }
957
- /** `lyth_addressProfile` — live account + label + activity aggregate. */
958
- async lythAddressProfile(address) {
959
- return this.call("lyth_addressProfile", [sdkTypedAddress(address, "user", "address")]);
960
- }
961
- /** `lyth_addressFlow` — recent indexed address-flow aggregate. */
962
- async lythAddressFlow(address, limit = 250) {
963
- return this.call("lyth_addressFlow", [sdkTypedAddress(address, "user", "address"), limit]);
964
- }
965
- /** `lyth_search` — exact live resolver for hashes, addresses, blocks, and clusters. */
966
- async lythSearch(query, limit = 10) {
967
- return this.call("lyth_search", [query, limit]);
968
- }
969
- /** `lyth_chainStats` — compact live chain/indexer/mempool summary. */
970
- async lythChainStats() {
971
- return this.call("lyth_chainStats", []);
972
- }
973
- /** `lyth_mempoolStatus` — aggregate mempool snapshot. */
974
- async lythMempoolStatus() {
975
- return normalizeMempoolSnapshot(await this.call("lyth_mempoolStatus", []));
976
- }
977
- /** `lyth_mempoolPending` — pending txs for a sender. */
978
- async lythMempoolPending(sender) {
979
- return this.call("lyth_mempoolPending", [sdkTypedAddress(sender, "user", "sender")]);
980
- }
981
- /** `lyth_currentRound` — latest committed height. */
982
- async lythCurrentRound() {
983
- return normalizeRoundInfo(await this.call("lyth_currentRound", []));
984
- }
985
- /** `lyth_peerSummary` — public-safe aggregate peer-network diagnostics. */
986
- async lythPeerSummary() {
987
- return this.call("lyth_peerSummary", []);
988
- }
989
- /**
990
- * `lyth_listActivePrecompiles` — milestone-gated precompile catalogue
991
- * (OI-0170 / ADR-0015 §5).
992
- */
993
- async lythListActivePrecompiles(block = "latest") {
994
- return this.call("lyth_listActivePrecompiles", [encodeBlockSelector(block)]);
995
- }
996
- /** `lyth_capabilities` — address-keyed precompile capability map. */
997
- async lythCapabilities(block) {
998
- const params = block === void 0 ? [] : [encodeBlockSelector(block)];
999
- return normalizeCapabilitiesResponse(
1000
- await this.call("lyth_capabilities", params)
1001
- );
1002
- }
1003
- /**
1004
- * `lyth_operatorCapabilities` — node-level availability for operator UI
1005
- * and explorer surfaces.
1006
- */
1007
- async lythOperatorCapabilities() {
1008
- return this.call("lyth_operatorCapabilities", []);
1009
- }
1010
- /** `lyth_indexerStatus` — indexer status; `null` when disabled. */
1011
- async lythIndexerStatus() {
1012
- const v = await this.call("lyth_indexerStatus", []);
1013
- if (v === null || v === void 0) return null;
1014
- return v;
1015
- }
1016
- /** `lyth_getStorageProof` — batched Merkle proofs. */
1017
- async lythGetStorageProof(address, slots) {
1018
- return this.call("lyth_getStorageProof", [address, slots]);
1019
- }
1020
- /** `lyth_getDelegations` — wallet delegation rows at a block. */
1021
- async lythGetDelegations(wallet, block) {
1022
- const userWallet = sdkTypedAddress(wallet, "user", "wallet");
1023
- const params = block === void 0 ? [userWallet] : [userWallet, encodeBlockSelector(block)];
1024
- return this.call("lyth_getDelegations", params);
1025
- }
1026
- /** `lyth_pendingRewards` — wallet pending rewards at a block. */
1027
- async lythPendingRewards(wallet, block) {
1028
- const userWallet = sdkTypedAddress(wallet, "user", "wallet");
1029
- const params = block === void 0 ? [userWallet] : [userWallet, encodeBlockSelector(block)];
1030
- return this.call("lyth_pendingRewards", params);
1031
- }
1032
- /** `lyth_redemptionQueue` — wallet redemption tickets at a block. */
1033
- async lythRedemptionQueue(wallet, block) {
1034
- const userWallet = sdkTypedAddress(wallet, "user", "wallet");
1035
- const params = block === void 0 ? [userWallet] : [userWallet, encodeBlockSelector(block)];
1036
- return this.call("lyth_redemptionQueue", params);
1037
- }
1038
- /** `lyth_getDelegationHistory` — indexed per-wallet delegation event timeline. */
1039
- async lythGetDelegationHistory(wallet, limit = 50, cursor) {
1040
- const userWallet = sdkTypedAddress(wallet, "user", "wallet");
1041
- const params = cursor === void 0 ? [userWallet, limit] : [userWallet, limit, cursor];
1042
- return this.call("lyth_getDelegationHistory", params);
1043
- }
1044
- /** `lyth_getClusterDelegators` — delegator addresses for a cluster. */
1045
- async lythGetClusterDelegators(cluster, block) {
1046
- const params = block === void 0 ? [cluster] : [cluster, encodeBlockSelector(block)];
1047
- return this.call("lyth_getClusterDelegators", params);
1048
- }
1049
- /** `lyth_getDelegationCap` — active per-cluster cap at a block. */
1050
- async lythGetDelegationCap(block) {
1051
- const params = block === void 0 ? [] : [encodeBlockSelector(block)];
1052
- return this.call("lyth_getDelegationCap", params);
1053
- }
1054
- /** `lyth_getTpmAttestation` — TPM quote digest + EK id for a peer. */
1055
- async lythGetTpmAttestation(peerId, block) {
1056
- const params = block === void 0 ? [peerId] : [peerId, encodeBlockSelector(block)];
1057
- return this.call("lyth_getTpmAttestation", params);
1058
- }
1059
- /** `lyth_getClusterEntity` — entity flag for a cluster. */
1060
- async lythGetClusterEntity(cluster, block) {
1061
- const params = block === void 0 ? [cluster] : [cluster, encodeBlockSelector(block)];
1062
- return this.call("lyth_getClusterEntity", params);
1063
- }
1064
- /** `lyth_getEntityRatchet` — entity-ratchet snapshot at a block. */
1065
- async lythGetEntityRatchet(block) {
1066
- const params = block === void 0 ? [] : [encodeBlockSelector(block)];
1067
- return this.call("lyth_getEntityRatchet", params);
1068
- }
1069
- /** `lyth_operatorInfo` — canonical operator identity envelope. */
1070
- async lythOperatorInfo(operatorId) {
1071
- return normalizeOperatorInfo(await this.call("lyth_operatorInfo", [operatorId]));
1072
- }
1073
- /** `lyth_getServiceProbe` — latest external reachability report for one public service. */
1074
- async lythGetServiceProbe(peerId, serviceMask) {
1075
- assertHexBytes(peerId, 32, "peerId");
1076
- if (!isSinglePublicServiceProbeMask(serviceMask)) {
1077
- throw SdkError.malformed("serviceMask must contain exactly one public-service bit");
1078
- }
1079
- const value = await this.call("lyth_getServiceProbe", [peerId, serviceMask]);
1080
- if (value === null || value === void 0) return null;
1081
- return normalizeServiceProbe(value);
1082
- }
1083
- /** `lyth_reportServiceProbe` — submit a pre-signed public-service probe report. */
1084
- async lythReportServiceProbe(req) {
1085
- assertHexBytes(req.peerId, 32, "peerId");
1086
- if (!isValidPublicServiceProbeMask(req.serviceMask)) {
1087
- throw SdkError.malformed("serviceMask must name one or more public-service bits");
1088
- }
1089
- if (!isConcreteServiceProbeStatus(req.status)) {
1090
- throw SdkError.malformed("status must be reachable, degraded, or unreachable");
1091
- }
1092
- assertSafeUint32(req.latencyMs, "latencyMs");
1093
- assertHexBytes(req.probeDigest, 32, "probeDigest");
1094
- assertNonEmptyHex(req.signedRawTx, "signedRawTx");
1095
- return this.call("lyth_reportServiceProbe", [req]);
1096
- }
1097
- /** `lyth_clusterStatus` — canonical cluster status envelope. */
1098
- async lythClusterStatus(clusterId) {
1099
- return normalizeClusterStatus(await this.call("lyth_clusterStatus", [clusterId]));
1100
- }
1101
- /** `lyth_clusterDirectory` — paged public cluster directory. */
1102
- async lythClusterDirectory(page = 0, limit = 25) {
1103
- return normalizeClusterDirectoryPage(
1104
- await this.call("lyth_clusterDirectory", [page, limit])
1105
- );
1106
- }
1107
- /** `lyth_clusters` — alias for `lyth_clusterDirectory`. */
1108
- async lythClusters(page = 0, limit = 25) {
1109
- return normalizeClusterDirectoryPage(await this.call("lyth_clusters", [page, limit]));
1110
- }
1111
- /**
1112
- * `lyth_submitPendingChange` — operator-onboarding transport for the
1113
- * pending-change ledger. Server validates the envelope shape.
1114
- */
1115
- async lythSubmitPendingChange(envelope) {
1116
- return this.call("lyth_submitPendingChange", [envelope]);
1117
- }
1118
- /** `lyth_submitEncrypted` — submit a bincode-encoded encrypted envelope hex. */
1119
- async lythSubmitEncrypted(envelopeHex) {
1120
- return this.call("lyth_submitEncrypted", [envelopeHex]);
1121
- }
1122
- /** `lyth_getEncryptionKey` — cluster ML-KEM encapsulation key. */
1123
- async lythGetEncryptionKey() {
1124
- return this.call("lyth_getEncryptionKey", []);
1125
- }
1126
- /** `lyth_syncStatus` — DAG-sync driver snapshot. */
1127
- async lythSyncStatus() {
1128
- const v = await this.call("lyth_syncStatus", []);
1129
- if (v === null || v === void 0) return null;
1130
- return v;
1131
- }
1132
- /** `lyth_resolveOperatorAuthority` — operator id to authority index. */
1133
- async lythResolveOperatorAuthority(operatorId) {
1134
- return normalizeOperatorAuthority(
1135
- await this.call("lyth_resolveOperatorAuthority", [operatorId])
1136
- );
1137
- }
1138
- /** `lyth_signingActivity` — recent per-round signing participation. */
1139
- async lythSigningActivity(authorityIndex, limit) {
1140
- const params = limit == null ? [authorityIndex] : [authorityIndex, limit];
1141
- return normalizeSigningActivity(await this.call("lyth_signingActivity", params));
1142
- }
1143
- /** `lyth_upcomingDuties` — deterministic upcoming duty windows. */
1144
- async lythUpcomingDuties(authorityIndex, horizonRounds) {
1145
- const params = horizonRounds == null ? [authorityIndex] : [authorityIndex, horizonRounds];
1146
- return normalizeUpcomingDuties(await this.call("lyth_upcomingDuties", params));
1147
- }
1148
- /** `lyth_operatorRisk` — miss-rate and jail-status window. */
1149
- async lythOperatorRisk(authorityIndex, windowRounds) {
1150
- const params = windowRounds == null ? [authorityIndex] : [authorityIndex, windowRounds];
1151
- return normalizeOperatorRisk(await this.call("lyth_operatorRisk", params));
1152
- }
1153
- /** `lyth_upgradeStatus` — signed network-upgrade readiness at a height. */
1154
- async lythUpgradeStatus(block) {
1155
- const params = block === void 0 ? [] : [encodeBlockSelector(block)];
1156
- return this.call("lyth_upgradeStatus", params);
1157
- }
1158
- /** `lyth_runtimeProvenance` — public-safe build/runtime provenance. */
1159
- async lythRuntimeProvenance() {
1160
- return this.call("lyth_runtimeProvenance", []);
1161
- }
1162
- /** `lyth_txStatus` — discriminated transaction lookup outcome. */
1163
- async lythTxStatus(txHash) {
1164
- return this.call("lyth_txStatus", [txHash]);
1165
- }
1166
- /** `lyth_verticesAtRound` — per-vertex authorship observed at a DAG round. */
1167
- async lythVerticesAtRound(round) {
1168
- return this.call("lyth_verticesAtRound", [
1169
- encodeRpcU64Number(round, "round")
1170
- ]);
1171
- }
1172
- /** `lyth_metricsRange` — retained telemetry series when the node has them. */
1173
- async lythMetricsRange(selectors, range) {
1174
- const params = range === void 0 ? [selectors] : [
1175
- selectors,
1176
- range === null ? null : [
1177
- encodeRpcU64Number(range[0], "fromBlock"),
1178
- encodeRpcU64Number(range[1], "toBlock")
1179
- ]
1180
- ];
1181
- return this.call("lyth_metricsRange", params);
1182
- }
1183
- /** `lyth_getLatestCheckpoint` — latest PQ-finality checkpoint rows. */
1184
- async lythGetLatestCheckpoint(belowHeight) {
1185
- const params = belowHeight === void 0 ? [] : [encodeOptionalHeight(belowHeight)];
1186
- return this.call("lyth_getLatestCheckpoint", params);
1187
- }
1188
- /** `lyth_getClusterResignations` — in-flight + applied operator resignations. */
1189
- async lythGetClusterResignations(operator, status) {
1190
- const params = status === void 0 ? operator == null ? [] : [operator] : [operator ?? null, status];
1191
- return this.call("lyth_getClusterResignations", params);
1192
- }
1193
- /** `lyth_getBlsRoundCertificate` — round-advancement BLS aggregate. */
1194
- async lythGetBlsRoundCertificate(round) {
1195
- return this.call("lyth_getBlsRoundCertificate", [encodeRpcInteger(round)]);
1196
- }
1197
- /** `lyth_getLeaderCertificate` — leader-vote BLS aggregate for a block ref. */
1198
- async lythGetLeaderCertificate(round, authority, digest) {
1199
- return this.call("lyth_getLeaderCertificate", [encodeRpcInteger(round), authority, digest]);
1200
- }
1201
- /** `lyth_getDacCertificate` — data-availability certificate for a block ref. */
1202
- async lythGetDacCertificate(round, authority, digest) {
1203
- return this.call("lyth_getDacCertificate", [encodeRpcInteger(round), authority, digest]);
1204
- }
1205
- /** `lyth_subscribe` — WebSocket-only; returns an RPC error over HTTP. */
1206
- async lythSubscribe(channel) {
1207
- return this.call("lyth_subscribe", [channel]);
1208
- }
1209
- /** `lyth_unsubscribe` — counterpart to `lythSubscribe`. */
1210
- async lythUnsubscribe(subId) {
1211
- return this.call("lyth_unsubscribe", [subId]);
1212
- }
1213
- // ---- debug_* ------------------------------------------------------
1214
- // Server-side gated by `RpcConfig::debug_enabled`. When the namespace
1215
- // is disabled, every call surfaces as `SdkError.rpc`.
1216
- /** `debug_traceTransaction` — legacy compatibility trace for a confirmed tx. */
1217
- async debugTraceTransaction(txHash) {
1218
- return this.call("debug_traceTransaction", [txHash]);
1219
- }
1220
- /** `debug_traceCall` — legacy compatibility trace for a dry-run. */
1221
- async debugTraceCall(request, block = "latest") {
1222
- return this.call("debug_traceCall", [request, encodeBlockSelector(block)]);
1223
- }
1224
- /** `debug_traceBlockByNumber` — legacy compatibility traces for an entire block. */
1225
- async debugTraceBlockByNumber(block) {
1226
- return this.call("debug_traceBlockByNumber", [encodeBlockSelector(block)]);
1227
- }
1228
- /** `debug_mempoolDump` — full mempool snapshot. */
1229
- async debugMempoolDump() {
1230
- return normalizeMempoolSnapshot(await this.call("debug_mempoolDump", []));
1231
- }
1232
- /** `debug_p2pPeers` — connected libp2p peer list. */
1233
- async debugP2pPeers() {
1234
- return this.call("debug_p2pPeers", []);
1235
- }
1236
- /** `debug_stateDiff` — state-diff for a block range. */
1237
- async debugStateDiff(params) {
1238
- return this.call("debug_stateDiff", params);
1239
- }
1240
- /** `debug_chainReorg` — testnet-only reorg trigger. */
1241
- async debugChainReorg(params) {
1242
- return this.call("debug_chainReorg", params);
1243
- }
1244
- // ---- mesh_* -------------------------------------------------------
1245
- /** `mesh_buildUnsignedTx` — build an unsigned transaction envelope. */
1246
- async meshBuildUnsignedTx(intent) {
1247
- return this.call("mesh_buildUnsignedTx", [intent]);
1248
- }
1249
- /** `mesh_combineTx` — combine an unsigned envelope with a wallet signature. */
1250
- async meshCombineTx(unsignedTx, signatureHex, algo, pubkeyHex) {
1251
- const params = algo === void 0 ? [unsignedTx, signatureHex] : pubkeyHex === void 0 ? [unsignedTx, signatureHex, algo] : [unsignedTx, signatureHex, algo, pubkeyHex];
1252
- return this.call("mesh_combineTx", params);
1253
- }
1254
- /** `mesh_decodeTx` — decode a signed or unsigned mesh envelope. */
1255
- async meshDecodeTx(envelopeHex, signed = false) {
1256
- return this.call("mesh_decodeTx", [envelopeHex, signed]);
1257
- }
1258
- /** `mesh_submitTx` — submit a signed mesh envelope. */
1259
- async meshSubmitTx(signedTx) {
1260
- return this.call("mesh_submitTx", [signedTx]);
1261
- }
1262
- };
1263
- function parseQuantityBig(hex) {
1264
- if (!hex) return 0n;
1265
- const rest = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
1266
- if (rest.length === 0) return 0n;
1267
- if (!/^[0-9a-fA-F]+$/.test(rest)) {
1268
- throw SdkError.malformed(`invalid hex quantity: ${hex}`);
1269
- }
1270
- return BigInt(`0x${rest}`);
1271
- }
1272
- function encodeRpcInteger(v) {
1273
- if (typeof v === "bigint") return `0x${v.toString(16)}`;
1274
- return v;
1275
- }
1276
- function encodeOptionalHeight(v) {
1277
- if (v === null) return null;
1278
- return encodeRpcInteger(v);
1279
- }
1280
- function encodeRpcU64Number(v, label) {
1281
- return parseRpcNumber(v, label);
1282
- }
1283
- function nativeEventsFilterParams(filter) {
1284
- return {
1285
- fromBlock: encodeRpcU64Number(filter.fromBlock, "fromBlock"),
1286
- toBlock: encodeRpcU64Number(filter.toBlock, "toBlock"),
1287
- ...optionalRpcNumber("limit", filter.limit),
1288
- ...optionalRpcNumber("txIndex", filter.txIndex),
1289
- ...optionalRpcNumber("logIndex", filter.logIndex),
1290
- ...optionalString("address", filter.address),
1291
- ...optionalString("eventTopic", filter.eventTopic),
1292
- ...optionalString("family", filter.family),
1293
- ...optionalString("eventName", filter.eventName),
1294
- ...optionalString("primaryId", filter.primaryId),
1295
- ...optionalString("relatedId", filter.relatedId),
1296
- ...optionalString("tokenId", filter.tokenId),
1297
- ...optionalString("account", filter.account),
1298
- ...optionalString("counterparty", filter.counterparty)
1299
- };
1300
- }
1301
- function optionalRpcNumber(key, value) {
1302
- return value == null ? {} : { [key]: encodeRpcU64Number(value, key) };
1303
- }
1304
- function optionalString(key, value) {
1305
- return value == null ? {} : { [key]: value };
1306
- }
1307
- function parseRpcBigint(value, label) {
1308
- if (typeof value === "bigint") {
1309
- if (value < 0n) {
1310
- throw SdkError.malformed(`${label} must be a non-negative quantity`);
1311
- }
1312
- return value;
1313
- }
1314
- if (typeof value === "number") {
1315
- if (!Number.isSafeInteger(value) || value < 0) {
1316
- throw SdkError.malformed(`${label} must be a non-negative safe integer`);
1317
- }
1318
- return BigInt(value);
1319
- }
1320
- if (typeof value === "string") {
1321
- if (value.startsWith("0x") || value.startsWith("0X")) return parseQuantityBig(value);
1322
- if (/^\d+$/.test(value)) return BigInt(value);
1323
- }
1324
- throw SdkError.malformed(`${label} must be a bigint-compatible quantity`);
1325
- }
1326
- function parseRpcNumber(value, label) {
1327
- const big = parseRpcBigint(value, label);
1328
- if (big > BigInt(Number.MAX_SAFE_INTEGER)) {
1329
- throw SdkError.malformed(`${label} exceeds safe integer range`);
1330
- }
1331
- return Number(big);
1332
- }
1333
- function parseRpcNumberNullable(value, label) {
1334
- return value === null || value === void 0 ? null : parseRpcNumber(value, label);
1335
- }
1336
- function parseRpcBigintNullable(value, label) {
1337
- return value === null || value === void 0 ? null : parseRpcBigint(value, label);
1338
- }
1339
- function parseStringNullable(value) {
1340
- return value === null || value === void 0 ? null : String(value);
1341
- }
1342
- function parseStringField(value, label) {
1343
- if (value === null || value === void 0) {
1344
- throw SdkError.malformed(`${label} is missing`);
1345
- }
1346
- return String(value);
1347
- }
1348
- function parseBooleanField(value, label) {
1349
- if (typeof value !== "boolean") {
1350
- throw SdkError.malformed(`${label} must be a boolean`);
1351
- }
1352
- return value;
1353
- }
1354
- function parseRpcUint(value, label, max, typeName) {
1355
- const parsed = parseRpcNumber(value, label);
1356
- if (parsed > max) {
1357
- throw SdkError.malformed(`${label} must be a ${typeName}`);
1358
- }
1359
- return parsed;
1360
- }
1361
- function parseRpcUintNullable(value, label, max, typeName) {
1362
- return value === null || value === void 0 ? null : parseRpcUint(value, label, max, typeName);
1363
- }
1364
- function decodeNativeAgentStateArray(row, key, decode, defaultMissing) {
1365
- const value = row[key];
1366
- if (value === void 0 && defaultMissing) return [];
1367
- if (!Array.isArray(value)) {
1368
- throw SdkError.malformed(`native agent state ${key} must be an array`);
1369
- }
1370
- return value.map((item, index) => decode(item, `native agent state ${key}[${index}]`));
1371
- }
1372
- function decodeNativeAgentExistingStateRecord(value, label) {
1373
- return expectObject(value, label);
1374
- }
1375
- function decodeNativeAgentIssuerStateRecord(value, label) {
1376
- const row = expectObject(value, label);
1377
- return {
1378
- issuerId: parseStringField(row["issuerId"], `${label}.issuerId`),
1379
- issuer: parseStringField(row["issuer"], `${label}.issuer`),
1380
- nonce: parseRpcNumberNullable(row["nonce"], `${label}.nonce`),
1381
- metadataHash: parseStringNullable(row["metadataHash"]),
1382
- updatedAtBlock: parseRpcNumber(row["updatedAtBlock"], `${label}.updatedAtBlock`)
1383
- };
1384
- }
1385
- function decodeNativeAgentAttestationStateRecord(value, label) {
1386
- const row = expectObject(value, label);
1387
- return {
1388
- attestationId: parseStringField(row["attestationId"], `${label}.attestationId`),
1389
- nonce: parseRpcNumberNullable(row["nonce"], `${label}.nonce`),
1390
- issuerId: parseStringNullable(row["issuerId"]),
1391
- issuer: parseStringNullable(row["issuer"]),
1392
- subject: parseStringField(row["subject"], `${label}.subject`),
1393
- schemaHash: parseStringNullable(row["schemaHash"]),
1394
- payloadHash: parseStringNullable(row["payloadHash"]),
1395
- active: parseBooleanField(row["active"], `${label}.active`),
1396
- updatedAtBlock: parseRpcNumber(row["updatedAtBlock"], `${label}.updatedAtBlock`)
1397
- };
1398
- }
1399
- function decodeNativeAgentConsentStateRecord(value, label) {
1400
- const row = expectObject(value, label);
1401
- return {
1402
- consentId: parseStringField(row["consentId"], `${label}.consentId`),
1403
- subject: parseStringField(row["subject"], `${label}.subject`),
1404
- grantee: parseStringField(row["grantee"], `${label}.grantee`),
1405
- nonce: parseRpcNumberNullable(row["nonce"], `${label}.nonce`),
1406
- scopeHash: parseStringNullable(row["scopeHash"]),
1407
- expiresAt: parseRpcNumberNullable(row["expiresAt"], `${label}.expiresAt`),
1408
- active: parseBooleanField(row["active"], `${label}.active`),
1409
- updatedAtBlock: parseRpcNumber(row["updatedAtBlock"], `${label}.updatedAtBlock`)
1410
- };
1411
- }
1412
- function decodeNativeAgentServiceStateRecord(value, label) {
1413
- const row = expectObject(value, label);
1414
- return {
1415
- serviceId: parseStringField(row["serviceId"], `${label}.serviceId`),
1416
- provider: parseStringField(row["provider"], `${label}.provider`),
1417
- nonce: parseRpcNumberNullable(row["nonce"], `${label}.nonce`),
1418
- categoryHash: parseStringNullable(row["categoryHash"]),
1419
- metadataHash: parseStringNullable(row["metadataHash"]),
1420
- active: parseBooleanField(row["active"], `${label}.active`),
1421
- updatedAtBlock: parseRpcNumber(row["updatedAtBlock"], `${label}.updatedAtBlock`)
1422
- };
1423
- }
1424
- function decodeNativeAgentAvailabilityStateRecord(value, label) {
1425
- const row = expectObject(value, label);
1426
- return {
1427
- provider: parseStringField(row["provider"], `${label}.provider`),
1428
- maxConcurrent: parseRpcUint(row["maxConcurrent"], `${label}.maxConcurrent`, 4294967295, "uint32"),
1429
- openRequests: parseRpcUint(row["openRequests"], `${label}.openRequests`, 4294967295, "uint32"),
1430
- paused: parseBooleanField(row["paused"], `${label}.paused`),
1431
- updatedAtBlock: parseRpcNumber(row["updatedAtBlock"], `${label}.updatedAtBlock`)
1432
- };
1433
- }
1434
- function decodeNativeAgentArbiterStateRecord(value, label) {
1435
- const row = expectObject(value, label);
1436
- return {
1437
- arbiterId: parseStringField(row["arbiterId"], `${label}.arbiterId`),
1438
- arbiter: parseStringField(row["arbiter"], `${label}.arbiter`),
1439
- nonce: parseRpcNumberNullable(row["nonce"], `${label}.nonce`),
1440
- tier: parseRpcUintNullable(row["tier"], `${label}.tier`, 65535, "uint16"),
1441
- metadataHash: parseStringNullable(row["metadataHash"]),
1442
- updatedAtBlock: parseRpcNumber(row["updatedAtBlock"], `${label}.updatedAtBlock`)
1443
- };
1444
- }
1445
- function decodeNativeAgentReputationReviewStateRecord(value, label) {
1446
- const row = expectObject(value, label);
1447
- return {
1448
- reviewId: parseStringField(row["reviewId"], `${label}.reviewId`),
1449
- reviewer: parseStringField(row["reviewer"], `${label}.reviewer`),
1450
- subject: parseStringField(row["subject"], `${label}.subject`),
1451
- categoryId: parseRpcUint(row["categoryId"], `${label}.categoryId`, 4294967295, "uint32"),
1452
- speedScore: parseRpcUint(row["speedScore"], `${label}.speedScore`, 255, "uint8"),
1453
- qualityScore: parseRpcUint(row["qualityScore"], `${label}.qualityScore`, 255, "uint8"),
1454
- communicationScore: parseRpcUint(
1455
- row["communicationScore"],
1456
- `${label}.communicationScore`,
1457
- 255,
1458
- "uint8"
1459
- ),
1460
- accuracyScore: parseRpcUint(row["accuracyScore"], `${label}.accuracyScore`, 255, "uint8"),
1461
- payloadHash: parseStringNullable(row["payloadHash"]),
1462
- updatedAtBlock: parseRpcNumber(row["updatedAtBlock"], `${label}.updatedAtBlock`)
1463
- };
1464
- }
1465
- function expectObject(value, label) {
1466
- if (!value || typeof value !== "object" || Array.isArray(value)) {
1467
- throw SdkError.malformed(`${label} must be an object`);
1468
- }
1469
- return value;
1470
- }
1471
- function decodeNativeReceiptResponse(value) {
1472
- const row = expectObject(value, "native receipt response");
1473
- assertNativeReceiptFee(row["fee"], "native receipt response.fee");
1474
- return value;
1475
- }
1476
- function decodeTxFeedResponse(value) {
1477
- const row = expectObject(value, "tx feed response");
1478
- const transactions = row["transactions"];
1479
- if (!Array.isArray(transactions)) {
1480
- throw SdkError.malformed("tx feed response.transactions must be an array");
1481
- }
1482
- transactions.forEach((transaction, index) => {
1483
- const tx = expectObject(transaction, `tx feed response.transactions[${index}]`);
1484
- assertNativeReceiptFee(tx["fee"], `tx feed response.transactions[${index}].fee`);
1485
- });
1486
- return value;
1487
- }
1488
- function assertNativeReceiptFee(value, label) {
1489
- try {
1490
- assertMrvStructuredFeeConformance(value, { label });
1491
- } catch (err) {
1492
- const message = err instanceof Error ? err.message : String(err);
1493
- throw SdkError.malformed(`structured native fee violation: ${message}`);
1494
- }
1495
- }
1496
- function firstField(row, keys, label) {
1497
- for (const key of keys) {
1498
- if (row[key] !== void 0) return row[key];
1499
- }
1500
- throw SdkError.malformed(`${label} is missing (${keys.join(" | ")})`);
1501
- }
1502
- function normalizeServiceProbe(value) {
1503
- const row = expectObject(value, "service probe response");
1504
- return {
1505
- serviceMask: parseRpcNumber(row["serviceMask"], "service probe serviceMask"),
1506
- status: String(row["status"]),
1507
- statusCode: parseRpcNumber(row["statusCode"], "service probe statusCode"),
1508
- lastProbeBlock: parseRpcNumber(row["lastProbeBlock"], "service probe lastProbeBlock"),
1509
- latencyMs: parseRpcNumber(row["latencyMs"], "service probe latencyMs"),
1510
- probeDigest: String(row["probeDigest"]),
1511
- reporter: String(row["reporter"])
1512
- };
1513
- }
1514
- function assertSafeUint32(value, label) {
1515
- if (!Number.isInteger(value) || value < 0 || value > 4294967295) {
1516
- throw SdkError.malformed(`${label} must be a uint32`);
1517
- }
1518
- }
1519
- function assertHexBytes(value, expectedLen, label) {
1520
- const body = hexBody(value, label);
1521
- if (body.length !== expectedLen * 2) {
1522
- throw SdkError.malformed(`${label} must be ${expectedLen} bytes`);
1523
- }
1524
- }
1525
- function assertNonEmptyHex(value, label) {
1526
- const body = hexBody(value, label);
1527
- if (body.length === 0) {
1528
- throw SdkError.malformed(`${label} must be non-empty`);
1529
- }
1530
- }
1531
- function hexBody(value, label) {
1532
- const body = value.startsWith("0x") || value.startsWith("0X") ? value.slice(2) : value;
1533
- if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
1534
- throw SdkError.malformed(`${label} must be hex bytes`);
1535
- }
1536
- return body;
1537
- }
1538
- function normalizeOperatorInfo(value) {
1539
- const row = expectObject(value, "operator info response");
1540
- const activeClusterIds = row["activeClusterIds"];
1541
- if (!Array.isArray(activeClusterIds)) {
1542
- throw SdkError.malformed("operator info activeClusterIds must be an array");
1543
- }
1544
- const capability = row["capability"];
1545
- return {
1546
- operatorId: String(row["operatorId"]),
1547
- moniker: parseStringNullable(row["moniker"]),
1548
- alias: parseStringNullable(row["alias"]),
1549
- chainAddress: String(row["chainAddress"]),
1550
- bonded: Boolean(row["bonded"]),
1551
- commissionBps: parseRpcNumberNullable(row["commissionBps"], "operator info commissionBps"),
1552
- delegationCount: parseRpcNumberNullable(
1553
- row["delegationCount"],
1554
- "operator info delegationCount"
1555
- ),
1556
- bondedAmount: String(row["bondedAmount"]),
1557
- activeClusterIds: activeClusterIds.map(
1558
- (v, i) => parseRpcNumber(v, `operator info activeClusterIds[${i}]`)
1559
- ),
1560
- operatorKeyFingerprint: parseStringNullable(row["operatorKeyFingerprint"]),
1561
- blsKeyFingerprint: parseStringNullable(row["blsKeyFingerprint"]),
1562
- lifecycleState: String(row["lifecycleState"]),
1563
- capability: capability && typeof capability === "object" && !Array.isArray(capability) ? capability : {}
1564
- };
1565
- }
1566
- function normalizeClusterMember(value, label) {
1567
- const row = expectObject(value, label);
1568
- return {
1569
- operatorId: String(row["operatorId"]),
1570
- blsPubkey: String(row["blsPubkey"]),
1571
- state: String(row["state"])
1572
- };
1573
- }
1574
- function normalizeClusterStatus(value) {
1575
- const row = expectObject(value, "cluster status response");
1576
- const members = row["members"];
1577
- if (!Array.isArray(members)) {
1578
- throw SdkError.malformed("cluster status members must be an array");
1579
- }
1580
- return {
1581
- clusterId: parseRpcNumber(row["clusterId"], "cluster status clusterId"),
1582
- threshold: parseRpcNumber(row["threshold"], "cluster status threshold"),
1583
- size: parseRpcNumber(row["size"], "cluster status size"),
1584
- live: parseRpcNumber(row["live"], "cluster status live"),
1585
- lagging: parseRpcNumber(row["lagging"], "cluster status lagging"),
1586
- offline: parseRpcNumber(row["offline"], "cluster status offline"),
1587
- maintenance: parseRpcNumber(row["maintenance"], "cluster status maintenance"),
1588
- members: members.map((member, i) => normalizeClusterMember(member, `cluster status members[${i}]`)),
1589
- epoch: parseRpcBigintNullable(row["epoch"], "cluster status epoch"),
1590
- round: parseRpcBigintNullable(row["round"], "cluster status round"),
1591
- quorum: String(row["quorum"]),
1592
- reputationScore: parseRpcNumberNullable(
1593
- row["reputationScore"],
1594
- "cluster status reputationScore"
1595
- ),
1596
- livenessScore: parseRpcNumberNullable(row["livenessScore"], "cluster status livenessScore"),
1597
- lastUpdateHeight: parseRpcBigint(row["lastUpdateHeight"], "cluster status lastUpdateHeight")
1598
- };
1599
- }
1600
- function normalizeClusterDirectoryEntry(value, label) {
1601
- const row = expectObject(value, label);
1602
- const regionDiversity = row["regionDiversity"];
1603
- if (regionDiversity !== null && regionDiversity !== void 0 && !Array.isArray(regionDiversity)) {
1604
- throw SdkError.malformed(`${label}.regionDiversity must be an array or null`);
1605
- }
1606
- return {
1607
- clusterId: parseRpcNumber(row["clusterId"], `${label}.clusterId`),
1608
- size: parseRpcNumber(row["size"], `${label}.size`),
1609
- threshold: parseRpcNumber(row["threshold"], `${label}.threshold`),
1610
- aggregateHealth: String(row["aggregateHealth"]),
1611
- regionDiversity: Array.isArray(regionDiversity) ? regionDiversity.map(String) : null,
1612
- active: Boolean(row["active"])
1613
- };
1614
- }
1615
- function normalizeClusterDirectoryPage(value) {
1616
- const row = expectObject(value, "cluster directory response");
1617
- const clusters = row["clusters"];
1618
- if (!Array.isArray(clusters)) {
1619
- throw SdkError.malformed("cluster directory clusters must be an array");
1620
- }
1621
- return {
1622
- page: parseRpcNumber(row["page"], "cluster directory page"),
1623
- limit: parseRpcNumber(row["limit"], "cluster directory limit"),
1624
- totalClusters: parseRpcNumber(row["totalClusters"], "cluster directory totalClusters"),
1625
- clusters: clusters.map(
1626
- (cluster, i) => normalizeClusterDirectoryEntry(cluster, `cluster directory clusters[${i}]`)
1627
- )
1628
- };
1629
- }
1630
- function normalizeOperatorAuthority(value) {
1631
- const row = expectObject(value, "operator authority response");
1632
- return {
1633
- schemaVersion: parseRpcNumber(row["schemaVersion"], "operator authority schemaVersion"),
1634
- operatorId: String(row["operatorId"]),
1635
- authorityIndex: parseRpcNumber(row["authorityIndex"], "operator authority authorityIndex"),
1636
- blsPubkey: String(row["blsPubkey"]),
1637
- active: Boolean(row["active"])
1638
- };
1639
- }
1640
- function normalizeSigningActivity(value) {
1641
- const row = expectObject(value, "signing activity response");
1642
- const entries = row["entries"];
1643
- if (!Array.isArray(entries)) {
1644
- throw SdkError.malformed("signing activity entries must be an array");
1645
- }
1646
- return {
1647
- schemaVersion: parseRpcNumber(row["schemaVersion"], "signing activity schemaVersion"),
1648
- authorityIndex: parseRpcNumber(row["authorityIndex"], "signing activity authorityIndex"),
1649
- currentRound: parseRpcBigint(row["currentRound"], "signing activity currentRound"),
1650
- limit: parseRpcNumber(row["limit"], "signing activity limit"),
1651
- entries: entries.map((entry, i) => {
1652
- const e = expectObject(entry, `signing activity entries[${i}]`);
1653
- return {
1654
- round: parseRpcBigint(e["round"], `signing activity entries[${i}].round`),
1655
- status: String(e["status"])
1656
- };
1657
- })
1658
- };
1659
- }
1660
- function normalizeDutyAbsence(value, label) {
1661
- const row = expectObject(value, label);
1662
- return { reason: String(row["reason"]) };
1663
- }
1664
- function normalizeKeyRotationWindow(value) {
1665
- const row = expectObject(value, "upcoming duties keyRotation");
1666
- if ("nextRound" in row) {
1667
- return {
1668
- nextRound: parseRpcBigint(row["nextRound"], "upcoming duties keyRotation.nextRound"),
1669
- epochLengthRounds: parseRpcBigint(
1670
- row["epochLengthRounds"],
1671
- "upcoming duties keyRotation.epochLengthRounds"
1672
- )
1673
- };
1674
- }
1675
- return { reason: String(row["reason"]) };
1676
- }
1677
- function normalizeUpcomingDuties(value) {
1678
- const row = expectObject(value, "upcoming duties response");
1679
- const duties = expectObject(row["duties"], "upcoming duties duties");
1680
- const attestation = expectObject(duties["attestation"], "upcoming duties attestation");
1681
- return {
1682
- schemaVersion: parseRpcNumber(row["schemaVersion"], "upcoming duties schemaVersion"),
1683
- authorityIndex: parseRpcNumber(row["authorityIndex"], "upcoming duties authorityIndex"),
1684
- currentRound: parseRpcBigint(row["currentRound"], "upcoming duties currentRound"),
1685
- horizonRounds: parseRpcNumber(row["horizonRounds"], "upcoming duties horizonRounds"),
1686
- duties: {
1687
- attestation: {
1688
- startRound: parseRpcBigint(attestation["startRound"], "upcoming duties attestation.startRound"),
1689
- endRound: parseRpcBigint(attestation["endRound"], "upcoming duties attestation.endRound"),
1690
- kind: String(attestation["kind"])
1691
- },
1692
- blockProduction: normalizeDutyAbsence(
1693
- duties["blockProduction"],
1694
- "upcoming duties blockProduction"
1695
- ),
1696
- sync: normalizeDutyAbsence(duties["sync"], "upcoming duties sync"),
1697
- keyRotation: normalizeKeyRotationWindow(duties["keyRotation"])
1698
- }
1699
- };
1700
- }
1701
- function normalizeJailStatus(value) {
1702
- const row = expectObject(value, "operator risk jailStatus");
1703
- if ("jailed" in row || "tombstoned" in row) {
1704
- return {
1705
- jailed: Boolean(row["jailed"]),
1706
- tombstoned: Boolean(row["tombstoned"]),
1707
- jailedUntilHeight: parseRpcBigint(
1708
- row["jailedUntilHeight"],
1709
- "operator risk jailStatus.jailedUntilHeight"
1710
- ),
1711
- unjailCount: parseRpcBigint(row["unjailCount"], "operator risk jailStatus.unjailCount")
1712
- };
1713
- }
1714
- return { reason: String(row["reason"]) };
1715
- }
1716
- function normalizeOperatorRisk(value) {
1717
- const row = expectObject(value, "operator risk response");
1718
- const reasons = row["reasons"];
1719
- if (!Array.isArray(reasons)) {
1720
- throw SdkError.malformed("operator risk reasons must be an array");
1721
- }
1722
- return {
1723
- schemaVersion: parseRpcNumber(row["schemaVersion"], "operator risk schemaVersion"),
1724
- authorityIndex: parseRpcNumber(row["authorityIndex"], "operator risk authorityIndex"),
1725
- dataHeight: parseRpcBigint(row["dataHeight"], "operator risk dataHeight"),
1726
- windowRounds: parseRpcNumber(row["windowRounds"], "operator risk windowRounds"),
1727
- missedRounds: parseRpcNumber(row["missedRounds"], "operator risk missedRounds"),
1728
- observedRounds: parseRpcNumber(row["observedRounds"], "operator risk observedRounds"),
1729
- missRateBps: parseRpcNumber(row["missRateBps"], "operator risk missRateBps"),
1730
- thresholdBps: parseRpcNumber(row["thresholdBps"], "operator risk thresholdBps"),
1731
- remainingHeadroomBps: parseRpcNumber(
1732
- row["remainingHeadroomBps"],
1733
- "operator risk remainingHeadroomBps"
1734
- ),
1735
- jailStatus: normalizeJailStatus(row["jailStatus"]),
1736
- reasons: reasons.map(String)
1737
- };
1738
- }
1739
- function nativeAgentStateFilterParams(filter) {
1740
- const out = {};
1741
- if (filter.policyId != null) out.policyId = filter.policyId;
1742
- if (filter.escrowId != null) out.escrowId = filter.escrowId;
1743
- if (filter.account != null) out.account = filter.account;
1744
- if (filter.includePolicySpends != null) out.includePolicySpends = filter.includePolicySpends;
1745
- if (filter.limit != null) out.limit = encodeRpcU64Number(filter.limit, "limit");
1746
- return out;
1747
- }
1748
- function decodeNativeAgentStateResponse(value) {
1749
- const row = expectObject(value, "native agent state response");
1750
- return {
1751
- schemaVersion: parseRpcNumber(row["schemaVersion"], "native agent state schemaVersion"),
1752
- limit: parseRpcNumber(row["limit"], "native agent state limit"),
1753
- filters: expectObject(
1754
- row["filters"],
1755
- "native agent state filters"
1756
- ),
1757
- issuers: decodeNativeAgentStateArray(
1758
- row,
1759
- "issuers",
1760
- decodeNativeAgentIssuerStateRecord,
1761
- true
1762
- ),
1763
- attestations: decodeNativeAgentStateArray(
1764
- row,
1765
- "attestations",
1766
- decodeNativeAgentAttestationStateRecord,
1767
- true
1768
- ),
1769
- consents: decodeNativeAgentStateArray(
1770
- row,
1771
- "consents",
1772
- decodeNativeAgentConsentStateRecord,
1773
- true
1774
- ),
1775
- services: decodeNativeAgentStateArray(
1776
- row,
1777
- "services",
1778
- decodeNativeAgentServiceStateRecord,
1779
- true
1780
- ),
1781
- availability: decodeNativeAgentStateArray(
1782
- row,
1783
- "availability",
1784
- decodeNativeAgentAvailabilityStateRecord,
1785
- true
1786
- ),
1787
- arbiters: decodeNativeAgentStateArray(
1788
- row,
1789
- "arbiters",
1790
- decodeNativeAgentArbiterStateRecord,
1791
- true
1792
- ),
1793
- reputationReviews: decodeNativeAgentStateArray(
1794
- row,
1795
- "reputationReviews",
1796
- decodeNativeAgentReputationReviewStateRecord,
1797
- true
1798
- ),
1799
- spendingPolicies: decodeNativeAgentStateArray(
1800
- row,
1801
- "spendingPolicies",
1802
- decodeNativeAgentExistingStateRecord,
1803
- false
1804
- ),
1805
- policySpends: decodeNativeAgentStateArray(
1806
- row,
1807
- "policySpends",
1808
- decodeNativeAgentExistingStateRecord,
1809
- false
1810
- ),
1811
- escrows: decodeNativeAgentStateArray(
1812
- row,
1813
- "escrows",
1814
- decodeNativeAgentExistingStateRecord,
1815
- false
1816
- ),
1817
- source: expectObject(
1818
- row["source"],
1819
- "native agent state source"
1820
- )
1821
- };
1822
- }
1823
- function nativeMarketStateFilterParams(filter) {
1824
- const out = {};
1825
- if (filter.marketId != null) out.marketId = filter.marketId;
1826
- if (filter.orderId != null) out.orderId = filter.orderId;
1827
- if (filter.listingId != null) out.listingId = filter.listingId;
1828
- if (filter.collectionId != null) out.collectionId = filter.collectionId;
1829
- if (filter.account != null) out.account = filter.account;
1830
- if (filter.includeSpotOrders != null) out.includeSpotOrders = filter.includeSpotOrders;
1831
- if (filter.limit != null) out.limit = encodeRpcU64Number(filter.limit, "limit");
1832
- return out;
1833
- }
1834
- function normalizeBlockHeader(value) {
1835
- if (value === null || value === void 0) return null;
1836
- if (!value || typeof value !== "object") {
1837
- throw SdkError.malformed("block header must be an object or null");
1838
- }
1839
- const h = value;
1840
- return {
1841
- number: parseRpcBigint(h["number"], "block header number"),
1842
- hash: String(h["hash"]),
1843
- parent_hash: String(firstField(h, ["parent_hash", "parentHash"], "block header parent hash")),
1844
- state_root: String(firstField(h, ["state_root", "stateRoot"], "block header state root")),
1845
- timestamp: parseRpcBigint(h["timestamp"], "block header timestamp"),
1846
- executionUnitsUsed: parseRpcBigint(
1847
- firstField(
1848
- h,
1849
- ["executionUnitsUsed", "execution_units_used", "gas_used", "gasUsed"],
1850
- "block header execution units used"
1851
- ),
1852
- "block header execution units used"
1853
- ),
1854
- executionUnitLimit: parseRpcBigint(
1855
- firstField(
1856
- h,
1857
- ["executionUnitLimit", "execution_unit_limit", "gas_limit", "gasLimit"],
1858
- "block header execution unit limit"
1859
- ),
1860
- "block header execution unit limit"
1861
- )
1862
- };
1863
- }
1864
- function normalizeTransactionReceipt(value) {
1865
- if (value === null || value === void 0) return null;
1866
- const r = expectObject(value, "transaction receipt");
1867
- return {
1868
- tx_hash: String(
1869
- firstField(r, ["tx_hash", "txHash", "transactionHash"], "transaction receipt tx hash")
1870
- ),
1871
- block_hash: String(
1872
- firstField(r, ["block_hash", "blockHash"], "transaction receipt block hash")
1873
- ),
1874
- block_number: parseRpcBigint(
1875
- firstField(r, ["block_number", "blockNumber"], "transaction receipt block number"),
1876
- "transaction receipt block number"
1877
- ),
1878
- tx_index: parseRpcNumber(
1879
- firstField(r, ["tx_index", "txIndex", "transactionIndex"], "transaction receipt tx index"),
1880
- "transaction receipt tx index"
1881
- ),
1882
- status: parseRpcNumber(firstField(r, ["status"], "transaction receipt status"), "transaction receipt status"),
1883
- executionUnitsUsed: parseRpcBigint(
1884
- firstField(
1885
- r,
1886
- ["executionUnitsUsed", "execution_units_used", "gas_used", "gasUsed"],
1887
- "transaction receipt execution units used"
1888
- ),
1889
- "transaction receipt execution units used"
1890
- )
1891
- };
1892
- }
1893
- function sdkTypedAddress(address, kind, label) {
1894
- try {
1895
- return requireTypedAddress(address, kind, label);
1896
- } catch (err) {
1897
- const message = err instanceof Error ? err.message : String(err);
1898
- throw SdkError.malformed(message);
1899
- }
1900
- }
1901
- function normalizeRoundInfo(value) {
1902
- if (!value || typeof value !== "object") {
1903
- throw SdkError.malformed("round info must be an object");
1904
- }
1905
- const row = value;
1906
- return {
1907
- height: parseRpcBigint(row["height"], "round height")
1908
- };
1909
- }
1910
- function normalizeMempoolSnapshot(value) {
1911
- if (!value || typeof value !== "object") {
1912
- throw SdkError.malformed("mempool snapshot must be an object");
1913
- }
1914
- const row = value;
1915
- const bytesByClass = row["bytes_by_class"];
1916
- if (!Array.isArray(bytesByClass) || bytesByClass.length !== 7) {
1917
- throw SdkError.malformed("mempool bytes_by_class must contain 7 entries");
1918
- }
1919
- return {
1920
- count_ready: parseRpcBigint(row["count_ready"], "mempool count_ready"),
1921
- count_pending: parseRpcBigint(row["count_pending"], "mempool count_pending"),
1922
- mailbox_depth: parseRpcBigint(row["mailbox_depth"], "mempool mailbox_depth"),
1923
- bytes_by_class: bytesByClass.map((v, i) => parseRpcBigint(v, `mempool bytes_by_class[${i}]`))
1924
- };
1925
- }
1926
- function normalizeCapabilitiesResponse(value) {
1927
- return {
1928
- ...value,
1929
- nativeModuleForwarders: value.nativeModuleForwarders ?? {}
1930
- };
1931
- }
1932
-
1933
- // src/ethers/network.ts
1934
- var MONOLYTHIUM_TESTNET_CHAIN_ID = 69420n;
1935
- var MONOLYTHIUM_TESTNET_NETWORK_NAME = "monolythium-testnet";
1936
- var MONOLYTHIUM_NETWORKS = {
1937
- testnet: {
1938
- chainId: MONOLYTHIUM_TESTNET_CHAIN_ID,
1939
- name: MONOLYTHIUM_TESTNET_NETWORK_NAME
1940
- }
1941
- };
1942
-
1943
- // src/ethers/provider.ts
1944
- var MonolythiumProvider = class extends JsonRpcApiProvider {
1945
- /** Underlying SDK client. Exposed for callers that want native types. */
1946
- rpcClient;
1947
- constructor(endpointOrClient, options = {}) {
1948
- const network = options.network ?? {
1949
- chainId: MONOLYTHIUM_TESTNET_CHAIN_ID,
1950
- name: MONOLYTHIUM_TESTNET_NETWORK_NAME
1951
- };
1952
- try {
1953
- Network.register(
1954
- network.name,
1955
- () => new Network(network.name, network.chainId)
1956
- );
1957
- } catch (_e) {
1958
- }
1959
- super(new Network(network.name, network.chainId));
1960
- this.rpcClient = typeof endpointOrClient === "string" ? new RpcClient(endpointOrClient, {
1961
- fetch: options.fetch,
1962
- headers: options.headers
1963
- }) : endpointOrClient;
1964
- }
1965
- /**
1966
- * Forward a single JSON-RPC method through the SDK transport. Ethers'
1967
- * `_perform` calls this and ethers callers can also call `provider.send`
1968
- * directly to access methods the rich provider interface does not wrap
1969
- * (e.g. `lyth_*`).
1970
- */
1971
- async _send(payload) {
1972
- const calls = Array.isArray(payload) ? payload : [payload];
1973
- return Promise.all(calls.map((p) => this.#sendOne(p)));
1974
- }
1975
- async #sendOne(p) {
1976
- try {
1977
- const params = Array.isArray(p.params) ? p.params : p.params === void 0 ? [] : p.params;
1978
- const result = await this.rpcClient.call(p.method, params);
1979
- return { id: p.id, result };
1980
- } catch (e) {
1981
- if (e instanceof SdkError && e.kind === "rpc") {
1982
- return {
1983
- id: p.id,
1984
- error: {
1985
- code: e.code ?? -32603,
1986
- message: e.message,
1987
- data: e.data
1988
- }
1989
- };
1990
- }
1991
- const msg = e?.message ?? String(e);
1992
- return {
1993
- id: p.id,
1994
- error: { code: -32603, message: `${msg}` }
1995
- };
1996
- }
1997
- }
1998
- };
1999
- var MonolythiumSigner = class _MonolythiumSigner extends AbstractSigner {
2000
- #backend;
2001
- constructor(backend, provider) {
2002
- super(provider ?? null);
2003
- this.#backend = backend;
2004
- }
2005
- /**
2006
- * Wrap any ethers v6 `BaseWallet` (the parent class of `Wallet`,
2007
- * `HDNodeWallet`, and friends) so callers don't have to write a
2008
- * `MonolythiumSignerBackend` for the common test / dev path.
2009
- *
2010
- * Both `new Wallet(privateKey)` and `Wallet.createRandom()` /
2011
- * `HDNodeWallet.fromMnemonic(...)` are accepted.
2012
- */
2013
- static fromEthersWallet(wallet, provider) {
2014
- const backend = {
2015
- getAddress: async () => wallet.address,
2016
- signTransaction: (tx) => wallet.signTransaction(tx),
2017
- signMessage: (message) => wallet.signMessage(message),
2018
- signTypedData: (domain, types, value) => wallet.signTypedData(domain, types, value)
2019
- };
2020
- return new _MonolythiumSigner(backend, provider);
2021
- }
2022
- async getAddress() {
2023
- return this.#backend.getAddress();
2024
- }
2025
- connect(provider) {
2026
- return new _MonolythiumSigner(this.#backend, provider);
2027
- }
2028
- async signTransaction(tx) {
2029
- return this.#backend.signTransaction(tx);
2030
- }
2031
- async signMessage(message) {
2032
- return this.#backend.signMessage(message);
2033
- }
2034
- async signTypedData(domain, types, value) {
2035
- return this.#backend.signTypedData(domain, types, value);
2036
- }
2037
- };
2038
-
2039
- // src/ethers/tx-translate.ts
2040
- function toHexQuantity(v) {
2041
- if (v === null || v === void 0) return void 0;
2042
- if (typeof v === "string") {
2043
- if (v.startsWith("0x") || v.startsWith("0X")) return v;
2044
- return `0x${BigInt(v).toString(16)}`;
2045
- }
2046
- if (typeof v === "number") return `0x${v.toString(16)}`;
2047
- return `0x${v.toString(16)}`;
2048
- }
2049
- function translateTxIn(req) {
2050
- const out = {};
2051
- if (req.from !== void 0 && req.from !== null) out.from = req.from;
2052
- if (req.to !== void 0 && req.to !== null) out.to = req.to;
2053
- const gas = toHexQuantity(req.gasLimit);
2054
- if (gas !== void 0) out.gas = gas;
2055
- const gasPrice = toHexQuantity(req.gasPrice);
2056
- if (gasPrice !== void 0) out.gasPrice = gasPrice;
2057
- const value = toHexQuantity(req.value);
2058
- if (value !== void 0) out.value = value;
2059
- if (req.data !== void 0 && req.data !== null) out.data = req.data;
2060
- return out;
2061
- }
2062
- function translateReceiptOut(monoReceipt, fromAddress, toAddress) {
2063
- return {
2064
- transactionHash: monoReceipt.tx_hash,
2065
- blockHash: monoReceipt.block_hash,
2066
- blockNumber: `0x${BigInt(monoReceipt.block_number).toString(16)}`,
2067
- transactionIndex: `0x${monoReceipt.tx_index.toString(16)}`,
2068
- status: monoReceipt.status === 1 ? "0x1" : "0x0",
2069
- gasUsed: `0x${BigInt(monoReceipt.executionUnitsUsed).toString(16)}`,
2070
- cumulativeGasUsed: `0x${BigInt(monoReceipt.executionUnitsUsed).toString(16)}`,
2071
- effectiveGasPrice: "0x0",
2072
- contractAddress: null,
2073
- from: fromAddress ?? "0x0000000000000000000000000000000000000000",
2074
- to: toAddress,
2075
- type: "0x2",
2076
- logsBloom: `0x${"0".repeat(512)}`,
2077
- logs: []
2078
- };
2079
- }
2080
- function translateBlockOut(header) {
2081
- return {
2082
- number: `0x${header.number.toString(16)}`,
2083
- hash: header.hash,
2084
- parentHash: header.parent_hash,
2085
- timestamp: `0x${header.timestamp.toString(16)}`,
2086
- gasUsed: `0x${header.executionUnitsUsed.toString(16)}`,
2087
- gasLimit: `0x${header.executionUnitLimit.toString(16)}`,
2088
- stateRoot: header.state_root,
2089
- miner: "0x0000000000000000000000000000000000000000",
2090
- difficulty: "0x0",
2091
- nonce: "0x0000000000000000",
2092
- baseFeePerGas: null,
2093
- extraData: "0x",
2094
- mixHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
2095
- transactions: [],
2096
- transactionsRoot: "0x0000000000000000000000000000000000000000000000000000000000000000",
2097
- receiptsRoot: "0x0000000000000000000000000000000000000000000000000000000000000000",
2098
- logsBloom: `0x${"0".repeat(512)}`,
2099
- sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
2100
- uncles: [],
2101
- size: "0x0"
2102
- };
2103
- }
2104
-
2105
- export { MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MonolythiumProvider, MonolythiumSigner, translateBlockOut, translateReceiptOut, translateTxIn };
2106
- //# sourceMappingURL=index.js.map
2107
- //# sourceMappingURL=index.js.map