@monolythium/core-sdk 0.3.13 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/crypto/index.d.cts +2 -2
- package/dist/crypto/index.d.ts +2 -2
- package/dist/index.cjs +947 -160
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +906 -161
- package/dist/index.js.map +1 -1
- package/dist/{submission-CA8L21An.d.cts → submission-vhPqAwkD.d.cts} +488 -1
- package/dist/{submission-CA8L21An.d.ts → submission-vhPqAwkD.d.ts} +488 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -420,6 +420,14 @@ var SERVICE_PROBE_STATUS = {
|
|
|
420
420
|
UNREACHABLE: 3
|
|
421
421
|
};
|
|
422
422
|
var NODE_REGISTRY_SELECTORS = {
|
|
423
|
+
/** `recoverOperatorNode(bytes32)` — foundation-gated DR alias for `unjail`. */
|
|
424
|
+
recoverOperatorNode: "0x" + selectorHex("recoverOperatorNode(bytes32)"),
|
|
425
|
+
/** `submitPendingChange(uint8,bytes,uint64,uint64)` — foundation-gated roster lifecycle. */
|
|
426
|
+
submitPendingChange: "0x" + selectorHex("submitPendingChange(uint8,bytes,uint64,uint64)"),
|
|
427
|
+
/** `cancelPendingChange(uint64,bytes)` — foundation-gated pending-change cancellation. */
|
|
428
|
+
cancelPendingChange: "0x" + selectorHex("cancelPendingChange(uint64,bytes)"),
|
|
429
|
+
/** `attestDkgReshare(uint64,bytes,bytes)` — operator-signed DKG re-share attestation. */
|
|
430
|
+
attestDkgReshare: "0x" + selectorHex("attestDkgReshare(uint64,bytes,bytes)"),
|
|
423
431
|
reportServiceProbe: "0xeee31bba",
|
|
424
432
|
getServiceProbe: "0x1fcbfbce",
|
|
425
433
|
/** `setNetworkMetadata(bytes32,uint16,bytes3,bytes)` — owner-callable (PF-6). */
|
|
@@ -429,6 +437,21 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
429
437
|
/** `getClusterDiversity(uint32)` view (PF-6). */
|
|
430
438
|
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)")
|
|
431
439
|
};
|
|
440
|
+
var NODE_REGISTRY_BLS_PUBKEY_BYTES = 48;
|
|
441
|
+
var NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = 96;
|
|
442
|
+
var NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = 5;
|
|
443
|
+
var NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS = 7;
|
|
444
|
+
var NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = (1n << 56n) - 1n;
|
|
445
|
+
var PENDING_CHANGE_KIND_CODES = {
|
|
446
|
+
add: 1,
|
|
447
|
+
remove: 2,
|
|
448
|
+
rotate: 3
|
|
449
|
+
};
|
|
450
|
+
var PENDING_CHANGE_KIND_LABELS = {
|
|
451
|
+
1: "add",
|
|
452
|
+
2: "remove",
|
|
453
|
+
3: "rotate"
|
|
454
|
+
};
|
|
432
455
|
var CLUSTER_FORMED_EVENT_SIG = "ClusterFormed(uint32,uint64,address,bytes)";
|
|
433
456
|
var NodeRegistryError = class extends Error {
|
|
434
457
|
constructor(message) {
|
|
@@ -463,6 +486,131 @@ function serviceProbeStatusLabel(status) {
|
|
|
463
486
|
return "unknown";
|
|
464
487
|
}
|
|
465
488
|
}
|
|
489
|
+
function normalizePendingChangeKind(kind) {
|
|
490
|
+
if (typeof kind === "number") {
|
|
491
|
+
const label = PENDING_CHANGE_KIND_LABELS[kind];
|
|
492
|
+
if (!label) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
493
|
+
return { kind: label, kindCode: kind };
|
|
494
|
+
}
|
|
495
|
+
const kindCode = PENDING_CHANGE_KIND_CODES[kind];
|
|
496
|
+
if (!kindCode) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
497
|
+
return { kind, kindCode };
|
|
498
|
+
}
|
|
499
|
+
function encodeRecoverOperatorNodeCalldata(peerId) {
|
|
500
|
+
return bytesToHex(
|
|
501
|
+
concatBytes(
|
|
502
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.recoverOperatorNode),
|
|
503
|
+
expectLength2(toBytes(peerId), 32, "peerId")
|
|
504
|
+
)
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
function encodeSubmitPendingChangeCalldata(args) {
|
|
508
|
+
const { kind, kindCode } = normalizePendingChangeKind(args.kind);
|
|
509
|
+
const targetPubkey = expectLength2(
|
|
510
|
+
toBytes(args.targetPubkey),
|
|
511
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
512
|
+
"targetPubkey"
|
|
513
|
+
);
|
|
514
|
+
const effectiveEpoch = toUint64(args.effectiveEpoch, "effectiveEpoch");
|
|
515
|
+
if (effectiveEpoch === 0n) {
|
|
516
|
+
throw new NodeRegistryError("effectiveEpoch must be greater than zero");
|
|
517
|
+
}
|
|
518
|
+
const intentId = toUint64(args.intentId ?? 0n, "intentId");
|
|
519
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
520
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
521
|
+
}
|
|
522
|
+
if (kind !== "rotate" && intentId !== 0n) {
|
|
523
|
+
throw new NodeRegistryError("only rotate pending changes may carry a non-zero intentId");
|
|
524
|
+
}
|
|
525
|
+
const targetTail = new Uint8Array(32);
|
|
526
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
527
|
+
return bytesToHex(
|
|
528
|
+
concatBytes(
|
|
529
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.submitPendingChange),
|
|
530
|
+
uint8Word(kindCode),
|
|
531
|
+
uint64Word(4n * 32n, "targetPubkeyOffset"),
|
|
532
|
+
uint64Word(effectiveEpoch, "effectiveEpoch"),
|
|
533
|
+
uint64Word(intentId, "intentId"),
|
|
534
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
535
|
+
targetPubkey.slice(0, 32),
|
|
536
|
+
targetTail
|
|
537
|
+
)
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
function encodeCancelPendingChangeCalldata(args) {
|
|
541
|
+
const targetPubkey = expectLength2(
|
|
542
|
+
toBytes(args.targetPubkey),
|
|
543
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
544
|
+
"targetPubkey"
|
|
545
|
+
);
|
|
546
|
+
const targetTail = new Uint8Array(32);
|
|
547
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
548
|
+
return bytesToHex(
|
|
549
|
+
concatBytes(
|
|
550
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.cancelPendingChange),
|
|
551
|
+
uint64Word(args.epoch, "epoch"),
|
|
552
|
+
uint64Word(2n * 32n, "targetPubkeyOffset"),
|
|
553
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
554
|
+
targetPubkey.slice(0, 32),
|
|
555
|
+
targetTail
|
|
556
|
+
)
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
function parseDkgResharePublicKeys(blsPublicKeys) {
|
|
560
|
+
const keys = toBytes(blsPublicKeys);
|
|
561
|
+
if (keys.length % NODE_REGISTRY_BLS_PUBKEY_BYTES !== 0) {
|
|
562
|
+
throw new NodeRegistryError("blsPublicKeys length must be a multiple of 48 bytes");
|
|
563
|
+
}
|
|
564
|
+
const signerCount = keys.length / NODE_REGISTRY_BLS_PUBKEY_BYTES;
|
|
565
|
+
if (signerCount < NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS || signerCount > NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS) {
|
|
566
|
+
throw new NodeRegistryError(
|
|
567
|
+
`blsPublicKeys must contain ${NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS}..${NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS} signers`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
const out = [];
|
|
571
|
+
const seen = /* @__PURE__ */ new Set();
|
|
572
|
+
for (let offset = 0; offset < keys.length; offset += NODE_REGISTRY_BLS_PUBKEY_BYTES) {
|
|
573
|
+
const key = keys.slice(offset, offset + NODE_REGISTRY_BLS_PUBKEY_BYTES);
|
|
574
|
+
const keyHex = bytesToHex(key);
|
|
575
|
+
if (seen.has(keyHex)) {
|
|
576
|
+
throw new NodeRegistryError("blsPublicKeys contains a duplicate signer pubkey");
|
|
577
|
+
}
|
|
578
|
+
seen.add(keyHex);
|
|
579
|
+
out.push(key);
|
|
580
|
+
}
|
|
581
|
+
return out;
|
|
582
|
+
}
|
|
583
|
+
function encodeAttestDkgReshareCalldata(args) {
|
|
584
|
+
const intentId = toUint64(args.intentId, "intentId");
|
|
585
|
+
if (intentId === 0n) {
|
|
586
|
+
throw new NodeRegistryError("intentId must be greater than zero");
|
|
587
|
+
}
|
|
588
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
589
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
590
|
+
}
|
|
591
|
+
const publicKeys = concatBytes(...parseDkgResharePublicKeys(args.blsPublicKeys));
|
|
592
|
+
const thresholdSig = expectLength2(
|
|
593
|
+
toBytes(args.thresholdSig),
|
|
594
|
+
NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES,
|
|
595
|
+
"thresholdSig"
|
|
596
|
+
);
|
|
597
|
+
const keysPadded = padToWord(publicKeys);
|
|
598
|
+
const sigPadded = padToWord(thresholdSig);
|
|
599
|
+
const offsetKeys = 3n * 32n;
|
|
600
|
+
const offsetSig = offsetKeys + 32n + BigInt(keysPadded.length);
|
|
601
|
+
return bytesToHex(
|
|
602
|
+
concatBytes(
|
|
603
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.attestDkgReshare),
|
|
604
|
+
uint64Word(intentId, "intentId"),
|
|
605
|
+
uint64Word(offsetKeys, "blsPublicKeysOffset"),
|
|
606
|
+
uint64Word(offsetSig, "thresholdSigOffset"),
|
|
607
|
+
uint64Word(BigInt(publicKeys.length), "blsPublicKeysLength"),
|
|
608
|
+
keysPadded,
|
|
609
|
+
uint64Word(BigInt(thresholdSig.length), "thresholdSigLength"),
|
|
610
|
+
sigPadded
|
|
611
|
+
)
|
|
612
|
+
);
|
|
613
|
+
}
|
|
466
614
|
function encodeReportServiceProbeCalldata(args) {
|
|
467
615
|
if (!isValidPublicServiceProbeMask(args.serviceMask)) {
|
|
468
616
|
throw new NodeRegistryError(
|
|
@@ -622,6 +770,44 @@ function uint8Word(value) {
|
|
|
622
770
|
out[31] = value;
|
|
623
771
|
return out;
|
|
624
772
|
}
|
|
773
|
+
function uint64Word(value, name) {
|
|
774
|
+
const n = toUint64(value, name);
|
|
775
|
+
const out = new Uint8Array(32);
|
|
776
|
+
let rest = n;
|
|
777
|
+
for (let i = 31; i >= 24; i--) {
|
|
778
|
+
out[i] = Number(rest & 0xffn);
|
|
779
|
+
rest >>= 8n;
|
|
780
|
+
}
|
|
781
|
+
return out;
|
|
782
|
+
}
|
|
783
|
+
function toUint64(value, name) {
|
|
784
|
+
let parsed;
|
|
785
|
+
if (typeof value === "bigint") {
|
|
786
|
+
parsed = value;
|
|
787
|
+
} else if (typeof value === "number") {
|
|
788
|
+
if (!Number.isSafeInteger(value)) {
|
|
789
|
+
throw new NodeRegistryError(`${name} must be a safe integer`);
|
|
790
|
+
}
|
|
791
|
+
parsed = BigInt(value);
|
|
792
|
+
} else {
|
|
793
|
+
const trimmed = value.trim();
|
|
794
|
+
if (!/^\d+$/u.test(trimmed)) {
|
|
795
|
+
throw new NodeRegistryError(`${name} must be a decimal uint64`);
|
|
796
|
+
}
|
|
797
|
+
parsed = BigInt(trimmed);
|
|
798
|
+
}
|
|
799
|
+
if (parsed < 0n || parsed > 0xffffffffffffffffn) {
|
|
800
|
+
throw new NodeRegistryError(`${name} must fit uint64`);
|
|
801
|
+
}
|
|
802
|
+
return parsed;
|
|
803
|
+
}
|
|
804
|
+
function padToWord(bytes) {
|
|
805
|
+
const paddedLength = Math.ceil(bytes.length / 32) * 32;
|
|
806
|
+
if (paddedLength === bytes.length) return bytes;
|
|
807
|
+
const out = new Uint8Array(paddedLength);
|
|
808
|
+
out.set(bytes);
|
|
809
|
+
return out;
|
|
810
|
+
}
|
|
625
811
|
function toBytes(value) {
|
|
626
812
|
if (typeof value === "string") {
|
|
627
813
|
return hexToBytes(value);
|
|
@@ -2428,6 +2614,192 @@ function encodeBlockSelector(b) {
|
|
|
2428
2614
|
if (typeof b === "bigint") return `0x${b.toString(16)}`;
|
|
2429
2615
|
return b;
|
|
2430
2616
|
}
|
|
2617
|
+
var NameRegistryError = class extends Error {
|
|
2618
|
+
constructor(message) {
|
|
2619
|
+
super(message);
|
|
2620
|
+
this.name = "NameRegistryError";
|
|
2621
|
+
}
|
|
2622
|
+
};
|
|
2623
|
+
var NAME_REGISTRY_SELECTORS = {
|
|
2624
|
+
register: selectorHex2("register(string,address)"),
|
|
2625
|
+
proposeTransfer: selectorHex2("proposeTransfer(string,address)"),
|
|
2626
|
+
acceptTransfer: selectorHex2("acceptTransfer(string)")
|
|
2627
|
+
};
|
|
2628
|
+
var NAME_BASE_MULTIPLIER = {
|
|
2629
|
+
human: 5,
|
|
2630
|
+
agent: 2,
|
|
2631
|
+
cluster: 20,
|
|
2632
|
+
contract: 10
|
|
2633
|
+
};
|
|
2634
|
+
var NAME_FALLBACK_FEE_UNIT_LYTHOSHI = 100n;
|
|
2635
|
+
var NAME_MAX_LEN = 80;
|
|
2636
|
+
var NAME_LABEL_MIN_LEN = 1;
|
|
2637
|
+
var NAME_LABEL_MAX_LEN = 63;
|
|
2638
|
+
function nameRegistryAddressHex() {
|
|
2639
|
+
return PRECOMPILE_ADDRESSES.NAME_REGISTRY.toLowerCase();
|
|
2640
|
+
}
|
|
2641
|
+
function nameLengthModifierX10(labelLen) {
|
|
2642
|
+
if (labelLen === 1) return 1e3;
|
|
2643
|
+
if (labelLen === 2) return 500;
|
|
2644
|
+
if (labelLen === 3) return 100;
|
|
2645
|
+
if (labelLen === 4) return 50;
|
|
2646
|
+
if (labelLen === 5) return 30;
|
|
2647
|
+
if (labelLen >= 6 && labelLen <= 12) return 10;
|
|
2648
|
+
if (labelLen >= 13 && labelLen <= 20) return 15;
|
|
2649
|
+
if (labelLen >= 21 && labelLen <= 32) return 30;
|
|
2650
|
+
if (labelLen >= 33 && labelLen <= 50) return 100;
|
|
2651
|
+
if (labelLen >= 51 && labelLen <= 63) return 500;
|
|
2652
|
+
return null;
|
|
2653
|
+
}
|
|
2654
|
+
function parseNameCategory(name) {
|
|
2655
|
+
if (name.length === 0) throw new NameRegistryError("name is empty");
|
|
2656
|
+
if (name.length > NAME_MAX_LEN) throw new NameRegistryError(`name exceeds ${NAME_MAX_LEN} chars`);
|
|
2657
|
+
const parts = name.split(".");
|
|
2658
|
+
if (parts.some((p) => p.length === 0)) {
|
|
2659
|
+
throw new NameRegistryError("name has an empty label");
|
|
2660
|
+
}
|
|
2661
|
+
for (const label of parts) validateLabel(label);
|
|
2662
|
+
if (parts[parts.length - 1] !== "mono") {
|
|
2663
|
+
throw new NameRegistryError("name must end with .mono");
|
|
2664
|
+
}
|
|
2665
|
+
const primaryLabelLen = parts[0].length;
|
|
2666
|
+
switch (parts.length) {
|
|
2667
|
+
case 2:
|
|
2668
|
+
if (STRUCTURAL_RESERVES.has(parts[0])) {
|
|
2669
|
+
throw new NameRegistryError(`"${parts[0]}.mono" is a structural reserve`);
|
|
2670
|
+
}
|
|
2671
|
+
return { category: "human", primaryLabelLen };
|
|
2672
|
+
case 3: {
|
|
2673
|
+
const anchor = parts[1];
|
|
2674
|
+
if (anchor === "cluster") return { category: "cluster", primaryLabelLen };
|
|
2675
|
+
if (anchor === "contract") return { category: "contract", primaryLabelLen };
|
|
2676
|
+
if (anchor === "system") return { category: "system", primaryLabelLen };
|
|
2677
|
+
throw new NameRegistryError(`unknown name category anchor ".${anchor}.mono"`);
|
|
2678
|
+
}
|
|
2679
|
+
case 4:
|
|
2680
|
+
if (parts[1] !== "agent") {
|
|
2681
|
+
throw new NameRegistryError("unknown 4-label name form (expected <x>.agent.<human>.mono)");
|
|
2682
|
+
}
|
|
2683
|
+
return { category: "agent", primaryLabelLen };
|
|
2684
|
+
default:
|
|
2685
|
+
throw new NameRegistryError("unrecognised name structure");
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
function nameRegistrationCost(category, primaryLabelLen, feeUnitLythoshi) {
|
|
2689
|
+
if (category === "system") {
|
|
2690
|
+
throw new NameRegistryError("system names are not registerable via this path");
|
|
2691
|
+
}
|
|
2692
|
+
const base = BigInt(NAME_BASE_MULTIPLIER[category]);
|
|
2693
|
+
const modX10 = nameLengthModifierX10(primaryLabelLen);
|
|
2694
|
+
if (modX10 === null) {
|
|
2695
|
+
throw new NameRegistryError("primary label length is outside the priceable 1..=63 range");
|
|
2696
|
+
}
|
|
2697
|
+
return base * BigInt(modX10) * feeUnitLythoshi / 10n;
|
|
2698
|
+
}
|
|
2699
|
+
function encodeNameRegisterCall(name, owner) {
|
|
2700
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.register, name, owner);
|
|
2701
|
+
}
|
|
2702
|
+
function encodeNameProposeTransferCall(name, recipient) {
|
|
2703
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.proposeTransfer, name, recipient);
|
|
2704
|
+
}
|
|
2705
|
+
function encodeNameAcceptTransferCall(name) {
|
|
2706
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2707
|
+
return bytesToHex4(
|
|
2708
|
+
concatBytes4(
|
|
2709
|
+
hexToBytes4(NAME_REGISTRY_SELECTORS.acceptTransfer),
|
|
2710
|
+
// Single head word → the string offset is 0x20 (one word precedes the tail).
|
|
2711
|
+
uint256Word(0x20n),
|
|
2712
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2713
|
+
padTo32(nameBytes)
|
|
2714
|
+
)
|
|
2715
|
+
);
|
|
2716
|
+
}
|
|
2717
|
+
var STRUCTURAL_RESERVES = /* @__PURE__ */ new Set(["agent", "cluster", "contract", "system"]);
|
|
2718
|
+
function encodeStringAddressCall(selector, name, address) {
|
|
2719
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2720
|
+
return bytesToHex4(
|
|
2721
|
+
concatBytes4(
|
|
2722
|
+
hexToBytes4(selector),
|
|
2723
|
+
// Two head words (string offset, address) → string tail starts at 0x40.
|
|
2724
|
+
uint256Word(0x40n),
|
|
2725
|
+
addressWord(address),
|
|
2726
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2727
|
+
padTo32(nameBytes)
|
|
2728
|
+
)
|
|
2729
|
+
);
|
|
2730
|
+
}
|
|
2731
|
+
function validateLabel(label) {
|
|
2732
|
+
if (label.length < NAME_LABEL_MIN_LEN || label.length > NAME_LABEL_MAX_LEN) {
|
|
2733
|
+
throw new NameRegistryError(`label "${label}" must be ${NAME_LABEL_MIN_LEN}..${NAME_LABEL_MAX_LEN} chars`);
|
|
2734
|
+
}
|
|
2735
|
+
if (label.startsWith("-") || label.endsWith("-")) {
|
|
2736
|
+
throw new NameRegistryError(`label "${label}" may not start or end with a hyphen`);
|
|
2737
|
+
}
|
|
2738
|
+
if (label.includes("--")) {
|
|
2739
|
+
throw new NameRegistryError(`label "${label}" may not contain a double hyphen`);
|
|
2740
|
+
}
|
|
2741
|
+
if (!/^[a-z0-9-]+$/.test(label)) {
|
|
2742
|
+
throw new NameRegistryError(`label "${label}" has an invalid char (allowed: a-z 0-9 -)`);
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
function selectorHex2(signature) {
|
|
2746
|
+
const sel = keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
2747
|
+
return `0x${[...sel].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2748
|
+
}
|
|
2749
|
+
function addressWord(value) {
|
|
2750
|
+
const out = new Uint8Array(32);
|
|
2751
|
+
if (value == null) return out;
|
|
2752
|
+
const bytes = toBytes2(value);
|
|
2753
|
+
if (bytes.length !== 20) {
|
|
2754
|
+
throw new NameRegistryError(`address must be 20 bytes, got ${bytes.length}`);
|
|
2755
|
+
}
|
|
2756
|
+
out.set(bytes, 12);
|
|
2757
|
+
return out;
|
|
2758
|
+
}
|
|
2759
|
+
function uint256Word(value) {
|
|
2760
|
+
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
2761
|
+
throw new NameRegistryError("uint256 word out of range");
|
|
2762
|
+
}
|
|
2763
|
+
const out = new Uint8Array(32);
|
|
2764
|
+
let rest = value;
|
|
2765
|
+
for (let i = 31; i >= 0 && rest > 0n; i--) {
|
|
2766
|
+
out[i] = Number(rest & 0xffn);
|
|
2767
|
+
rest >>= 8n;
|
|
2768
|
+
}
|
|
2769
|
+
return out;
|
|
2770
|
+
}
|
|
2771
|
+
function padTo32(bytes) {
|
|
2772
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
2773
|
+
if (padded === bytes.length) return bytes;
|
|
2774
|
+
const out = new Uint8Array(padded);
|
|
2775
|
+
out.set(bytes);
|
|
2776
|
+
return out;
|
|
2777
|
+
}
|
|
2778
|
+
function toBytes2(value) {
|
|
2779
|
+
if (typeof value === "string") return hexToBytes4(value);
|
|
2780
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
2781
|
+
}
|
|
2782
|
+
function hexToBytes4(hex) {
|
|
2783
|
+
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
2784
|
+
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
2785
|
+
throw new NameRegistryError("invalid hex bytes");
|
|
2786
|
+
}
|
|
2787
|
+
const out = new Uint8Array(body.length / 2);
|
|
2788
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(body.slice(i * 2, i * 2 + 2), 16);
|
|
2789
|
+
return out;
|
|
2790
|
+
}
|
|
2791
|
+
function bytesToHex4(bytes) {
|
|
2792
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2793
|
+
}
|
|
2794
|
+
function concatBytes4(...parts) {
|
|
2795
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
2796
|
+
let offset = 0;
|
|
2797
|
+
for (const part of parts) {
|
|
2798
|
+
out.set(part, offset);
|
|
2799
|
+
offset += part.length;
|
|
2800
|
+
}
|
|
2801
|
+
return out;
|
|
2802
|
+
}
|
|
2431
2803
|
|
|
2432
2804
|
// src/client.ts
|
|
2433
2805
|
var MAX_NATIVE_RECEIPT_EVENTS = 1e3;
|
|
@@ -3265,7 +3637,234 @@ var RpcClient = class _RpcClient {
|
|
|
3265
3637
|
async meshSubmitTx(signedTx) {
|
|
3266
3638
|
return this.call("mesh_submitTx", [signedTx]);
|
|
3267
3639
|
}
|
|
3640
|
+
// ---- lyth_* additions (R15 / wallet + monoscan surfaces) -----------
|
|
3641
|
+
/**
|
|
3642
|
+
* `lyth_clusterApr` — observed APR for a cluster over a rolling window.
|
|
3643
|
+
* `windowBlocks` defaults to the chain's 1200-block (~1h) window and is
|
|
3644
|
+
* server-clamped to `[10, 86_400]`.
|
|
3645
|
+
*/
|
|
3646
|
+
async lythClusterApr(clusterId, windowBlocks) {
|
|
3647
|
+
const params = windowBlocks === void 0 ? [clusterId] : [clusterId, windowBlocks];
|
|
3648
|
+
return normalizeClusterApr(await this.call("lyth_clusterApr", params));
|
|
3649
|
+
}
|
|
3650
|
+
/** `lyth_resolveName` — forward name → address resolution (0x110E). */
|
|
3651
|
+
async lythResolveName(name, block = "latest") {
|
|
3652
|
+
return this.call("lyth_resolveName", [name, encodeBlockSelector(block)]);
|
|
3653
|
+
}
|
|
3654
|
+
/** `lyth_nameOf` — reverse address → name resolution. */
|
|
3655
|
+
async lythNameOf(address, block = "latest") {
|
|
3656
|
+
return this.call("lyth_nameOf", [sdkTypedAddress(address, "user", "address"), encodeBlockSelector(block)]);
|
|
3657
|
+
}
|
|
3658
|
+
/** `lyth_getClusterName` — reverse cluster id → canonical name. */
|
|
3659
|
+
async lythGetClusterName(clusterId, block = "latest") {
|
|
3660
|
+
return this.call("lyth_getClusterName", [clusterId, encodeBlockSelector(block)]);
|
|
3661
|
+
}
|
|
3662
|
+
/**
|
|
3663
|
+
* Convenience over {@link lythResolveName}: `true` when a well-formed
|
|
3664
|
+
* name is unregistered. A malformed name throws `RpcError`
|
|
3665
|
+
* (`InvalidParams`) rather than returning `true`, so the UI should treat
|
|
3666
|
+
* a thrown validation error distinctly from "taken".
|
|
3667
|
+
*/
|
|
3668
|
+
async lythIsNameAvailable(name, block = "latest") {
|
|
3669
|
+
const resolved = await this.lythResolveName(name, block);
|
|
3670
|
+
return resolved.address === null;
|
|
3671
|
+
}
|
|
3672
|
+
/**
|
|
3673
|
+
* Live name-registration quote: parses the name's category + primary
|
|
3674
|
+
* label length, reads the chain's base fee unit via `eth_feeHistory`
|
|
3675
|
+
* (the bare `baseFeePerGas` — NOT `eth_gasPrice`, which adds the tip and
|
|
3676
|
+
* would over-quote), and applies the U-curve. The resulting
|
|
3677
|
+
* `costLythoshi` is what the `register` tx `value` must equal exactly
|
|
3678
|
+
* (else the precompile reverts `IncorrectFee`).
|
|
3679
|
+
*/
|
|
3680
|
+
async quoteNameRegistration(name, block = "latest") {
|
|
3681
|
+
const parsed = parseNameCategory(name);
|
|
3682
|
+
const history = await this.ethFeeHistory(1, block, []);
|
|
3683
|
+
const baseFees = history.baseFeePerGas ?? [];
|
|
3684
|
+
const lastHex = baseFees.length > 0 ? baseFees[baseFees.length - 1] : "0x0";
|
|
3685
|
+
const baseFee = parseQuantityBig(lastHex);
|
|
3686
|
+
const feeUnitLythoshi = baseFee > 0n ? baseFee : NAME_FALLBACK_FEE_UNIT_LYTHOSHI;
|
|
3687
|
+
return {
|
|
3688
|
+
name,
|
|
3689
|
+
category: parsed.category,
|
|
3690
|
+
primaryLabelLen: parsed.primaryLabelLen,
|
|
3691
|
+
feeUnitLythoshi,
|
|
3692
|
+
costLythoshi: nameRegistrationCost(parsed.category, parsed.primaryLabelLen, feeUnitLythoshi)
|
|
3693
|
+
};
|
|
3694
|
+
}
|
|
3695
|
+
/** `lyth_circulatingSupply` — native LYTH circulating / initial / burned (decimal lythoshi strings). */
|
|
3696
|
+
async lythCirculatingSupply() {
|
|
3697
|
+
return this.call("lyth_circulatingSupply", []);
|
|
3698
|
+
}
|
|
3699
|
+
/** `lyth_totalBurned` — cumulative burned native LYTH (decimal lythoshi string). */
|
|
3700
|
+
async lythTotalBurned() {
|
|
3701
|
+
return this.call("lyth_totalBurned", []);
|
|
3702
|
+
}
|
|
3703
|
+
/** `lyth_swapIntentStatus` — bridge swap-intent / DKG-reshare lifecycle for one intent id. */
|
|
3704
|
+
async lythSwapIntentStatus(intentId) {
|
|
3705
|
+
let id;
|
|
3706
|
+
if (typeof intentId === "number") {
|
|
3707
|
+
id = intentId;
|
|
3708
|
+
} else if (typeof intentId === "bigint") {
|
|
3709
|
+
id = `0x${intentId.toString(16)}`;
|
|
3710
|
+
} else if (intentId.startsWith("0x") || intentId.startsWith("0X")) {
|
|
3711
|
+
id = intentId;
|
|
3712
|
+
} else {
|
|
3713
|
+
id = `0x${BigInt(intentId).toString(16)}`;
|
|
3714
|
+
}
|
|
3715
|
+
return this.call("lyth_swapIntentStatus", [id]);
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Per-tx confirmation depth, derived from `lyth_txStatus` (which returns
|
|
3719
|
+
* both the tx's `blockNumber` and the node `latestHeight`).
|
|
3720
|
+
*/
|
|
3721
|
+
async lythTxConfirmations(txHash) {
|
|
3722
|
+
const status = await this.lythTxStatus(txHash);
|
|
3723
|
+
if (status.status === "found") {
|
|
3724
|
+
return {
|
|
3725
|
+
status: "found",
|
|
3726
|
+
confirmations: status.latestHeight - status.blockNumber + 1,
|
|
3727
|
+
blockNumber: status.blockNumber,
|
|
3728
|
+
latestHeight: status.latestHeight
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
return {
|
|
3732
|
+
status: "not_found",
|
|
3733
|
+
confirmations: null,
|
|
3734
|
+
blockNumber: null,
|
|
3735
|
+
latestHeight: status.latestHeight
|
|
3736
|
+
};
|
|
3737
|
+
}
|
|
3738
|
+
/**
|
|
3739
|
+
* Resolve a user-pasted MRC token id to its metadata (name/symbol/
|
|
3740
|
+
* decimals), for an "add custom token" flow. Returns `null` for an
|
|
3741
|
+
* unknown/untracked id. Performs light client-side format validation
|
|
3742
|
+
* (32-byte hex) for fast UX feedback; the chain re-validates regardless.
|
|
3743
|
+
*/
|
|
3744
|
+
async lythResolveTokenMetadata(rawTokenId) {
|
|
3745
|
+
const body = rawTokenId.startsWith("0x") || rawTokenId.startsWith("0X") ? rawTokenId.slice(2) : rawTokenId;
|
|
3746
|
+
if (!/^[0-9a-fA-F]{64}$/.test(body)) {
|
|
3747
|
+
throw SdkError.malformed("token id must be 32 bytes (64 hex chars)");
|
|
3748
|
+
}
|
|
3749
|
+
return (await this.lythMrcMetadata(rawTokenId)).metadata;
|
|
3750
|
+
}
|
|
3751
|
+
/**
|
|
3752
|
+
* `lyth_getTokenBalances` joined with per-token MRC metadata. Balances
|
|
3753
|
+
* are PUBLIC-only by construction (private-denomination balances are
|
|
3754
|
+
* excluded by the chain). Raw `balance` strings are preserved (apply
|
|
3755
|
+
* `metadata.decimals` client-side for display).
|
|
3756
|
+
*/
|
|
3757
|
+
async lythGetTokenBalancesWithMetadata(address) {
|
|
3758
|
+
const rows = await this.lythGetTokenBalances(address);
|
|
3759
|
+
const keyFor = (row) => {
|
|
3760
|
+
const assetId = row.mrc?.assetId ?? row.tokenId;
|
|
3761
|
+
const tokenId = row.mrc?.tokenId ?? null;
|
|
3762
|
+
return { assetId, tokenId, key: `${assetId}:${tokenId ?? ""}` };
|
|
3763
|
+
};
|
|
3764
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
3765
|
+
for (const row of rows) {
|
|
3766
|
+
const k = keyFor(row);
|
|
3767
|
+
if (!distinct.has(k.key)) distinct.set(k.key, { assetId: k.assetId, tokenId: k.tokenId });
|
|
3768
|
+
}
|
|
3769
|
+
const metaByKey = /* @__PURE__ */ new Map();
|
|
3770
|
+
await Promise.all(
|
|
3771
|
+
[...distinct.entries()].map(async ([key, { assetId, tokenId }]) => {
|
|
3772
|
+
const resp = await this.lythMrcMetadata(assetId, tokenId);
|
|
3773
|
+
metaByKey.set(key, resp.metadata);
|
|
3774
|
+
})
|
|
3775
|
+
);
|
|
3776
|
+
return rows.map((row) => ({ ...row, metadata: metaByKey.get(keyFor(row).key) ?? null }));
|
|
3777
|
+
}
|
|
3778
|
+
/**
|
|
3779
|
+
* Resolve a CLOB market's base/quote asset metadata (symbol/name/
|
|
3780
|
+
* decimals) by joining `lyth_clobMarket` to `lyth_mrcMetadata`. Either
|
|
3781
|
+
* side may be `null` when the indexer has no MRC row (e.g. native LYTH).
|
|
3782
|
+
*/
|
|
3783
|
+
async resolveClobMarketAssets(marketId) {
|
|
3784
|
+
const response = await this.lythClobMarket(marketId);
|
|
3785
|
+
const market = response.market;
|
|
3786
|
+
if (!market) return { base: null, quote: null };
|
|
3787
|
+
const [base, quote] = await Promise.all([
|
|
3788
|
+
this.lythMrcMetadata(market.baseToken).then((m) => m.metadata),
|
|
3789
|
+
this.lythMrcMetadata(market.quoteToken).then((m) => m.metadata)
|
|
3790
|
+
]);
|
|
3791
|
+
return { base, quote };
|
|
3792
|
+
}
|
|
3793
|
+
/**
|
|
3794
|
+
* `lyth_getAddressActivity` enriched with each row's block timestamp,
|
|
3795
|
+
* canonical tx hash (resolved from `(blockHeight, txIndex)`), and
|
|
3796
|
+
* resolved cluster name. Issues one block read per distinct height and
|
|
3797
|
+
* one name read per distinct cluster.
|
|
3798
|
+
*/
|
|
3799
|
+
async enrichAddressActivity(address, limit = 50, cursor) {
|
|
3800
|
+
const entries = await this.lythGetAddressActivity(address, limit, cursor);
|
|
3801
|
+
const heights = [...new Set(entries.map((entry) => BigInt(entry.blockHeight)))];
|
|
3802
|
+
const blockByHeight = /* @__PURE__ */ new Map();
|
|
3803
|
+
await Promise.all(
|
|
3804
|
+
heights.map(async (height) => {
|
|
3805
|
+
blockByHeight.set(height, await this.blockTimeAndTxHashes(height));
|
|
3806
|
+
})
|
|
3807
|
+
);
|
|
3808
|
+
const clusters = [
|
|
3809
|
+
...new Set(entries.map((entry) => entry.cluster).filter((c) => c != null))
|
|
3810
|
+
];
|
|
3811
|
+
const nameByCluster = /* @__PURE__ */ new Map();
|
|
3812
|
+
await Promise.all(
|
|
3813
|
+
clusters.map(async (clusterId) => {
|
|
3814
|
+
nameByCluster.set(clusterId, (await this.lythGetClusterName(clusterId)).name);
|
|
3815
|
+
})
|
|
3816
|
+
);
|
|
3817
|
+
return entries.map((entry) => {
|
|
3818
|
+
const block = blockByHeight.get(BigInt(entry.blockHeight));
|
|
3819
|
+
const txHash = block && entry.txIndex >= 0 && entry.txIndex < block.txHashes.length ? block.txHashes[entry.txIndex] : null;
|
|
3820
|
+
return {
|
|
3821
|
+
...entry,
|
|
3822
|
+
blockTimestampSeconds: block?.timestampSeconds ?? null,
|
|
3823
|
+
txHash,
|
|
3824
|
+
clusterName: entry.cluster != null ? nameByCluster.get(entry.cluster) ?? null : null
|
|
3825
|
+
};
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
/**
|
|
3829
|
+
* Read a block's header timestamp (UNIX seconds) and ordered tx-hash
|
|
3830
|
+
* array via the raw `eth_getBlockByNumber` (hash-only mode). The typed
|
|
3831
|
+
* `ethGetBlockByNumber` wrapper drops the `transactions` array, so this
|
|
3832
|
+
* uses the raw call.
|
|
3833
|
+
*/
|
|
3834
|
+
async blockTimeAndTxHashes(height) {
|
|
3835
|
+
const hexHeight = `0x${height.toString(16)}`;
|
|
3836
|
+
const raw = await this.call("eth_getBlockByNumber", [
|
|
3837
|
+
hexHeight,
|
|
3838
|
+
false
|
|
3839
|
+
]);
|
|
3840
|
+
if (!raw || typeof raw !== "object") return { timestampSeconds: null, txHashes: [] };
|
|
3841
|
+
const ts = raw["timestamp"];
|
|
3842
|
+
const timestampSeconds = ts === null || ts === void 0 ? null : parseRpcBigint(ts, "block timestamp");
|
|
3843
|
+
const txs = raw["transactions"];
|
|
3844
|
+
const txHashes = Array.isArray(txs) ? txs.filter((t) => typeof t === "string") : [];
|
|
3845
|
+
return { timestampSeconds, txHashes };
|
|
3846
|
+
}
|
|
3268
3847
|
};
|
|
3848
|
+
function clusterApyPercent(apr) {
|
|
3849
|
+
return Number(apr.aprBps) / 100;
|
|
3850
|
+
}
|
|
3851
|
+
function computeQuoteLiquidity(book) {
|
|
3852
|
+
const sumQuote = (levels) => levels.reduce((acc, level) => acc + BigInt(level.price) * BigInt(level.size), 0n);
|
|
3853
|
+
const bidQuote = sumQuote(book.bids);
|
|
3854
|
+
const askQuote = sumQuote(book.asks);
|
|
3855
|
+
return {
|
|
3856
|
+
bidQuote: bidQuote.toString(10),
|
|
3857
|
+
askQuote: askQuote.toString(10),
|
|
3858
|
+
totalQuote: (bidQuote + askQuote).toString(10)
|
|
3859
|
+
};
|
|
3860
|
+
}
|
|
3861
|
+
function rankMarketsByVolume(markets) {
|
|
3862
|
+
return [...markets].sort((a, b) => {
|
|
3863
|
+
const av = BigInt(a.totalVolumeBase);
|
|
3864
|
+
const bv = BigInt(b.totalVolumeBase);
|
|
3865
|
+
return av < bv ? 1 : av > bv ? -1 : 0;
|
|
3866
|
+
}).map((market, index) => ({ ...market, volumeRank: index + 1 }));
|
|
3867
|
+
}
|
|
3269
3868
|
function parseQuantityBig(hex) {
|
|
3270
3869
|
if (!hex) return 0n;
|
|
3271
3870
|
const rest = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
@@ -3920,6 +4519,29 @@ function normalizeRoundInfo(value) {
|
|
|
3920
4519
|
height: parseRpcBigint(row["height"], "round height")
|
|
3921
4520
|
};
|
|
3922
4521
|
}
|
|
4522
|
+
function normalizeClusterApr(value) {
|
|
4523
|
+
if (!value || typeof value !== "object") {
|
|
4524
|
+
throw SdkError.malformed("cluster apr must be an object");
|
|
4525
|
+
}
|
|
4526
|
+
const row = value;
|
|
4527
|
+
const blocks = row["blocks"] ?? {};
|
|
4528
|
+
return {
|
|
4529
|
+
clusterId: parseRpcNumber(row["clusterId"], "clusterId"),
|
|
4530
|
+
blocks: {
|
|
4531
|
+
from: parseRpcBigint(blocks["from"], "blocks.from"),
|
|
4532
|
+
to: parseRpcBigint(blocks["to"], "blocks.to"),
|
|
4533
|
+
window: parseRpcBigint(blocks["window"], "blocks.window")
|
|
4534
|
+
},
|
|
4535
|
+
rewardIndexFromHex: parseStringField(row["rewardIndexFromHex"], "rewardIndexFromHex"),
|
|
4536
|
+
rewardIndexToHex: parseStringField(row["rewardIndexToHex"], "rewardIndexToHex"),
|
|
4537
|
+
deltaIndexHex: parseStringField(row["deltaIndexHex"], "deltaIndexHex"),
|
|
4538
|
+
rewardIndexScale: parseStringField(row["rewardIndexScale"], "rewardIndexScale"),
|
|
4539
|
+
totalBps: parseRpcNumber(row["totalBps"], "totalBps"),
|
|
4540
|
+
blocksPerYear: parseRpcBigint(row["blocksPerYear"], "blocksPerYear"),
|
|
4541
|
+
stakePerBpsLythoshi: parseRpcBigint(row["stakePerBpsLythoshi"], "stakePerBpsLythoshi"),
|
|
4542
|
+
aprBps: parseRpcBigint(row["aprBps"], "aprBps")
|
|
4543
|
+
};
|
|
4544
|
+
}
|
|
3923
4545
|
function normalizeExecutionUnitPriceResponse(value) {
|
|
3924
4546
|
if (!value || typeof value !== "object") {
|
|
3925
4547
|
throw SdkError.malformed("execution unit price response must be an object");
|
|
@@ -4565,8 +5187,6 @@ function encodePathBlock(block) {
|
|
|
4565
5187
|
function encodePathSegment(value) {
|
|
4566
5188
|
return encodeURIComponent(typeof value === "bigint" ? value.toString() : String(value));
|
|
4567
5189
|
}
|
|
4568
|
-
|
|
4569
|
-
// src/bridge.ts
|
|
4570
5190
|
var BRIDGE_SELECTORS = {
|
|
4571
5191
|
lockBridgeConfig: "0x8956feb3",
|
|
4572
5192
|
setBridgeResumeCooldown: "0x1a3a0672",
|
|
@@ -4600,42 +5220,105 @@ function bridgeAddressHex() {
|
|
|
4600
5220
|
return PRECOMPILE_ADDRESSES.BRIDGE.toLowerCase();
|
|
4601
5221
|
}
|
|
4602
5222
|
function encodeLockBridgeConfigCalldata(bridgeId) {
|
|
4603
|
-
return
|
|
4604
|
-
|
|
4605
|
-
|
|
4606
|
-
expectLength3(
|
|
5223
|
+
return bytesToHex5(
|
|
5224
|
+
concatBytes5(
|
|
5225
|
+
hexToBytes5(BRIDGE_SELECTORS.lockBridgeConfig),
|
|
5226
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId")
|
|
4607
5227
|
)
|
|
4608
5228
|
);
|
|
4609
5229
|
}
|
|
4610
5230
|
function encodeSetBridgeResumeCooldownCalldata(bridgeId, cooldownBlocks) {
|
|
4611
|
-
return
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
expectLength3(
|
|
4615
|
-
|
|
5231
|
+
return bytesToHex5(
|
|
5232
|
+
concatBytes5(
|
|
5233
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeResumeCooldown),
|
|
5234
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5235
|
+
uint64Word2(cooldownBlocks, "cooldownBlocks")
|
|
4616
5236
|
)
|
|
4617
5237
|
);
|
|
4618
5238
|
}
|
|
4619
5239
|
function encodeSetBridgeRouteFinalityCalldata(bridgeId, finalityBlocks) {
|
|
4620
|
-
return
|
|
4621
|
-
|
|
4622
|
-
|
|
4623
|
-
expectLength3(
|
|
4624
|
-
|
|
5240
|
+
return bytesToHex5(
|
|
5241
|
+
concatBytes5(
|
|
5242
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeRouteFinality),
|
|
5243
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5244
|
+
uint64Word2(finalityBlocks, "finalityBlocks")
|
|
5245
|
+
)
|
|
5246
|
+
);
|
|
5247
|
+
}
|
|
5248
|
+
function bridgeSelector(signature) {
|
|
5249
|
+
return keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
5250
|
+
}
|
|
5251
|
+
function addressWord2(value, name) {
|
|
5252
|
+
const addr = expectLength3(toBytes3(value), 20, name);
|
|
5253
|
+
const out = new Uint8Array(32);
|
|
5254
|
+
out.set(addr, 12);
|
|
5255
|
+
return out;
|
|
5256
|
+
}
|
|
5257
|
+
function padTo322(bytes) {
|
|
5258
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
5259
|
+
if (padded === bytes.length) return bytes;
|
|
5260
|
+
const out = new Uint8Array(padded);
|
|
5261
|
+
out.set(bytes);
|
|
5262
|
+
return out;
|
|
5263
|
+
}
|
|
5264
|
+
function encodeBridgeClaimCalldata(bridgeId, depositId, recipient) {
|
|
5265
|
+
return bytesToHex5(
|
|
5266
|
+
concatBytes5(
|
|
5267
|
+
bridgeSelector("claim(bytes32,bytes32,address)"),
|
|
5268
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5269
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5270
|
+
addressWord2(recipient, "recipient")
|
|
5271
|
+
)
|
|
5272
|
+
);
|
|
5273
|
+
}
|
|
5274
|
+
function encodeBridgeChallengeCalldata(bridgeId, depositId, fraudProof) {
|
|
5275
|
+
const proof = toBytes3(fraudProof);
|
|
5276
|
+
return bytesToHex5(
|
|
5277
|
+
concatBytes5(
|
|
5278
|
+
bridgeSelector("challenge(bytes32,bytes32,bytes)"),
|
|
5279
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5280
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5281
|
+
uint64Word2(3n * 32n, "fraudProofOffset"),
|
|
5282
|
+
uint64Word2(BigInt(proof.length), "fraudProofLength"),
|
|
5283
|
+
padTo322(proof)
|
|
5284
|
+
)
|
|
5285
|
+
);
|
|
5286
|
+
}
|
|
5287
|
+
function encodeSubmitBridgeProofCalldata(bridgeId, depositId, lockReceipt, zkProof, publicInputs) {
|
|
5288
|
+
const receipt = toBytes3(lockReceipt);
|
|
5289
|
+
const proof = toBytes3(zkProof);
|
|
5290
|
+
const inputs = toBytes3(publicInputs);
|
|
5291
|
+
const off0 = 5n * 32n;
|
|
5292
|
+
const off1 = off0 + 32n + BigInt(Math.ceil(receipt.length / 32) * 32);
|
|
5293
|
+
const off2 = off1 + 32n + BigInt(Math.ceil(proof.length / 32) * 32);
|
|
5294
|
+
return bytesToHex5(
|
|
5295
|
+
concatBytes5(
|
|
5296
|
+
bridgeSelector("submitProof(bytes32,bytes32,bytes,bytes,bytes)"),
|
|
5297
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5298
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5299
|
+
uint64Word2(off0, "lockReceiptOffset"),
|
|
5300
|
+
uint64Word2(off1, "zkProofOffset"),
|
|
5301
|
+
uint64Word2(off2, "publicInputsOffset"),
|
|
5302
|
+
uint64Word2(BigInt(receipt.length), "lockReceiptLength"),
|
|
5303
|
+
padTo322(receipt),
|
|
5304
|
+
uint64Word2(BigInt(proof.length), "zkProofLength"),
|
|
5305
|
+
padTo322(proof),
|
|
5306
|
+
uint64Word2(BigInt(inputs.length), "publicInputsLength"),
|
|
5307
|
+
padTo322(inputs)
|
|
4625
5308
|
)
|
|
4626
5309
|
);
|
|
4627
5310
|
}
|
|
4628
5311
|
function isBridgeAdminLockedRevert(data) {
|
|
4629
|
-
return
|
|
5312
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeAdminLocked;
|
|
4630
5313
|
}
|
|
4631
5314
|
function isBridgeResumeCooldownActiveRevert(data) {
|
|
4632
|
-
return
|
|
5315
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeResumeCooldownActive;
|
|
4633
5316
|
}
|
|
4634
5317
|
function isBridgeCooldownZeroRevert(data) {
|
|
4635
|
-
return
|
|
5318
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeCooldownZero;
|
|
4636
5319
|
}
|
|
4637
5320
|
function isBridgeFinalityZeroRevert(data) {
|
|
4638
|
-
return
|
|
5321
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
|
|
4639
5322
|
}
|
|
4640
5323
|
function bridgeDrainRemaining(capPerWindow, drained) {
|
|
4641
5324
|
const cap = BigInt(capPerWindow);
|
|
@@ -5238,7 +5921,7 @@ function expectLength3(value, len, name) {
|
|
|
5238
5921
|
}
|
|
5239
5922
|
return value;
|
|
5240
5923
|
}
|
|
5241
|
-
function
|
|
5924
|
+
function uint64Word2(value, name) {
|
|
5242
5925
|
const n = toBigint(value, name);
|
|
5243
5926
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
5244
5927
|
throw new BridgePrecompileError(`${name} must fit uint64`);
|
|
@@ -5264,13 +5947,13 @@ function toBigint(value, name) {
|
|
|
5264
5947
|
}
|
|
5265
5948
|
return BigInt(value);
|
|
5266
5949
|
}
|
|
5267
|
-
function
|
|
5950
|
+
function toBytes3(value) {
|
|
5268
5951
|
if (typeof value === "string") {
|
|
5269
|
-
return
|
|
5952
|
+
return hexToBytes5(value);
|
|
5270
5953
|
}
|
|
5271
5954
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
5272
5955
|
}
|
|
5273
|
-
function
|
|
5956
|
+
function hexToBytes5(hex) {
|
|
5274
5957
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
5275
5958
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
5276
5959
|
throw new BridgePrecompileError("invalid hex bytes");
|
|
@@ -5281,10 +5964,10 @@ function hexToBytes4(hex) {
|
|
|
5281
5964
|
}
|
|
5282
5965
|
return out;
|
|
5283
5966
|
}
|
|
5284
|
-
function
|
|
5967
|
+
function bytesToHex5(bytes) {
|
|
5285
5968
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
5286
5969
|
}
|
|
5287
|
-
function
|
|
5970
|
+
function concatBytes5(...parts) {
|
|
5288
5971
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
5289
5972
|
let offset = 0;
|
|
5290
5973
|
for (const part of parts) {
|
|
@@ -5339,10 +6022,10 @@ function decodeNoEvmReceiptTranscript(proof) {
|
|
|
5339
6022
|
);
|
|
5340
6023
|
}
|
|
5341
6024
|
function computeNoEvmReceiptsRoot(receipts) {
|
|
5342
|
-
return
|
|
6025
|
+
return bytesToHex6(computeNoEvmReceiptsRootBytes(receipts));
|
|
5343
6026
|
}
|
|
5344
6027
|
function computeNoEvmTargetReceiptHash(receiptBytes) {
|
|
5345
|
-
return
|
|
6028
|
+
return bytesToHex6(keccak_256(receiptBytes));
|
|
5346
6029
|
}
|
|
5347
6030
|
function verifyNoEvmReceiptProof(proof) {
|
|
5348
6031
|
if (proof == null) return null;
|
|
@@ -5929,7 +6612,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5929
6612
|
if (!bytesEqual(expectedLeafHashBytes, actualLeafHashBytes)) {
|
|
5930
6613
|
throw new NoEvmReceiptProofError(
|
|
5931
6614
|
"compact_leaf_hash_mismatch",
|
|
5932
|
-
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${
|
|
6615
|
+
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
|
|
5933
6616
|
actualLeafHashBytes
|
|
5934
6617
|
)}`
|
|
5935
6618
|
);
|
|
@@ -5962,14 +6645,14 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5962
6645
|
if (!bytesEqual(actualRootBytes, compactRootBytes)) {
|
|
5963
6646
|
throw new NoEvmReceiptProofError(
|
|
5964
6647
|
"compact_path_mismatch",
|
|
5965
|
-
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${
|
|
6648
|
+
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
|
|
5966
6649
|
actualRootBytes
|
|
5967
6650
|
)}`
|
|
5968
6651
|
);
|
|
5969
6652
|
}
|
|
5970
6653
|
return {
|
|
5971
6654
|
receipts: [],
|
|
5972
|
-
receiptsRoot:
|
|
6655
|
+
receiptsRoot: bytesToHex6(actualRootBytes),
|
|
5973
6656
|
targetReceiptHash: actualTargetHash,
|
|
5974
6657
|
receiptCount: proof.receiptCount,
|
|
5975
6658
|
txIndex: proof.txIndex,
|
|
@@ -6179,7 +6862,7 @@ function parseArchiveProofSignature(signature, index, fieldPrefix = "archiveProo
|
|
|
6179
6862
|
`${field2}.payload must be non-empty`
|
|
6180
6863
|
);
|
|
6181
6864
|
}
|
|
6182
|
-
return { signerId:
|
|
6865
|
+
return { signerId: bytesToHex6(signerId), payload };
|
|
6183
6866
|
}
|
|
6184
6867
|
function normalizeSignerId(value) {
|
|
6185
6868
|
const bytes = decodeHexBytes(value, "signerId");
|
|
@@ -6189,7 +6872,7 @@ function normalizeSignerId(value) {
|
|
|
6189
6872
|
`signerId must be ${ARCHIVE_SIGNATURE_SIGNER_ID_BYTE_LENGTH} bytes, got ${bytes.length}`
|
|
6190
6873
|
);
|
|
6191
6874
|
}
|
|
6192
|
-
return
|
|
6875
|
+
return bytesToHex6(bytes);
|
|
6193
6876
|
}
|
|
6194
6877
|
function expectArchivePublicKey(value, field2) {
|
|
6195
6878
|
if (value.length !== ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
@@ -6670,7 +7353,7 @@ function bytesEqual(a, b) {
|
|
|
6670
7353
|
}
|
|
6671
7354
|
return diff === 0;
|
|
6672
7355
|
}
|
|
6673
|
-
function
|
|
7356
|
+
function bytesToHex6(bytes) {
|
|
6674
7357
|
let out = "0x";
|
|
6675
7358
|
for (let index = 0; index < bytes.length; index++) {
|
|
6676
7359
|
out += bytes[index].toString(16).padStart(2, "0");
|
|
@@ -6889,12 +7572,48 @@ var OracleEventError = class extends Error {
|
|
|
6889
7572
|
function oracleAddressHex() {
|
|
6890
7573
|
return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
|
|
6891
7574
|
}
|
|
7575
|
+
var FEED_ID_DOMAIN_TAG = "protocore-oracle/feed-id/v1";
|
|
7576
|
+
function deriveFeedId(name, decimals) {
|
|
7577
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
7578
|
+
throw new OracleEventError("feed decimals must be an integer in 0..=255");
|
|
7579
|
+
}
|
|
7580
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
7581
|
+
const buf = concatBytes6(
|
|
7582
|
+
new TextEncoder().encode(FEED_ID_DOMAIN_TAG),
|
|
7583
|
+
nameBytes,
|
|
7584
|
+
Uint8Array.of(decimals & 255)
|
|
7585
|
+
);
|
|
7586
|
+
return bytesToHex7(keccak_256(buf));
|
|
7587
|
+
}
|
|
7588
|
+
function formatOraclePrice(price) {
|
|
7589
|
+
if (price.median === null) return null;
|
|
7590
|
+
const value = BigInt(price.median);
|
|
7591
|
+
const decimals = price.decimals;
|
|
7592
|
+
if (decimals <= 0) return value.toString(10);
|
|
7593
|
+
const base = 10n ** BigInt(decimals);
|
|
7594
|
+
const whole = value / base;
|
|
7595
|
+
const frac = (value % base).toString(10).padStart(decimals, "0").replace(/0+$/, "");
|
|
7596
|
+
return frac.length > 0 ? `${whole.toString(10)}.${frac}` : whole.toString(10);
|
|
7597
|
+
}
|
|
7598
|
+
function oraclePriceToNumber(price) {
|
|
7599
|
+
const formatted = formatOraclePrice(price);
|
|
7600
|
+
return formatted === null ? null : Number(formatted);
|
|
7601
|
+
}
|
|
7602
|
+
function concatBytes6(...parts) {
|
|
7603
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7604
|
+
let offset = 0;
|
|
7605
|
+
for (const part of parts) {
|
|
7606
|
+
out.set(part, offset);
|
|
7607
|
+
offset += part.length;
|
|
7608
|
+
}
|
|
7609
|
+
return out;
|
|
7610
|
+
}
|
|
6892
7611
|
function decodeOracleEvent(topics, data) {
|
|
6893
7612
|
if (topics.length === 0) {
|
|
6894
7613
|
throw new OracleEventError("event record has no topics");
|
|
6895
7614
|
}
|
|
6896
|
-
const topic0 =
|
|
6897
|
-
const body =
|
|
7615
|
+
const topic0 = bytesToHex7(expectLength4(toBytes4(topics[0]), 32, "topic0"));
|
|
7616
|
+
const body = toBytes4(data);
|
|
6898
7617
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
|
|
6899
7618
|
checkArity("OracleRoundFinalized", 3, topics.length);
|
|
6900
7619
|
checkData("OracleRoundFinalized", 3 * 32, body.length);
|
|
@@ -6927,7 +7646,7 @@ function decodeOracleEvent(topics, data) {
|
|
|
6927
7646
|
feedId: hex32(topics[1]),
|
|
6928
7647
|
roundId: u64FromTopic(topics[2]),
|
|
6929
7648
|
writer: addressFromTopic(topics[3]),
|
|
6930
|
-
evidenceHash:
|
|
7649
|
+
evidenceHash: bytesToHex7(body.subarray(0, 32))
|
|
6931
7650
|
};
|
|
6932
7651
|
}
|
|
6933
7652
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
|
|
@@ -6975,7 +7694,7 @@ function decodeFeedFields(feedTopic, body) {
|
|
|
6975
7694
|
};
|
|
6976
7695
|
}
|
|
6977
7696
|
function topicHex(sig) {
|
|
6978
|
-
return
|
|
7697
|
+
return bytesToHex7(keccak_256(new TextEncoder().encode(sig)));
|
|
6979
7698
|
}
|
|
6980
7699
|
function checkArity(event, expected, found) {
|
|
6981
7700
|
if (found !== expected) {
|
|
@@ -6988,13 +7707,13 @@ function checkData(event, expected, found) {
|
|
|
6988
7707
|
}
|
|
6989
7708
|
}
|
|
6990
7709
|
function hex32(topic) {
|
|
6991
|
-
return
|
|
7710
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "feedId topic"));
|
|
6992
7711
|
}
|
|
6993
7712
|
function addressFromTopic(topic) {
|
|
6994
|
-
return
|
|
7713
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "address topic").subarray(12, 32));
|
|
6995
7714
|
}
|
|
6996
7715
|
function u64FromTopic(topic) {
|
|
6997
|
-
return u64FromWord2(expectLength4(
|
|
7716
|
+
return u64FromWord2(expectLength4(toBytes4(topic), 32, "u64 topic"));
|
|
6998
7717
|
}
|
|
6999
7718
|
function u64FromWord2(word) {
|
|
7000
7719
|
let v = 0n;
|
|
@@ -7009,11 +7728,11 @@ function u256Decimal(word) {
|
|
|
7009
7728
|
for (const b of word) v = v << 8n | BigInt(b);
|
|
7010
7729
|
return v.toString(10);
|
|
7011
7730
|
}
|
|
7012
|
-
function
|
|
7013
|
-
if (typeof value === "string") return
|
|
7731
|
+
function toBytes4(value) {
|
|
7732
|
+
if (typeof value === "string") return hexToBytes6(value);
|
|
7014
7733
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7015
7734
|
}
|
|
7016
|
-
function
|
|
7735
|
+
function hexToBytes6(hex) {
|
|
7017
7736
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7018
7737
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
7019
7738
|
throw new OracleEventError("invalid hex bytes");
|
|
@@ -7022,7 +7741,7 @@ function hexToBytes5(hex) {
|
|
|
7022
7741
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
7023
7742
|
return out;
|
|
7024
7743
|
}
|
|
7025
|
-
function
|
|
7744
|
+
function bytesToHex7(bytes) {
|
|
7026
7745
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7027
7746
|
}
|
|
7028
7747
|
function expectLength4(value, len, name) {
|
|
@@ -7034,12 +7753,12 @@ function expectLength4(value, len, name) {
|
|
|
7034
7753
|
var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
|
|
7035
7754
|
var SERVES_GPU_PROVE = 512;
|
|
7036
7755
|
var PROVER_MARKET_SELECTORS = {
|
|
7037
|
-
createRequest: "0x" +
|
|
7038
|
-
submitBid: "0x" +
|
|
7039
|
-
closeRequest: "0x" +
|
|
7040
|
-
submitProof: "0x" +
|
|
7041
|
-
settle: "0x" +
|
|
7042
|
-
slash: "0x" +
|
|
7756
|
+
createRequest: "0x" + selectorHex3("createRequest(bytes)"),
|
|
7757
|
+
submitBid: "0x" + selectorHex3("submitBid(bytes)"),
|
|
7758
|
+
closeRequest: "0x" + selectorHex3("closeRequest(bytes)"),
|
|
7759
|
+
submitProof: "0x" + selectorHex3("submitProof(bytes)"),
|
|
7760
|
+
settle: "0x" + selectorHex3("settle(bytes)"),
|
|
7761
|
+
slash: "0x" + selectorHex3("slash(bytes)")
|
|
7043
7762
|
};
|
|
7044
7763
|
var PROVER_MARKET_EVENT_SIGS = {
|
|
7045
7764
|
proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
|
|
@@ -7077,12 +7796,12 @@ var ProverMarketError = class extends Error {
|
|
|
7077
7796
|
}
|
|
7078
7797
|
};
|
|
7079
7798
|
function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
7080
|
-
return
|
|
7799
|
+
return bytesToHex8(
|
|
7081
7800
|
keccak_256(
|
|
7082
|
-
|
|
7801
|
+
concatBytes7(
|
|
7083
7802
|
new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
|
|
7084
|
-
expectLength5(
|
|
7085
|
-
expectLength5(
|
|
7803
|
+
expectLength5(toBytes5(vkeyHash), 32, "vkeyHash"),
|
|
7804
|
+
expectLength5(toBytes5(inputsHash), 32, "inputsHash"),
|
|
7086
7805
|
u128Bytes(maxFee, "maxFee"),
|
|
7087
7806
|
u64Bytes(deadline, "deadline"),
|
|
7088
7807
|
u64Bytes(nonce, "nonce")
|
|
@@ -7091,44 +7810,44 @@ function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
|
7091
7810
|
);
|
|
7092
7811
|
}
|
|
7093
7812
|
function bidSighash(requestId, fee) {
|
|
7094
|
-
return
|
|
7813
|
+
return bytesToHex8(
|
|
7095
7814
|
keccak_256(
|
|
7096
|
-
|
|
7815
|
+
concatBytes7(
|
|
7097
7816
|
new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
|
|
7098
|
-
expectLength5(
|
|
7817
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
7099
7818
|
u128Bytes(fee, "fee")
|
|
7100
7819
|
)
|
|
7101
7820
|
)
|
|
7102
7821
|
);
|
|
7103
7822
|
}
|
|
7104
7823
|
function submitSighash(requestId, proofHash) {
|
|
7105
|
-
return
|
|
7824
|
+
return bytesToHex8(
|
|
7106
7825
|
keccak_256(
|
|
7107
|
-
|
|
7826
|
+
concatBytes7(
|
|
7108
7827
|
new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
|
|
7109
|
-
expectLength5(
|
|
7110
|
-
expectLength5(
|
|
7828
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
7829
|
+
expectLength5(toBytes5(proofHash), 32, "proofHash")
|
|
7111
7830
|
)
|
|
7112
7831
|
)
|
|
7113
7832
|
);
|
|
7114
7833
|
}
|
|
7115
7834
|
function encodeCreateRequestCanonical(args) {
|
|
7116
|
-
const buyer = expectLength5(
|
|
7117
|
-
const buyerPubkey =
|
|
7118
|
-
const sig =
|
|
7835
|
+
const buyer = expectLength5(toBytes5(args.buyer), 20, "buyer");
|
|
7836
|
+
const buyerPubkey = toBytes5(args.buyerPubkey);
|
|
7837
|
+
const sig = toBytes5(args.sig);
|
|
7119
7838
|
if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
|
|
7120
7839
|
throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
|
|
7121
7840
|
}
|
|
7122
7841
|
if (sig.length === 0 || sig.length > 65535) {
|
|
7123
7842
|
throw new ProverMarketError("sig length out of range (1..=65535)");
|
|
7124
7843
|
}
|
|
7125
|
-
return
|
|
7126
|
-
|
|
7844
|
+
return bytesToHex8(
|
|
7845
|
+
concatBytes7(
|
|
7127
7846
|
buyer,
|
|
7128
7847
|
u16Bytes(buyerPubkey.length),
|
|
7129
7848
|
buyerPubkey,
|
|
7130
|
-
expectLength5(
|
|
7131
|
-
expectLength5(
|
|
7849
|
+
expectLength5(toBytes5(args.vkeyHash), 32, "vkeyHash"),
|
|
7850
|
+
expectLength5(toBytes5(args.inputsHash), 32, "inputsHash"),
|
|
7132
7851
|
u128Bytes(args.maxFee, "maxFee"),
|
|
7133
7852
|
u64Bytes(args.deadline, "deadline"),
|
|
7134
7853
|
u64Bytes(args.nonce, "nonce"),
|
|
@@ -7138,7 +7857,7 @@ function encodeCreateRequestCanonical(args) {
|
|
|
7138
7857
|
);
|
|
7139
7858
|
}
|
|
7140
7859
|
function encodeCreateRequestCalldata(args) {
|
|
7141
|
-
const canonical =
|
|
7860
|
+
const canonical = toBytes5(encodeCreateRequestCanonical(args));
|
|
7142
7861
|
const offset = new Uint8Array(32);
|
|
7143
7862
|
offset[31] = 32;
|
|
7144
7863
|
const lenWord = new Uint8Array(32);
|
|
@@ -7148,18 +7867,18 @@ function encodeCreateRequestCalldata(args) {
|
|
|
7148
7867
|
lenWord[30] = len >>> 8 & 255;
|
|
7149
7868
|
lenWord[31] = len & 255;
|
|
7150
7869
|
const pad = (32 - len % 32) % 32;
|
|
7151
|
-
return
|
|
7152
|
-
|
|
7870
|
+
return bytesToHex8(
|
|
7871
|
+
concatBytes7(hexToBytes7(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
|
|
7153
7872
|
);
|
|
7154
7873
|
}
|
|
7155
|
-
function
|
|
7874
|
+
function selectorHex3(sig) {
|
|
7156
7875
|
return [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7157
7876
|
}
|
|
7158
|
-
function
|
|
7159
|
-
if (typeof value === "string") return
|
|
7877
|
+
function toBytes5(value) {
|
|
7878
|
+
if (typeof value === "string") return hexToBytes7(value);
|
|
7160
7879
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7161
7880
|
}
|
|
7162
|
-
function
|
|
7881
|
+
function hexToBytes7(hex) {
|
|
7163
7882
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7164
7883
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
7165
7884
|
throw new ProverMarketError("invalid hex bytes");
|
|
@@ -7168,10 +7887,10 @@ function hexToBytes6(hex) {
|
|
|
7168
7887
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
7169
7888
|
return out;
|
|
7170
7889
|
}
|
|
7171
|
-
function
|
|
7890
|
+
function bytesToHex8(bytes) {
|
|
7172
7891
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7173
7892
|
}
|
|
7174
|
-
function
|
|
7893
|
+
function concatBytes7(...parts) {
|
|
7175
7894
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7176
7895
|
let offset = 0;
|
|
7177
7896
|
for (const part of parts) {
|
|
@@ -7248,34 +7967,34 @@ function delegationAddressHex() {
|
|
|
7248
7967
|
return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
|
|
7249
7968
|
}
|
|
7250
7969
|
function encodeCompleteRedemptionCalldata(index) {
|
|
7251
|
-
return
|
|
7252
|
-
|
|
7253
|
-
|
|
7254
|
-
|
|
7970
|
+
return bytesToHex9(
|
|
7971
|
+
concatBytes8(
|
|
7972
|
+
hexToBytes8(DELEGATION_SELECTORS.completeRedemption),
|
|
7973
|
+
uint64Word3(index, "index")
|
|
7255
7974
|
)
|
|
7256
7975
|
);
|
|
7257
7976
|
}
|
|
7258
7977
|
function encodeDelegateCalldata(cluster, weightBps) {
|
|
7259
|
-
return
|
|
7260
|
-
|
|
7261
|
-
|
|
7978
|
+
return bytesToHex9(
|
|
7979
|
+
concatBytes8(
|
|
7980
|
+
hexToBytes8(DELEGATION_SELECTORS.delegate),
|
|
7262
7981
|
uint32Word2(cluster, "cluster"),
|
|
7263
7982
|
uint16Word(weightBps, "weightBps")
|
|
7264
7983
|
)
|
|
7265
7984
|
);
|
|
7266
7985
|
}
|
|
7267
7986
|
function encodeUndelegateCalldata(cluster) {
|
|
7268
|
-
return
|
|
7269
|
-
|
|
7270
|
-
|
|
7987
|
+
return bytesToHex9(
|
|
7988
|
+
concatBytes8(
|
|
7989
|
+
hexToBytes8(DELEGATION_SELECTORS.undelegate),
|
|
7271
7990
|
uint32Word2(cluster, "cluster")
|
|
7272
7991
|
)
|
|
7273
7992
|
);
|
|
7274
7993
|
}
|
|
7275
7994
|
function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
|
|
7276
|
-
return
|
|
7277
|
-
|
|
7278
|
-
|
|
7995
|
+
return bytesToHex9(
|
|
7996
|
+
concatBytes8(
|
|
7997
|
+
hexToBytes8(DELEGATION_SELECTORS.redelegate),
|
|
7279
7998
|
uint32Word2(fromCluster, "fromCluster"),
|
|
7280
7999
|
uint32Word2(toCluster, "toCluster"),
|
|
7281
8000
|
uint16Word(weightBps, "weightBps")
|
|
@@ -7288,14 +8007,14 @@ function encodeClaimCalldata() {
|
|
|
7288
8007
|
function encodeSetAutoCompoundCalldata(enabled) {
|
|
7289
8008
|
const flag = new Uint8Array(32);
|
|
7290
8009
|
flag[31] = enabled ? 1 : 0;
|
|
7291
|
-
return
|
|
7292
|
-
|
|
8010
|
+
return bytesToHex9(
|
|
8011
|
+
concatBytes8(hexToBytes8(DELEGATION_SELECTORS.setAutoCompound), flag)
|
|
7293
8012
|
);
|
|
7294
8013
|
}
|
|
7295
8014
|
function isRedemptionPrincipalUnavailableRevert(data) {
|
|
7296
|
-
return
|
|
8015
|
+
return bytesToHex9(toBytes6(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
|
|
7297
8016
|
}
|
|
7298
|
-
function
|
|
8017
|
+
function uint64Word3(value, name) {
|
|
7299
8018
|
const n = toBigint3(value, name);
|
|
7300
8019
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
7301
8020
|
throw new DelegationPrecompileError(`${name} must fit uint64`);
|
|
@@ -7347,13 +8066,13 @@ function toBigint3(value, name) {
|
|
|
7347
8066
|
}
|
|
7348
8067
|
return BigInt(value);
|
|
7349
8068
|
}
|
|
7350
|
-
function
|
|
8069
|
+
function toBytes6(value) {
|
|
7351
8070
|
if (typeof value === "string") {
|
|
7352
|
-
return
|
|
8071
|
+
return hexToBytes8(value);
|
|
7353
8072
|
}
|
|
7354
8073
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7355
8074
|
}
|
|
7356
|
-
function
|
|
8075
|
+
function hexToBytes8(hex) {
|
|
7357
8076
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7358
8077
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7359
8078
|
throw new DelegationPrecompileError("invalid hex bytes");
|
|
@@ -7364,10 +8083,10 @@ function hexToBytes7(hex) {
|
|
|
7364
8083
|
}
|
|
7365
8084
|
return out;
|
|
7366
8085
|
}
|
|
7367
|
-
function
|
|
8086
|
+
function bytesToHex9(bytes) {
|
|
7368
8087
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7369
8088
|
}
|
|
7370
|
-
function
|
|
8089
|
+
function concatBytes8(...parts) {
|
|
7371
8090
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7372
8091
|
let offset = 0;
|
|
7373
8092
|
for (const part of parts) {
|
|
@@ -7376,8 +8095,6 @@ function concatBytes6(...parts) {
|
|
|
7376
8095
|
}
|
|
7377
8096
|
return out;
|
|
7378
8097
|
}
|
|
7379
|
-
|
|
7380
|
-
// src/spending-policy.ts
|
|
7381
8098
|
var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
|
|
7382
8099
|
var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
|
|
7383
8100
|
var ML_DSA_65_SIGNATURE_LEN2 = 3309;
|
|
@@ -7400,10 +8117,38 @@ var SpendingPolicyError = class extends Error {
|
|
|
7400
8117
|
function spendingPolicyAddressHex() {
|
|
7401
8118
|
return PRECOMPILE_ADDRESSES.SPENDING_POLICY.toLowerCase();
|
|
7402
8119
|
}
|
|
8120
|
+
var EMPTY_ROOT = new Uint8Array(32);
|
|
8121
|
+
function destinationRoot(address) {
|
|
8122
|
+
const bytes = toUserAddressBytes(address, "address");
|
|
8123
|
+
return keccak_256(bytes);
|
|
8124
|
+
}
|
|
8125
|
+
var allowRootFor = destinationRoot;
|
|
8126
|
+
var denyRootFor = destinationRoot;
|
|
8127
|
+
function categoryRoot(selectorOrSig) {
|
|
8128
|
+
let selector;
|
|
8129
|
+
if (typeof selectorOrSig === "string") {
|
|
8130
|
+
selector = keccak_256(new TextEncoder().encode(selectorOrSig)).slice(0, 4);
|
|
8131
|
+
} else {
|
|
8132
|
+
selector = selectorOrSig instanceof Uint8Array ? selectorOrSig : Uint8Array.from(selectorOrSig);
|
|
8133
|
+
if (selector.length !== 4) {
|
|
8134
|
+
throw new SpendingPolicyError("category selector must be exactly 4 bytes");
|
|
8135
|
+
}
|
|
8136
|
+
}
|
|
8137
|
+
return keccak_256(selector);
|
|
8138
|
+
}
|
|
8139
|
+
function setDestinationRoot(entries) {
|
|
8140
|
+
if (entries.length === 0) return EMPTY_ROOT;
|
|
8141
|
+
if (entries.length > 1) {
|
|
8142
|
+
throw new SpendingPolicyError(
|
|
8143
|
+
"multi-entry destination sets are not supported by the chain yet (v1 allows a single counterparty per root); pass exactly one address"
|
|
8144
|
+
);
|
|
8145
|
+
}
|
|
8146
|
+
return destinationRoot(entries[0]);
|
|
8147
|
+
}
|
|
7403
8148
|
function composeClaimBoundMessage(chainId, args, opts) {
|
|
7404
8149
|
const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
|
|
7405
8150
|
const normalized = normalizeArgs(args);
|
|
7406
|
-
return
|
|
8151
|
+
return concatBytes9(
|
|
7407
8152
|
new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
|
|
7408
8153
|
uint64Bytes(chainId, "chainId"),
|
|
7409
8154
|
precompileAddress,
|
|
@@ -7426,17 +8171,17 @@ function composeClaimBoundMessage(chainId, args, opts) {
|
|
|
7426
8171
|
}
|
|
7427
8172
|
function encodeSetPolicyCalldata(args) {
|
|
7428
8173
|
const normalized = normalizeArgs(args);
|
|
7429
|
-
return
|
|
7430
|
-
|
|
7431
|
-
|
|
8174
|
+
return bytesToHex10(
|
|
8175
|
+
concatBytes9(
|
|
8176
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicy),
|
|
7432
8177
|
encodePolicyWords(normalized)
|
|
7433
8178
|
)
|
|
7434
8179
|
);
|
|
7435
8180
|
}
|
|
7436
8181
|
function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
7437
8182
|
const normalized = normalizeArgs(args);
|
|
7438
|
-
const pubkey =
|
|
7439
|
-
const sig =
|
|
8183
|
+
const pubkey = toBytes7(subAccountPubkey);
|
|
8184
|
+
const sig = toBytes7(subAccountSig);
|
|
7440
8185
|
if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
|
|
7441
8186
|
throw new SpendingPolicyError(
|
|
7442
8187
|
`subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
|
|
@@ -7447,9 +8192,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7447
8192
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7448
8193
|
);
|
|
7449
8194
|
}
|
|
7450
|
-
return
|
|
7451
|
-
|
|
7452
|
-
|
|
8195
|
+
return bytesToHex10(
|
|
8196
|
+
concatBytes9(
|
|
8197
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicyClaim),
|
|
7453
8198
|
encodePolicyWords(normalized),
|
|
7454
8199
|
pubkey,
|
|
7455
8200
|
sig
|
|
@@ -7458,15 +8203,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7458
8203
|
}
|
|
7459
8204
|
function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
|
|
7460
8205
|
const normalized = normalizeArgs(args);
|
|
7461
|
-
const sig =
|
|
8206
|
+
const sig = toBytes7(subAccountSig);
|
|
7462
8207
|
if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
|
|
7463
8208
|
throw new SpendingPolicyError(
|
|
7464
8209
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7465
8210
|
);
|
|
7466
8211
|
}
|
|
7467
|
-
return
|
|
7468
|
-
|
|
7469
|
-
|
|
8212
|
+
return bytesToHex10(
|
|
8213
|
+
concatBytes9(
|
|
8214
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
|
|
7470
8215
|
encodePolicyWords(normalized),
|
|
7471
8216
|
sig
|
|
7472
8217
|
)
|
|
@@ -7485,17 +8230,17 @@ function normalizeArgs(args) {
|
|
|
7485
8230
|
principal: toUserAddressBytes(args.principal, "principal"),
|
|
7486
8231
|
dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
|
|
7487
8232
|
perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
7488
|
-
allowRoot: expectLength6(
|
|
7489
|
-
denyRoot: expectLength6(
|
|
8233
|
+
allowRoot: expectLength6(toBytes7(args.allowRoot), 32, "allowRoot"),
|
|
8234
|
+
denyRoot: expectLength6(toBytes7(args.denyRoot), 32, "denyRoot"),
|
|
7490
8235
|
weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
|
|
7491
8236
|
monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
|
|
7492
|
-
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(
|
|
7493
|
-
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(
|
|
8237
|
+
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes7(args.categoryAllowRoot), 32, "categoryAllowRoot"),
|
|
8238
|
+
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes7(args.timeWindow), 32, "timeWindow"),
|
|
7494
8239
|
policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
|
|
7495
8240
|
};
|
|
7496
8241
|
}
|
|
7497
8242
|
function encodePolicyWords(args) {
|
|
7498
|
-
return
|
|
8243
|
+
return concatBytes9(
|
|
7499
8244
|
encodeAddressWord(args.subAccount),
|
|
7500
8245
|
encodeAddressWord(args.principal),
|
|
7501
8246
|
encodeUint128Word(args.dailyCapLythoshi),
|
|
@@ -7520,7 +8265,7 @@ function packTimeWindow(enabled, startHour, endHour) {
|
|
|
7520
8265
|
return out;
|
|
7521
8266
|
}
|
|
7522
8267
|
function decodeTimeWindow(word) {
|
|
7523
|
-
const bytes = expectLength6(
|
|
8268
|
+
const bytes = expectLength6(toBytes7(word), 32, "timeWindow");
|
|
7524
8269
|
if (bytes.every((b) => b === 0)) return null;
|
|
7525
8270
|
if (bytes[29] === 0) return null;
|
|
7526
8271
|
return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
|
|
@@ -7532,16 +8277,16 @@ function clampHour(hour) {
|
|
|
7532
8277
|
return Math.min(hour, 23);
|
|
7533
8278
|
}
|
|
7534
8279
|
function encodeUint64Word(value) {
|
|
7535
|
-
return
|
|
8280
|
+
return concatBytes9(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
|
|
7536
8281
|
}
|
|
7537
8282
|
function encodeSingleAddressCall(selector, address, name) {
|
|
7538
|
-
return
|
|
8283
|
+
return bytesToHex10(concatBytes9(hexToBytes9(selector), encodeAddressWord(toUserAddressBytes(address, name))));
|
|
7539
8284
|
}
|
|
7540
8285
|
function encodeAddressWord(address) {
|
|
7541
|
-
return
|
|
8286
|
+
return concatBytes9(new Uint8Array(12), address);
|
|
7542
8287
|
}
|
|
7543
8288
|
function encodeUint128Word(value) {
|
|
7544
|
-
return
|
|
8289
|
+
return concatBytes9(new Uint8Array(16), uint128Bytes(value, "uint128"));
|
|
7545
8290
|
}
|
|
7546
8291
|
function toUserAddressBytes(value, name) {
|
|
7547
8292
|
if (typeof value !== "string") {
|
|
@@ -7563,13 +8308,13 @@ function toRawAddressBytes(value) {
|
|
|
7563
8308
|
}
|
|
7564
8309
|
return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
|
|
7565
8310
|
}
|
|
7566
|
-
function
|
|
8311
|
+
function toBytes7(value) {
|
|
7567
8312
|
if (typeof value === "string") {
|
|
7568
|
-
return
|
|
8313
|
+
return hexToBytes9(value);
|
|
7569
8314
|
}
|
|
7570
8315
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7571
8316
|
}
|
|
7572
|
-
function
|
|
8317
|
+
function hexToBytes9(hex) {
|
|
7573
8318
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7574
8319
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7575
8320
|
throw new SpendingPolicyError("invalid hex bytes");
|
|
@@ -7580,10 +8325,10 @@ function hexToBytes8(hex) {
|
|
|
7580
8325
|
}
|
|
7581
8326
|
return out;
|
|
7582
8327
|
}
|
|
7583
|
-
function
|
|
8328
|
+
function bytesToHex10(bytes) {
|
|
7584
8329
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7585
8330
|
}
|
|
7586
|
-
function
|
|
8331
|
+
function concatBytes9(...parts) {
|
|
7587
8332
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7588
8333
|
let offset = 0;
|
|
7589
8334
|
for (const part of parts) {
|
|
@@ -7645,17 +8390,17 @@ function pubkeyRegistryAddressHex() {
|
|
|
7645
8390
|
return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
|
|
7646
8391
|
}
|
|
7647
8392
|
function encodeRegisterPubkeyCalldata(pubkey) {
|
|
7648
|
-
const bytes =
|
|
8393
|
+
const bytes = toBytes8(pubkey);
|
|
7649
8394
|
if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
7650
8395
|
throw new PubkeyRegistryError(
|
|
7651
8396
|
`pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
|
|
7652
8397
|
);
|
|
7653
8398
|
}
|
|
7654
|
-
return
|
|
7655
|
-
|
|
7656
|
-
|
|
7657
|
-
|
|
7658
|
-
|
|
8399
|
+
return bytesToHex11(
|
|
8400
|
+
concatBytes10(
|
|
8401
|
+
hexToBytes10(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
|
|
8402
|
+
uint256Word2(32n),
|
|
8403
|
+
uint256Word2(BigInt(bytes.length)),
|
|
7659
8404
|
bytes
|
|
7660
8405
|
)
|
|
7661
8406
|
);
|
|
@@ -7667,7 +8412,7 @@ function encodeHasPubkeyCalldata(address) {
|
|
|
7667
8412
|
return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
|
|
7668
8413
|
}
|
|
7669
8414
|
function decodeLookupPubkeyReturn(data) {
|
|
7670
|
-
const bytes =
|
|
8415
|
+
const bytes = toBytes8(data);
|
|
7671
8416
|
if (bytes.length < 96) {
|
|
7672
8417
|
throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
|
|
7673
8418
|
}
|
|
@@ -7692,7 +8437,7 @@ function decodeLookupPubkeyReturn(data) {
|
|
|
7692
8437
|
};
|
|
7693
8438
|
}
|
|
7694
8439
|
function decodeHasPubkeyReturn(data) {
|
|
7695
|
-
const bytes =
|
|
8440
|
+
const bytes = toBytes8(data);
|
|
7696
8441
|
if (bytes.length !== 32) {
|
|
7697
8442
|
throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
|
|
7698
8443
|
}
|
|
@@ -7706,10 +8451,10 @@ function decodeHasPubkeyReturn(data) {
|
|
|
7706
8451
|
throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
|
|
7707
8452
|
}
|
|
7708
8453
|
function encodeSingleAddressCall2(selector, address) {
|
|
7709
|
-
return
|
|
8454
|
+
return bytesToHex11(concatBytes10(hexToBytes10(selector), addressWord3(toAddressBytes(address))));
|
|
7710
8455
|
}
|
|
7711
|
-
function
|
|
7712
|
-
return
|
|
8456
|
+
function addressWord3(address) {
|
|
8457
|
+
return concatBytes10(new Uint8Array(12), address);
|
|
7713
8458
|
}
|
|
7714
8459
|
function toAddressBytes(value) {
|
|
7715
8460
|
if (typeof value !== "string") {
|
|
@@ -7725,13 +8470,13 @@ function toAddressBytes(value) {
|
|
|
7725
8470
|
throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
|
|
7726
8471
|
}
|
|
7727
8472
|
}
|
|
7728
|
-
function
|
|
8473
|
+
function toBytes8(value) {
|
|
7729
8474
|
if (typeof value === "string") {
|
|
7730
|
-
return
|
|
8475
|
+
return hexToBytes10(value);
|
|
7731
8476
|
}
|
|
7732
8477
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7733
8478
|
}
|
|
7734
|
-
function
|
|
8479
|
+
function hexToBytes10(hex) {
|
|
7735
8480
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7736
8481
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7737
8482
|
throw new PubkeyRegistryError("invalid hex bytes");
|
|
@@ -7742,10 +8487,10 @@ function hexToBytes9(hex) {
|
|
|
7742
8487
|
}
|
|
7743
8488
|
return out;
|
|
7744
8489
|
}
|
|
7745
|
-
function
|
|
8490
|
+
function bytesToHex11(bytes) {
|
|
7746
8491
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7747
8492
|
}
|
|
7748
|
-
function
|
|
8493
|
+
function concatBytes10(...parts) {
|
|
7749
8494
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7750
8495
|
let offset = 0;
|
|
7751
8496
|
for (const part of parts) {
|
|
@@ -7754,7 +8499,7 @@ function concatBytes8(...parts) {
|
|
|
7754
8499
|
}
|
|
7755
8500
|
return out;
|
|
7756
8501
|
}
|
|
7757
|
-
function
|
|
8502
|
+
function uint256Word2(value) {
|
|
7758
8503
|
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
7759
8504
|
throw new PubkeyRegistryError("uint256 value out of range");
|
|
7760
8505
|
}
|
|
@@ -7902,9 +8647,9 @@ function encodePlaceLimitOrderCalldata(args) {
|
|
|
7902
8647
|
normalized.baseTokenId,
|
|
7903
8648
|
normalized.quoteTokenId,
|
|
7904
8649
|
uint8Word2(normalized.side),
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
8650
|
+
uint256Word3(normalized.price, "price"),
|
|
8651
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
8652
|
+
uint64Word4(normalized.expiryBlock, "expiryBlock")
|
|
7908
8653
|
)
|
|
7909
8654
|
);
|
|
7910
8655
|
}
|
|
@@ -7916,7 +8661,7 @@ function encodePlaceMarketOrderCalldata(args) {
|
|
|
7916
8661
|
normalized.baseTokenId,
|
|
7917
8662
|
normalized.quoteTokenId,
|
|
7918
8663
|
uint8Word2(normalized.side),
|
|
7919
|
-
|
|
8664
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7920
8665
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps")
|
|
7921
8666
|
)
|
|
7922
8667
|
);
|
|
@@ -7929,7 +8674,7 @@ function encodePlaceMarketOrderExCalldata(args) {
|
|
|
7929
8674
|
normalized.baseTokenId,
|
|
7930
8675
|
normalized.quoteTokenId,
|
|
7931
8676
|
uint8Word2(normalized.side),
|
|
7932
|
-
|
|
8677
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7933
8678
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps"),
|
|
7934
8679
|
uint8Word2(normalized.mode)
|
|
7935
8680
|
)
|
|
@@ -7949,7 +8694,7 @@ function encodeMarketGridTuneCalldata(selector, label, args) {
|
|
|
7949
8694
|
hexToBytes2(selector, `${label} selector`),
|
|
7950
8695
|
bytes32FromHex(args.baseTokenId, "baseTokenId"),
|
|
7951
8696
|
bytes32FromHex(args.quoteTokenId, "quoteTokenId"),
|
|
7952
|
-
|
|
8697
|
+
uint256Word3(BigInt(args.newValue), "newValue")
|
|
7953
8698
|
)
|
|
7954
8699
|
);
|
|
7955
8700
|
}
|
|
@@ -8237,13 +8982,13 @@ function encodePlaceLimitOrderViaCalldata(args) {
|
|
|
8237
8982
|
return bytesToHex2(
|
|
8238
8983
|
concatBytes2(
|
|
8239
8984
|
hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
|
|
8240
|
-
|
|
8985
|
+
addressWord4(operator.bytes),
|
|
8241
8986
|
bytes32FromHex(args.base, "base"),
|
|
8242
8987
|
bytes32FromHex(args.quote, "quote"),
|
|
8243
8988
|
uint8Word2(side),
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8989
|
+
uint256Word3(price, "price"),
|
|
8990
|
+
uint256Word3(amount, "amount"),
|
|
8991
|
+
uint64Word4(expiresAtBlock, "expiresAtBlock")
|
|
8247
8992
|
)
|
|
8248
8993
|
);
|
|
8249
8994
|
}
|
|
@@ -8533,7 +9278,7 @@ function uint8Word2(value) {
|
|
|
8533
9278
|
out[31] = value;
|
|
8534
9279
|
return out;
|
|
8535
9280
|
}
|
|
8536
|
-
function
|
|
9281
|
+
function uint64Word4(value, name) {
|
|
8537
9282
|
if (value < 0n || value > 0xffffffffffffffffn) {
|
|
8538
9283
|
throw new MarketActionError(`${name} must fit uint64`);
|
|
8539
9284
|
}
|
|
@@ -8554,7 +9299,7 @@ function uint16Word2(value, name) {
|
|
|
8554
9299
|
out[31] = Number(value & 0xffn);
|
|
8555
9300
|
return out;
|
|
8556
9301
|
}
|
|
8557
|
-
function
|
|
9302
|
+
function uint256Word3(value, name) {
|
|
8558
9303
|
if (value < 0n || value >= 1n << 256n) {
|
|
8559
9304
|
throw new MarketActionError(`${name} must fit uint256`);
|
|
8560
9305
|
}
|
|
@@ -8566,7 +9311,7 @@ function uint256Word2(value, name) {
|
|
|
8566
9311
|
}
|
|
8567
9312
|
return out;
|
|
8568
9313
|
}
|
|
8569
|
-
function
|
|
9314
|
+
function addressWord4(addr) {
|
|
8570
9315
|
if (addr.length !== 20) {
|
|
8571
9316
|
throw new MarketActionError("address must be 20 bytes");
|
|
8572
9317
|
}
|
|
@@ -9108,6 +9853,6 @@ var MONOLYTHIUM_NETWORKS = {
|
|
|
9108
9853
|
// src/index.ts
|
|
9109
9854
|
var version = "0.2.2";
|
|
9110
9855
|
|
|
9111
|
-
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, CLUSTER_FORMED_EVENT_SIG, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DIVERSITY_SCORE_MAX, DelegationPrecompileError, EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MULTISIG_ADDRESS_DERIVATION_DOMAIN, MarketActionError, MrvValidationError, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NoEvmReceiptProofError, NodeRegistryError, OPERATOR_ROUTER_ADDRESS, OPERATOR_ROUTER_EVENT_SIGS, OPERATOR_ROUTER_SELECTORS, OPERATOR_ROUTER_SIGS, ORACLE_EVENT_SIGS, OracleEventError, PRECOMPILE_ADDRESSES, PROTOCOL_MAX_OPERATOR_FEE_BPS, PROVER_MARKET_ADDRESS, PROVER_MARKET_BID_DOMAIN, PROVER_MARKET_EVENT_SIGS, PROVER_MARKET_REQUEST_DOMAIN, PROVER_MARKET_SELECTORS, PROVER_MARKET_SUBMIT_DOMAIN, PROVER_SLASH_REASON_BAD_PROOF, PROVER_SLASH_REASON_NON_DELIVERY, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, ProverMarketError, PubkeyRegistryError, REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bidSighash, bridgeAddressHex, bridgeDrainRemaining, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceLimitOrderViaPlan, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, consumeNativeEvents, decodeClusterDiversity, decodeClusterFormedEvent, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodeTimeWindow, decodeTxFeedResponse, delegationAddressHex, deriveClobMarketId, deriveClusterAnchorAddress, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, encodeBlockSelector, encodeCancelOrderCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceLimitOrderViaCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeUndelegateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeHostingClassFromByte, nodeHostingClassToByte, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, oracleAddressHex, packTimeWindow, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseLythToLythoshi, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, requestSighash, requireTypedAddress, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitSighash, transactionFeeExposure, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
9856
|
+
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, CLUSTER_FORMED_EVENT_SIG, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DIVERSITY_SCORE_MAX, DelegationPrecompileError, EMPTY_ROOT, EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER, FEED_ID_DOMAIN_TAG, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MULTISIG_ADDRESS_DERIVATION_DOMAIN, MarketActionError, MrvValidationError, NAME_BASE_MULTIPLIER, NAME_FALLBACK_FEE_UNIT_LYTHOSHI, NAME_LABEL_MAX_LEN, NAME_LABEL_MIN_LEN, NAME_MAX_LEN, NAME_REGISTRY_SELECTORS, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_BLS_PUBKEY_BYTES, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS, NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS, NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES, NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NameRegistryError, NoEvmReceiptProofError, NodeRegistryError, OPERATOR_ROUTER_ADDRESS, OPERATOR_ROUTER_EVENT_SIGS, OPERATOR_ROUTER_SELECTORS, OPERATOR_ROUTER_SIGS, ORACLE_EVENT_SIGS, OracleEventError, PENDING_CHANGE_KIND_CODES, PRECOMPILE_ADDRESSES, PROTOCOL_MAX_OPERATOR_FEE_BPS, PROVER_MARKET_ADDRESS, PROVER_MARKET_BID_DOMAIN, PROVER_MARKET_EVENT_SIGS, PROVER_MARKET_REQUEST_DOMAIN, PROVER_MARKET_SELECTORS, PROVER_MARKET_SUBMIT_DOMAIN, PROVER_SLASH_REASON_BAD_PROOF, PROVER_SLASH_REASON_NON_DELIVERY, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, ProverMarketError, PubkeyRegistryError, REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, allowRootFor, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bidSighash, bridgeAddressHex, bridgeDrainRemaining, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceLimitOrderViaPlan, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, categoryRoot, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, clusterApyPercent, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, computeQuoteLiquidity, consumeNativeEvents, decodeClusterDiversity, decodeClusterFormedEvent, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodeTimeWindow, decodeTxFeedResponse, delegationAddressHex, denyRootFor, deriveClobMarketId, deriveClusterAnchorAddress, deriveFeedId, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, destinationRoot, encodeAttestDkgReshareCalldata, encodeBlockSelector, encodeBridgeChallengeCalldata, encodeBridgeClaimCalldata, encodeCancelOrderCalldata, encodeCancelPendingChangeCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNameAcceptTransferCall, encodeNameProposeTransferCall, encodeNameRegisterCall, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceLimitOrderViaCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRecoverOperatorNodeCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeSubmitBridgeProofCalldata, encodeSubmitPendingChangeCalldata, encodeUndelegateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, formatOraclePrice, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nameLengthModifierX10, nameRegistrationCost, nameRegistryAddressHex, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeHostingClassFromByte, nodeHostingClassToByte, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, normalizePendingChangeKind, oracleAddressHex, oraclePriceToNumber, packTimeWindow, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseDkgResharePublicKeys, parseLythToLythoshi, parseNameCategory, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, rankMarketsByVolume, requestSighash, requireTypedAddress, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, setDestinationRoot, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitSighash, transactionFeeExposure, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
9112
9857
|
//# sourceMappingURL=index.js.map
|
|
9113
9858
|
//# sourceMappingURL=index.js.map
|