@monolythium/core-sdk 0.3.12 → 0.3.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/dist/crypto/index.d.cts +2 -2
- package/dist/crypto/index.d.ts +2 -2
- package/dist/index.cjs +1169 -229
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +1127 -230
- package/dist/index.js.map +1 -1
- package/dist/{submission-CA8L21An.d.cts → submission-vhPqAwkD.d.cts} +488 -1
- package/dist/{submission-CA8L21An.d.ts → submission-vhPqAwkD.d.ts} +488 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -420,6 +420,14 @@ var SERVICE_PROBE_STATUS = {
|
|
|
420
420
|
UNREACHABLE: 3
|
|
421
421
|
};
|
|
422
422
|
var NODE_REGISTRY_SELECTORS = {
|
|
423
|
+
/** `recoverOperatorNode(bytes32)` — foundation-gated DR alias for `unjail`. */
|
|
424
|
+
recoverOperatorNode: "0x" + selectorHex("recoverOperatorNode(bytes32)"),
|
|
425
|
+
/** `submitPendingChange(uint8,bytes,uint64,uint64)` — foundation-gated roster lifecycle. */
|
|
426
|
+
submitPendingChange: "0x" + selectorHex("submitPendingChange(uint8,bytes,uint64,uint64)"),
|
|
427
|
+
/** `cancelPendingChange(uint64,bytes)` — foundation-gated pending-change cancellation. */
|
|
428
|
+
cancelPendingChange: "0x" + selectorHex("cancelPendingChange(uint64,bytes)"),
|
|
429
|
+
/** `attestDkgReshare(uint64,bytes,bytes)` — operator-signed DKG re-share attestation. */
|
|
430
|
+
attestDkgReshare: "0x" + selectorHex("attestDkgReshare(uint64,bytes,bytes)"),
|
|
423
431
|
reportServiceProbe: "0xeee31bba",
|
|
424
432
|
getServiceProbe: "0x1fcbfbce",
|
|
425
433
|
/** `setNetworkMetadata(bytes32,uint16,bytes3,bytes)` — owner-callable (PF-6). */
|
|
@@ -429,6 +437,21 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
429
437
|
/** `getClusterDiversity(uint32)` view (PF-6). */
|
|
430
438
|
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)")
|
|
431
439
|
};
|
|
440
|
+
var NODE_REGISTRY_BLS_PUBKEY_BYTES = 48;
|
|
441
|
+
var NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = 96;
|
|
442
|
+
var NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = 5;
|
|
443
|
+
var NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS = 7;
|
|
444
|
+
var NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = (1n << 56n) - 1n;
|
|
445
|
+
var PENDING_CHANGE_KIND_CODES = {
|
|
446
|
+
add: 1,
|
|
447
|
+
remove: 2,
|
|
448
|
+
rotate: 3
|
|
449
|
+
};
|
|
450
|
+
var PENDING_CHANGE_KIND_LABELS = {
|
|
451
|
+
1: "add",
|
|
452
|
+
2: "remove",
|
|
453
|
+
3: "rotate"
|
|
454
|
+
};
|
|
432
455
|
var CLUSTER_FORMED_EVENT_SIG = "ClusterFormed(uint32,uint64,address,bytes)";
|
|
433
456
|
var NodeRegistryError = class extends Error {
|
|
434
457
|
constructor(message) {
|
|
@@ -463,6 +486,131 @@ function serviceProbeStatusLabel(status) {
|
|
|
463
486
|
return "unknown";
|
|
464
487
|
}
|
|
465
488
|
}
|
|
489
|
+
function normalizePendingChangeKind(kind) {
|
|
490
|
+
if (typeof kind === "number") {
|
|
491
|
+
const label = PENDING_CHANGE_KIND_LABELS[kind];
|
|
492
|
+
if (!label) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
493
|
+
return { kind: label, kindCode: kind };
|
|
494
|
+
}
|
|
495
|
+
const kindCode = PENDING_CHANGE_KIND_CODES[kind];
|
|
496
|
+
if (!kindCode) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
497
|
+
return { kind, kindCode };
|
|
498
|
+
}
|
|
499
|
+
function encodeRecoverOperatorNodeCalldata(peerId) {
|
|
500
|
+
return bytesToHex(
|
|
501
|
+
concatBytes(
|
|
502
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.recoverOperatorNode),
|
|
503
|
+
expectLength2(toBytes(peerId), 32, "peerId")
|
|
504
|
+
)
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
function encodeSubmitPendingChangeCalldata(args) {
|
|
508
|
+
const { kind, kindCode } = normalizePendingChangeKind(args.kind);
|
|
509
|
+
const targetPubkey = expectLength2(
|
|
510
|
+
toBytes(args.targetPubkey),
|
|
511
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
512
|
+
"targetPubkey"
|
|
513
|
+
);
|
|
514
|
+
const effectiveEpoch = toUint64(args.effectiveEpoch, "effectiveEpoch");
|
|
515
|
+
if (effectiveEpoch === 0n) {
|
|
516
|
+
throw new NodeRegistryError("effectiveEpoch must be greater than zero");
|
|
517
|
+
}
|
|
518
|
+
const intentId = toUint64(args.intentId ?? 0n, "intentId");
|
|
519
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
520
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
521
|
+
}
|
|
522
|
+
if (kind !== "rotate" && intentId !== 0n) {
|
|
523
|
+
throw new NodeRegistryError("only rotate pending changes may carry a non-zero intentId");
|
|
524
|
+
}
|
|
525
|
+
const targetTail = new Uint8Array(32);
|
|
526
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
527
|
+
return bytesToHex(
|
|
528
|
+
concatBytes(
|
|
529
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.submitPendingChange),
|
|
530
|
+
uint8Word(kindCode),
|
|
531
|
+
uint64Word(4n * 32n, "targetPubkeyOffset"),
|
|
532
|
+
uint64Word(effectiveEpoch, "effectiveEpoch"),
|
|
533
|
+
uint64Word(intentId, "intentId"),
|
|
534
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
535
|
+
targetPubkey.slice(0, 32),
|
|
536
|
+
targetTail
|
|
537
|
+
)
|
|
538
|
+
);
|
|
539
|
+
}
|
|
540
|
+
function encodeCancelPendingChangeCalldata(args) {
|
|
541
|
+
const targetPubkey = expectLength2(
|
|
542
|
+
toBytes(args.targetPubkey),
|
|
543
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
544
|
+
"targetPubkey"
|
|
545
|
+
);
|
|
546
|
+
const targetTail = new Uint8Array(32);
|
|
547
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
548
|
+
return bytesToHex(
|
|
549
|
+
concatBytes(
|
|
550
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.cancelPendingChange),
|
|
551
|
+
uint64Word(args.epoch, "epoch"),
|
|
552
|
+
uint64Word(2n * 32n, "targetPubkeyOffset"),
|
|
553
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
554
|
+
targetPubkey.slice(0, 32),
|
|
555
|
+
targetTail
|
|
556
|
+
)
|
|
557
|
+
);
|
|
558
|
+
}
|
|
559
|
+
function parseDkgResharePublicKeys(blsPublicKeys) {
|
|
560
|
+
const keys = toBytes(blsPublicKeys);
|
|
561
|
+
if (keys.length % NODE_REGISTRY_BLS_PUBKEY_BYTES !== 0) {
|
|
562
|
+
throw new NodeRegistryError("blsPublicKeys length must be a multiple of 48 bytes");
|
|
563
|
+
}
|
|
564
|
+
const signerCount = keys.length / NODE_REGISTRY_BLS_PUBKEY_BYTES;
|
|
565
|
+
if (signerCount < NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS || signerCount > NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS) {
|
|
566
|
+
throw new NodeRegistryError(
|
|
567
|
+
`blsPublicKeys must contain ${NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS}..${NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS} signers`
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
const out = [];
|
|
571
|
+
const seen = /* @__PURE__ */ new Set();
|
|
572
|
+
for (let offset = 0; offset < keys.length; offset += NODE_REGISTRY_BLS_PUBKEY_BYTES) {
|
|
573
|
+
const key = keys.slice(offset, offset + NODE_REGISTRY_BLS_PUBKEY_BYTES);
|
|
574
|
+
const keyHex = bytesToHex(key);
|
|
575
|
+
if (seen.has(keyHex)) {
|
|
576
|
+
throw new NodeRegistryError("blsPublicKeys contains a duplicate signer pubkey");
|
|
577
|
+
}
|
|
578
|
+
seen.add(keyHex);
|
|
579
|
+
out.push(key);
|
|
580
|
+
}
|
|
581
|
+
return out;
|
|
582
|
+
}
|
|
583
|
+
function encodeAttestDkgReshareCalldata(args) {
|
|
584
|
+
const intentId = toUint64(args.intentId, "intentId");
|
|
585
|
+
if (intentId === 0n) {
|
|
586
|
+
throw new NodeRegistryError("intentId must be greater than zero");
|
|
587
|
+
}
|
|
588
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
589
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
590
|
+
}
|
|
591
|
+
const publicKeys = concatBytes(...parseDkgResharePublicKeys(args.blsPublicKeys));
|
|
592
|
+
const thresholdSig = expectLength2(
|
|
593
|
+
toBytes(args.thresholdSig),
|
|
594
|
+
NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES,
|
|
595
|
+
"thresholdSig"
|
|
596
|
+
);
|
|
597
|
+
const keysPadded = padToWord(publicKeys);
|
|
598
|
+
const sigPadded = padToWord(thresholdSig);
|
|
599
|
+
const offsetKeys = 3n * 32n;
|
|
600
|
+
const offsetSig = offsetKeys + 32n + BigInt(keysPadded.length);
|
|
601
|
+
return bytesToHex(
|
|
602
|
+
concatBytes(
|
|
603
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.attestDkgReshare),
|
|
604
|
+
uint64Word(intentId, "intentId"),
|
|
605
|
+
uint64Word(offsetKeys, "blsPublicKeysOffset"),
|
|
606
|
+
uint64Word(offsetSig, "thresholdSigOffset"),
|
|
607
|
+
uint64Word(BigInt(publicKeys.length), "blsPublicKeysLength"),
|
|
608
|
+
keysPadded,
|
|
609
|
+
uint64Word(BigInt(thresholdSig.length), "thresholdSigLength"),
|
|
610
|
+
sigPadded
|
|
611
|
+
)
|
|
612
|
+
);
|
|
613
|
+
}
|
|
466
614
|
function encodeReportServiceProbeCalldata(args) {
|
|
467
615
|
if (!isValidPublicServiceProbeMask(args.serviceMask)) {
|
|
468
616
|
throw new NodeRegistryError(
|
|
@@ -622,6 +770,44 @@ function uint8Word(value) {
|
|
|
622
770
|
out[31] = value;
|
|
623
771
|
return out;
|
|
624
772
|
}
|
|
773
|
+
function uint64Word(value, name) {
|
|
774
|
+
const n = toUint64(value, name);
|
|
775
|
+
const out = new Uint8Array(32);
|
|
776
|
+
let rest = n;
|
|
777
|
+
for (let i = 31; i >= 24; i--) {
|
|
778
|
+
out[i] = Number(rest & 0xffn);
|
|
779
|
+
rest >>= 8n;
|
|
780
|
+
}
|
|
781
|
+
return out;
|
|
782
|
+
}
|
|
783
|
+
function toUint64(value, name) {
|
|
784
|
+
let parsed;
|
|
785
|
+
if (typeof value === "bigint") {
|
|
786
|
+
parsed = value;
|
|
787
|
+
} else if (typeof value === "number") {
|
|
788
|
+
if (!Number.isSafeInteger(value)) {
|
|
789
|
+
throw new NodeRegistryError(`${name} must be a safe integer`);
|
|
790
|
+
}
|
|
791
|
+
parsed = BigInt(value);
|
|
792
|
+
} else {
|
|
793
|
+
const trimmed = value.trim();
|
|
794
|
+
if (!/^\d+$/u.test(trimmed)) {
|
|
795
|
+
throw new NodeRegistryError(`${name} must be a decimal uint64`);
|
|
796
|
+
}
|
|
797
|
+
parsed = BigInt(trimmed);
|
|
798
|
+
}
|
|
799
|
+
if (parsed < 0n || parsed > 0xffffffffffffffffn) {
|
|
800
|
+
throw new NodeRegistryError(`${name} must fit uint64`);
|
|
801
|
+
}
|
|
802
|
+
return parsed;
|
|
803
|
+
}
|
|
804
|
+
function padToWord(bytes) {
|
|
805
|
+
const paddedLength = Math.ceil(bytes.length / 32) * 32;
|
|
806
|
+
if (paddedLength === bytes.length) return bytes;
|
|
807
|
+
const out = new Uint8Array(paddedLength);
|
|
808
|
+
out.set(bytes);
|
|
809
|
+
return out;
|
|
810
|
+
}
|
|
625
811
|
function toBytes(value) {
|
|
626
812
|
if (typeof value === "string") {
|
|
627
813
|
return hexToBytes(value);
|
|
@@ -1820,9 +2006,16 @@ var TESTNET_69420 = {
|
|
|
1820
2006
|
network: "testnet-69420",
|
|
1821
2007
|
display_name: "Monolythium Testnet",
|
|
1822
2008
|
description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
|
|
1823
|
-
genesis_hash: "
|
|
1824
|
-
binary_sha: "
|
|
2009
|
+
genesis_hash: "0xe67cf82131fc63e335ce61afeae53299283eaa3a692830a618911aa840245031",
|
|
2010
|
+
binary_sha: "e4697f9b",
|
|
1825
2011
|
rpc: [
|
|
2012
|
+
{
|
|
2013
|
+
url: "http://178.105.12.9:8545",
|
|
2014
|
+
provider: "monolythium-foundation",
|
|
2015
|
+
region: "fsn1",
|
|
2016
|
+
tier: "official",
|
|
2017
|
+
notes: "operator-1"
|
|
2018
|
+
},
|
|
1826
2019
|
{
|
|
1827
2020
|
url: "http://178.105.15.216:8545",
|
|
1828
2021
|
provider: "monolythium-foundation",
|
|
@@ -1864,9 +2057,107 @@ var TESTNET_69420 = {
|
|
|
1864
2057
|
region: "sin",
|
|
1865
2058
|
tier: "official",
|
|
1866
2059
|
notes: "operator-7; APAC"
|
|
2060
|
+
},
|
|
2061
|
+
{
|
|
2062
|
+
url: "http://142.132.180.99:8545",
|
|
2063
|
+
provider: "monolythium-foundation",
|
|
2064
|
+
region: "fsn1",
|
|
2065
|
+
tier: "official",
|
|
2066
|
+
notes: "operator-8"
|
|
2067
|
+
},
|
|
2068
|
+
{
|
|
2069
|
+
url: "http://162.55.54.198:8545",
|
|
2070
|
+
provider: "monolythium-foundation",
|
|
2071
|
+
region: "nbg1",
|
|
2072
|
+
tier: "official",
|
|
2073
|
+
notes: "operator-9"
|
|
2074
|
+
},
|
|
2075
|
+
{
|
|
2076
|
+
url: "http://95.217.156.190:8545",
|
|
2077
|
+
provider: "monolythium-foundation",
|
|
2078
|
+
region: "hel1",
|
|
2079
|
+
tier: "official",
|
|
2080
|
+
notes: "operator-10"
|
|
2081
|
+
},
|
|
2082
|
+
{
|
|
2083
|
+
url: "http://5.223.65.201:8545",
|
|
2084
|
+
provider: "monolythium-foundation",
|
|
2085
|
+
region: "sin",
|
|
2086
|
+
tier: "official",
|
|
2087
|
+
notes: "operator-11; APAC"
|
|
2088
|
+
},
|
|
2089
|
+
{
|
|
2090
|
+
url: "http://128.140.125.5:8545",
|
|
2091
|
+
provider: "monolythium-foundation",
|
|
2092
|
+
region: "fsn1",
|
|
2093
|
+
tier: "official",
|
|
2094
|
+
notes: "operator-12"
|
|
2095
|
+
},
|
|
2096
|
+
{
|
|
2097
|
+
url: "http://178.105.45.210:8545",
|
|
2098
|
+
provider: "monolythium-foundation",
|
|
2099
|
+
region: "nbg1",
|
|
2100
|
+
tier: "official",
|
|
2101
|
+
notes: "relay-1"
|
|
2102
|
+
},
|
|
2103
|
+
{
|
|
2104
|
+
url: "http://65.21.252.34:8545",
|
|
2105
|
+
provider: "monolythium-foundation",
|
|
2106
|
+
region: "hel1",
|
|
2107
|
+
tier: "official",
|
|
2108
|
+
notes: "relay-2"
|
|
1867
2109
|
}
|
|
1868
2110
|
],
|
|
1869
|
-
p2p: [
|
|
2111
|
+
p2p: [
|
|
2112
|
+
{
|
|
2113
|
+
multiaddr: "/ip4/178.105.12.9/tcp/29898/p2p/12D3KooWPv4ctqZX9faHicr8dJifyBwrpPA4oBev7w2WZStejMKa",
|
|
2114
|
+
region: "fsn1"
|
|
2115
|
+
},
|
|
2116
|
+
{
|
|
2117
|
+
multiaddr: "/ip4/178.105.15.216/tcp/29898/p2p/12D3KooWFZqKgAbve2dsAm9kKomychF4dyhtJYHL13mzh3D62d1r",
|
|
2118
|
+
region: "fsn1"
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
multiaddr: "/ip4/178.104.233.182/tcp/29898/p2p/12D3KooWMG1tbP4hcvqdPP8QmnnPjaJCs4M1GUskzAJsL15ZFcVX",
|
|
2122
|
+
region: "nbg1"
|
|
2123
|
+
},
|
|
2124
|
+
{
|
|
2125
|
+
multiaddr: "/ip4/65.108.94.1/tcp/29898/p2p/12D3KooWR5cz3fR4YkDDoPmQ6Qe7fmsXA7zo5AqdHY5Enmk5bKyT",
|
|
2126
|
+
region: "hel1"
|
|
2127
|
+
},
|
|
2128
|
+
{
|
|
2129
|
+
multiaddr: "/ip4/95.216.154.155/tcp/29898/p2p/12D3KooWFJHH3zgAaPtSBXPkCEKeGNCWQTn1QYcm4YCr5VFT3GbC",
|
|
2130
|
+
region: "hel1"
|
|
2131
|
+
},
|
|
2132
|
+
{
|
|
2133
|
+
multiaddr: "/ip4/87.99.145.48/tcp/29898/p2p/12D3KooWSDQdjgoiEbvsLErphM52u8tETdBtgyr4mbHQC5pT6HQz",
|
|
2134
|
+
region: "ash"
|
|
2135
|
+
},
|
|
2136
|
+
{
|
|
2137
|
+
multiaddr: "/ip4/5.223.85.76/tcp/29898/p2p/12D3KooWKHgMQnBtSfZqUknJdhGK8niKKbLXy81ifHV2khRgAYFX",
|
|
2138
|
+
region: "sin"
|
|
2139
|
+
},
|
|
2140
|
+
{
|
|
2141
|
+
multiaddr: "/ip4/142.132.180.99/tcp/29898/p2p/12D3KooWBx29V8iNQL22jk2CSVbvhodtXy4uTXVG7AgobxNcUuyP",
|
|
2142
|
+
region: "fsn1"
|
|
2143
|
+
},
|
|
2144
|
+
{
|
|
2145
|
+
multiaddr: "/ip4/162.55.54.198/tcp/29898/p2p/12D3KooWJK2w6xzRFJMHWMxVuXpBHZE7PtDNGahEp9rq86AuhNRk",
|
|
2146
|
+
region: "nbg1"
|
|
2147
|
+
},
|
|
2148
|
+
{
|
|
2149
|
+
multiaddr: "/ip4/95.217.156.190/tcp/29898/p2p/12D3KooWLD8kzKHPVexZv2pMTvpjcEPTVZxr5qMxCeVB2QR6NNa6",
|
|
2150
|
+
region: "hel1"
|
|
2151
|
+
},
|
|
2152
|
+
{
|
|
2153
|
+
multiaddr: "/ip4/5.223.65.201/tcp/29898/p2p/12D3KooWAHC1cCiVsyVqrg4ofS2EQmu6Pv6G9Rc1t5btmoW6YicJ",
|
|
2154
|
+
region: "sin"
|
|
2155
|
+
},
|
|
2156
|
+
{
|
|
2157
|
+
multiaddr: "/ip4/128.140.125.5/tcp/29898/p2p/12D3KooWNAc4EWkWWprKvqoF5aiq1ByqsLQjSN7r9ZTwYgGW365r",
|
|
2158
|
+
region: "fsn1"
|
|
2159
|
+
}
|
|
2160
|
+
]
|
|
1870
2161
|
};
|
|
1871
2162
|
var CHAIN_REGISTRY = {
|
|
1872
2163
|
"testnet-69420": TESTNET_69420
|
|
@@ -2323,6 +2614,192 @@ function encodeBlockSelector(b) {
|
|
|
2323
2614
|
if (typeof b === "bigint") return `0x${b.toString(16)}`;
|
|
2324
2615
|
return b;
|
|
2325
2616
|
}
|
|
2617
|
+
var NameRegistryError = class extends Error {
|
|
2618
|
+
constructor(message) {
|
|
2619
|
+
super(message);
|
|
2620
|
+
this.name = "NameRegistryError";
|
|
2621
|
+
}
|
|
2622
|
+
};
|
|
2623
|
+
var NAME_REGISTRY_SELECTORS = {
|
|
2624
|
+
register: selectorHex2("register(string,address)"),
|
|
2625
|
+
proposeTransfer: selectorHex2("proposeTransfer(string,address)"),
|
|
2626
|
+
acceptTransfer: selectorHex2("acceptTransfer(string)")
|
|
2627
|
+
};
|
|
2628
|
+
var NAME_BASE_MULTIPLIER = {
|
|
2629
|
+
human: 5,
|
|
2630
|
+
agent: 2,
|
|
2631
|
+
cluster: 20,
|
|
2632
|
+
contract: 10
|
|
2633
|
+
};
|
|
2634
|
+
var NAME_FALLBACK_FEE_UNIT_LYTHOSHI = 100n;
|
|
2635
|
+
var NAME_MAX_LEN = 80;
|
|
2636
|
+
var NAME_LABEL_MIN_LEN = 1;
|
|
2637
|
+
var NAME_LABEL_MAX_LEN = 63;
|
|
2638
|
+
function nameRegistryAddressHex() {
|
|
2639
|
+
return PRECOMPILE_ADDRESSES.NAME_REGISTRY.toLowerCase();
|
|
2640
|
+
}
|
|
2641
|
+
function nameLengthModifierX10(labelLen) {
|
|
2642
|
+
if (labelLen === 1) return 1e3;
|
|
2643
|
+
if (labelLen === 2) return 500;
|
|
2644
|
+
if (labelLen === 3) return 100;
|
|
2645
|
+
if (labelLen === 4) return 50;
|
|
2646
|
+
if (labelLen === 5) return 30;
|
|
2647
|
+
if (labelLen >= 6 && labelLen <= 12) return 10;
|
|
2648
|
+
if (labelLen >= 13 && labelLen <= 20) return 15;
|
|
2649
|
+
if (labelLen >= 21 && labelLen <= 32) return 30;
|
|
2650
|
+
if (labelLen >= 33 && labelLen <= 50) return 100;
|
|
2651
|
+
if (labelLen >= 51 && labelLen <= 63) return 500;
|
|
2652
|
+
return null;
|
|
2653
|
+
}
|
|
2654
|
+
function parseNameCategory(name) {
|
|
2655
|
+
if (name.length === 0) throw new NameRegistryError("name is empty");
|
|
2656
|
+
if (name.length > NAME_MAX_LEN) throw new NameRegistryError(`name exceeds ${NAME_MAX_LEN} chars`);
|
|
2657
|
+
const parts = name.split(".");
|
|
2658
|
+
if (parts.some((p) => p.length === 0)) {
|
|
2659
|
+
throw new NameRegistryError("name has an empty label");
|
|
2660
|
+
}
|
|
2661
|
+
for (const label of parts) validateLabel(label);
|
|
2662
|
+
if (parts[parts.length - 1] !== "mono") {
|
|
2663
|
+
throw new NameRegistryError("name must end with .mono");
|
|
2664
|
+
}
|
|
2665
|
+
const primaryLabelLen = parts[0].length;
|
|
2666
|
+
switch (parts.length) {
|
|
2667
|
+
case 2:
|
|
2668
|
+
if (STRUCTURAL_RESERVES.has(parts[0])) {
|
|
2669
|
+
throw new NameRegistryError(`"${parts[0]}.mono" is a structural reserve`);
|
|
2670
|
+
}
|
|
2671
|
+
return { category: "human", primaryLabelLen };
|
|
2672
|
+
case 3: {
|
|
2673
|
+
const anchor = parts[1];
|
|
2674
|
+
if (anchor === "cluster") return { category: "cluster", primaryLabelLen };
|
|
2675
|
+
if (anchor === "contract") return { category: "contract", primaryLabelLen };
|
|
2676
|
+
if (anchor === "system") return { category: "system", primaryLabelLen };
|
|
2677
|
+
throw new NameRegistryError(`unknown name category anchor ".${anchor}.mono"`);
|
|
2678
|
+
}
|
|
2679
|
+
case 4:
|
|
2680
|
+
if (parts[1] !== "agent") {
|
|
2681
|
+
throw new NameRegistryError("unknown 4-label name form (expected <x>.agent.<human>.mono)");
|
|
2682
|
+
}
|
|
2683
|
+
return { category: "agent", primaryLabelLen };
|
|
2684
|
+
default:
|
|
2685
|
+
throw new NameRegistryError("unrecognised name structure");
|
|
2686
|
+
}
|
|
2687
|
+
}
|
|
2688
|
+
function nameRegistrationCost(category, primaryLabelLen, feeUnitLythoshi) {
|
|
2689
|
+
if (category === "system") {
|
|
2690
|
+
throw new NameRegistryError("system names are not registerable via this path");
|
|
2691
|
+
}
|
|
2692
|
+
const base = BigInt(NAME_BASE_MULTIPLIER[category]);
|
|
2693
|
+
const modX10 = nameLengthModifierX10(primaryLabelLen);
|
|
2694
|
+
if (modX10 === null) {
|
|
2695
|
+
throw new NameRegistryError("primary label length is outside the priceable 1..=63 range");
|
|
2696
|
+
}
|
|
2697
|
+
return base * BigInt(modX10) * feeUnitLythoshi / 10n;
|
|
2698
|
+
}
|
|
2699
|
+
function encodeNameRegisterCall(name, owner) {
|
|
2700
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.register, name, owner);
|
|
2701
|
+
}
|
|
2702
|
+
function encodeNameProposeTransferCall(name, recipient) {
|
|
2703
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.proposeTransfer, name, recipient);
|
|
2704
|
+
}
|
|
2705
|
+
function encodeNameAcceptTransferCall(name) {
|
|
2706
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2707
|
+
return bytesToHex4(
|
|
2708
|
+
concatBytes4(
|
|
2709
|
+
hexToBytes4(NAME_REGISTRY_SELECTORS.acceptTransfer),
|
|
2710
|
+
// Single head word → the string offset is 0x20 (one word precedes the tail).
|
|
2711
|
+
uint256Word(0x20n),
|
|
2712
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2713
|
+
padTo32(nameBytes)
|
|
2714
|
+
)
|
|
2715
|
+
);
|
|
2716
|
+
}
|
|
2717
|
+
var STRUCTURAL_RESERVES = /* @__PURE__ */ new Set(["agent", "cluster", "contract", "system"]);
|
|
2718
|
+
function encodeStringAddressCall(selector, name, address) {
|
|
2719
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2720
|
+
return bytesToHex4(
|
|
2721
|
+
concatBytes4(
|
|
2722
|
+
hexToBytes4(selector),
|
|
2723
|
+
// Two head words (string offset, address) → string tail starts at 0x40.
|
|
2724
|
+
uint256Word(0x40n),
|
|
2725
|
+
addressWord(address),
|
|
2726
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2727
|
+
padTo32(nameBytes)
|
|
2728
|
+
)
|
|
2729
|
+
);
|
|
2730
|
+
}
|
|
2731
|
+
function validateLabel(label) {
|
|
2732
|
+
if (label.length < NAME_LABEL_MIN_LEN || label.length > NAME_LABEL_MAX_LEN) {
|
|
2733
|
+
throw new NameRegistryError(`label "${label}" must be ${NAME_LABEL_MIN_LEN}..${NAME_LABEL_MAX_LEN} chars`);
|
|
2734
|
+
}
|
|
2735
|
+
if (label.startsWith("-") || label.endsWith("-")) {
|
|
2736
|
+
throw new NameRegistryError(`label "${label}" may not start or end with a hyphen`);
|
|
2737
|
+
}
|
|
2738
|
+
if (label.includes("--")) {
|
|
2739
|
+
throw new NameRegistryError(`label "${label}" may not contain a double hyphen`);
|
|
2740
|
+
}
|
|
2741
|
+
if (!/^[a-z0-9-]+$/.test(label)) {
|
|
2742
|
+
throw new NameRegistryError(`label "${label}" has an invalid char (allowed: a-z 0-9 -)`);
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
function selectorHex2(signature) {
|
|
2746
|
+
const sel = keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
2747
|
+
return `0x${[...sel].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2748
|
+
}
|
|
2749
|
+
function addressWord(value) {
|
|
2750
|
+
const out = new Uint8Array(32);
|
|
2751
|
+
if (value == null) return out;
|
|
2752
|
+
const bytes = toBytes2(value);
|
|
2753
|
+
if (bytes.length !== 20) {
|
|
2754
|
+
throw new NameRegistryError(`address must be 20 bytes, got ${bytes.length}`);
|
|
2755
|
+
}
|
|
2756
|
+
out.set(bytes, 12);
|
|
2757
|
+
return out;
|
|
2758
|
+
}
|
|
2759
|
+
function uint256Word(value) {
|
|
2760
|
+
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
2761
|
+
throw new NameRegistryError("uint256 word out of range");
|
|
2762
|
+
}
|
|
2763
|
+
const out = new Uint8Array(32);
|
|
2764
|
+
let rest = value;
|
|
2765
|
+
for (let i = 31; i >= 0 && rest > 0n; i--) {
|
|
2766
|
+
out[i] = Number(rest & 0xffn);
|
|
2767
|
+
rest >>= 8n;
|
|
2768
|
+
}
|
|
2769
|
+
return out;
|
|
2770
|
+
}
|
|
2771
|
+
function padTo32(bytes) {
|
|
2772
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
2773
|
+
if (padded === bytes.length) return bytes;
|
|
2774
|
+
const out = new Uint8Array(padded);
|
|
2775
|
+
out.set(bytes);
|
|
2776
|
+
return out;
|
|
2777
|
+
}
|
|
2778
|
+
function toBytes2(value) {
|
|
2779
|
+
if (typeof value === "string") return hexToBytes4(value);
|
|
2780
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
2781
|
+
}
|
|
2782
|
+
function hexToBytes4(hex) {
|
|
2783
|
+
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
2784
|
+
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
2785
|
+
throw new NameRegistryError("invalid hex bytes");
|
|
2786
|
+
}
|
|
2787
|
+
const out = new Uint8Array(body.length / 2);
|
|
2788
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(body.slice(i * 2, i * 2 + 2), 16);
|
|
2789
|
+
return out;
|
|
2790
|
+
}
|
|
2791
|
+
function bytesToHex4(bytes) {
|
|
2792
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2793
|
+
}
|
|
2794
|
+
function concatBytes4(...parts) {
|
|
2795
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
2796
|
+
let offset = 0;
|
|
2797
|
+
for (const part of parts) {
|
|
2798
|
+
out.set(part, offset);
|
|
2799
|
+
offset += part.length;
|
|
2800
|
+
}
|
|
2801
|
+
return out;
|
|
2802
|
+
}
|
|
2326
2803
|
|
|
2327
2804
|
// src/client.ts
|
|
2328
2805
|
var MAX_NATIVE_RECEIPT_EVENTS = 1e3;
|
|
@@ -3160,7 +3637,234 @@ var RpcClient = class _RpcClient {
|
|
|
3160
3637
|
async meshSubmitTx(signedTx) {
|
|
3161
3638
|
return this.call("mesh_submitTx", [signedTx]);
|
|
3162
3639
|
}
|
|
3640
|
+
// ---- lyth_* additions (R15 / wallet + monoscan surfaces) -----------
|
|
3641
|
+
/**
|
|
3642
|
+
* `lyth_clusterApr` — observed APR for a cluster over a rolling window.
|
|
3643
|
+
* `windowBlocks` defaults to the chain's 1200-block (~1h) window and is
|
|
3644
|
+
* server-clamped to `[10, 86_400]`.
|
|
3645
|
+
*/
|
|
3646
|
+
async lythClusterApr(clusterId, windowBlocks) {
|
|
3647
|
+
const params = windowBlocks === void 0 ? [clusterId] : [clusterId, windowBlocks];
|
|
3648
|
+
return normalizeClusterApr(await this.call("lyth_clusterApr", params));
|
|
3649
|
+
}
|
|
3650
|
+
/** `lyth_resolveName` — forward name → address resolution (0x110E). */
|
|
3651
|
+
async lythResolveName(name, block = "latest") {
|
|
3652
|
+
return this.call("lyth_resolveName", [name, encodeBlockSelector(block)]);
|
|
3653
|
+
}
|
|
3654
|
+
/** `lyth_nameOf` — reverse address → name resolution. */
|
|
3655
|
+
async lythNameOf(address, block = "latest") {
|
|
3656
|
+
return this.call("lyth_nameOf", [sdkTypedAddress(address, "user", "address"), encodeBlockSelector(block)]);
|
|
3657
|
+
}
|
|
3658
|
+
/** `lyth_getClusterName` — reverse cluster id → canonical name. */
|
|
3659
|
+
async lythGetClusterName(clusterId, block = "latest") {
|
|
3660
|
+
return this.call("lyth_getClusterName", [clusterId, encodeBlockSelector(block)]);
|
|
3661
|
+
}
|
|
3662
|
+
/**
|
|
3663
|
+
* Convenience over {@link lythResolveName}: `true` when a well-formed
|
|
3664
|
+
* name is unregistered. A malformed name throws `RpcError`
|
|
3665
|
+
* (`InvalidParams`) rather than returning `true`, so the UI should treat
|
|
3666
|
+
* a thrown validation error distinctly from "taken".
|
|
3667
|
+
*/
|
|
3668
|
+
async lythIsNameAvailable(name, block = "latest") {
|
|
3669
|
+
const resolved = await this.lythResolveName(name, block);
|
|
3670
|
+
return resolved.address === null;
|
|
3671
|
+
}
|
|
3672
|
+
/**
|
|
3673
|
+
* Live name-registration quote: parses the name's category + primary
|
|
3674
|
+
* label length, reads the chain's base fee unit via `eth_feeHistory`
|
|
3675
|
+
* (the bare `baseFeePerGas` — NOT `eth_gasPrice`, which adds the tip and
|
|
3676
|
+
* would over-quote), and applies the U-curve. The resulting
|
|
3677
|
+
* `costLythoshi` is what the `register` tx `value` must equal exactly
|
|
3678
|
+
* (else the precompile reverts `IncorrectFee`).
|
|
3679
|
+
*/
|
|
3680
|
+
async quoteNameRegistration(name, block = "latest") {
|
|
3681
|
+
const parsed = parseNameCategory(name);
|
|
3682
|
+
const history = await this.ethFeeHistory(1, block, []);
|
|
3683
|
+
const baseFees = history.baseFeePerGas ?? [];
|
|
3684
|
+
const lastHex = baseFees.length > 0 ? baseFees[baseFees.length - 1] : "0x0";
|
|
3685
|
+
const baseFee = parseQuantityBig(lastHex);
|
|
3686
|
+
const feeUnitLythoshi = baseFee > 0n ? baseFee : NAME_FALLBACK_FEE_UNIT_LYTHOSHI;
|
|
3687
|
+
return {
|
|
3688
|
+
name,
|
|
3689
|
+
category: parsed.category,
|
|
3690
|
+
primaryLabelLen: parsed.primaryLabelLen,
|
|
3691
|
+
feeUnitLythoshi,
|
|
3692
|
+
costLythoshi: nameRegistrationCost(parsed.category, parsed.primaryLabelLen, feeUnitLythoshi)
|
|
3693
|
+
};
|
|
3694
|
+
}
|
|
3695
|
+
/** `lyth_circulatingSupply` — native LYTH circulating / initial / burned (decimal lythoshi strings). */
|
|
3696
|
+
async lythCirculatingSupply() {
|
|
3697
|
+
return this.call("lyth_circulatingSupply", []);
|
|
3698
|
+
}
|
|
3699
|
+
/** `lyth_totalBurned` — cumulative burned native LYTH (decimal lythoshi string). */
|
|
3700
|
+
async lythTotalBurned() {
|
|
3701
|
+
return this.call("lyth_totalBurned", []);
|
|
3702
|
+
}
|
|
3703
|
+
/** `lyth_swapIntentStatus` — bridge swap-intent / DKG-reshare lifecycle for one intent id. */
|
|
3704
|
+
async lythSwapIntentStatus(intentId) {
|
|
3705
|
+
let id;
|
|
3706
|
+
if (typeof intentId === "number") {
|
|
3707
|
+
id = intentId;
|
|
3708
|
+
} else if (typeof intentId === "bigint") {
|
|
3709
|
+
id = `0x${intentId.toString(16)}`;
|
|
3710
|
+
} else if (intentId.startsWith("0x") || intentId.startsWith("0X")) {
|
|
3711
|
+
id = intentId;
|
|
3712
|
+
} else {
|
|
3713
|
+
id = `0x${BigInt(intentId).toString(16)}`;
|
|
3714
|
+
}
|
|
3715
|
+
return this.call("lyth_swapIntentStatus", [id]);
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Per-tx confirmation depth, derived from `lyth_txStatus` (which returns
|
|
3719
|
+
* both the tx's `blockNumber` and the node `latestHeight`).
|
|
3720
|
+
*/
|
|
3721
|
+
async lythTxConfirmations(txHash) {
|
|
3722
|
+
const status = await this.lythTxStatus(txHash);
|
|
3723
|
+
if (status.status === "found") {
|
|
3724
|
+
return {
|
|
3725
|
+
status: "found",
|
|
3726
|
+
confirmations: status.latestHeight - status.blockNumber + 1,
|
|
3727
|
+
blockNumber: status.blockNumber,
|
|
3728
|
+
latestHeight: status.latestHeight
|
|
3729
|
+
};
|
|
3730
|
+
}
|
|
3731
|
+
return {
|
|
3732
|
+
status: "not_found",
|
|
3733
|
+
confirmations: null,
|
|
3734
|
+
blockNumber: null,
|
|
3735
|
+
latestHeight: status.latestHeight
|
|
3736
|
+
};
|
|
3737
|
+
}
|
|
3738
|
+
/**
|
|
3739
|
+
* Resolve a user-pasted MRC token id to its metadata (name/symbol/
|
|
3740
|
+
* decimals), for an "add custom token" flow. Returns `null` for an
|
|
3741
|
+
* unknown/untracked id. Performs light client-side format validation
|
|
3742
|
+
* (32-byte hex) for fast UX feedback; the chain re-validates regardless.
|
|
3743
|
+
*/
|
|
3744
|
+
async lythResolveTokenMetadata(rawTokenId) {
|
|
3745
|
+
const body = rawTokenId.startsWith("0x") || rawTokenId.startsWith("0X") ? rawTokenId.slice(2) : rawTokenId;
|
|
3746
|
+
if (!/^[0-9a-fA-F]{64}$/.test(body)) {
|
|
3747
|
+
throw SdkError.malformed("token id must be 32 bytes (64 hex chars)");
|
|
3748
|
+
}
|
|
3749
|
+
return (await this.lythMrcMetadata(rawTokenId)).metadata;
|
|
3750
|
+
}
|
|
3751
|
+
/**
|
|
3752
|
+
* `lyth_getTokenBalances` joined with per-token MRC metadata. Balances
|
|
3753
|
+
* are PUBLIC-only by construction (private-denomination balances are
|
|
3754
|
+
* excluded by the chain). Raw `balance` strings are preserved (apply
|
|
3755
|
+
* `metadata.decimals` client-side for display).
|
|
3756
|
+
*/
|
|
3757
|
+
async lythGetTokenBalancesWithMetadata(address) {
|
|
3758
|
+
const rows = await this.lythGetTokenBalances(address);
|
|
3759
|
+
const keyFor = (row) => {
|
|
3760
|
+
const assetId = row.mrc?.assetId ?? row.tokenId;
|
|
3761
|
+
const tokenId = row.mrc?.tokenId ?? null;
|
|
3762
|
+
return { assetId, tokenId, key: `${assetId}:${tokenId ?? ""}` };
|
|
3763
|
+
};
|
|
3764
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
3765
|
+
for (const row of rows) {
|
|
3766
|
+
const k = keyFor(row);
|
|
3767
|
+
if (!distinct.has(k.key)) distinct.set(k.key, { assetId: k.assetId, tokenId: k.tokenId });
|
|
3768
|
+
}
|
|
3769
|
+
const metaByKey = /* @__PURE__ */ new Map();
|
|
3770
|
+
await Promise.all(
|
|
3771
|
+
[...distinct.entries()].map(async ([key, { assetId, tokenId }]) => {
|
|
3772
|
+
const resp = await this.lythMrcMetadata(assetId, tokenId);
|
|
3773
|
+
metaByKey.set(key, resp.metadata);
|
|
3774
|
+
})
|
|
3775
|
+
);
|
|
3776
|
+
return rows.map((row) => ({ ...row, metadata: metaByKey.get(keyFor(row).key) ?? null }));
|
|
3777
|
+
}
|
|
3778
|
+
/**
|
|
3779
|
+
* Resolve a CLOB market's base/quote asset metadata (symbol/name/
|
|
3780
|
+
* decimals) by joining `lyth_clobMarket` to `lyth_mrcMetadata`. Either
|
|
3781
|
+
* side may be `null` when the indexer has no MRC row (e.g. native LYTH).
|
|
3782
|
+
*/
|
|
3783
|
+
async resolveClobMarketAssets(marketId) {
|
|
3784
|
+
const response = await this.lythClobMarket(marketId);
|
|
3785
|
+
const market = response.market;
|
|
3786
|
+
if (!market) return { base: null, quote: null };
|
|
3787
|
+
const [base, quote] = await Promise.all([
|
|
3788
|
+
this.lythMrcMetadata(market.baseToken).then((m) => m.metadata),
|
|
3789
|
+
this.lythMrcMetadata(market.quoteToken).then((m) => m.metadata)
|
|
3790
|
+
]);
|
|
3791
|
+
return { base, quote };
|
|
3792
|
+
}
|
|
3793
|
+
/**
|
|
3794
|
+
* `lyth_getAddressActivity` enriched with each row's block timestamp,
|
|
3795
|
+
* canonical tx hash (resolved from `(blockHeight, txIndex)`), and
|
|
3796
|
+
* resolved cluster name. Issues one block read per distinct height and
|
|
3797
|
+
* one name read per distinct cluster.
|
|
3798
|
+
*/
|
|
3799
|
+
async enrichAddressActivity(address, limit = 50, cursor) {
|
|
3800
|
+
const entries = await this.lythGetAddressActivity(address, limit, cursor);
|
|
3801
|
+
const heights = [...new Set(entries.map((entry) => BigInt(entry.blockHeight)))];
|
|
3802
|
+
const blockByHeight = /* @__PURE__ */ new Map();
|
|
3803
|
+
await Promise.all(
|
|
3804
|
+
heights.map(async (height) => {
|
|
3805
|
+
blockByHeight.set(height, await this.blockTimeAndTxHashes(height));
|
|
3806
|
+
})
|
|
3807
|
+
);
|
|
3808
|
+
const clusters = [
|
|
3809
|
+
...new Set(entries.map((entry) => entry.cluster).filter((c) => c != null))
|
|
3810
|
+
];
|
|
3811
|
+
const nameByCluster = /* @__PURE__ */ new Map();
|
|
3812
|
+
await Promise.all(
|
|
3813
|
+
clusters.map(async (clusterId) => {
|
|
3814
|
+
nameByCluster.set(clusterId, (await this.lythGetClusterName(clusterId)).name);
|
|
3815
|
+
})
|
|
3816
|
+
);
|
|
3817
|
+
return entries.map((entry) => {
|
|
3818
|
+
const block = blockByHeight.get(BigInt(entry.blockHeight));
|
|
3819
|
+
const txHash = block && entry.txIndex >= 0 && entry.txIndex < block.txHashes.length ? block.txHashes[entry.txIndex] : null;
|
|
3820
|
+
return {
|
|
3821
|
+
...entry,
|
|
3822
|
+
blockTimestampSeconds: block?.timestampSeconds ?? null,
|
|
3823
|
+
txHash,
|
|
3824
|
+
clusterName: entry.cluster != null ? nameByCluster.get(entry.cluster) ?? null : null
|
|
3825
|
+
};
|
|
3826
|
+
});
|
|
3827
|
+
}
|
|
3828
|
+
/**
|
|
3829
|
+
* Read a block's header timestamp (UNIX seconds) and ordered tx-hash
|
|
3830
|
+
* array via the raw `eth_getBlockByNumber` (hash-only mode). The typed
|
|
3831
|
+
* `ethGetBlockByNumber` wrapper drops the `transactions` array, so this
|
|
3832
|
+
* uses the raw call.
|
|
3833
|
+
*/
|
|
3834
|
+
async blockTimeAndTxHashes(height) {
|
|
3835
|
+
const hexHeight = `0x${height.toString(16)}`;
|
|
3836
|
+
const raw = await this.call("eth_getBlockByNumber", [
|
|
3837
|
+
hexHeight,
|
|
3838
|
+
false
|
|
3839
|
+
]);
|
|
3840
|
+
if (!raw || typeof raw !== "object") return { timestampSeconds: null, txHashes: [] };
|
|
3841
|
+
const ts = raw["timestamp"];
|
|
3842
|
+
const timestampSeconds = ts === null || ts === void 0 ? null : parseRpcBigint(ts, "block timestamp");
|
|
3843
|
+
const txs = raw["transactions"];
|
|
3844
|
+
const txHashes = Array.isArray(txs) ? txs.filter((t) => typeof t === "string") : [];
|
|
3845
|
+
return { timestampSeconds, txHashes };
|
|
3846
|
+
}
|
|
3163
3847
|
};
|
|
3848
|
+
function clusterApyPercent(apr) {
|
|
3849
|
+
return Number(apr.aprBps) / 100;
|
|
3850
|
+
}
|
|
3851
|
+
function computeQuoteLiquidity(book) {
|
|
3852
|
+
const sumQuote = (levels) => levels.reduce((acc, level) => acc + BigInt(level.price) * BigInt(level.size), 0n);
|
|
3853
|
+
const bidQuote = sumQuote(book.bids);
|
|
3854
|
+
const askQuote = sumQuote(book.asks);
|
|
3855
|
+
return {
|
|
3856
|
+
bidQuote: bidQuote.toString(10),
|
|
3857
|
+
askQuote: askQuote.toString(10),
|
|
3858
|
+
totalQuote: (bidQuote + askQuote).toString(10)
|
|
3859
|
+
};
|
|
3860
|
+
}
|
|
3861
|
+
function rankMarketsByVolume(markets) {
|
|
3862
|
+
return [...markets].sort((a, b) => {
|
|
3863
|
+
const av = BigInt(a.totalVolumeBase);
|
|
3864
|
+
const bv = BigInt(b.totalVolumeBase);
|
|
3865
|
+
return av < bv ? 1 : av > bv ? -1 : 0;
|
|
3866
|
+
}).map((market, index) => ({ ...market, volumeRank: index + 1 }));
|
|
3867
|
+
}
|
|
3164
3868
|
function parseQuantityBig(hex) {
|
|
3165
3869
|
if (!hex) return 0n;
|
|
3166
3870
|
const rest = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
@@ -3815,6 +4519,29 @@ function normalizeRoundInfo(value) {
|
|
|
3815
4519
|
height: parseRpcBigint(row["height"], "round height")
|
|
3816
4520
|
};
|
|
3817
4521
|
}
|
|
4522
|
+
function normalizeClusterApr(value) {
|
|
4523
|
+
if (!value || typeof value !== "object") {
|
|
4524
|
+
throw SdkError.malformed("cluster apr must be an object");
|
|
4525
|
+
}
|
|
4526
|
+
const row = value;
|
|
4527
|
+
const blocks = row["blocks"] ?? {};
|
|
4528
|
+
return {
|
|
4529
|
+
clusterId: parseRpcNumber(row["clusterId"], "clusterId"),
|
|
4530
|
+
blocks: {
|
|
4531
|
+
from: parseRpcBigint(blocks["from"], "blocks.from"),
|
|
4532
|
+
to: parseRpcBigint(blocks["to"], "blocks.to"),
|
|
4533
|
+
window: parseRpcBigint(blocks["window"], "blocks.window")
|
|
4534
|
+
},
|
|
4535
|
+
rewardIndexFromHex: parseStringField(row["rewardIndexFromHex"], "rewardIndexFromHex"),
|
|
4536
|
+
rewardIndexToHex: parseStringField(row["rewardIndexToHex"], "rewardIndexToHex"),
|
|
4537
|
+
deltaIndexHex: parseStringField(row["deltaIndexHex"], "deltaIndexHex"),
|
|
4538
|
+
rewardIndexScale: parseStringField(row["rewardIndexScale"], "rewardIndexScale"),
|
|
4539
|
+
totalBps: parseRpcNumber(row["totalBps"], "totalBps"),
|
|
4540
|
+
blocksPerYear: parseRpcBigint(row["blocksPerYear"], "blocksPerYear"),
|
|
4541
|
+
stakePerBpsLythoshi: parseRpcBigint(row["stakePerBpsLythoshi"], "stakePerBpsLythoshi"),
|
|
4542
|
+
aprBps: parseRpcBigint(row["aprBps"], "aprBps")
|
|
4543
|
+
};
|
|
4544
|
+
}
|
|
3818
4545
|
function normalizeExecutionUnitPriceResponse(value) {
|
|
3819
4546
|
if (!value || typeof value !== "object") {
|
|
3820
4547
|
throw SdkError.malformed("execution unit price response must be an object");
|
|
@@ -3960,24 +4687,101 @@ function expectObject2(value, label) {
|
|
|
3960
4687
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
3961
4688
|
throw SdkError.malformed(`${label} must be an object`);
|
|
3962
4689
|
}
|
|
3963
|
-
return value;
|
|
4690
|
+
return value;
|
|
4691
|
+
}
|
|
4692
|
+
function parseSafeInteger(value, label) {
|
|
4693
|
+
if (!isNonNegativeSafeInteger(value)) {
|
|
4694
|
+
throw SdkError.malformed(`nativeMarketOrderBook delta replay response ${label} is malformed`);
|
|
4695
|
+
}
|
|
4696
|
+
return value;
|
|
4697
|
+
}
|
|
4698
|
+
function parseNullableSafeInteger(value, label) {
|
|
4699
|
+
if (value === null || value === void 0) return null;
|
|
4700
|
+
return parseSafeInteger(value, label);
|
|
4701
|
+
}
|
|
4702
|
+
function parseNullableString(value, label) {
|
|
4703
|
+
if (value === null || value === void 0) return null;
|
|
4704
|
+
if (typeof value !== "string") {
|
|
4705
|
+
throw SdkError.malformed(`nativeMarketOrderBook delta replay response ${label} is malformed`);
|
|
4706
|
+
}
|
|
4707
|
+
return value;
|
|
4708
|
+
}
|
|
4709
|
+
|
|
4710
|
+
// src/tx-fee.ts
|
|
4711
|
+
var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
|
|
4712
|
+
var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
|
|
4713
|
+
var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
|
|
4714
|
+
var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
|
|
4715
|
+
function asBigint(value, label) {
|
|
4716
|
+
try {
|
|
4717
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
4718
|
+
} catch {
|
|
4719
|
+
throw new Error(`${label} is not an integer: ${String(value)}`);
|
|
4720
|
+
}
|
|
3964
4721
|
}
|
|
3965
|
-
function
|
|
3966
|
-
|
|
3967
|
-
|
|
4722
|
+
function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
|
|
4723
|
+
const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
|
|
4724
|
+
const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
|
|
4725
|
+
if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
|
|
4726
|
+
return tip > cap ? cap : tip;
|
|
4727
|
+
}
|
|
4728
|
+
async function resolveMaxExecutionUnitPrice(client, options = {}) {
|
|
4729
|
+
const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
|
|
4730
|
+
const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
4731
|
+
const quote = await client.lythExecutionUnitPrice();
|
|
4732
|
+
let unitPrice;
|
|
4733
|
+
try {
|
|
4734
|
+
unitPrice = BigInt(quote.executionUnitPriceLythoshi);
|
|
4735
|
+
} catch {
|
|
4736
|
+
throw SdkError.malformed(
|
|
4737
|
+
`lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
|
|
4738
|
+
);
|
|
3968
4739
|
}
|
|
3969
|
-
|
|
4740
|
+
const base = unitPrice > floor ? unitPrice : floor;
|
|
4741
|
+
return base * multiplier;
|
|
3970
4742
|
}
|
|
3971
|
-
function
|
|
3972
|
-
|
|
3973
|
-
|
|
4743
|
+
async function resolveExecutionFee(client, options = {}) {
|
|
4744
|
+
const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
|
|
4745
|
+
minPriceLythoshi: options.minPriceLythoshi,
|
|
4746
|
+
safetyMultiplier: options.safetyMultiplier
|
|
4747
|
+
});
|
|
4748
|
+
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
4749
|
+
return {
|
|
4750
|
+
maxFeePerGas,
|
|
4751
|
+
maxPriorityFeePerGas: tip,
|
|
4752
|
+
gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
4753
|
+
};
|
|
3974
4754
|
}
|
|
3975
|
-
function
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
4755
|
+
async function resolveRegistryExecutionFee(client, options = {}) {
|
|
4756
|
+
return resolveExecutionFee(client, {
|
|
4757
|
+
...options,
|
|
4758
|
+
executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
4759
|
+
});
|
|
4760
|
+
}
|
|
4761
|
+
function feeFieldToBigint(value, field2) {
|
|
4762
|
+
if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
|
|
4763
|
+
throw SdkError.malformed(`${field2} is not an integer: ${String(value)}`);
|
|
3979
4764
|
}
|
|
3980
|
-
|
|
4765
|
+
try {
|
|
4766
|
+
return BigInt(value.trim());
|
|
4767
|
+
} catch {
|
|
4768
|
+
throw SdkError.malformed(`${field2} is not an integer: ${String(value)}`);
|
|
4769
|
+
}
|
|
4770
|
+
}
|
|
4771
|
+
function transactionFeeExposure(fee) {
|
|
4772
|
+
const basePrice = feeFieldToBigint(
|
|
4773
|
+
fee.base_price_per_cycle_lythoshi,
|
|
4774
|
+
"fee.base_price_per_cycle_lythoshi"
|
|
4775
|
+
);
|
|
4776
|
+
const priorityTip = feeFieldToBigint(
|
|
4777
|
+
fee.priority_tip_lythoshi,
|
|
4778
|
+
"fee.priority_tip_lythoshi"
|
|
4779
|
+
);
|
|
4780
|
+
feeFieldToBigint(fee.total_lythoshi, "fee.total_lythoshi");
|
|
4781
|
+
return {
|
|
4782
|
+
feeLythoshi: fee.total_lythoshi,
|
|
4783
|
+
effectiveGasPricePerUnit: (basePrice + priorityTip).toString()
|
|
4784
|
+
};
|
|
3981
4785
|
}
|
|
3982
4786
|
|
|
3983
4787
|
// src/api.ts
|
|
@@ -4055,7 +4859,13 @@ var ApiClient = class {
|
|
|
4055
4859
|
};
|
|
4056
4860
|
}
|
|
4057
4861
|
async transaction(hash) {
|
|
4058
|
-
|
|
4862
|
+
const response = await this.get(
|
|
4863
|
+
`/transactions/${encodePathSegment(hash)}`
|
|
4864
|
+
);
|
|
4865
|
+
return {
|
|
4866
|
+
...response,
|
|
4867
|
+
data: enrichTransactionDataWithFee(response.data)
|
|
4868
|
+
};
|
|
4059
4869
|
}
|
|
4060
4870
|
async transactionReceipt(hash) {
|
|
4061
4871
|
return this.get(`/transactions/${encodePathSegment(hash)}/receipt`);
|
|
@@ -4284,6 +5094,22 @@ var ApiClient = class {
|
|
|
4284
5094
|
return parsed;
|
|
4285
5095
|
}
|
|
4286
5096
|
};
|
|
5097
|
+
function enrichTransactionDataWithFee(data) {
|
|
5098
|
+
const exposure = transactionFeeExposure(data.transaction.fee);
|
|
5099
|
+
return {
|
|
5100
|
+
...data,
|
|
5101
|
+
transaction: {
|
|
5102
|
+
...data.transaction,
|
|
5103
|
+
feeLythoshi: exposure.feeLythoshi,
|
|
5104
|
+
effectiveGasPricePerUnit: exposure.effectiveGasPricePerUnit
|
|
5105
|
+
},
|
|
5106
|
+
receipt: data.receipt == null ? data.receipt : {
|
|
5107
|
+
...data.receipt,
|
|
5108
|
+
feeLythoshi: exposure.feeLythoshi,
|
|
5109
|
+
effectiveGasPricePerUnit: exposure.effectiveGasPricePerUnit
|
|
5110
|
+
}
|
|
5111
|
+
};
|
|
5112
|
+
}
|
|
4287
5113
|
function parseApiError(value) {
|
|
4288
5114
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
4289
5115
|
const error = value["error"];
|
|
@@ -4361,8 +5187,6 @@ function encodePathBlock(block) {
|
|
|
4361
5187
|
function encodePathSegment(value) {
|
|
4362
5188
|
return encodeURIComponent(typeof value === "bigint" ? value.toString() : String(value));
|
|
4363
5189
|
}
|
|
4364
|
-
|
|
4365
|
-
// src/bridge.ts
|
|
4366
5190
|
var BRIDGE_SELECTORS = {
|
|
4367
5191
|
lockBridgeConfig: "0x8956feb3",
|
|
4368
5192
|
setBridgeResumeCooldown: "0x1a3a0672",
|
|
@@ -4396,42 +5220,105 @@ function bridgeAddressHex() {
|
|
|
4396
5220
|
return PRECOMPILE_ADDRESSES.BRIDGE.toLowerCase();
|
|
4397
5221
|
}
|
|
4398
5222
|
function encodeLockBridgeConfigCalldata(bridgeId) {
|
|
4399
|
-
return
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
expectLength3(
|
|
5223
|
+
return bytesToHex5(
|
|
5224
|
+
concatBytes5(
|
|
5225
|
+
hexToBytes5(BRIDGE_SELECTORS.lockBridgeConfig),
|
|
5226
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId")
|
|
4403
5227
|
)
|
|
4404
5228
|
);
|
|
4405
5229
|
}
|
|
4406
5230
|
function encodeSetBridgeResumeCooldownCalldata(bridgeId, cooldownBlocks) {
|
|
4407
|
-
return
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
expectLength3(
|
|
4411
|
-
|
|
5231
|
+
return bytesToHex5(
|
|
5232
|
+
concatBytes5(
|
|
5233
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeResumeCooldown),
|
|
5234
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5235
|
+
uint64Word2(cooldownBlocks, "cooldownBlocks")
|
|
4412
5236
|
)
|
|
4413
5237
|
);
|
|
4414
5238
|
}
|
|
4415
5239
|
function encodeSetBridgeRouteFinalityCalldata(bridgeId, finalityBlocks) {
|
|
4416
|
-
return
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
expectLength3(
|
|
4420
|
-
|
|
5240
|
+
return bytesToHex5(
|
|
5241
|
+
concatBytes5(
|
|
5242
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeRouteFinality),
|
|
5243
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5244
|
+
uint64Word2(finalityBlocks, "finalityBlocks")
|
|
5245
|
+
)
|
|
5246
|
+
);
|
|
5247
|
+
}
|
|
5248
|
+
function bridgeSelector(signature) {
|
|
5249
|
+
return keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
5250
|
+
}
|
|
5251
|
+
function addressWord2(value, name) {
|
|
5252
|
+
const addr = expectLength3(toBytes3(value), 20, name);
|
|
5253
|
+
const out = new Uint8Array(32);
|
|
5254
|
+
out.set(addr, 12);
|
|
5255
|
+
return out;
|
|
5256
|
+
}
|
|
5257
|
+
function padTo322(bytes) {
|
|
5258
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
5259
|
+
if (padded === bytes.length) return bytes;
|
|
5260
|
+
const out = new Uint8Array(padded);
|
|
5261
|
+
out.set(bytes);
|
|
5262
|
+
return out;
|
|
5263
|
+
}
|
|
5264
|
+
function encodeBridgeClaimCalldata(bridgeId, depositId, recipient) {
|
|
5265
|
+
return bytesToHex5(
|
|
5266
|
+
concatBytes5(
|
|
5267
|
+
bridgeSelector("claim(bytes32,bytes32,address)"),
|
|
5268
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5269
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5270
|
+
addressWord2(recipient, "recipient")
|
|
5271
|
+
)
|
|
5272
|
+
);
|
|
5273
|
+
}
|
|
5274
|
+
function encodeBridgeChallengeCalldata(bridgeId, depositId, fraudProof) {
|
|
5275
|
+
const proof = toBytes3(fraudProof);
|
|
5276
|
+
return bytesToHex5(
|
|
5277
|
+
concatBytes5(
|
|
5278
|
+
bridgeSelector("challenge(bytes32,bytes32,bytes)"),
|
|
5279
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5280
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5281
|
+
uint64Word2(3n * 32n, "fraudProofOffset"),
|
|
5282
|
+
uint64Word2(BigInt(proof.length), "fraudProofLength"),
|
|
5283
|
+
padTo322(proof)
|
|
5284
|
+
)
|
|
5285
|
+
);
|
|
5286
|
+
}
|
|
5287
|
+
function encodeSubmitBridgeProofCalldata(bridgeId, depositId, lockReceipt, zkProof, publicInputs) {
|
|
5288
|
+
const receipt = toBytes3(lockReceipt);
|
|
5289
|
+
const proof = toBytes3(zkProof);
|
|
5290
|
+
const inputs = toBytes3(publicInputs);
|
|
5291
|
+
const off0 = 5n * 32n;
|
|
5292
|
+
const off1 = off0 + 32n + BigInt(Math.ceil(receipt.length / 32) * 32);
|
|
5293
|
+
const off2 = off1 + 32n + BigInt(Math.ceil(proof.length / 32) * 32);
|
|
5294
|
+
return bytesToHex5(
|
|
5295
|
+
concatBytes5(
|
|
5296
|
+
bridgeSelector("submitProof(bytes32,bytes32,bytes,bytes,bytes)"),
|
|
5297
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5298
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5299
|
+
uint64Word2(off0, "lockReceiptOffset"),
|
|
5300
|
+
uint64Word2(off1, "zkProofOffset"),
|
|
5301
|
+
uint64Word2(off2, "publicInputsOffset"),
|
|
5302
|
+
uint64Word2(BigInt(receipt.length), "lockReceiptLength"),
|
|
5303
|
+
padTo322(receipt),
|
|
5304
|
+
uint64Word2(BigInt(proof.length), "zkProofLength"),
|
|
5305
|
+
padTo322(proof),
|
|
5306
|
+
uint64Word2(BigInt(inputs.length), "publicInputsLength"),
|
|
5307
|
+
padTo322(inputs)
|
|
4421
5308
|
)
|
|
4422
5309
|
);
|
|
4423
5310
|
}
|
|
4424
5311
|
function isBridgeAdminLockedRevert(data) {
|
|
4425
|
-
return
|
|
5312
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeAdminLocked;
|
|
4426
5313
|
}
|
|
4427
5314
|
function isBridgeResumeCooldownActiveRevert(data) {
|
|
4428
|
-
return
|
|
5315
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeResumeCooldownActive;
|
|
4429
5316
|
}
|
|
4430
5317
|
function isBridgeCooldownZeroRevert(data) {
|
|
4431
|
-
return
|
|
5318
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeCooldownZero;
|
|
4432
5319
|
}
|
|
4433
5320
|
function isBridgeFinalityZeroRevert(data) {
|
|
4434
|
-
return
|
|
5321
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
|
|
4435
5322
|
}
|
|
4436
5323
|
function bridgeDrainRemaining(capPerWindow, drained) {
|
|
4437
5324
|
const cap = BigInt(capPerWindow);
|
|
@@ -5034,7 +5921,7 @@ function expectLength3(value, len, name) {
|
|
|
5034
5921
|
}
|
|
5035
5922
|
return value;
|
|
5036
5923
|
}
|
|
5037
|
-
function
|
|
5924
|
+
function uint64Word2(value, name) {
|
|
5038
5925
|
const n = toBigint(value, name);
|
|
5039
5926
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
5040
5927
|
throw new BridgePrecompileError(`${name} must fit uint64`);
|
|
@@ -5060,13 +5947,13 @@ function toBigint(value, name) {
|
|
|
5060
5947
|
}
|
|
5061
5948
|
return BigInt(value);
|
|
5062
5949
|
}
|
|
5063
|
-
function
|
|
5950
|
+
function toBytes3(value) {
|
|
5064
5951
|
if (typeof value === "string") {
|
|
5065
|
-
return
|
|
5952
|
+
return hexToBytes5(value);
|
|
5066
5953
|
}
|
|
5067
5954
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
5068
5955
|
}
|
|
5069
|
-
function
|
|
5956
|
+
function hexToBytes5(hex) {
|
|
5070
5957
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
5071
5958
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
5072
5959
|
throw new BridgePrecompileError("invalid hex bytes");
|
|
@@ -5077,10 +5964,10 @@ function hexToBytes4(hex) {
|
|
|
5077
5964
|
}
|
|
5078
5965
|
return out;
|
|
5079
5966
|
}
|
|
5080
|
-
function
|
|
5967
|
+
function bytesToHex5(bytes) {
|
|
5081
5968
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
5082
5969
|
}
|
|
5083
|
-
function
|
|
5970
|
+
function concatBytes5(...parts) {
|
|
5084
5971
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
5085
5972
|
let offset = 0;
|
|
5086
5973
|
for (const part of parts) {
|
|
@@ -5135,10 +6022,10 @@ function decodeNoEvmReceiptTranscript(proof) {
|
|
|
5135
6022
|
);
|
|
5136
6023
|
}
|
|
5137
6024
|
function computeNoEvmReceiptsRoot(receipts) {
|
|
5138
|
-
return
|
|
6025
|
+
return bytesToHex6(computeNoEvmReceiptsRootBytes(receipts));
|
|
5139
6026
|
}
|
|
5140
6027
|
function computeNoEvmTargetReceiptHash(receiptBytes) {
|
|
5141
|
-
return
|
|
6028
|
+
return bytesToHex6(keccak_256(receiptBytes));
|
|
5142
6029
|
}
|
|
5143
6030
|
function verifyNoEvmReceiptProof(proof) {
|
|
5144
6031
|
if (proof == null) return null;
|
|
@@ -5725,7 +6612,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5725
6612
|
if (!bytesEqual(expectedLeafHashBytes, actualLeafHashBytes)) {
|
|
5726
6613
|
throw new NoEvmReceiptProofError(
|
|
5727
6614
|
"compact_leaf_hash_mismatch",
|
|
5728
|
-
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${
|
|
6615
|
+
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
|
|
5729
6616
|
actualLeafHashBytes
|
|
5730
6617
|
)}`
|
|
5731
6618
|
);
|
|
@@ -5758,14 +6645,14 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5758
6645
|
if (!bytesEqual(actualRootBytes, compactRootBytes)) {
|
|
5759
6646
|
throw new NoEvmReceiptProofError(
|
|
5760
6647
|
"compact_path_mismatch",
|
|
5761
|
-
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${
|
|
6648
|
+
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
|
|
5762
6649
|
actualRootBytes
|
|
5763
6650
|
)}`
|
|
5764
6651
|
);
|
|
5765
6652
|
}
|
|
5766
6653
|
return {
|
|
5767
6654
|
receipts: [],
|
|
5768
|
-
receiptsRoot:
|
|
6655
|
+
receiptsRoot: bytesToHex6(actualRootBytes),
|
|
5769
6656
|
targetReceiptHash: actualTargetHash,
|
|
5770
6657
|
receiptCount: proof.receiptCount,
|
|
5771
6658
|
txIndex: proof.txIndex,
|
|
@@ -5975,7 +6862,7 @@ function parseArchiveProofSignature(signature, index, fieldPrefix = "archiveProo
|
|
|
5975
6862
|
`${field2}.payload must be non-empty`
|
|
5976
6863
|
);
|
|
5977
6864
|
}
|
|
5978
|
-
return { signerId:
|
|
6865
|
+
return { signerId: bytesToHex6(signerId), payload };
|
|
5979
6866
|
}
|
|
5980
6867
|
function normalizeSignerId(value) {
|
|
5981
6868
|
const bytes = decodeHexBytes(value, "signerId");
|
|
@@ -5985,7 +6872,7 @@ function normalizeSignerId(value) {
|
|
|
5985
6872
|
`signerId must be ${ARCHIVE_SIGNATURE_SIGNER_ID_BYTE_LENGTH} bytes, got ${bytes.length}`
|
|
5986
6873
|
);
|
|
5987
6874
|
}
|
|
5988
|
-
return
|
|
6875
|
+
return bytesToHex6(bytes);
|
|
5989
6876
|
}
|
|
5990
6877
|
function expectArchivePublicKey(value, field2) {
|
|
5991
6878
|
if (value.length !== ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
@@ -6466,7 +7353,7 @@ function bytesEqual(a, b) {
|
|
|
6466
7353
|
}
|
|
6467
7354
|
return diff === 0;
|
|
6468
7355
|
}
|
|
6469
|
-
function
|
|
7356
|
+
function bytesToHex6(bytes) {
|
|
6470
7357
|
let out = "0x";
|
|
6471
7358
|
for (let index = 0; index < bytes.length; index++) {
|
|
6472
7359
|
out += bytes[index].toString(16).padStart(2, "0");
|
|
@@ -6666,58 +7553,6 @@ function assertWholeNumber(field2, value) {
|
|
|
6666
7553
|
throw new Error(`${field2} must be a whole number`);
|
|
6667
7554
|
}
|
|
6668
7555
|
}
|
|
6669
|
-
|
|
6670
|
-
// src/tx-fee.ts
|
|
6671
|
-
var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
|
|
6672
|
-
var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
|
|
6673
|
-
var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
|
|
6674
|
-
var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
|
|
6675
|
-
function asBigint(value, label) {
|
|
6676
|
-
try {
|
|
6677
|
-
return typeof value === "bigint" ? value : BigInt(value);
|
|
6678
|
-
} catch {
|
|
6679
|
-
throw new Error(`${label} is not an integer: ${String(value)}`);
|
|
6680
|
-
}
|
|
6681
|
-
}
|
|
6682
|
-
function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
|
|
6683
|
-
const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
|
|
6684
|
-
const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
|
|
6685
|
-
if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
|
|
6686
|
-
return tip > cap ? cap : tip;
|
|
6687
|
-
}
|
|
6688
|
-
async function resolveMaxExecutionUnitPrice(client, options = {}) {
|
|
6689
|
-
const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
|
|
6690
|
-
const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
6691
|
-
const quote = await client.lythExecutionUnitPrice();
|
|
6692
|
-
let unitPrice;
|
|
6693
|
-
try {
|
|
6694
|
-
unitPrice = BigInt(quote.executionUnitPriceLythoshi);
|
|
6695
|
-
} catch {
|
|
6696
|
-
throw SdkError.malformed(
|
|
6697
|
-
`lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
|
|
6698
|
-
);
|
|
6699
|
-
}
|
|
6700
|
-
const base = unitPrice > floor ? unitPrice : floor;
|
|
6701
|
-
return base * multiplier;
|
|
6702
|
-
}
|
|
6703
|
-
async function resolveExecutionFee(client, options = {}) {
|
|
6704
|
-
const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
|
|
6705
|
-
minPriceLythoshi: options.minPriceLythoshi,
|
|
6706
|
-
safetyMultiplier: options.safetyMultiplier
|
|
6707
|
-
});
|
|
6708
|
-
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
6709
|
-
return {
|
|
6710
|
-
maxFeePerGas,
|
|
6711
|
-
maxPriorityFeePerGas: tip,
|
|
6712
|
-
gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6713
|
-
};
|
|
6714
|
-
}
|
|
6715
|
-
async function resolveRegistryExecutionFee(client, options = {}) {
|
|
6716
|
-
return resolveExecutionFee(client, {
|
|
6717
|
-
...options,
|
|
6718
|
-
executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6719
|
-
});
|
|
6720
|
-
}
|
|
6721
7556
|
var ORACLE_EVENT_SIGS = {
|
|
6722
7557
|
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
6723
7558
|
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
@@ -6737,12 +7572,48 @@ var OracleEventError = class extends Error {
|
|
|
6737
7572
|
function oracleAddressHex() {
|
|
6738
7573
|
return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
|
|
6739
7574
|
}
|
|
7575
|
+
var FEED_ID_DOMAIN_TAG = "protocore-oracle/feed-id/v1";
|
|
7576
|
+
function deriveFeedId(name, decimals) {
|
|
7577
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
7578
|
+
throw new OracleEventError("feed decimals must be an integer in 0..=255");
|
|
7579
|
+
}
|
|
7580
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
7581
|
+
const buf = concatBytes6(
|
|
7582
|
+
new TextEncoder().encode(FEED_ID_DOMAIN_TAG),
|
|
7583
|
+
nameBytes,
|
|
7584
|
+
Uint8Array.of(decimals & 255)
|
|
7585
|
+
);
|
|
7586
|
+
return bytesToHex7(keccak_256(buf));
|
|
7587
|
+
}
|
|
7588
|
+
function formatOraclePrice(price) {
|
|
7589
|
+
if (price.median === null) return null;
|
|
7590
|
+
const value = BigInt(price.median);
|
|
7591
|
+
const decimals = price.decimals;
|
|
7592
|
+
if (decimals <= 0) return value.toString(10);
|
|
7593
|
+
const base = 10n ** BigInt(decimals);
|
|
7594
|
+
const whole = value / base;
|
|
7595
|
+
const frac = (value % base).toString(10).padStart(decimals, "0").replace(/0+$/, "");
|
|
7596
|
+
return frac.length > 0 ? `${whole.toString(10)}.${frac}` : whole.toString(10);
|
|
7597
|
+
}
|
|
7598
|
+
function oraclePriceToNumber(price) {
|
|
7599
|
+
const formatted = formatOraclePrice(price);
|
|
7600
|
+
return formatted === null ? null : Number(formatted);
|
|
7601
|
+
}
|
|
7602
|
+
function concatBytes6(...parts) {
|
|
7603
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7604
|
+
let offset = 0;
|
|
7605
|
+
for (const part of parts) {
|
|
7606
|
+
out.set(part, offset);
|
|
7607
|
+
offset += part.length;
|
|
7608
|
+
}
|
|
7609
|
+
return out;
|
|
7610
|
+
}
|
|
6740
7611
|
function decodeOracleEvent(topics, data) {
|
|
6741
7612
|
if (topics.length === 0) {
|
|
6742
7613
|
throw new OracleEventError("event record has no topics");
|
|
6743
7614
|
}
|
|
6744
|
-
const topic0 =
|
|
6745
|
-
const body =
|
|
7615
|
+
const topic0 = bytesToHex7(expectLength4(toBytes4(topics[0]), 32, "topic0"));
|
|
7616
|
+
const body = toBytes4(data);
|
|
6746
7617
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
|
|
6747
7618
|
checkArity("OracleRoundFinalized", 3, topics.length);
|
|
6748
7619
|
checkData("OracleRoundFinalized", 3 * 32, body.length);
|
|
@@ -6775,7 +7646,7 @@ function decodeOracleEvent(topics, data) {
|
|
|
6775
7646
|
feedId: hex32(topics[1]),
|
|
6776
7647
|
roundId: u64FromTopic(topics[2]),
|
|
6777
7648
|
writer: addressFromTopic(topics[3]),
|
|
6778
|
-
evidenceHash:
|
|
7649
|
+
evidenceHash: bytesToHex7(body.subarray(0, 32))
|
|
6779
7650
|
};
|
|
6780
7651
|
}
|
|
6781
7652
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
|
|
@@ -6823,7 +7694,7 @@ function decodeFeedFields(feedTopic, body) {
|
|
|
6823
7694
|
};
|
|
6824
7695
|
}
|
|
6825
7696
|
function topicHex(sig) {
|
|
6826
|
-
return
|
|
7697
|
+
return bytesToHex7(keccak_256(new TextEncoder().encode(sig)));
|
|
6827
7698
|
}
|
|
6828
7699
|
function checkArity(event, expected, found) {
|
|
6829
7700
|
if (found !== expected) {
|
|
@@ -6836,13 +7707,13 @@ function checkData(event, expected, found) {
|
|
|
6836
7707
|
}
|
|
6837
7708
|
}
|
|
6838
7709
|
function hex32(topic) {
|
|
6839
|
-
return
|
|
7710
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "feedId topic"));
|
|
6840
7711
|
}
|
|
6841
7712
|
function addressFromTopic(topic) {
|
|
6842
|
-
return
|
|
7713
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "address topic").subarray(12, 32));
|
|
6843
7714
|
}
|
|
6844
7715
|
function u64FromTopic(topic) {
|
|
6845
|
-
return u64FromWord2(expectLength4(
|
|
7716
|
+
return u64FromWord2(expectLength4(toBytes4(topic), 32, "u64 topic"));
|
|
6846
7717
|
}
|
|
6847
7718
|
function u64FromWord2(word) {
|
|
6848
7719
|
let v = 0n;
|
|
@@ -6857,11 +7728,11 @@ function u256Decimal(word) {
|
|
|
6857
7728
|
for (const b of word) v = v << 8n | BigInt(b);
|
|
6858
7729
|
return v.toString(10);
|
|
6859
7730
|
}
|
|
6860
|
-
function
|
|
6861
|
-
if (typeof value === "string") return
|
|
7731
|
+
function toBytes4(value) {
|
|
7732
|
+
if (typeof value === "string") return hexToBytes6(value);
|
|
6862
7733
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6863
7734
|
}
|
|
6864
|
-
function
|
|
7735
|
+
function hexToBytes6(hex) {
|
|
6865
7736
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6866
7737
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6867
7738
|
throw new OracleEventError("invalid hex bytes");
|
|
@@ -6870,7 +7741,7 @@ function hexToBytes5(hex) {
|
|
|
6870
7741
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6871
7742
|
return out;
|
|
6872
7743
|
}
|
|
6873
|
-
function
|
|
7744
|
+
function bytesToHex7(bytes) {
|
|
6874
7745
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6875
7746
|
}
|
|
6876
7747
|
function expectLength4(value, len, name) {
|
|
@@ -6882,12 +7753,12 @@ function expectLength4(value, len, name) {
|
|
|
6882
7753
|
var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
|
|
6883
7754
|
var SERVES_GPU_PROVE = 512;
|
|
6884
7755
|
var PROVER_MARKET_SELECTORS = {
|
|
6885
|
-
createRequest: "0x" +
|
|
6886
|
-
submitBid: "0x" +
|
|
6887
|
-
closeRequest: "0x" +
|
|
6888
|
-
submitProof: "0x" +
|
|
6889
|
-
settle: "0x" +
|
|
6890
|
-
slash: "0x" +
|
|
7756
|
+
createRequest: "0x" + selectorHex3("createRequest(bytes)"),
|
|
7757
|
+
submitBid: "0x" + selectorHex3("submitBid(bytes)"),
|
|
7758
|
+
closeRequest: "0x" + selectorHex3("closeRequest(bytes)"),
|
|
7759
|
+
submitProof: "0x" + selectorHex3("submitProof(bytes)"),
|
|
7760
|
+
settle: "0x" + selectorHex3("settle(bytes)"),
|
|
7761
|
+
slash: "0x" + selectorHex3("slash(bytes)")
|
|
6891
7762
|
};
|
|
6892
7763
|
var PROVER_MARKET_EVENT_SIGS = {
|
|
6893
7764
|
proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
|
|
@@ -6925,12 +7796,12 @@ var ProverMarketError = class extends Error {
|
|
|
6925
7796
|
}
|
|
6926
7797
|
};
|
|
6927
7798
|
function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
6928
|
-
return
|
|
7799
|
+
return bytesToHex8(
|
|
6929
7800
|
keccak_256(
|
|
6930
|
-
|
|
7801
|
+
concatBytes7(
|
|
6931
7802
|
new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
|
|
6932
|
-
expectLength5(
|
|
6933
|
-
expectLength5(
|
|
7803
|
+
expectLength5(toBytes5(vkeyHash), 32, "vkeyHash"),
|
|
7804
|
+
expectLength5(toBytes5(inputsHash), 32, "inputsHash"),
|
|
6934
7805
|
u128Bytes(maxFee, "maxFee"),
|
|
6935
7806
|
u64Bytes(deadline, "deadline"),
|
|
6936
7807
|
u64Bytes(nonce, "nonce")
|
|
@@ -6939,44 +7810,44 @@ function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
|
6939
7810
|
);
|
|
6940
7811
|
}
|
|
6941
7812
|
function bidSighash(requestId, fee) {
|
|
6942
|
-
return
|
|
7813
|
+
return bytesToHex8(
|
|
6943
7814
|
keccak_256(
|
|
6944
|
-
|
|
7815
|
+
concatBytes7(
|
|
6945
7816
|
new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
|
|
6946
|
-
expectLength5(
|
|
7817
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
6947
7818
|
u128Bytes(fee, "fee")
|
|
6948
7819
|
)
|
|
6949
7820
|
)
|
|
6950
7821
|
);
|
|
6951
7822
|
}
|
|
6952
7823
|
function submitSighash(requestId, proofHash) {
|
|
6953
|
-
return
|
|
7824
|
+
return bytesToHex8(
|
|
6954
7825
|
keccak_256(
|
|
6955
|
-
|
|
7826
|
+
concatBytes7(
|
|
6956
7827
|
new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
|
|
6957
|
-
expectLength5(
|
|
6958
|
-
expectLength5(
|
|
7828
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
7829
|
+
expectLength5(toBytes5(proofHash), 32, "proofHash")
|
|
6959
7830
|
)
|
|
6960
7831
|
)
|
|
6961
7832
|
);
|
|
6962
7833
|
}
|
|
6963
7834
|
function encodeCreateRequestCanonical(args) {
|
|
6964
|
-
const buyer = expectLength5(
|
|
6965
|
-
const buyerPubkey =
|
|
6966
|
-
const sig =
|
|
7835
|
+
const buyer = expectLength5(toBytes5(args.buyer), 20, "buyer");
|
|
7836
|
+
const buyerPubkey = toBytes5(args.buyerPubkey);
|
|
7837
|
+
const sig = toBytes5(args.sig);
|
|
6967
7838
|
if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
|
|
6968
7839
|
throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
|
|
6969
7840
|
}
|
|
6970
7841
|
if (sig.length === 0 || sig.length > 65535) {
|
|
6971
7842
|
throw new ProverMarketError("sig length out of range (1..=65535)");
|
|
6972
7843
|
}
|
|
6973
|
-
return
|
|
6974
|
-
|
|
7844
|
+
return bytesToHex8(
|
|
7845
|
+
concatBytes7(
|
|
6975
7846
|
buyer,
|
|
6976
7847
|
u16Bytes(buyerPubkey.length),
|
|
6977
7848
|
buyerPubkey,
|
|
6978
|
-
expectLength5(
|
|
6979
|
-
expectLength5(
|
|
7849
|
+
expectLength5(toBytes5(args.vkeyHash), 32, "vkeyHash"),
|
|
7850
|
+
expectLength5(toBytes5(args.inputsHash), 32, "inputsHash"),
|
|
6980
7851
|
u128Bytes(args.maxFee, "maxFee"),
|
|
6981
7852
|
u64Bytes(args.deadline, "deadline"),
|
|
6982
7853
|
u64Bytes(args.nonce, "nonce"),
|
|
@@ -6986,7 +7857,7 @@ function encodeCreateRequestCanonical(args) {
|
|
|
6986
7857
|
);
|
|
6987
7858
|
}
|
|
6988
7859
|
function encodeCreateRequestCalldata(args) {
|
|
6989
|
-
const canonical =
|
|
7860
|
+
const canonical = toBytes5(encodeCreateRequestCanonical(args));
|
|
6990
7861
|
const offset = new Uint8Array(32);
|
|
6991
7862
|
offset[31] = 32;
|
|
6992
7863
|
const lenWord = new Uint8Array(32);
|
|
@@ -6996,18 +7867,18 @@ function encodeCreateRequestCalldata(args) {
|
|
|
6996
7867
|
lenWord[30] = len >>> 8 & 255;
|
|
6997
7868
|
lenWord[31] = len & 255;
|
|
6998
7869
|
const pad = (32 - len % 32) % 32;
|
|
6999
|
-
return
|
|
7000
|
-
|
|
7870
|
+
return bytesToHex8(
|
|
7871
|
+
concatBytes7(hexToBytes7(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
|
|
7001
7872
|
);
|
|
7002
7873
|
}
|
|
7003
|
-
function
|
|
7874
|
+
function selectorHex3(sig) {
|
|
7004
7875
|
return [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7005
7876
|
}
|
|
7006
|
-
function
|
|
7007
|
-
if (typeof value === "string") return
|
|
7877
|
+
function toBytes5(value) {
|
|
7878
|
+
if (typeof value === "string") return hexToBytes7(value);
|
|
7008
7879
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7009
7880
|
}
|
|
7010
|
-
function
|
|
7881
|
+
function hexToBytes7(hex) {
|
|
7011
7882
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7012
7883
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
7013
7884
|
throw new ProverMarketError("invalid hex bytes");
|
|
@@ -7016,10 +7887,10 @@ function hexToBytes6(hex) {
|
|
|
7016
7887
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
7017
7888
|
return out;
|
|
7018
7889
|
}
|
|
7019
|
-
function
|
|
7890
|
+
function bytesToHex8(bytes) {
|
|
7020
7891
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7021
7892
|
}
|
|
7022
|
-
function
|
|
7893
|
+
function concatBytes7(...parts) {
|
|
7023
7894
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7024
7895
|
let offset = 0;
|
|
7025
7896
|
for (const part of parts) {
|
|
@@ -7096,34 +7967,34 @@ function delegationAddressHex() {
|
|
|
7096
7967
|
return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
|
|
7097
7968
|
}
|
|
7098
7969
|
function encodeCompleteRedemptionCalldata(index) {
|
|
7099
|
-
return
|
|
7100
|
-
|
|
7101
|
-
|
|
7102
|
-
|
|
7970
|
+
return bytesToHex9(
|
|
7971
|
+
concatBytes8(
|
|
7972
|
+
hexToBytes8(DELEGATION_SELECTORS.completeRedemption),
|
|
7973
|
+
uint64Word3(index, "index")
|
|
7103
7974
|
)
|
|
7104
7975
|
);
|
|
7105
7976
|
}
|
|
7106
7977
|
function encodeDelegateCalldata(cluster, weightBps) {
|
|
7107
|
-
return
|
|
7108
|
-
|
|
7109
|
-
|
|
7978
|
+
return bytesToHex9(
|
|
7979
|
+
concatBytes8(
|
|
7980
|
+
hexToBytes8(DELEGATION_SELECTORS.delegate),
|
|
7110
7981
|
uint32Word2(cluster, "cluster"),
|
|
7111
7982
|
uint16Word(weightBps, "weightBps")
|
|
7112
7983
|
)
|
|
7113
7984
|
);
|
|
7114
7985
|
}
|
|
7115
7986
|
function encodeUndelegateCalldata(cluster) {
|
|
7116
|
-
return
|
|
7117
|
-
|
|
7118
|
-
|
|
7987
|
+
return bytesToHex9(
|
|
7988
|
+
concatBytes8(
|
|
7989
|
+
hexToBytes8(DELEGATION_SELECTORS.undelegate),
|
|
7119
7990
|
uint32Word2(cluster, "cluster")
|
|
7120
7991
|
)
|
|
7121
7992
|
);
|
|
7122
7993
|
}
|
|
7123
7994
|
function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
|
|
7124
|
-
return
|
|
7125
|
-
|
|
7126
|
-
|
|
7995
|
+
return bytesToHex9(
|
|
7996
|
+
concatBytes8(
|
|
7997
|
+
hexToBytes8(DELEGATION_SELECTORS.redelegate),
|
|
7127
7998
|
uint32Word2(fromCluster, "fromCluster"),
|
|
7128
7999
|
uint32Word2(toCluster, "toCluster"),
|
|
7129
8000
|
uint16Word(weightBps, "weightBps")
|
|
@@ -7136,14 +8007,14 @@ function encodeClaimCalldata() {
|
|
|
7136
8007
|
function encodeSetAutoCompoundCalldata(enabled) {
|
|
7137
8008
|
const flag = new Uint8Array(32);
|
|
7138
8009
|
flag[31] = enabled ? 1 : 0;
|
|
7139
|
-
return
|
|
7140
|
-
|
|
8010
|
+
return bytesToHex9(
|
|
8011
|
+
concatBytes8(hexToBytes8(DELEGATION_SELECTORS.setAutoCompound), flag)
|
|
7141
8012
|
);
|
|
7142
8013
|
}
|
|
7143
8014
|
function isRedemptionPrincipalUnavailableRevert(data) {
|
|
7144
|
-
return
|
|
8015
|
+
return bytesToHex9(toBytes6(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
|
|
7145
8016
|
}
|
|
7146
|
-
function
|
|
8017
|
+
function uint64Word3(value, name) {
|
|
7147
8018
|
const n = toBigint3(value, name);
|
|
7148
8019
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
7149
8020
|
throw new DelegationPrecompileError(`${name} must fit uint64`);
|
|
@@ -7195,13 +8066,13 @@ function toBigint3(value, name) {
|
|
|
7195
8066
|
}
|
|
7196
8067
|
return BigInt(value);
|
|
7197
8068
|
}
|
|
7198
|
-
function
|
|
8069
|
+
function toBytes6(value) {
|
|
7199
8070
|
if (typeof value === "string") {
|
|
7200
|
-
return
|
|
8071
|
+
return hexToBytes8(value);
|
|
7201
8072
|
}
|
|
7202
8073
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7203
8074
|
}
|
|
7204
|
-
function
|
|
8075
|
+
function hexToBytes8(hex) {
|
|
7205
8076
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7206
8077
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7207
8078
|
throw new DelegationPrecompileError("invalid hex bytes");
|
|
@@ -7212,10 +8083,10 @@ function hexToBytes7(hex) {
|
|
|
7212
8083
|
}
|
|
7213
8084
|
return out;
|
|
7214
8085
|
}
|
|
7215
|
-
function
|
|
8086
|
+
function bytesToHex9(bytes) {
|
|
7216
8087
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7217
8088
|
}
|
|
7218
|
-
function
|
|
8089
|
+
function concatBytes8(...parts) {
|
|
7219
8090
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7220
8091
|
let offset = 0;
|
|
7221
8092
|
for (const part of parts) {
|
|
@@ -7224,8 +8095,6 @@ function concatBytes6(...parts) {
|
|
|
7224
8095
|
}
|
|
7225
8096
|
return out;
|
|
7226
8097
|
}
|
|
7227
|
-
|
|
7228
|
-
// src/spending-policy.ts
|
|
7229
8098
|
var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
|
|
7230
8099
|
var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
|
|
7231
8100
|
var ML_DSA_65_SIGNATURE_LEN2 = 3309;
|
|
@@ -7248,10 +8117,38 @@ var SpendingPolicyError = class extends Error {
|
|
|
7248
8117
|
function spendingPolicyAddressHex() {
|
|
7249
8118
|
return PRECOMPILE_ADDRESSES.SPENDING_POLICY.toLowerCase();
|
|
7250
8119
|
}
|
|
8120
|
+
var EMPTY_ROOT = new Uint8Array(32);
|
|
8121
|
+
function destinationRoot(address) {
|
|
8122
|
+
const bytes = toUserAddressBytes(address, "address");
|
|
8123
|
+
return keccak_256(bytes);
|
|
8124
|
+
}
|
|
8125
|
+
var allowRootFor = destinationRoot;
|
|
8126
|
+
var denyRootFor = destinationRoot;
|
|
8127
|
+
function categoryRoot(selectorOrSig) {
|
|
8128
|
+
let selector;
|
|
8129
|
+
if (typeof selectorOrSig === "string") {
|
|
8130
|
+
selector = keccak_256(new TextEncoder().encode(selectorOrSig)).slice(0, 4);
|
|
8131
|
+
} else {
|
|
8132
|
+
selector = selectorOrSig instanceof Uint8Array ? selectorOrSig : Uint8Array.from(selectorOrSig);
|
|
8133
|
+
if (selector.length !== 4) {
|
|
8134
|
+
throw new SpendingPolicyError("category selector must be exactly 4 bytes");
|
|
8135
|
+
}
|
|
8136
|
+
}
|
|
8137
|
+
return keccak_256(selector);
|
|
8138
|
+
}
|
|
8139
|
+
function setDestinationRoot(entries) {
|
|
8140
|
+
if (entries.length === 0) return EMPTY_ROOT;
|
|
8141
|
+
if (entries.length > 1) {
|
|
8142
|
+
throw new SpendingPolicyError(
|
|
8143
|
+
"multi-entry destination sets are not supported by the chain yet (v1 allows a single counterparty per root); pass exactly one address"
|
|
8144
|
+
);
|
|
8145
|
+
}
|
|
8146
|
+
return destinationRoot(entries[0]);
|
|
8147
|
+
}
|
|
7251
8148
|
function composeClaimBoundMessage(chainId, args, opts) {
|
|
7252
8149
|
const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
|
|
7253
8150
|
const normalized = normalizeArgs(args);
|
|
7254
|
-
return
|
|
8151
|
+
return concatBytes9(
|
|
7255
8152
|
new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
|
|
7256
8153
|
uint64Bytes(chainId, "chainId"),
|
|
7257
8154
|
precompileAddress,
|
|
@@ -7274,17 +8171,17 @@ function composeClaimBoundMessage(chainId, args, opts) {
|
|
|
7274
8171
|
}
|
|
7275
8172
|
function encodeSetPolicyCalldata(args) {
|
|
7276
8173
|
const normalized = normalizeArgs(args);
|
|
7277
|
-
return
|
|
7278
|
-
|
|
7279
|
-
|
|
8174
|
+
return bytesToHex10(
|
|
8175
|
+
concatBytes9(
|
|
8176
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicy),
|
|
7280
8177
|
encodePolicyWords(normalized)
|
|
7281
8178
|
)
|
|
7282
8179
|
);
|
|
7283
8180
|
}
|
|
7284
8181
|
function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
7285
8182
|
const normalized = normalizeArgs(args);
|
|
7286
|
-
const pubkey =
|
|
7287
|
-
const sig =
|
|
8183
|
+
const pubkey = toBytes7(subAccountPubkey);
|
|
8184
|
+
const sig = toBytes7(subAccountSig);
|
|
7288
8185
|
if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
|
|
7289
8186
|
throw new SpendingPolicyError(
|
|
7290
8187
|
`subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
|
|
@@ -7295,9 +8192,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7295
8192
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7296
8193
|
);
|
|
7297
8194
|
}
|
|
7298
|
-
return
|
|
7299
|
-
|
|
7300
|
-
|
|
8195
|
+
return bytesToHex10(
|
|
8196
|
+
concatBytes9(
|
|
8197
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicyClaim),
|
|
7301
8198
|
encodePolicyWords(normalized),
|
|
7302
8199
|
pubkey,
|
|
7303
8200
|
sig
|
|
@@ -7306,15 +8203,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7306
8203
|
}
|
|
7307
8204
|
function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
|
|
7308
8205
|
const normalized = normalizeArgs(args);
|
|
7309
|
-
const sig =
|
|
8206
|
+
const sig = toBytes7(subAccountSig);
|
|
7310
8207
|
if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
|
|
7311
8208
|
throw new SpendingPolicyError(
|
|
7312
8209
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7313
8210
|
);
|
|
7314
8211
|
}
|
|
7315
|
-
return
|
|
7316
|
-
|
|
7317
|
-
|
|
8212
|
+
return bytesToHex10(
|
|
8213
|
+
concatBytes9(
|
|
8214
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
|
|
7318
8215
|
encodePolicyWords(normalized),
|
|
7319
8216
|
sig
|
|
7320
8217
|
)
|
|
@@ -7333,17 +8230,17 @@ function normalizeArgs(args) {
|
|
|
7333
8230
|
principal: toUserAddressBytes(args.principal, "principal"),
|
|
7334
8231
|
dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
|
|
7335
8232
|
perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
7336
|
-
allowRoot: expectLength6(
|
|
7337
|
-
denyRoot: expectLength6(
|
|
8233
|
+
allowRoot: expectLength6(toBytes7(args.allowRoot), 32, "allowRoot"),
|
|
8234
|
+
denyRoot: expectLength6(toBytes7(args.denyRoot), 32, "denyRoot"),
|
|
7338
8235
|
weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
|
|
7339
8236
|
monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
|
|
7340
|
-
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(
|
|
7341
|
-
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(
|
|
8237
|
+
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes7(args.categoryAllowRoot), 32, "categoryAllowRoot"),
|
|
8238
|
+
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes7(args.timeWindow), 32, "timeWindow"),
|
|
7342
8239
|
policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
|
|
7343
8240
|
};
|
|
7344
8241
|
}
|
|
7345
8242
|
function encodePolicyWords(args) {
|
|
7346
|
-
return
|
|
8243
|
+
return concatBytes9(
|
|
7347
8244
|
encodeAddressWord(args.subAccount),
|
|
7348
8245
|
encodeAddressWord(args.principal),
|
|
7349
8246
|
encodeUint128Word(args.dailyCapLythoshi),
|
|
@@ -7368,7 +8265,7 @@ function packTimeWindow(enabled, startHour, endHour) {
|
|
|
7368
8265
|
return out;
|
|
7369
8266
|
}
|
|
7370
8267
|
function decodeTimeWindow(word) {
|
|
7371
|
-
const bytes = expectLength6(
|
|
8268
|
+
const bytes = expectLength6(toBytes7(word), 32, "timeWindow");
|
|
7372
8269
|
if (bytes.every((b) => b === 0)) return null;
|
|
7373
8270
|
if (bytes[29] === 0) return null;
|
|
7374
8271
|
return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
|
|
@@ -7380,16 +8277,16 @@ function clampHour(hour) {
|
|
|
7380
8277
|
return Math.min(hour, 23);
|
|
7381
8278
|
}
|
|
7382
8279
|
function encodeUint64Word(value) {
|
|
7383
|
-
return
|
|
8280
|
+
return concatBytes9(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
|
|
7384
8281
|
}
|
|
7385
8282
|
function encodeSingleAddressCall(selector, address, name) {
|
|
7386
|
-
return
|
|
8283
|
+
return bytesToHex10(concatBytes9(hexToBytes9(selector), encodeAddressWord(toUserAddressBytes(address, name))));
|
|
7387
8284
|
}
|
|
7388
8285
|
function encodeAddressWord(address) {
|
|
7389
|
-
return
|
|
8286
|
+
return concatBytes9(new Uint8Array(12), address);
|
|
7390
8287
|
}
|
|
7391
8288
|
function encodeUint128Word(value) {
|
|
7392
|
-
return
|
|
8289
|
+
return concatBytes9(new Uint8Array(16), uint128Bytes(value, "uint128"));
|
|
7393
8290
|
}
|
|
7394
8291
|
function toUserAddressBytes(value, name) {
|
|
7395
8292
|
if (typeof value !== "string") {
|
|
@@ -7411,13 +8308,13 @@ function toRawAddressBytes(value) {
|
|
|
7411
8308
|
}
|
|
7412
8309
|
return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
|
|
7413
8310
|
}
|
|
7414
|
-
function
|
|
8311
|
+
function toBytes7(value) {
|
|
7415
8312
|
if (typeof value === "string") {
|
|
7416
|
-
return
|
|
8313
|
+
return hexToBytes9(value);
|
|
7417
8314
|
}
|
|
7418
8315
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7419
8316
|
}
|
|
7420
|
-
function
|
|
8317
|
+
function hexToBytes9(hex) {
|
|
7421
8318
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7422
8319
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7423
8320
|
throw new SpendingPolicyError("invalid hex bytes");
|
|
@@ -7428,10 +8325,10 @@ function hexToBytes8(hex) {
|
|
|
7428
8325
|
}
|
|
7429
8326
|
return out;
|
|
7430
8327
|
}
|
|
7431
|
-
function
|
|
8328
|
+
function bytesToHex10(bytes) {
|
|
7432
8329
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7433
8330
|
}
|
|
7434
|
-
function
|
|
8331
|
+
function concatBytes9(...parts) {
|
|
7435
8332
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7436
8333
|
let offset = 0;
|
|
7437
8334
|
for (const part of parts) {
|
|
@@ -7493,17 +8390,17 @@ function pubkeyRegistryAddressHex() {
|
|
|
7493
8390
|
return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
|
|
7494
8391
|
}
|
|
7495
8392
|
function encodeRegisterPubkeyCalldata(pubkey) {
|
|
7496
|
-
const bytes =
|
|
8393
|
+
const bytes = toBytes8(pubkey);
|
|
7497
8394
|
if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
7498
8395
|
throw new PubkeyRegistryError(
|
|
7499
8396
|
`pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
|
|
7500
8397
|
);
|
|
7501
8398
|
}
|
|
7502
|
-
return
|
|
7503
|
-
|
|
7504
|
-
|
|
7505
|
-
|
|
7506
|
-
|
|
8399
|
+
return bytesToHex11(
|
|
8400
|
+
concatBytes10(
|
|
8401
|
+
hexToBytes10(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
|
|
8402
|
+
uint256Word2(32n),
|
|
8403
|
+
uint256Word2(BigInt(bytes.length)),
|
|
7507
8404
|
bytes
|
|
7508
8405
|
)
|
|
7509
8406
|
);
|
|
@@ -7515,7 +8412,7 @@ function encodeHasPubkeyCalldata(address) {
|
|
|
7515
8412
|
return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
|
|
7516
8413
|
}
|
|
7517
8414
|
function decodeLookupPubkeyReturn(data) {
|
|
7518
|
-
const bytes =
|
|
8415
|
+
const bytes = toBytes8(data);
|
|
7519
8416
|
if (bytes.length < 96) {
|
|
7520
8417
|
throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
|
|
7521
8418
|
}
|
|
@@ -7540,7 +8437,7 @@ function decodeLookupPubkeyReturn(data) {
|
|
|
7540
8437
|
};
|
|
7541
8438
|
}
|
|
7542
8439
|
function decodeHasPubkeyReturn(data) {
|
|
7543
|
-
const bytes =
|
|
8440
|
+
const bytes = toBytes8(data);
|
|
7544
8441
|
if (bytes.length !== 32) {
|
|
7545
8442
|
throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
|
|
7546
8443
|
}
|
|
@@ -7554,10 +8451,10 @@ function decodeHasPubkeyReturn(data) {
|
|
|
7554
8451
|
throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
|
|
7555
8452
|
}
|
|
7556
8453
|
function encodeSingleAddressCall2(selector, address) {
|
|
7557
|
-
return
|
|
8454
|
+
return bytesToHex11(concatBytes10(hexToBytes10(selector), addressWord3(toAddressBytes(address))));
|
|
7558
8455
|
}
|
|
7559
|
-
function
|
|
7560
|
-
return
|
|
8456
|
+
function addressWord3(address) {
|
|
8457
|
+
return concatBytes10(new Uint8Array(12), address);
|
|
7561
8458
|
}
|
|
7562
8459
|
function toAddressBytes(value) {
|
|
7563
8460
|
if (typeof value !== "string") {
|
|
@@ -7573,13 +8470,13 @@ function toAddressBytes(value) {
|
|
|
7573
8470
|
throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
|
|
7574
8471
|
}
|
|
7575
8472
|
}
|
|
7576
|
-
function
|
|
8473
|
+
function toBytes8(value) {
|
|
7577
8474
|
if (typeof value === "string") {
|
|
7578
|
-
return
|
|
8475
|
+
return hexToBytes10(value);
|
|
7579
8476
|
}
|
|
7580
8477
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7581
8478
|
}
|
|
7582
|
-
function
|
|
8479
|
+
function hexToBytes10(hex) {
|
|
7583
8480
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7584
8481
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7585
8482
|
throw new PubkeyRegistryError("invalid hex bytes");
|
|
@@ -7590,10 +8487,10 @@ function hexToBytes9(hex) {
|
|
|
7590
8487
|
}
|
|
7591
8488
|
return out;
|
|
7592
8489
|
}
|
|
7593
|
-
function
|
|
8490
|
+
function bytesToHex11(bytes) {
|
|
7594
8491
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7595
8492
|
}
|
|
7596
|
-
function
|
|
8493
|
+
function concatBytes10(...parts) {
|
|
7597
8494
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7598
8495
|
let offset = 0;
|
|
7599
8496
|
for (const part of parts) {
|
|
@@ -7602,7 +8499,7 @@ function concatBytes8(...parts) {
|
|
|
7602
8499
|
}
|
|
7603
8500
|
return out;
|
|
7604
8501
|
}
|
|
7605
|
-
function
|
|
8502
|
+
function uint256Word2(value) {
|
|
7606
8503
|
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
7607
8504
|
throw new PubkeyRegistryError("uint256 value out of range");
|
|
7608
8505
|
}
|
|
@@ -7750,9 +8647,9 @@ function encodePlaceLimitOrderCalldata(args) {
|
|
|
7750
8647
|
normalized.baseTokenId,
|
|
7751
8648
|
normalized.quoteTokenId,
|
|
7752
8649
|
uint8Word2(normalized.side),
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
8650
|
+
uint256Word3(normalized.price, "price"),
|
|
8651
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
8652
|
+
uint64Word4(normalized.expiryBlock, "expiryBlock")
|
|
7756
8653
|
)
|
|
7757
8654
|
);
|
|
7758
8655
|
}
|
|
@@ -7764,7 +8661,7 @@ function encodePlaceMarketOrderCalldata(args) {
|
|
|
7764
8661
|
normalized.baseTokenId,
|
|
7765
8662
|
normalized.quoteTokenId,
|
|
7766
8663
|
uint8Word2(normalized.side),
|
|
7767
|
-
|
|
8664
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7768
8665
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps")
|
|
7769
8666
|
)
|
|
7770
8667
|
);
|
|
@@ -7777,7 +8674,7 @@ function encodePlaceMarketOrderExCalldata(args) {
|
|
|
7777
8674
|
normalized.baseTokenId,
|
|
7778
8675
|
normalized.quoteTokenId,
|
|
7779
8676
|
uint8Word2(normalized.side),
|
|
7780
|
-
|
|
8677
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7781
8678
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps"),
|
|
7782
8679
|
uint8Word2(normalized.mode)
|
|
7783
8680
|
)
|
|
@@ -7797,7 +8694,7 @@ function encodeMarketGridTuneCalldata(selector, label, args) {
|
|
|
7797
8694
|
hexToBytes2(selector, `${label} selector`),
|
|
7798
8695
|
bytes32FromHex(args.baseTokenId, "baseTokenId"),
|
|
7799
8696
|
bytes32FromHex(args.quoteTokenId, "quoteTokenId"),
|
|
7800
|
-
|
|
8697
|
+
uint256Word3(BigInt(args.newValue), "newValue")
|
|
7801
8698
|
)
|
|
7802
8699
|
);
|
|
7803
8700
|
}
|
|
@@ -8085,13 +8982,13 @@ function encodePlaceLimitOrderViaCalldata(args) {
|
|
|
8085
8982
|
return bytesToHex2(
|
|
8086
8983
|
concatBytes2(
|
|
8087
8984
|
hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
|
|
8088
|
-
|
|
8985
|
+
addressWord4(operator.bytes),
|
|
8089
8986
|
bytes32FromHex(args.base, "base"),
|
|
8090
8987
|
bytes32FromHex(args.quote, "quote"),
|
|
8091
8988
|
uint8Word2(side),
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
|
-
|
|
8989
|
+
uint256Word3(price, "price"),
|
|
8990
|
+
uint256Word3(amount, "amount"),
|
|
8991
|
+
uint64Word4(expiresAtBlock, "expiresAtBlock")
|
|
8095
8992
|
)
|
|
8096
8993
|
);
|
|
8097
8994
|
}
|
|
@@ -8381,7 +9278,7 @@ function uint8Word2(value) {
|
|
|
8381
9278
|
out[31] = value;
|
|
8382
9279
|
return out;
|
|
8383
9280
|
}
|
|
8384
|
-
function
|
|
9281
|
+
function uint64Word4(value, name) {
|
|
8385
9282
|
if (value < 0n || value > 0xffffffffffffffffn) {
|
|
8386
9283
|
throw new MarketActionError(`${name} must fit uint64`);
|
|
8387
9284
|
}
|
|
@@ -8402,7 +9299,7 @@ function uint16Word2(value, name) {
|
|
|
8402
9299
|
out[31] = Number(value & 0xffn);
|
|
8403
9300
|
return out;
|
|
8404
9301
|
}
|
|
8405
|
-
function
|
|
9302
|
+
function uint256Word3(value, name) {
|
|
8406
9303
|
if (value < 0n || value >= 1n << 256n) {
|
|
8407
9304
|
throw new MarketActionError(`${name} must fit uint256`);
|
|
8408
9305
|
}
|
|
@@ -8414,7 +9311,7 @@ function uint256Word2(value, name) {
|
|
|
8414
9311
|
}
|
|
8415
9312
|
return out;
|
|
8416
9313
|
}
|
|
8417
|
-
function
|
|
9314
|
+
function addressWord4(addr) {
|
|
8418
9315
|
if (addr.length !== 20) {
|
|
8419
9316
|
throw new MarketActionError("address must be 20 bytes");
|
|
8420
9317
|
}
|
|
@@ -8956,6 +9853,6 @@ var MONOLYTHIUM_NETWORKS = {
|
|
|
8956
9853
|
// src/index.ts
|
|
8957
9854
|
var version = "0.2.2";
|
|
8958
9855
|
|
|
8959
|
-
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, CLUSTER_FORMED_EVENT_SIG, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DIVERSITY_SCORE_MAX, DelegationPrecompileError, EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MULTISIG_ADDRESS_DERIVATION_DOMAIN, MarketActionError, MrvValidationError, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NoEvmReceiptProofError, NodeRegistryError, OPERATOR_ROUTER_ADDRESS, OPERATOR_ROUTER_EVENT_SIGS, OPERATOR_ROUTER_SELECTORS, OPERATOR_ROUTER_SIGS, ORACLE_EVENT_SIGS, OracleEventError, PRECOMPILE_ADDRESSES, PROTOCOL_MAX_OPERATOR_FEE_BPS, PROVER_MARKET_ADDRESS, PROVER_MARKET_BID_DOMAIN, PROVER_MARKET_EVENT_SIGS, PROVER_MARKET_REQUEST_DOMAIN, PROVER_MARKET_SELECTORS, PROVER_MARKET_SUBMIT_DOMAIN, PROVER_SLASH_REASON_BAD_PROOF, PROVER_SLASH_REASON_NON_DELIVERY, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, ProverMarketError, PubkeyRegistryError, REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bidSighash, bridgeAddressHex, bridgeDrainRemaining, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceLimitOrderViaPlan, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, consumeNativeEvents, decodeClusterDiversity, decodeClusterFormedEvent, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodeTimeWindow, decodeTxFeedResponse, delegationAddressHex, deriveClobMarketId, deriveClusterAnchorAddress, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, encodeBlockSelector, encodeCancelOrderCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceLimitOrderViaCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeUndelegateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeHostingClassFromByte, nodeHostingClassToByte, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, oracleAddressHex, packTimeWindow, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseLythToLythoshi, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, requestSighash, requireTypedAddress, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitSighash, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
9856
|
+
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, CLUSTER_FORMED_EVENT_SIG, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DIVERSITY_SCORE_MAX, DelegationPrecompileError, EMPTY_ROOT, EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER, FEED_ID_DOMAIN_TAG, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MULTISIG_ADDRESS_DERIVATION_DOMAIN, MarketActionError, MrvValidationError, NAME_BASE_MULTIPLIER, NAME_FALLBACK_FEE_UNIT_LYTHOSHI, NAME_LABEL_MAX_LEN, NAME_LABEL_MIN_LEN, NAME_MAX_LEN, NAME_REGISTRY_SELECTORS, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_BLS_PUBKEY_BYTES, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS, NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS, NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES, NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NameRegistryError, NoEvmReceiptProofError, NodeRegistryError, OPERATOR_ROUTER_ADDRESS, OPERATOR_ROUTER_EVENT_SIGS, OPERATOR_ROUTER_SELECTORS, OPERATOR_ROUTER_SIGS, ORACLE_EVENT_SIGS, OracleEventError, PENDING_CHANGE_KIND_CODES, PRECOMPILE_ADDRESSES, PROTOCOL_MAX_OPERATOR_FEE_BPS, PROVER_MARKET_ADDRESS, PROVER_MARKET_BID_DOMAIN, PROVER_MARKET_EVENT_SIGS, PROVER_MARKET_REQUEST_DOMAIN, PROVER_MARKET_SELECTORS, PROVER_MARKET_SUBMIT_DOMAIN, PROVER_SLASH_REASON_BAD_PROOF, PROVER_SLASH_REASON_NON_DELIVERY, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, ProverMarketError, PubkeyRegistryError, REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, allowRootFor, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bidSighash, bridgeAddressHex, bridgeDrainRemaining, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceLimitOrderViaPlan, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, categoryRoot, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, clusterApyPercent, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, computeQuoteLiquidity, consumeNativeEvents, decodeClusterDiversity, decodeClusterFormedEvent, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodeTimeWindow, decodeTxFeedResponse, delegationAddressHex, denyRootFor, deriveClobMarketId, deriveClusterAnchorAddress, deriveFeedId, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, destinationRoot, encodeAttestDkgReshareCalldata, encodeBlockSelector, encodeBridgeChallengeCalldata, encodeBridgeClaimCalldata, encodeCancelOrderCalldata, encodeCancelPendingChangeCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNameAcceptTransferCall, encodeNameProposeTransferCall, encodeNameRegisterCall, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceLimitOrderViaCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRecoverOperatorNodeCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeSubmitBridgeProofCalldata, encodeSubmitPendingChangeCalldata, encodeUndelegateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, formatOraclePrice, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nameLengthModifierX10, nameRegistrationCost, nameRegistryAddressHex, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeHostingClassFromByte, nodeHostingClassToByte, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, normalizePendingChangeKind, oracleAddressHex, oraclePriceToNumber, packTimeWindow, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseDkgResharePublicKeys, parseLythToLythoshi, parseNameCategory, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, rankMarketsByVolume, requestSighash, requireTypedAddress, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, setDestinationRoot, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitSighash, transactionFeeExposure, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
8960
9857
|
//# sourceMappingURL=index.js.map
|
|
8961
9858
|
//# sourceMappingURL=index.js.map
|