@monolythium/core-sdk 0.3.13 → 0.3.15

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/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { blake3 } from '@noble/hashes/blake3.js';
2
2
  import { keccak_256 } from '@noble/hashes/sha3.js';
3
- import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
4
- import { chacha20poly1305 } from '@noble/ciphers/chacha.js';
5
- import { randomBytes } from '@noble/hashes/utils.js';
6
3
  import { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';
7
4
  import { bls12_381 } from '@noble/curves/bls12-381.js';
5
+ import '@noble/post-quantum/ml-kem.js';
6
+ import '@noble/ciphers/chacha.js';
7
+ import '@noble/hashes/utils.js';
8
8
 
9
9
  // src/error.ts
10
10
  var SdkError = class _SdkError extends Error {
@@ -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);
@@ -709,15 +895,26 @@ function bigintToBeBytes(value, bytes, label) {
709
895
  }
710
896
  return out;
711
897
  }
712
- function parseBigint(value, label) {
713
- if (value === void 0) throw new Error(`${label} missing`);
714
- if (typeof value === "bigint") return value;
715
- if (typeof value === "number") {
716
- if (!Number.isSafeInteger(value) || value < 0) throw new Error(`${label} must be a non-negative safe integer`);
717
- return BigInt(value);
718
- }
719
- if (value.startsWith("0x") || value.startsWith("0X")) return BigInt(value);
720
- return BigInt(value);
898
+
899
+ // src/crypto/submission.ts
900
+ async function fetchEncryptionKey(client) {
901
+ const result = await client.call(
902
+ "lyth_getEncryptionKey",
903
+ []
904
+ );
905
+ return {
906
+ algo: result.algo ?? "ml-kem-768",
907
+ epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
908
+ encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
909
+ };
910
+ }
911
+ var ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE = "encrypted mempool submission unavailable until MB-3 threshold decryption is active";
912
+ async function buildEncryptedSubmission(_args) {
913
+ await Promise.resolve();
914
+ throw new Error(ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE);
915
+ }
916
+ async function submitEncryptedEnvelope(client, envelopeWireHex) {
917
+ return client.call("lyth_submitEncrypted", [envelopeWireHex]);
721
918
  }
722
919
 
723
920
  // src/crypto/bincode.ts
@@ -778,164 +975,6 @@ var BincodeWriter = class {
778
975
  }
779
976
  }
780
977
  };
781
- var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
782
- var ML_DSA_65_SIGNATURE_LEN = 3309;
783
- var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
784
- var ENUM_VARIANT_INDEX_ML_DSA_65 = 5;
785
- var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
786
- var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
787
- function mlDsa65AddressFromPublicKey(publicKey) {
788
- return bytesToHex2(mlDsa65AddressBytes(publicKey));
789
- }
790
- function mlDsa65AddressBytes(publicKey) {
791
- const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
792
- return blake3(concatBytes2(
793
- ADDRESS_DERIVATION_DOMAIN_BYTES,
794
- bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
795
- bytes
796
- )).slice(0, 20);
797
- }
798
-
799
- // src/crypto/envelope.ts
800
- var DKG_AEAD_DOMAIN_TAG = new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
801
- var ML_KEM_768_ENCAPSULATION_KEY_LEN = 1184;
802
- var DKG_NONCE_LEN = 12;
803
- var MempoolClass = {
804
- Transfer: 0,
805
- ContractCall: 1,
806
- CLOBOp: 3};
807
- function bincodeNonceAad(aad) {
808
- const w = new BincodeWriter();
809
- w.bytes(expectBytes(aad.sender, 20, "NonceAad.sender"));
810
- w.u64(aad.nonce);
811
- w.u64(aad.chainId);
812
- w.enumVariant(aad.class);
813
- w.u128(aad.maxFeePerGas);
814
- w.u128(aad.maxPriorityFeePerGas);
815
- w.u64(aad.gasLimit);
816
- return w.toBytes();
817
- }
818
- function bincodeDecryptHint(hint) {
819
- const w = new BincodeWriter();
820
- w.u64(hint.epoch);
821
- w.u16(hint.scheme);
822
- return w.toBytes();
823
- }
824
- function bincodeEncryptedEnvelope(env) {
825
- const w = new BincodeWriter();
826
- w.rawBytes(bincodeNonceAad(env.nonceAad));
827
- w.bytes(env.ciphertext);
828
- w.rawBytes(bincodeDecryptHint(env.decryptionHint));
829
- bincodeMlDsa65OpaqueInto(w, expectBytes(env.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey"));
830
- bincodeMlDsa65OpaqueInto(w, expectBytes(env.outerSignature, ML_DSA_65_SIGNATURE_LEN, "outerSignature"));
831
- w.bytes(expectBytes(env.sender, 20, "sender"));
832
- return w.toBytes();
833
- }
834
- function encryptInnerTx(signedInnerTxBincode, nonceAad, kemEncapsulationKey) {
835
- expectBytes(kemEncapsulationKey, ML_KEM_768_ENCAPSULATION_KEY_LEN, "kemEncapsulationKey");
836
- const { cipherText: kemCt, sharedSecret } = ml_kem768.encapsulate(kemEncapsulationKey);
837
- const nonce = randomBytes(DKG_NONCE_LEN);
838
- const cipher = chacha20poly1305(sharedSecret, nonce, aadFor(nonceAad));
839
- const aeadCt = cipher.encrypt(signedInnerTxBincode);
840
- sharedSecret.fill(0);
841
- return concatBytes2(kemCt, nonce, aeadCt);
842
- }
843
- function outerSigDigest(nonceAad, ciphertext, decryptionHint, senderPubkey) {
844
- const aad = bincodeNonceAad(nonceAad);
845
- const hint = bincodeDecryptHint(decryptionHint);
846
- return keccak_256(concatBytes2(aad, ciphertext, hint, expectBytes(senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey")));
847
- }
848
- async function buildEncryptedEnvelope(args) {
849
- const ciphertext = encryptInnerTx(args.signedInnerTxBincode, args.nonceAad, args.kemEncapsulationKey);
850
- const digest = outerSigDigest(args.nonceAad, ciphertext, args.decryptionHint, args.senderPubkey);
851
- const outerSignature = await args.signOuterDigest(digest);
852
- const envelope = {
853
- nonceAad: args.nonceAad,
854
- ciphertext,
855
- decryptionHint: args.decryptionHint,
856
- senderPubkey: expectBytes(args.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey"),
857
- outerSignature: expectBytes(outerSignature, ML_DSA_65_SIGNATURE_LEN, "outerSignature"),
858
- sender: expectBytes(args.senderAddress, 20, "senderAddress")
859
- };
860
- const wireBytes = bincodeEncryptedEnvelope(envelope);
861
- return { envelope, wireBytes, wireHex: bytesToHex2(wireBytes) };
862
- }
863
- function aadFor(aad) {
864
- return concatBytes2(DKG_AEAD_DOMAIN_TAG, bincodeNonceAad(aad));
865
- }
866
- function bincodeMlDsa65OpaqueInto(w, raw) {
867
- w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
868
- w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
869
- w.bytes(raw);
870
- }
871
-
872
- // src/crypto/submission.ts
873
- async function fetchEncryptionKey(client) {
874
- const result = await client.call(
875
- "lyth_getEncryptionKey",
876
- []
877
- );
878
- return {
879
- algo: result.algo ?? "ml-kem-768",
880
- epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
881
- encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
882
- };
883
- }
884
- async function buildEncryptedSubmission(args) {
885
- const input = normalizeInput(args.tx.input);
886
- const to = normalizeTo(args.tx.to);
887
- const nonceAad = {
888
- sender: args.backend.addressBytes(),
889
- nonce: parseBigint(args.tx.nonce, "nonce"),
890
- chainId: parseBigint(args.tx.chainId, "chainId"),
891
- class: args.class ?? (to !== null && input.length === 0 ? MempoolClass.Transfer : MempoolClass.ContractCall),
892
- maxFeePerGas: u128Checked(parseBigint(args.tx.maxFeePerGas, "maxFeePerGas"), "maxFeePerGas"),
893
- maxPriorityFeePerGas: u128Checked(
894
- parseBigint(args.tx.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
895
- "maxPriorityFeePerGas"
896
- ),
897
- gasLimit: parseBigint(args.tx.gasLimit, "gasLimit")
898
- };
899
- const signed = args.backend.signEvmTx(args.tx);
900
- const decryptionHint = { epoch: args.encryptionKey.epoch, scheme: 0 };
901
- const built = await buildEncryptedEnvelope({
902
- signedInnerTxBincode: signed.wireBytes,
903
- nonceAad,
904
- decryptionHint,
905
- kemEncapsulationKey: args.encryptionKey.encapsulationKey,
906
- senderAddress: args.backend.addressBytes(),
907
- senderPubkey: args.backend.publicKey(),
908
- signOuterDigest: (digest) => args.backend.signPrehash(digest)
909
- });
910
- return {
911
- envelopeWireHex: built.wireHex,
912
- innerSighashHex: `0x${[...signed.sighash].map((b) => b.toString(16).padStart(2, "0")).join("")}`,
913
- innerTxHashHex: bytesToHex2(signed.txHash),
914
- innerWireBytes: signed.wireBytes.length
915
- };
916
- }
917
- async function submitEncryptedEnvelope(client, envelopeWireHex) {
918
- return client.call("lyth_submitEncrypted", [envelopeWireHex]);
919
- }
920
- function u128Checked(value, field2) {
921
- const cap = (1n << 128n) - 1n;
922
- if (value < 0n || value > cap) {
923
- throw new Error(`${field2} must fit in u128 for encrypted nonce AAD`);
924
- }
925
- return value;
926
- }
927
- function normalizeTo(value) {
928
- if (value === null) return null;
929
- if (typeof value === "string") return hexToAddressBytes(value);
930
- const bytes = value instanceof Uint8Array ? value : Uint8Array.from(value);
931
- if (bytes.length !== 20) throw new Error("to must be 20 bytes");
932
- return bytes;
933
- }
934
- function normalizeInput(value) {
935
- if (value === void 0) return new Uint8Array(0);
936
- if (typeof value === "string") return hexToBytes2(value, "input");
937
- return value instanceof Uint8Array ? value : Uint8Array.from(value);
938
- }
939
978
 
940
979
  // src/mrv.ts
941
980
  var MRV_FORMAT_VERSION = 1;
@@ -947,9 +986,9 @@ var MRV_MAX_DEBUG_BYTES = 16 * 1024 * 1024;
947
986
  var MRV_MAX_MEMORY_PAGES = 1024;
948
987
  var MRV_MAX_ABI_SYMBOLS = 1024;
949
988
  var MRV_MAX_STORAGE_NAMESPACE_BYTES = 64;
950
- var LYTH_DECIMALS = 8;
989
+ var LYTH_DECIMALS = 18;
951
990
  var NATIVE_LYTH_DECIMALS = LYTH_DECIMALS;
952
- var LYTHOSHI_PER_LYTH = 100000000n;
991
+ var LYTHOSHI_PER_LYTH = 1000000000000000000n;
953
992
  var MRV_TX_EXTENSION_KIND = 48;
954
993
  var MRV_TX_EXTENSION_V1 = 1;
955
994
  var MRV_CODE_HASH_DOMAIN = new TextEncoder().encode("MONO_MRV_CODE_V1");
@@ -1016,7 +1055,7 @@ function parseLythToLythoshi(input) {
1016
1055
  throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
1017
1056
  }
1018
1057
  if (fractionRaw.length > NATIVE_LYTH_DECIMALS || !/^[0-9]*$/.test(fractionRaw)) {
1019
- throw new MrvValidationError("lyth amount supports at most 8 decimal places");
1058
+ throw new MrvValidationError(`lyth amount supports at most ${NATIVE_LYTH_DECIMALS} decimal places`);
1020
1059
  }
1021
1060
  const whole = BigInt(wholeRaw.replaceAll(",", ""));
1022
1061
  const fraction = fractionRaw === "" ? 0n : BigInt(fractionRaw.padEnd(NATIVE_LYTH_DECIMALS, "0"));
@@ -1040,7 +1079,7 @@ function checkMrvFeeDisplayConformance(input) {
1040
1079
  failures.push(`defaultFeeText fee must total ${expectedTotalLythoshi} lythoshi`);
1041
1080
  }
1042
1081
  } catch {
1043
- failures.push("defaultFeeText fee must be a canonical 8-decimal LYTH amount");
1082
+ failures.push(`defaultFeeText fee must be a canonical ${NATIVE_LYTH_DECIMALS}-decimal LYTH amount`);
1044
1083
  }
1045
1084
  }
1046
1085
  const defaultForbidden = firstForbiddenDefaultFeeTerm(input.defaultFeeText);
@@ -1424,38 +1463,20 @@ function buildMrvNativeFeePreview(executionUnitLimit, maxExecutionFeeLythoshi, p
1424
1463
  async function submitMrvDeployNativeTx(client, backend, artifactBytes, options) {
1425
1464
  const plan = buildMrvDeployNativeTxPlan(artifactBytes, options);
1426
1465
  assertMrvDeployNativeSubmissionPlan(plan);
1427
- const submission = await buildEncryptedSubmission({
1428
- backend,
1429
- tx: plan.tx,
1430
- encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
1431
- class: options.class
1432
- });
1433
- return {
1434
- ...plan,
1435
- ...submission,
1436
- txHash: await submitEncryptedEnvelope(client, submission.envelopeWireHex)
1437
- };
1466
+ return submitMrvEncryptedNativeTxGated(client, backend, plan, options);
1438
1467
  }
1439
1468
  async function submitMrvDeployPayloadNativeTx(client, backend, artifactBytes, options) {
1440
1469
  const plan = buildMrvDeployPayloadNativeTxPlan(artifactBytes, options);
1441
1470
  assertMrvDeployNativeSubmissionPlan(plan);
1442
- const submission = await buildEncryptedSubmission({
1443
- backend,
1444
- tx: plan.tx,
1445
- encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
1446
- class: options.class
1447
- });
1448
- return {
1449
- ...plan,
1450
- ...submission,
1451
- txHash: await submitEncryptedEnvelope(client, submission.envelopeWireHex)
1452
- };
1471
+ return submitMrvEncryptedNativeTxGated(client, backend, plan, options);
1453
1472
  }
1454
1473
  async function submitMrvCallNativeTx(client, backend, contractAddress, input, options) {
1455
1474
  const plan = buildMrvCallNativeTxPlan(contractAddress, input, options);
1456
1475
  assertMrvCallNativeSubmissionPlan(plan);
1476
+ return submitMrvEncryptedNativeTxGated(client, backend, plan, options);
1477
+ }
1478
+ async function submitMrvEncryptedNativeTxGated(client, backend, plan, options) {
1457
1479
  const submission = await buildEncryptedSubmission({
1458
- backend,
1459
1480
  tx: plan.tx,
1460
1481
  encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
1461
1482
  class: options.class
@@ -1812,6 +1833,22 @@ function concatBytes3(...parts) {
1812
1833
  function isIdentifier(value) {
1813
1834
  return /^[a-z][a-z0-9_]*$/.test(value);
1814
1835
  }
1836
+ var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
1837
+ var ML_DSA_65_SIGNATURE_LEN = 3309;
1838
+ var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
1839
+ var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
1840
+ var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
1841
+ function mlDsa65AddressFromPublicKey(publicKey) {
1842
+ return bytesToHex2(mlDsa65AddressBytes(publicKey));
1843
+ }
1844
+ function mlDsa65AddressBytes(publicKey) {
1845
+ const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
1846
+ return blake3(concatBytes2(
1847
+ ADDRESS_DERIVATION_DOMAIN_BYTES,
1848
+ bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
1849
+ bytes
1850
+ )).slice(0, 20);
1851
+ }
1815
1852
 
1816
1853
  // src/registry.ts
1817
1854
  var BLS_PUBLIC_KEY_BYTE_LENGTH = 48;
@@ -2428,6 +2465,192 @@ function encodeBlockSelector(b) {
2428
2465
  if (typeof b === "bigint") return `0x${b.toString(16)}`;
2429
2466
  return b;
2430
2467
  }
2468
+ var NameRegistryError = class extends Error {
2469
+ constructor(message) {
2470
+ super(message);
2471
+ this.name = "NameRegistryError";
2472
+ }
2473
+ };
2474
+ var NAME_REGISTRY_SELECTORS = {
2475
+ register: selectorHex2("register(string,address)"),
2476
+ proposeTransfer: selectorHex2("proposeTransfer(string,address)"),
2477
+ acceptTransfer: selectorHex2("acceptTransfer(string)")
2478
+ };
2479
+ var NAME_BASE_MULTIPLIER = {
2480
+ human: 5,
2481
+ agent: 2,
2482
+ cluster: 20,
2483
+ contract: 10
2484
+ };
2485
+ var NAME_FALLBACK_FEE_UNIT_LYTHOSHI = 1000000000000n;
2486
+ var NAME_MAX_LEN = 80;
2487
+ var NAME_LABEL_MIN_LEN = 1;
2488
+ var NAME_LABEL_MAX_LEN = 63;
2489
+ function nameRegistryAddressHex() {
2490
+ return PRECOMPILE_ADDRESSES.NAME_REGISTRY.toLowerCase();
2491
+ }
2492
+ function nameLengthModifierX10(labelLen) {
2493
+ if (labelLen === 1) return 1e3;
2494
+ if (labelLen === 2) return 500;
2495
+ if (labelLen === 3) return 100;
2496
+ if (labelLen === 4) return 50;
2497
+ if (labelLen === 5) return 30;
2498
+ if (labelLen >= 6 && labelLen <= 12) return 10;
2499
+ if (labelLen >= 13 && labelLen <= 20) return 15;
2500
+ if (labelLen >= 21 && labelLen <= 32) return 30;
2501
+ if (labelLen >= 33 && labelLen <= 50) return 100;
2502
+ if (labelLen >= 51 && labelLen <= 63) return 500;
2503
+ return null;
2504
+ }
2505
+ function parseNameCategory(name) {
2506
+ if (name.length === 0) throw new NameRegistryError("name is empty");
2507
+ if (name.length > NAME_MAX_LEN) throw new NameRegistryError(`name exceeds ${NAME_MAX_LEN} chars`);
2508
+ const parts = name.split(".");
2509
+ if (parts.some((p) => p.length === 0)) {
2510
+ throw new NameRegistryError("name has an empty label");
2511
+ }
2512
+ for (const label of parts) validateLabel(label);
2513
+ if (parts[parts.length - 1] !== "mono") {
2514
+ throw new NameRegistryError("name must end with .mono");
2515
+ }
2516
+ const primaryLabelLen = parts[0].length;
2517
+ switch (parts.length) {
2518
+ case 2:
2519
+ if (STRUCTURAL_RESERVES.has(parts[0])) {
2520
+ throw new NameRegistryError(`"${parts[0]}.mono" is a structural reserve`);
2521
+ }
2522
+ return { category: "human", primaryLabelLen };
2523
+ case 3: {
2524
+ const anchor = parts[1];
2525
+ if (anchor === "cluster") return { category: "cluster", primaryLabelLen };
2526
+ if (anchor === "contract") return { category: "contract", primaryLabelLen };
2527
+ if (anchor === "system") return { category: "system", primaryLabelLen };
2528
+ throw new NameRegistryError(`unknown name category anchor ".${anchor}.mono"`);
2529
+ }
2530
+ case 4:
2531
+ if (parts[1] !== "agent") {
2532
+ throw new NameRegistryError("unknown 4-label name form (expected <x>.agent.<human>.mono)");
2533
+ }
2534
+ return { category: "agent", primaryLabelLen };
2535
+ default:
2536
+ throw new NameRegistryError("unrecognised name structure");
2537
+ }
2538
+ }
2539
+ function nameRegistrationCost(category, primaryLabelLen, feeUnitLythoshi) {
2540
+ if (category === "system") {
2541
+ throw new NameRegistryError("system names are not registerable via this path");
2542
+ }
2543
+ const base = BigInt(NAME_BASE_MULTIPLIER[category]);
2544
+ const modX10 = nameLengthModifierX10(primaryLabelLen);
2545
+ if (modX10 === null) {
2546
+ throw new NameRegistryError("primary label length is outside the priceable 1..=63 range");
2547
+ }
2548
+ return base * BigInt(modX10) * feeUnitLythoshi / 10n;
2549
+ }
2550
+ function encodeNameRegisterCall(name, owner) {
2551
+ return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.register, name, owner);
2552
+ }
2553
+ function encodeNameProposeTransferCall(name, recipient) {
2554
+ return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.proposeTransfer, name, recipient);
2555
+ }
2556
+ function encodeNameAcceptTransferCall(name) {
2557
+ const nameBytes = new TextEncoder().encode(name);
2558
+ return bytesToHex4(
2559
+ concatBytes4(
2560
+ hexToBytes4(NAME_REGISTRY_SELECTORS.acceptTransfer),
2561
+ // Single head word → the string offset is 0x20 (one word precedes the tail).
2562
+ uint256Word(0x20n),
2563
+ uint256Word(BigInt(nameBytes.length)),
2564
+ padTo32(nameBytes)
2565
+ )
2566
+ );
2567
+ }
2568
+ var STRUCTURAL_RESERVES = /* @__PURE__ */ new Set(["agent", "cluster", "contract", "system"]);
2569
+ function encodeStringAddressCall(selector, name, address) {
2570
+ const nameBytes = new TextEncoder().encode(name);
2571
+ return bytesToHex4(
2572
+ concatBytes4(
2573
+ hexToBytes4(selector),
2574
+ // Two head words (string offset, address) → string tail starts at 0x40.
2575
+ uint256Word(0x40n),
2576
+ addressWord(address),
2577
+ uint256Word(BigInt(nameBytes.length)),
2578
+ padTo32(nameBytes)
2579
+ )
2580
+ );
2581
+ }
2582
+ function validateLabel(label) {
2583
+ if (label.length < NAME_LABEL_MIN_LEN || label.length > NAME_LABEL_MAX_LEN) {
2584
+ throw new NameRegistryError(`label "${label}" must be ${NAME_LABEL_MIN_LEN}..${NAME_LABEL_MAX_LEN} chars`);
2585
+ }
2586
+ if (label.startsWith("-") || label.endsWith("-")) {
2587
+ throw new NameRegistryError(`label "${label}" may not start or end with a hyphen`);
2588
+ }
2589
+ if (label.includes("--")) {
2590
+ throw new NameRegistryError(`label "${label}" may not contain a double hyphen`);
2591
+ }
2592
+ if (!/^[a-z0-9-]+$/.test(label)) {
2593
+ throw new NameRegistryError(`label "${label}" has an invalid char (allowed: a-z 0-9 -)`);
2594
+ }
2595
+ }
2596
+ function selectorHex2(signature) {
2597
+ const sel = keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
2598
+ return `0x${[...sel].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
2599
+ }
2600
+ function addressWord(value) {
2601
+ const out = new Uint8Array(32);
2602
+ if (value == null) return out;
2603
+ const bytes = toBytes2(value);
2604
+ if (bytes.length !== 20) {
2605
+ throw new NameRegistryError(`address must be 20 bytes, got ${bytes.length}`);
2606
+ }
2607
+ out.set(bytes, 12);
2608
+ return out;
2609
+ }
2610
+ function uint256Word(value) {
2611
+ if (value < 0n || value > (1n << 256n) - 1n) {
2612
+ throw new NameRegistryError("uint256 word out of range");
2613
+ }
2614
+ const out = new Uint8Array(32);
2615
+ let rest = value;
2616
+ for (let i = 31; i >= 0 && rest > 0n; i--) {
2617
+ out[i] = Number(rest & 0xffn);
2618
+ rest >>= 8n;
2619
+ }
2620
+ return out;
2621
+ }
2622
+ function padTo32(bytes) {
2623
+ const padded = Math.ceil(bytes.length / 32) * 32;
2624
+ if (padded === bytes.length) return bytes;
2625
+ const out = new Uint8Array(padded);
2626
+ out.set(bytes);
2627
+ return out;
2628
+ }
2629
+ function toBytes2(value) {
2630
+ if (typeof value === "string") return hexToBytes4(value);
2631
+ return value instanceof Uint8Array ? value : Uint8Array.from(value);
2632
+ }
2633
+ function hexToBytes4(hex) {
2634
+ const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
2635
+ if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
2636
+ throw new NameRegistryError("invalid hex bytes");
2637
+ }
2638
+ const out = new Uint8Array(body.length / 2);
2639
+ for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(body.slice(i * 2, i * 2 + 2), 16);
2640
+ return out;
2641
+ }
2642
+ function bytesToHex4(bytes) {
2643
+ return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
2644
+ }
2645
+ function concatBytes4(...parts) {
2646
+ const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
2647
+ let offset = 0;
2648
+ for (const part of parts) {
2649
+ out.set(part, offset);
2650
+ offset += part.length;
2651
+ }
2652
+ return out;
2653
+ }
2431
2654
 
2432
2655
  // src/client.ts
2433
2656
  var MAX_NATIVE_RECEIPT_EVENTS = 1e3;
@@ -2603,13 +2826,31 @@ var RpcClient = class _RpcClient {
2603
2826
  async ethGasPrice() {
2604
2827
  return parseQuantityBig(await this.call("eth_gasPrice", []));
2605
2828
  }
2606
- /** `eth_feeHistory` — base-fee + gas-used history. */
2829
+ /**
2830
+ * `eth_feeHistory` — base-fee + gas-used history.
2831
+ *
2832
+ * The chain's eth-compat surface serializes the base-fee window under the
2833
+ * camelCase key `baseFeePerGas`. Internally the chain header field is
2834
+ * `base_fee_per_gas`; this method asserts the on-the-wire response actually
2835
+ * carries the expected `baseFeePerGas` array and fails LOUD if the field is
2836
+ * missing or has drifted to snake_case `base_fee_per_gas`. Without this
2837
+ * guard a future rename would silently collapse the base fee to an empty
2838
+ * array and over-/under-quote fees (e.g. name registration would fall back
2839
+ * to the placeholder fee unit and revert `IncorrectFee` on submit).
2840
+ */
2607
2841
  async ethFeeHistory(blockCount, newestBlock = "latest", rewardPercentiles = []) {
2608
- return this.call("eth_feeHistory", [
2842
+ const result = await this.call("eth_feeHistory", [
2609
2843
  `0x${blockCount.toString(16)}`,
2610
2844
  encodeBlockSelector(newestBlock),
2611
2845
  rewardPercentiles
2612
2846
  ]);
2847
+ if (result !== null && typeof result === "object" && !Array.isArray(result.baseFeePerGas)) {
2848
+ const drifted = "base_fee_per_gas" in result ? " (found snake_case 'base_fee_per_gas')" : "";
2849
+ throw SdkError.malformed(
2850
+ `eth_feeHistory response is missing the camelCase 'baseFeePerGas' array${drifted}; the base-fee field contract changed`
2851
+ );
2852
+ }
2853
+ return result;
2613
2854
  }
2614
2855
  /** `eth_syncing` — `null` when caught up. */
2615
2856
  async ethSyncing() {
@@ -3265,7 +3506,234 @@ var RpcClient = class _RpcClient {
3265
3506
  async meshSubmitTx(signedTx) {
3266
3507
  return this.call("mesh_submitTx", [signedTx]);
3267
3508
  }
3509
+ // ---- lyth_* additions (R15 / wallet + monoscan surfaces) -----------
3510
+ /**
3511
+ * `lyth_clusterApr` — observed APR for a cluster over a rolling window.
3512
+ * `windowBlocks` defaults to the chain's 1200-block (~1h) window and is
3513
+ * server-clamped to `[10, 86_400]`.
3514
+ */
3515
+ async lythClusterApr(clusterId, windowBlocks) {
3516
+ const params = windowBlocks === void 0 ? [clusterId] : [clusterId, windowBlocks];
3517
+ return normalizeClusterApr(await this.call("lyth_clusterApr", params));
3518
+ }
3519
+ /** `lyth_resolveName` — forward name → address resolution (0x110E). */
3520
+ async lythResolveName(name, block = "latest") {
3521
+ return this.call("lyth_resolveName", [name, encodeBlockSelector(block)]);
3522
+ }
3523
+ /** `lyth_nameOf` — reverse address → name resolution. */
3524
+ async lythNameOf(address, block = "latest") {
3525
+ return this.call("lyth_nameOf", [sdkTypedAddress(address, "user", "address"), encodeBlockSelector(block)]);
3526
+ }
3527
+ /** `lyth_getClusterName` — reverse cluster id → canonical name. */
3528
+ async lythGetClusterName(clusterId, block = "latest") {
3529
+ return this.call("lyth_getClusterName", [clusterId, encodeBlockSelector(block)]);
3530
+ }
3531
+ /**
3532
+ * Convenience over {@link lythResolveName}: `true` when a well-formed
3533
+ * name is unregistered. A malformed name throws `RpcError`
3534
+ * (`InvalidParams`) rather than returning `true`, so the UI should treat
3535
+ * a thrown validation error distinctly from "taken".
3536
+ */
3537
+ async lythIsNameAvailable(name, block = "latest") {
3538
+ const resolved = await this.lythResolveName(name, block);
3539
+ return resolved.address === null;
3540
+ }
3541
+ /**
3542
+ * Live name-registration quote: parses the name's category + primary
3543
+ * label length, reads the chain's base fee unit via `eth_feeHistory`
3544
+ * (the bare `baseFeePerGas` — NOT `eth_gasPrice`, which adds the tip and
3545
+ * would over-quote), and applies the U-curve. The resulting
3546
+ * `costLythoshi` is what the `register` tx `value` must equal exactly
3547
+ * (else the precompile reverts `IncorrectFee`).
3548
+ */
3549
+ async quoteNameRegistration(name, block = "latest") {
3550
+ const parsed = parseNameCategory(name);
3551
+ const history = await this.ethFeeHistory(1, block, []);
3552
+ const baseFees = history.baseFeePerGas ?? [];
3553
+ const lastHex = baseFees.length > 0 ? baseFees[baseFees.length - 1] : "0x0";
3554
+ const baseFee = parseQuantityBig(lastHex);
3555
+ const feeUnitLythoshi = baseFee > 0n ? baseFee : NAME_FALLBACK_FEE_UNIT_LYTHOSHI;
3556
+ return {
3557
+ name,
3558
+ category: parsed.category,
3559
+ primaryLabelLen: parsed.primaryLabelLen,
3560
+ feeUnitLythoshi,
3561
+ costLythoshi: nameRegistrationCost(parsed.category, parsed.primaryLabelLen, feeUnitLythoshi)
3562
+ };
3563
+ }
3564
+ /** `lyth_circulatingSupply` — native LYTH circulating / initial / burned (decimal lythoshi strings). */
3565
+ async lythCirculatingSupply() {
3566
+ return this.call("lyth_circulatingSupply", []);
3567
+ }
3568
+ /** `lyth_totalBurned` — cumulative burned native LYTH (decimal lythoshi string). */
3569
+ async lythTotalBurned() {
3570
+ return this.call("lyth_totalBurned", []);
3571
+ }
3572
+ /** `lyth_swapIntentStatus` — bridge swap-intent / DKG-reshare lifecycle for one intent id. */
3573
+ async lythSwapIntentStatus(intentId) {
3574
+ let id;
3575
+ if (typeof intentId === "number") {
3576
+ id = intentId;
3577
+ } else if (typeof intentId === "bigint") {
3578
+ id = `0x${intentId.toString(16)}`;
3579
+ } else if (intentId.startsWith("0x") || intentId.startsWith("0X")) {
3580
+ id = intentId;
3581
+ } else {
3582
+ id = `0x${BigInt(intentId).toString(16)}`;
3583
+ }
3584
+ return this.call("lyth_swapIntentStatus", [id]);
3585
+ }
3586
+ /**
3587
+ * Per-tx confirmation depth, derived from `lyth_txStatus` (which returns
3588
+ * both the tx's `blockNumber` and the node `latestHeight`).
3589
+ */
3590
+ async lythTxConfirmations(txHash) {
3591
+ const status = await this.lythTxStatus(txHash);
3592
+ if (status.status === "found") {
3593
+ return {
3594
+ status: "found",
3595
+ confirmations: status.latestHeight - status.blockNumber + 1,
3596
+ blockNumber: status.blockNumber,
3597
+ latestHeight: status.latestHeight
3598
+ };
3599
+ }
3600
+ return {
3601
+ status: "not_found",
3602
+ confirmations: null,
3603
+ blockNumber: null,
3604
+ latestHeight: status.latestHeight
3605
+ };
3606
+ }
3607
+ /**
3608
+ * Resolve a user-pasted MRC token id to its metadata (name/symbol/
3609
+ * decimals), for an "add custom token" flow. Returns `null` for an
3610
+ * unknown/untracked id. Performs light client-side format validation
3611
+ * (32-byte hex) for fast UX feedback; the chain re-validates regardless.
3612
+ */
3613
+ async lythResolveTokenMetadata(rawTokenId) {
3614
+ const body = rawTokenId.startsWith("0x") || rawTokenId.startsWith("0X") ? rawTokenId.slice(2) : rawTokenId;
3615
+ if (!/^[0-9a-fA-F]{64}$/.test(body)) {
3616
+ throw SdkError.malformed("token id must be 32 bytes (64 hex chars)");
3617
+ }
3618
+ return (await this.lythMrcMetadata(rawTokenId)).metadata;
3619
+ }
3620
+ /**
3621
+ * `lyth_getTokenBalances` joined with per-token MRC metadata. Balances
3622
+ * are PUBLIC-only by construction (private-denomination balances are
3623
+ * excluded by the chain). Raw `balance` strings are preserved (apply
3624
+ * `metadata.decimals` client-side for display).
3625
+ */
3626
+ async lythGetTokenBalancesWithMetadata(address) {
3627
+ const rows = await this.lythGetTokenBalances(address);
3628
+ const keyFor = (row) => {
3629
+ const assetId = row.mrc?.assetId ?? row.tokenId;
3630
+ const tokenId = row.mrc?.tokenId ?? null;
3631
+ return { assetId, tokenId, key: `${assetId}:${tokenId ?? ""}` };
3632
+ };
3633
+ const distinct = /* @__PURE__ */ new Map();
3634
+ for (const row of rows) {
3635
+ const k = keyFor(row);
3636
+ if (!distinct.has(k.key)) distinct.set(k.key, { assetId: k.assetId, tokenId: k.tokenId });
3637
+ }
3638
+ const metaByKey = /* @__PURE__ */ new Map();
3639
+ await Promise.all(
3640
+ [...distinct.entries()].map(async ([key, { assetId, tokenId }]) => {
3641
+ const resp = await this.lythMrcMetadata(assetId, tokenId);
3642
+ metaByKey.set(key, resp.metadata);
3643
+ })
3644
+ );
3645
+ return rows.map((row) => ({ ...row, metadata: metaByKey.get(keyFor(row).key) ?? null }));
3646
+ }
3647
+ /**
3648
+ * Resolve a CLOB market's base/quote asset metadata (symbol/name/
3649
+ * decimals) by joining `lyth_clobMarket` to `lyth_mrcMetadata`. Either
3650
+ * side may be `null` when the indexer has no MRC row (e.g. native LYTH).
3651
+ */
3652
+ async resolveClobMarketAssets(marketId) {
3653
+ const response = await this.lythClobMarket(marketId);
3654
+ const market = response.market;
3655
+ if (!market) return { base: null, quote: null };
3656
+ const [base, quote] = await Promise.all([
3657
+ this.lythMrcMetadata(market.baseToken).then((m) => m.metadata),
3658
+ this.lythMrcMetadata(market.quoteToken).then((m) => m.metadata)
3659
+ ]);
3660
+ return { base, quote };
3661
+ }
3662
+ /**
3663
+ * `lyth_getAddressActivity` enriched with each row's block timestamp,
3664
+ * canonical tx hash (resolved from `(blockHeight, txIndex)`), and
3665
+ * resolved cluster name. Issues one block read per distinct height and
3666
+ * one name read per distinct cluster.
3667
+ */
3668
+ async enrichAddressActivity(address, limit = 50, cursor) {
3669
+ const entries = await this.lythGetAddressActivity(address, limit, cursor);
3670
+ const heights = [...new Set(entries.map((entry) => BigInt(entry.blockHeight)))];
3671
+ const blockByHeight = /* @__PURE__ */ new Map();
3672
+ await Promise.all(
3673
+ heights.map(async (height) => {
3674
+ blockByHeight.set(height, await this.blockTimeAndTxHashes(height));
3675
+ })
3676
+ );
3677
+ const clusters = [
3678
+ ...new Set(entries.map((entry) => entry.cluster).filter((c) => c != null))
3679
+ ];
3680
+ const nameByCluster = /* @__PURE__ */ new Map();
3681
+ await Promise.all(
3682
+ clusters.map(async (clusterId) => {
3683
+ nameByCluster.set(clusterId, (await this.lythGetClusterName(clusterId)).name);
3684
+ })
3685
+ );
3686
+ return entries.map((entry) => {
3687
+ const block = blockByHeight.get(BigInt(entry.blockHeight));
3688
+ const txHash = block && entry.txIndex >= 0 && entry.txIndex < block.txHashes.length ? block.txHashes[entry.txIndex] : null;
3689
+ return {
3690
+ ...entry,
3691
+ blockTimestampSeconds: block?.timestampSeconds ?? null,
3692
+ txHash,
3693
+ clusterName: entry.cluster != null ? nameByCluster.get(entry.cluster) ?? null : null
3694
+ };
3695
+ });
3696
+ }
3697
+ /**
3698
+ * Read a block's header timestamp (UNIX seconds) and ordered tx-hash
3699
+ * array via the raw `eth_getBlockByNumber` (hash-only mode). The typed
3700
+ * `ethGetBlockByNumber` wrapper drops the `transactions` array, so this
3701
+ * uses the raw call.
3702
+ */
3703
+ async blockTimeAndTxHashes(height) {
3704
+ const hexHeight = `0x${height.toString(16)}`;
3705
+ const raw = await this.call("eth_getBlockByNumber", [
3706
+ hexHeight,
3707
+ false
3708
+ ]);
3709
+ if (!raw || typeof raw !== "object") return { timestampSeconds: null, txHashes: [] };
3710
+ const ts = raw["timestamp"];
3711
+ const timestampSeconds = ts === null || ts === void 0 ? null : parseRpcBigint(ts, "block timestamp");
3712
+ const txs = raw["transactions"];
3713
+ const txHashes = Array.isArray(txs) ? txs.filter((t) => typeof t === "string") : [];
3714
+ return { timestampSeconds, txHashes };
3715
+ }
3268
3716
  };
3717
+ function clusterApyPercent(apr) {
3718
+ return Number(apr.aprBps) / 100;
3719
+ }
3720
+ function computeQuoteLiquidity(book) {
3721
+ const sumQuote = (levels) => levels.reduce((acc, level) => acc + BigInt(level.price) * BigInt(level.size), 0n);
3722
+ const bidQuote = sumQuote(book.bids);
3723
+ const askQuote = sumQuote(book.asks);
3724
+ return {
3725
+ bidQuote: bidQuote.toString(10),
3726
+ askQuote: askQuote.toString(10),
3727
+ totalQuote: (bidQuote + askQuote).toString(10)
3728
+ };
3729
+ }
3730
+ function rankMarketsByVolume(markets) {
3731
+ return [...markets].sort((a, b) => {
3732
+ const av = BigInt(a.totalVolumeBase);
3733
+ const bv = BigInt(b.totalVolumeBase);
3734
+ return av < bv ? 1 : av > bv ? -1 : 0;
3735
+ }).map((market, index) => ({ ...market, volumeRank: index + 1 }));
3736
+ }
3269
3737
  function parseQuantityBig(hex) {
3270
3738
  if (!hex) return 0n;
3271
3739
  const rest = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
@@ -3920,6 +4388,29 @@ function normalizeRoundInfo(value) {
3920
4388
  height: parseRpcBigint(row["height"], "round height")
3921
4389
  };
3922
4390
  }
4391
+ function normalizeClusterApr(value) {
4392
+ if (!value || typeof value !== "object") {
4393
+ throw SdkError.malformed("cluster apr must be an object");
4394
+ }
4395
+ const row = value;
4396
+ const blocks = row["blocks"] ?? {};
4397
+ return {
4398
+ clusterId: parseRpcNumber(row["clusterId"], "clusterId"),
4399
+ blocks: {
4400
+ from: parseRpcBigint(blocks["from"], "blocks.from"),
4401
+ to: parseRpcBigint(blocks["to"], "blocks.to"),
4402
+ window: parseRpcBigint(blocks["window"], "blocks.window")
4403
+ },
4404
+ rewardIndexFromHex: parseStringField(row["rewardIndexFromHex"], "rewardIndexFromHex"),
4405
+ rewardIndexToHex: parseStringField(row["rewardIndexToHex"], "rewardIndexToHex"),
4406
+ deltaIndexHex: parseStringField(row["deltaIndexHex"], "deltaIndexHex"),
4407
+ rewardIndexScale: parseStringField(row["rewardIndexScale"], "rewardIndexScale"),
4408
+ totalBps: parseRpcNumber(row["totalBps"], "totalBps"),
4409
+ blocksPerYear: parseRpcBigint(row["blocksPerYear"], "blocksPerYear"),
4410
+ stakePerBpsLythoshi: parseRpcBigint(row["stakePerBpsLythoshi"], "stakePerBpsLythoshi"),
4411
+ aprBps: parseRpcBigint(row["aprBps"], "aprBps")
4412
+ };
4413
+ }
3923
4414
  function normalizeExecutionUnitPriceResponse(value) {
3924
4415
  if (!value || typeof value !== "object") {
3925
4416
  throw SdkError.malformed("execution unit price response must be an object");
@@ -4565,8 +5056,6 @@ function encodePathBlock(block) {
4565
5056
  function encodePathSegment(value) {
4566
5057
  return encodeURIComponent(typeof value === "bigint" ? value.toString() : String(value));
4567
5058
  }
4568
-
4569
- // src/bridge.ts
4570
5059
  var BRIDGE_SELECTORS = {
4571
5060
  lockBridgeConfig: "0x8956feb3",
4572
5061
  setBridgeResumeCooldown: "0x1a3a0672",
@@ -4600,42 +5089,105 @@ function bridgeAddressHex() {
4600
5089
  return PRECOMPILE_ADDRESSES.BRIDGE.toLowerCase();
4601
5090
  }
4602
5091
  function encodeLockBridgeConfigCalldata(bridgeId) {
4603
- return bytesToHex4(
4604
- concatBytes4(
4605
- hexToBytes4(BRIDGE_SELECTORS.lockBridgeConfig),
4606
- expectLength3(toBytes2(bridgeId), 32, "bridgeId")
5092
+ return bytesToHex5(
5093
+ concatBytes5(
5094
+ hexToBytes5(BRIDGE_SELECTORS.lockBridgeConfig),
5095
+ expectLength3(toBytes3(bridgeId), 32, "bridgeId")
4607
5096
  )
4608
5097
  );
4609
5098
  }
4610
5099
  function encodeSetBridgeResumeCooldownCalldata(bridgeId, cooldownBlocks) {
4611
- return bytesToHex4(
4612
- concatBytes4(
4613
- hexToBytes4(BRIDGE_SELECTORS.setBridgeResumeCooldown),
4614
- expectLength3(toBytes2(bridgeId), 32, "bridgeId"),
4615
- uint64Word(cooldownBlocks, "cooldownBlocks")
5100
+ return bytesToHex5(
5101
+ concatBytes5(
5102
+ hexToBytes5(BRIDGE_SELECTORS.setBridgeResumeCooldown),
5103
+ expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
5104
+ uint64Word2(cooldownBlocks, "cooldownBlocks")
4616
5105
  )
4617
5106
  );
4618
5107
  }
4619
5108
  function encodeSetBridgeRouteFinalityCalldata(bridgeId, finalityBlocks) {
4620
- return bytesToHex4(
4621
- concatBytes4(
4622
- hexToBytes4(BRIDGE_SELECTORS.setBridgeRouteFinality),
4623
- expectLength3(toBytes2(bridgeId), 32, "bridgeId"),
4624
- uint64Word(finalityBlocks, "finalityBlocks")
5109
+ return bytesToHex5(
5110
+ concatBytes5(
5111
+ hexToBytes5(BRIDGE_SELECTORS.setBridgeRouteFinality),
5112
+ expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
5113
+ uint64Word2(finalityBlocks, "finalityBlocks")
5114
+ )
5115
+ );
5116
+ }
5117
+ function bridgeSelector(signature) {
5118
+ return keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
5119
+ }
5120
+ function addressWord2(value, name) {
5121
+ const addr = expectLength3(toBytes3(value), 20, name);
5122
+ const out = new Uint8Array(32);
5123
+ out.set(addr, 12);
5124
+ return out;
5125
+ }
5126
+ function padTo322(bytes) {
5127
+ const padded = Math.ceil(bytes.length / 32) * 32;
5128
+ if (padded === bytes.length) return bytes;
5129
+ const out = new Uint8Array(padded);
5130
+ out.set(bytes);
5131
+ return out;
5132
+ }
5133
+ function encodeBridgeClaimCalldata(bridgeId, depositId, recipient) {
5134
+ return bytesToHex5(
5135
+ concatBytes5(
5136
+ bridgeSelector("claim(bytes32,bytes32,address)"),
5137
+ expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
5138
+ expectLength3(toBytes3(depositId), 32, "depositId"),
5139
+ addressWord2(recipient, "recipient")
5140
+ )
5141
+ );
5142
+ }
5143
+ function encodeBridgeChallengeCalldata(bridgeId, depositId, fraudProof) {
5144
+ const proof = toBytes3(fraudProof);
5145
+ return bytesToHex5(
5146
+ concatBytes5(
5147
+ bridgeSelector("challenge(bytes32,bytes32,bytes)"),
5148
+ expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
5149
+ expectLength3(toBytes3(depositId), 32, "depositId"),
5150
+ uint64Word2(3n * 32n, "fraudProofOffset"),
5151
+ uint64Word2(BigInt(proof.length), "fraudProofLength"),
5152
+ padTo322(proof)
5153
+ )
5154
+ );
5155
+ }
5156
+ function encodeSubmitBridgeProofCalldata(bridgeId, depositId, lockReceipt, zkProof, publicInputs) {
5157
+ const receipt = toBytes3(lockReceipt);
5158
+ const proof = toBytes3(zkProof);
5159
+ const inputs = toBytes3(publicInputs);
5160
+ const off0 = 5n * 32n;
5161
+ const off1 = off0 + 32n + BigInt(Math.ceil(receipt.length / 32) * 32);
5162
+ const off2 = off1 + 32n + BigInt(Math.ceil(proof.length / 32) * 32);
5163
+ return bytesToHex5(
5164
+ concatBytes5(
5165
+ bridgeSelector("submitProof(bytes32,bytes32,bytes,bytes,bytes)"),
5166
+ expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
5167
+ expectLength3(toBytes3(depositId), 32, "depositId"),
5168
+ uint64Word2(off0, "lockReceiptOffset"),
5169
+ uint64Word2(off1, "zkProofOffset"),
5170
+ uint64Word2(off2, "publicInputsOffset"),
5171
+ uint64Word2(BigInt(receipt.length), "lockReceiptLength"),
5172
+ padTo322(receipt),
5173
+ uint64Word2(BigInt(proof.length), "zkProofLength"),
5174
+ padTo322(proof),
5175
+ uint64Word2(BigInt(inputs.length), "publicInputsLength"),
5176
+ padTo322(inputs)
4625
5177
  )
4626
5178
  );
4627
5179
  }
4628
5180
  function isBridgeAdminLockedRevert(data) {
4629
- return bytesToHex4(toBytes2(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeAdminLocked;
5181
+ return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeAdminLocked;
4630
5182
  }
4631
5183
  function isBridgeResumeCooldownActiveRevert(data) {
4632
- return bytesToHex4(toBytes2(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeResumeCooldownActive;
5184
+ return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeResumeCooldownActive;
4633
5185
  }
4634
5186
  function isBridgeCooldownZeroRevert(data) {
4635
- return bytesToHex4(toBytes2(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeCooldownZero;
5187
+ return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeCooldownZero;
4636
5188
  }
4637
5189
  function isBridgeFinalityZeroRevert(data) {
4638
- return bytesToHex4(toBytes2(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
5190
+ return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
4639
5191
  }
4640
5192
  function bridgeDrainRemaining(capPerWindow, drained) {
4641
5193
  const cap = BigInt(capPerWindow);
@@ -5238,7 +5790,7 @@ function expectLength3(value, len, name) {
5238
5790
  }
5239
5791
  return value;
5240
5792
  }
5241
- function uint64Word(value, name) {
5793
+ function uint64Word2(value, name) {
5242
5794
  const n = toBigint(value, name);
5243
5795
  if (n < 0n || n > 0xffffffffffffffffn) {
5244
5796
  throw new BridgePrecompileError(`${name} must fit uint64`);
@@ -5264,13 +5816,13 @@ function toBigint(value, name) {
5264
5816
  }
5265
5817
  return BigInt(value);
5266
5818
  }
5267
- function toBytes2(value) {
5819
+ function toBytes3(value) {
5268
5820
  if (typeof value === "string") {
5269
- return hexToBytes4(value);
5821
+ return hexToBytes5(value);
5270
5822
  }
5271
5823
  return value instanceof Uint8Array ? value : Uint8Array.from(value);
5272
5824
  }
5273
- function hexToBytes4(hex) {
5825
+ function hexToBytes5(hex) {
5274
5826
  const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
5275
5827
  if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
5276
5828
  throw new BridgePrecompileError("invalid hex bytes");
@@ -5281,10 +5833,10 @@ function hexToBytes4(hex) {
5281
5833
  }
5282
5834
  return out;
5283
5835
  }
5284
- function bytesToHex4(bytes) {
5836
+ function bytesToHex5(bytes) {
5285
5837
  return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
5286
5838
  }
5287
- function concatBytes4(...parts) {
5839
+ function concatBytes5(...parts) {
5288
5840
  const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
5289
5841
  let offset = 0;
5290
5842
  for (const part of parts) {
@@ -5339,10 +5891,10 @@ function decodeNoEvmReceiptTranscript(proof) {
5339
5891
  );
5340
5892
  }
5341
5893
  function computeNoEvmReceiptsRoot(receipts) {
5342
- return bytesToHex5(computeNoEvmReceiptsRootBytes(receipts));
5894
+ return bytesToHex6(computeNoEvmReceiptsRootBytes(receipts));
5343
5895
  }
5344
5896
  function computeNoEvmTargetReceiptHash(receiptBytes) {
5345
- return bytesToHex5(keccak_256(receiptBytes));
5897
+ return bytesToHex6(keccak_256(receiptBytes));
5346
5898
  }
5347
5899
  function verifyNoEvmReceiptProof(proof) {
5348
5900
  if (proof == null) return null;
@@ -5929,7 +6481,7 @@ function verifyCompactReceiptProof(proof) {
5929
6481
  if (!bytesEqual(expectedLeafHashBytes, actualLeafHashBytes)) {
5930
6482
  throw new NoEvmReceiptProofError(
5931
6483
  "compact_leaf_hash_mismatch",
5932
- `compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex5(
6484
+ `compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
5933
6485
  actualLeafHashBytes
5934
6486
  )}`
5935
6487
  );
@@ -5962,14 +6514,14 @@ function verifyCompactReceiptProof(proof) {
5962
6514
  if (!bytesEqual(actualRootBytes, compactRootBytes)) {
5963
6515
  throw new NoEvmReceiptProofError(
5964
6516
  "compact_path_mismatch",
5965
- `compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex5(
6517
+ `compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
5966
6518
  actualRootBytes
5967
6519
  )}`
5968
6520
  );
5969
6521
  }
5970
6522
  return {
5971
6523
  receipts: [],
5972
- receiptsRoot: bytesToHex5(actualRootBytes),
6524
+ receiptsRoot: bytesToHex6(actualRootBytes),
5973
6525
  targetReceiptHash: actualTargetHash,
5974
6526
  receiptCount: proof.receiptCount,
5975
6527
  txIndex: proof.txIndex,
@@ -6179,7 +6731,7 @@ function parseArchiveProofSignature(signature, index, fieldPrefix = "archiveProo
6179
6731
  `${field2}.payload must be non-empty`
6180
6732
  );
6181
6733
  }
6182
- return { signerId: bytesToHex5(signerId), payload };
6734
+ return { signerId: bytesToHex6(signerId), payload };
6183
6735
  }
6184
6736
  function normalizeSignerId(value) {
6185
6737
  const bytes = decodeHexBytes(value, "signerId");
@@ -6189,7 +6741,7 @@ function normalizeSignerId(value) {
6189
6741
  `signerId must be ${ARCHIVE_SIGNATURE_SIGNER_ID_BYTE_LENGTH} bytes, got ${bytes.length}`
6190
6742
  );
6191
6743
  }
6192
- return bytesToHex5(bytes);
6744
+ return bytesToHex6(bytes);
6193
6745
  }
6194
6746
  function expectArchivePublicKey(value, field2) {
6195
6747
  if (value.length !== ML_DSA_65_PUBLIC_KEY_LEN) {
@@ -6670,7 +7222,7 @@ function bytesEqual(a, b) {
6670
7222
  }
6671
7223
  return diff === 0;
6672
7224
  }
6673
- function bytesToHex5(bytes) {
7225
+ function bytesToHex6(bytes) {
6674
7226
  let out = "0x";
6675
7227
  for (let index = 0; index < bytes.length; index++) {
6676
7228
  out += bytes[index].toString(16).padStart(2, "0");
@@ -6889,12 +7441,48 @@ var OracleEventError = class extends Error {
6889
7441
  function oracleAddressHex() {
6890
7442
  return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
6891
7443
  }
7444
+ var FEED_ID_DOMAIN_TAG = "protocore-oracle/feed-id/v1";
7445
+ function deriveFeedId(name, decimals) {
7446
+ if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
7447
+ throw new OracleEventError("feed decimals must be an integer in 0..=255");
7448
+ }
7449
+ const nameBytes = new TextEncoder().encode(name);
7450
+ const buf = concatBytes6(
7451
+ new TextEncoder().encode(FEED_ID_DOMAIN_TAG),
7452
+ nameBytes,
7453
+ Uint8Array.of(decimals & 255)
7454
+ );
7455
+ return bytesToHex7(keccak_256(buf));
7456
+ }
7457
+ function formatOraclePrice(price) {
7458
+ if (price.median === null) return null;
7459
+ const value = BigInt(price.median);
7460
+ const decimals = price.decimals;
7461
+ if (decimals <= 0) return value.toString(10);
7462
+ const base = 10n ** BigInt(decimals);
7463
+ const whole = value / base;
7464
+ const frac = (value % base).toString(10).padStart(decimals, "0").replace(/0+$/, "");
7465
+ return frac.length > 0 ? `${whole.toString(10)}.${frac}` : whole.toString(10);
7466
+ }
7467
+ function oraclePriceToNumber(price) {
7468
+ const formatted = formatOraclePrice(price);
7469
+ return formatted === null ? null : Number(formatted);
7470
+ }
7471
+ function concatBytes6(...parts) {
7472
+ const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
7473
+ let offset = 0;
7474
+ for (const part of parts) {
7475
+ out.set(part, offset);
7476
+ offset += part.length;
7477
+ }
7478
+ return out;
7479
+ }
6892
7480
  function decodeOracleEvent(topics, data) {
6893
7481
  if (topics.length === 0) {
6894
7482
  throw new OracleEventError("event record has no topics");
6895
7483
  }
6896
- const topic0 = bytesToHex6(expectLength4(toBytes3(topics[0]), 32, "topic0"));
6897
- const body = toBytes3(data);
7484
+ const topic0 = bytesToHex7(expectLength4(toBytes4(topics[0]), 32, "topic0"));
7485
+ const body = toBytes4(data);
6898
7486
  if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
6899
7487
  checkArity("OracleRoundFinalized", 3, topics.length);
6900
7488
  checkData("OracleRoundFinalized", 3 * 32, body.length);
@@ -6927,7 +7515,7 @@ function decodeOracleEvent(topics, data) {
6927
7515
  feedId: hex32(topics[1]),
6928
7516
  roundId: u64FromTopic(topics[2]),
6929
7517
  writer: addressFromTopic(topics[3]),
6930
- evidenceHash: bytesToHex6(body.subarray(0, 32))
7518
+ evidenceHash: bytesToHex7(body.subarray(0, 32))
6931
7519
  };
6932
7520
  }
6933
7521
  if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
@@ -6975,7 +7563,7 @@ function decodeFeedFields(feedTopic, body) {
6975
7563
  };
6976
7564
  }
6977
7565
  function topicHex(sig) {
6978
- return bytesToHex6(keccak_256(new TextEncoder().encode(sig)));
7566
+ return bytesToHex7(keccak_256(new TextEncoder().encode(sig)));
6979
7567
  }
6980
7568
  function checkArity(event, expected, found) {
6981
7569
  if (found !== expected) {
@@ -6988,13 +7576,13 @@ function checkData(event, expected, found) {
6988
7576
  }
6989
7577
  }
6990
7578
  function hex32(topic) {
6991
- return bytesToHex6(expectLength4(toBytes3(topic), 32, "feedId topic"));
7579
+ return bytesToHex7(expectLength4(toBytes4(topic), 32, "feedId topic"));
6992
7580
  }
6993
7581
  function addressFromTopic(topic) {
6994
- return bytesToHex6(expectLength4(toBytes3(topic), 32, "address topic").subarray(12, 32));
7582
+ return bytesToHex7(expectLength4(toBytes4(topic), 32, "address topic").subarray(12, 32));
6995
7583
  }
6996
7584
  function u64FromTopic(topic) {
6997
- return u64FromWord2(expectLength4(toBytes3(topic), 32, "u64 topic"));
7585
+ return u64FromWord2(expectLength4(toBytes4(topic), 32, "u64 topic"));
6998
7586
  }
6999
7587
  function u64FromWord2(word) {
7000
7588
  let v = 0n;
@@ -7009,11 +7597,11 @@ function u256Decimal(word) {
7009
7597
  for (const b of word) v = v << 8n | BigInt(b);
7010
7598
  return v.toString(10);
7011
7599
  }
7012
- function toBytes3(value) {
7013
- if (typeof value === "string") return hexToBytes5(value);
7600
+ function toBytes4(value) {
7601
+ if (typeof value === "string") return hexToBytes6(value);
7014
7602
  return value instanceof Uint8Array ? value : Uint8Array.from(value);
7015
7603
  }
7016
- function hexToBytes5(hex) {
7604
+ function hexToBytes6(hex) {
7017
7605
  const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
7018
7606
  if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
7019
7607
  throw new OracleEventError("invalid hex bytes");
@@ -7022,7 +7610,7 @@ function hexToBytes5(hex) {
7022
7610
  for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
7023
7611
  return out;
7024
7612
  }
7025
- function bytesToHex6(bytes) {
7613
+ function bytesToHex7(bytes) {
7026
7614
  return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
7027
7615
  }
7028
7616
  function expectLength4(value, len, name) {
@@ -7034,12 +7622,12 @@ function expectLength4(value, len, name) {
7034
7622
  var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
7035
7623
  var SERVES_GPU_PROVE = 512;
7036
7624
  var PROVER_MARKET_SELECTORS = {
7037
- createRequest: "0x" + selectorHex2("createRequest(bytes)"),
7038
- submitBid: "0x" + selectorHex2("submitBid(bytes)"),
7039
- closeRequest: "0x" + selectorHex2("closeRequest(bytes)"),
7040
- submitProof: "0x" + selectorHex2("submitProof(bytes)"),
7041
- settle: "0x" + selectorHex2("settle(bytes)"),
7042
- slash: "0x" + selectorHex2("slash(bytes)")
7625
+ createRequest: "0x" + selectorHex3("createRequest(bytes)"),
7626
+ submitBid: "0x" + selectorHex3("submitBid(bytes)"),
7627
+ closeRequest: "0x" + selectorHex3("closeRequest(bytes)"),
7628
+ submitProof: "0x" + selectorHex3("submitProof(bytes)"),
7629
+ settle: "0x" + selectorHex3("settle(bytes)"),
7630
+ slash: "0x" + selectorHex3("slash(bytes)")
7043
7631
  };
7044
7632
  var PROVER_MARKET_EVENT_SIGS = {
7045
7633
  proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
@@ -7077,12 +7665,12 @@ var ProverMarketError = class extends Error {
7077
7665
  }
7078
7666
  };
7079
7667
  function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
7080
- return bytesToHex7(
7668
+ return bytesToHex8(
7081
7669
  keccak_256(
7082
- concatBytes5(
7670
+ concatBytes7(
7083
7671
  new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
7084
- expectLength5(toBytes4(vkeyHash), 32, "vkeyHash"),
7085
- expectLength5(toBytes4(inputsHash), 32, "inputsHash"),
7672
+ expectLength5(toBytes5(vkeyHash), 32, "vkeyHash"),
7673
+ expectLength5(toBytes5(inputsHash), 32, "inputsHash"),
7086
7674
  u128Bytes(maxFee, "maxFee"),
7087
7675
  u64Bytes(deadline, "deadline"),
7088
7676
  u64Bytes(nonce, "nonce")
@@ -7091,44 +7679,44 @@ function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
7091
7679
  );
7092
7680
  }
7093
7681
  function bidSighash(requestId, fee) {
7094
- return bytesToHex7(
7682
+ return bytesToHex8(
7095
7683
  keccak_256(
7096
- concatBytes5(
7684
+ concatBytes7(
7097
7685
  new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
7098
- expectLength5(toBytes4(requestId), 32, "requestId"),
7686
+ expectLength5(toBytes5(requestId), 32, "requestId"),
7099
7687
  u128Bytes(fee, "fee")
7100
7688
  )
7101
7689
  )
7102
7690
  );
7103
7691
  }
7104
7692
  function submitSighash(requestId, proofHash) {
7105
- return bytesToHex7(
7693
+ return bytesToHex8(
7106
7694
  keccak_256(
7107
- concatBytes5(
7695
+ concatBytes7(
7108
7696
  new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
7109
- expectLength5(toBytes4(requestId), 32, "requestId"),
7110
- expectLength5(toBytes4(proofHash), 32, "proofHash")
7697
+ expectLength5(toBytes5(requestId), 32, "requestId"),
7698
+ expectLength5(toBytes5(proofHash), 32, "proofHash")
7111
7699
  )
7112
7700
  )
7113
7701
  );
7114
7702
  }
7115
7703
  function encodeCreateRequestCanonical(args) {
7116
- const buyer = expectLength5(toBytes4(args.buyer), 20, "buyer");
7117
- const buyerPubkey = toBytes4(args.buyerPubkey);
7118
- const sig = toBytes4(args.sig);
7704
+ const buyer = expectLength5(toBytes5(args.buyer), 20, "buyer");
7705
+ const buyerPubkey = toBytes5(args.buyerPubkey);
7706
+ const sig = toBytes5(args.sig);
7119
7707
  if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
7120
7708
  throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
7121
7709
  }
7122
7710
  if (sig.length === 0 || sig.length > 65535) {
7123
7711
  throw new ProverMarketError("sig length out of range (1..=65535)");
7124
7712
  }
7125
- return bytesToHex7(
7126
- concatBytes5(
7713
+ return bytesToHex8(
7714
+ concatBytes7(
7127
7715
  buyer,
7128
7716
  u16Bytes(buyerPubkey.length),
7129
7717
  buyerPubkey,
7130
- expectLength5(toBytes4(args.vkeyHash), 32, "vkeyHash"),
7131
- expectLength5(toBytes4(args.inputsHash), 32, "inputsHash"),
7718
+ expectLength5(toBytes5(args.vkeyHash), 32, "vkeyHash"),
7719
+ expectLength5(toBytes5(args.inputsHash), 32, "inputsHash"),
7132
7720
  u128Bytes(args.maxFee, "maxFee"),
7133
7721
  u64Bytes(args.deadline, "deadline"),
7134
7722
  u64Bytes(args.nonce, "nonce"),
@@ -7138,7 +7726,7 @@ function encodeCreateRequestCanonical(args) {
7138
7726
  );
7139
7727
  }
7140
7728
  function encodeCreateRequestCalldata(args) {
7141
- const canonical = toBytes4(encodeCreateRequestCanonical(args));
7729
+ const canonical = toBytes5(encodeCreateRequestCanonical(args));
7142
7730
  const offset = new Uint8Array(32);
7143
7731
  offset[31] = 32;
7144
7732
  const lenWord = new Uint8Array(32);
@@ -7148,18 +7736,18 @@ function encodeCreateRequestCalldata(args) {
7148
7736
  lenWord[30] = len >>> 8 & 255;
7149
7737
  lenWord[31] = len & 255;
7150
7738
  const pad = (32 - len % 32) % 32;
7151
- return bytesToHex7(
7152
- concatBytes5(hexToBytes6(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
7739
+ return bytesToHex8(
7740
+ concatBytes7(hexToBytes7(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
7153
7741
  );
7154
7742
  }
7155
- function selectorHex2(sig) {
7743
+ function selectorHex3(sig) {
7156
7744
  return [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
7157
7745
  }
7158
- function toBytes4(value) {
7159
- if (typeof value === "string") return hexToBytes6(value);
7746
+ function toBytes5(value) {
7747
+ if (typeof value === "string") return hexToBytes7(value);
7160
7748
  return value instanceof Uint8Array ? value : Uint8Array.from(value);
7161
7749
  }
7162
- function hexToBytes6(hex) {
7750
+ function hexToBytes7(hex) {
7163
7751
  const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
7164
7752
  if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
7165
7753
  throw new ProverMarketError("invalid hex bytes");
@@ -7168,10 +7756,10 @@ function hexToBytes6(hex) {
7168
7756
  for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
7169
7757
  return out;
7170
7758
  }
7171
- function bytesToHex7(bytes) {
7759
+ function bytesToHex8(bytes) {
7172
7760
  return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
7173
7761
  }
7174
- function concatBytes5(...parts) {
7762
+ function concatBytes7(...parts) {
7175
7763
  const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
7176
7764
  let offset = 0;
7177
7765
  for (const part of parts) {
@@ -7248,34 +7836,34 @@ function delegationAddressHex() {
7248
7836
  return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
7249
7837
  }
7250
7838
  function encodeCompleteRedemptionCalldata(index) {
7251
- return bytesToHex8(
7252
- concatBytes6(
7253
- hexToBytes7(DELEGATION_SELECTORS.completeRedemption),
7254
- uint64Word2(index, "index")
7839
+ return bytesToHex9(
7840
+ concatBytes8(
7841
+ hexToBytes8(DELEGATION_SELECTORS.completeRedemption),
7842
+ uint64Word3(index, "index")
7255
7843
  )
7256
7844
  );
7257
7845
  }
7258
7846
  function encodeDelegateCalldata(cluster, weightBps) {
7259
- return bytesToHex8(
7260
- concatBytes6(
7261
- hexToBytes7(DELEGATION_SELECTORS.delegate),
7847
+ return bytesToHex9(
7848
+ concatBytes8(
7849
+ hexToBytes8(DELEGATION_SELECTORS.delegate),
7262
7850
  uint32Word2(cluster, "cluster"),
7263
7851
  uint16Word(weightBps, "weightBps")
7264
7852
  )
7265
7853
  );
7266
7854
  }
7267
7855
  function encodeUndelegateCalldata(cluster) {
7268
- return bytesToHex8(
7269
- concatBytes6(
7270
- hexToBytes7(DELEGATION_SELECTORS.undelegate),
7856
+ return bytesToHex9(
7857
+ concatBytes8(
7858
+ hexToBytes8(DELEGATION_SELECTORS.undelegate),
7271
7859
  uint32Word2(cluster, "cluster")
7272
7860
  )
7273
7861
  );
7274
7862
  }
7275
7863
  function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
7276
- return bytesToHex8(
7277
- concatBytes6(
7278
- hexToBytes7(DELEGATION_SELECTORS.redelegate),
7864
+ return bytesToHex9(
7865
+ concatBytes8(
7866
+ hexToBytes8(DELEGATION_SELECTORS.redelegate),
7279
7867
  uint32Word2(fromCluster, "fromCluster"),
7280
7868
  uint32Word2(toCluster, "toCluster"),
7281
7869
  uint16Word(weightBps, "weightBps")
@@ -7288,14 +7876,14 @@ function encodeClaimCalldata() {
7288
7876
  function encodeSetAutoCompoundCalldata(enabled) {
7289
7877
  const flag = new Uint8Array(32);
7290
7878
  flag[31] = enabled ? 1 : 0;
7291
- return bytesToHex8(
7292
- concatBytes6(hexToBytes7(DELEGATION_SELECTORS.setAutoCompound), flag)
7879
+ return bytesToHex9(
7880
+ concatBytes8(hexToBytes8(DELEGATION_SELECTORS.setAutoCompound), flag)
7293
7881
  );
7294
7882
  }
7295
7883
  function isRedemptionPrincipalUnavailableRevert(data) {
7296
- return bytesToHex8(toBytes5(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
7884
+ return bytesToHex9(toBytes6(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
7297
7885
  }
7298
- function uint64Word2(value, name) {
7886
+ function uint64Word3(value, name) {
7299
7887
  const n = toBigint3(value, name);
7300
7888
  if (n < 0n || n > 0xffffffffffffffffn) {
7301
7889
  throw new DelegationPrecompileError(`${name} must fit uint64`);
@@ -7347,13 +7935,13 @@ function toBigint3(value, name) {
7347
7935
  }
7348
7936
  return BigInt(value);
7349
7937
  }
7350
- function toBytes5(value) {
7938
+ function toBytes6(value) {
7351
7939
  if (typeof value === "string") {
7352
- return hexToBytes7(value);
7940
+ return hexToBytes8(value);
7353
7941
  }
7354
7942
  return value instanceof Uint8Array ? value : Uint8Array.from(value);
7355
7943
  }
7356
- function hexToBytes7(hex) {
7944
+ function hexToBytes8(hex) {
7357
7945
  const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
7358
7946
  if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
7359
7947
  throw new DelegationPrecompileError("invalid hex bytes");
@@ -7364,10 +7952,10 @@ function hexToBytes7(hex) {
7364
7952
  }
7365
7953
  return out;
7366
7954
  }
7367
- function bytesToHex8(bytes) {
7955
+ function bytesToHex9(bytes) {
7368
7956
  return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
7369
7957
  }
7370
- function concatBytes6(...parts) {
7958
+ function concatBytes8(...parts) {
7371
7959
  const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
7372
7960
  let offset = 0;
7373
7961
  for (const part of parts) {
@@ -7376,8 +7964,6 @@ function concatBytes6(...parts) {
7376
7964
  }
7377
7965
  return out;
7378
7966
  }
7379
-
7380
- // src/spending-policy.ts
7381
7967
  var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
7382
7968
  var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
7383
7969
  var ML_DSA_65_SIGNATURE_LEN2 = 3309;
@@ -7400,10 +7986,38 @@ var SpendingPolicyError = class extends Error {
7400
7986
  function spendingPolicyAddressHex() {
7401
7987
  return PRECOMPILE_ADDRESSES.SPENDING_POLICY.toLowerCase();
7402
7988
  }
7989
+ var EMPTY_ROOT = new Uint8Array(32);
7990
+ function destinationRoot(address) {
7991
+ const bytes = toUserAddressBytes(address, "address");
7992
+ return keccak_256(bytes);
7993
+ }
7994
+ var allowRootFor = destinationRoot;
7995
+ var denyRootFor = destinationRoot;
7996
+ function categoryRoot(selectorOrSig) {
7997
+ let selector;
7998
+ if (typeof selectorOrSig === "string") {
7999
+ selector = keccak_256(new TextEncoder().encode(selectorOrSig)).slice(0, 4);
8000
+ } else {
8001
+ selector = selectorOrSig instanceof Uint8Array ? selectorOrSig : Uint8Array.from(selectorOrSig);
8002
+ if (selector.length !== 4) {
8003
+ throw new SpendingPolicyError("category selector must be exactly 4 bytes");
8004
+ }
8005
+ }
8006
+ return keccak_256(selector);
8007
+ }
8008
+ function setDestinationRoot(entries) {
8009
+ if (entries.length === 0) return EMPTY_ROOT;
8010
+ if (entries.length > 1) {
8011
+ throw new SpendingPolicyError(
8012
+ "multi-entry destination sets are not supported by the chain yet (v1 allows a single counterparty per root); pass exactly one address"
8013
+ );
8014
+ }
8015
+ return destinationRoot(entries[0]);
8016
+ }
7403
8017
  function composeClaimBoundMessage(chainId, args, opts) {
7404
8018
  const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
7405
8019
  const normalized = normalizeArgs(args);
7406
- return concatBytes7(
8020
+ return concatBytes9(
7407
8021
  new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
7408
8022
  uint64Bytes(chainId, "chainId"),
7409
8023
  precompileAddress,
@@ -7426,17 +8040,17 @@ function composeClaimBoundMessage(chainId, args, opts) {
7426
8040
  }
7427
8041
  function encodeSetPolicyCalldata(args) {
7428
8042
  const normalized = normalizeArgs(args);
7429
- return bytesToHex9(
7430
- concatBytes7(
7431
- hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicy),
8043
+ return bytesToHex10(
8044
+ concatBytes9(
8045
+ hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicy),
7432
8046
  encodePolicyWords(normalized)
7433
8047
  )
7434
8048
  );
7435
8049
  }
7436
8050
  function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
7437
8051
  const normalized = normalizeArgs(args);
7438
- const pubkey = toBytes6(subAccountPubkey);
7439
- const sig = toBytes6(subAccountSig);
8052
+ const pubkey = toBytes7(subAccountPubkey);
8053
+ const sig = toBytes7(subAccountSig);
7440
8054
  if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
7441
8055
  throw new SpendingPolicyError(
7442
8056
  `subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
@@ -7447,9 +8061,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
7447
8061
  `subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
7448
8062
  );
7449
8063
  }
7450
- return bytesToHex9(
7451
- concatBytes7(
7452
- hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicyClaim),
8064
+ return bytesToHex10(
8065
+ concatBytes9(
8066
+ hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicyClaim),
7453
8067
  encodePolicyWords(normalized),
7454
8068
  pubkey,
7455
8069
  sig
@@ -7458,15 +8072,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
7458
8072
  }
7459
8073
  function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
7460
8074
  const normalized = normalizeArgs(args);
7461
- const sig = toBytes6(subAccountSig);
8075
+ const sig = toBytes7(subAccountSig);
7462
8076
  if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
7463
8077
  throw new SpendingPolicyError(
7464
8078
  `subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
7465
8079
  );
7466
8080
  }
7467
- return bytesToHex9(
7468
- concatBytes7(
7469
- hexToBytes8(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
8081
+ return bytesToHex10(
8082
+ concatBytes9(
8083
+ hexToBytes9(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
7470
8084
  encodePolicyWords(normalized),
7471
8085
  sig
7472
8086
  )
@@ -7485,17 +8099,17 @@ function normalizeArgs(args) {
7485
8099
  principal: toUserAddressBytes(args.principal, "principal"),
7486
8100
  dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
7487
8101
  perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
7488
- allowRoot: expectLength6(toBytes6(args.allowRoot), 32, "allowRoot"),
7489
- denyRoot: expectLength6(toBytes6(args.denyRoot), 32, "denyRoot"),
8102
+ allowRoot: expectLength6(toBytes7(args.allowRoot), 32, "allowRoot"),
8103
+ denyRoot: expectLength6(toBytes7(args.denyRoot), 32, "denyRoot"),
7490
8104
  weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
7491
8105
  monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
7492
- categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes6(args.categoryAllowRoot), 32, "categoryAllowRoot"),
7493
- timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes6(args.timeWindow), 32, "timeWindow"),
8106
+ categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes7(args.categoryAllowRoot), 32, "categoryAllowRoot"),
8107
+ timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes7(args.timeWindow), 32, "timeWindow"),
7494
8108
  policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
7495
8109
  };
7496
8110
  }
7497
8111
  function encodePolicyWords(args) {
7498
- return concatBytes7(
8112
+ return concatBytes9(
7499
8113
  encodeAddressWord(args.subAccount),
7500
8114
  encodeAddressWord(args.principal),
7501
8115
  encodeUint128Word(args.dailyCapLythoshi),
@@ -7520,7 +8134,7 @@ function packTimeWindow(enabled, startHour, endHour) {
7520
8134
  return out;
7521
8135
  }
7522
8136
  function decodeTimeWindow(word) {
7523
- const bytes = expectLength6(toBytes6(word), 32, "timeWindow");
8137
+ const bytes = expectLength6(toBytes7(word), 32, "timeWindow");
7524
8138
  if (bytes.every((b) => b === 0)) return null;
7525
8139
  if (bytes[29] === 0) return null;
7526
8140
  return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
@@ -7532,16 +8146,16 @@ function clampHour(hour) {
7532
8146
  return Math.min(hour, 23);
7533
8147
  }
7534
8148
  function encodeUint64Word(value) {
7535
- return concatBytes7(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
8149
+ return concatBytes9(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
7536
8150
  }
7537
8151
  function encodeSingleAddressCall(selector, address, name) {
7538
- return bytesToHex9(concatBytes7(hexToBytes8(selector), encodeAddressWord(toUserAddressBytes(address, name))));
8152
+ return bytesToHex10(concatBytes9(hexToBytes9(selector), encodeAddressWord(toUserAddressBytes(address, name))));
7539
8153
  }
7540
8154
  function encodeAddressWord(address) {
7541
- return concatBytes7(new Uint8Array(12), address);
8155
+ return concatBytes9(new Uint8Array(12), address);
7542
8156
  }
7543
8157
  function encodeUint128Word(value) {
7544
- return concatBytes7(new Uint8Array(16), uint128Bytes(value, "uint128"));
8158
+ return concatBytes9(new Uint8Array(16), uint128Bytes(value, "uint128"));
7545
8159
  }
7546
8160
  function toUserAddressBytes(value, name) {
7547
8161
  if (typeof value !== "string") {
@@ -7563,13 +8177,13 @@ function toRawAddressBytes(value) {
7563
8177
  }
7564
8178
  return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
7565
8179
  }
7566
- function toBytes6(value) {
8180
+ function toBytes7(value) {
7567
8181
  if (typeof value === "string") {
7568
- return hexToBytes8(value);
8182
+ return hexToBytes9(value);
7569
8183
  }
7570
8184
  return value instanceof Uint8Array ? value : Uint8Array.from(value);
7571
8185
  }
7572
- function hexToBytes8(hex) {
8186
+ function hexToBytes9(hex) {
7573
8187
  const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
7574
8188
  if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
7575
8189
  throw new SpendingPolicyError("invalid hex bytes");
@@ -7580,10 +8194,10 @@ function hexToBytes8(hex) {
7580
8194
  }
7581
8195
  return out;
7582
8196
  }
7583
- function bytesToHex9(bytes) {
8197
+ function bytesToHex10(bytes) {
7584
8198
  return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
7585
8199
  }
7586
- function concatBytes7(...parts) {
8200
+ function concatBytes9(...parts) {
7587
8201
  const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
7588
8202
  let offset = 0;
7589
8203
  for (const part of parts) {
@@ -7645,17 +8259,17 @@ function pubkeyRegistryAddressHex() {
7645
8259
  return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
7646
8260
  }
7647
8261
  function encodeRegisterPubkeyCalldata(pubkey) {
7648
- const bytes = toBytes7(pubkey);
8262
+ const bytes = toBytes8(pubkey);
7649
8263
  if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
7650
8264
  throw new PubkeyRegistryError(
7651
8265
  `pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
7652
8266
  );
7653
8267
  }
7654
- return bytesToHex10(
7655
- concatBytes8(
7656
- hexToBytes9(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
7657
- uint256Word(32n),
7658
- uint256Word(BigInt(bytes.length)),
8268
+ return bytesToHex11(
8269
+ concatBytes10(
8270
+ hexToBytes10(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
8271
+ uint256Word2(32n),
8272
+ uint256Word2(BigInt(bytes.length)),
7659
8273
  bytes
7660
8274
  )
7661
8275
  );
@@ -7667,7 +8281,7 @@ function encodeHasPubkeyCalldata(address) {
7667
8281
  return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
7668
8282
  }
7669
8283
  function decodeLookupPubkeyReturn(data) {
7670
- const bytes = toBytes7(data);
8284
+ const bytes = toBytes8(data);
7671
8285
  if (bytes.length < 96) {
7672
8286
  throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
7673
8287
  }
@@ -7692,7 +8306,7 @@ function decodeLookupPubkeyReturn(data) {
7692
8306
  };
7693
8307
  }
7694
8308
  function decodeHasPubkeyReturn(data) {
7695
- const bytes = toBytes7(data);
8309
+ const bytes = toBytes8(data);
7696
8310
  if (bytes.length !== 32) {
7697
8311
  throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
7698
8312
  }
@@ -7706,10 +8320,10 @@ function decodeHasPubkeyReturn(data) {
7706
8320
  throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
7707
8321
  }
7708
8322
  function encodeSingleAddressCall2(selector, address) {
7709
- return bytesToHex10(concatBytes8(hexToBytes9(selector), addressWord(toAddressBytes(address))));
8323
+ return bytesToHex11(concatBytes10(hexToBytes10(selector), addressWord3(toAddressBytes(address))));
7710
8324
  }
7711
- function addressWord(address) {
7712
- return concatBytes8(new Uint8Array(12), address);
8325
+ function addressWord3(address) {
8326
+ return concatBytes10(new Uint8Array(12), address);
7713
8327
  }
7714
8328
  function toAddressBytes(value) {
7715
8329
  if (typeof value !== "string") {
@@ -7725,13 +8339,13 @@ function toAddressBytes(value) {
7725
8339
  throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
7726
8340
  }
7727
8341
  }
7728
- function toBytes7(value) {
8342
+ function toBytes8(value) {
7729
8343
  if (typeof value === "string") {
7730
- return hexToBytes9(value);
8344
+ return hexToBytes10(value);
7731
8345
  }
7732
8346
  return value instanceof Uint8Array ? value : Uint8Array.from(value);
7733
8347
  }
7734
- function hexToBytes9(hex) {
8348
+ function hexToBytes10(hex) {
7735
8349
  const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
7736
8350
  if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
7737
8351
  throw new PubkeyRegistryError("invalid hex bytes");
@@ -7742,10 +8356,10 @@ function hexToBytes9(hex) {
7742
8356
  }
7743
8357
  return out;
7744
8358
  }
7745
- function bytesToHex10(bytes) {
8359
+ function bytesToHex11(bytes) {
7746
8360
  return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
7747
8361
  }
7748
- function concatBytes8(...parts) {
8362
+ function concatBytes10(...parts) {
7749
8363
  const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
7750
8364
  let offset = 0;
7751
8365
  for (const part of parts) {
@@ -7754,7 +8368,7 @@ function concatBytes8(...parts) {
7754
8368
  }
7755
8369
  return out;
7756
8370
  }
7757
- function uint256Word(value) {
8371
+ function uint256Word2(value) {
7758
8372
  if (value < 0n || value > (1n << 256n) - 1n) {
7759
8373
  throw new PubkeyRegistryError("uint256 value out of range");
7760
8374
  }
@@ -7776,6 +8390,11 @@ function wordToBigint(word) {
7776
8390
  }
7777
8391
  return out;
7778
8392
  }
8393
+ new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
8394
+ var MempoolClass = {
8395
+ CLOBOp: 3};
8396
+
8397
+ // src/market-actions.ts
7779
8398
  var CLOB_MARKET_ID_DOMAIN_TAG = 193;
7780
8399
  var NATIVE_MARKET_MODULE_ADDRESS_BYTES = "0x4d41524b45545f4e41544956455f4d4f445f5631";
7781
8400
  var NATIVE_MARKET_MODULE_ADDRESS = addressToTypedBech32(
@@ -7902,9 +8521,9 @@ function encodePlaceLimitOrderCalldata(args) {
7902
8521
  normalized.baseTokenId,
7903
8522
  normalized.quoteTokenId,
7904
8523
  uint8Word2(normalized.side),
7905
- uint256Word2(normalized.price, "price"),
7906
- uint256Word2(normalized.quantity, "quantity"),
7907
- uint64Word3(normalized.expiryBlock, "expiryBlock")
8524
+ uint256Word3(normalized.price, "price"),
8525
+ uint256Word3(normalized.quantity, "quantity"),
8526
+ uint64Word4(normalized.expiryBlock, "expiryBlock")
7908
8527
  )
7909
8528
  );
7910
8529
  }
@@ -7916,7 +8535,7 @@ function encodePlaceMarketOrderCalldata(args) {
7916
8535
  normalized.baseTokenId,
7917
8536
  normalized.quoteTokenId,
7918
8537
  uint8Word2(normalized.side),
7919
- uint256Word2(normalized.quantity, "quantity"),
8538
+ uint256Word3(normalized.quantity, "quantity"),
7920
8539
  uint16Word2(normalized.maxSlippageBps, "maxSlippageBps")
7921
8540
  )
7922
8541
  );
@@ -7929,7 +8548,7 @@ function encodePlaceMarketOrderExCalldata(args) {
7929
8548
  normalized.baseTokenId,
7930
8549
  normalized.quoteTokenId,
7931
8550
  uint8Word2(normalized.side),
7932
- uint256Word2(normalized.quantity, "quantity"),
8551
+ uint256Word3(normalized.quantity, "quantity"),
7933
8552
  uint16Word2(normalized.maxSlippageBps, "maxSlippageBps"),
7934
8553
  uint8Word2(normalized.mode)
7935
8554
  )
@@ -7949,7 +8568,7 @@ function encodeMarketGridTuneCalldata(selector, label, args) {
7949
8568
  hexToBytes2(selector, `${label} selector`),
7950
8569
  bytes32FromHex(args.baseTokenId, "baseTokenId"),
7951
8570
  bytes32FromHex(args.quoteTokenId, "quoteTokenId"),
7952
- uint256Word2(BigInt(args.newValue), "newValue")
8571
+ uint256Word3(BigInt(args.newValue), "newValue")
7953
8572
  )
7954
8573
  );
7955
8574
  }
@@ -8237,13 +8856,13 @@ function encodePlaceLimitOrderViaCalldata(args) {
8237
8856
  return bytesToHex2(
8238
8857
  concatBytes2(
8239
8858
  hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
8240
- addressWord2(operator.bytes),
8859
+ addressWord4(operator.bytes),
8241
8860
  bytes32FromHex(args.base, "base"),
8242
8861
  bytes32FromHex(args.quote, "quote"),
8243
8862
  uint8Word2(side),
8244
- uint256Word2(price, "price"),
8245
- uint256Word2(amount, "amount"),
8246
- uint64Word3(expiresAtBlock, "expiresAtBlock")
8863
+ uint256Word3(price, "price"),
8864
+ uint256Word3(amount, "amount"),
8865
+ uint64Word4(expiresAtBlock, "expiresAtBlock")
8247
8866
  )
8248
8867
  );
8249
8868
  }
@@ -8533,7 +9152,7 @@ function uint8Word2(value) {
8533
9152
  out[31] = value;
8534
9153
  return out;
8535
9154
  }
8536
- function uint64Word3(value, name) {
9155
+ function uint64Word4(value, name) {
8537
9156
  if (value < 0n || value > 0xffffffffffffffffn) {
8538
9157
  throw new MarketActionError(`${name} must fit uint64`);
8539
9158
  }
@@ -8554,7 +9173,7 @@ function uint16Word2(value, name) {
8554
9173
  out[31] = Number(value & 0xffn);
8555
9174
  return out;
8556
9175
  }
8557
- function uint256Word2(value, name) {
9176
+ function uint256Word3(value, name) {
8558
9177
  if (value < 0n || value >= 1n << 256n) {
8559
9178
  throw new MarketActionError(`${name} must fit uint256`);
8560
9179
  }
@@ -8566,7 +9185,7 @@ function uint256Word2(value, name) {
8566
9185
  }
8567
9186
  return out;
8568
9187
  }
8569
- function addressWord2(addr) {
9188
+ function addressWord4(addr) {
8570
9189
  if (addr.length !== 20) {
8571
9190
  throw new MarketActionError("address must be 20 bytes");
8572
9191
  }
@@ -9106,8 +9725,8 @@ var MONOLYTHIUM_NETWORKS = {
9106
9725
  };
9107
9726
 
9108
9727
  // src/index.ts
9109
- var version = "0.2.2";
9728
+ var version = "0.3.15";
9110
9729
 
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 };
9730
+ 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
9731
  //# sourceMappingURL=index.js.map
9113
9732
  //# sourceMappingURL=index.js.map