@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.cjs
CHANGED
|
@@ -422,6 +422,14 @@ var SERVICE_PROBE_STATUS = {
|
|
|
422
422
|
UNREACHABLE: 3
|
|
423
423
|
};
|
|
424
424
|
var NODE_REGISTRY_SELECTORS = {
|
|
425
|
+
/** `recoverOperatorNode(bytes32)` — foundation-gated DR alias for `unjail`. */
|
|
426
|
+
recoverOperatorNode: "0x" + selectorHex("recoverOperatorNode(bytes32)"),
|
|
427
|
+
/** `submitPendingChange(uint8,bytes,uint64,uint64)` — foundation-gated roster lifecycle. */
|
|
428
|
+
submitPendingChange: "0x" + selectorHex("submitPendingChange(uint8,bytes,uint64,uint64)"),
|
|
429
|
+
/** `cancelPendingChange(uint64,bytes)` — foundation-gated pending-change cancellation. */
|
|
430
|
+
cancelPendingChange: "0x" + selectorHex("cancelPendingChange(uint64,bytes)"),
|
|
431
|
+
/** `attestDkgReshare(uint64,bytes,bytes)` — operator-signed DKG re-share attestation. */
|
|
432
|
+
attestDkgReshare: "0x" + selectorHex("attestDkgReshare(uint64,bytes,bytes)"),
|
|
425
433
|
reportServiceProbe: "0xeee31bba",
|
|
426
434
|
getServiceProbe: "0x1fcbfbce",
|
|
427
435
|
/** `setNetworkMetadata(bytes32,uint16,bytes3,bytes)` — owner-callable (PF-6). */
|
|
@@ -431,6 +439,21 @@ var NODE_REGISTRY_SELECTORS = {
|
|
|
431
439
|
/** `getClusterDiversity(uint32)` view (PF-6). */
|
|
432
440
|
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)")
|
|
433
441
|
};
|
|
442
|
+
var NODE_REGISTRY_BLS_PUBKEY_BYTES = 48;
|
|
443
|
+
var NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = 96;
|
|
444
|
+
var NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = 5;
|
|
445
|
+
var NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS = 7;
|
|
446
|
+
var NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = (1n << 56n) - 1n;
|
|
447
|
+
var PENDING_CHANGE_KIND_CODES = {
|
|
448
|
+
add: 1,
|
|
449
|
+
remove: 2,
|
|
450
|
+
rotate: 3
|
|
451
|
+
};
|
|
452
|
+
var PENDING_CHANGE_KIND_LABELS = {
|
|
453
|
+
1: "add",
|
|
454
|
+
2: "remove",
|
|
455
|
+
3: "rotate"
|
|
456
|
+
};
|
|
434
457
|
var CLUSTER_FORMED_EVENT_SIG = "ClusterFormed(uint32,uint64,address,bytes)";
|
|
435
458
|
var NodeRegistryError = class extends Error {
|
|
436
459
|
constructor(message) {
|
|
@@ -465,6 +488,131 @@ function serviceProbeStatusLabel(status) {
|
|
|
465
488
|
return "unknown";
|
|
466
489
|
}
|
|
467
490
|
}
|
|
491
|
+
function normalizePendingChangeKind(kind) {
|
|
492
|
+
if (typeof kind === "number") {
|
|
493
|
+
const label = PENDING_CHANGE_KIND_LABELS[kind];
|
|
494
|
+
if (!label) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
495
|
+
return { kind: label, kindCode: kind };
|
|
496
|
+
}
|
|
497
|
+
const kindCode = PENDING_CHANGE_KIND_CODES[kind];
|
|
498
|
+
if (!kindCode) throw new NodeRegistryError(`unknown pending-change kind ${kind}`);
|
|
499
|
+
return { kind, kindCode };
|
|
500
|
+
}
|
|
501
|
+
function encodeRecoverOperatorNodeCalldata(peerId) {
|
|
502
|
+
return bytesToHex(
|
|
503
|
+
concatBytes(
|
|
504
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.recoverOperatorNode),
|
|
505
|
+
expectLength2(toBytes(peerId), 32, "peerId")
|
|
506
|
+
)
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
function encodeSubmitPendingChangeCalldata(args) {
|
|
510
|
+
const { kind, kindCode } = normalizePendingChangeKind(args.kind);
|
|
511
|
+
const targetPubkey = expectLength2(
|
|
512
|
+
toBytes(args.targetPubkey),
|
|
513
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
514
|
+
"targetPubkey"
|
|
515
|
+
);
|
|
516
|
+
const effectiveEpoch = toUint64(args.effectiveEpoch, "effectiveEpoch");
|
|
517
|
+
if (effectiveEpoch === 0n) {
|
|
518
|
+
throw new NodeRegistryError("effectiveEpoch must be greater than zero");
|
|
519
|
+
}
|
|
520
|
+
const intentId = toUint64(args.intentId ?? 0n, "intentId");
|
|
521
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
522
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
523
|
+
}
|
|
524
|
+
if (kind !== "rotate" && intentId !== 0n) {
|
|
525
|
+
throw new NodeRegistryError("only rotate pending changes may carry a non-zero intentId");
|
|
526
|
+
}
|
|
527
|
+
const targetTail = new Uint8Array(32);
|
|
528
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
529
|
+
return bytesToHex(
|
|
530
|
+
concatBytes(
|
|
531
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.submitPendingChange),
|
|
532
|
+
uint8Word(kindCode),
|
|
533
|
+
uint64Word(4n * 32n, "targetPubkeyOffset"),
|
|
534
|
+
uint64Word(effectiveEpoch, "effectiveEpoch"),
|
|
535
|
+
uint64Word(intentId, "intentId"),
|
|
536
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
537
|
+
targetPubkey.slice(0, 32),
|
|
538
|
+
targetTail
|
|
539
|
+
)
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
function encodeCancelPendingChangeCalldata(args) {
|
|
543
|
+
const targetPubkey = expectLength2(
|
|
544
|
+
toBytes(args.targetPubkey),
|
|
545
|
+
NODE_REGISTRY_BLS_PUBKEY_BYTES,
|
|
546
|
+
"targetPubkey"
|
|
547
|
+
);
|
|
548
|
+
const targetTail = new Uint8Array(32);
|
|
549
|
+
targetTail.set(targetPubkey.slice(32, 48), 0);
|
|
550
|
+
return bytesToHex(
|
|
551
|
+
concatBytes(
|
|
552
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.cancelPendingChange),
|
|
553
|
+
uint64Word(args.epoch, "epoch"),
|
|
554
|
+
uint64Word(2n * 32n, "targetPubkeyOffset"),
|
|
555
|
+
uint64Word(BigInt(NODE_REGISTRY_BLS_PUBKEY_BYTES), "targetPubkeyLength"),
|
|
556
|
+
targetPubkey.slice(0, 32),
|
|
557
|
+
targetTail
|
|
558
|
+
)
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
function parseDkgResharePublicKeys(blsPublicKeys) {
|
|
562
|
+
const keys = toBytes(blsPublicKeys);
|
|
563
|
+
if (keys.length % NODE_REGISTRY_BLS_PUBKEY_BYTES !== 0) {
|
|
564
|
+
throw new NodeRegistryError("blsPublicKeys length must be a multiple of 48 bytes");
|
|
565
|
+
}
|
|
566
|
+
const signerCount = keys.length / NODE_REGISTRY_BLS_PUBKEY_BYTES;
|
|
567
|
+
if (signerCount < NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS || signerCount > NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS) {
|
|
568
|
+
throw new NodeRegistryError(
|
|
569
|
+
`blsPublicKeys must contain ${NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS}..${NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS} signers`
|
|
570
|
+
);
|
|
571
|
+
}
|
|
572
|
+
const out = [];
|
|
573
|
+
const seen = /* @__PURE__ */ new Set();
|
|
574
|
+
for (let offset = 0; offset < keys.length; offset += NODE_REGISTRY_BLS_PUBKEY_BYTES) {
|
|
575
|
+
const key = keys.slice(offset, offset + NODE_REGISTRY_BLS_PUBKEY_BYTES);
|
|
576
|
+
const keyHex = bytesToHex(key);
|
|
577
|
+
if (seen.has(keyHex)) {
|
|
578
|
+
throw new NodeRegistryError("blsPublicKeys contains a duplicate signer pubkey");
|
|
579
|
+
}
|
|
580
|
+
seen.add(keyHex);
|
|
581
|
+
out.push(key);
|
|
582
|
+
}
|
|
583
|
+
return out;
|
|
584
|
+
}
|
|
585
|
+
function encodeAttestDkgReshareCalldata(args) {
|
|
586
|
+
const intentId = toUint64(args.intentId, "intentId");
|
|
587
|
+
if (intentId === 0n) {
|
|
588
|
+
throw new NodeRegistryError("intentId must be greater than zero");
|
|
589
|
+
}
|
|
590
|
+
if (intentId > NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID) {
|
|
591
|
+
throw new NodeRegistryError("intentId must be <= 2^56-1");
|
|
592
|
+
}
|
|
593
|
+
const publicKeys = concatBytes(...parseDkgResharePublicKeys(args.blsPublicKeys));
|
|
594
|
+
const thresholdSig = expectLength2(
|
|
595
|
+
toBytes(args.thresholdSig),
|
|
596
|
+
NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES,
|
|
597
|
+
"thresholdSig"
|
|
598
|
+
);
|
|
599
|
+
const keysPadded = padToWord(publicKeys);
|
|
600
|
+
const sigPadded = padToWord(thresholdSig);
|
|
601
|
+
const offsetKeys = 3n * 32n;
|
|
602
|
+
const offsetSig = offsetKeys + 32n + BigInt(keysPadded.length);
|
|
603
|
+
return bytesToHex(
|
|
604
|
+
concatBytes(
|
|
605
|
+
hexToBytes(NODE_REGISTRY_SELECTORS.attestDkgReshare),
|
|
606
|
+
uint64Word(intentId, "intentId"),
|
|
607
|
+
uint64Word(offsetKeys, "blsPublicKeysOffset"),
|
|
608
|
+
uint64Word(offsetSig, "thresholdSigOffset"),
|
|
609
|
+
uint64Word(BigInt(publicKeys.length), "blsPublicKeysLength"),
|
|
610
|
+
keysPadded,
|
|
611
|
+
uint64Word(BigInt(thresholdSig.length), "thresholdSigLength"),
|
|
612
|
+
sigPadded
|
|
613
|
+
)
|
|
614
|
+
);
|
|
615
|
+
}
|
|
468
616
|
function encodeReportServiceProbeCalldata(args) {
|
|
469
617
|
if (!isValidPublicServiceProbeMask(args.serviceMask)) {
|
|
470
618
|
throw new NodeRegistryError(
|
|
@@ -624,6 +772,44 @@ function uint8Word(value) {
|
|
|
624
772
|
out[31] = value;
|
|
625
773
|
return out;
|
|
626
774
|
}
|
|
775
|
+
function uint64Word(value, name) {
|
|
776
|
+
const n = toUint64(value, name);
|
|
777
|
+
const out = new Uint8Array(32);
|
|
778
|
+
let rest = n;
|
|
779
|
+
for (let i = 31; i >= 24; i--) {
|
|
780
|
+
out[i] = Number(rest & 0xffn);
|
|
781
|
+
rest >>= 8n;
|
|
782
|
+
}
|
|
783
|
+
return out;
|
|
784
|
+
}
|
|
785
|
+
function toUint64(value, name) {
|
|
786
|
+
let parsed;
|
|
787
|
+
if (typeof value === "bigint") {
|
|
788
|
+
parsed = value;
|
|
789
|
+
} else if (typeof value === "number") {
|
|
790
|
+
if (!Number.isSafeInteger(value)) {
|
|
791
|
+
throw new NodeRegistryError(`${name} must be a safe integer`);
|
|
792
|
+
}
|
|
793
|
+
parsed = BigInt(value);
|
|
794
|
+
} else {
|
|
795
|
+
const trimmed = value.trim();
|
|
796
|
+
if (!/^\d+$/u.test(trimmed)) {
|
|
797
|
+
throw new NodeRegistryError(`${name} must be a decimal uint64`);
|
|
798
|
+
}
|
|
799
|
+
parsed = BigInt(trimmed);
|
|
800
|
+
}
|
|
801
|
+
if (parsed < 0n || parsed > 0xffffffffffffffffn) {
|
|
802
|
+
throw new NodeRegistryError(`${name} must fit uint64`);
|
|
803
|
+
}
|
|
804
|
+
return parsed;
|
|
805
|
+
}
|
|
806
|
+
function padToWord(bytes) {
|
|
807
|
+
const paddedLength = Math.ceil(bytes.length / 32) * 32;
|
|
808
|
+
if (paddedLength === bytes.length) return bytes;
|
|
809
|
+
const out = new Uint8Array(paddedLength);
|
|
810
|
+
out.set(bytes);
|
|
811
|
+
return out;
|
|
812
|
+
}
|
|
627
813
|
function toBytes(value) {
|
|
628
814
|
if (typeof value === "string") {
|
|
629
815
|
return hexToBytes(value);
|
|
@@ -1822,9 +2008,16 @@ var TESTNET_69420 = {
|
|
|
1822
2008
|
network: "testnet-69420",
|
|
1823
2009
|
display_name: "Monolythium Testnet",
|
|
1824
2010
|
description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
|
|
1825
|
-
genesis_hash: "
|
|
1826
|
-
binary_sha: "
|
|
2011
|
+
genesis_hash: "0xe67cf82131fc63e335ce61afeae53299283eaa3a692830a618911aa840245031",
|
|
2012
|
+
binary_sha: "e4697f9b",
|
|
1827
2013
|
rpc: [
|
|
2014
|
+
{
|
|
2015
|
+
url: "http://178.105.12.9:8545",
|
|
2016
|
+
provider: "monolythium-foundation",
|
|
2017
|
+
region: "fsn1",
|
|
2018
|
+
tier: "official",
|
|
2019
|
+
notes: "operator-1"
|
|
2020
|
+
},
|
|
1828
2021
|
{
|
|
1829
2022
|
url: "http://178.105.15.216:8545",
|
|
1830
2023
|
provider: "monolythium-foundation",
|
|
@@ -1866,9 +2059,107 @@ var TESTNET_69420 = {
|
|
|
1866
2059
|
region: "sin",
|
|
1867
2060
|
tier: "official",
|
|
1868
2061
|
notes: "operator-7; APAC"
|
|
2062
|
+
},
|
|
2063
|
+
{
|
|
2064
|
+
url: "http://142.132.180.99:8545",
|
|
2065
|
+
provider: "monolythium-foundation",
|
|
2066
|
+
region: "fsn1",
|
|
2067
|
+
tier: "official",
|
|
2068
|
+
notes: "operator-8"
|
|
2069
|
+
},
|
|
2070
|
+
{
|
|
2071
|
+
url: "http://162.55.54.198:8545",
|
|
2072
|
+
provider: "monolythium-foundation",
|
|
2073
|
+
region: "nbg1",
|
|
2074
|
+
tier: "official",
|
|
2075
|
+
notes: "operator-9"
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
url: "http://95.217.156.190:8545",
|
|
2079
|
+
provider: "monolythium-foundation",
|
|
2080
|
+
region: "hel1",
|
|
2081
|
+
tier: "official",
|
|
2082
|
+
notes: "operator-10"
|
|
2083
|
+
},
|
|
2084
|
+
{
|
|
2085
|
+
url: "http://5.223.65.201:8545",
|
|
2086
|
+
provider: "monolythium-foundation",
|
|
2087
|
+
region: "sin",
|
|
2088
|
+
tier: "official",
|
|
2089
|
+
notes: "operator-11; APAC"
|
|
2090
|
+
},
|
|
2091
|
+
{
|
|
2092
|
+
url: "http://128.140.125.5:8545",
|
|
2093
|
+
provider: "monolythium-foundation",
|
|
2094
|
+
region: "fsn1",
|
|
2095
|
+
tier: "official",
|
|
2096
|
+
notes: "operator-12"
|
|
2097
|
+
},
|
|
2098
|
+
{
|
|
2099
|
+
url: "http://178.105.45.210:8545",
|
|
2100
|
+
provider: "monolythium-foundation",
|
|
2101
|
+
region: "nbg1",
|
|
2102
|
+
tier: "official",
|
|
2103
|
+
notes: "relay-1"
|
|
2104
|
+
},
|
|
2105
|
+
{
|
|
2106
|
+
url: "http://65.21.252.34:8545",
|
|
2107
|
+
provider: "monolythium-foundation",
|
|
2108
|
+
region: "hel1",
|
|
2109
|
+
tier: "official",
|
|
2110
|
+
notes: "relay-2"
|
|
1869
2111
|
}
|
|
1870
2112
|
],
|
|
1871
|
-
p2p: [
|
|
2113
|
+
p2p: [
|
|
2114
|
+
{
|
|
2115
|
+
multiaddr: "/ip4/178.105.12.9/tcp/29898/p2p/12D3KooWPv4ctqZX9faHicr8dJifyBwrpPA4oBev7w2WZStejMKa",
|
|
2116
|
+
region: "fsn1"
|
|
2117
|
+
},
|
|
2118
|
+
{
|
|
2119
|
+
multiaddr: "/ip4/178.105.15.216/tcp/29898/p2p/12D3KooWFZqKgAbve2dsAm9kKomychF4dyhtJYHL13mzh3D62d1r",
|
|
2120
|
+
region: "fsn1"
|
|
2121
|
+
},
|
|
2122
|
+
{
|
|
2123
|
+
multiaddr: "/ip4/178.104.233.182/tcp/29898/p2p/12D3KooWMG1tbP4hcvqdPP8QmnnPjaJCs4M1GUskzAJsL15ZFcVX",
|
|
2124
|
+
region: "nbg1"
|
|
2125
|
+
},
|
|
2126
|
+
{
|
|
2127
|
+
multiaddr: "/ip4/65.108.94.1/tcp/29898/p2p/12D3KooWR5cz3fR4YkDDoPmQ6Qe7fmsXA7zo5AqdHY5Enmk5bKyT",
|
|
2128
|
+
region: "hel1"
|
|
2129
|
+
},
|
|
2130
|
+
{
|
|
2131
|
+
multiaddr: "/ip4/95.216.154.155/tcp/29898/p2p/12D3KooWFJHH3zgAaPtSBXPkCEKeGNCWQTn1QYcm4YCr5VFT3GbC",
|
|
2132
|
+
region: "hel1"
|
|
2133
|
+
},
|
|
2134
|
+
{
|
|
2135
|
+
multiaddr: "/ip4/87.99.145.48/tcp/29898/p2p/12D3KooWSDQdjgoiEbvsLErphM52u8tETdBtgyr4mbHQC5pT6HQz",
|
|
2136
|
+
region: "ash"
|
|
2137
|
+
},
|
|
2138
|
+
{
|
|
2139
|
+
multiaddr: "/ip4/5.223.85.76/tcp/29898/p2p/12D3KooWKHgMQnBtSfZqUknJdhGK8niKKbLXy81ifHV2khRgAYFX",
|
|
2140
|
+
region: "sin"
|
|
2141
|
+
},
|
|
2142
|
+
{
|
|
2143
|
+
multiaddr: "/ip4/142.132.180.99/tcp/29898/p2p/12D3KooWBx29V8iNQL22jk2CSVbvhodtXy4uTXVG7AgobxNcUuyP",
|
|
2144
|
+
region: "fsn1"
|
|
2145
|
+
},
|
|
2146
|
+
{
|
|
2147
|
+
multiaddr: "/ip4/162.55.54.198/tcp/29898/p2p/12D3KooWJK2w6xzRFJMHWMxVuXpBHZE7PtDNGahEp9rq86AuhNRk",
|
|
2148
|
+
region: "nbg1"
|
|
2149
|
+
},
|
|
2150
|
+
{
|
|
2151
|
+
multiaddr: "/ip4/95.217.156.190/tcp/29898/p2p/12D3KooWLD8kzKHPVexZv2pMTvpjcEPTVZxr5qMxCeVB2QR6NNa6",
|
|
2152
|
+
region: "hel1"
|
|
2153
|
+
},
|
|
2154
|
+
{
|
|
2155
|
+
multiaddr: "/ip4/5.223.65.201/tcp/29898/p2p/12D3KooWAHC1cCiVsyVqrg4ofS2EQmu6Pv6G9Rc1t5btmoW6YicJ",
|
|
2156
|
+
region: "sin"
|
|
2157
|
+
},
|
|
2158
|
+
{
|
|
2159
|
+
multiaddr: "/ip4/128.140.125.5/tcp/29898/p2p/12D3KooWNAc4EWkWWprKvqoF5aiq1ByqsLQjSN7r9ZTwYgGW365r",
|
|
2160
|
+
region: "fsn1"
|
|
2161
|
+
}
|
|
2162
|
+
]
|
|
1872
2163
|
};
|
|
1873
2164
|
var CHAIN_REGISTRY = {
|
|
1874
2165
|
"testnet-69420": TESTNET_69420
|
|
@@ -2325,6 +2616,192 @@ function encodeBlockSelector(b) {
|
|
|
2325
2616
|
if (typeof b === "bigint") return `0x${b.toString(16)}`;
|
|
2326
2617
|
return b;
|
|
2327
2618
|
}
|
|
2619
|
+
var NameRegistryError = class extends Error {
|
|
2620
|
+
constructor(message) {
|
|
2621
|
+
super(message);
|
|
2622
|
+
this.name = "NameRegistryError";
|
|
2623
|
+
}
|
|
2624
|
+
};
|
|
2625
|
+
var NAME_REGISTRY_SELECTORS = {
|
|
2626
|
+
register: selectorHex2("register(string,address)"),
|
|
2627
|
+
proposeTransfer: selectorHex2("proposeTransfer(string,address)"),
|
|
2628
|
+
acceptTransfer: selectorHex2("acceptTransfer(string)")
|
|
2629
|
+
};
|
|
2630
|
+
var NAME_BASE_MULTIPLIER = {
|
|
2631
|
+
human: 5,
|
|
2632
|
+
agent: 2,
|
|
2633
|
+
cluster: 20,
|
|
2634
|
+
contract: 10
|
|
2635
|
+
};
|
|
2636
|
+
var NAME_FALLBACK_FEE_UNIT_LYTHOSHI = 100n;
|
|
2637
|
+
var NAME_MAX_LEN = 80;
|
|
2638
|
+
var NAME_LABEL_MIN_LEN = 1;
|
|
2639
|
+
var NAME_LABEL_MAX_LEN = 63;
|
|
2640
|
+
function nameRegistryAddressHex() {
|
|
2641
|
+
return PRECOMPILE_ADDRESSES.NAME_REGISTRY.toLowerCase();
|
|
2642
|
+
}
|
|
2643
|
+
function nameLengthModifierX10(labelLen) {
|
|
2644
|
+
if (labelLen === 1) return 1e3;
|
|
2645
|
+
if (labelLen === 2) return 500;
|
|
2646
|
+
if (labelLen === 3) return 100;
|
|
2647
|
+
if (labelLen === 4) return 50;
|
|
2648
|
+
if (labelLen === 5) return 30;
|
|
2649
|
+
if (labelLen >= 6 && labelLen <= 12) return 10;
|
|
2650
|
+
if (labelLen >= 13 && labelLen <= 20) return 15;
|
|
2651
|
+
if (labelLen >= 21 && labelLen <= 32) return 30;
|
|
2652
|
+
if (labelLen >= 33 && labelLen <= 50) return 100;
|
|
2653
|
+
if (labelLen >= 51 && labelLen <= 63) return 500;
|
|
2654
|
+
return null;
|
|
2655
|
+
}
|
|
2656
|
+
function parseNameCategory(name) {
|
|
2657
|
+
if (name.length === 0) throw new NameRegistryError("name is empty");
|
|
2658
|
+
if (name.length > NAME_MAX_LEN) throw new NameRegistryError(`name exceeds ${NAME_MAX_LEN} chars`);
|
|
2659
|
+
const parts = name.split(".");
|
|
2660
|
+
if (parts.some((p) => p.length === 0)) {
|
|
2661
|
+
throw new NameRegistryError("name has an empty label");
|
|
2662
|
+
}
|
|
2663
|
+
for (const label of parts) validateLabel(label);
|
|
2664
|
+
if (parts[parts.length - 1] !== "mono") {
|
|
2665
|
+
throw new NameRegistryError("name must end with .mono");
|
|
2666
|
+
}
|
|
2667
|
+
const primaryLabelLen = parts[0].length;
|
|
2668
|
+
switch (parts.length) {
|
|
2669
|
+
case 2:
|
|
2670
|
+
if (STRUCTURAL_RESERVES.has(parts[0])) {
|
|
2671
|
+
throw new NameRegistryError(`"${parts[0]}.mono" is a structural reserve`);
|
|
2672
|
+
}
|
|
2673
|
+
return { category: "human", primaryLabelLen };
|
|
2674
|
+
case 3: {
|
|
2675
|
+
const anchor = parts[1];
|
|
2676
|
+
if (anchor === "cluster") return { category: "cluster", primaryLabelLen };
|
|
2677
|
+
if (anchor === "contract") return { category: "contract", primaryLabelLen };
|
|
2678
|
+
if (anchor === "system") return { category: "system", primaryLabelLen };
|
|
2679
|
+
throw new NameRegistryError(`unknown name category anchor ".${anchor}.mono"`);
|
|
2680
|
+
}
|
|
2681
|
+
case 4:
|
|
2682
|
+
if (parts[1] !== "agent") {
|
|
2683
|
+
throw new NameRegistryError("unknown 4-label name form (expected <x>.agent.<human>.mono)");
|
|
2684
|
+
}
|
|
2685
|
+
return { category: "agent", primaryLabelLen };
|
|
2686
|
+
default:
|
|
2687
|
+
throw new NameRegistryError("unrecognised name structure");
|
|
2688
|
+
}
|
|
2689
|
+
}
|
|
2690
|
+
function nameRegistrationCost(category, primaryLabelLen, feeUnitLythoshi) {
|
|
2691
|
+
if (category === "system") {
|
|
2692
|
+
throw new NameRegistryError("system names are not registerable via this path");
|
|
2693
|
+
}
|
|
2694
|
+
const base = BigInt(NAME_BASE_MULTIPLIER[category]);
|
|
2695
|
+
const modX10 = nameLengthModifierX10(primaryLabelLen);
|
|
2696
|
+
if (modX10 === null) {
|
|
2697
|
+
throw new NameRegistryError("primary label length is outside the priceable 1..=63 range");
|
|
2698
|
+
}
|
|
2699
|
+
return base * BigInt(modX10) * feeUnitLythoshi / 10n;
|
|
2700
|
+
}
|
|
2701
|
+
function encodeNameRegisterCall(name, owner) {
|
|
2702
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.register, name, owner);
|
|
2703
|
+
}
|
|
2704
|
+
function encodeNameProposeTransferCall(name, recipient) {
|
|
2705
|
+
return encodeStringAddressCall(NAME_REGISTRY_SELECTORS.proposeTransfer, name, recipient);
|
|
2706
|
+
}
|
|
2707
|
+
function encodeNameAcceptTransferCall(name) {
|
|
2708
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2709
|
+
return bytesToHex4(
|
|
2710
|
+
concatBytes4(
|
|
2711
|
+
hexToBytes4(NAME_REGISTRY_SELECTORS.acceptTransfer),
|
|
2712
|
+
// Single head word → the string offset is 0x20 (one word precedes the tail).
|
|
2713
|
+
uint256Word(0x20n),
|
|
2714
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2715
|
+
padTo32(nameBytes)
|
|
2716
|
+
)
|
|
2717
|
+
);
|
|
2718
|
+
}
|
|
2719
|
+
var STRUCTURAL_RESERVES = /* @__PURE__ */ new Set(["agent", "cluster", "contract", "system"]);
|
|
2720
|
+
function encodeStringAddressCall(selector, name, address) {
|
|
2721
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
2722
|
+
return bytesToHex4(
|
|
2723
|
+
concatBytes4(
|
|
2724
|
+
hexToBytes4(selector),
|
|
2725
|
+
// Two head words (string offset, address) → string tail starts at 0x40.
|
|
2726
|
+
uint256Word(0x40n),
|
|
2727
|
+
addressWord(address),
|
|
2728
|
+
uint256Word(BigInt(nameBytes.length)),
|
|
2729
|
+
padTo32(nameBytes)
|
|
2730
|
+
)
|
|
2731
|
+
);
|
|
2732
|
+
}
|
|
2733
|
+
function validateLabel(label) {
|
|
2734
|
+
if (label.length < NAME_LABEL_MIN_LEN || label.length > NAME_LABEL_MAX_LEN) {
|
|
2735
|
+
throw new NameRegistryError(`label "${label}" must be ${NAME_LABEL_MIN_LEN}..${NAME_LABEL_MAX_LEN} chars`);
|
|
2736
|
+
}
|
|
2737
|
+
if (label.startsWith("-") || label.endsWith("-")) {
|
|
2738
|
+
throw new NameRegistryError(`label "${label}" may not start or end with a hyphen`);
|
|
2739
|
+
}
|
|
2740
|
+
if (label.includes("--")) {
|
|
2741
|
+
throw new NameRegistryError(`label "${label}" may not contain a double hyphen`);
|
|
2742
|
+
}
|
|
2743
|
+
if (!/^[a-z0-9-]+$/.test(label)) {
|
|
2744
|
+
throw new NameRegistryError(`label "${label}" has an invalid char (allowed: a-z 0-9 -)`);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
function selectorHex2(signature) {
|
|
2748
|
+
const sel = sha3_js.keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
2749
|
+
return `0x${[...sel].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2750
|
+
}
|
|
2751
|
+
function addressWord(value) {
|
|
2752
|
+
const out = new Uint8Array(32);
|
|
2753
|
+
if (value == null) return out;
|
|
2754
|
+
const bytes = toBytes2(value);
|
|
2755
|
+
if (bytes.length !== 20) {
|
|
2756
|
+
throw new NameRegistryError(`address must be 20 bytes, got ${bytes.length}`);
|
|
2757
|
+
}
|
|
2758
|
+
out.set(bytes, 12);
|
|
2759
|
+
return out;
|
|
2760
|
+
}
|
|
2761
|
+
function uint256Word(value) {
|
|
2762
|
+
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
2763
|
+
throw new NameRegistryError("uint256 word out of range");
|
|
2764
|
+
}
|
|
2765
|
+
const out = new Uint8Array(32);
|
|
2766
|
+
let rest = value;
|
|
2767
|
+
for (let i = 31; i >= 0 && rest > 0n; i--) {
|
|
2768
|
+
out[i] = Number(rest & 0xffn);
|
|
2769
|
+
rest >>= 8n;
|
|
2770
|
+
}
|
|
2771
|
+
return out;
|
|
2772
|
+
}
|
|
2773
|
+
function padTo32(bytes) {
|
|
2774
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
2775
|
+
if (padded === bytes.length) return bytes;
|
|
2776
|
+
const out = new Uint8Array(padded);
|
|
2777
|
+
out.set(bytes);
|
|
2778
|
+
return out;
|
|
2779
|
+
}
|
|
2780
|
+
function toBytes2(value) {
|
|
2781
|
+
if (typeof value === "string") return hexToBytes4(value);
|
|
2782
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
2783
|
+
}
|
|
2784
|
+
function hexToBytes4(hex) {
|
|
2785
|
+
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
2786
|
+
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
2787
|
+
throw new NameRegistryError("invalid hex bytes");
|
|
2788
|
+
}
|
|
2789
|
+
const out = new Uint8Array(body.length / 2);
|
|
2790
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(body.slice(i * 2, i * 2 + 2), 16);
|
|
2791
|
+
return out;
|
|
2792
|
+
}
|
|
2793
|
+
function bytesToHex4(bytes) {
|
|
2794
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
2795
|
+
}
|
|
2796
|
+
function concatBytes4(...parts) {
|
|
2797
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
2798
|
+
let offset = 0;
|
|
2799
|
+
for (const part of parts) {
|
|
2800
|
+
out.set(part, offset);
|
|
2801
|
+
offset += part.length;
|
|
2802
|
+
}
|
|
2803
|
+
return out;
|
|
2804
|
+
}
|
|
2328
2805
|
|
|
2329
2806
|
// src/client.ts
|
|
2330
2807
|
var MAX_NATIVE_RECEIPT_EVENTS = 1e3;
|
|
@@ -3162,7 +3639,234 @@ var RpcClient = class _RpcClient {
|
|
|
3162
3639
|
async meshSubmitTx(signedTx) {
|
|
3163
3640
|
return this.call("mesh_submitTx", [signedTx]);
|
|
3164
3641
|
}
|
|
3642
|
+
// ---- lyth_* additions (R15 / wallet + monoscan surfaces) -----------
|
|
3643
|
+
/**
|
|
3644
|
+
* `lyth_clusterApr` — observed APR for a cluster over a rolling window.
|
|
3645
|
+
* `windowBlocks` defaults to the chain's 1200-block (~1h) window and is
|
|
3646
|
+
* server-clamped to `[10, 86_400]`.
|
|
3647
|
+
*/
|
|
3648
|
+
async lythClusterApr(clusterId, windowBlocks) {
|
|
3649
|
+
const params = windowBlocks === void 0 ? [clusterId] : [clusterId, windowBlocks];
|
|
3650
|
+
return normalizeClusterApr(await this.call("lyth_clusterApr", params));
|
|
3651
|
+
}
|
|
3652
|
+
/** `lyth_resolveName` — forward name → address resolution (0x110E). */
|
|
3653
|
+
async lythResolveName(name, block = "latest") {
|
|
3654
|
+
return this.call("lyth_resolveName", [name, encodeBlockSelector(block)]);
|
|
3655
|
+
}
|
|
3656
|
+
/** `lyth_nameOf` — reverse address → name resolution. */
|
|
3657
|
+
async lythNameOf(address, block = "latest") {
|
|
3658
|
+
return this.call("lyth_nameOf", [sdkTypedAddress(address, "user", "address"), encodeBlockSelector(block)]);
|
|
3659
|
+
}
|
|
3660
|
+
/** `lyth_getClusterName` — reverse cluster id → canonical name. */
|
|
3661
|
+
async lythGetClusterName(clusterId, block = "latest") {
|
|
3662
|
+
return this.call("lyth_getClusterName", [clusterId, encodeBlockSelector(block)]);
|
|
3663
|
+
}
|
|
3664
|
+
/**
|
|
3665
|
+
* Convenience over {@link lythResolveName}: `true` when a well-formed
|
|
3666
|
+
* name is unregistered. A malformed name throws `RpcError`
|
|
3667
|
+
* (`InvalidParams`) rather than returning `true`, so the UI should treat
|
|
3668
|
+
* a thrown validation error distinctly from "taken".
|
|
3669
|
+
*/
|
|
3670
|
+
async lythIsNameAvailable(name, block = "latest") {
|
|
3671
|
+
const resolved = await this.lythResolveName(name, block);
|
|
3672
|
+
return resolved.address === null;
|
|
3673
|
+
}
|
|
3674
|
+
/**
|
|
3675
|
+
* Live name-registration quote: parses the name's category + primary
|
|
3676
|
+
* label length, reads the chain's base fee unit via `eth_feeHistory`
|
|
3677
|
+
* (the bare `baseFeePerGas` — NOT `eth_gasPrice`, which adds the tip and
|
|
3678
|
+
* would over-quote), and applies the U-curve. The resulting
|
|
3679
|
+
* `costLythoshi` is what the `register` tx `value` must equal exactly
|
|
3680
|
+
* (else the precompile reverts `IncorrectFee`).
|
|
3681
|
+
*/
|
|
3682
|
+
async quoteNameRegistration(name, block = "latest") {
|
|
3683
|
+
const parsed = parseNameCategory(name);
|
|
3684
|
+
const history = await this.ethFeeHistory(1, block, []);
|
|
3685
|
+
const baseFees = history.baseFeePerGas ?? [];
|
|
3686
|
+
const lastHex = baseFees.length > 0 ? baseFees[baseFees.length - 1] : "0x0";
|
|
3687
|
+
const baseFee = parseQuantityBig(lastHex);
|
|
3688
|
+
const feeUnitLythoshi = baseFee > 0n ? baseFee : NAME_FALLBACK_FEE_UNIT_LYTHOSHI;
|
|
3689
|
+
return {
|
|
3690
|
+
name,
|
|
3691
|
+
category: parsed.category,
|
|
3692
|
+
primaryLabelLen: parsed.primaryLabelLen,
|
|
3693
|
+
feeUnitLythoshi,
|
|
3694
|
+
costLythoshi: nameRegistrationCost(parsed.category, parsed.primaryLabelLen, feeUnitLythoshi)
|
|
3695
|
+
};
|
|
3696
|
+
}
|
|
3697
|
+
/** `lyth_circulatingSupply` — native LYTH circulating / initial / burned (decimal lythoshi strings). */
|
|
3698
|
+
async lythCirculatingSupply() {
|
|
3699
|
+
return this.call("lyth_circulatingSupply", []);
|
|
3700
|
+
}
|
|
3701
|
+
/** `lyth_totalBurned` — cumulative burned native LYTH (decimal lythoshi string). */
|
|
3702
|
+
async lythTotalBurned() {
|
|
3703
|
+
return this.call("lyth_totalBurned", []);
|
|
3704
|
+
}
|
|
3705
|
+
/** `lyth_swapIntentStatus` — bridge swap-intent / DKG-reshare lifecycle for one intent id. */
|
|
3706
|
+
async lythSwapIntentStatus(intentId) {
|
|
3707
|
+
let id;
|
|
3708
|
+
if (typeof intentId === "number") {
|
|
3709
|
+
id = intentId;
|
|
3710
|
+
} else if (typeof intentId === "bigint") {
|
|
3711
|
+
id = `0x${intentId.toString(16)}`;
|
|
3712
|
+
} else if (intentId.startsWith("0x") || intentId.startsWith("0X")) {
|
|
3713
|
+
id = intentId;
|
|
3714
|
+
} else {
|
|
3715
|
+
id = `0x${BigInt(intentId).toString(16)}`;
|
|
3716
|
+
}
|
|
3717
|
+
return this.call("lyth_swapIntentStatus", [id]);
|
|
3718
|
+
}
|
|
3719
|
+
/**
|
|
3720
|
+
* Per-tx confirmation depth, derived from `lyth_txStatus` (which returns
|
|
3721
|
+
* both the tx's `blockNumber` and the node `latestHeight`).
|
|
3722
|
+
*/
|
|
3723
|
+
async lythTxConfirmations(txHash) {
|
|
3724
|
+
const status = await this.lythTxStatus(txHash);
|
|
3725
|
+
if (status.status === "found") {
|
|
3726
|
+
return {
|
|
3727
|
+
status: "found",
|
|
3728
|
+
confirmations: status.latestHeight - status.blockNumber + 1,
|
|
3729
|
+
blockNumber: status.blockNumber,
|
|
3730
|
+
latestHeight: status.latestHeight
|
|
3731
|
+
};
|
|
3732
|
+
}
|
|
3733
|
+
return {
|
|
3734
|
+
status: "not_found",
|
|
3735
|
+
confirmations: null,
|
|
3736
|
+
blockNumber: null,
|
|
3737
|
+
latestHeight: status.latestHeight
|
|
3738
|
+
};
|
|
3739
|
+
}
|
|
3740
|
+
/**
|
|
3741
|
+
* Resolve a user-pasted MRC token id to its metadata (name/symbol/
|
|
3742
|
+
* decimals), for an "add custom token" flow. Returns `null` for an
|
|
3743
|
+
* unknown/untracked id. Performs light client-side format validation
|
|
3744
|
+
* (32-byte hex) for fast UX feedback; the chain re-validates regardless.
|
|
3745
|
+
*/
|
|
3746
|
+
async lythResolveTokenMetadata(rawTokenId) {
|
|
3747
|
+
const body = rawTokenId.startsWith("0x") || rawTokenId.startsWith("0X") ? rawTokenId.slice(2) : rawTokenId;
|
|
3748
|
+
if (!/^[0-9a-fA-F]{64}$/.test(body)) {
|
|
3749
|
+
throw SdkError.malformed("token id must be 32 bytes (64 hex chars)");
|
|
3750
|
+
}
|
|
3751
|
+
return (await this.lythMrcMetadata(rawTokenId)).metadata;
|
|
3752
|
+
}
|
|
3753
|
+
/**
|
|
3754
|
+
* `lyth_getTokenBalances` joined with per-token MRC metadata. Balances
|
|
3755
|
+
* are PUBLIC-only by construction (private-denomination balances are
|
|
3756
|
+
* excluded by the chain). Raw `balance` strings are preserved (apply
|
|
3757
|
+
* `metadata.decimals` client-side for display).
|
|
3758
|
+
*/
|
|
3759
|
+
async lythGetTokenBalancesWithMetadata(address) {
|
|
3760
|
+
const rows = await this.lythGetTokenBalances(address);
|
|
3761
|
+
const keyFor = (row) => {
|
|
3762
|
+
const assetId = row.mrc?.assetId ?? row.tokenId;
|
|
3763
|
+
const tokenId = row.mrc?.tokenId ?? null;
|
|
3764
|
+
return { assetId, tokenId, key: `${assetId}:${tokenId ?? ""}` };
|
|
3765
|
+
};
|
|
3766
|
+
const distinct = /* @__PURE__ */ new Map();
|
|
3767
|
+
for (const row of rows) {
|
|
3768
|
+
const k = keyFor(row);
|
|
3769
|
+
if (!distinct.has(k.key)) distinct.set(k.key, { assetId: k.assetId, tokenId: k.tokenId });
|
|
3770
|
+
}
|
|
3771
|
+
const metaByKey = /* @__PURE__ */ new Map();
|
|
3772
|
+
await Promise.all(
|
|
3773
|
+
[...distinct.entries()].map(async ([key, { assetId, tokenId }]) => {
|
|
3774
|
+
const resp = await this.lythMrcMetadata(assetId, tokenId);
|
|
3775
|
+
metaByKey.set(key, resp.metadata);
|
|
3776
|
+
})
|
|
3777
|
+
);
|
|
3778
|
+
return rows.map((row) => ({ ...row, metadata: metaByKey.get(keyFor(row).key) ?? null }));
|
|
3779
|
+
}
|
|
3780
|
+
/**
|
|
3781
|
+
* Resolve a CLOB market's base/quote asset metadata (symbol/name/
|
|
3782
|
+
* decimals) by joining `lyth_clobMarket` to `lyth_mrcMetadata`. Either
|
|
3783
|
+
* side may be `null` when the indexer has no MRC row (e.g. native LYTH).
|
|
3784
|
+
*/
|
|
3785
|
+
async resolveClobMarketAssets(marketId) {
|
|
3786
|
+
const response = await this.lythClobMarket(marketId);
|
|
3787
|
+
const market = response.market;
|
|
3788
|
+
if (!market) return { base: null, quote: null };
|
|
3789
|
+
const [base, quote] = await Promise.all([
|
|
3790
|
+
this.lythMrcMetadata(market.baseToken).then((m) => m.metadata),
|
|
3791
|
+
this.lythMrcMetadata(market.quoteToken).then((m) => m.metadata)
|
|
3792
|
+
]);
|
|
3793
|
+
return { base, quote };
|
|
3794
|
+
}
|
|
3795
|
+
/**
|
|
3796
|
+
* `lyth_getAddressActivity` enriched with each row's block timestamp,
|
|
3797
|
+
* canonical tx hash (resolved from `(blockHeight, txIndex)`), and
|
|
3798
|
+
* resolved cluster name. Issues one block read per distinct height and
|
|
3799
|
+
* one name read per distinct cluster.
|
|
3800
|
+
*/
|
|
3801
|
+
async enrichAddressActivity(address, limit = 50, cursor) {
|
|
3802
|
+
const entries = await this.lythGetAddressActivity(address, limit, cursor);
|
|
3803
|
+
const heights = [...new Set(entries.map((entry) => BigInt(entry.blockHeight)))];
|
|
3804
|
+
const blockByHeight = /* @__PURE__ */ new Map();
|
|
3805
|
+
await Promise.all(
|
|
3806
|
+
heights.map(async (height) => {
|
|
3807
|
+
blockByHeight.set(height, await this.blockTimeAndTxHashes(height));
|
|
3808
|
+
})
|
|
3809
|
+
);
|
|
3810
|
+
const clusters = [
|
|
3811
|
+
...new Set(entries.map((entry) => entry.cluster).filter((c) => c != null))
|
|
3812
|
+
];
|
|
3813
|
+
const nameByCluster = /* @__PURE__ */ new Map();
|
|
3814
|
+
await Promise.all(
|
|
3815
|
+
clusters.map(async (clusterId) => {
|
|
3816
|
+
nameByCluster.set(clusterId, (await this.lythGetClusterName(clusterId)).name);
|
|
3817
|
+
})
|
|
3818
|
+
);
|
|
3819
|
+
return entries.map((entry) => {
|
|
3820
|
+
const block = blockByHeight.get(BigInt(entry.blockHeight));
|
|
3821
|
+
const txHash = block && entry.txIndex >= 0 && entry.txIndex < block.txHashes.length ? block.txHashes[entry.txIndex] : null;
|
|
3822
|
+
return {
|
|
3823
|
+
...entry,
|
|
3824
|
+
blockTimestampSeconds: block?.timestampSeconds ?? null,
|
|
3825
|
+
txHash,
|
|
3826
|
+
clusterName: entry.cluster != null ? nameByCluster.get(entry.cluster) ?? null : null
|
|
3827
|
+
};
|
|
3828
|
+
});
|
|
3829
|
+
}
|
|
3830
|
+
/**
|
|
3831
|
+
* Read a block's header timestamp (UNIX seconds) and ordered tx-hash
|
|
3832
|
+
* array via the raw `eth_getBlockByNumber` (hash-only mode). The typed
|
|
3833
|
+
* `ethGetBlockByNumber` wrapper drops the `transactions` array, so this
|
|
3834
|
+
* uses the raw call.
|
|
3835
|
+
*/
|
|
3836
|
+
async blockTimeAndTxHashes(height) {
|
|
3837
|
+
const hexHeight = `0x${height.toString(16)}`;
|
|
3838
|
+
const raw = await this.call("eth_getBlockByNumber", [
|
|
3839
|
+
hexHeight,
|
|
3840
|
+
false
|
|
3841
|
+
]);
|
|
3842
|
+
if (!raw || typeof raw !== "object") return { timestampSeconds: null, txHashes: [] };
|
|
3843
|
+
const ts = raw["timestamp"];
|
|
3844
|
+
const timestampSeconds = ts === null || ts === void 0 ? null : parseRpcBigint(ts, "block timestamp");
|
|
3845
|
+
const txs = raw["transactions"];
|
|
3846
|
+
const txHashes = Array.isArray(txs) ? txs.filter((t) => typeof t === "string") : [];
|
|
3847
|
+
return { timestampSeconds, txHashes };
|
|
3848
|
+
}
|
|
3165
3849
|
};
|
|
3850
|
+
function clusterApyPercent(apr) {
|
|
3851
|
+
return Number(apr.aprBps) / 100;
|
|
3852
|
+
}
|
|
3853
|
+
function computeQuoteLiquidity(book) {
|
|
3854
|
+
const sumQuote = (levels) => levels.reduce((acc, level) => acc + BigInt(level.price) * BigInt(level.size), 0n);
|
|
3855
|
+
const bidQuote = sumQuote(book.bids);
|
|
3856
|
+
const askQuote = sumQuote(book.asks);
|
|
3857
|
+
return {
|
|
3858
|
+
bidQuote: bidQuote.toString(10),
|
|
3859
|
+
askQuote: askQuote.toString(10),
|
|
3860
|
+
totalQuote: (bidQuote + askQuote).toString(10)
|
|
3861
|
+
};
|
|
3862
|
+
}
|
|
3863
|
+
function rankMarketsByVolume(markets) {
|
|
3864
|
+
return [...markets].sort((a, b) => {
|
|
3865
|
+
const av = BigInt(a.totalVolumeBase);
|
|
3866
|
+
const bv = BigInt(b.totalVolumeBase);
|
|
3867
|
+
return av < bv ? 1 : av > bv ? -1 : 0;
|
|
3868
|
+
}).map((market, index) => ({ ...market, volumeRank: index + 1 }));
|
|
3869
|
+
}
|
|
3166
3870
|
function parseQuantityBig(hex) {
|
|
3167
3871
|
if (!hex) return 0n;
|
|
3168
3872
|
const rest = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
@@ -3817,6 +4521,29 @@ function normalizeRoundInfo(value) {
|
|
|
3817
4521
|
height: parseRpcBigint(row["height"], "round height")
|
|
3818
4522
|
};
|
|
3819
4523
|
}
|
|
4524
|
+
function normalizeClusterApr(value) {
|
|
4525
|
+
if (!value || typeof value !== "object") {
|
|
4526
|
+
throw SdkError.malformed("cluster apr must be an object");
|
|
4527
|
+
}
|
|
4528
|
+
const row = value;
|
|
4529
|
+
const blocks = row["blocks"] ?? {};
|
|
4530
|
+
return {
|
|
4531
|
+
clusterId: parseRpcNumber(row["clusterId"], "clusterId"),
|
|
4532
|
+
blocks: {
|
|
4533
|
+
from: parseRpcBigint(blocks["from"], "blocks.from"),
|
|
4534
|
+
to: parseRpcBigint(blocks["to"], "blocks.to"),
|
|
4535
|
+
window: parseRpcBigint(blocks["window"], "blocks.window")
|
|
4536
|
+
},
|
|
4537
|
+
rewardIndexFromHex: parseStringField(row["rewardIndexFromHex"], "rewardIndexFromHex"),
|
|
4538
|
+
rewardIndexToHex: parseStringField(row["rewardIndexToHex"], "rewardIndexToHex"),
|
|
4539
|
+
deltaIndexHex: parseStringField(row["deltaIndexHex"], "deltaIndexHex"),
|
|
4540
|
+
rewardIndexScale: parseStringField(row["rewardIndexScale"], "rewardIndexScale"),
|
|
4541
|
+
totalBps: parseRpcNumber(row["totalBps"], "totalBps"),
|
|
4542
|
+
blocksPerYear: parseRpcBigint(row["blocksPerYear"], "blocksPerYear"),
|
|
4543
|
+
stakePerBpsLythoshi: parseRpcBigint(row["stakePerBpsLythoshi"], "stakePerBpsLythoshi"),
|
|
4544
|
+
aprBps: parseRpcBigint(row["aprBps"], "aprBps")
|
|
4545
|
+
};
|
|
4546
|
+
}
|
|
3820
4547
|
function normalizeExecutionUnitPriceResponse(value) {
|
|
3821
4548
|
if (!value || typeof value !== "object") {
|
|
3822
4549
|
throw SdkError.malformed("execution unit price response must be an object");
|
|
@@ -3962,24 +4689,101 @@ function expectObject2(value, label) {
|
|
|
3962
4689
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
3963
4690
|
throw SdkError.malformed(`${label} must be an object`);
|
|
3964
4691
|
}
|
|
3965
|
-
return value;
|
|
4692
|
+
return value;
|
|
4693
|
+
}
|
|
4694
|
+
function parseSafeInteger(value, label) {
|
|
4695
|
+
if (!isNonNegativeSafeInteger(value)) {
|
|
4696
|
+
throw SdkError.malformed(`nativeMarketOrderBook delta replay response ${label} is malformed`);
|
|
4697
|
+
}
|
|
4698
|
+
return value;
|
|
4699
|
+
}
|
|
4700
|
+
function parseNullableSafeInteger(value, label) {
|
|
4701
|
+
if (value === null || value === void 0) return null;
|
|
4702
|
+
return parseSafeInteger(value, label);
|
|
4703
|
+
}
|
|
4704
|
+
function parseNullableString(value, label) {
|
|
4705
|
+
if (value === null || value === void 0) return null;
|
|
4706
|
+
if (typeof value !== "string") {
|
|
4707
|
+
throw SdkError.malformed(`nativeMarketOrderBook delta replay response ${label} is malformed`);
|
|
4708
|
+
}
|
|
4709
|
+
return value;
|
|
4710
|
+
}
|
|
4711
|
+
|
|
4712
|
+
// src/tx-fee.ts
|
|
4713
|
+
var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
|
|
4714
|
+
var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
|
|
4715
|
+
var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
|
|
4716
|
+
var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
|
|
4717
|
+
function asBigint(value, label) {
|
|
4718
|
+
try {
|
|
4719
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
4720
|
+
} catch {
|
|
4721
|
+
throw new Error(`${label} is not an integer: ${String(value)}`);
|
|
4722
|
+
}
|
|
3966
4723
|
}
|
|
3967
|
-
function
|
|
3968
|
-
|
|
3969
|
-
|
|
4724
|
+
function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
|
|
4725
|
+
const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
|
|
4726
|
+
const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
|
|
4727
|
+
if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
|
|
4728
|
+
return tip > cap ? cap : tip;
|
|
4729
|
+
}
|
|
4730
|
+
async function resolveMaxExecutionUnitPrice(client, options = {}) {
|
|
4731
|
+
const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
|
|
4732
|
+
const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
4733
|
+
const quote = await client.lythExecutionUnitPrice();
|
|
4734
|
+
let unitPrice;
|
|
4735
|
+
try {
|
|
4736
|
+
unitPrice = BigInt(quote.executionUnitPriceLythoshi);
|
|
4737
|
+
} catch {
|
|
4738
|
+
throw SdkError.malformed(
|
|
4739
|
+
`lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
|
|
4740
|
+
);
|
|
3970
4741
|
}
|
|
3971
|
-
|
|
4742
|
+
const base = unitPrice > floor ? unitPrice : floor;
|
|
4743
|
+
return base * multiplier;
|
|
3972
4744
|
}
|
|
3973
|
-
function
|
|
3974
|
-
|
|
3975
|
-
|
|
4745
|
+
async function resolveExecutionFee(client, options = {}) {
|
|
4746
|
+
const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
|
|
4747
|
+
minPriceLythoshi: options.minPriceLythoshi,
|
|
4748
|
+
safetyMultiplier: options.safetyMultiplier
|
|
4749
|
+
});
|
|
4750
|
+
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
4751
|
+
return {
|
|
4752
|
+
maxFeePerGas,
|
|
4753
|
+
maxPriorityFeePerGas: tip,
|
|
4754
|
+
gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
4755
|
+
};
|
|
3976
4756
|
}
|
|
3977
|
-
function
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
4757
|
+
async function resolveRegistryExecutionFee(client, options = {}) {
|
|
4758
|
+
return resolveExecutionFee(client, {
|
|
4759
|
+
...options,
|
|
4760
|
+
executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
4761
|
+
});
|
|
4762
|
+
}
|
|
4763
|
+
function feeFieldToBigint(value, field2) {
|
|
4764
|
+
if (typeof value !== "string" || !/^\d+$/.test(value.trim())) {
|
|
4765
|
+
throw SdkError.malformed(`${field2} is not an integer: ${String(value)}`);
|
|
3981
4766
|
}
|
|
3982
|
-
|
|
4767
|
+
try {
|
|
4768
|
+
return BigInt(value.trim());
|
|
4769
|
+
} catch {
|
|
4770
|
+
throw SdkError.malformed(`${field2} is not an integer: ${String(value)}`);
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
function transactionFeeExposure(fee) {
|
|
4774
|
+
const basePrice = feeFieldToBigint(
|
|
4775
|
+
fee.base_price_per_cycle_lythoshi,
|
|
4776
|
+
"fee.base_price_per_cycle_lythoshi"
|
|
4777
|
+
);
|
|
4778
|
+
const priorityTip = feeFieldToBigint(
|
|
4779
|
+
fee.priority_tip_lythoshi,
|
|
4780
|
+
"fee.priority_tip_lythoshi"
|
|
4781
|
+
);
|
|
4782
|
+
feeFieldToBigint(fee.total_lythoshi, "fee.total_lythoshi");
|
|
4783
|
+
return {
|
|
4784
|
+
feeLythoshi: fee.total_lythoshi,
|
|
4785
|
+
effectiveGasPricePerUnit: (basePrice + priorityTip).toString()
|
|
4786
|
+
};
|
|
3983
4787
|
}
|
|
3984
4788
|
|
|
3985
4789
|
// src/api.ts
|
|
@@ -4057,7 +4861,13 @@ var ApiClient = class {
|
|
|
4057
4861
|
};
|
|
4058
4862
|
}
|
|
4059
4863
|
async transaction(hash) {
|
|
4060
|
-
|
|
4864
|
+
const response = await this.get(
|
|
4865
|
+
`/transactions/${encodePathSegment(hash)}`
|
|
4866
|
+
);
|
|
4867
|
+
return {
|
|
4868
|
+
...response,
|
|
4869
|
+
data: enrichTransactionDataWithFee(response.data)
|
|
4870
|
+
};
|
|
4061
4871
|
}
|
|
4062
4872
|
async transactionReceipt(hash) {
|
|
4063
4873
|
return this.get(`/transactions/${encodePathSegment(hash)}/receipt`);
|
|
@@ -4286,6 +5096,22 @@ var ApiClient = class {
|
|
|
4286
5096
|
return parsed;
|
|
4287
5097
|
}
|
|
4288
5098
|
};
|
|
5099
|
+
function enrichTransactionDataWithFee(data) {
|
|
5100
|
+
const exposure = transactionFeeExposure(data.transaction.fee);
|
|
5101
|
+
return {
|
|
5102
|
+
...data,
|
|
5103
|
+
transaction: {
|
|
5104
|
+
...data.transaction,
|
|
5105
|
+
feeLythoshi: exposure.feeLythoshi,
|
|
5106
|
+
effectiveGasPricePerUnit: exposure.effectiveGasPricePerUnit
|
|
5107
|
+
},
|
|
5108
|
+
receipt: data.receipt == null ? data.receipt : {
|
|
5109
|
+
...data.receipt,
|
|
5110
|
+
feeLythoshi: exposure.feeLythoshi,
|
|
5111
|
+
effectiveGasPricePerUnit: exposure.effectiveGasPricePerUnit
|
|
5112
|
+
}
|
|
5113
|
+
};
|
|
5114
|
+
}
|
|
4289
5115
|
function parseApiError(value) {
|
|
4290
5116
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
4291
5117
|
const error = value["error"];
|
|
@@ -4363,8 +5189,6 @@ function encodePathBlock(block) {
|
|
|
4363
5189
|
function encodePathSegment(value) {
|
|
4364
5190
|
return encodeURIComponent(typeof value === "bigint" ? value.toString() : String(value));
|
|
4365
5191
|
}
|
|
4366
|
-
|
|
4367
|
-
// src/bridge.ts
|
|
4368
5192
|
var BRIDGE_SELECTORS = {
|
|
4369
5193
|
lockBridgeConfig: "0x8956feb3",
|
|
4370
5194
|
setBridgeResumeCooldown: "0x1a3a0672",
|
|
@@ -4398,42 +5222,105 @@ function bridgeAddressHex() {
|
|
|
4398
5222
|
return PRECOMPILE_ADDRESSES.BRIDGE.toLowerCase();
|
|
4399
5223
|
}
|
|
4400
5224
|
function encodeLockBridgeConfigCalldata(bridgeId) {
|
|
4401
|
-
return
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
expectLength3(
|
|
5225
|
+
return bytesToHex5(
|
|
5226
|
+
concatBytes5(
|
|
5227
|
+
hexToBytes5(BRIDGE_SELECTORS.lockBridgeConfig),
|
|
5228
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId")
|
|
4405
5229
|
)
|
|
4406
5230
|
);
|
|
4407
5231
|
}
|
|
4408
5232
|
function encodeSetBridgeResumeCooldownCalldata(bridgeId, cooldownBlocks) {
|
|
4409
|
-
return
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
expectLength3(
|
|
4413
|
-
|
|
5233
|
+
return bytesToHex5(
|
|
5234
|
+
concatBytes5(
|
|
5235
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeResumeCooldown),
|
|
5236
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5237
|
+
uint64Word2(cooldownBlocks, "cooldownBlocks")
|
|
4414
5238
|
)
|
|
4415
5239
|
);
|
|
4416
5240
|
}
|
|
4417
5241
|
function encodeSetBridgeRouteFinalityCalldata(bridgeId, finalityBlocks) {
|
|
4418
|
-
return
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
expectLength3(
|
|
4422
|
-
|
|
5242
|
+
return bytesToHex5(
|
|
5243
|
+
concatBytes5(
|
|
5244
|
+
hexToBytes5(BRIDGE_SELECTORS.setBridgeRouteFinality),
|
|
5245
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5246
|
+
uint64Word2(finalityBlocks, "finalityBlocks")
|
|
5247
|
+
)
|
|
5248
|
+
);
|
|
5249
|
+
}
|
|
5250
|
+
function bridgeSelector(signature) {
|
|
5251
|
+
return sha3_js.keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
|
|
5252
|
+
}
|
|
5253
|
+
function addressWord2(value, name) {
|
|
5254
|
+
const addr = expectLength3(toBytes3(value), 20, name);
|
|
5255
|
+
const out = new Uint8Array(32);
|
|
5256
|
+
out.set(addr, 12);
|
|
5257
|
+
return out;
|
|
5258
|
+
}
|
|
5259
|
+
function padTo322(bytes) {
|
|
5260
|
+
const padded = Math.ceil(bytes.length / 32) * 32;
|
|
5261
|
+
if (padded === bytes.length) return bytes;
|
|
5262
|
+
const out = new Uint8Array(padded);
|
|
5263
|
+
out.set(bytes);
|
|
5264
|
+
return out;
|
|
5265
|
+
}
|
|
5266
|
+
function encodeBridgeClaimCalldata(bridgeId, depositId, recipient) {
|
|
5267
|
+
return bytesToHex5(
|
|
5268
|
+
concatBytes5(
|
|
5269
|
+
bridgeSelector("claim(bytes32,bytes32,address)"),
|
|
5270
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5271
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5272
|
+
addressWord2(recipient, "recipient")
|
|
5273
|
+
)
|
|
5274
|
+
);
|
|
5275
|
+
}
|
|
5276
|
+
function encodeBridgeChallengeCalldata(bridgeId, depositId, fraudProof) {
|
|
5277
|
+
const proof = toBytes3(fraudProof);
|
|
5278
|
+
return bytesToHex5(
|
|
5279
|
+
concatBytes5(
|
|
5280
|
+
bridgeSelector("challenge(bytes32,bytes32,bytes)"),
|
|
5281
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5282
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5283
|
+
uint64Word2(3n * 32n, "fraudProofOffset"),
|
|
5284
|
+
uint64Word2(BigInt(proof.length), "fraudProofLength"),
|
|
5285
|
+
padTo322(proof)
|
|
5286
|
+
)
|
|
5287
|
+
);
|
|
5288
|
+
}
|
|
5289
|
+
function encodeSubmitBridgeProofCalldata(bridgeId, depositId, lockReceipt, zkProof, publicInputs) {
|
|
5290
|
+
const receipt = toBytes3(lockReceipt);
|
|
5291
|
+
const proof = toBytes3(zkProof);
|
|
5292
|
+
const inputs = toBytes3(publicInputs);
|
|
5293
|
+
const off0 = 5n * 32n;
|
|
5294
|
+
const off1 = off0 + 32n + BigInt(Math.ceil(receipt.length / 32) * 32);
|
|
5295
|
+
const off2 = off1 + 32n + BigInt(Math.ceil(proof.length / 32) * 32);
|
|
5296
|
+
return bytesToHex5(
|
|
5297
|
+
concatBytes5(
|
|
5298
|
+
bridgeSelector("submitProof(bytes32,bytes32,bytes,bytes,bytes)"),
|
|
5299
|
+
expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
|
|
5300
|
+
expectLength3(toBytes3(depositId), 32, "depositId"),
|
|
5301
|
+
uint64Word2(off0, "lockReceiptOffset"),
|
|
5302
|
+
uint64Word2(off1, "zkProofOffset"),
|
|
5303
|
+
uint64Word2(off2, "publicInputsOffset"),
|
|
5304
|
+
uint64Word2(BigInt(receipt.length), "lockReceiptLength"),
|
|
5305
|
+
padTo322(receipt),
|
|
5306
|
+
uint64Word2(BigInt(proof.length), "zkProofLength"),
|
|
5307
|
+
padTo322(proof),
|
|
5308
|
+
uint64Word2(BigInt(inputs.length), "publicInputsLength"),
|
|
5309
|
+
padTo322(inputs)
|
|
4423
5310
|
)
|
|
4424
5311
|
);
|
|
4425
5312
|
}
|
|
4426
5313
|
function isBridgeAdminLockedRevert(data) {
|
|
4427
|
-
return
|
|
5314
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeAdminLocked;
|
|
4428
5315
|
}
|
|
4429
5316
|
function isBridgeResumeCooldownActiveRevert(data) {
|
|
4430
|
-
return
|
|
5317
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeResumeCooldownActive;
|
|
4431
5318
|
}
|
|
4432
5319
|
function isBridgeCooldownZeroRevert(data) {
|
|
4433
|
-
return
|
|
5320
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeCooldownZero;
|
|
4434
5321
|
}
|
|
4435
5322
|
function isBridgeFinalityZeroRevert(data) {
|
|
4436
|
-
return
|
|
5323
|
+
return bytesToHex5(toBytes3(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
|
|
4437
5324
|
}
|
|
4438
5325
|
function bridgeDrainRemaining(capPerWindow, drained) {
|
|
4439
5326
|
const cap = BigInt(capPerWindow);
|
|
@@ -5036,7 +5923,7 @@ function expectLength3(value, len, name) {
|
|
|
5036
5923
|
}
|
|
5037
5924
|
return value;
|
|
5038
5925
|
}
|
|
5039
|
-
function
|
|
5926
|
+
function uint64Word2(value, name) {
|
|
5040
5927
|
const n = toBigint(value, name);
|
|
5041
5928
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
5042
5929
|
throw new BridgePrecompileError(`${name} must fit uint64`);
|
|
@@ -5062,13 +5949,13 @@ function toBigint(value, name) {
|
|
|
5062
5949
|
}
|
|
5063
5950
|
return BigInt(value);
|
|
5064
5951
|
}
|
|
5065
|
-
function
|
|
5952
|
+
function toBytes3(value) {
|
|
5066
5953
|
if (typeof value === "string") {
|
|
5067
|
-
return
|
|
5954
|
+
return hexToBytes5(value);
|
|
5068
5955
|
}
|
|
5069
5956
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
5070
5957
|
}
|
|
5071
|
-
function
|
|
5958
|
+
function hexToBytes5(hex) {
|
|
5072
5959
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
5073
5960
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
5074
5961
|
throw new BridgePrecompileError("invalid hex bytes");
|
|
@@ -5079,10 +5966,10 @@ function hexToBytes4(hex) {
|
|
|
5079
5966
|
}
|
|
5080
5967
|
return out;
|
|
5081
5968
|
}
|
|
5082
|
-
function
|
|
5969
|
+
function bytesToHex5(bytes) {
|
|
5083
5970
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
5084
5971
|
}
|
|
5085
|
-
function
|
|
5972
|
+
function concatBytes5(...parts) {
|
|
5086
5973
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
5087
5974
|
let offset = 0;
|
|
5088
5975
|
for (const part of parts) {
|
|
@@ -5137,10 +6024,10 @@ function decodeNoEvmReceiptTranscript(proof) {
|
|
|
5137
6024
|
);
|
|
5138
6025
|
}
|
|
5139
6026
|
function computeNoEvmReceiptsRoot(receipts) {
|
|
5140
|
-
return
|
|
6027
|
+
return bytesToHex6(computeNoEvmReceiptsRootBytes(receipts));
|
|
5141
6028
|
}
|
|
5142
6029
|
function computeNoEvmTargetReceiptHash(receiptBytes) {
|
|
5143
|
-
return
|
|
6030
|
+
return bytesToHex6(sha3_js.keccak_256(receiptBytes));
|
|
5144
6031
|
}
|
|
5145
6032
|
function verifyNoEvmReceiptProof(proof) {
|
|
5146
6033
|
if (proof == null) return null;
|
|
@@ -5727,7 +6614,7 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5727
6614
|
if (!bytesEqual(expectedLeafHashBytes, actualLeafHashBytes)) {
|
|
5728
6615
|
throw new NoEvmReceiptProofError(
|
|
5729
6616
|
"compact_leaf_hash_mismatch",
|
|
5730
|
-
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${
|
|
6617
|
+
`compactInclusionProof.leafHash mismatch: expected ${compactProof.leafHash}, computed ${bytesToHex6(
|
|
5731
6618
|
actualLeafHashBytes
|
|
5732
6619
|
)}`
|
|
5733
6620
|
);
|
|
@@ -5760,14 +6647,14 @@ function verifyCompactReceiptProof(proof) {
|
|
|
5760
6647
|
if (!bytesEqual(actualRootBytes, compactRootBytes)) {
|
|
5761
6648
|
throw new NoEvmReceiptProofError(
|
|
5762
6649
|
"compact_path_mismatch",
|
|
5763
|
-
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${
|
|
6650
|
+
`compact inclusion path mismatch: expected ${compactProof.root}, computed ${bytesToHex6(
|
|
5764
6651
|
actualRootBytes
|
|
5765
6652
|
)}`
|
|
5766
6653
|
);
|
|
5767
6654
|
}
|
|
5768
6655
|
return {
|
|
5769
6656
|
receipts: [],
|
|
5770
|
-
receiptsRoot:
|
|
6657
|
+
receiptsRoot: bytesToHex6(actualRootBytes),
|
|
5771
6658
|
targetReceiptHash: actualTargetHash,
|
|
5772
6659
|
receiptCount: proof.receiptCount,
|
|
5773
6660
|
txIndex: proof.txIndex,
|
|
@@ -5977,7 +6864,7 @@ function parseArchiveProofSignature(signature, index, fieldPrefix = "archiveProo
|
|
|
5977
6864
|
`${field2}.payload must be non-empty`
|
|
5978
6865
|
);
|
|
5979
6866
|
}
|
|
5980
|
-
return { signerId:
|
|
6867
|
+
return { signerId: bytesToHex6(signerId), payload };
|
|
5981
6868
|
}
|
|
5982
6869
|
function normalizeSignerId(value) {
|
|
5983
6870
|
const bytes = decodeHexBytes(value, "signerId");
|
|
@@ -5987,7 +6874,7 @@ function normalizeSignerId(value) {
|
|
|
5987
6874
|
`signerId must be ${ARCHIVE_SIGNATURE_SIGNER_ID_BYTE_LENGTH} bytes, got ${bytes.length}`
|
|
5988
6875
|
);
|
|
5989
6876
|
}
|
|
5990
|
-
return
|
|
6877
|
+
return bytesToHex6(bytes);
|
|
5991
6878
|
}
|
|
5992
6879
|
function expectArchivePublicKey(value, field2) {
|
|
5993
6880
|
if (value.length !== ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
@@ -6468,7 +7355,7 @@ function bytesEqual(a, b) {
|
|
|
6468
7355
|
}
|
|
6469
7356
|
return diff === 0;
|
|
6470
7357
|
}
|
|
6471
|
-
function
|
|
7358
|
+
function bytesToHex6(bytes) {
|
|
6472
7359
|
let out = "0x";
|
|
6473
7360
|
for (let index = 0; index < bytes.length; index++) {
|
|
6474
7361
|
out += bytes[index].toString(16).padStart(2, "0");
|
|
@@ -6668,58 +7555,6 @@ function assertWholeNumber(field2, value) {
|
|
|
6668
7555
|
throw new Error(`${field2} must be a whole number`);
|
|
6669
7556
|
}
|
|
6670
7557
|
}
|
|
6671
|
-
|
|
6672
|
-
// src/tx-fee.ts
|
|
6673
|
-
var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
|
|
6674
|
-
var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
|
|
6675
|
-
var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
|
|
6676
|
-
var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
|
|
6677
|
-
function asBigint(value, label) {
|
|
6678
|
-
try {
|
|
6679
|
-
return typeof value === "bigint" ? value : BigInt(value);
|
|
6680
|
-
} catch {
|
|
6681
|
-
throw new Error(`${label} is not an integer: ${String(value)}`);
|
|
6682
|
-
}
|
|
6683
|
-
}
|
|
6684
|
-
function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
|
|
6685
|
-
const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
|
|
6686
|
-
const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
|
|
6687
|
-
if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
|
|
6688
|
-
return tip > cap ? cap : tip;
|
|
6689
|
-
}
|
|
6690
|
-
async function resolveMaxExecutionUnitPrice(client, options = {}) {
|
|
6691
|
-
const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
|
|
6692
|
-
const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
6693
|
-
const quote = await client.lythExecutionUnitPrice();
|
|
6694
|
-
let unitPrice;
|
|
6695
|
-
try {
|
|
6696
|
-
unitPrice = BigInt(quote.executionUnitPriceLythoshi);
|
|
6697
|
-
} catch {
|
|
6698
|
-
throw SdkError.malformed(
|
|
6699
|
-
`lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
|
|
6700
|
-
);
|
|
6701
|
-
}
|
|
6702
|
-
const base = unitPrice > floor ? unitPrice : floor;
|
|
6703
|
-
return base * multiplier;
|
|
6704
|
-
}
|
|
6705
|
-
async function resolveExecutionFee(client, options = {}) {
|
|
6706
|
-
const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
|
|
6707
|
-
minPriceLythoshi: options.minPriceLythoshi,
|
|
6708
|
-
safetyMultiplier: options.safetyMultiplier
|
|
6709
|
-
});
|
|
6710
|
-
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
6711
|
-
return {
|
|
6712
|
-
maxFeePerGas,
|
|
6713
|
-
maxPriorityFeePerGas: tip,
|
|
6714
|
-
gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6715
|
-
};
|
|
6716
|
-
}
|
|
6717
|
-
async function resolveRegistryExecutionFee(client, options = {}) {
|
|
6718
|
-
return resolveExecutionFee(client, {
|
|
6719
|
-
...options,
|
|
6720
|
-
executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6721
|
-
});
|
|
6722
|
-
}
|
|
6723
7558
|
var ORACLE_EVENT_SIGS = {
|
|
6724
7559
|
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
6725
7560
|
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
@@ -6739,12 +7574,48 @@ var OracleEventError = class extends Error {
|
|
|
6739
7574
|
function oracleAddressHex() {
|
|
6740
7575
|
return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
|
|
6741
7576
|
}
|
|
7577
|
+
var FEED_ID_DOMAIN_TAG = "protocore-oracle/feed-id/v1";
|
|
7578
|
+
function deriveFeedId(name, decimals) {
|
|
7579
|
+
if (!Number.isInteger(decimals) || decimals < 0 || decimals > 255) {
|
|
7580
|
+
throw new OracleEventError("feed decimals must be an integer in 0..=255");
|
|
7581
|
+
}
|
|
7582
|
+
const nameBytes = new TextEncoder().encode(name);
|
|
7583
|
+
const buf = concatBytes6(
|
|
7584
|
+
new TextEncoder().encode(FEED_ID_DOMAIN_TAG),
|
|
7585
|
+
nameBytes,
|
|
7586
|
+
Uint8Array.of(decimals & 255)
|
|
7587
|
+
);
|
|
7588
|
+
return bytesToHex7(sha3_js.keccak_256(buf));
|
|
7589
|
+
}
|
|
7590
|
+
function formatOraclePrice(price) {
|
|
7591
|
+
if (price.median === null) return null;
|
|
7592
|
+
const value = BigInt(price.median);
|
|
7593
|
+
const decimals = price.decimals;
|
|
7594
|
+
if (decimals <= 0) return value.toString(10);
|
|
7595
|
+
const base = 10n ** BigInt(decimals);
|
|
7596
|
+
const whole = value / base;
|
|
7597
|
+
const frac = (value % base).toString(10).padStart(decimals, "0").replace(/0+$/, "");
|
|
7598
|
+
return frac.length > 0 ? `${whole.toString(10)}.${frac}` : whole.toString(10);
|
|
7599
|
+
}
|
|
7600
|
+
function oraclePriceToNumber(price) {
|
|
7601
|
+
const formatted = formatOraclePrice(price);
|
|
7602
|
+
return formatted === null ? null : Number(formatted);
|
|
7603
|
+
}
|
|
7604
|
+
function concatBytes6(...parts) {
|
|
7605
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7606
|
+
let offset = 0;
|
|
7607
|
+
for (const part of parts) {
|
|
7608
|
+
out.set(part, offset);
|
|
7609
|
+
offset += part.length;
|
|
7610
|
+
}
|
|
7611
|
+
return out;
|
|
7612
|
+
}
|
|
6742
7613
|
function decodeOracleEvent(topics, data) {
|
|
6743
7614
|
if (topics.length === 0) {
|
|
6744
7615
|
throw new OracleEventError("event record has no topics");
|
|
6745
7616
|
}
|
|
6746
|
-
const topic0 =
|
|
6747
|
-
const body =
|
|
7617
|
+
const topic0 = bytesToHex7(expectLength4(toBytes4(topics[0]), 32, "topic0"));
|
|
7618
|
+
const body = toBytes4(data);
|
|
6748
7619
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
|
|
6749
7620
|
checkArity("OracleRoundFinalized", 3, topics.length);
|
|
6750
7621
|
checkData("OracleRoundFinalized", 3 * 32, body.length);
|
|
@@ -6777,7 +7648,7 @@ function decodeOracleEvent(topics, data) {
|
|
|
6777
7648
|
feedId: hex32(topics[1]),
|
|
6778
7649
|
roundId: u64FromTopic(topics[2]),
|
|
6779
7650
|
writer: addressFromTopic(topics[3]),
|
|
6780
|
-
evidenceHash:
|
|
7651
|
+
evidenceHash: bytesToHex7(body.subarray(0, 32))
|
|
6781
7652
|
};
|
|
6782
7653
|
}
|
|
6783
7654
|
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
|
|
@@ -6825,7 +7696,7 @@ function decodeFeedFields(feedTopic, body) {
|
|
|
6825
7696
|
};
|
|
6826
7697
|
}
|
|
6827
7698
|
function topicHex(sig) {
|
|
6828
|
-
return
|
|
7699
|
+
return bytesToHex7(sha3_js.keccak_256(new TextEncoder().encode(sig)));
|
|
6829
7700
|
}
|
|
6830
7701
|
function checkArity(event, expected, found) {
|
|
6831
7702
|
if (found !== expected) {
|
|
@@ -6838,13 +7709,13 @@ function checkData(event, expected, found) {
|
|
|
6838
7709
|
}
|
|
6839
7710
|
}
|
|
6840
7711
|
function hex32(topic) {
|
|
6841
|
-
return
|
|
7712
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "feedId topic"));
|
|
6842
7713
|
}
|
|
6843
7714
|
function addressFromTopic(topic) {
|
|
6844
|
-
return
|
|
7715
|
+
return bytesToHex7(expectLength4(toBytes4(topic), 32, "address topic").subarray(12, 32));
|
|
6845
7716
|
}
|
|
6846
7717
|
function u64FromTopic(topic) {
|
|
6847
|
-
return u64FromWord2(expectLength4(
|
|
7718
|
+
return u64FromWord2(expectLength4(toBytes4(topic), 32, "u64 topic"));
|
|
6848
7719
|
}
|
|
6849
7720
|
function u64FromWord2(word) {
|
|
6850
7721
|
let v = 0n;
|
|
@@ -6859,11 +7730,11 @@ function u256Decimal(word) {
|
|
|
6859
7730
|
for (const b of word) v = v << 8n | BigInt(b);
|
|
6860
7731
|
return v.toString(10);
|
|
6861
7732
|
}
|
|
6862
|
-
function
|
|
6863
|
-
if (typeof value === "string") return
|
|
7733
|
+
function toBytes4(value) {
|
|
7734
|
+
if (typeof value === "string") return hexToBytes6(value);
|
|
6864
7735
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6865
7736
|
}
|
|
6866
|
-
function
|
|
7737
|
+
function hexToBytes6(hex) {
|
|
6867
7738
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6868
7739
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6869
7740
|
throw new OracleEventError("invalid hex bytes");
|
|
@@ -6872,7 +7743,7 @@ function hexToBytes5(hex) {
|
|
|
6872
7743
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6873
7744
|
return out;
|
|
6874
7745
|
}
|
|
6875
|
-
function
|
|
7746
|
+
function bytesToHex7(bytes) {
|
|
6876
7747
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6877
7748
|
}
|
|
6878
7749
|
function expectLength4(value, len, name) {
|
|
@@ -6884,12 +7755,12 @@ function expectLength4(value, len, name) {
|
|
|
6884
7755
|
var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
|
|
6885
7756
|
var SERVES_GPU_PROVE = 512;
|
|
6886
7757
|
var PROVER_MARKET_SELECTORS = {
|
|
6887
|
-
createRequest: "0x" +
|
|
6888
|
-
submitBid: "0x" +
|
|
6889
|
-
closeRequest: "0x" +
|
|
6890
|
-
submitProof: "0x" +
|
|
6891
|
-
settle: "0x" +
|
|
6892
|
-
slash: "0x" +
|
|
7758
|
+
createRequest: "0x" + selectorHex3("createRequest(bytes)"),
|
|
7759
|
+
submitBid: "0x" + selectorHex3("submitBid(bytes)"),
|
|
7760
|
+
closeRequest: "0x" + selectorHex3("closeRequest(bytes)"),
|
|
7761
|
+
submitProof: "0x" + selectorHex3("submitProof(bytes)"),
|
|
7762
|
+
settle: "0x" + selectorHex3("settle(bytes)"),
|
|
7763
|
+
slash: "0x" + selectorHex3("slash(bytes)")
|
|
6893
7764
|
};
|
|
6894
7765
|
var PROVER_MARKET_EVENT_SIGS = {
|
|
6895
7766
|
proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
|
|
@@ -6927,12 +7798,12 @@ var ProverMarketError = class extends Error {
|
|
|
6927
7798
|
}
|
|
6928
7799
|
};
|
|
6929
7800
|
function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
6930
|
-
return
|
|
7801
|
+
return bytesToHex8(
|
|
6931
7802
|
sha3_js.keccak_256(
|
|
6932
|
-
|
|
7803
|
+
concatBytes7(
|
|
6933
7804
|
new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
|
|
6934
|
-
expectLength5(
|
|
6935
|
-
expectLength5(
|
|
7805
|
+
expectLength5(toBytes5(vkeyHash), 32, "vkeyHash"),
|
|
7806
|
+
expectLength5(toBytes5(inputsHash), 32, "inputsHash"),
|
|
6936
7807
|
u128Bytes(maxFee, "maxFee"),
|
|
6937
7808
|
u64Bytes(deadline, "deadline"),
|
|
6938
7809
|
u64Bytes(nonce, "nonce")
|
|
@@ -6941,44 +7812,44 @@ function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
|
6941
7812
|
);
|
|
6942
7813
|
}
|
|
6943
7814
|
function bidSighash(requestId, fee) {
|
|
6944
|
-
return
|
|
7815
|
+
return bytesToHex8(
|
|
6945
7816
|
sha3_js.keccak_256(
|
|
6946
|
-
|
|
7817
|
+
concatBytes7(
|
|
6947
7818
|
new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
|
|
6948
|
-
expectLength5(
|
|
7819
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
6949
7820
|
u128Bytes(fee, "fee")
|
|
6950
7821
|
)
|
|
6951
7822
|
)
|
|
6952
7823
|
);
|
|
6953
7824
|
}
|
|
6954
7825
|
function submitSighash(requestId, proofHash) {
|
|
6955
|
-
return
|
|
7826
|
+
return bytesToHex8(
|
|
6956
7827
|
sha3_js.keccak_256(
|
|
6957
|
-
|
|
7828
|
+
concatBytes7(
|
|
6958
7829
|
new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
|
|
6959
|
-
expectLength5(
|
|
6960
|
-
expectLength5(
|
|
7830
|
+
expectLength5(toBytes5(requestId), 32, "requestId"),
|
|
7831
|
+
expectLength5(toBytes5(proofHash), 32, "proofHash")
|
|
6961
7832
|
)
|
|
6962
7833
|
)
|
|
6963
7834
|
);
|
|
6964
7835
|
}
|
|
6965
7836
|
function encodeCreateRequestCanonical(args) {
|
|
6966
|
-
const buyer = expectLength5(
|
|
6967
|
-
const buyerPubkey =
|
|
6968
|
-
const sig =
|
|
7837
|
+
const buyer = expectLength5(toBytes5(args.buyer), 20, "buyer");
|
|
7838
|
+
const buyerPubkey = toBytes5(args.buyerPubkey);
|
|
7839
|
+
const sig = toBytes5(args.sig);
|
|
6969
7840
|
if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
|
|
6970
7841
|
throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
|
|
6971
7842
|
}
|
|
6972
7843
|
if (sig.length === 0 || sig.length > 65535) {
|
|
6973
7844
|
throw new ProverMarketError("sig length out of range (1..=65535)");
|
|
6974
7845
|
}
|
|
6975
|
-
return
|
|
6976
|
-
|
|
7846
|
+
return bytesToHex8(
|
|
7847
|
+
concatBytes7(
|
|
6977
7848
|
buyer,
|
|
6978
7849
|
u16Bytes(buyerPubkey.length),
|
|
6979
7850
|
buyerPubkey,
|
|
6980
|
-
expectLength5(
|
|
6981
|
-
expectLength5(
|
|
7851
|
+
expectLength5(toBytes5(args.vkeyHash), 32, "vkeyHash"),
|
|
7852
|
+
expectLength5(toBytes5(args.inputsHash), 32, "inputsHash"),
|
|
6982
7853
|
u128Bytes(args.maxFee, "maxFee"),
|
|
6983
7854
|
u64Bytes(args.deadline, "deadline"),
|
|
6984
7855
|
u64Bytes(args.nonce, "nonce"),
|
|
@@ -6988,7 +7859,7 @@ function encodeCreateRequestCanonical(args) {
|
|
|
6988
7859
|
);
|
|
6989
7860
|
}
|
|
6990
7861
|
function encodeCreateRequestCalldata(args) {
|
|
6991
|
-
const canonical =
|
|
7862
|
+
const canonical = toBytes5(encodeCreateRequestCanonical(args));
|
|
6992
7863
|
const offset = new Uint8Array(32);
|
|
6993
7864
|
offset[31] = 32;
|
|
6994
7865
|
const lenWord = new Uint8Array(32);
|
|
@@ -6998,18 +7869,18 @@ function encodeCreateRequestCalldata(args) {
|
|
|
6998
7869
|
lenWord[30] = len >>> 8 & 255;
|
|
6999
7870
|
lenWord[31] = len & 255;
|
|
7000
7871
|
const pad = (32 - len % 32) % 32;
|
|
7001
|
-
return
|
|
7002
|
-
|
|
7872
|
+
return bytesToHex8(
|
|
7873
|
+
concatBytes7(hexToBytes7(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
|
|
7003
7874
|
);
|
|
7004
7875
|
}
|
|
7005
|
-
function
|
|
7876
|
+
function selectorHex3(sig) {
|
|
7006
7877
|
return [...sha3_js.keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7007
7878
|
}
|
|
7008
|
-
function
|
|
7009
|
-
if (typeof value === "string") return
|
|
7879
|
+
function toBytes5(value) {
|
|
7880
|
+
if (typeof value === "string") return hexToBytes7(value);
|
|
7010
7881
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7011
7882
|
}
|
|
7012
|
-
function
|
|
7883
|
+
function hexToBytes7(hex) {
|
|
7013
7884
|
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7014
7885
|
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
7015
7886
|
throw new ProverMarketError("invalid hex bytes");
|
|
@@ -7018,10 +7889,10 @@ function hexToBytes6(hex) {
|
|
|
7018
7889
|
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
7019
7890
|
return out;
|
|
7020
7891
|
}
|
|
7021
|
-
function
|
|
7892
|
+
function bytesToHex8(bytes) {
|
|
7022
7893
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7023
7894
|
}
|
|
7024
|
-
function
|
|
7895
|
+
function concatBytes7(...parts) {
|
|
7025
7896
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7026
7897
|
let offset = 0;
|
|
7027
7898
|
for (const part of parts) {
|
|
@@ -7098,34 +7969,34 @@ function delegationAddressHex() {
|
|
|
7098
7969
|
return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
|
|
7099
7970
|
}
|
|
7100
7971
|
function encodeCompleteRedemptionCalldata(index) {
|
|
7101
|
-
return
|
|
7102
|
-
|
|
7103
|
-
|
|
7104
|
-
|
|
7972
|
+
return bytesToHex9(
|
|
7973
|
+
concatBytes8(
|
|
7974
|
+
hexToBytes8(DELEGATION_SELECTORS.completeRedemption),
|
|
7975
|
+
uint64Word3(index, "index")
|
|
7105
7976
|
)
|
|
7106
7977
|
);
|
|
7107
7978
|
}
|
|
7108
7979
|
function encodeDelegateCalldata(cluster, weightBps) {
|
|
7109
|
-
return
|
|
7110
|
-
|
|
7111
|
-
|
|
7980
|
+
return bytesToHex9(
|
|
7981
|
+
concatBytes8(
|
|
7982
|
+
hexToBytes8(DELEGATION_SELECTORS.delegate),
|
|
7112
7983
|
uint32Word2(cluster, "cluster"),
|
|
7113
7984
|
uint16Word(weightBps, "weightBps")
|
|
7114
7985
|
)
|
|
7115
7986
|
);
|
|
7116
7987
|
}
|
|
7117
7988
|
function encodeUndelegateCalldata(cluster) {
|
|
7118
|
-
return
|
|
7119
|
-
|
|
7120
|
-
|
|
7989
|
+
return bytesToHex9(
|
|
7990
|
+
concatBytes8(
|
|
7991
|
+
hexToBytes8(DELEGATION_SELECTORS.undelegate),
|
|
7121
7992
|
uint32Word2(cluster, "cluster")
|
|
7122
7993
|
)
|
|
7123
7994
|
);
|
|
7124
7995
|
}
|
|
7125
7996
|
function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
|
|
7126
|
-
return
|
|
7127
|
-
|
|
7128
|
-
|
|
7997
|
+
return bytesToHex9(
|
|
7998
|
+
concatBytes8(
|
|
7999
|
+
hexToBytes8(DELEGATION_SELECTORS.redelegate),
|
|
7129
8000
|
uint32Word2(fromCluster, "fromCluster"),
|
|
7130
8001
|
uint32Word2(toCluster, "toCluster"),
|
|
7131
8002
|
uint16Word(weightBps, "weightBps")
|
|
@@ -7138,14 +8009,14 @@ function encodeClaimCalldata() {
|
|
|
7138
8009
|
function encodeSetAutoCompoundCalldata(enabled) {
|
|
7139
8010
|
const flag = new Uint8Array(32);
|
|
7140
8011
|
flag[31] = enabled ? 1 : 0;
|
|
7141
|
-
return
|
|
7142
|
-
|
|
8012
|
+
return bytesToHex9(
|
|
8013
|
+
concatBytes8(hexToBytes8(DELEGATION_SELECTORS.setAutoCompound), flag)
|
|
7143
8014
|
);
|
|
7144
8015
|
}
|
|
7145
8016
|
function isRedemptionPrincipalUnavailableRevert(data) {
|
|
7146
|
-
return
|
|
8017
|
+
return bytesToHex9(toBytes6(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
|
|
7147
8018
|
}
|
|
7148
|
-
function
|
|
8019
|
+
function uint64Word3(value, name) {
|
|
7149
8020
|
const n = toBigint3(value, name);
|
|
7150
8021
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
7151
8022
|
throw new DelegationPrecompileError(`${name} must fit uint64`);
|
|
@@ -7197,13 +8068,13 @@ function toBigint3(value, name) {
|
|
|
7197
8068
|
}
|
|
7198
8069
|
return BigInt(value);
|
|
7199
8070
|
}
|
|
7200
|
-
function
|
|
8071
|
+
function toBytes6(value) {
|
|
7201
8072
|
if (typeof value === "string") {
|
|
7202
|
-
return
|
|
8073
|
+
return hexToBytes8(value);
|
|
7203
8074
|
}
|
|
7204
8075
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7205
8076
|
}
|
|
7206
|
-
function
|
|
8077
|
+
function hexToBytes8(hex) {
|
|
7207
8078
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7208
8079
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7209
8080
|
throw new DelegationPrecompileError("invalid hex bytes");
|
|
@@ -7214,10 +8085,10 @@ function hexToBytes7(hex) {
|
|
|
7214
8085
|
}
|
|
7215
8086
|
return out;
|
|
7216
8087
|
}
|
|
7217
|
-
function
|
|
8088
|
+
function bytesToHex9(bytes) {
|
|
7218
8089
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7219
8090
|
}
|
|
7220
|
-
function
|
|
8091
|
+
function concatBytes8(...parts) {
|
|
7221
8092
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7222
8093
|
let offset = 0;
|
|
7223
8094
|
for (const part of parts) {
|
|
@@ -7226,8 +8097,6 @@ function concatBytes6(...parts) {
|
|
|
7226
8097
|
}
|
|
7227
8098
|
return out;
|
|
7228
8099
|
}
|
|
7229
|
-
|
|
7230
|
-
// src/spending-policy.ts
|
|
7231
8100
|
var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
|
|
7232
8101
|
var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
|
|
7233
8102
|
var ML_DSA_65_SIGNATURE_LEN2 = 3309;
|
|
@@ -7250,10 +8119,38 @@ var SpendingPolicyError = class extends Error {
|
|
|
7250
8119
|
function spendingPolicyAddressHex() {
|
|
7251
8120
|
return PRECOMPILE_ADDRESSES.SPENDING_POLICY.toLowerCase();
|
|
7252
8121
|
}
|
|
8122
|
+
var EMPTY_ROOT = new Uint8Array(32);
|
|
8123
|
+
function destinationRoot(address) {
|
|
8124
|
+
const bytes = toUserAddressBytes(address, "address");
|
|
8125
|
+
return sha3_js.keccak_256(bytes);
|
|
8126
|
+
}
|
|
8127
|
+
var allowRootFor = destinationRoot;
|
|
8128
|
+
var denyRootFor = destinationRoot;
|
|
8129
|
+
function categoryRoot(selectorOrSig) {
|
|
8130
|
+
let selector;
|
|
8131
|
+
if (typeof selectorOrSig === "string") {
|
|
8132
|
+
selector = sha3_js.keccak_256(new TextEncoder().encode(selectorOrSig)).slice(0, 4);
|
|
8133
|
+
} else {
|
|
8134
|
+
selector = selectorOrSig instanceof Uint8Array ? selectorOrSig : Uint8Array.from(selectorOrSig);
|
|
8135
|
+
if (selector.length !== 4) {
|
|
8136
|
+
throw new SpendingPolicyError("category selector must be exactly 4 bytes");
|
|
8137
|
+
}
|
|
8138
|
+
}
|
|
8139
|
+
return sha3_js.keccak_256(selector);
|
|
8140
|
+
}
|
|
8141
|
+
function setDestinationRoot(entries) {
|
|
8142
|
+
if (entries.length === 0) return EMPTY_ROOT;
|
|
8143
|
+
if (entries.length > 1) {
|
|
8144
|
+
throw new SpendingPolicyError(
|
|
8145
|
+
"multi-entry destination sets are not supported by the chain yet (v1 allows a single counterparty per root); pass exactly one address"
|
|
8146
|
+
);
|
|
8147
|
+
}
|
|
8148
|
+
return destinationRoot(entries[0]);
|
|
8149
|
+
}
|
|
7253
8150
|
function composeClaimBoundMessage(chainId, args, opts) {
|
|
7254
8151
|
const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
|
|
7255
8152
|
const normalized = normalizeArgs(args);
|
|
7256
|
-
return
|
|
8153
|
+
return concatBytes9(
|
|
7257
8154
|
new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
|
|
7258
8155
|
uint64Bytes(chainId, "chainId"),
|
|
7259
8156
|
precompileAddress,
|
|
@@ -7276,17 +8173,17 @@ function composeClaimBoundMessage(chainId, args, opts) {
|
|
|
7276
8173
|
}
|
|
7277
8174
|
function encodeSetPolicyCalldata(args) {
|
|
7278
8175
|
const normalized = normalizeArgs(args);
|
|
7279
|
-
return
|
|
7280
|
-
|
|
7281
|
-
|
|
8176
|
+
return bytesToHex10(
|
|
8177
|
+
concatBytes9(
|
|
8178
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicy),
|
|
7282
8179
|
encodePolicyWords(normalized)
|
|
7283
8180
|
)
|
|
7284
8181
|
);
|
|
7285
8182
|
}
|
|
7286
8183
|
function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
7287
8184
|
const normalized = normalizeArgs(args);
|
|
7288
|
-
const pubkey =
|
|
7289
|
-
const sig =
|
|
8185
|
+
const pubkey = toBytes7(subAccountPubkey);
|
|
8186
|
+
const sig = toBytes7(subAccountSig);
|
|
7290
8187
|
if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
|
|
7291
8188
|
throw new SpendingPolicyError(
|
|
7292
8189
|
`subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
|
|
@@ -7297,9 +8194,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7297
8194
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7298
8195
|
);
|
|
7299
8196
|
}
|
|
7300
|
-
return
|
|
7301
|
-
|
|
7302
|
-
|
|
8197
|
+
return bytesToHex10(
|
|
8198
|
+
concatBytes9(
|
|
8199
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.setPolicyClaim),
|
|
7303
8200
|
encodePolicyWords(normalized),
|
|
7304
8201
|
pubkey,
|
|
7305
8202
|
sig
|
|
@@ -7308,15 +8205,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
7308
8205
|
}
|
|
7309
8206
|
function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
|
|
7310
8207
|
const normalized = normalizeArgs(args);
|
|
7311
|
-
const sig =
|
|
8208
|
+
const sig = toBytes7(subAccountSig);
|
|
7312
8209
|
if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
|
|
7313
8210
|
throw new SpendingPolicyError(
|
|
7314
8211
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
7315
8212
|
);
|
|
7316
8213
|
}
|
|
7317
|
-
return
|
|
7318
|
-
|
|
7319
|
-
|
|
8214
|
+
return bytesToHex10(
|
|
8215
|
+
concatBytes9(
|
|
8216
|
+
hexToBytes9(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
|
|
7320
8217
|
encodePolicyWords(normalized),
|
|
7321
8218
|
sig
|
|
7322
8219
|
)
|
|
@@ -7335,17 +8232,17 @@ function normalizeArgs(args) {
|
|
|
7335
8232
|
principal: toUserAddressBytes(args.principal, "principal"),
|
|
7336
8233
|
dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
|
|
7337
8234
|
perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
7338
|
-
allowRoot: expectLength6(
|
|
7339
|
-
denyRoot: expectLength6(
|
|
8235
|
+
allowRoot: expectLength6(toBytes7(args.allowRoot), 32, "allowRoot"),
|
|
8236
|
+
denyRoot: expectLength6(toBytes7(args.denyRoot), 32, "denyRoot"),
|
|
7340
8237
|
weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
|
|
7341
8238
|
monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
|
|
7342
|
-
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(
|
|
7343
|
-
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(
|
|
8239
|
+
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes7(args.categoryAllowRoot), 32, "categoryAllowRoot"),
|
|
8240
|
+
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes7(args.timeWindow), 32, "timeWindow"),
|
|
7344
8241
|
policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
|
|
7345
8242
|
};
|
|
7346
8243
|
}
|
|
7347
8244
|
function encodePolicyWords(args) {
|
|
7348
|
-
return
|
|
8245
|
+
return concatBytes9(
|
|
7349
8246
|
encodeAddressWord(args.subAccount),
|
|
7350
8247
|
encodeAddressWord(args.principal),
|
|
7351
8248
|
encodeUint128Word(args.dailyCapLythoshi),
|
|
@@ -7370,7 +8267,7 @@ function packTimeWindow(enabled, startHour, endHour) {
|
|
|
7370
8267
|
return out;
|
|
7371
8268
|
}
|
|
7372
8269
|
function decodeTimeWindow(word) {
|
|
7373
|
-
const bytes = expectLength6(
|
|
8270
|
+
const bytes = expectLength6(toBytes7(word), 32, "timeWindow");
|
|
7374
8271
|
if (bytes.every((b) => b === 0)) return null;
|
|
7375
8272
|
if (bytes[29] === 0) return null;
|
|
7376
8273
|
return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
|
|
@@ -7382,16 +8279,16 @@ function clampHour(hour) {
|
|
|
7382
8279
|
return Math.min(hour, 23);
|
|
7383
8280
|
}
|
|
7384
8281
|
function encodeUint64Word(value) {
|
|
7385
|
-
return
|
|
8282
|
+
return concatBytes9(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
|
|
7386
8283
|
}
|
|
7387
8284
|
function encodeSingleAddressCall(selector, address, name) {
|
|
7388
|
-
return
|
|
8285
|
+
return bytesToHex10(concatBytes9(hexToBytes9(selector), encodeAddressWord(toUserAddressBytes(address, name))));
|
|
7389
8286
|
}
|
|
7390
8287
|
function encodeAddressWord(address) {
|
|
7391
|
-
return
|
|
8288
|
+
return concatBytes9(new Uint8Array(12), address);
|
|
7392
8289
|
}
|
|
7393
8290
|
function encodeUint128Word(value) {
|
|
7394
|
-
return
|
|
8291
|
+
return concatBytes9(new Uint8Array(16), uint128Bytes(value, "uint128"));
|
|
7395
8292
|
}
|
|
7396
8293
|
function toUserAddressBytes(value, name) {
|
|
7397
8294
|
if (typeof value !== "string") {
|
|
@@ -7413,13 +8310,13 @@ function toRawAddressBytes(value) {
|
|
|
7413
8310
|
}
|
|
7414
8311
|
return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
|
|
7415
8312
|
}
|
|
7416
|
-
function
|
|
8313
|
+
function toBytes7(value) {
|
|
7417
8314
|
if (typeof value === "string") {
|
|
7418
|
-
return
|
|
8315
|
+
return hexToBytes9(value);
|
|
7419
8316
|
}
|
|
7420
8317
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7421
8318
|
}
|
|
7422
|
-
function
|
|
8319
|
+
function hexToBytes9(hex) {
|
|
7423
8320
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7424
8321
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7425
8322
|
throw new SpendingPolicyError("invalid hex bytes");
|
|
@@ -7430,10 +8327,10 @@ function hexToBytes8(hex) {
|
|
|
7430
8327
|
}
|
|
7431
8328
|
return out;
|
|
7432
8329
|
}
|
|
7433
|
-
function
|
|
8330
|
+
function bytesToHex10(bytes) {
|
|
7434
8331
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7435
8332
|
}
|
|
7436
|
-
function
|
|
8333
|
+
function concatBytes9(...parts) {
|
|
7437
8334
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7438
8335
|
let offset = 0;
|
|
7439
8336
|
for (const part of parts) {
|
|
@@ -7495,17 +8392,17 @@ function pubkeyRegistryAddressHex() {
|
|
|
7495
8392
|
return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
|
|
7496
8393
|
}
|
|
7497
8394
|
function encodeRegisterPubkeyCalldata(pubkey) {
|
|
7498
|
-
const bytes =
|
|
8395
|
+
const bytes = toBytes8(pubkey);
|
|
7499
8396
|
if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
7500
8397
|
throw new PubkeyRegistryError(
|
|
7501
8398
|
`pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
|
|
7502
8399
|
);
|
|
7503
8400
|
}
|
|
7504
|
-
return
|
|
7505
|
-
|
|
7506
|
-
|
|
7507
|
-
|
|
7508
|
-
|
|
8401
|
+
return bytesToHex11(
|
|
8402
|
+
concatBytes10(
|
|
8403
|
+
hexToBytes10(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
|
|
8404
|
+
uint256Word2(32n),
|
|
8405
|
+
uint256Word2(BigInt(bytes.length)),
|
|
7509
8406
|
bytes
|
|
7510
8407
|
)
|
|
7511
8408
|
);
|
|
@@ -7517,7 +8414,7 @@ function encodeHasPubkeyCalldata(address) {
|
|
|
7517
8414
|
return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
|
|
7518
8415
|
}
|
|
7519
8416
|
function decodeLookupPubkeyReturn(data) {
|
|
7520
|
-
const bytes =
|
|
8417
|
+
const bytes = toBytes8(data);
|
|
7521
8418
|
if (bytes.length < 96) {
|
|
7522
8419
|
throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
|
|
7523
8420
|
}
|
|
@@ -7542,7 +8439,7 @@ function decodeLookupPubkeyReturn(data) {
|
|
|
7542
8439
|
};
|
|
7543
8440
|
}
|
|
7544
8441
|
function decodeHasPubkeyReturn(data) {
|
|
7545
|
-
const bytes =
|
|
8442
|
+
const bytes = toBytes8(data);
|
|
7546
8443
|
if (bytes.length !== 32) {
|
|
7547
8444
|
throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
|
|
7548
8445
|
}
|
|
@@ -7556,10 +8453,10 @@ function decodeHasPubkeyReturn(data) {
|
|
|
7556
8453
|
throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
|
|
7557
8454
|
}
|
|
7558
8455
|
function encodeSingleAddressCall2(selector, address) {
|
|
7559
|
-
return
|
|
8456
|
+
return bytesToHex11(concatBytes10(hexToBytes10(selector), addressWord3(toAddressBytes(address))));
|
|
7560
8457
|
}
|
|
7561
|
-
function
|
|
7562
|
-
return
|
|
8458
|
+
function addressWord3(address) {
|
|
8459
|
+
return concatBytes10(new Uint8Array(12), address);
|
|
7563
8460
|
}
|
|
7564
8461
|
function toAddressBytes(value) {
|
|
7565
8462
|
if (typeof value !== "string") {
|
|
@@ -7575,13 +8472,13 @@ function toAddressBytes(value) {
|
|
|
7575
8472
|
throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
|
|
7576
8473
|
}
|
|
7577
8474
|
}
|
|
7578
|
-
function
|
|
8475
|
+
function toBytes8(value) {
|
|
7579
8476
|
if (typeof value === "string") {
|
|
7580
|
-
return
|
|
8477
|
+
return hexToBytes10(value);
|
|
7581
8478
|
}
|
|
7582
8479
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
7583
8480
|
}
|
|
7584
|
-
function
|
|
8481
|
+
function hexToBytes10(hex) {
|
|
7585
8482
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
7586
8483
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
7587
8484
|
throw new PubkeyRegistryError("invalid hex bytes");
|
|
@@ -7592,10 +8489,10 @@ function hexToBytes9(hex) {
|
|
|
7592
8489
|
}
|
|
7593
8490
|
return out;
|
|
7594
8491
|
}
|
|
7595
|
-
function
|
|
8492
|
+
function bytesToHex11(bytes) {
|
|
7596
8493
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
7597
8494
|
}
|
|
7598
|
-
function
|
|
8495
|
+
function concatBytes10(...parts) {
|
|
7599
8496
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
7600
8497
|
let offset = 0;
|
|
7601
8498
|
for (const part of parts) {
|
|
@@ -7604,7 +8501,7 @@ function concatBytes8(...parts) {
|
|
|
7604
8501
|
}
|
|
7605
8502
|
return out;
|
|
7606
8503
|
}
|
|
7607
|
-
function
|
|
8504
|
+
function uint256Word2(value) {
|
|
7608
8505
|
if (value < 0n || value > (1n << 256n) - 1n) {
|
|
7609
8506
|
throw new PubkeyRegistryError("uint256 value out of range");
|
|
7610
8507
|
}
|
|
@@ -7752,9 +8649,9 @@ function encodePlaceLimitOrderCalldata(args) {
|
|
|
7752
8649
|
normalized.baseTokenId,
|
|
7753
8650
|
normalized.quoteTokenId,
|
|
7754
8651
|
uint8Word2(normalized.side),
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
8652
|
+
uint256Word3(normalized.price, "price"),
|
|
8653
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
8654
|
+
uint64Word4(normalized.expiryBlock, "expiryBlock")
|
|
7758
8655
|
)
|
|
7759
8656
|
);
|
|
7760
8657
|
}
|
|
@@ -7766,7 +8663,7 @@ function encodePlaceMarketOrderCalldata(args) {
|
|
|
7766
8663
|
normalized.baseTokenId,
|
|
7767
8664
|
normalized.quoteTokenId,
|
|
7768
8665
|
uint8Word2(normalized.side),
|
|
7769
|
-
|
|
8666
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7770
8667
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps")
|
|
7771
8668
|
)
|
|
7772
8669
|
);
|
|
@@ -7779,7 +8676,7 @@ function encodePlaceMarketOrderExCalldata(args) {
|
|
|
7779
8676
|
normalized.baseTokenId,
|
|
7780
8677
|
normalized.quoteTokenId,
|
|
7781
8678
|
uint8Word2(normalized.side),
|
|
7782
|
-
|
|
8679
|
+
uint256Word3(normalized.quantity, "quantity"),
|
|
7783
8680
|
uint16Word2(normalized.maxSlippageBps, "maxSlippageBps"),
|
|
7784
8681
|
uint8Word2(normalized.mode)
|
|
7785
8682
|
)
|
|
@@ -7799,7 +8696,7 @@ function encodeMarketGridTuneCalldata(selector, label, args) {
|
|
|
7799
8696
|
hexToBytes2(selector, `${label} selector`),
|
|
7800
8697
|
bytes32FromHex(args.baseTokenId, "baseTokenId"),
|
|
7801
8698
|
bytes32FromHex(args.quoteTokenId, "quoteTokenId"),
|
|
7802
|
-
|
|
8699
|
+
uint256Word3(BigInt(args.newValue), "newValue")
|
|
7803
8700
|
)
|
|
7804
8701
|
);
|
|
7805
8702
|
}
|
|
@@ -8087,13 +8984,13 @@ function encodePlaceLimitOrderViaCalldata(args) {
|
|
|
8087
8984
|
return bytesToHex2(
|
|
8088
8985
|
concatBytes2(
|
|
8089
8986
|
hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
|
|
8090
|
-
|
|
8987
|
+
addressWord4(operator.bytes),
|
|
8091
8988
|
bytes32FromHex(args.base, "base"),
|
|
8092
8989
|
bytes32FromHex(args.quote, "quote"),
|
|
8093
8990
|
uint8Word2(side),
|
|
8094
|
-
|
|
8095
|
-
|
|
8096
|
-
|
|
8991
|
+
uint256Word3(price, "price"),
|
|
8992
|
+
uint256Word3(amount, "amount"),
|
|
8993
|
+
uint64Word4(expiresAtBlock, "expiresAtBlock")
|
|
8097
8994
|
)
|
|
8098
8995
|
);
|
|
8099
8996
|
}
|
|
@@ -8383,7 +9280,7 @@ function uint8Word2(value) {
|
|
|
8383
9280
|
out[31] = value;
|
|
8384
9281
|
return out;
|
|
8385
9282
|
}
|
|
8386
|
-
function
|
|
9283
|
+
function uint64Word4(value, name) {
|
|
8387
9284
|
if (value < 0n || value > 0xffffffffffffffffn) {
|
|
8388
9285
|
throw new MarketActionError(`${name} must fit uint64`);
|
|
8389
9286
|
}
|
|
@@ -8404,7 +9301,7 @@ function uint16Word2(value, name) {
|
|
|
8404
9301
|
out[31] = Number(value & 0xffn);
|
|
8405
9302
|
return out;
|
|
8406
9303
|
}
|
|
8407
|
-
function
|
|
9304
|
+
function uint256Word3(value, name) {
|
|
8408
9305
|
if (value < 0n || value >= 1n << 256n) {
|
|
8409
9306
|
throw new MarketActionError(`${name} must fit uint256`);
|
|
8410
9307
|
}
|
|
@@ -8416,7 +9313,7 @@ function uint256Word2(value, name) {
|
|
|
8416
9313
|
}
|
|
8417
9314
|
return out;
|
|
8418
9315
|
}
|
|
8419
|
-
function
|
|
9316
|
+
function addressWord4(addr) {
|
|
8420
9317
|
if (addr.length !== 20) {
|
|
8421
9318
|
throw new MarketActionError("address must be 20 bytes");
|
|
8422
9319
|
}
|
|
@@ -8980,7 +9877,9 @@ exports.DELEGATION_REVERT_TAGS = DELEGATION_REVERT_TAGS;
|
|
|
8980
9877
|
exports.DELEGATION_SELECTORS = DELEGATION_SELECTORS;
|
|
8981
9878
|
exports.DIVERSITY_SCORE_MAX = DIVERSITY_SCORE_MAX;
|
|
8982
9879
|
exports.DelegationPrecompileError = DelegationPrecompileError;
|
|
9880
|
+
exports.EMPTY_ROOT = EMPTY_ROOT;
|
|
8983
9881
|
exports.EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
9882
|
+
exports.FEED_ID_DOMAIN_TAG = FEED_ID_DOMAIN_TAG;
|
|
8984
9883
|
exports.LYTHOSHI_PER_LYTH = LYTHOSHI_PER_LYTH;
|
|
8985
9884
|
exports.LYTH_DECIMALS = LYTH_DECIMALS;
|
|
8986
9885
|
exports.MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES = MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES;
|
|
@@ -9006,6 +9905,12 @@ exports.MRV_TX_EXTENSION_V1 = MRV_TX_EXTENSION_V1;
|
|
|
9006
9905
|
exports.MULTISIG_ADDRESS_DERIVATION_DOMAIN = MULTISIG_ADDRESS_DERIVATION_DOMAIN;
|
|
9007
9906
|
exports.MarketActionError = MarketActionError;
|
|
9008
9907
|
exports.MrvValidationError = MrvValidationError;
|
|
9908
|
+
exports.NAME_BASE_MULTIPLIER = NAME_BASE_MULTIPLIER;
|
|
9909
|
+
exports.NAME_FALLBACK_FEE_UNIT_LYTHOSHI = NAME_FALLBACK_FEE_UNIT_LYTHOSHI;
|
|
9910
|
+
exports.NAME_LABEL_MAX_LEN = NAME_LABEL_MAX_LEN;
|
|
9911
|
+
exports.NAME_LABEL_MIN_LEN = NAME_LABEL_MIN_LEN;
|
|
9912
|
+
exports.NAME_MAX_LEN = NAME_MAX_LEN;
|
|
9913
|
+
exports.NAME_REGISTRY_SELECTORS = NAME_REGISTRY_SELECTORS;
|
|
9009
9914
|
exports.NATIVE_AGENT_MODULE_ADDRESS = NATIVE_AGENT_MODULE_ADDRESS;
|
|
9010
9915
|
exports.NATIVE_AGENT_MODULE_ADDRESS_BYTES = NATIVE_AGENT_MODULE_ADDRESS_BYTES;
|
|
9011
9916
|
exports.NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE = NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE;
|
|
@@ -9019,8 +9924,13 @@ exports.NATIVE_MARKET_EVENT_FAMILY = NATIVE_MARKET_EVENT_FAMILY;
|
|
|
9019
9924
|
exports.NATIVE_MARKET_MODULE_ADDRESS = NATIVE_MARKET_MODULE_ADDRESS;
|
|
9020
9925
|
exports.NATIVE_MARKET_MODULE_ADDRESS_BYTES = NATIVE_MARKET_MODULE_ADDRESS_BYTES;
|
|
9021
9926
|
exports.NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC = NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC;
|
|
9927
|
+
exports.NODE_REGISTRY_BLS_PUBKEY_BYTES = NODE_REGISTRY_BLS_PUBKEY_BYTES;
|
|
9022
9928
|
exports.NODE_REGISTRY_CAPABILITIES = NODE_REGISTRY_CAPABILITIES;
|
|
9023
9929
|
exports.NODE_REGISTRY_CAPABILITY_MASK = NODE_REGISTRY_CAPABILITY_MASK;
|
|
9930
|
+
exports.NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS = NODE_REGISTRY_DKG_RESHARE_MAX_SIGNERS;
|
|
9931
|
+
exports.NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS = NODE_REGISTRY_DKG_RESHARE_MIN_SIGNERS;
|
|
9932
|
+
exports.NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES = NODE_REGISTRY_DKG_THRESHOLD_SIG_BYTES;
|
|
9933
|
+
exports.NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID;
|
|
9024
9934
|
exports.NODE_REGISTRY_PUBLIC_SERVICE_MASK = NODE_REGISTRY_PUBLIC_SERVICE_MASK;
|
|
9025
9935
|
exports.NODE_REGISTRY_SELECTORS = NODE_REGISTRY_SELECTORS;
|
|
9026
9936
|
exports.NO_EVM_ARCHIVE_PROOF_SCHEMA = NO_EVM_ARCHIVE_PROOF_SCHEMA;
|
|
@@ -9032,6 +9942,7 @@ exports.NO_EVM_RECEIPT_CODEC = NO_EVM_RECEIPT_CODEC;
|
|
|
9032
9942
|
exports.NO_EVM_RECEIPT_PROOF_SCHEMA = NO_EVM_RECEIPT_PROOF_SCHEMA;
|
|
9033
9943
|
exports.NO_EVM_RECEIPT_PROOF_TYPE = NO_EVM_RECEIPT_PROOF_TYPE;
|
|
9034
9944
|
exports.NO_EVM_RECEIPT_ROOT_ALGORITHM = NO_EVM_RECEIPT_ROOT_ALGORITHM;
|
|
9945
|
+
exports.NameRegistryError = NameRegistryError;
|
|
9035
9946
|
exports.NoEvmReceiptProofError = NoEvmReceiptProofError;
|
|
9036
9947
|
exports.NodeRegistryError = NodeRegistryError;
|
|
9037
9948
|
exports.OPERATOR_ROUTER_ADDRESS = OPERATOR_ROUTER_ADDRESS;
|
|
@@ -9040,6 +9951,7 @@ exports.OPERATOR_ROUTER_SELECTORS = OPERATOR_ROUTER_SELECTORS;
|
|
|
9040
9951
|
exports.OPERATOR_ROUTER_SIGS = OPERATOR_ROUTER_SIGS;
|
|
9041
9952
|
exports.ORACLE_EVENT_SIGS = ORACLE_EVENT_SIGS;
|
|
9042
9953
|
exports.OracleEventError = OracleEventError;
|
|
9954
|
+
exports.PENDING_CHANGE_KIND_CODES = PENDING_CHANGE_KIND_CODES;
|
|
9043
9955
|
exports.PRECOMPILE_ADDRESSES = PRECOMPILE_ADDRESSES;
|
|
9044
9956
|
exports.PROTOCOL_MAX_OPERATOR_FEE_BPS = PROTOCOL_MAX_OPERATOR_FEE_BPS;
|
|
9045
9957
|
exports.PROVER_MARKET_ADDRESS = PROVER_MARKET_ADDRESS;
|
|
@@ -9070,6 +9982,7 @@ exports.V1_BRIDGE_ALLOWED_PROTOCOL = V1_BRIDGE_ALLOWED_PROTOCOL;
|
|
|
9070
9982
|
exports.addressBytesToHex = addressBytesToHex;
|
|
9071
9983
|
exports.addressToBech32 = addressToBech32;
|
|
9072
9984
|
exports.addressToTypedBech32 = addressToTypedBech32;
|
|
9985
|
+
exports.allowRootFor = allowRootFor;
|
|
9073
9986
|
exports.apiEndpointFromRpcEndpoint = apiEndpointFromRpcEndpoint;
|
|
9074
9987
|
exports.assertMrvCallNativeSubmissionPlan = assertMrvCallNativeSubmissionPlan;
|
|
9075
9988
|
exports.assertMrvDeployNativeSubmissionPlan = assertMrvDeployNativeSubmissionPlan;
|
|
@@ -9134,11 +10047,13 @@ exports.buildPlaceLimitOrderViaPlan = buildPlaceLimitOrderViaPlan;
|
|
|
9134
10047
|
exports.buildPlaceSpotLimitOrderPlan = buildPlaceSpotLimitOrderPlan;
|
|
9135
10048
|
exports.buildPlaceSpotMarketOrderExPlan = buildPlaceSpotMarketOrderExPlan;
|
|
9136
10049
|
exports.buildPlaceSpotMarketOrderPlan = buildPlaceSpotMarketOrderPlan;
|
|
10050
|
+
exports.categoryRoot = categoryRoot;
|
|
9137
10051
|
exports.checkMrvFeeDisplayConformance = checkMrvFeeDisplayConformance;
|
|
9138
10052
|
exports.checkMrvStructuredFeeConformance = checkMrvStructuredFeeConformance;
|
|
9139
10053
|
exports.checkNativeDevkitCompatibility = checkNativeDevkitCompatibility;
|
|
9140
10054
|
exports.clampPriorityTip = clampPriorityTip;
|
|
9141
10055
|
exports.clobAddressHex = clobAddressHex;
|
|
10056
|
+
exports.clusterApyPercent = clusterApyPercent;
|
|
9142
10057
|
exports.compareNativeDevVersions = compareNativeDevVersions;
|
|
9143
10058
|
exports.composeClaimBoundMessage = composeClaimBoundMessage;
|
|
9144
10059
|
exports.computeNoEvmDacFinalityMessage = computeNoEvmDacFinalityMessage;
|
|
@@ -9146,6 +10061,7 @@ exports.computeNoEvmLeaderFinalityMessage = computeNoEvmLeaderFinalityMessage;
|
|
|
9146
10061
|
exports.computeNoEvmReceiptsRoot = computeNoEvmReceiptsRoot;
|
|
9147
10062
|
exports.computeNoEvmRoundFinalityMessage = computeNoEvmRoundFinalityMessage;
|
|
9148
10063
|
exports.computeNoEvmTargetReceiptHash = computeNoEvmTargetReceiptHash;
|
|
10064
|
+
exports.computeQuoteLiquidity = computeQuoteLiquidity;
|
|
9149
10065
|
exports.consumeNativeEvents = consumeNativeEvents;
|
|
9150
10066
|
exports.decodeClusterDiversity = decodeClusterDiversity;
|
|
9151
10067
|
exports.decodeClusterFormedEvent = decodeClusterFormedEvent;
|
|
@@ -9161,13 +10077,20 @@ exports.decodeOracleEvent = decodeOracleEvent;
|
|
|
9161
10077
|
exports.decodeTimeWindow = decodeTimeWindow;
|
|
9162
10078
|
exports.decodeTxFeedResponse = decodeTxFeedResponse;
|
|
9163
10079
|
exports.delegationAddressHex = delegationAddressHex;
|
|
10080
|
+
exports.denyRootFor = denyRootFor;
|
|
9164
10081
|
exports.deriveClobMarketId = deriveClobMarketId;
|
|
9165
10082
|
exports.deriveClusterAnchorAddress = deriveClusterAnchorAddress;
|
|
10083
|
+
exports.deriveFeedId = deriveFeedId;
|
|
9166
10084
|
exports.deriveMrvContractAddress = deriveMrvContractAddress;
|
|
9167
10085
|
exports.deriveNativeSpotMarketId = deriveNativeSpotMarketId;
|
|
9168
10086
|
exports.deriveNativeSpotOrderId = deriveNativeSpotOrderId;
|
|
10087
|
+
exports.destinationRoot = destinationRoot;
|
|
10088
|
+
exports.encodeAttestDkgReshareCalldata = encodeAttestDkgReshareCalldata;
|
|
9169
10089
|
exports.encodeBlockSelector = encodeBlockSelector;
|
|
10090
|
+
exports.encodeBridgeChallengeCalldata = encodeBridgeChallengeCalldata;
|
|
10091
|
+
exports.encodeBridgeClaimCalldata = encodeBridgeClaimCalldata;
|
|
9170
10092
|
exports.encodeCancelOrderCalldata = encodeCancelOrderCalldata;
|
|
10093
|
+
exports.encodeCancelPendingChangeCalldata = encodeCancelPendingChangeCalldata;
|
|
9171
10094
|
exports.encodeClaimCalldata = encodeClaimCalldata;
|
|
9172
10095
|
exports.encodeClaimPolicyByAddressCalldata = encodeClaimPolicyByAddressCalldata;
|
|
9173
10096
|
exports.encodeCompleteRedemptionCalldata = encodeCompleteRedemptionCalldata;
|
|
@@ -9180,6 +10103,9 @@ exports.encodeHasPubkeyCalldata = encodeHasPubkeyCalldata;
|
|
|
9180
10103
|
exports.encodeLockBridgeConfigCalldata = encodeLockBridgeConfigCalldata;
|
|
9181
10104
|
exports.encodeLookupPubkeyCalldata = encodeLookupPubkeyCalldata;
|
|
9182
10105
|
exports.encodeMrvDeployPayload = encodeMrvDeployPayload;
|
|
10106
|
+
exports.encodeNameAcceptTransferCall = encodeNameAcceptTransferCall;
|
|
10107
|
+
exports.encodeNameProposeTransferCall = encodeNameProposeTransferCall;
|
|
10108
|
+
exports.encodeNameRegisterCall = encodeNameRegisterCall;
|
|
9183
10109
|
exports.encodeNativeAgentAcceptEscrowCall = encodeNativeAgentAcceptEscrowCall;
|
|
9184
10110
|
exports.encodeNativeAgentApproveEscrowCall = encodeNativeAgentApproveEscrowCall;
|
|
9185
10111
|
exports.encodeNativeAgentArbiterGetCall = encodeNativeAgentArbiterGetCall;
|
|
@@ -9229,6 +10155,7 @@ exports.encodePlaceLimitOrderCalldata = encodePlaceLimitOrderCalldata;
|
|
|
9229
10155
|
exports.encodePlaceLimitOrderViaCalldata = encodePlaceLimitOrderViaCalldata;
|
|
9230
10156
|
exports.encodePlaceMarketOrderCalldata = encodePlaceMarketOrderCalldata;
|
|
9231
10157
|
exports.encodePlaceMarketOrderExCalldata = encodePlaceMarketOrderExCalldata;
|
|
10158
|
+
exports.encodeRecoverOperatorNodeCalldata = encodeRecoverOperatorNodeCalldata;
|
|
9232
10159
|
exports.encodeRedelegateCalldata = encodeRedelegateCalldata;
|
|
9233
10160
|
exports.encodeRegisterPubkeyCalldata = encodeRegisterPubkeyCalldata;
|
|
9234
10161
|
exports.encodeReportServiceProbeCalldata = encodeReportServiceProbeCalldata;
|
|
@@ -9240,6 +10167,8 @@ exports.encodeSetMinNotionalCalldata = encodeSetMinNotionalCalldata;
|
|
|
9240
10167
|
exports.encodeSetPolicyCalldata = encodeSetPolicyCalldata;
|
|
9241
10168
|
exports.encodeSetPolicyClaimCalldata = encodeSetPolicyClaimCalldata;
|
|
9242
10169
|
exports.encodeSetTickSizeCalldata = encodeSetTickSizeCalldata;
|
|
10170
|
+
exports.encodeSubmitBridgeProofCalldata = encodeSubmitBridgeProofCalldata;
|
|
10171
|
+
exports.encodeSubmitPendingChangeCalldata = encodeSubmitPendingChangeCalldata;
|
|
9243
10172
|
exports.encodeUndelegateCalldata = encodeUndelegateCalldata;
|
|
9244
10173
|
exports.exportBridgeRouteCatalogueJson = exportBridgeRouteCatalogueJson;
|
|
9245
10174
|
exports.fetchChainInfoLatest = fetchChainInfoLatest;
|
|
@@ -9247,6 +10176,7 @@ exports.fetchChainRegistryLatest = fetchChainRegistryLatest;
|
|
|
9247
10176
|
exports.formatLyth = formatLyth;
|
|
9248
10177
|
exports.formatLythoshi = formatLythoshi;
|
|
9249
10178
|
exports.formatNativeReceiptFeeDisplay = formatNativeReceiptFeeDisplay;
|
|
10179
|
+
exports.formatOraclePrice = formatOraclePrice;
|
|
9250
10180
|
exports.getChainInfo = getChainInfo;
|
|
9251
10181
|
exports.getNoEvmReceiptTrustPolicy = getNoEvmReceiptTrustPolicy;
|
|
9252
10182
|
exports.getP2pSeeds = getP2pSeeds;
|
|
@@ -9267,6 +10197,9 @@ exports.mrvAddressToBech32 = mrvAddressToBech32;
|
|
|
9267
10197
|
exports.mrvBech32ToAddress = mrvBech32ToAddress;
|
|
9268
10198
|
exports.mrvCodeHashHex = mrvCodeHashHex;
|
|
9269
10199
|
exports.mrvV1TransactionExtension = mrvV1TransactionExtension;
|
|
10200
|
+
exports.nameLengthModifierX10 = nameLengthModifierX10;
|
|
10201
|
+
exports.nameRegistrationCost = nameRegistrationCost;
|
|
10202
|
+
exports.nameRegistryAddressHex = nameRegistryAddressHex;
|
|
9270
10203
|
exports.nativeAgentStateFilterParams = nativeAgentStateFilterParams;
|
|
9271
10204
|
exports.nativeDevSchemaFieldNames = nativeDevSchemaFieldNames;
|
|
9272
10205
|
exports.nativeDevUiStrings = nativeDevUiStrings;
|
|
@@ -9284,12 +10217,16 @@ exports.nodeHostingClassToByte = nodeHostingClassToByte;
|
|
|
9284
10217
|
exports.nodeRegistryAddressHex = nodeRegistryAddressHex;
|
|
9285
10218
|
exports.normalizeAddressHex = normalizeAddressHex;
|
|
9286
10219
|
exports.normalizeBridgeRouteCatalogue = normalizeBridgeRouteCatalogue;
|
|
10220
|
+
exports.normalizePendingChangeKind = normalizePendingChangeKind;
|
|
9287
10221
|
exports.oracleAddressHex = oracleAddressHex;
|
|
10222
|
+
exports.oraclePriceToNumber = oraclePriceToNumber;
|
|
9288
10223
|
exports.packTimeWindow = packTimeWindow;
|
|
9289
10224
|
exports.parseAddress = parseAddress;
|
|
9290
10225
|
exports.parseBridgeRouteCatalogueJson = parseBridgeRouteCatalogueJson;
|
|
9291
10226
|
exports.parseChainRegistryToml = parseChainRegistryToml;
|
|
10227
|
+
exports.parseDkgResharePublicKeys = parseDkgResharePublicKeys;
|
|
9292
10228
|
exports.parseLythToLythoshi = parseLythToLythoshi;
|
|
10229
|
+
exports.parseNameCategory = parseNameCategory;
|
|
9293
10230
|
exports.parseNativeDecodedEvent = parseNativeDecodedEvent;
|
|
9294
10231
|
exports.parseQuantity = parseQuantity;
|
|
9295
10232
|
exports.parseQuantityBig = parseQuantityBig;
|
|
@@ -9297,6 +10234,7 @@ exports.proverMarketStateFromByte = proverMarketStateFromByte;
|
|
|
9297
10234
|
exports.pubkeyRegistryAddressHex = pubkeyRegistryAddressHex;
|
|
9298
10235
|
exports.quoteOperatorFee = quoteOperatorFee;
|
|
9299
10236
|
exports.rankBridgeRoutes = rankBridgeRoutes;
|
|
10237
|
+
exports.rankMarketsByVolume = rankMarketsByVolume;
|
|
9300
10238
|
exports.requestSighash = requestSighash;
|
|
9301
10239
|
exports.requireTypedAddress = requireTypedAddress;
|
|
9302
10240
|
exports.resolveExecutionFee = resolveExecutionFee;
|
|
@@ -9305,11 +10243,13 @@ exports.resolveRegistryExecutionFee = resolveRegistryExecutionFee;
|
|
|
9305
10243
|
exports.resolveStudioHostStatus = resolveStudioHostStatus;
|
|
9306
10244
|
exports.selectBridgeTransferRoute = selectBridgeTransferRoute;
|
|
9307
10245
|
exports.serviceProbeStatusLabel = serviceProbeStatusLabel;
|
|
10246
|
+
exports.setDestinationRoot = setDestinationRoot;
|
|
9308
10247
|
exports.spendingPolicyAddressHex = spendingPolicyAddressHex;
|
|
9309
10248
|
exports.submitMrvCallNativeTx = submitMrvCallNativeTx;
|
|
9310
10249
|
exports.submitMrvDeployNativeTx = submitMrvDeployNativeTx;
|
|
9311
10250
|
exports.submitMrvDeployPayloadNativeTx = submitMrvDeployPayloadNativeTx;
|
|
9312
10251
|
exports.submitSighash = submitSighash;
|
|
10252
|
+
exports.transactionFeeExposure = transactionFeeExposure;
|
|
9313
10253
|
exports.typedBech32ToAddress = typedBech32ToAddress;
|
|
9314
10254
|
exports.validateAddress = validateAddress;
|
|
9315
10255
|
exports.validateBridgeRouteCatalogue = validateBridgeRouteCatalogue;
|