@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/README.md +24 -0
- package/dist/crypto/index.cjs +5 -73
- package/dist/crypto/index.cjs.map +1 -1
- package/dist/crypto/index.d.cts +2 -2
- package/dist/crypto/index.d.ts +2 -2
- package/dist/crypto/index.js +5 -74
- package/dist/crypto/index.js.map +1 -1
- package/dist/index.cjs +1021 -360
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +980 -361
- package/dist/index.js.map +1 -1
- package/dist/{submission-CA8L21An.d.cts → submission-BeEYbbGi.d.cts} +551 -15
- package/dist/{submission-CA8L21An.d.ts → submission-BeEYbbGi.d.ts} +551 -15
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var blake3_js = require('@noble/hashes/blake3.js');
|
|
4
4
|
var sha3_js = require('@noble/hashes/sha3.js');
|
|
5
|
-
var mlKem_js = require('@noble/post-quantum/ml-kem.js');
|
|
6
|
-
var chacha_js = require('@noble/ciphers/chacha.js');
|
|
7
|
-
var utils_js = require('@noble/hashes/utils.js');
|
|
8
5
|
var mlDsa_js = require('@noble/post-quantum/ml-dsa.js');
|
|
9
6
|
var bls12381_js = require('@noble/curves/bls12-381.js');
|
|
7
|
+
require('@noble/post-quantum/ml-kem.js');
|
|
8
|
+
require('@noble/ciphers/chacha.js');
|
|
9
|
+
require('@noble/hashes/utils.js');
|
|
10
10
|
|
|
11
11
|
// src/error.ts
|
|
12
12
|
var SdkError = class _SdkError extends Error {
|
|
@@ -422,6 +422,14 @@ var SERVICE_PROBE_STATUS = {
|
|
|
422
422
|
UNREACHABLE: 3
|
|
423
423
|
};
|
|
424
424
|
var NODE_REGISTRY_SELECTORS = {
|
|
425
|
+
/** `recoverOperatorNode(bytes32)` — foundation-gated DR alias for `unjail`. */
|
|
426
|
+
recoverOperatorNode: "0x" + selectorHex("recoverOperatorNode(bytes32)"),
|
|
427
|
+
/** `submitPendingChange(uint8,bytes,uint64,uint64)` — foundation-gated roster lifecycle. */
|
|
428
|
+
submitPendingChange: "0x" + selectorHex("submitPendingChange(uint8,bytes,uint64,uint64)"),
|
|
429
|
+
/** `cancelPendingChange(uint64,bytes)` — foundation-gated pending-change cancellation. */
|
|
430
|
+
cancelPendingChange: "0x" + selectorHex("cancelPendingChange(uint64,bytes)"),
|
|
431
|
+
/** `attestDkgReshare(uint64,bytes,bytes)` — operator-signed DKG re-share attestation. */
|
|
432
|
+
attestDkgReshare: "0x" + selectorHex("attestDkgReshare(uint64,bytes,bytes)"),
|
|
425
433
|
reportServiceProbe: "0xeee31bba",
|
|
426
434
|
getServiceProbe: "0x1fcbfbce",
|
|
427
435
|
/** `setNetworkMetadata(bytes32,uint16,bytes3,bytes)` — owner-callable (PF-6). */
|
|
@@ -431,6 +439,21 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
431
439
|
/** `getClusterDiversity(uint32)` view (PF-6). */
|
|
432
440
|
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)")
|
|
433
441
|
};
|
|
442
|
+
var NODE_REGISTRY_BLS_PUBKEY_BYTES = 48;
|
|
443
|
+
var NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = 96;
|
|
444
|
+
var NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = 5;
|
|
445
|
+
var NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS = 7;
|
|
446
|
+
var NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = (1n << 56n) - 1n;
|
|
447
|
+
var PENDING_CHANGE_KIND_CODES = {
|
|
448
|
+
add: 1,
|
|
449
|
+
remove: 2,
|
|
450
|
+
rotate: 3
|
|
451
|
+
};
|
|
452
|
+
var PENDING_CHANGE_KIND_LABELS = {
|
|
453
|
+
1: "add",
|
|
454
|
+
2: "remove",
|
|
455
|
+
3: "rotate"
|
|
456
|
+
};
|
|
434
457
|
var CLUSTER_FORMED_EVENT_SIG = "ClusterFormed(uint32,uint64,address,bytes)";
|
|
435
458
|
var NodeRegistryError = class extends Error {
|
|
436
459
|
constructor(message) {
|
|
@@ -465,6 +488,131 @@ function serviceProbeStatusLabel(status) {
|
|
|
465
488
|
return "unknown";
|
|
466
489
|
}
|
|
467
490
|
}
|
|
491
|
+
function normalizePendingChangeKind(kind) {
|
|
492
|
+
if (typeof kind === "number") {
|
|
493
|
+
const label = PENDING_CHANGE_KIND_LABELS[kind];
|
|
494
|
+
if (!label) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
495
|
+
return { kind: label, kindCode: kind };
|
|
496
|
+
}
|
|
497
|
+
const kindCode = PENDING_CHANGE_KIND_CODES[kind];
|
|
498
|
+
if (!kindCode) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
499
|
+
return { kind, kindCode };
|
|
500
|
+
}
|
|
501
|
+
function encodeRecoverOperatorNodeCalldata(peerId) {
|
|
502
|
+
return bytesToHex(
|
|
503
|
+
concatBytes(
|
|
504
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.recoverOperatorNode),
|
|
505
|
+
expectLength2(toBytes(peerId), 32, "peerId")
|
|
506
|
+
)
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
function encodeSubmitPendingChangeCalldata(args) {
|
|
510
|
+
const { kind, kindCode } = normalizePendingChangeKind(args.kind);
|
|
511
|
+
const targetPubkey = expectLength2(
|
|
512
|
+
toBytes(args.targetPubkey),
|
|
513
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
514
|
+
"targetPubkey"
|
|
515
|
+
);
|
|
516
|
+
const effectiveEpoch = toUint64(args.effectiveEpoch, "effectiveEpoch");
|
|
517
|
+
if (effectiveEpoch === 0n) {
|
|
518
|
+
throw new NodeRegistryError("effectiveEpoch must be greater than zero");
|
|
519
|
+
}
|
|
520
|
+
const intentId = toUint64(args.intentId ?? 0n, "intentId");
|
|
521
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
522
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
523
|
+
}
|
|
524
|
+
if (kind !== "rotate" && intentId !== 0n) {
|
|
525
|
+
throw new NodeRegistryError("only rotate pending changes may carry a non-zero intentId");
|
|
526
|
+
}
|
|
527
|
+
const targetTail = new Uint8Array(32);
|
|
528
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
529
|
+
return bytesToHex(
|
|
530
|
+
concatBytes(
|
|
531
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.submitPendingChange),
|
|
532
|
+
uint8Word(kindCode),
|
|
533
|
+
uint64Word(4n * 32n, "targetPubkeyOffset"),
|
|
534
|
+
uint64Word(effectiveEpoch, "effectiveEpoch"),
|
|
535
|
+
uint64Word(intentId, "intentId"),
|
|
536
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
537
|
+
targetPubkey.slice(0, 32),
|
|
538
|
+
targetTail
|
|
539
|
+
)
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
function encodeCancelPendingChangeCalldata(args) {
|
|
543
|
+
const targetPubkey = expectLength2(
|
|
544
|
+
toBytes(args.targetPubkey),
|
|
545
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
546
|
+
"targetPubkey"
|
|
547
|
+
);
|
|
548
|
+
const targetTail = new Uint8Array(32);
|
|
549
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
550
|
+
return bytesToHex(
|
|
551
|
+
concatBytes(
|
|
552
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.cancelPendingChange),
|
|
553
|
+
uint64Word(args.epoch, "epoch"),
|
|
554
|
+
uint64Word(2n * 32n, "targetPubkeyOffset"),
|
|
555
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
556
|
+
targetPubkey.slice(0, 32),
|
|
557
|
+
targetTail
|
|
558
|
+
)
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
function parseDkgResharePublicKeys(blsPublicKeys) {
|
|
562
|
+
const keys = toBytes(blsPublicKeys);
|
|
563
|
+
if (keys.length % NODE_REGISTRY_BLS_PUBKEY_BYTES !== 0) {
|
|
564
|
+
throw new NodeRegistryError("blsPublicKeys length must be a multiple of 48 bytes");
|
|
565
|
+
}
|
|
566
|
+
const signerCount = keys.length / NODE_REGISTRY_BLS_PUBKEY_BYTES;
|
|
567
|
+
if (signerCount < NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS || signerCount > NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS) {
|
|
568
|
+
throw new NodeRegistryError(
|
|
569
|
+
`blsPublicKeys must contain ${NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS}..${NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS} signers`
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
const out = [];
|
|
573
|
+
const seen = /* @__PURE__ */ new Set();
|
|
574
|
+
for (let offset = 0; offset < keys.length; offset += NODE_REGISTRY_BLS_PUBKEY_BYTES) {
|
|
575
|
+
const key = keys.slice(offset, offset + NODE_REGISTRY_BLS_PUBKEY_BYTES);
|
|
576
|
+
const keyHex = bytesToHex(key);
|
|
577
|
+
if (seen.has(keyHex)) {
|
|
578
|
+
throw new NodeRegistryError("blsPublicKeys contains a duplicate signer pubkey");
|
|
579
|
+
}
|
|
580
|
+
seen.add(keyHex);
|
|
581
|
+
out.push(key);
|
|
582
|
+
}
|
|
583
|
+
return out;
|
|
584
|
+
}
|
|
585
|
+
function encodeAttestDkgReshareCalldata(args) {
|
|
586
|
+
const intentId = toUint64(args.intentId, "intentId");
|
|
587
|
+
if (intentId === 0n) {
|
|
588
|
+
throw new NodeRegistryError("intentId must be greater than zero");
|
|
589
|
+
}
|
|
590
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
591
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
592
|
+
}
|
|
593
|
+
const publicKeys = concatBytes(...parseDkgResharePublicKeys(args.blsPublicKeys));
|
|
594
|
+
const thresholdSig = expectLength2(
|
|
595
|
+
toBytes(args.thresholdSig),
|
|
596
|
+
NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES,
|
|
597
|
+
"thresholdSig"
|
|
598
|
+
);
|
|
599
|
+
const keysPadded = padToWord(publicKeys);
|
|
600
|
+
const sigPadded = padToWord(thresholdSig);
|
|
601
|
+
const offsetKeys = 3n * 32n;
|
|
602
|
+
const offsetSig = offsetKeys + 32n + BigInt(keysPadded.length);
|
|
603
|
+
return bytesToHex(
|
|
604
|
+
concatBytes(
|
|
605
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.attestDkgReshare),
|
|
606
|
+
uint64Word(intentId, "intentId"),
|
|
607
|
+
uint64Word(offsetKeys, "blsPublicKeysOffset"),
|
|
608
|
+
uint64Word(offsetSig, "thresholdSigOffset"),
|
|
609
|
+
uint64Word(BigInt(publicKeys.length), "blsPublicKeysLength"),
|
|
610
|
+
keysPadded,
|
|
611
|
+
uint64Word(BigInt(thresholdSig.length), "thresholdSigLength"),
|
|
612
|
+
sigPadded
|
|
613
|
+
)
|
|
614
|
+
);
|
|
615
|
+
}
|
|
468
616
|
function encodeReportServiceProbeCalldata(args) {
|
|
469
617
|
if (!isValidPublicServiceProbeMask(args.serviceMask)) {
|
|
470
618
|
throw new NodeRegistryError(
|
|
@@ -624,6 +772,44 @@ function uint8Word(value) {
|
|
|
624
772
|
out[31] = value;
|
|
625
773
|
return out;
|
|
626
774
|
}
|
|
775
|
+
function uint64Word(value, name) {
|
|
776
|
+
const n = toUint64(value, name);
|
|
777
|
+
const out = new Uint8Array(32);
|
|
778
|
+
let rest = n;
|
|
779
|
+
for (let i = 31; i >= 24; i--) {
|
|
780
|
+
out[i] = Number(rest & 0xffn);
|
|
781
|
+
rest >>= 8n;
|
|
782
|
+
}
|
|
783
|
+
return out;
|
|
784
|
+
}
|
|
785
|
+
function toUint64(value, name) {
|
|
786
|
+
let parsed;
|
|
787
|
+
if (typeof value === "bigint") {
|
|
788
|
+
parsed = value;
|
|
789
|
+
} else if (typeof value === "number") {
|
|
790
|
+
if (!Number.isSafeInteger(value)) {
|
|
791
|
+
throw new NodeRegistryError(`${name} must be a safe integer`);
|
|
792
|
+
}
|
|
793
|
+
parsed = BigInt(value);
|
|
794
|
+
} else {
|
|
795
|
+
const trimmed = value.trim();
|
|
796
|
+
if (!/^\d+$/u.test(trimmed)) {
|
|
797
|
+
throw new NodeRegistryError(`${name} must be a decimal uint64`);
|
|
798
|
+
}
|
|
799
|
+
parsed = BigInt(trimmed);
|
|
800
|
+
}
|
|
801
|
+
if (parsed < 0n || parsed > 0xffffffffffffffffn) {
|
|
802
|
+
throw new NodeRegistryError(`${name} must fit uint64`);
|
|
803
|
+
}
|
|
804
|
+
return parsed;
|
|
805
|
+
}
|
|
806
|
+
function padToWord(bytes) {
|
|
807
|
+
const paddedLength = Math.ceil(bytes.length / 32) * 32;
|
|
808
|
+
if (paddedLength === bytes.length) return bytes;
|
|
809
|
+
const out = new Uint8Array(paddedLength);
|
|
810
|
+
out.set(bytes);
|
|
811
|
+
return out;
|
|
812
|
+
}
|
|
627
813
|
function toBytes(value) {
|
|
628
814
|
if (typeof value === "string") {
|
|
629
815
|
return hexToBytes(value);
|
|
@@ -711,15 +897,26 @@ function bigintToBeBytes(value, bytes, label) {
|
|
|
711
897
|
}
|
|
712
898
|
return out;
|
|
713
899
|
}
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
900
|
+
|
|
901
|
+
// src/crypto/submission.ts
|
|
902
|
+
async function fetchEncryptionKey(client) {
|
|
903
|
+
const result = await client.call(
|
|
904
|
+
"lyth_getEncryptionKey",
|
|
905
|
+
[]
|
|
906
|
+
);
|
|
907
|
+
return {
|
|
908
|
+
algo: result.algo ?? "ml-kem-768",
|
|
909
|
+
epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
|
|
910
|
+
encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
var ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE = "encrypted mempool submission unavailable until MB-3 threshold decryption is active";
|
|
914
|
+
async function buildEncryptedSubmission(_args) {
|
|
915
|
+
await Promise.resolve();
|
|
916
|
+
throw new Error(ENCRYPTED_SUBMISSION_UNAVAILABLE_MESSAGE);
|
|
917
|
+
}
|
|
918
|
+
async function submitEncryptedEnvelope(client, envelopeWireHex) {
|
|
919
|
+
return client.call("lyth_submitEncrypted", [envelopeWireHex]);
|
|
723
920
|
}
|
|
724
921
|
|
|
725
922
|
// src/crypto/bincode.ts
|
|
@@ -780,164 +977,6 @@ var BincodeWriter = class {
|
|
|
780
977
|
}
|
|
781
978
|
}
|
|
782
979
|
};
|
|
783
|
-
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
784
|
-
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
785
|
-
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
786
|
-
var ENUM_VARIANT_INDEX_ML_DSA_65 = 5;
|
|
787
|
-
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
788
|
-
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
789
|
-
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
790
|
-
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
791
|
-
}
|
|
792
|
-
function mlDsa65AddressBytes(publicKey) {
|
|
793
|
-
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
794
|
-
return blake3_js.blake3(concatBytes2(
|
|
795
|
-
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
796
|
-
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
797
|
-
bytes
|
|
798
|
-
)).slice(0, 20);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
// src/crypto/envelope.ts
|
|
802
|
-
var DKG_AEAD_DOMAIN_TAG = new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
|
|
803
|
-
var ML_KEM_768_ENCAPSULATION_KEY_LEN = 1184;
|
|
804
|
-
var DKG_NONCE_LEN = 12;
|
|
805
|
-
var MempoolClass = {
|
|
806
|
-
Transfer: 0,
|
|
807
|
-
ContractCall: 1,
|
|
808
|
-
CLOBOp: 3};
|
|
809
|
-
function bincodeNonceAad(aad) {
|
|
810
|
-
const w = new BincodeWriter();
|
|
811
|
-
w.bytes(expectBytes(aad.sender, 20, "NonceAad.sender"));
|
|
812
|
-
w.u64(aad.nonce);
|
|
813
|
-
w.u64(aad.chainId);
|
|
814
|
-
w.enumVariant(aad.class);
|
|
815
|
-
w.u128(aad.maxFeePerGas);
|
|
816
|
-
w.u128(aad.maxPriorityFeePerGas);
|
|
817
|
-
w.u64(aad.gasLimit);
|
|
818
|
-
return w.toBytes();
|
|
819
|
-
}
|
|
820
|
-
function bincodeDecryptHint(hint) {
|
|
821
|
-
const w = new BincodeWriter();
|
|
822
|
-
w.u64(hint.epoch);
|
|
823
|
-
w.u16(hint.scheme);
|
|
824
|
-
return w.toBytes();
|
|
825
|
-
}
|
|
826
|
-
function bincodeEncryptedEnvelope(env) {
|
|
827
|
-
const w = new BincodeWriter();
|
|
828
|
-
w.rawBytes(bincodeNonceAad(env.nonceAad));
|
|
829
|
-
w.bytes(env.ciphertext);
|
|
830
|
-
w.rawBytes(bincodeDecryptHint(env.decryptionHint));
|
|
831
|
-
bincodeMlDsa65OpaqueInto(w, expectBytes(env.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey"));
|
|
832
|
-
bincodeMlDsa65OpaqueInto(w, expectBytes(env.outerSignature, ML_DSA_65_SIGNATURE_LEN, "outerSignature"));
|
|
833
|
-
w.bytes(expectBytes(env.sender, 20, "sender"));
|
|
834
|
-
return w.toBytes();
|
|
835
|
-
}
|
|
836
|
-
function encryptInnerTx(signedInnerTxBincode, nonceAad, kemEncapsulationKey) {
|
|
837
|
-
expectBytes(kemEncapsulationKey, ML_KEM_768_ENCAPSULATION_KEY_LEN, "kemEncapsulationKey");
|
|
838
|
-
const { cipherText: kemCt, sharedSecret } = mlKem_js.ml_kem768.encapsulate(kemEncapsulationKey);
|
|
839
|
-
const nonce = utils_js.randomBytes(DKG_NONCE_LEN);
|
|
840
|
-
const cipher = chacha_js.chacha20poly1305(sharedSecret, nonce, aadFor(nonceAad));
|
|
841
|
-
const aeadCt = cipher.encrypt(signedInnerTxBincode);
|
|
842
|
-
sharedSecret.fill(0);
|
|
843
|
-
return concatBytes2(kemCt, nonce, aeadCt);
|
|
844
|
-
}
|
|
845
|
-
function outerSigDigest(nonceAad, ciphertext, decryptionHint, senderPubkey) {
|
|
846
|
-
const aad = bincodeNonceAad(nonceAad);
|
|
847
|
-
const hint = bincodeDecryptHint(decryptionHint);
|
|
848
|
-
return sha3_js.keccak_256(concatBytes2(aad, ciphertext, hint, expectBytes(senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey")));
|
|
849
|
-
}
|
|
850
|
-
async function buildEncryptedEnvelope(args) {
|
|
851
|
-
const ciphertext = encryptInnerTx(args.signedInnerTxBincode, args.nonceAad, args.kemEncapsulationKey);
|
|
852
|
-
const digest = outerSigDigest(args.nonceAad, ciphertext, args.decryptionHint, args.senderPubkey);
|
|
853
|
-
const outerSignature = await args.signOuterDigest(digest);
|
|
854
|
-
const envelope = {
|
|
855
|
-
nonceAad: args.nonceAad,
|
|
856
|
-
ciphertext,
|
|
857
|
-
decryptionHint: args.decryptionHint,
|
|
858
|
-
senderPubkey: expectBytes(args.senderPubkey, ML_DSA_65_PUBLIC_KEY_LEN, "senderPubkey"),
|
|
859
|
-
outerSignature: expectBytes(outerSignature, ML_DSA_65_SIGNATURE_LEN, "outerSignature"),
|
|
860
|
-
sender: expectBytes(args.senderAddress, 20, "senderAddress")
|
|
861
|
-
};
|
|
862
|
-
const wireBytes = bincodeEncryptedEnvelope(envelope);
|
|
863
|
-
return { envelope, wireBytes, wireHex: bytesToHex2(wireBytes) };
|
|
864
|
-
}
|
|
865
|
-
function aadFor(aad) {
|
|
866
|
-
return concatBytes2(DKG_AEAD_DOMAIN_TAG, bincodeNonceAad(aad));
|
|
867
|
-
}
|
|
868
|
-
function bincodeMlDsa65OpaqueInto(w, raw) {
|
|
869
|
-
w.enumVariant(ENUM_VARIANT_INDEX_ML_DSA_65);
|
|
870
|
-
w.u16(STANDARD_ALGO_NUMBER_ML_DSA_65);
|
|
871
|
-
w.bytes(raw);
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
// src/crypto/submission.ts
|
|
875
|
-
async function fetchEncryptionKey(client) {
|
|
876
|
-
const result = await client.call(
|
|
877
|
-
"lyth_getEncryptionKey",
|
|
878
|
-
[]
|
|
879
|
-
);
|
|
880
|
-
return {
|
|
881
|
-
algo: result.algo ?? "ml-kem-768",
|
|
882
|
-
epoch: typeof result.epoch === "string" ? BigInt(result.epoch) : BigInt(result.epoch),
|
|
883
|
-
encapsulationKey: hexToBytes2(result.encapsulationKey, "encapsulationKey")
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
async function buildEncryptedSubmission(args) {
|
|
887
|
-
const input = normalizeInput(args.tx.input);
|
|
888
|
-
const to = normalizeTo(args.tx.to);
|
|
889
|
-
const nonceAad = {
|
|
890
|
-
sender: args.backend.addressBytes(),
|
|
891
|
-
nonce: parseBigint(args.tx.nonce, "nonce"),
|
|
892
|
-
chainId: parseBigint(args.tx.chainId, "chainId"),
|
|
893
|
-
class: args.class ?? (to !== null && input.length === 0 ? MempoolClass.Transfer : MempoolClass.ContractCall),
|
|
894
|
-
maxFeePerGas: u128Checked(parseBigint(args.tx.maxFeePerGas, "maxFeePerGas"), "maxFeePerGas"),
|
|
895
|
-
maxPriorityFeePerGas: u128Checked(
|
|
896
|
-
parseBigint(args.tx.maxPriorityFeePerGas, "maxPriorityFeePerGas"),
|
|
897
|
-
"maxPriorityFeePerGas"
|
|
898
|
-
),
|
|
899
|
-
gasLimit: parseBigint(args.tx.gasLimit, "gasLimit")
|
|
900
|
-
};
|
|
901
|
-
const signed = args.backend.signEvmTx(args.tx);
|
|
902
|
-
const decryptionHint = { epoch: args.encryptionKey.epoch, scheme: 0 };
|
|
903
|
-
const built = await buildEncryptedEnvelope({
|
|
904
|
-
signedInnerTxBincode: signed.wireBytes,
|
|
905
|
-
nonceAad,
|
|
906
|
-
decryptionHint,
|
|
907
|
-
kemEncapsulationKey: args.encryptionKey.encapsulationKey,
|
|
908
|
-
senderAddress: args.backend.addressBytes(),
|
|
909
|
-
senderPubkey: args.backend.publicKey(),
|
|
910
|
-
signOuterDigest: (digest) => args.backend.signPrehash(digest)
|
|
911
|
-
});
|
|
912
|
-
return {
|
|
913
|
-
envelopeWireHex: built.wireHex,
|
|
914
|
-
innerSighashHex: `0x${[...signed.sighash].map((b) => b.toString(16).padStart(2, "0")).join("")}`,
|
|
915
|
-
innerTxHashHex: bytesToHex2(signed.txHash),
|
|
916
|
-
innerWireBytes: signed.wireBytes.length
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
async function submitEncryptedEnvelope(client, envelopeWireHex) {
|
|
920
|
-
return client.call("lyth_submitEncrypted", [envelopeWireHex]);
|
|
921
|
-
}
|
|
922
|
-
function u128Checked(value, field2) {
|
|
923
|
-
const cap = (1n << 128n) - 1n;
|
|
924
|
-
if (value < 0n || value > cap) {
|
|
925
|
-
throw new Error(`${field2} must fit in u128 for encrypted nonce AAD`);
|
|
926
|
-
}
|
|
927
|
-
return value;
|
|
928
|
-
}
|
|
929
|
-
function normalizeTo(value) {
|
|
930
|
-
if (value === null) return null;
|
|
931
|
-
if (typeof value === "string") return hexToAddressBytes(value);
|
|
932
|
-
const bytes = value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
933
|
-
if (bytes.length !== 20) throw new Error("to must be 20 bytes");
|
|
934
|
-
return bytes;
|
|
935
|
-
}
|
|
936
|
-
function normalizeInput(value) {
|
|
937
|
-
if (value === void 0) return new Uint8Array(0);
|
|
938
|
-
if (typeof value === "string") return hexToBytes2(value, "input");
|
|
939
|
-
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
940
|
-
}
|
|
941
980
|
|
|
942
981
|
// src/mrv.ts
|
|
943
982
|
var MRV_FORMAT_VERSION = 1;
|
|
@@ -949,9 +988,9 @@ var MRV_MAX_DEBUG_BYTES = 16 * 1024 * 1024;
|
|
|
949
988
|
var MRV_MAX_MEMORY_PAGES = 1024;
|
|
950
989
|
var MRV_MAX_ABI_SYMBOLS = 1024;
|
|
951
990
|
var MRV_MAX_STORAGE_NAMESPACE_BYTES = 64;
|
|
952
|
-
var LYTH_DECIMALS =
|
|
991
|
+
var LYTH_DECIMALS = 18;
|
|
953
992
|
var NATIVE_LYTH_DECIMALS = LYTH_DECIMALS;
|
|
954
|
-
var LYTHOSHI_PER_LYTH =
|
|
993
|
+
var LYTHOSHI_PER_LYTH = 1000000000000000000n;
|
|
955
994
|
var MRV_TX_EXTENSION_KIND = 48;
|
|
956
995
|
var MRV_TX_EXTENSION_V1 = 1;
|
|
957
996
|
var MRV_CODE_HASH_DOMAIN = new TextEncoder().encode("MONO_MRV_CODE_V1");
|
|
@@ -1018,7 +1057,7 @@ function parseLythToLythoshi(input) {
|
|
|
1018
1057
|
throw new MrvValidationError("lyth amount must be a canonical LYTH decimal");
|
|
1019
1058
|
}
|
|
1020
1059
|
if (fractionRaw.length > NATIVE_LYTH_DECIMALS || !/^[0-9]*$/.test(fractionRaw)) {
|
|
1021
|
-
throw new MrvValidationError(
|
|
1060
|
+
throw new MrvValidationError(`lyth amount supports at most ${NATIVE_LYTH_DECIMALS} decimal places`);
|
|
1022
1061
|
}
|
|
1023
1062
|
const whole = BigInt(wholeRaw.replaceAll(",", ""));
|
|
1024
1063
|
const fraction = fractionRaw === "" ? 0n : BigInt(fractionRaw.padEnd(NATIVE_LYTH_DECIMALS, "0"));
|
|
@@ -1042,7 +1081,7 @@ function checkMrvFeeDisplayConformance(input) {
|
|
|
1042
1081
|
failures.push(`defaultFeeText fee must total ${expectedTotalLythoshi} lythoshi`);
|
|
1043
1082
|
}
|
|
1044
1083
|
} catch {
|
|
1045
|
-
failures.push(
|
|
1084
|
+
failures.push(`defaultFeeText fee must be a canonical ${NATIVE_LYTH_DECIMALS}-decimal LYTH amount`);
|
|
1046
1085
|
}
|
|
1047
1086
|
}
|
|
1048
1087
|
const defaultForbidden = firstForbiddenDefaultFeeTerm(input.defaultFeeText);
|
|
@@ -1426,38 +1465,20 @@ function buildMrvNativeFeePreview(executionUnitLimit, maxExecutionFeeLythoshi, p
|
|
|
1426
1465
|
async function submitMrvDeployNativeTx(client, backend, artifactBytes, options) {
|
|
1427
1466
|
const plan = buildMrvDeployNativeTxPlan(artifactBytes, options);
|
|
1428
1467
|
assertMrvDeployNativeSubmissionPlan(plan);
|
|
1429
|
-
|
|
1430
|
-
backend,
|
|
1431
|
-
tx: plan.tx,
|
|
1432
|
-
encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
|
|
1433
|
-
class: options.class
|
|
1434
|
-
});
|
|
1435
|
-
return {
|
|
1436
|
-
...plan,
|
|
1437
|
-
...submission,
|
|
1438
|
-
txHash: await submitEncryptedEnvelope(client, submission.envelopeWireHex)
|
|
1439
|
-
};
|
|
1468
|
+
return submitMrvEncryptedNativeTxGated(client, backend, plan, options);
|
|
1440
1469
|
}
|
|
1441
1470
|
async function submitMrvDeployPayloadNativeTx(client, backend, artifactBytes, options) {
|
|
1442
1471
|
const plan = buildMrvDeployPayloadNativeTxPlan(artifactBytes, options);
|
|
1443
1472
|
assertMrvDeployNativeSubmissionPlan(plan);
|
|
1444
|
-
|
|
1445
|
-
backend,
|
|
1446
|
-
tx: plan.tx,
|
|
1447
|
-
encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
|
|
1448
|
-
class: options.class
|
|
1449
|
-
});
|
|
1450
|
-
return {
|
|
1451
|
-
...plan,
|
|
1452
|
-
...submission,
|
|
1453
|
-
txHash: await submitEncryptedEnvelope(client, submission.envelopeWireHex)
|
|
1454
|
-
};
|
|
1473
|
+
return submitMrvEncryptedNativeTxGated(client, backend, plan, options);
|
|
1455
1474
|
}
|
|
1456
1475
|
async function submitMrvCallNativeTx(client, backend, contractAddress, input, options) {
|
|
1457
1476
|
const plan = buildMrvCallNativeTxPlan(contractAddress, input, options);
|
|
1458
1477
|
assertMrvCallNativeSubmissionPlan(plan);
|
|
1478
|
+
return submitMrvEncryptedNativeTxGated(client, backend, plan, options);
|
|
1479
|
+
}
|
|
1480
|
+
async function submitMrvEncryptedNativeTxGated(client, backend, plan, options) {
|
|
1459
1481
|
const submission = await buildEncryptedSubmission({
|
|
1460
|
-
backend,
|
|
1461
1482
|
tx: plan.tx,
|
|
1462
1483
|
encryptionKey: options.encryptionKey ?? await fetchEncryptionKey(client),
|
|
1463
1484
|
class: options.class
|
|
@@ -1814,6 +1835,22 @@ function concatBytes3(...parts) {
|
|
|
1814
1835
|
function isIdentifier(value) {
|
|
1815
1836
|
return /^[a-z][a-z0-9_]*$/.test(value);
|
|
1816
1837
|
}
|
|
1838
|
+
var ML_DSA_65_PUBLIC_KEY_LEN = 1952;
|
|
1839
|
+
var ML_DSA_65_SIGNATURE_LEN = 3309;
|
|
1840
|
+
var STANDARD_ALGO_NUMBER_ML_DSA_65 = 1001;
|
|
1841
|
+
var ADDRESS_DERIVATION_DOMAIN = "MONO_ADDRESS_BLAKE3_20_V1";
|
|
1842
|
+
var ADDRESS_DERIVATION_DOMAIN_BYTES = new TextEncoder().encode(ADDRESS_DERIVATION_DOMAIN);
|
|
1843
|
+
function mlDsa65AddressFromPublicKey(publicKey) {
|
|
1844
|
+
return bytesToHex2(mlDsa65AddressBytes(publicKey));
|
|
1845
|
+
}
|
|
1846
|
+
function mlDsa65AddressBytes(publicKey) {
|
|
1847
|
+
const bytes = expectBytes(publicKey, ML_DSA_65_PUBLIC_KEY_LEN, "ML-DSA-65 public key");
|
|
1848
|
+
return blake3_js.blake3(concatBytes2(
|
|
1849
|
+
ADDRESS_DERIVATION_DOMAIN_BYTES,
|
|
1850
|
+
bigintToBeBytes(BigInt(STANDARD_ALGO_NUMBER_ML_DSA_65), 2, "ML-DSA-65 algo id"),
|
|
1851
|
+
bytes
|
|
1852
|
+
)).slice(0, 20);
|
|
1853
|
+
}
|
|
1817
1854
|
|
|
1818
1855
|
// src/registry.ts
|
|
1819
1856
|
var BLS_PUBLIC_KEY_BYTE_LENGTH = 48;
|
|
@@ -2430,6 +2467,192 @@ function encodeBlockSelector(b) {
|
|
|
2430
2467
|
if (typeof b === "bigint") return `0x${b.toString(16)}`;
|
|
2431
2468
|
return b;
|
|
2432
2469
|
}
|
|
2470
|
+
var NameRegistryError = class extends Error {
|
|
2471
|
+
constructor(message) {
|
|
2472
|
+
super(message);
|
|
2473
|
+
this.name = "NameRegistryError";
|
|
2474
|
+
}
|
|
2475
|
+
};
|
|
2476
|
+
var NAME_REGISTRY_SELECTORS = {
|
|
2477
|
+
register: selectorHex2("register(string,address)"),
|
|
2478
|
+
proposeTransfer: selectorHex2("proposeTransfer(string,address)"),
|
|
2479
|
+
acceptTransfer: selectorHex2("acceptTransfer(string)")
|
|
2480
|
+
};
|
|
2481
|
+
var NAME_BASE_MULTIPLIER = {
|
|
2482
|
+
human: 5,
|
|
2483
|
+
agent: 2,
|
|
2484
|
+
cluster: 20,
|
|
2485
|
+
contract: 10
|
|
2486
|
+
};
|
|
2487
|
+
var NAME_FALLBACK_FEE_UNIT_LYTHOSHI = 1000000000000n;
|
|
2488
|
+
var NAME_MAX_LEN = 80;
|
|
2489
|
+
var NAME_LABEL_MIN_LEN = 1;
|
|
2490
|
+
var NAME_LABEL_MAX_LEN = 63;
|
|
2491
|
+
function nameRegistryAddressHex() {
|
|
2492
|
+
return PRECOMPILE_ADDRESSES.NAME_REGISTRY.toLowerCase();
|
|
2493
|
+
}
|
|
2494
|
+
function nameLengthModifierX10(labelLen) {
|
|
2495
|
+
if (labelLen === 1) return 1e3;
|
|
2496
|
+
if (labelLen === 2) return 500;
|
|
2497
|
+
if (labelLen === 3) return 100;
|
|
2498
|
+
if (labelLen === 4) return 50;
|
|
2499
|
+
if (labelLen === 5) return 30;
|
|
2500
|
+
if (labelLen >= 6 && labelLen <= 12) return 10;
|
|
2501
|
+
if (labelLen >= 13 && labelLen <= 20) return 15;
|
|
2502
|
+
if (labelLen >= 21 && labelLen <= 32) return 30;
|
|
2503
|
+
if (labelLen >= 33 && labelLen <= 50) return 100;
|
|
2504
|
+
if (labelLen >= 51 && labelLen <= 63) return 500;
|
|
2505
|
+
return null;
|
|
2506
|
+
}
|
|
2507
|
+
function parseNameCategory(name) {
|
|
2508
|
+
if (name.length === 0) throw new NameRegistryError("name is empty");
|
|
2509
|
+
if (name.length > NAME_MAX_LEN) throw new NameRegistryError(`name exceeds ${NAME_MAX_LEN} chars`);
|
|
2510
|
+
const parts = name.split(".");
|
|
2511
|
+
if (parts.some((p) => p.length === 0)) {
|
|
2512
|
+
throw new NameRegistryError("name has an empty label");
|
|
2513
|
+
}
|
|
2514
|
+
for (const label of parts) validateLabel(label);
|
|
2515
|
+
if (parts[parts.length - 1] !== "mono") {
|
|
2516
|
+
throw new NameRegistryError("name must end with .mono");
|
|
2517
|
+
}
|
|
2518
|
+
const primaryLabelLen = parts[0].length;
|
|
2519
|
+
switch (parts.length) {
|
|
2520
|
+
case 2:
|
|
2521
|
+
if (STRUCTURAL_RESERVES.has(parts[0])) {
|
|
2522
|
+
throw new NameRegistryError(`"${parts[0]}.mono" is a structural reserve`);
|
|
2523
|
+
}
|
|
2524
|
+
return { category: "human", primaryLabelLen };
|
|
2525
|
+
case 3: {
|
|
2526
|
+
const anchor = parts[1];
|
|
2527
|
+
if (anchor === "cluster") return { category: "cluster", primaryLabelLen };
|
|
2528
|
+
if (anchor === "contract") return { category: "contract", primaryLabelLen };
|
|
2529
|
+
if (anchor === "system") return { category: "system", primaryLabelLen };
|
|
2530
|
+
throw new NameRegistryError(`unknown name category anchor ".${anchor}.mono"`);
|
|
2531
|
+
}
|
|
2532
|
+
case 4:
|
|
2533
|
+
if (parts[1] !== "agent") {
|
|
2534
|
+
throw new NameRegistryError("unknown 4-label name form (expected <x>.agent.<human>.mono)");
|
|
2535
|
+
}
|
|
2536
|
+
return { category: "agent", primaryLabelLen };
|
|
2537
|
+
default:
|
|
2538
|
+
throw new NameRegistryError("unrecognised name structure");
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
function nameRegistrationCost(category, primaryLabelLen, feeUnitLythoshi) {
|
|
2542
|
+
if (category === "system") {
|
|
2543
|
+
throw new NameRegistryError("system names are not registerable via this path");
|
|
2544
|
+
}
|
|
2545
|
+
const base = BigInt(NAME_BASE_MULTIPLIER[category]);
|
|
2546
|
+
const modX10 = nameLengthModifierX10(primaryLabelLen);
|
|
2547
|
+
if (modX10 === null) {
|
|
2548
|
+
throw new NameRegistryError("primary label length is outside the priceable 1..=63 range");
|
|
2549
|
+
}
|
|
2550
|
+
return base * BigInt(modX10) * feeUnitLythoshi / 10n;
|
|
2551
|
+
}
|
|
2552
|
+
function encodeNameRegisterCall(name, owner) {
|
|
2553
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.register, name, owner);
|
|
2554
|
+
}
|
|
2555
|
+
function encodeNameProposeTransferCall(name, recipient) {
|
|
2556
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.proposeTransfer, name, recipient);
|
|
2557
|
+
}
|
|
2558
|
+
function encodeNameAcceptTransferCall(name) {
|
|
2559
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2560
|
+
return bytesToHex4(
|
|
2561
|
+
concatBytes4(
|
|
2562
|
+
hexToBytes4(NAME_REGISTRY_SELECTORS.acceptTransfer),
|
|
2563
|
+
// Single head word → the string offset is 0x20 (one word precedes the tail).
|
|
2564
|
+
uint256Word(0x20n),
|
|
2565
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2566
|
+
padTo32(nameBytes)
|
|
2567
|
+
)
|
|
2568
|
+
);
|
|
2569
|
+
}
|
|
2570
|
+
var STRUCTURAL_RESERVES = /* @__PURE__ */ new Set(["agent", "cluster", "contract", "system"]);
|
|
2571
|
+
function encodeStringAddressCall(selector, name, address) {
|
|
2572
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2573
|
+
return bytesToHex4(
|
|
2574
|
+
concatBytes4(
|
|
2575
|
+
hexToBytes4(selector),
|
|
2576
|
+
// Two head words (string offset, address) → string tail starts at 0x40.
|
|
2577
|
+
uint256Word(0x40n),
|
|
2578
|
+
addressWord(address),
|
|
2579
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2580
|
+
padTo32(nameBytes)
|
|
2581
|
+
)
|
|
2582
|
+
);
|
|
2583
|
+
}
|
|
2584
|
+
function validateLabel(label) {
|
|
2585
|
+
if (label.length < NAME_LABEL_MIN_LEN || label.length > NAME_LABEL_MAX_LEN) {
|
|
2586
|
+
throw new NameRegistryError(`label "${label}" must be ${NAME_LABEL_MIN_LEN}..${NAME_LABEL_MAX_LEN} chars`);
|
|
2587
|
+
}
|
|
2588
|
+
if (label.startsWith("-") || label.endsWith("-")) {
|
|
2589
|
+
throw new NameRegistryError(`label "${label}" may not start or end with a hyphen`);
|
|
2590
|
+
}
|
|
2591
|
+
if (label.includes("--")) {
|
|
2592
|
+
throw new NameRegistryError(`label "${label}" may not contain a double hyphen`);
|
|
2593
|
+
}
|
|
2594
|
+
if (!/^[a-z0-9-]+$/.test(label)) {
|
|
2595
|
+
throw new NameRegistryError(`label "${label}" has an invalid char (allowed: a-z 0-9 -)`);
|
|
2596
|
+
}
|
|
2597
|
+
}
|
|
2598
|
+
function selectorHex2(signature) {
|
|
2599
|
+
const sel = sha3_js.keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
2600
|
+
return `0x${[...sel].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2601
|
+
}
|
|
2602
|
+
function addressWord(value) {
|
|
2603
|
+
const out = new Uint8Array(32);
|
|
2604
|
+
if (value == null) return out;
|
|
2605
|
+
const bytes = toBytes2(value);
|
|
2606
|
+
if (bytes.length !== 20) {
|
|
2607
|
+
throw new NameRegistryError(`address must be 20 bytes, got ${bytes.length}`);
|
|
2608
|
+
}
|
|
2609
|
+
out.set(bytes, 12);
|
|
2610
|
+
return out;
|
|
2611
|
+
}
|
|
2612
|
+
function uint256Word(value) {
|
|
2613
|
+
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
2614
|
+
throw new NameRegistryError("uint256 word out of range");
|
|
2615
|
+
}
|
|
2616
|
+
const out = new Uint8Array(32);
|
|
2617
|
+
let rest = value;
|
|
2618
|
+
for (let i = 31; i >= 0 && rest > 0n; i--) {
|
|
2619
|
+
out[i] = Number(rest & 0xffn);
|
|
2620
|
+
rest >>= 8n;
|
|
2621
|
+
}
|
|
2622
|
+
return out;
|
|
2623
|
+
}
|
|
2624
|
+
function padTo32(bytes) {
|
|
2625
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
2626
|
+
if (padded === bytes.length) return bytes;
|
|
2627
|
+
const out = new Uint8Array(padded);
|
|
2628
|
+
out.set(bytes);
|
|
2629
|
+
return out;
|
|
2630
|
+
}
|
|
2631
|
+
function toBytes2(value) {
|
|
2632
|
+
if (typeof value === "string") return hexToBytes4(value);
|
|
2633
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
2634
|
+
}
|
|
2635
|
+
function hexToBytes4(hex) {
|
|
2636
|
+
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
2637
|
+
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
2638
|
+
throw new NameRegistryError("invalid hex bytes");
|
|
2639
|
+
}
|
|
2640
|
+
const out = new Uint8Array(body.length / 2);
|
|
2641
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(body.slice(i * 2, i * 2 + 2), 16);
|
|
2642
|
+
return out;
|
|
2643
|
+
}
|
|
2644
|
+
function bytesToHex4(bytes) {
|
|
2645
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2646
|
+
}
|
|
2647
|
+
function concatBytes4(...parts) {
|
|
2648
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
2649
|
+
let offset = 0;
|
|
2650
|
+
for (const part of parts) {
|
|
2651
|
+
out.set(part, offset);
|
|
2652
|
+
offset += part.length;
|
|
2653
|
+
}
|
|
2654
|
+
return out;
|
|
2655
|
+
}
|
|
2433
2656
|
|
|
2434
2657
|
// src/client.ts
|
|
2435
2658
|
var MAX_NATIVE_RECEIPT_EVENTS = 1e3;
|
|
@@ -2605,13 +2828,31 @@ var RpcClient = class _RpcClient {
|
|
|
2605
2828
|
async ethGasPrice() {
|
|
2606
2829
|
return parseQuantityBig(await this.call("eth_gasPrice", []));
|
|
2607
2830
|
}
|
|
2608
|
-
/**
|
|
2831
|
+
/**
|
|
2832
|
+
* `eth_feeHistory` — base-fee + gas-used history.
|
|
2833
|
+
*
|
|
2834
|
+
* The chain's eth-compat surface serializes the base-fee window under the
|
|
2835
|
+
* camelCase key `baseFeePerGas`. Internally the chain header field is
|
|
2836
|
+
* `base_fee_per_gas`; this method asserts the on-the-wire response actually
|
|
2837
|
+
* carries the expected `baseFeePerGas` array and fails LOUD if the field is
|
|
2838
|
+
* missing or has drifted to snake_case `base_fee_per_gas`. Without this
|
|
2839
|
+
* guard a future rename would silently collapse the base fee to an empty
|
|
2840
|
+
* array and over-/under-quote fees (e.g. name registration would fall back
|
|
2841
|
+
* to the placeholder fee unit and revert `IncorrectFee` on submit).
|
|
2842
|
+
*/
|
|
2609
2843
|
async ethFeeHistory(blockCount, newestBlock = "latest", rewardPercentiles = []) {
|
|
2610
|
-
|
|
2844
|
+
const result = await this.call("eth_feeHistory", [
|
|
2611
2845
|
`0x${blockCount.toString(16)}`,
|
|
2612
2846
|
encodeBlockSelector(newestBlock),
|
|
2613
2847
|
rewardPercentiles
|
|
2614
2848
|
]);
|
|
2849
|
+
if (result !== null && typeof result === "object" && !Array.isArray(result.baseFeePerGas)) {
|
|
2850
|
+
const drifted = "base_fee_per_gas" in result ? " (found snake_case 'base_fee_per_gas')" : "";
|
|
2851
|
+
throw SdkError.malformed(
|
|
2852
|
+
`eth_feeHistory response is missing the camelCase 'baseFeePerGas' array${drifted}; the base-fee field contract changed`
|
|
2853
|
+
);
|
|
2854
|
+
}
|
|
2855
|
+
return result;
|
|
2615
2856
|
}
|
|
2616
2857
|
/** `eth_syncing` — `null` when caught up. */
|
|
2617
2858
|
async ethSyncing() {
|
|
@@ -3267,7 +3508,234 @@ var RpcClient = class _RpcClient {
|
|
|
3267
3508
|
async meshSubmitTx(signedTx) {
|
|
3268
3509
|
return this.call("mesh_submitTx", [signedTx]);
|
|
3269
3510
|
}
|
|
3511
|
+
// ---- lyth_* additions (R15 / wallet + monoscan surfaces) -----------
|
|
3512
|
+
/**
|
|
3513
|
+
* `lyth_clusterApr` — observed APR for a cluster over a rolling window.
|
|
3514
|
+
* `windowBlocks` defaults to the chain's 1200-block (~1h) window and is
|
|
3515
|
+
* server-clamped to `[10, 86_400]`.
|
|
3516
|
+
*/
|
|
3517
|
+
async lythClusterApr(clusterId, windowBlocks) {
|
|
3518
|
+
const params = windowBlocks === void 0 ? [clusterId] : [clusterId, windowBlocks];
|
|
3519
|
+
return normalizeClusterApr(await this.call("lyth_clusterApr", params));
|
|
3520
|
+
}
|
|
3521
|
+
/** `lyth_resolveName` — forward name → address resolution (0x110E). */
|
|
3522
|
+
async lythResolveName(name, block = "latest") {
|
|
3523
|
+
return this.call("lyth_resolveName", [name, encodeBlockSelector(block)]);
|
|
3524
|
+
}
|
|
3525
|
+
/** `lyth_nameOf` — reverse address → name resolution. */
|
|
3526
|
+
async lythNameOf(address, block = "latest") {
|
|
3527
|
+
return this.call("lyth_nameOf", [sdkTypedAddress(address, "user", "address"), encodeBlockSelector(block)]);
|
|
3528
|
+
}
|
|
3529
|
+
/** `lyth_getClusterName` — reverse cluster id → canonical name. */
|
|
3530
|
+
async lythGetClusterName(clusterId, block = "latest") {
|
|
3531
|
+
return this.call("lyth_getClusterName", [clusterId, encodeBlockSelector(block)]);
|
|
3532
|
+
}
|
|
3533
|
+
/**
|
|
3534
|
+
* Convenience over {@link lythResolveName}: `true` when a well-formed
|
|
3535
|
+
* name is unregistered. A malformed name throws `RpcError`
|
|
3536
|
+
* (`InvalidParams`) rather than returning `true`, so the UI should treat
|
|
3537
|
+
* a thrown validation error distinctly from "taken".
|
|
3538
|
+
*/
|
|
3539
|
+
async lythIsNameAvailable(name, block = "latest") {
|
|
3540
|
+
const resolved = await this.lythResolveName(name, block);
|
|
3541
|
+
return resolved.address === null;
|
|
3542
|
+
}
|
|
3543
|
+
/**
|
|
3544
|
+
* Live name-registration quote: parses the name's category + primary
|
|
3545
|
+
* label length, reads the chain's base fee unit via `eth_feeHistory`
|
|
3546
|
+
* (the bare `baseFeePerGas` — NOT `eth_gasPrice`, which adds the tip and
|
|
3547
|
+
* would over-quote), and applies the U-curve. The resulting
|
|
3548
|
+
* `costLythoshi` is what the `register` tx `value` must equal exactly
|
|
3549
|
+
* (else the precompile reverts `IncorrectFee`).
|
|
3550
|
+
*/
|
|
3551
|
+
async quoteNameRegistration(name, block = "latest") {
|
|
3552
|
+
const parsed = parseNameCategory(name);
|
|
3553
|
+
const history = await this.ethFeeHistory(1, block, []);
|
|
3554
|
+
const baseFees = history.baseFeePerGas ?? [];
|
|
3555
|
+
const lastHex = baseFees.length > 0 ? baseFees[baseFees.length - 1] : "0x0";
|
|
3556
|
+
const baseFee = parseQuantityBig(lastHex);
|
|
3557
|
+
const feeUnitLythoshi = baseFee > 0n ? baseFee : NAME_FALLBACK_FEE_UNIT_LYTHOSHI;
|
|
3558
|
+
return {
|
|
3559
|
+
name,
|
|
3560
|
+
category: parsed.category,
|
|
3561
|
+
primaryLabelLen: parsed.primaryLabelLen,
|
|
3562
|
+
feeUnitLythoshi,
|
|
3563
|
+
costLythoshi: nameRegistrationCost(parsed.category, parsed.primaryLabelLen, feeUnitLythoshi)
|
|
3564
|
+
};
|
|
3565
|
+
}
|
|
3566
|
+
/** `lyth_circulatingSupply` — native LYTH circulating / initial / burned (decimal lythoshi strings). */
|
|
3567
|
+
async lythCirculatingSupply() {
|
|
3568
|
+
return this.call("lyth_circulatingSupply", []);
|
|
3569
|
+
}
|
|
3570
|
+
/** `lyth_totalBurned` — cumulative burned native LYTH (decimal lythoshi string). */
|
|
3571
|
+
async lythTotalBurned() {
|
|
3572
|
+
return this.call("lyth_totalBurned", []);
|
|
3573
|
+
}
|
|
3574
|
+
/** `lyth_swapIntentStatus` — bridge swap-intent / DKG-reshare lifecycle for one intent id. */
|
|
3575
|
+
async lythSwapIntentStatus(intentId) {
|
|
3576
|
+
let id;
|
|
3577
|
+
if (typeof intentId === "number") {
|
|
3578
|
+
id = intentId;
|
|
3579
|
+
} else if (typeof intentId === "bigint") {
|
|
3580
|
+
id = `0x${intentId.toString(16)}`;
|
|
3581
|
+
} else if (intentId.startsWith("0x") || intentId.startsWith("0X")) {
|
|
3582
|
+
id = intentId;
|
|
3583
|
+
} else {
|
|
3584
|
+
id = `0x${BigInt(intentId).toString(16)}`;
|
|
3585
|
+
}
|
|
3586
|
+
return this.call("lyth_swapIntentStatus", [id]);
|
|
3587
|
+
}
|
|
3588
|
+
/**
|
|
3589
|
+
* Per-tx confirmation depth, derived from `lyth_txStatus` (which returns
|
|
3590
|
+
* both the tx's `blockNumber` and the node `latestHeight`).
|
|
3591
|
+
*/
|
|
3592
|
+
async lythTxConfirmations(txHash) {
|
|
3593
|
+
const status = await this.lythTxStatus(txHash);
|
|
3594
|
+
if (status.status === "found") {
|
|
3595
|
+
return {
|
|
3596
|
+
status: "found",
|
|
3597
|
+
confirmations: status.latestHeight - status.blockNumber + 1,
|
|
3598
|
+
blockNumber: status.blockNumber,
|
|
3599
|
+
latestHeight: status.latestHeight
|
|
3600
|
+
};
|
|
3601
|
+
}
|
|
3602
|
+
return {
|
|
3603
|
+
status: "not_found",
|
|
3604
|
+
confirmations: null,
|
|
3605
|
+
blockNumber: null,
|
|
3606
|
+
latestHeight: status.latestHeight
|
|
3607
|
+
};
|
|
3608
|
+
}
|
|
3609
|
+
/**
|
|
3610
|
+
* Resolve a user-pasted MRC token id to its metadata (name/symbol/
|
|
3611
|
+
* decimals), for an "add custom token" flow. Returns `null` for an
|
|
3612
|
+
* unknown/untracked id. Performs light client-side format validation
|
|
3613
|
+
* (32-byte hex) for fast UX feedback; the chain re-validates regardless.
|
|
3614
|
+
*/
|
|
3615
|
+
async lythResolveTokenMetadata(rawTokenId) {
|
|
3616
|
+
const body = rawTokenId.startsWith("0x") || rawTokenId.startsWith("0X") ? rawTokenId.slice(2) : rawTokenId;
|
|
3617
|
+
if (!/^[0-9a-fA-F]{64}$/.test(body)) {
|
|
3618
|
+
throw SdkError.malformed("token id must be 32 bytes (64 hex chars)");
|
|
3619
|
+
}
|
|
3620
|
+
return (await this.lythMrcMetadata(rawTokenId)).metadata;
|
|
3621
|
+
}
|
|
3622
|
+
/**
|
|
3623
|
+
* `lyth_getTokenBalances` joined with per-token MRC metadata. Balances
|
|
3624
|
+
* are PUBLIC-only by construction (private-denomination balances are
|
|
3625
|
+
* excluded by the chain). Raw `balance` strings are preserved (apply
|
|
3626
|
+
* `metadata.decimals` client-side for display).
|
|
3627
|
+
*/
|
|
3628
|
+
async lythGetTokenBalancesWithMetadata(address) {
|
|
3629
|
+
const rows = await this.lythGetTokenBalances(address);
|
|
3630
|
+
const keyFor = (row) => {
|
|
3631
|
+
const assetId = row.mrc?.assetId ?? row.tokenId;
|
|
3632
|
+
const tokenId = row.mrc?.tokenId ?? null;
|
|
3633
|
+
return { assetId, tokenId, key: `${assetId}:${tokenId ?? ""}` };
|
|
3634
|
+
};
|
|
3635
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
3636
|
+
for (const row of rows) {
|
|
3637
|
+
const k = keyFor(row);
|
|
3638
|
+
if (!distinct.has(k.key)) distinct.set(k.key, { assetId: k.assetId, tokenId: k.tokenId });
|
|
3639
|
+
}
|
|
3640
|
+
const metaByKey = /* @__PURE__ */ new Map();
|
|
3641
|
+
await Promise.all(
|
|
3642
|
+
[...distinct.entries()].map(async ([key, { assetId, tokenId }]) => {
|
|
3643
|
+
const resp = await this.lythMrcMetadata(assetId, tokenId);
|
|
3644
|
+
metaByKey.set(key, resp.metadata);
|
|
3645
|
+
})
|
|
3646
|
+
);
|
|
3647
|
+
return rows.map((row) => ({ ...row, metadata: metaByKey.get(keyFor(row).key) ?? null }));
|
|
3648
|
+
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Resolve a CLOB market's base/quote asset metadata (symbol/name/
|
|
3651
|
+
* decimals) by joining `lyth_clobMarket` to `lyth_mrcMetadata`. Either
|
|
3652
|
+
* side may be `null` when the indexer has no MRC row (e.g. native LYTH).
|
|
3653
|
+
*/
|
|
3654
|
+
async resolveClobMarketAssets(marketId) {
|
|
3655
|
+
const response = await this.lythClobMarket(marketId);
|
|
3656
|
+
const market = response.market;
|
|
3657
|
+
if (!market) return { base: null, quote: null };
|
|
3658
|
+
const [base, quote] = await Promise.all([
|
|
3659
|
+
this.lythMrcMetadata(market.baseToken).then((m) => m.metadata),
|
|
3660
|
+
this.lythMrcMetadata(market.quoteToken).then((m) => m.metadata)
|
|
3661
|
+
]);
|
|
3662
|
+
return { base, quote };
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* `lyth_getAddressActivity` enriched with each row's block timestamp,
|
|
3666
|
+
* canonical tx hash (resolved from `(blockHeight, txIndex)`), and
|
|
3667
|
+
* resolved cluster name. Issues one block read per distinct height and
|
|
3668
|
+
* one name read per distinct cluster.
|
|
3669
|
+
*/
|
|
3670
|
+
async enrichAddressActivity(address, limit = 50, cursor) {
|
|
3671
|
+
const entries = await this.lythGetAddressActivity(address, limit, cursor);
|
|
3672
|
+
const heights = [...new Set(entries.map((entry) => BigInt(entry.blockHeight)))];
|
|
3673
|
+
const blockByHeight = /* @__PURE__ */ new Map();
|
|
3674
|
+
await Promise.all(
|
|
3675
|
+
heights.map(async (height) => {
|
|
3676
|
+
blockByHeight.set(height, await this.blockTimeAndTxHashes(height));
|
|
3677
|
+
})
|
|
3678
|
+
);
|
|
3679
|
+
const clusters = [
|
|
3680
|
+
...new Set(entries.map((entry) => entry.cluster).filter((c) => c != null))
|
|
3681
|
+
];
|
|
3682
|
+
const nameByCluster = /* @__PURE__ */ new Map();
|
|
3683
|
+
await Promise.all(
|
|
3684
|
+
clusters.map(async (clusterId) => {
|
|
3685
|
+
nameByCluster.set(clusterId, (await this.lythGetClusterName(clusterId)).name);
|
|
3686
|
+
})
|
|
3687
|
+
);
|
|
3688
|
+
return entries.map((entry) => {
|
|
3689
|
+
const block = blockByHeight.get(BigInt(entry.blockHeight));
|
|
3690
|
+
const txHash = block && entry.txIndex >= 0 && entry.txIndex < block.txHashes.length ? block.txHashes[entry.txIndex] : null;
|
|
3691
|
+
return {
|
|
3692
|
+
...entry,
|
|
3693
|
+
blockTimestampSeconds: block?.timestampSeconds ?? null,
|
|
3694
|
+
txHash,
|
|
3695
|
+
clusterName: entry.cluster != null ? nameByCluster.get(entry.cluster) ?? null : null
|
|
3696
|
+
};
|
|
3697
|
+
});
|
|
3698
|
+
}
|
|
3699
|
+
/**
|
|
3700
|
+
* Read a block's header timestamp (UNIX seconds) and ordered tx-hash
|
|
3701
|
+
* array via the raw `eth_getBlockByNumber` (hash-only mode). The typed
|
|
3702
|
+
* `ethGetBlockByNumber` wrapper drops the `transactions` array, so this
|
|
3703
|
+
* uses the raw call.
|
|
3704
|
+
*/
|
|
3705
|
+
async blockTimeAndTxHashes(height) {
|
|
3706
|
+
const hexHeight = `0x${height.toString(16)}`;
|
|
3707
|
+
const raw = await this.call("eth_getBlockByNumber", [
|
|
3708
|
+
hexHeight,
|
|
3709
|
+
false
|
|
3710
|
+
]);
|
|
3711
|
+
if (!raw || typeof raw !== "object") return { timestampSeconds: null, txHashes: [] };
|
|
3712
|
+
const ts = raw["timestamp"];
|
|
3713
|
+
const timestampSeconds = ts === null || ts === void 0 ? null : parseRpcBigint(ts, "block timestamp");
|
|
3714
|
+
const txs = raw["transactions"];
|
|
3715
|
+
const txHashes = Array.isArray(txs) ? txs.filter((t) => typeof t === "string") : [];
|
|
3716
|
+
return { timestampSeconds, txHashes };
|
|
3717
|
+
}
|
|
3270
3718
|
};
|
|
3719
|
+
function clusterApyPercent(apr) {
|
|
3720
|
+
return Number(apr.aprBps) / 100;
|
|
3721
|
+
}
|
|
3722
|
+
function computeQuoteLiquidity(book) {
|
|
3723
|
+
const sumQuote = (levels) => levels.reduce((acc, level) => acc + BigInt(level.price) * BigInt(level.size), 0n);
|
|
3724
|
+
const bidQuote = sumQuote(book.bids);
|
|
3725
|
+
const askQuote = sumQuote(book.asks);
|
|
3726
|
+
return {
|
|
3727
|
+
bidQuote: bidQuote.toString(10),
|
|
3728
|
+
askQuote: askQuote.toString(10),
|
|
3729
|
+
totalQuote: (bidQuote + askQuote).toString(10)
|
|
3730
|
+
};
|
|
3731
|
+
}
|
|
3732
|
+
function rankMarketsByVolume(markets) {
|
|
3733
|
+
return [...markets].sort((a, b) => {
|
|
3734
|
+
const av = BigInt(a.totalVolumeBase);
|
|
3735
|
+
const bv = BigInt(b.totalVolumeBase);
|
|
3736
|
+
return av < bv ? 1 : av > bv ? -1 : 0;
|
|
3737
|
+
}).map((market, index) => ({ ...market, volumeRank: index + 1 }));
|
|
3738
|
+
}
|
|
3271
3739
|
function parseQuantityBig(hex) {
|
|
3272
3740
|
if (!hex) return 0n;
|
|
3273
3741
|
const rest = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
@@ -3922,6 +4390,29 @@ function normalizeRoundInfo(value) {
|
|
|
3922
4390
|
height: parseRpcBigint(row["height"], "round height")
|
|
3923
4391
|
};
|
|
3924
4392
|
}
|
|
4393
|
+
function normalizeClusterApr(value) {
|
|
4394
|
+
if (!value || typeof value !== "object") {
|
|
4395
|
+
throw SdkError.malformed("cluster apr must be an object");
|
|
4396
|
+
}
|
|
4397
|
+
const row = value;
|
|
4398
|
+
const blocks = row["blocks"] ?? {};
|
|
4399
|
+
return {
|
|
4400
|
+
clusterId: parseRpcNumber(row["clusterId"], "clusterId"),
|
|
4401
|
+
blocks: {
|
|
4402
|
+
from: parseRpcBigint(blocks["from"], "blocks.from"),
|
|
4403
|
+
to: parseRpcBigint(blocks["to"], "blocks.to"),
|
|
4404
|
+
window: parseRpcBigint(blocks["window"], "blocks.window")
|
|
4405
|
+
},
|
|
4406
|
+
rewardIndexFromHex: parseStringField(row["rewardIndexFromHex"], "rewardIndexFromHex"),
|
|
4407
|
+
rewardIndexToHex: parseStringField(row["rewardIndexToHex"], "rewardIndexToHex"),
|
|
4408
|
+
deltaIndexHex: parseStringField(row["deltaIndexHex"], "deltaIndexHex"),
|
|
4409
|
+
rewardIndexScale: parseStringField(row["rewardIndexScale"], "rewardIndexScale"),
|
|
4410
|
+
totalBps: parseRpcNumber(row["totalBps"], "totalBps"),
|
|
4411
|
+
blocksPerYear: parseRpcBigint(row["blocksPerYear"], "blocksPerYear"),
|
|
4412
|
+
stakePerBpsLythoshi: parseRpcBigint(row["stakePerBpsLythoshi"], "stakePerBpsLythoshi"),
|
|
4413
|
+
aprBps: parseRpcBigint(row["aprBps"], "aprBps")
|
|
4414
|
+
};
|
|
4415
|
+
}
|
|
3925
4416
|
function normalizeExecutionUnitPriceResponse(value) {
|
|
3926
4417
|
if (!value || typeof value !== "object") {
|
|
3927
4418
|
throw SdkError.malformed("execution unit price response must be an object");
|
|
@@ -4567,8 +5058,6 @@ function encodePathBlock(block) {
|
|
|
4567
5058
|
function encodePathSegment(value) {
|
|
4568
5059
|
return encodeURIComponent(typeof value === "bigint" ? value.toString() : String(value));
|
|
4569
5060
|
}
|
|
4570
|
-
|
|
4571
|
-
// src/bridge.ts
|
|
4572
5061
|
var BRIDGE_SELECTORS = {
|
|
4573
5062
|
lockBridgeConfig: "0x8956feb3",
|
|
4574
5063
|
setBridgeResumeCooldown: "0x1a3a0672",
|
|
@@ -4602,42 +5091,105 @@ function bridgeAddressHex() {
|
|
|
4602
5091
|
return PRECOMPILE_ADDRESSES.BRIDGE.toLowerCase();
|
|
4603
5092
|
}
|
|
4604
5093
|
function encodeLockBridgeConfigCalldata(bridgeId) {
|
|
4605
|
-
return
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
expectLength3(
|
|
5094
|
+
return bytesToHex5(
|
|
5095
|
+
concatBytes5(
|
|
5096
|
+
hexToBytes5(BRIDGE_SELECTORS.lockBridgeConfig),
|
|
5097
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId")
|
|
4609
5098
|
)
|
|
4610
5099
|
);
|
|
4611
5100
|
}
|
|
4612
5101
|
function encodeSetBridgeResumeCooldownCalldata(bridgeId, cooldownBlocks) {
|
|
4613
|
-
return
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
expectLength3(
|
|
4617
|
-
|
|
5102
|
+
return bytesToHex5(
|
|
5103
|
+
concatBytes5(
|
|
5104
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeResumeCooldown),
|
|
5105
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5106
|
+
uint64Word2(cooldownBlocks, "cooldownBlocks")
|
|
4618
5107
|
)
|
|
4619
5108
|
);
|
|
4620
5109
|
}
|
|
4621
5110
|
function encodeSetBridgeRouteFinalityCalldata(bridgeId, finalityBlocks) {
|
|
4622
|
-
return
|
|
4623
|
-
|
|
4624
|
-
|
|
4625
|
-
expectLength3(
|
|
4626
|
-
|
|
5111
|
+
return bytesToHex5(
|
|
5112
|
+
concatBytes5(
|
|
5113
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeRouteFinality),
|
|
5114
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5115
|
+
uint64Word2(finalityBlocks, "finalityBlocks")
|
|
5116
|
+
)
|
|
5117
|
+
);
|
|
5118
|
+
}
|
|
5119
|
+
function bridgeSelector(signature) {
|
|
5120
|
+
return sha3_js.keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
5121
|
+
}
|
|
5122
|
+
function addressWord2(value, name) {
|
|
5123
|
+
const addr = expectLength3(toBytes3(value), 20, name);
|
|
5124
|
+
const out = new Uint8Array(32);
|
|
5125
|
+
out.set(addr, 12);
|
|
5126
|
+
return out;
|
|
5127
|
+
}
|
|
5128
|
+
function padTo322(bytes) {
|
|
5129
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
5130
|
+
if (padded === bytes.length) return bytes;
|
|
5131
|
+
const out = new Uint8Array(padded);
|
|
5132
|
+
out.set(bytes);
|
|
5133
|
+
return out;
|
|
5134
|
+
}
|
|
5135
|
+
function encodeBridgeClaimCalldata(bridgeId, depositId, recipient) {
|
|
5136
|
+
return bytesToHex5(
|
|
5137
|
+
concatBytes5(
|
|
5138
|
+
bridgeSelector("claim(bytes32,bytes32,address)"),
|
|
5139
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5140
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5141
|
+
addressWord2(recipient, "recipient")
|
|
5142
|
+
)
|
|
5143
|
+
);
|
|
5144
|
+
}
|
|
5145
|
+
function encodeBridgeChallengeCalldata(bridgeId, depositId, fraudProof) {
|
|
5146
|
+
const proof = toBytes3(fraudProof);
|
|
5147
|
+
return bytesToHex5(
|
|
5148
|
+
concatBytes5(
|
|
5149
|
+
bridgeSelector("challenge(bytes32,bytes32,bytes)"),
|
|
5150
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5151
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5152
|
+
uint64Word2(3n * 32n, "fraudProofOffset"),
|
|
5153
|
+
uint64Word2(BigInt(proof.length), "fraudProofLength"),
|
|
5154
|
+
padTo322(proof)
|
|
5155
|
+
)
|
|
5156
|
+
);
|
|
5157
|
+
}
|
|
5158
|
+
function encodeSubmitBridgeProofCalldata(bridgeId, depositId, lockReceipt, zkProof, publicInputs) {
|
|
5159
|
+
const receipt = toBytes3(lockReceipt);
|
|
5160
|
+
const proof = toBytes3(zkProof);
|
|
5161
|
+
const inputs = toBytes3(publicInputs);
|
|
5162
|
+
const off0 = 5n * 32n;
|
|
5163
|
+
const off1 = off0 + 32n + BigInt(Math.ceil(receipt.length / 32) * 32);
|
|
5164
|
+
const off2 = off1 + 32n + BigInt(Math.ceil(proof.length / 32) * 32);
|
|
5165
|
+
return bytesToHex5(
|
|
5166
|
+
concatBytes5(
|
|
5167
|
+
bridgeSelector("submitProof(bytes32,bytes32,bytes,bytes,bytes)"),
|
|
5168
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5169
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5170
|
+
uint64Word2(off0, "lockReceiptOffset"),
|
|
5171
|
+
uint64Word2(off1, "zkProofOffset"),
|
|
5172
|
+
uint64Word2(off2, "publicInputsOffset"),
|
|
5173
|
+
uint64Word2(BigInt(receipt.length), "lockReceiptLength"),
|
|
5174
|
+
padTo322(receipt),
|
|
5175
|
+
uint64Word2(BigInt(proof.length), "zkProofLength"),
|
|
5176
|
+
padTo322(proof),
|
|
5177
|
+
uint64Word2(BigInt(inputs.length), "publicInputsLength"),
|
|
5178
|
+
padTo322(inputs)
|
|
4627
5179
|
)
|
|
4628
5180
|
);
|
|
4629
5181
|
}
|
|
4630
5182
|
function isBridgeAdminLockedRevert(data) {
|
|
4631
|
-
return
|
|
5183
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeAdminLocked;
|
|
4632
5184
|
}
|
|
4633
5185
|
function isBridgeResumeCooldownActiveRevert(data) {
|
|
4634
|
-
return
|
|
5186
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeResumeCooldownActive;
|
|
4635
5187
|
}
|
|
4636
5188
|
function isBridgeCooldownZeroRevert(data) {
|
|
4637
|
-
return
|
|
5189
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeCooldownZero;
|
|
4638
5190
|
}
|
|
4639
5191
|
function isBridgeFinalityZeroRevert(data) {
|
|
4640
|
-
return
|
|
5192
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
|
|
4641
5193
|
}
|
|
4642
5194
|
function bridgeDrainRemaining(capPerWindow, drained) {
|
|
4643
5195
|
const cap = BigInt(capPerWindow);
|
|
@@ -5240,7 +5792,7 @@ function expectLength3(value, len, name) {
|
|
|
5240
5792
|
}
|
|
5241
5793
|
return value;
|
|
5242
5794
|
}
|
|
5243
|
-
function
|
|
5795
|
+
function uint64Word2(value, name) {
|
|
5244
5796
|
const n = toBigint(value, name);
|
|
5245
5797
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
5246
5798
|
throw new BridgePrecompileError(`${name} must fit uint64`);
|
|
@@ -5266,13 +5818,13 @@ function toBigint(value, name) {
|
|
|
5266
5818
|
}
|
|
5267
5819
|
return BigInt(value);
|
|
5268
5820
|
}
|
|
5269
|
-
function
|
|
5821
|
+
function toBytes3(value) {
|
|
5270
5822
|
if (typeof value === "string") {
|
|
5271
|
-
return
|
|
5823
|
+
return hexToBytes5(value);
|
|
5272
5824
|
}
|
|
5273
5825
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
5274
5826
|
}
|
|
5275
|
-
function
|
|
5827
|
+
function hexToBytes5(hex) {
|
|
5276
5828
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
5277
5829
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
5278
5830
|
throw new BridgePrecompileError("invalid hex bytes");
|
|
@@ -5283,10 +5835,10 @@ function hexToBytes4(hex) {
|
|
|
5283
5835
|
}
|
|
5284
5836
|
return out;
|
|
5285
5837
|
}
|
|
5286
|
-
function
|
|
5838
|
+
function bytesToHex5(bytes) {
|
|
5287
5839
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
5288
5840
|
}
|
|
5289
|
-
function
|
|
5841
|
+
function concatBytes5(...parts) {
|
|
5290
5842
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
5291
5843
|
let offset = 0;
|
|
5292
5844
|
for (const part of parts) {
|
|
@@ -5341,10 +5893,10 @@ function decodeNoEvmReceiptTranscript(proof) {
|
|
|
5341
5893
|
);
|
|
5342
5894
|
}
|
|
5343
5895
|
function computeNoEvmReceiptsRoot(receipts) {
|
|
5344
|
-
return
|
|
5896
|
+
return bytesToHex6(computeNoEvmReceiptsRootBytes(receipts));
|
|
5345
5897
|
}
|
|
5346
5898
|
function computeNoEvmTargetReceiptHash(receiptBytes) {
|
|
5347
|
-
return
|
|
5899
|
+
return bytesToHex6(sha3_js.keccak_256(receiptBytes));
|
|
5348
5900
|
}
|
|
5349
5901
|
function verifyNoEvmReceiptProof(proof) {
|
|
5350
5902
|
if (proof == null) return null;
|
|
@@ -5931,7 +6483,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5931
6483
|
if (!bytesEqual(expectedLeafHashBytes, actualLeafHashBytes)) {
|
|
5932
6484
|
throw new NoEvmReceiptProofError(
|
|
5933
6485
|
"compact_leaf_hash_mismatch",
|
|
5934
|
-
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${
|
|
6486
|
+
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
|
|
5935
6487
|
actualLeafHashBytes
|
|
5936
6488
|
)}`
|
|
5937
6489
|
);
|
|
@@ -5964,14 +6516,14 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5964
6516
|
if (!bytesEqual(actualRootBytes, compactRootBytes)) {
|
|
5965
6517
|
throw new NoEvmReceiptProofError(
|
|
5966
6518
|
"compact_path_mismatch",
|
|
5967
|
-
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${
|
|
6519
|
+
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
|
|
5968
6520
|
actualRootBytes
|
|
5969
6521
|
)}`
|
|
5970
6522
|
);
|
|
5971
6523
|
}
|
|
5972
6524
|
return {
|
|
5973
6525
|
receipts: [],
|
|
5974
|
-
receiptsRoot:
|
|
6526
|
+
receiptsRoot: bytesToHex6(actualRootBytes),
|
|
5975
6527
|
targetReceiptHash: actualTargetHash,
|
|
5976
6528
|
receiptCount: proof.receiptCount,
|
|
5977
6529
|
txIndex: proof.txIndex,
|
|
@@ -6181,7 +6733,7 @@ function parseArchiveProofSignature(signature, index, fieldPrefix = "archiveProo
|
|
|
6181
6733
|
`${field2}.payload must be non-empty`
|
|
6182
6734
|
);
|
|
6183
6735
|
}
|
|
6184
|
-
return { signerId:
|
|
6736
|
+
return { signerId: bytesToHex6(signerId), payload };
|
|
6185
6737
|
}
|
|
6186
6738
|
function normalizeSignerId(value) {
|
|
6187
6739
|
const bytes = decodeHexBytes(value, "signerId");
|
|
@@ -6191,7 +6743,7 @@ function normalizeSignerId(value) {
|
|
|
6191
6743
|
`signerId must be ${ARCHIVE_SIGNATURE_SIGNER_ID_BYTE_LENGTH} bytes, got ${bytes.length}`
|
|
6192
6744
|
);
|
|
6193
6745
|
}
|
|
6194
|
-
return
|
|
6746
|
+
return bytesToHex6(bytes);
|
|
6195
6747
|
}
|
|
6196
6748
|
function expectArchivePublicKey(value, field2) {
|
|
6197
6749
|
if (value.length !== ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
@@ -6672,7 +7224,7 @@ function bytesEqual(a, b) {
|
|
|
6672
7224
|
}
|
|
6673
7225
|
return diff === 0;
|
|
6674
7226
|
}
|
|
6675
|
-
function
|
|
7227
|
+
function bytesToHex6(bytes) {
|
|
6676
7228
|
let out = "0x";
|
|
6677
7229
|
for (let index = 0; index < bytes.length; index++) {
|
|
6678
7230
|
out += bytes[index].toString(16).padStart(2, "0");
|
|
@@ -6891,12 +7443,48 @@ var OracleEventError = class extends Error {
|
|
|
6891
7443
|
function oracleAddressHex() {
|
|
6892
7444
|
return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
|
|
6893
7445
|
}
|
|
7446
|
+
var FEED_ID_DOMAIN_TAG = "protocore-oracle/feed-id/v1";
|
|
7447
|
+
function deriveFeedId(name, decimals) {
|
|
7448
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
7449
|
+
throw new OracleEventError("feed decimals must be an integer in 0..=255");
|
|
7450
|
+
}
|
|
7451
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
7452
|
+
const buf = concatBytes6(
|
|
7453
|
+
new TextEncoder().encode(FEED_ID_DOMAIN_TAG),
|
|
7454
|
+
nameBytes,
|
|
7455
|
+
Uint8Array.of(decimals & 255)
|
|
7456
|
+
);
|
|
7457
|
+
return bytesToHex7(sha3_js.keccak_256(buf));
|
|
7458
|
+
}
|
|
7459
|
+
function formatOraclePrice(price) {
|
|
7460
|
+
if (price.median === null) return null;
|
|
7461
|
+
const value = BigInt(price.median);
|
|
7462
|
+
const decimals = price.decimals;
|
|
7463
|
+
if (decimals <= 0) return value.toString(10);
|
|
7464
|
+
const base = 10n ** BigInt(decimals);
|
|
7465
|
+
const whole = value / base;
|
|
7466
|
+
const frac = (value % base).toString(10).padStart(decimals, "0").replace(/0+$/, "");
|
|
7467
|
+
return frac.length > 0 ? `${whole.toString(10)}.${frac}` : whole.toString(10);
|
|
7468
|
+
}
|
|
7469
|
+
function oraclePriceToNumber(price) {
|
|
7470
|
+
const formatted = formatOraclePrice(price);
|
|
7471
|
+
return formatted === null ? null : Number(formatted);
|
|
7472
|
+
}
|
|
7473
|
+
function concatBytes6(...parts) {
|
|
7474
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7475
|
+
let offset = 0;
|
|
7476
|
+
for (const part of parts) {
|
|
7477
|
+
out.set(part, offset);
|
|
7478
|
+
offset += part.length;
|
|
7479
|
+
}
|
|
7480
|
+
return out;
|
|
7481
|
+
}
|
|
6894
7482
|
function decodeOracleEvent(topics, data) {
|
|
6895
7483
|
if (topics.length === 0) {
|
|
6896
7484
|
throw new OracleEventError("event record has no topics");
|
|
6897
7485
|
}
|
|
6898
|
-
const topic0 =
|
|
6899
|
-
const body =
|
|
7486
|
+
const topic0 = bytesToHex7(expectLength4(toBytes4(topics[0]), 32, "topic0"));
|
|
7487
|
+
const body = toBytes4(data);
|
|
6900
7488
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
|
|
6901
7489
|
checkArity("OracleRoundFinalized", 3, topics.length);
|
|
6902
7490
|
checkData("OracleRoundFinalized", 3 * 32, body.length);
|
|
@@ -6929,7 +7517,7 @@ function decodeOracleEvent(topics, data) {
|
|
|
6929
7517
|
feedId: hex32(topics[1]),
|
|
6930
7518
|
roundId: u64FromTopic(topics[2]),
|
|
6931
7519
|
writer: addressFromTopic(topics[3]),
|
|
6932
|
-
evidenceHash:
|
|
7520
|
+
evidenceHash: bytesToHex7(body.subarray(0, 32))
|
|
6933
7521
|
};
|
|
6934
7522
|
}
|
|
6935
7523
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
|
|
@@ -6977,7 +7565,7 @@ function decodeFeedFields(feedTopic, body) {
|
|
|
6977
7565
|
};
|
|
6978
7566
|
}
|
|
6979
7567
|
function topicHex(sig) {
|
|
6980
|
-
return
|
|
7568
|
+
return bytesToHex7(sha3_js.keccak_256(new TextEncoder().encode(sig)));
|
|
6981
7569
|
}
|
|
6982
7570
|
function checkArity(event, expected, found) {
|
|
6983
7571
|
if (found !== expected) {
|
|
@@ -6990,13 +7578,13 @@ function checkData(event, expected, found) {
|
|
|
6990
7578
|
}
|
|
6991
7579
|
}
|
|
6992
7580
|
function hex32(topic) {
|
|
6993
|
-
return
|
|
7581
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "feedId topic"));
|
|
6994
7582
|
}
|
|
6995
7583
|
function addressFromTopic(topic) {
|
|
6996
|
-
return
|
|
7584
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "address topic").subarray(12, 32));
|
|
6997
7585
|
}
|
|
6998
7586
|
function u64FromTopic(topic) {
|
|
6999
|
-
return u64FromWord2(expectLength4(
|
|
7587
|
+
return u64FromWord2(expectLength4(toBytes4(topic), 32, "u64 topic"));
|
|
7000
7588
|
}
|
|
7001
7589
|
function u64FromWord2(word) {
|
|
7002
7590
|
let v = 0n;
|
|
@@ -7011,11 +7599,11 @@ function u256Decimal(word) {
|
|
|
7011
7599
|
for (const b of word) v = v << 8n | BigInt(b);
|
|
7012
7600
|
return v.toString(10);
|
|
7013
7601
|
}
|
|
7014
|
-
function
|
|
7015
|
-
if (typeof value === "string") return
|
|
7602
|
+
function toBytes4(value) {
|
|
7603
|
+
if (typeof value === "string") return hexToBytes6(value);
|
|
7016
7604
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7017
7605
|
}
|
|
7018
|
-
function
|
|
7606
|
+
function hexToBytes6(hex) {
|
|
7019
7607
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7020
7608
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
7021
7609
|
throw new OracleEventError("invalid hex bytes");
|
|
@@ -7024,7 +7612,7 @@ function hexToBytes5(hex) {
|
|
|
7024
7612
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
7025
7613
|
return out;
|
|
7026
7614
|
}
|
|
7027
|
-
function
|
|
7615
|
+
function bytesToHex7(bytes) {
|
|
7028
7616
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7029
7617
|
}
|
|
7030
7618
|
function expectLength4(value, len, name) {
|
|
@@ -7036,12 +7624,12 @@ function expectLength4(value, len, name) {
|
|
|
7036
7624
|
var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
|
|
7037
7625
|
var SERVES_GPU_PROVE = 512;
|
|
7038
7626
|
var PROVER_MARKET_SELECTORS = {
|
|
7039
|
-
createRequest: "0x" +
|
|
7040
|
-
submitBid: "0x" +
|
|
7041
|
-
closeRequest: "0x" +
|
|
7042
|
-
submitProof: "0x" +
|
|
7043
|
-
settle: "0x" +
|
|
7044
|
-
slash: "0x" +
|
|
7627
|
+
createRequest: "0x" + selectorHex3("createRequest(bytes)"),
|
|
7628
|
+
submitBid: "0x" + selectorHex3("submitBid(bytes)"),
|
|
7629
|
+
closeRequest: "0x" + selectorHex3("closeRequest(bytes)"),
|
|
7630
|
+
submitProof: "0x" + selectorHex3("submitProof(bytes)"),
|
|
7631
|
+
settle: "0x" + selectorHex3("settle(bytes)"),
|
|
7632
|
+
slash: "0x" + selectorHex3("slash(bytes)")
|
|
7045
7633
|
};
|
|
7046
7634
|
var PROVER_MARKET_EVENT_SIGS = {
|
|
7047
7635
|
proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
|
|
@@ -7079,12 +7667,12 @@ var ProverMarketError = class extends Error {
|
|
|
7079
7667
|
}
|
|
7080
7668
|
};
|
|
7081
7669
|
function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
7082
|
-
return
|
|
7670
|
+
return bytesToHex8(
|
|
7083
7671
|
sha3_js.keccak_256(
|
|
7084
|
-
|
|
7672
|
+
concatBytes7(
|
|
7085
7673
|
new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
|
|
7086
|
-
expectLength5(
|
|
7087
|
-
expectLength5(
|
|
7674
|
+
expectLength5(toBytes5(vkeyHash), 32, "vkeyHash"),
|
|
7675
|
+
expectLength5(toBytes5(inputsHash), 32, "inputsHash"),
|
|
7088
7676
|
u128Bytes(maxFee, "maxFee"),
|
|
7089
7677
|
u64Bytes(deadline, "deadline"),
|
|
7090
7678
|
u64Bytes(nonce, "nonce")
|
|
@@ -7093,44 +7681,44 @@ function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
|
7093
7681
|
);
|
|
7094
7682
|
}
|
|
7095
7683
|
function bidSighash(requestId, fee) {
|
|
7096
|
-
return
|
|
7684
|
+
return bytesToHex8(
|
|
7097
7685
|
sha3_js.keccak_256(
|
|
7098
|
-
|
|
7686
|
+
concatBytes7(
|
|
7099
7687
|
new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
|
|
7100
|
-
expectLength5(
|
|
7688
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
7101
7689
|
u128Bytes(fee, "fee")
|
|
7102
7690
|
)
|
|
7103
7691
|
)
|
|
7104
7692
|
);
|
|
7105
7693
|
}
|
|
7106
7694
|
function submitSighash(requestId, proofHash) {
|
|
7107
|
-
return
|
|
7695
|
+
return bytesToHex8(
|
|
7108
7696
|
sha3_js.keccak_256(
|
|
7109
|
-
|
|
7697
|
+
concatBytes7(
|
|
7110
7698
|
new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
|
|
7111
|
-
expectLength5(
|
|
7112
|
-
expectLength5(
|
|
7699
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
7700
|
+
expectLength5(toBytes5(proofHash), 32, "proofHash")
|
|
7113
7701
|
)
|
|
7114
7702
|
)
|
|
7115
7703
|
);
|
|
7116
7704
|
}
|
|
7117
7705
|
function encodeCreateRequestCanonical(args) {
|
|
7118
|
-
const buyer = expectLength5(
|
|
7119
|
-
const buyerPubkey =
|
|
7120
|
-
const sig =
|
|
7706
|
+
const buyer = expectLength5(toBytes5(args.buyer), 20, "buyer");
|
|
7707
|
+
const buyerPubkey = toBytes5(args.buyerPubkey);
|
|
7708
|
+
const sig = toBytes5(args.sig);
|
|
7121
7709
|
if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
|
|
7122
7710
|
throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
|
|
7123
7711
|
}
|
|
7124
7712
|
if (sig.length === 0 || sig.length > 65535) {
|
|
7125
7713
|
throw new ProverMarketError("sig length out of range (1..=65535)");
|
|
7126
7714
|
}
|
|
7127
|
-
return
|
|
7128
|
-
|
|
7715
|
+
return bytesToHex8(
|
|
7716
|
+
concatBytes7(
|
|
7129
7717
|
buyer,
|
|
7130
7718
|
u16Bytes(buyerPubkey.length),
|
|
7131
7719
|
buyerPubkey,
|
|
7132
|
-
expectLength5(
|
|
7133
|
-
expectLength5(
|
|
7720
|
+
expectLength5(toBytes5(args.vkeyHash), 32, "vkeyHash"),
|
|
7721
|
+
expectLength5(toBytes5(args.inputsHash), 32, "inputsHash"),
|
|
7134
7722
|
u128Bytes(args.maxFee, "maxFee"),
|
|
7135
7723
|
u64Bytes(args.deadline, "deadline"),
|
|
7136
7724
|
u64Bytes(args.nonce, "nonce"),
|
|
@@ -7140,7 +7728,7 @@ function encodeCreateRequestCanonical(args) {
|
|
|
7140
7728
|
);
|
|
7141
7729
|
}
|
|
7142
7730
|
function encodeCreateRequestCalldata(args) {
|
|
7143
|
-
const canonical =
|
|
7731
|
+
const canonical = toBytes5(encodeCreateRequestCanonical(args));
|
|
7144
7732
|
const offset = new Uint8Array(32);
|
|
7145
7733
|
offset[31] = 32;
|
|
7146
7734
|
const lenWord = new Uint8Array(32);
|
|
@@ -7150,18 +7738,18 @@ function encodeCreateRequestCalldata(args) {
|
|
|
7150
7738
|
lenWord[30] = len >>> 8 & 255;
|
|
7151
7739
|
lenWord[31] = len & 255;
|
|
7152
7740
|
const pad = (32 - len % 32) % 32;
|
|
7153
|
-
return
|
|
7154
|
-
|
|
7741
|
+
return bytesToHex8(
|
|
7742
|
+
concatBytes7(hexToBytes7(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
|
|
7155
7743
|
);
|
|
7156
7744
|
}
|
|
7157
|
-
function
|
|
7745
|
+
function selectorHex3(sig) {
|
|
7158
7746
|
return [...sha3_js.keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7159
7747
|
}
|
|
7160
|
-
function
|
|
7161
|
-
if (typeof value === "string") return
|
|
7748
|
+
function toBytes5(value) {
|
|
7749
|
+
if (typeof value === "string") return hexToBytes7(value);
|
|
7162
7750
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7163
7751
|
}
|
|
7164
|
-
function
|
|
7752
|
+
function hexToBytes7(hex) {
|
|
7165
7753
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7166
7754
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
7167
7755
|
throw new ProverMarketError("invalid hex bytes");
|
|
@@ -7170,10 +7758,10 @@ function hexToBytes6(hex) {
|
|
|
7170
7758
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
7171
7759
|
return out;
|
|
7172
7760
|
}
|
|
7173
|
-
function
|
|
7761
|
+
function bytesToHex8(bytes) {
|
|
7174
7762
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7175
7763
|
}
|
|
7176
|
-
function
|
|
7764
|
+
function concatBytes7(...parts) {
|
|
7177
7765
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7178
7766
|
let offset = 0;
|
|
7179
7767
|
for (const part of parts) {
|
|
@@ -7250,34 +7838,34 @@ function delegationAddressHex() {
|
|
|
7250
7838
|
return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
|
|
7251
7839
|
}
|
|
7252
7840
|
function encodeCompleteRedemptionCalldata(index) {
|
|
7253
|
-
return
|
|
7254
|
-
|
|
7255
|
-
|
|
7256
|
-
|
|
7841
|
+
return bytesToHex9(
|
|
7842
|
+
concatBytes8(
|
|
7843
|
+
hexToBytes8(DELEGATION_SELECTORS.completeRedemption),
|
|
7844
|
+
uint64Word3(index, "index")
|
|
7257
7845
|
)
|
|
7258
7846
|
);
|
|
7259
7847
|
}
|
|
7260
7848
|
function encodeDelegateCalldata(cluster, weightBps) {
|
|
7261
|
-
return
|
|
7262
|
-
|
|
7263
|
-
|
|
7849
|
+
return bytesToHex9(
|
|
7850
|
+
concatBytes8(
|
|
7851
|
+
hexToBytes8(DELEGATION_SELECTORS.delegate),
|
|
7264
7852
|
uint32Word2(cluster, "cluster"),
|
|
7265
7853
|
uint16Word(weightBps, "weightBps")
|
|
7266
7854
|
)
|
|
7267
7855
|
);
|
|
7268
7856
|
}
|
|
7269
7857
|
function encodeUndelegateCalldata(cluster) {
|
|
7270
|
-
return
|
|
7271
|
-
|
|
7272
|
-
|
|
7858
|
+
return bytesToHex9(
|
|
7859
|
+
concatBytes8(
|
|
7860
|
+
hexToBytes8(DELEGATION_SELECTORS.undelegate),
|
|
7273
7861
|
uint32Word2(cluster, "cluster")
|
|
7274
7862
|
)
|
|
7275
7863
|
);
|
|
7276
7864
|
}
|
|
7277
7865
|
function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
|
|
7278
|
-
return
|
|
7279
|
-
|
|
7280
|
-
|
|
7866
|
+
return bytesToHex9(
|
|
7867
|
+
concatBytes8(
|
|
7868
|
+
hexToBytes8(DELEGATION_SELECTORS.redelegate),
|
|
7281
7869
|
uint32Word2(fromCluster, "fromCluster"),
|
|
7282
7870
|
uint32Word2(toCluster, "toCluster"),
|
|
7283
7871
|
uint16Word(weightBps, "weightBps")
|
|
@@ -7290,14 +7878,14 @@ function encodeClaimCalldata() {
|
|
|
7290
7878
|
function encodeSetAutoCompoundCalldata(enabled) {
|
|
7291
7879
|
const flag = new Uint8Array(32);
|
|
7292
7880
|
flag[31] = enabled ? 1 : 0;
|
|
7293
|
-
return
|
|
7294
|
-
|
|
7881
|
+
return bytesToHex9(
|
|
7882
|
+
concatBytes8(hexToBytes8(DELEGATION_SELECTORS.setAutoCompound), flag)
|
|
7295
7883
|
);
|
|
7296
7884
|
}
|
|
7297
7885
|
function isRedemptionPrincipalUnavailableRevert(data) {
|
|
7298
|
-
return
|
|
7886
|
+
return bytesToHex9(toBytes6(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
|
|
7299
7887
|
}
|
|
7300
|
-
function
|
|
7888
|
+
function uint64Word3(value, name) {
|
|
7301
7889
|
const n = toBigint3(value, name);
|
|
7302
7890
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
7303
7891
|
throw new DelegationPrecompileError(`${name} must fit uint64`);
|
|
@@ -7349,13 +7937,13 @@ function toBigint3(value, name) {
|
|
|
7349
7937
|
}
|
|
7350
7938
|
return BigInt(value);
|
|
7351
7939
|
}
|
|
7352
|
-
function
|
|
7940
|
+
function toBytes6(value) {
|
|
7353
7941
|
if (typeof value === "string") {
|
|
7354
|
-
return
|
|
7942
|
+
return hexToBytes8(value);
|
|
7355
7943
|
}
|
|
7356
7944
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7357
7945
|
}
|
|
7358
|
-
function
|
|
7946
|
+
function hexToBytes8(hex) {
|
|
7359
7947
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7360
7948
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7361
7949
|
throw new DelegationPrecompileError("invalid hex bytes");
|
|
@@ -7366,10 +7954,10 @@ function hexToBytes7(hex) {
|
|
|
7366
7954
|
}
|
|
7367
7955
|
return out;
|
|
7368
7956
|
}
|
|
7369
|
-
function
|
|
7957
|
+
function bytesToHex9(bytes) {
|
|
7370
7958
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7371
7959
|
}
|
|
7372
|
-
function
|
|
7960
|
+
function concatBytes8(...parts) {
|
|
7373
7961
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7374
7962
|
let offset = 0;
|
|
7375
7963
|
for (const part of parts) {
|
|
@@ -7378,8 +7966,6 @@ function concatBytes6(...parts) {
|
|
|
7378
7966
|
}
|
|
7379
7967
|
return out;
|
|
7380
7968
|
}
|
|
7381
|
-
|
|
7382
|
-
// src/spending-policy.ts
|
|
7383
7969
|
var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
|
|
7384
7970
|
var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
|
|
7385
7971
|
var ML_DSA_65_SIGNATURE_LEN2 = 3309;
|
|
@@ -7402,10 +7988,38 @@ var SpendingPolicyError = class extends Error {
|
|
|
7402
7988
|
function spendingPolicyAddressHex() {
|
|
7403
7989
|
return PRECOMPILE_ADDRESSES.SPENDING_POLICY.toLowerCase();
|
|
7404
7990
|
}
|
|
7991
|
+
var EMPTY_ROOT = new Uint8Array(32);
|
|
7992
|
+
function destinationRoot(address) {
|
|
7993
|
+
const bytes = toUserAddressBytes(address, "address");
|
|
7994
|
+
return sha3_js.keccak_256(bytes);
|
|
7995
|
+
}
|
|
7996
|
+
var allowRootFor = destinationRoot;
|
|
7997
|
+
var denyRootFor = destinationRoot;
|
|
7998
|
+
function categoryRoot(selectorOrSig) {
|
|
7999
|
+
let selector;
|
|
8000
|
+
if (typeof selectorOrSig === "string") {
|
|
8001
|
+
selector = sha3_js.keccak_256(new TextEncoder().encode(selectorOrSig)).slice(0, 4);
|
|
8002
|
+
} else {
|
|
8003
|
+
selector = selectorOrSig instanceof Uint8Array ? selectorOrSig : Uint8Array.from(selectorOrSig);
|
|
8004
|
+
if (selector.length !== 4) {
|
|
8005
|
+
throw new SpendingPolicyError("category selector must be exactly 4 bytes");
|
|
8006
|
+
}
|
|
8007
|
+
}
|
|
8008
|
+
return sha3_js.keccak_256(selector);
|
|
8009
|
+
}
|
|
8010
|
+
function setDestinationRoot(entries) {
|
|
8011
|
+
if (entries.length === 0) return EMPTY_ROOT;
|
|
8012
|
+
if (entries.length > 1) {
|
|
8013
|
+
throw new SpendingPolicyError(
|
|
8014
|
+
"multi-entry destination sets are not supported by the chain yet (v1 allows a single counterparty per root); pass exactly one address"
|
|
8015
|
+
);
|
|
8016
|
+
}
|
|
8017
|
+
return destinationRoot(entries[0]);
|
|
8018
|
+
}
|
|
7405
8019
|
function composeClaimBoundMessage(chainId, args, opts) {
|
|
7406
8020
|
const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
|
|
7407
8021
|
const normalized = normalizeArgs(args);
|
|
7408
|
-
return
|
|
8022
|
+
return concatBytes9(
|
|
7409
8023
|
new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
|
|
7410
8024
|
uint64Bytes(chainId, "chainId"),
|
|
7411
8025
|
precompileAddress,
|
|
@@ -7428,17 +8042,17 @@ function composeClaimBoundMessage(chainId, args, opts) {
|
|
|
7428
8042
|
}
|
|
7429
8043
|
function encodeSetPolicyCalldata(args) {
|
|
7430
8044
|
const normalized = normalizeArgs(args);
|
|
7431
|
-
return
|
|
7432
|
-
|
|
7433
|
-
|
|
8045
|
+
return bytesToHex10(
|
|
8046
|
+
concatBytes9(
|
|
8047
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicy),
|
|
7434
8048
|
encodePolicyWords(normalized)
|
|
7435
8049
|
)
|
|
7436
8050
|
);
|
|
7437
8051
|
}
|
|
7438
8052
|
function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
7439
8053
|
const normalized = normalizeArgs(args);
|
|
7440
|
-
const pubkey =
|
|
7441
|
-
const sig =
|
|
8054
|
+
const pubkey = toBytes7(subAccountPubkey);
|
|
8055
|
+
const sig = toBytes7(subAccountSig);
|
|
7442
8056
|
if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
|
|
7443
8057
|
throw new SpendingPolicyError(
|
|
7444
8058
|
`subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
|
|
@@ -7449,9 +8063,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7449
8063
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7450
8064
|
);
|
|
7451
8065
|
}
|
|
7452
|
-
return
|
|
7453
|
-
|
|
7454
|
-
|
|
8066
|
+
return bytesToHex10(
|
|
8067
|
+
concatBytes9(
|
|
8068
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicyClaim),
|
|
7455
8069
|
encodePolicyWords(normalized),
|
|
7456
8070
|
pubkey,
|
|
7457
8071
|
sig
|
|
@@ -7460,15 +8074,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7460
8074
|
}
|
|
7461
8075
|
function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
|
|
7462
8076
|
const normalized = normalizeArgs(args);
|
|
7463
|
-
const sig =
|
|
8077
|
+
const sig = toBytes7(subAccountSig);
|
|
7464
8078
|
if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
|
|
7465
8079
|
throw new SpendingPolicyError(
|
|
7466
8080
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7467
8081
|
);
|
|
7468
8082
|
}
|
|
7469
|
-
return
|
|
7470
|
-
|
|
7471
|
-
|
|
8083
|
+
return bytesToHex10(
|
|
8084
|
+
concatBytes9(
|
|
8085
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
|
|
7472
8086
|
encodePolicyWords(normalized),
|
|
7473
8087
|
sig
|
|
7474
8088
|
)
|
|
@@ -7487,17 +8101,17 @@ function normalizeArgs(args) {
|
|
|
7487
8101
|
principal: toUserAddressBytes(args.principal, "principal"),
|
|
7488
8102
|
dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
|
|
7489
8103
|
perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
7490
|
-
allowRoot: expectLength6(
|
|
7491
|
-
denyRoot: expectLength6(
|
|
8104
|
+
allowRoot: expectLength6(toBytes7(args.allowRoot), 32, "allowRoot"),
|
|
8105
|
+
denyRoot: expectLength6(toBytes7(args.denyRoot), 32, "denyRoot"),
|
|
7492
8106
|
weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
|
|
7493
8107
|
monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
|
|
7494
|
-
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(
|
|
7495
|
-
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(
|
|
8108
|
+
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes7(args.categoryAllowRoot), 32, "categoryAllowRoot"),
|
|
8109
|
+
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes7(args.timeWindow), 32, "timeWindow"),
|
|
7496
8110
|
policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
|
|
7497
8111
|
};
|
|
7498
8112
|
}
|
|
7499
8113
|
function encodePolicyWords(args) {
|
|
7500
|
-
return
|
|
8114
|
+
return concatBytes9(
|
|
7501
8115
|
encodeAddressWord(args.subAccount),
|
|
7502
8116
|
encodeAddressWord(args.principal),
|
|
7503
8117
|
encodeUint128Word(args.dailyCapLythoshi),
|
|
@@ -7522,7 +8136,7 @@ function packTimeWindow(enabled, startHour, endHour) {
|
|
|
7522
8136
|
return out;
|
|
7523
8137
|
}
|
|
7524
8138
|
function decodeTimeWindow(word) {
|
|
7525
|
-
const bytes = expectLength6(
|
|
8139
|
+
const bytes = expectLength6(toBytes7(word), 32, "timeWindow");
|
|
7526
8140
|
if (bytes.every((b) => b === 0)) return null;
|
|
7527
8141
|
if (bytes[29] === 0) return null;
|
|
7528
8142
|
return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
|
|
@@ -7534,16 +8148,16 @@ function clampHour(hour) {
|
|
|
7534
8148
|
return Math.min(hour, 23);
|
|
7535
8149
|
}
|
|
7536
8150
|
function encodeUint64Word(value) {
|
|
7537
|
-
return
|
|
8151
|
+
return concatBytes9(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
|
|
7538
8152
|
}
|
|
7539
8153
|
function encodeSingleAddressCall(selector, address, name) {
|
|
7540
|
-
return
|
|
8154
|
+
return bytesToHex10(concatBytes9(hexToBytes9(selector), encodeAddressWord(toUserAddressBytes(address, name))));
|
|
7541
8155
|
}
|
|
7542
8156
|
function encodeAddressWord(address) {
|
|
7543
|
-
return
|
|
8157
|
+
return concatBytes9(new Uint8Array(12), address);
|
|
7544
8158
|
}
|
|
7545
8159
|
function encodeUint128Word(value) {
|
|
7546
|
-
return
|
|
8160
|
+
return concatBytes9(new Uint8Array(16), uint128Bytes(value, "uint128"));
|
|
7547
8161
|
}
|
|
7548
8162
|
function toUserAddressBytes(value, name) {
|
|
7549
8163
|
if (typeof value !== "string") {
|
|
@@ -7565,13 +8179,13 @@ function toRawAddressBytes(value) {
|
|
|
7565
8179
|
}
|
|
7566
8180
|
return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
|
|
7567
8181
|
}
|
|
7568
|
-
function
|
|
8182
|
+
function toBytes7(value) {
|
|
7569
8183
|
if (typeof value === "string") {
|
|
7570
|
-
return
|
|
8184
|
+
return hexToBytes9(value);
|
|
7571
8185
|
}
|
|
7572
8186
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7573
8187
|
}
|
|
7574
|
-
function
|
|
8188
|
+
function hexToBytes9(hex) {
|
|
7575
8189
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7576
8190
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7577
8191
|
throw new SpendingPolicyError("invalid hex bytes");
|
|
@@ -7582,10 +8196,10 @@ function hexToBytes8(hex) {
|
|
|
7582
8196
|
}
|
|
7583
8197
|
return out;
|
|
7584
8198
|
}
|
|
7585
|
-
function
|
|
8199
|
+
function bytesToHex10(bytes) {
|
|
7586
8200
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7587
8201
|
}
|
|
7588
|
-
function
|
|
8202
|
+
function concatBytes9(...parts) {
|
|
7589
8203
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7590
8204
|
let offset = 0;
|
|
7591
8205
|
for (const part of parts) {
|
|
@@ -7647,17 +8261,17 @@ function pubkeyRegistryAddressHex() {
|
|
|
7647
8261
|
return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
|
|
7648
8262
|
}
|
|
7649
8263
|
function encodeRegisterPubkeyCalldata(pubkey) {
|
|
7650
|
-
const bytes =
|
|
8264
|
+
const bytes = toBytes8(pubkey);
|
|
7651
8265
|
if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
7652
8266
|
throw new PubkeyRegistryError(
|
|
7653
8267
|
`pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
|
|
7654
8268
|
);
|
|
7655
8269
|
}
|
|
7656
|
-
return
|
|
7657
|
-
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
8270
|
+
return bytesToHex11(
|
|
8271
|
+
concatBytes10(
|
|
8272
|
+
hexToBytes10(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
|
|
8273
|
+
uint256Word2(32n),
|
|
8274
|
+
uint256Word2(BigInt(bytes.length)),
|
|
7661
8275
|
bytes
|
|
7662
8276
|
)
|
|
7663
8277
|
);
|
|
@@ -7669,7 +8283,7 @@ function encodeHasPubkeyCalldata(address) {
|
|
|
7669
8283
|
return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
|
|
7670
8284
|
}
|
|
7671
8285
|
function decodeLookupPubkeyReturn(data) {
|
|
7672
|
-
const bytes =
|
|
8286
|
+
const bytes = toBytes8(data);
|
|
7673
8287
|
if (bytes.length < 96) {
|
|
7674
8288
|
throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
|
|
7675
8289
|
}
|
|
@@ -7694,7 +8308,7 @@ function decodeLookupPubkeyReturn(data) {
|
|
|
7694
8308
|
};
|
|
7695
8309
|
}
|
|
7696
8310
|
function decodeHasPubkeyReturn(data) {
|
|
7697
|
-
const bytes =
|
|
8311
|
+
const bytes = toBytes8(data);
|
|
7698
8312
|
if (bytes.length !== 32) {
|
|
7699
8313
|
throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
|
|
7700
8314
|
}
|
|
@@ -7708,10 +8322,10 @@ function decodeHasPubkeyReturn(data) {
|
|
|
7708
8322
|
throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
|
|
7709
8323
|
}
|
|
7710
8324
|
function encodeSingleAddressCall2(selector, address) {
|
|
7711
|
-
return
|
|
8325
|
+
return bytesToHex11(concatBytes10(hexToBytes10(selector), addressWord3(toAddressBytes(address))));
|
|
7712
8326
|
}
|
|
7713
|
-
function
|
|
7714
|
-
return
|
|
8327
|
+
function addressWord3(address) {
|
|
8328
|
+
return concatBytes10(new Uint8Array(12), address);
|
|
7715
8329
|
}
|
|
7716
8330
|
function toAddressBytes(value) {
|
|
7717
8331
|
if (typeof value !== "string") {
|
|
@@ -7727,13 +8341,13 @@ function toAddressBytes(value) {
|
|
|
7727
8341
|
throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
|
|
7728
8342
|
}
|
|
7729
8343
|
}
|
|
7730
|
-
function
|
|
8344
|
+
function toBytes8(value) {
|
|
7731
8345
|
if (typeof value === "string") {
|
|
7732
|
-
return
|
|
8346
|
+
return hexToBytes10(value);
|
|
7733
8347
|
}
|
|
7734
8348
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7735
8349
|
}
|
|
7736
|
-
function
|
|
8350
|
+
function hexToBytes10(hex) {
|
|
7737
8351
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7738
8352
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7739
8353
|
throw new PubkeyRegistryError("invalid hex bytes");
|
|
@@ -7744,10 +8358,10 @@ function hexToBytes9(hex) {
|
|
|
7744
8358
|
}
|
|
7745
8359
|
return out;
|
|
7746
8360
|
}
|
|
7747
|
-
function
|
|
8361
|
+
function bytesToHex11(bytes) {
|
|
7748
8362
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7749
8363
|
}
|
|
7750
|
-
function
|
|
8364
|
+
function concatBytes10(...parts) {
|
|
7751
8365
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7752
8366
|
let offset = 0;
|
|
7753
8367
|
for (const part of parts) {
|
|
@@ -7756,7 +8370,7 @@ function concatBytes8(...parts) {
|
|
|
7756
8370
|
}
|
|
7757
8371
|
return out;
|
|
7758
8372
|
}
|
|
7759
|
-
function
|
|
8373
|
+
function uint256Word2(value) {
|
|
7760
8374
|
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
7761
8375
|
throw new PubkeyRegistryError("uint256 value out of range");
|
|
7762
8376
|
}
|
|
@@ -7778,6 +8392,11 @@ function wordToBigint(word) {
|
|
|
7778
8392
|
}
|
|
7779
8393
|
return out;
|
|
7780
8394
|
}
|
|
8395
|
+
new TextEncoder().encode("protocore/v2/mempool/dkg-mlkem768/1");
|
|
8396
|
+
var MempoolClass = {
|
|
8397
|
+
CLOBOp: 3};
|
|
8398
|
+
|
|
8399
|
+
// src/market-actions.ts
|
|
7781
8400
|
var CLOB_MARKET_ID_DOMAIN_TAG = 193;
|
|
7782
8401
|
var NATIVE_MARKET_MODULE_ADDRESS_BYTES = "0x4d41524b45545f4e41544956455f4d4f445f5631";
|
|
7783
8402
|
var NATIVE_MARKET_MODULE_ADDRESS = addressToTypedBech32(
|
|
@@ -7904,9 +8523,9 @@ function encodePlaceLimitOrderCalldata(args) {
|
|
|
7904
8523
|
normalized.baseTokenId,
|
|
7905
8524
|
normalized.quoteTokenId,
|
|
7906
8525
|
uint8Word2(normalized.side),
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
8526
|
+
uint256Word3(normalized.price, "price"),
|
|
8527
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
8528
|
+
uint64Word4(normalized.expiryBlock, "expiryBlock")
|
|
7910
8529
|
)
|
|
7911
8530
|
);
|
|
7912
8531
|
}
|
|
@@ -7918,7 +8537,7 @@ function encodePlaceMarketOrderCalldata(args) {
|
|
|
7918
8537
|
normalized.baseTokenId,
|
|
7919
8538
|
normalized.quoteTokenId,
|
|
7920
8539
|
uint8Word2(normalized.side),
|
|
7921
|
-
|
|
8540
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7922
8541
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps")
|
|
7923
8542
|
)
|
|
7924
8543
|
);
|
|
@@ -7931,7 +8550,7 @@ function encodePlaceMarketOrderExCalldata(args) {
|
|
|
7931
8550
|
normalized.baseTokenId,
|
|
7932
8551
|
normalized.quoteTokenId,
|
|
7933
8552
|
uint8Word2(normalized.side),
|
|
7934
|
-
|
|
8553
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7935
8554
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps"),
|
|
7936
8555
|
uint8Word2(normalized.mode)
|
|
7937
8556
|
)
|
|
@@ -7951,7 +8570,7 @@ function encodeMarketGridTuneCalldata(selector, label, args) {
|
|
|
7951
8570
|
hexToBytes2(selector, `${label} selector`),
|
|
7952
8571
|
bytes32FromHex(args.baseTokenId, "baseTokenId"),
|
|
7953
8572
|
bytes32FromHex(args.quoteTokenId, "quoteTokenId"),
|
|
7954
|
-
|
|
8573
|
+
uint256Word3(BigInt(args.newValue), "newValue")
|
|
7955
8574
|
)
|
|
7956
8575
|
);
|
|
7957
8576
|
}
|
|
@@ -8239,13 +8858,13 @@ function encodePlaceLimitOrderViaCalldata(args) {
|
|
|
8239
8858
|
return bytesToHex2(
|
|
8240
8859
|
concatBytes2(
|
|
8241
8860
|
hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
|
|
8242
|
-
|
|
8861
|
+
addressWord4(operator.bytes),
|
|
8243
8862
|
bytes32FromHex(args.base, "base"),
|
|
8244
8863
|
bytes32FromHex(args.quote, "quote"),
|
|
8245
8864
|
uint8Word2(side),
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8865
|
+
uint256Word3(price, "price"),
|
|
8866
|
+
uint256Word3(amount, "amount"),
|
|
8867
|
+
uint64Word4(expiresAtBlock, "expiresAtBlock")
|
|
8249
8868
|
)
|
|
8250
8869
|
);
|
|
8251
8870
|
}
|
|
@@ -8535,7 +9154,7 @@ function uint8Word2(value) {
|
|
|
8535
9154
|
out[31] = value;
|
|
8536
9155
|
return out;
|
|
8537
9156
|
}
|
|
8538
|
-
function
|
|
9157
|
+
function uint64Word4(value, name) {
|
|
8539
9158
|
if (value < 0n || value > 0xffffffffffffffffn) {
|
|
8540
9159
|
throw new MarketActionError(`${name} must fit uint64`);
|
|
8541
9160
|
}
|
|
@@ -8556,7 +9175,7 @@ function uint16Word2(value, name) {
|
|
|
8556
9175
|
out[31] = Number(value & 0xffn);
|
|
8557
9176
|
return out;
|
|
8558
9177
|
}
|
|
8559
|
-
function
|
|
9178
|
+
function uint256Word3(value, name) {
|
|
8560
9179
|
if (value < 0n || value >= 1n << 256n) {
|
|
8561
9180
|
throw new MarketActionError(`${name} must fit uint256`);
|
|
8562
9181
|
}
|
|
@@ -8568,7 +9187,7 @@ function uint256Word2(value, name) {
|
|
|
8568
9187
|
}
|
|
8569
9188
|
return out;
|
|
8570
9189
|
}
|
|
8571
|
-
function
|
|
9190
|
+
function addressWord4(addr) {
|
|
8572
9191
|
if (addr.length !== 20) {
|
|
8573
9192
|
throw new MarketActionError("address must be 20 bytes");
|
|
8574
9193
|
}
|
|
@@ -9108,7 +9727,7 @@ var MONOLYTHIUM_NETWORKS = {
|
|
|
9108
9727
|
};
|
|
9109
9728
|
|
|
9110
9729
|
// src/index.ts
|
|
9111
|
-
var version = "0.
|
|
9730
|
+
var version = "0.3.15";
|
|
9112
9731
|
|
|
9113
9732
|
exports.ADDRESS_HRP = ADDRESS_HRP;
|
|
9114
9733
|
exports.ADDRESS_KIND_HRPS = ADDRESS_KIND_HRPS;
|
|
@@ -9132,7 +9751,9 @@ exports.DELEGATION_REVERT_TAGS = DELEGATION_REVERT_TAGS;
|
|
|
9132
9751
|
exports.DELEGATION_SELECTORS = DELEGATION_SELECTORS;
|
|
9133
9752
|
exports.DIVERSITY_SCORE_MAX = DIVERSITY_SCORE_MAX;
|
|
9134
9753
|
exports.DelegationPrecompileError = DelegationPrecompileError;
|
|
9754
|
+
exports.EMPTY_ROOT = EMPTY_ROOT;
|
|
9135
9755
|
exports.EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
9756
|
+
exports.FEED_ID_DOMAIN_TAG = FEED_ID_DOMAIN_TAG;
|
|
9136
9757
|
exports.LYTHOSHI_PER_LYTH = LYTHOSHI_PER_LYTH;
|
|
9137
9758
|
exports.LYTH_DECIMALS = LYTH_DECIMALS;
|
|
9138
9759
|
exports.MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES = MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES;
|
|
@@ -9158,6 +9779,12 @@ exports.MRV_TX_EXTENSION_V1 = MRV_TX_EXTENSION_V1;
|
|
|
9158
9779
|
exports.MULTISIG_ADDRESS_DERIVATION_DOMAIN = MULTISIG_ADDRESS_DERIVATION_DOMAIN;
|
|
9159
9780
|
exports.MarketActionError = MarketActionError;
|
|
9160
9781
|
exports.MrvValidationError = MrvValidationError;
|
|
9782
|
+
exports.NAME_BASE_MULTIPLIER = NAME_BASE_MULTIPLIER;
|
|
9783
|
+
exports.NAME_FALLBACK_FEE_UNIT_LYTHOSHI = NAME_FALLBACK_FEE_UNIT_LYTHOSHI;
|
|
9784
|
+
exports.NAME_LABEL_MAX_LEN = NAME_LABEL_MAX_LEN;
|
|
9785
|
+
exports.NAME_LABEL_MIN_LEN = NAME_LABEL_MIN_LEN;
|
|
9786
|
+
exports.NAME_MAX_LEN = NAME_MAX_LEN;
|
|
9787
|
+
exports.NAME_REGISTRY_SELECTORS = NAME_REGISTRY_SELECTORS;
|
|
9161
9788
|
exports.NATIVE_AGENT_MODULE_ADDRESS = NATIVE_AGENT_MODULE_ADDRESS;
|
|
9162
9789
|
exports.NATIVE_AGENT_MODULE_ADDRESS_BYTES = NATIVE_AGENT_MODULE_ADDRESS_BYTES;
|
|
9163
9790
|
exports.NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE = NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE;
|
|
@@ -9171,8 +9798,13 @@ exports.NATIVE_MARKET_EVENT_FAMILY = NATIVE_MARKET_EVENT_FAMILY;
|
|
|
9171
9798
|
exports.NATIVE_MARKET_MODULE_ADDRESS = NATIVE_MARKET_MODULE_ADDRESS;
|
|
9172
9799
|
exports.NATIVE_MARKET_MODULE_ADDRESS_BYTES = NATIVE_MARKET_MODULE_ADDRESS_BYTES;
|
|
9173
9800
|
exports.NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC = NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC;
|
|
9801
|
+
exports.NODE_REGISTRY_BLS_PUBKEY_BYTES = NODE_REGISTRY_BLS_PUBKEY_BYTES;
|
|
9174
9802
|
exports.NODE_REGISTRY_CAPABILITIES = NODE_REGISTRY_CAPABILITIES;
|
|
9175
9803
|
exports.NODE_REGISTRY_CAPABILITY_MASK = NODE_REGISTRY_CAPABILITY_MASK;
|
|
9804
|
+
exports.NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS = NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS;
|
|
9805
|
+
exports.NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS;
|
|
9806
|
+
exports.NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES;
|
|
9807
|
+
exports.NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID;
|
|
9176
9808
|
exports.NODE_REGISTRY_PUBLIC_SERVICE_MASK = NODE_REGISTRY_PUBLIC_SERVICE_MASK;
|
|
9177
9809
|
exports.NODE_REGISTRY_SELECTORS = NODE_REGISTRY_SELECTORS;
|
|
9178
9810
|
exports.NO_EVM_ARCHIVE_PROOF_SCHEMA = NO_EVM_ARCHIVE_PROOF_SCHEMA;
|
|
@@ -9184,6 +9816,7 @@ exports.NO_EVM_RECEIPT_CODEC = NO_EVM_RECEIPT_CODEC;
|
|
|
9184
9816
|
exports.NO_EVM_RECEIPT_PROOF_SCHEMA = NO_EVM_RECEIPT_PROOF_SCHEMA;
|
|
9185
9817
|
exports.NO_EVM_RECEIPT_PROOF_TYPE = NO_EVM_RECEIPT_PROOF_TYPE;
|
|
9186
9818
|
exports.NO_EVM_RECEIPT_ROOT_ALGORITHM = NO_EVM_RECEIPT_ROOT_ALGORITHM;
|
|
9819
|
+
exports.NameRegistryError = NameRegistryError;
|
|
9187
9820
|
exports.NoEvmReceiptProofError = NoEvmReceiptProofError;
|
|
9188
9821
|
exports.NodeRegistryError = NodeRegistryError;
|
|
9189
9822
|
exports.OPERATOR_ROUTER_ADDRESS = OPERATOR_ROUTER_ADDRESS;
|
|
@@ -9192,6 +9825,7 @@ exports.OPERATOR_ROUTER_SELECTORS = OPERATOR_ROUTER_SELECTORS;
|
|
|
9192
9825
|
exports.OPERATOR_ROUTER_SIGS = OPERATOR_ROUTER_SIGS;
|
|
9193
9826
|
exports.ORACLE_EVENT_SIGS = ORACLE_EVENT_SIGS;
|
|
9194
9827
|
exports.OracleEventError = OracleEventError;
|
|
9828
|
+
exports.PENDING_CHANGE_KIND_CODES = PENDING_CHANGE_KIND_CODES;
|
|
9195
9829
|
exports.PRECOMPILE_ADDRESSES = PRECOMPILE_ADDRESSES;
|
|
9196
9830
|
exports.PROTOCOL_MAX_OPERATOR_FEE_BPS = PROTOCOL_MAX_OPERATOR_FEE_BPS;
|
|
9197
9831
|
exports.PROVER_MARKET_ADDRESS = PROVER_MARKET_ADDRESS;
|
|
@@ -9222,6 +9856,7 @@ exports.V1_BRIDGE_ALLOWED_PROTOCOL = V1_BRIDGE_ALLOWED_PROTOCOL;
|
|
|
9222
9856
|
exports.addressBytesToHex = addressBytesToHex;
|
|
9223
9857
|
exports.addressToBech32 = addressToBech32;
|
|
9224
9858
|
exports.addressToTypedBech32 = addressToTypedBech32;
|
|
9859
|
+
exports.allowRootFor = allowRootFor;
|
|
9225
9860
|
exports.apiEndpointFromRpcEndpoint = apiEndpointFromRpcEndpoint;
|
|
9226
9861
|
exports.assertMrvCallNativeSubmissionPlan = assertMrvCallNativeSubmissionPlan;
|
|
9227
9862
|
exports.assertMrvDeployNativeSubmissionPlan = assertMrvDeployNativeSubmissionPlan;
|
|
@@ -9286,11 +9921,13 @@ exports.buildPlaceLimitOrderViaPlan = buildPlaceLimitOrderViaPlan;
|
|
|
9286
9921
|
exports.buildPlaceSpotLimitOrderPlan = buildPlaceSpotLimitOrderPlan;
|
|
9287
9922
|
exports.buildPlaceSpotMarketOrderExPlan = buildPlaceSpotMarketOrderExPlan;
|
|
9288
9923
|
exports.buildPlaceSpotMarketOrderPlan = buildPlaceSpotMarketOrderPlan;
|
|
9924
|
+
exports.categoryRoot = categoryRoot;
|
|
9289
9925
|
exports.checkMrvFeeDisplayConformance = checkMrvFeeDisplayConformance;
|
|
9290
9926
|
exports.checkMrvStructuredFeeConformance = checkMrvStructuredFeeConformance;
|
|
9291
9927
|
exports.checkNativeDevkitCompatibility = checkNativeDevkitCompatibility;
|
|
9292
9928
|
exports.clampPriorityTip = clampPriorityTip;
|
|
9293
9929
|
exports.clobAddressHex = clobAddressHex;
|
|
9930
|
+
exports.clusterApyPercent = clusterApyPercent;
|
|
9294
9931
|
exports.compareNativeDevVersions = compareNativeDevVersions;
|
|
9295
9932
|
exports.composeClaimBoundMessage = composeClaimBoundMessage;
|
|
9296
9933
|
exports.computeNoEvmDacFinalityMessage = computeNoEvmDacFinalityMessage;
|
|
@@ -9298,6 +9935,7 @@ exports.computeNoEvmLeaderFinalityMessage = computeNoEvmLeaderFinalityMessage;
|
|
|
9298
9935
|
exports.computeNoEvmReceiptsRoot = computeNoEvmReceiptsRoot;
|
|
9299
9936
|
exports.computeNoEvmRoundFinalityMessage = computeNoEvmRoundFinalityMessage;
|
|
9300
9937
|
exports.computeNoEvmTargetReceiptHash = computeNoEvmTargetReceiptHash;
|
|
9938
|
+
exports.computeQuoteLiquidity = computeQuoteLiquidity;
|
|
9301
9939
|
exports.consumeNativeEvents = consumeNativeEvents;
|
|
9302
9940
|
exports.decodeClusterDiversity = decodeClusterDiversity;
|
|
9303
9941
|
exports.decodeClusterFormedEvent = decodeClusterFormedEvent;
|
|
@@ -9313,13 +9951,20 @@ exports.decodeOracleEvent = decodeOracleEvent;
|
|
|
9313
9951
|
exports.decodeTimeWindow = decodeTimeWindow;
|
|
9314
9952
|
exports.decodeTxFeedResponse = decodeTxFeedResponse;
|
|
9315
9953
|
exports.delegationAddressHex = delegationAddressHex;
|
|
9954
|
+
exports.denyRootFor = denyRootFor;
|
|
9316
9955
|
exports.deriveClobMarketId = deriveClobMarketId;
|
|
9317
9956
|
exports.deriveClusterAnchorAddress = deriveClusterAnchorAddress;
|
|
9957
|
+
exports.deriveFeedId = deriveFeedId;
|
|
9318
9958
|
exports.deriveMrvContractAddress = deriveMrvContractAddress;
|
|
9319
9959
|
exports.deriveNativeSpotMarketId = deriveNativeSpotMarketId;
|
|
9320
9960
|
exports.deriveNativeSpotOrderId = deriveNativeSpotOrderId;
|
|
9961
|
+
exports.destinationRoot = destinationRoot;
|
|
9962
|
+
exports.encodeAttestDkgReshareCalldata = encodeAttestDkgReshareCalldata;
|
|
9321
9963
|
exports.encodeBlockSelector = encodeBlockSelector;
|
|
9964
|
+
exports.encodeBridgeChallengeCalldata = encodeBridgeChallengeCalldata;
|
|
9965
|
+
exports.encodeBridgeClaimCalldata = encodeBridgeClaimCalldata;
|
|
9322
9966
|
exports.encodeCancelOrderCalldata = encodeCancelOrderCalldata;
|
|
9967
|
+
exports.encodeCancelPendingChangeCalldata = encodeCancelPendingChangeCalldata;
|
|
9323
9968
|
exports.encodeClaimCalldata = encodeClaimCalldata;
|
|
9324
9969
|
exports.encodeClaimPolicyByAddressCalldata = encodeClaimPolicyByAddressCalldata;
|
|
9325
9970
|
exports.encodeCompleteRedemptionCalldata = encodeCompleteRedemptionCalldata;
|
|
@@ -9332,6 +9977,9 @@ exports.encodeHasPubkeyCalldata = encodeHasPubkeyCalldata;
|
|
|
9332
9977
|
exports.encodeLockBridgeConfigCalldata = encodeLockBridgeConfigCalldata;
|
|
9333
9978
|
exports.encodeLookupPubkeyCalldata = encodeLookupPubkeyCalldata;
|
|
9334
9979
|
exports.encodeMrvDeployPayload = encodeMrvDeployPayload;
|
|
9980
|
+
exports.encodeNameAcceptTransferCall = encodeNameAcceptTransferCall;
|
|
9981
|
+
exports.encodeNameProposeTransferCall = encodeNameProposeTransferCall;
|
|
9982
|
+
exports.encodeNameRegisterCall = encodeNameRegisterCall;
|
|
9335
9983
|
exports.encodeNativeAgentAcceptEscrowCall = encodeNativeAgentAcceptEscrowCall;
|
|
9336
9984
|
exports.encodeNativeAgentApproveEscrowCall = encodeNativeAgentApproveEscrowCall;
|
|
9337
9985
|
exports.encodeNativeAgentArbiterGetCall = encodeNativeAgentArbiterGetCall;
|
|
@@ -9381,6 +10029,7 @@ exports.encodePlaceLimitOrderCalldata = encodePlaceLimitOrderCalldata;
|
|
|
9381
10029
|
exports.encodePlaceLimitOrderViaCalldata = encodePlaceLimitOrderViaCalldata;
|
|
9382
10030
|
exports.encodePlaceMarketOrderCalldata = encodePlaceMarketOrderCalldata;
|
|
9383
10031
|
exports.encodePlaceMarketOrderExCalldata = encodePlaceMarketOrderExCalldata;
|
|
10032
|
+
exports.encodeRecoverOperatorNodeCalldata = encodeRecoverOperatorNodeCalldata;
|
|
9384
10033
|
exports.encodeRedelegateCalldata = encodeRedelegateCalldata;
|
|
9385
10034
|
exports.encodeRegisterPubkeyCalldata = encodeRegisterPubkeyCalldata;
|
|
9386
10035
|
exports.encodeReportServiceProbeCalldata = encodeReportServiceProbeCalldata;
|
|
@@ -9392,6 +10041,8 @@ exports.encodeSetMinNotionalCalldata = encodeSetMinNotionalCalldata;
|
|
|
9392
10041
|
exports.encodeSetPolicyCalldata = encodeSetPolicyCalldata;
|
|
9393
10042
|
exports.encodeSetPolicyClaimCalldata = encodeSetPolicyClaimCalldata;
|
|
9394
10043
|
exports.encodeSetTickSizeCalldata = encodeSetTickSizeCalldata;
|
|
10044
|
+
exports.encodeSubmitBridgeProofCalldata = encodeSubmitBridgeProofCalldata;
|
|
10045
|
+
exports.encodeSubmitPendingChangeCalldata = encodeSubmitPendingChangeCalldata;
|
|
9395
10046
|
exports.encodeUndelegateCalldata = encodeUndelegateCalldata;
|
|
9396
10047
|
exports.exportBridgeRouteCatalogueJson = exportBridgeRouteCatalogueJson;
|
|
9397
10048
|
exports.fetchChainInfoLatest = fetchChainInfoLatest;
|
|
@@ -9399,6 +10050,7 @@ exports.fetchChainRegistryLatest = fetchChainRegistryLatest;
|
|
|
9399
10050
|
exports.formatLyth = formatLyth;
|
|
9400
10051
|
exports.formatLythoshi = formatLythoshi;
|
|
9401
10052
|
exports.formatNativeReceiptFeeDisplay = formatNativeReceiptFeeDisplay;
|
|
10053
|
+
exports.formatOraclePrice = formatOraclePrice;
|
|
9402
10054
|
exports.getChainInfo = getChainInfo;
|
|
9403
10055
|
exports.getNoEvmReceiptTrustPolicy = getNoEvmReceiptTrustPolicy;
|
|
9404
10056
|
exports.getP2pSeeds = getP2pSeeds;
|
|
@@ -9419,6 +10071,9 @@ exports.mrvAddressToBech32 = mrvAddressToBech32;
|
|
|
9419
10071
|
exports.mrvBech32ToAddress = mrvBech32ToAddress;
|
|
9420
10072
|
exports.mrvCodeHashHex = mrvCodeHashHex;
|
|
9421
10073
|
exports.mrvV1TransactionExtension = mrvV1TransactionExtension;
|
|
10074
|
+
exports.nameLengthModifierX10 = nameLengthModifierX10;
|
|
10075
|
+
exports.nameRegistrationCost = nameRegistrationCost;
|
|
10076
|
+
exports.nameRegistryAddressHex = nameRegistryAddressHex;
|
|
9422
10077
|
exports.nativeAgentStateFilterParams = nativeAgentStateFilterParams;
|
|
9423
10078
|
exports.nativeDevSchemaFieldNames = nativeDevSchemaFieldNames;
|
|
9424
10079
|
exports.nativeDevUiStrings = nativeDevUiStrings;
|
|
@@ -9436,12 +10091,16 @@ exports.nodeHostingClassToByte = nodeHostingClassToByte;
|
|
|
9436
10091
|
exports.nodeRegistryAddressHex = nodeRegistryAddressHex;
|
|
9437
10092
|
exports.normalizeAddressHex = normalizeAddressHex;
|
|
9438
10093
|
exports.normalizeBridgeRouteCatalogue = normalizeBridgeRouteCatalogue;
|
|
10094
|
+
exports.normalizePendingChangeKind = normalizePendingChangeKind;
|
|
9439
10095
|
exports.oracleAddressHex = oracleAddressHex;
|
|
10096
|
+
exports.oraclePriceToNumber = oraclePriceToNumber;
|
|
9440
10097
|
exports.packTimeWindow = packTimeWindow;
|
|
9441
10098
|
exports.parseAddress = parseAddress;
|
|
9442
10099
|
exports.parseBridgeRouteCatalogueJson = parseBridgeRouteCatalogueJson;
|
|
9443
10100
|
exports.parseChainRegistryToml = parseChainRegistryToml;
|
|
10101
|
+
exports.parseDkgResharePublicKeys = parseDkgResharePublicKeys;
|
|
9444
10102
|
exports.parseLythToLythoshi = parseLythToLythoshi;
|
|
10103
|
+
exports.parseNameCategory = parseNameCategory;
|
|
9445
10104
|
exports.parseNativeDecodedEvent = parseNativeDecodedEvent;
|
|
9446
10105
|
exports.parseQuantity = parseQuantity;
|
|
9447
10106
|
exports.parseQuantityBig = parseQuantityBig;
|
|
@@ -9449,6 +10108,7 @@ exports.proverMarketStateFromByte = proverMarketStateFromByte;
|
|
|
9449
10108
|
exports.pubkeyRegistryAddressHex = pubkeyRegistryAddressHex;
|
|
9450
10109
|
exports.quoteOperatorFee = quoteOperatorFee;
|
|
9451
10110
|
exports.rankBridgeRoutes = rankBridgeRoutes;
|
|
10111
|
+
exports.rankMarketsByVolume = rankMarketsByVolume;
|
|
9452
10112
|
exports.requestSighash = requestSighash;
|
|
9453
10113
|
exports.requireTypedAddress = requireTypedAddress;
|
|
9454
10114
|
exports.resolveExecutionFee = resolveExecutionFee;
|
|
@@ -9457,6 +10117,7 @@ exports.resolveRegistryExecutionFee = resolveRegistryExecutionFee;
|
|
|
9457
10117
|
exports.resolveStudioHostStatus = resolveStudioHostStatus;
|
|
9458
10118
|
exports.selectBridgeTransferRoute = selectBridgeTransferRoute;
|
|
9459
10119
|
exports.serviceProbeStatusLabel = serviceProbeStatusLabel;
|
|
10120
|
+
exports.setDestinationRoot = setDestinationRoot;
|
|
9460
10121
|
exports.spendingPolicyAddressHex = spendingPolicyAddressHex;
|
|
9461
10122
|
exports.submitMrvCallNativeTx = submitMrvCallNativeTx;
|
|
9462
10123
|
exports.submitMrvDeployNativeTx = submitMrvDeployNativeTx;
|