@monolythium/core-sdk 0.3.9 → 0.3.11
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 +5 -5
- package/dist/crypto/index.cjs +58 -0
- package/dist/crypto/index.cjs.map +1 -1
- package/dist/crypto/index.d.cts +2 -2
- package/dist/crypto/index.d.ts +2 -2
- package/dist/crypto/index.js +56 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/index.cjs +966 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +140 -473
- package/dist/index.d.ts +140 -473
- package/dist/index.js +918 -78
- package/dist/index.js.map +1 -1
- package/dist/{submission-D8xzCLNl.d.cts → submission-CA8L21An.d.cts} +1722 -58
- package/dist/{submission-D8xzCLNl.d.ts → submission-CA8L21An.d.ts} +1722 -58
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blake3 } from '@noble/hashes/blake3.js';
|
|
2
|
+
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
2
3
|
import { ml_kem768 } from '@noble/post-quantum/ml-kem.js';
|
|
3
4
|
import { chacha20poly1305 } from '@noble/ciphers/chacha.js';
|
|
4
|
-
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
5
5
|
import { randomBytes } from '@noble/hashes/utils.js';
|
|
6
6
|
import { ml_dsa65 } from '@noble/post-quantum/ml-dsa.js';
|
|
7
7
|
import { bls12_381 } from '@noble/curves/bls12-381.js';
|
|
@@ -359,6 +359,10 @@ var PRECOMPILE_ADDRESSES = {
|
|
|
359
359
|
ORACLE: "0x0000000000000000000000000000000000001009",
|
|
360
360
|
/** Distributed delegation primitive — gateable. */
|
|
361
361
|
DELEGATION: "0x000000000000000000000000000000000000100A",
|
|
362
|
+
/** Operator-fee router — skims an operator surcharge on routed CLOB ops; gateable. */
|
|
363
|
+
OPERATOR_ROUTER: "0x000000000000000000000000000000000000100B",
|
|
364
|
+
/** GPU prover market — gateable, genesis-disabled (foundation milestone flip). */
|
|
365
|
+
PROVER_MARKET: "0x000000000000000000000000000000000000100C",
|
|
362
366
|
/** One-time emergency-key registry — non-gateable. */
|
|
363
367
|
EMERGENCY_KEY: "0x0000000000000000000000000000000000001100",
|
|
364
368
|
/** VRF precompile. */
|
|
@@ -388,6 +392,8 @@ var PRECOMPILE_ADDRESSES = {
|
|
|
388
392
|
/** Hierarchical name registry — gateable. */
|
|
389
393
|
NAME_REGISTRY: "0x000000000000000000000000000000000000110E"
|
|
390
394
|
};
|
|
395
|
+
var OPERATOR_ROUTER_ADDRESS = PRECOMPILE_ADDRESSES.OPERATOR_ROUTER;
|
|
396
|
+
var PROTOCOL_MAX_OPERATOR_FEE_BPS = 100;
|
|
391
397
|
|
|
392
398
|
// src/node-registry.ts
|
|
393
399
|
var NODE_REGISTRY_CAPABILITIES = {
|
|
@@ -399,8 +405,12 @@ var NODE_REGISTRY_CAPABILITIES = {
|
|
|
399
405
|
SERVES_LIGHT_CLIENT: 32,
|
|
400
406
|
SERVES_ORACLE_WRITER: 64,
|
|
401
407
|
SERVES_BRIDGE_RELAY: 128,
|
|
402
|
-
SERVES_PUBLIC_API: 256
|
|
408
|
+
SERVES_PUBLIC_API: 256,
|
|
409
|
+
/** GPU prover — may bid on + serve the GPU prover market (MB-4, bit 9). */
|
|
410
|
+
SERVES_GPU_PROVE: 512
|
|
403
411
|
};
|
|
412
|
+
var DIVERSITY_SCORE_MAX = 1e4;
|
|
413
|
+
var MULTISIG_ADDRESS_DERIVATION_DOMAIN = "MONO_MULTISIG_BLAKE3_20_V1";
|
|
404
414
|
var NODE_REGISTRY_CAPABILITY_MASK = 65535;
|
|
405
415
|
var NODE_REGISTRY_PUBLIC_SERVICE_MASK = NODE_REGISTRY_CAPABILITIES.SERVES_RPC | NODE_REGISTRY_CAPABILITIES.SERVES_INDEXER | NODE_REGISTRY_CAPABILITIES.SERVES_ARCHIVE | NODE_REGISTRY_CAPABILITIES.SERVES_WEBSOCKET | NODE_REGISTRY_CAPABILITIES.SERVES_PUBLIC_API;
|
|
406
416
|
var SERVICE_PROBE_STATUS = {
|
|
@@ -411,8 +421,15 @@ var SERVICE_PROBE_STATUS = {
|
|
|
411
421
|
};
|
|
412
422
|
var NODE_REGISTRY_SELECTORS = {
|
|
413
423
|
reportServiceProbe: "0xeee31bba",
|
|
414
|
-
getServiceProbe: "0x1fcbfbce"
|
|
424
|
+
getServiceProbe: "0x1fcbfbce",
|
|
425
|
+
/** `setNetworkMetadata(bytes32,uint16,bytes3,bytes)` — owner-callable (PF-6). */
|
|
426
|
+
setNetworkMetadata: "0x" + selectorHex("setNetworkMetadata(bytes32,uint16,bytes3,bytes)"),
|
|
427
|
+
/** `getOperatorNetworkMetadata(bytes32)` view (PF-6). */
|
|
428
|
+
getOperatorNetworkMetadata: "0x" + selectorHex("getOperatorNetworkMetadata(bytes32)"),
|
|
429
|
+
/** `getClusterDiversity(uint32)` view (PF-6). */
|
|
430
|
+
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)")
|
|
415
431
|
};
|
|
432
|
+
var CLUSTER_FORMED_EVENT_SIG = "ClusterFormed(uint32,uint64,address,bytes)";
|
|
416
433
|
var NodeRegistryError = class extends Error {
|
|
417
434
|
constructor(message) {
|
|
418
435
|
super(message);
|
|
@@ -467,6 +484,112 @@ function encodeReportServiceProbeCalldata(args) {
|
|
|
467
484
|
)
|
|
468
485
|
);
|
|
469
486
|
}
|
|
487
|
+
function nodeHostingClassFromByte(b) {
|
|
488
|
+
if (b === 0) return "bareMetal";
|
|
489
|
+
if (b === 1) return "coLocation";
|
|
490
|
+
return "cloud";
|
|
491
|
+
}
|
|
492
|
+
function nodeHostingClassToByte(c) {
|
|
493
|
+
switch (c) {
|
|
494
|
+
case "bareMetal":
|
|
495
|
+
return 0;
|
|
496
|
+
case "coLocation":
|
|
497
|
+
return 1;
|
|
498
|
+
default:
|
|
499
|
+
return 2;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
function decodeOperatorNetworkMetadata(returnData) {
|
|
503
|
+
const bytes = expectLength2(toBytes(returnData), 5 * 32, "operatorNetworkMetadata");
|
|
504
|
+
return {
|
|
505
|
+
asn: bytes[30] << 8 | bytes[31],
|
|
506
|
+
// bytes3 is left-aligned in the head word.
|
|
507
|
+
geoRegion: bytesToHex(bytes.slice(64, 67)),
|
|
508
|
+
hostingClass: nodeHostingClassFromByte(bytes[95]),
|
|
509
|
+
ipAddressHash: bytesToHex(bytes.slice(96, 128)),
|
|
510
|
+
pcrDigest: bytesToHex(bytes.slice(128, 160))
|
|
511
|
+
};
|
|
512
|
+
}
|
|
513
|
+
function decodeClusterDiversity(returnData) {
|
|
514
|
+
const bytes = expectLength2(toBytes(returnData), 4 * 32, "clusterDiversity");
|
|
515
|
+
const word = (i) => bytes[i * 32 + 30] << 8 | bytes[i * 32 + 31];
|
|
516
|
+
return {
|
|
517
|
+
score: word(0),
|
|
518
|
+
asnVariance: word(1),
|
|
519
|
+
geoVariance: word(2),
|
|
520
|
+
hostingSpread: word(3)
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function decodeClusterFormedEvent(topics, data) {
|
|
524
|
+
if (topics.length !== 3) {
|
|
525
|
+
throw new NodeRegistryError(`ClusterFormed expects 3 topics, got ${topics.length}`);
|
|
526
|
+
}
|
|
527
|
+
const body = toBytes(data);
|
|
528
|
+
if (body.length < 96) {
|
|
529
|
+
throw new NodeRegistryError("ClusterFormed data shorter than head + roster length");
|
|
530
|
+
}
|
|
531
|
+
const clusterIdTopic = expectLength2(toBytes(topics[1]), 32, "clusterId topic");
|
|
532
|
+
const epochTopic = expectLength2(toBytes(topics[2]), 32, "effectiveEpoch topic");
|
|
533
|
+
const clusterId = u32FromWord(clusterIdTopic);
|
|
534
|
+
const effectiveEpoch = u64FromWord(epochTopic);
|
|
535
|
+
const anchorAddress = bytesToHex(body.slice(12, 32));
|
|
536
|
+
const rosterLen = Number(u64FromWord(body.slice(64, 96)));
|
|
537
|
+
const rosterEnd = 96 + rosterLen;
|
|
538
|
+
if (body.length < rosterEnd) {
|
|
539
|
+
throw new NodeRegistryError("ClusterFormed roster payload truncated");
|
|
540
|
+
}
|
|
541
|
+
return {
|
|
542
|
+
clusterId,
|
|
543
|
+
effectiveEpoch,
|
|
544
|
+
anchorAddress,
|
|
545
|
+
operatorRoster: bytesToHex(body.slice(96, rosterEnd))
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function deriveClusterAnchorAddress(roster, threshold) {
|
|
549
|
+
if (!Number.isInteger(threshold) || threshold < 0 || threshold > 65535) {
|
|
550
|
+
throw new NodeRegistryError("threshold must be a uint16");
|
|
551
|
+
}
|
|
552
|
+
const members = roster.map((m, i) => expectLength2(toBytes(m), 48, `roster[${i}]`));
|
|
553
|
+
members.sort(compareBytes);
|
|
554
|
+
const parts = [
|
|
555
|
+
new TextEncoder().encode(MULTISIG_ADDRESS_DERIVATION_DOMAIN),
|
|
556
|
+
Uint8Array.from([threshold >> 8 & 255, threshold & 255])
|
|
557
|
+
];
|
|
558
|
+
for (const member of members) {
|
|
559
|
+
parts.push(u64BeBytes(BigInt(member.length)));
|
|
560
|
+
parts.push(member);
|
|
561
|
+
}
|
|
562
|
+
return bytesToHex(blake3(concatBytes(...parts)).slice(0, 20));
|
|
563
|
+
}
|
|
564
|
+
function selectorHex(sig) {
|
|
565
|
+
return [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
566
|
+
}
|
|
567
|
+
function u32FromWord(word) {
|
|
568
|
+
return (word[28] << 24 | word[29] << 16 | word[30] << 8 | word[31]) >>> 0;
|
|
569
|
+
}
|
|
570
|
+
function u64FromWord(word) {
|
|
571
|
+
let v = 0n;
|
|
572
|
+
for (let i = 24; i < 32; i++) {
|
|
573
|
+
v = v << 8n | BigInt(word[i]);
|
|
574
|
+
}
|
|
575
|
+
return v;
|
|
576
|
+
}
|
|
577
|
+
function u64BeBytes(value) {
|
|
578
|
+
const out = new Uint8Array(8);
|
|
579
|
+
let n = value;
|
|
580
|
+
for (let i = 7; i >= 0; i--) {
|
|
581
|
+
out[i] = Number(n & 0xffn);
|
|
582
|
+
n >>= 8n;
|
|
583
|
+
}
|
|
584
|
+
return out;
|
|
585
|
+
}
|
|
586
|
+
function compareBytes(a, b) {
|
|
587
|
+
const len = Math.min(a.length, b.length);
|
|
588
|
+
for (let i = 0; i < len; i++) {
|
|
589
|
+
if (a[i] !== b[i]) return a[i] - b[i];
|
|
590
|
+
}
|
|
591
|
+
return a.length - b.length;
|
|
592
|
+
}
|
|
470
593
|
function bitCount(value) {
|
|
471
594
|
let n = value >>> 0;
|
|
472
595
|
let count = 0;
|
|
@@ -2742,6 +2865,121 @@ var RpcClient = class _RpcClient {
|
|
|
2742
2865
|
async lythClusters(page = 0, limit = 25) {
|
|
2743
2866
|
return normalizeClusterDirectoryPage(await this.call("lyth_clusters", [page, limit]));
|
|
2744
2867
|
}
|
|
2868
|
+
// --- PF-4 / PF-6 / MB-6 / MB-4 / MB-2 + operator-router read wrappers ----
|
|
2869
|
+
//
|
|
2870
|
+
// Reconciled against the FINAL mono-core RPC surface (master 2eff9fed):
|
|
2871
|
+
// every method name + response shape below matches the chain's `lyth_*`
|
|
2872
|
+
// dispatch + impls exactly (camelCase keys, 0x-hex uint256 amounts,
|
|
2873
|
+
// bech32m addresses). The three indexer-backed methods —
|
|
2874
|
+
// `lyth_oracleSigners`, `lyth_listProofRequests`, `lyth_proverMarketStatus`
|
|
2875
|
+
// — return a graceful `{ status: "indexer_unavailable", … }` envelope
|
|
2876
|
+
// when the node runs without its indexer projection.
|
|
2877
|
+
/** PF-4 — `lyth_getSpendingPolicy`: the §18.8 spending-policy view for a sub-account. */
|
|
2878
|
+
async lythGetSpendingPolicy(subAccount) {
|
|
2879
|
+
return this.call("lyth_getSpendingPolicy", [sdkTypedAddress(subAccount, "user", "subAccount")]);
|
|
2880
|
+
}
|
|
2881
|
+
/** PF-6 — `lyth_getClusterDiversity`: diversity score + asn/geo/hosting breakdown. */
|
|
2882
|
+
async lythGetClusterDiversity(clusterId) {
|
|
2883
|
+
return this.call("lyth_getClusterDiversity", [clusterId]);
|
|
2884
|
+
}
|
|
2885
|
+
/**
|
|
2886
|
+
* PF-6 — `lyth_getOperatorNetworkMetadata`: ASN/geo/hosting-class/IP/PCR
|
|
2887
|
+
* for a peer. `operatorId` is the 32-byte operator/peer id as `0x…` hex
|
|
2888
|
+
* (the form `lyth_operatorInfo` returns).
|
|
2889
|
+
*/
|
|
2890
|
+
async lythGetOperatorNetworkMetadata(operatorId) {
|
|
2891
|
+
return this.call("lyth_getOperatorNetworkMetadata", [operatorId]);
|
|
2892
|
+
}
|
|
2893
|
+
/**
|
|
2894
|
+
* MB-6 — `lyth_oracleSigners`: the global oracle writer roster (folded
|
|
2895
|
+
* from `OracleWriterAdded` / `OracleWriterRemoved`). Returns the
|
|
2896
|
+
* `{ status: "indexer_unavailable", writers: [] }` fallback when the
|
|
2897
|
+
* node runs without the oracle writer-roster indexer projection.
|
|
2898
|
+
*/
|
|
2899
|
+
async lythOracleSigners() {
|
|
2900
|
+
return this.call("lyth_oracleSigners", []);
|
|
2901
|
+
}
|
|
2902
|
+
/** MB-6 — `lyth_oracleWriters`: the allowed writer set for a feed. */
|
|
2903
|
+
async lythOracleWriters(feedId) {
|
|
2904
|
+
return this.call("lyth_oracleWriters", [feedId]);
|
|
2905
|
+
}
|
|
2906
|
+
/** MB-6 — `lyth_oracleLatestPrice`: the latest finalized median for a feed. */
|
|
2907
|
+
async lythOracleLatestPrice(feedId) {
|
|
2908
|
+
return this.call("lyth_oracleLatestPrice", [feedId]);
|
|
2909
|
+
}
|
|
2910
|
+
/** MB-6 — `lyth_oracleFeedConfig`: a feed's decimals / min-signers / circuit-breaker config. */
|
|
2911
|
+
async lythOracleFeedConfig(feedId) {
|
|
2912
|
+
return this.call("lyth_oracleFeedConfig", [feedId]);
|
|
2913
|
+
}
|
|
2914
|
+
/** MB-4 — `lyth_getProofRequest`: a single GPU prover-market proof request. */
|
|
2915
|
+
async lythGetProofRequest(requestId) {
|
|
2916
|
+
return this.call("lyth_getProofRequest", [requestId]);
|
|
2917
|
+
}
|
|
2918
|
+
/**
|
|
2919
|
+
* MB-4 — `lyth_listProofRequests`: open/recent prover-market proof
|
|
2920
|
+
* requests. Params are `[stateFilter?, limit?]` (the chain's order),
|
|
2921
|
+
* where `stateFilter` is one of `open|assigned|settled|slashed|expired`.
|
|
2922
|
+
* Returns the `{ status: "indexer_unavailable", requests: [] }` fallback
|
|
2923
|
+
* when the node runs without the prover-market indexer projection.
|
|
2924
|
+
*/
|
|
2925
|
+
async lythListProofRequests(stateFilter, limit) {
|
|
2926
|
+
const params = [];
|
|
2927
|
+
if (stateFilter != null || limit != null) params.push(stateFilter ?? null);
|
|
2928
|
+
if (limit != null) params.push(limit);
|
|
2929
|
+
return this.call("lyth_listProofRequests", params);
|
|
2930
|
+
}
|
|
2931
|
+
/** MB-4 — `lyth_getProverBids`: the fee bids placed on one proof request. */
|
|
2932
|
+
async lythGetProverBids(requestId) {
|
|
2933
|
+
return this.call("lyth_getProverBids", [requestId]);
|
|
2934
|
+
}
|
|
2935
|
+
/**
|
|
2936
|
+
* MB-4 — `lyth_proverMarketStatus`: prover-market summary. `feeFloor` is
|
|
2937
|
+
* always present (on-chain genesis singleton); the aggregate counts are
|
|
2938
|
+
* `null` on the `{ status: "indexer_unavailable" }` fallback path.
|
|
2939
|
+
*/
|
|
2940
|
+
async lythProverMarketStatus() {
|
|
2941
|
+
return this.call("lyth_proverMarketStatus", []);
|
|
2942
|
+
}
|
|
2943
|
+
/**
|
|
2944
|
+
* Operator-router — `lyth_operatorRouterConfig`: the router's static
|
|
2945
|
+
* posture (`0x100B` address, the protocol fee ceiling, and whether the
|
|
2946
|
+
* gateable router precompile is currently milestone-activated).
|
|
2947
|
+
*/
|
|
2948
|
+
async lythOperatorRouterConfig() {
|
|
2949
|
+
return this.call("lyth_operatorRouterConfig", []);
|
|
2950
|
+
}
|
|
2951
|
+
/**
|
|
2952
|
+
* Operator-router — `lyth_operatorFeeConfig`: one operator's fee
|
|
2953
|
+
* registration (recipient, fee bps, enabled flag, registered-at block).
|
|
2954
|
+
* `operator` is a `mono` bech32m user address.
|
|
2955
|
+
*/
|
|
2956
|
+
async lythOperatorFeeConfig(operator) {
|
|
2957
|
+
return this.call("lyth_operatorFeeConfig", [sdkTypedAddress(operator, "user", "operator")]);
|
|
2958
|
+
}
|
|
2959
|
+
/**
|
|
2960
|
+
* MB-2 — `lyth_bridgeHealth`: a paged set of bridge-record health
|
|
2961
|
+
* envelopes. Each record carries the circuit-breaker posture
|
|
2962
|
+
* (`defaultDrainCapPerWindow`, `defaultDrainWindowBlocks`, `paused`,
|
|
2963
|
+
* `pausedAtBlock`, `resumeCooldownBlocks`). Params are `[cursor?, limit?]`
|
|
2964
|
+
* (the chain pages the global bridge set; there is no single-bridge form).
|
|
2965
|
+
*/
|
|
2966
|
+
async lythBridgeHealth(cursor, limit) {
|
|
2967
|
+
const params = [];
|
|
2968
|
+
if (cursor != null || limit != null) params.push(cursor ?? null);
|
|
2969
|
+
if (limit != null) params.push(limit);
|
|
2970
|
+
return this.call("lyth_bridgeHealth", params);
|
|
2971
|
+
}
|
|
2972
|
+
/**
|
|
2973
|
+
* MB-2 — `lyth_bridgeDrainStatus`: the live per-route circuit-breaker
|
|
2974
|
+
* drain bucket for one `(bridgeId, wrappedAsset)` route. `bridgeId` is a
|
|
2975
|
+
* 32-byte `0x…` hex id; `wrappedAsset` is a `mono` bech32m user address.
|
|
2976
|
+
*/
|
|
2977
|
+
async lythBridgeDrainStatus(bridgeId, wrappedAsset) {
|
|
2978
|
+
return this.call("lyth_bridgeDrainStatus", [
|
|
2979
|
+
bridgeId,
|
|
2980
|
+
sdkTypedAddress(wrappedAsset, "user", "wrappedAsset")
|
|
2981
|
+
]);
|
|
2982
|
+
}
|
|
2745
2983
|
/**
|
|
2746
2984
|
* `lyth_submitPendingChange` — operator-onboarding transport for the
|
|
2747
2985
|
* pending-change ledger. Server validates the envelope shape.
|
|
@@ -4158,6 +4396,13 @@ function isBridgeCooldownZeroRevert(data) {
|
|
|
4158
4396
|
function isBridgeFinalityZeroRevert(data) {
|
|
4159
4397
|
return bytesToHex4(toBytes2(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
|
|
4160
4398
|
}
|
|
4399
|
+
function bridgeDrainRemaining(capPerWindow, drained) {
|
|
4400
|
+
const cap = BigInt(capPerWindow);
|
|
4401
|
+
if (cap === 0n) return null;
|
|
4402
|
+
const used = BigInt(drained);
|
|
4403
|
+
const left = cap > used ? cap - used : 0n;
|
|
4404
|
+
return left.toString(10);
|
|
4405
|
+
}
|
|
4161
4406
|
function assessBridgeRoute(route) {
|
|
4162
4407
|
const blockedReasons = [];
|
|
4163
4408
|
const warnings = [];
|
|
@@ -6385,6 +6630,410 @@ function assertWholeNumber(field2, value) {
|
|
|
6385
6630
|
}
|
|
6386
6631
|
}
|
|
6387
6632
|
|
|
6633
|
+
// src/tx-fee.ts
|
|
6634
|
+
var REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT = 250000n;
|
|
6635
|
+
var TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT = 100000n;
|
|
6636
|
+
var MIN_EXECUTION_UNIT_PRICE_LYTHOSHI = 2000n;
|
|
6637
|
+
var EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER = 3n;
|
|
6638
|
+
function asBigint(value, label) {
|
|
6639
|
+
try {
|
|
6640
|
+
return typeof value === "bigint" ? value : BigInt(value);
|
|
6641
|
+
} catch {
|
|
6642
|
+
throw new Error(`${label} is not an integer: ${String(value)}`);
|
|
6643
|
+
}
|
|
6644
|
+
}
|
|
6645
|
+
function clampPriorityTip(priorityTipLythoshi, maxExecutionUnitPriceLythoshi) {
|
|
6646
|
+
const tip = asBigint(priorityTipLythoshi, "priorityTipLythoshi");
|
|
6647
|
+
const cap = asBigint(maxExecutionUnitPriceLythoshi, "maxExecutionUnitPriceLythoshi");
|
|
6648
|
+
if (tip < 0n) throw new Error("priorityTipLythoshi must be non-negative");
|
|
6649
|
+
return tip > cap ? cap : tip;
|
|
6650
|
+
}
|
|
6651
|
+
async function resolveMaxExecutionUnitPrice(client, options = {}) {
|
|
6652
|
+
const floor = options.minPriceLythoshi ?? MIN_EXECUTION_UNIT_PRICE_LYTHOSHI;
|
|
6653
|
+
const multiplier = options.safetyMultiplier ?? EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER;
|
|
6654
|
+
const quote = await client.lythExecutionUnitPrice();
|
|
6655
|
+
let unitPrice;
|
|
6656
|
+
try {
|
|
6657
|
+
unitPrice = BigInt(quote.executionUnitPriceLythoshi);
|
|
6658
|
+
} catch {
|
|
6659
|
+
throw SdkError.malformed(
|
|
6660
|
+
`lyth_executionUnitPrice returned a non-integer executionUnitPriceLythoshi: ${quote.executionUnitPriceLythoshi}`
|
|
6661
|
+
);
|
|
6662
|
+
}
|
|
6663
|
+
const base = unitPrice > floor ? unitPrice : floor;
|
|
6664
|
+
return base * multiplier;
|
|
6665
|
+
}
|
|
6666
|
+
async function resolveExecutionFee(client, options = {}) {
|
|
6667
|
+
const maxFeePerGas = await resolveMaxExecutionUnitPrice(client, {
|
|
6668
|
+
minPriceLythoshi: options.minPriceLythoshi,
|
|
6669
|
+
safetyMultiplier: options.safetyMultiplier
|
|
6670
|
+
});
|
|
6671
|
+
const tip = options.priorityTipLythoshi === void 0 ? maxFeePerGas : clampPriorityTip(options.priorityTipLythoshi, maxFeePerGas);
|
|
6672
|
+
return {
|
|
6673
|
+
maxFeePerGas,
|
|
6674
|
+
maxPriorityFeePerGas: tip,
|
|
6675
|
+
gasLimit: options.executionUnitLimit ?? TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6676
|
+
};
|
|
6677
|
+
}
|
|
6678
|
+
async function resolveRegistryExecutionFee(client, options = {}) {
|
|
6679
|
+
return resolveExecutionFee(client, {
|
|
6680
|
+
...options,
|
|
6681
|
+
executionUnitLimit: options.executionUnitLimit ?? REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT
|
|
6682
|
+
});
|
|
6683
|
+
}
|
|
6684
|
+
var ORACLE_EVENT_SIGS = {
|
|
6685
|
+
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
6686
|
+
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
6687
|
+
feedAdded: "FeedAdded(bytes32,uint8,uint16,uint32,uint32)",
|
|
6688
|
+
feedUpdated: "FeedUpdated(bytes32,uint8,uint16,uint32,uint32)",
|
|
6689
|
+
oracleFraudSlashed: "OracleFraudSlashed(bytes32,uint64,address,bytes32)",
|
|
6690
|
+
oracleAdminUpdated: "OracleAdminUpdated(address)",
|
|
6691
|
+
oracleWriterAdded: "OracleWriterAdded(address,address)",
|
|
6692
|
+
oracleWriterRemoved: "OracleWriterRemoved(address,address)"
|
|
6693
|
+
};
|
|
6694
|
+
var OracleEventError = class extends Error {
|
|
6695
|
+
constructor(message) {
|
|
6696
|
+
super(message);
|
|
6697
|
+
this.name = "OracleEventError";
|
|
6698
|
+
}
|
|
6699
|
+
};
|
|
6700
|
+
function oracleAddressHex() {
|
|
6701
|
+
return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
|
|
6702
|
+
}
|
|
6703
|
+
function decodeOracleEvent(topics, data) {
|
|
6704
|
+
if (topics.length === 0) {
|
|
6705
|
+
throw new OracleEventError("event record has no topics");
|
|
6706
|
+
}
|
|
6707
|
+
const topic0 = bytesToHex6(expectLength4(toBytes3(topics[0]), 32, "topic0"));
|
|
6708
|
+
const body = toBytes3(data);
|
|
6709
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
|
|
6710
|
+
checkArity("OracleRoundFinalized", 3, topics.length);
|
|
6711
|
+
checkData("OracleRoundFinalized", 3 * 32, body.length);
|
|
6712
|
+
return {
|
|
6713
|
+
kind: "roundFinalized",
|
|
6714
|
+
feedId: hex32(topics[1]),
|
|
6715
|
+
roundId: u64FromTopic(topics[2]),
|
|
6716
|
+
computedMedian: u256Decimal(body.subarray(0, 32)),
|
|
6717
|
+
finalizedAtBlock: u64FromWord2(body.subarray(32, 64)),
|
|
6718
|
+
observationsLen: u32FromWord2(body.subarray(64, 96))
|
|
6719
|
+
};
|
|
6720
|
+
}
|
|
6721
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.observationSubmitted)) {
|
|
6722
|
+
checkArity("ObservationSubmitted", 4, topics.length);
|
|
6723
|
+
checkData("ObservationSubmitted", 2 * 32, body.length);
|
|
6724
|
+
return {
|
|
6725
|
+
kind: "observationSubmitted",
|
|
6726
|
+
feedId: hex32(topics[1]),
|
|
6727
|
+
roundId: u64FromTopic(topics[2]),
|
|
6728
|
+
writer: addressFromTopic(topics[3]),
|
|
6729
|
+
value: u256Decimal(body.subarray(0, 32)),
|
|
6730
|
+
observedAt: u64FromWord2(body.subarray(32, 64))
|
|
6731
|
+
};
|
|
6732
|
+
}
|
|
6733
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleFraudSlashed)) {
|
|
6734
|
+
checkArity("OracleFraudSlashed", 4, topics.length);
|
|
6735
|
+
checkData("OracleFraudSlashed", 32, body.length);
|
|
6736
|
+
return {
|
|
6737
|
+
kind: "fraudSlashed",
|
|
6738
|
+
feedId: hex32(topics[1]),
|
|
6739
|
+
roundId: u64FromTopic(topics[2]),
|
|
6740
|
+
writer: addressFromTopic(topics[3]),
|
|
6741
|
+
evidenceHash: bytesToHex6(body.subarray(0, 32))
|
|
6742
|
+
};
|
|
6743
|
+
}
|
|
6744
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
|
|
6745
|
+
checkArity("FeedAdded", 2, topics.length);
|
|
6746
|
+
checkData("FeedAdded", 4 * 32, body.length);
|
|
6747
|
+
return { kind: "feedAdded", ...decodeFeedFields(topics[1], body) };
|
|
6748
|
+
}
|
|
6749
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedUpdated)) {
|
|
6750
|
+
checkArity("FeedUpdated", 2, topics.length);
|
|
6751
|
+
checkData("FeedUpdated", 4 * 32, body.length);
|
|
6752
|
+
return { kind: "feedUpdated", ...decodeFeedFields(topics[1], body) };
|
|
6753
|
+
}
|
|
6754
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleAdminUpdated)) {
|
|
6755
|
+
checkArity("OracleAdminUpdated", 2, topics.length);
|
|
6756
|
+
checkData("OracleAdminUpdated", 0, body.length);
|
|
6757
|
+
return { kind: "adminUpdated", admin: addressFromTopic(topics[1]) };
|
|
6758
|
+
}
|
|
6759
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleWriterAdded)) {
|
|
6760
|
+
checkArity("OracleWriterAdded", 3, topics.length);
|
|
6761
|
+
checkData("OracleWriterAdded", 0, body.length);
|
|
6762
|
+
return {
|
|
6763
|
+
kind: "writerAdded",
|
|
6764
|
+
admin: addressFromTopic(topics[1]),
|
|
6765
|
+
writer: addressFromTopic(topics[2])
|
|
6766
|
+
};
|
|
6767
|
+
}
|
|
6768
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleWriterRemoved)) {
|
|
6769
|
+
checkArity("OracleWriterRemoved", 3, topics.length);
|
|
6770
|
+
checkData("OracleWriterRemoved", 0, body.length);
|
|
6771
|
+
return {
|
|
6772
|
+
kind: "writerRemoved",
|
|
6773
|
+
admin: addressFromTopic(topics[1]),
|
|
6774
|
+
writer: addressFromTopic(topics[2])
|
|
6775
|
+
};
|
|
6776
|
+
}
|
|
6777
|
+
throw new OracleEventError("unknown oracle event topic0");
|
|
6778
|
+
}
|
|
6779
|
+
function decodeFeedFields(feedTopic, body) {
|
|
6780
|
+
return {
|
|
6781
|
+
feedId: hex32(feedTopic),
|
|
6782
|
+
decimals: body[31],
|
|
6783
|
+
minSigners: body[62] << 8 | body[63],
|
|
6784
|
+
circuitBreakerBps: u32FromWord2(body.subarray(64, 96)),
|
|
6785
|
+
allowedWritersLen: u32FromWord2(body.subarray(96, 128))
|
|
6786
|
+
};
|
|
6787
|
+
}
|
|
6788
|
+
function topicHex(sig) {
|
|
6789
|
+
return bytesToHex6(keccak_256(new TextEncoder().encode(sig)));
|
|
6790
|
+
}
|
|
6791
|
+
function checkArity(event, expected, found) {
|
|
6792
|
+
if (found !== expected) {
|
|
6793
|
+
throw new OracleEventError(`${event} expected ${expected} topics, found ${found}`);
|
|
6794
|
+
}
|
|
6795
|
+
}
|
|
6796
|
+
function checkData(event, expected, found) {
|
|
6797
|
+
if (found !== expected) {
|
|
6798
|
+
throw new OracleEventError(`${event} expected ${expected} data bytes, found ${found}`);
|
|
6799
|
+
}
|
|
6800
|
+
}
|
|
6801
|
+
function hex32(topic) {
|
|
6802
|
+
return bytesToHex6(expectLength4(toBytes3(topic), 32, "feedId topic"));
|
|
6803
|
+
}
|
|
6804
|
+
function addressFromTopic(topic) {
|
|
6805
|
+
return bytesToHex6(expectLength4(toBytes3(topic), 32, "address topic").subarray(12, 32));
|
|
6806
|
+
}
|
|
6807
|
+
function u64FromTopic(topic) {
|
|
6808
|
+
return u64FromWord2(expectLength4(toBytes3(topic), 32, "u64 topic"));
|
|
6809
|
+
}
|
|
6810
|
+
function u64FromWord2(word) {
|
|
6811
|
+
let v = 0n;
|
|
6812
|
+
for (let i = 24; i < 32; i++) v = v << 8n | BigInt(word[i]);
|
|
6813
|
+
return v;
|
|
6814
|
+
}
|
|
6815
|
+
function u32FromWord2(word) {
|
|
6816
|
+
return (word[28] << 24 | word[29] << 16 | word[30] << 8 | word[31]) >>> 0;
|
|
6817
|
+
}
|
|
6818
|
+
function u256Decimal(word) {
|
|
6819
|
+
let v = 0n;
|
|
6820
|
+
for (const b of word) v = v << 8n | BigInt(b);
|
|
6821
|
+
return v.toString(10);
|
|
6822
|
+
}
|
|
6823
|
+
function toBytes3(value) {
|
|
6824
|
+
if (typeof value === "string") return hexToBytes5(value);
|
|
6825
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6826
|
+
}
|
|
6827
|
+
function hexToBytes5(hex) {
|
|
6828
|
+
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6829
|
+
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6830
|
+
throw new OracleEventError("invalid hex bytes");
|
|
6831
|
+
}
|
|
6832
|
+
const out = new Uint8Array(b.length / 2);
|
|
6833
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6834
|
+
return out;
|
|
6835
|
+
}
|
|
6836
|
+
function bytesToHex6(bytes) {
|
|
6837
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6838
|
+
}
|
|
6839
|
+
function expectLength4(value, len, name) {
|
|
6840
|
+
if (value.length !== len) {
|
|
6841
|
+
throw new OracleEventError(`${name} must be ${len} bytes, got ${value.length}`);
|
|
6842
|
+
}
|
|
6843
|
+
return value;
|
|
6844
|
+
}
|
|
6845
|
+
var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
|
|
6846
|
+
var SERVES_GPU_PROVE = 512;
|
|
6847
|
+
var PROVER_MARKET_SELECTORS = {
|
|
6848
|
+
createRequest: "0x" + selectorHex2("createRequest(bytes)"),
|
|
6849
|
+
submitBid: "0x" + selectorHex2("submitBid(bytes)"),
|
|
6850
|
+
closeRequest: "0x" + selectorHex2("closeRequest(bytes)"),
|
|
6851
|
+
submitProof: "0x" + selectorHex2("submitProof(bytes)"),
|
|
6852
|
+
settle: "0x" + selectorHex2("settle(bytes)"),
|
|
6853
|
+
slash: "0x" + selectorHex2("slash(bytes)")
|
|
6854
|
+
};
|
|
6855
|
+
var PROVER_MARKET_EVENT_SIGS = {
|
|
6856
|
+
proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
|
|
6857
|
+
bidSubmitted: "BidSubmitted(bytes32,address,uint128)",
|
|
6858
|
+
requestAssigned: "RequestAssigned(bytes32,address,uint128)",
|
|
6859
|
+
proofSettled: "ProofSettled(bytes32,address,uint128,uint128)",
|
|
6860
|
+
proverSlashed: "ProverSlashed(bytes32,address,uint16,bytes32)",
|
|
6861
|
+
requestExpired: "RequestExpired(bytes32,address,uint128)"
|
|
6862
|
+
};
|
|
6863
|
+
var PROVER_SLASH_REASON_NON_DELIVERY = 1024;
|
|
6864
|
+
var PROVER_SLASH_REASON_BAD_PROOF = 1025;
|
|
6865
|
+
var PROVER_MARKET_REQUEST_DOMAIN = "prover_market.request.v1";
|
|
6866
|
+
var PROVER_MARKET_BID_DOMAIN = "prover_market.bid.v1";
|
|
6867
|
+
var PROVER_MARKET_SUBMIT_DOMAIN = "prover_market.submit.v1";
|
|
6868
|
+
function proverMarketStateFromByte(b) {
|
|
6869
|
+
switch (b) {
|
|
6870
|
+
case 0:
|
|
6871
|
+
return "open";
|
|
6872
|
+
case 1:
|
|
6873
|
+
return "assigned";
|
|
6874
|
+
case 2:
|
|
6875
|
+
return "settled";
|
|
6876
|
+
case 3:
|
|
6877
|
+
return "slashed";
|
|
6878
|
+
case 4:
|
|
6879
|
+
return "expired";
|
|
6880
|
+
default:
|
|
6881
|
+
return null;
|
|
6882
|
+
}
|
|
6883
|
+
}
|
|
6884
|
+
var ProverMarketError = class extends Error {
|
|
6885
|
+
constructor(message) {
|
|
6886
|
+
super(message);
|
|
6887
|
+
this.name = "ProverMarketError";
|
|
6888
|
+
}
|
|
6889
|
+
};
|
|
6890
|
+
function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
6891
|
+
return bytesToHex7(
|
|
6892
|
+
keccak_256(
|
|
6893
|
+
concatBytes5(
|
|
6894
|
+
new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
|
|
6895
|
+
expectLength5(toBytes4(vkeyHash), 32, "vkeyHash"),
|
|
6896
|
+
expectLength5(toBytes4(inputsHash), 32, "inputsHash"),
|
|
6897
|
+
u128Bytes(maxFee, "maxFee"),
|
|
6898
|
+
u64Bytes(deadline, "deadline"),
|
|
6899
|
+
u64Bytes(nonce, "nonce")
|
|
6900
|
+
)
|
|
6901
|
+
)
|
|
6902
|
+
);
|
|
6903
|
+
}
|
|
6904
|
+
function bidSighash(requestId, fee) {
|
|
6905
|
+
return bytesToHex7(
|
|
6906
|
+
keccak_256(
|
|
6907
|
+
concatBytes5(
|
|
6908
|
+
new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
|
|
6909
|
+
expectLength5(toBytes4(requestId), 32, "requestId"),
|
|
6910
|
+
u128Bytes(fee, "fee")
|
|
6911
|
+
)
|
|
6912
|
+
)
|
|
6913
|
+
);
|
|
6914
|
+
}
|
|
6915
|
+
function submitSighash(requestId, proofHash) {
|
|
6916
|
+
return bytesToHex7(
|
|
6917
|
+
keccak_256(
|
|
6918
|
+
concatBytes5(
|
|
6919
|
+
new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
|
|
6920
|
+
expectLength5(toBytes4(requestId), 32, "requestId"),
|
|
6921
|
+
expectLength5(toBytes4(proofHash), 32, "proofHash")
|
|
6922
|
+
)
|
|
6923
|
+
)
|
|
6924
|
+
);
|
|
6925
|
+
}
|
|
6926
|
+
function encodeCreateRequestCanonical(args) {
|
|
6927
|
+
const buyer = expectLength5(toBytes4(args.buyer), 20, "buyer");
|
|
6928
|
+
const buyerPubkey = toBytes4(args.buyerPubkey);
|
|
6929
|
+
const sig = toBytes4(args.sig);
|
|
6930
|
+
if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
|
|
6931
|
+
throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
|
|
6932
|
+
}
|
|
6933
|
+
if (sig.length === 0 || sig.length > 65535) {
|
|
6934
|
+
throw new ProverMarketError("sig length out of range (1..=65535)");
|
|
6935
|
+
}
|
|
6936
|
+
return bytesToHex7(
|
|
6937
|
+
concatBytes5(
|
|
6938
|
+
buyer,
|
|
6939
|
+
u16Bytes(buyerPubkey.length),
|
|
6940
|
+
buyerPubkey,
|
|
6941
|
+
expectLength5(toBytes4(args.vkeyHash), 32, "vkeyHash"),
|
|
6942
|
+
expectLength5(toBytes4(args.inputsHash), 32, "inputsHash"),
|
|
6943
|
+
u128Bytes(args.maxFee, "maxFee"),
|
|
6944
|
+
u64Bytes(args.deadline, "deadline"),
|
|
6945
|
+
u64Bytes(args.nonce, "nonce"),
|
|
6946
|
+
u16Bytes(sig.length),
|
|
6947
|
+
sig
|
|
6948
|
+
)
|
|
6949
|
+
);
|
|
6950
|
+
}
|
|
6951
|
+
function encodeCreateRequestCalldata(args) {
|
|
6952
|
+
const canonical = toBytes4(encodeCreateRequestCanonical(args));
|
|
6953
|
+
const offset = new Uint8Array(32);
|
|
6954
|
+
offset[31] = 32;
|
|
6955
|
+
const lenWord = new Uint8Array(32);
|
|
6956
|
+
const len = canonical.length;
|
|
6957
|
+
lenWord[28] = len >>> 24 & 255;
|
|
6958
|
+
lenWord[29] = len >>> 16 & 255;
|
|
6959
|
+
lenWord[30] = len >>> 8 & 255;
|
|
6960
|
+
lenWord[31] = len & 255;
|
|
6961
|
+
const pad = (32 - len % 32) % 32;
|
|
6962
|
+
return bytesToHex7(
|
|
6963
|
+
concatBytes5(hexToBytes6(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
|
|
6964
|
+
);
|
|
6965
|
+
}
|
|
6966
|
+
function selectorHex2(sig) {
|
|
6967
|
+
return [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6968
|
+
}
|
|
6969
|
+
function toBytes4(value) {
|
|
6970
|
+
if (typeof value === "string") return hexToBytes6(value);
|
|
6971
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6972
|
+
}
|
|
6973
|
+
function hexToBytes6(hex) {
|
|
6974
|
+
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6975
|
+
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6976
|
+
throw new ProverMarketError("invalid hex bytes");
|
|
6977
|
+
}
|
|
6978
|
+
const out = new Uint8Array(b.length / 2);
|
|
6979
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6980
|
+
return out;
|
|
6981
|
+
}
|
|
6982
|
+
function bytesToHex7(bytes) {
|
|
6983
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6984
|
+
}
|
|
6985
|
+
function concatBytes5(...parts) {
|
|
6986
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6987
|
+
let offset = 0;
|
|
6988
|
+
for (const part of parts) {
|
|
6989
|
+
out.set(part, offset);
|
|
6990
|
+
offset += part.length;
|
|
6991
|
+
}
|
|
6992
|
+
return out;
|
|
6993
|
+
}
|
|
6994
|
+
function expectLength5(value, len, name) {
|
|
6995
|
+
if (value.length !== len) {
|
|
6996
|
+
throw new ProverMarketError(`${name} must be ${len} bytes, got ${value.length}`);
|
|
6997
|
+
}
|
|
6998
|
+
return value;
|
|
6999
|
+
}
|
|
7000
|
+
function toBigint2(value, name) {
|
|
7001
|
+
let n;
|
|
7002
|
+
if (typeof value === "bigint") n = value;
|
|
7003
|
+
else if (typeof value === "number") {
|
|
7004
|
+
if (!Number.isSafeInteger(value)) throw new ProverMarketError(`${name} must be a safe integer`);
|
|
7005
|
+
n = BigInt(value);
|
|
7006
|
+
} else if (/^(0|[1-9][0-9]*|0x[0-9a-fA-F]+)$/.test(value)) n = BigInt(value);
|
|
7007
|
+
else throw new ProverMarketError(`${name} must be a non-negative integer`);
|
|
7008
|
+
if (n < 0n) throw new ProverMarketError(`${name} must be non-negative`);
|
|
7009
|
+
return n;
|
|
7010
|
+
}
|
|
7011
|
+
function u16Bytes(value) {
|
|
7012
|
+
if (!Number.isInteger(value) || value < 0 || value > 65535) {
|
|
7013
|
+
throw new ProverMarketError("u16 value out of range");
|
|
7014
|
+
}
|
|
7015
|
+
return Uint8Array.from([value >> 8 & 255, value & 255]);
|
|
7016
|
+
}
|
|
7017
|
+
function u64Bytes(value, name) {
|
|
7018
|
+
const n = toBigint2(value, name);
|
|
7019
|
+
if (n > 0xffffffffffffffffn) throw new ProverMarketError(`${name} exceeds uint64`);
|
|
7020
|
+
return bigintBytes(n, 8);
|
|
7021
|
+
}
|
|
7022
|
+
function u128Bytes(value, name) {
|
|
7023
|
+
const n = toBigint2(value, name);
|
|
7024
|
+
if (n > (1n << 128n) - 1n) throw new ProverMarketError(`${name} exceeds uint128`);
|
|
7025
|
+
return bigintBytes(n, 16);
|
|
7026
|
+
}
|
|
7027
|
+
function bigintBytes(value, len) {
|
|
7028
|
+
const out = new Uint8Array(len);
|
|
7029
|
+
let n = value;
|
|
7030
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
7031
|
+
out[i] = Number(n & 0xffn);
|
|
7032
|
+
n >>= 8n;
|
|
7033
|
+
}
|
|
7034
|
+
return out;
|
|
7035
|
+
}
|
|
7036
|
+
|
|
6388
7037
|
// src/delegation.ts
|
|
6389
7038
|
var DELEGATION_SELECTORS = {
|
|
6390
7039
|
delegate: "0x662337de",
|
|
@@ -6410,34 +7059,34 @@ function delegationAddressHex() {
|
|
|
6410
7059
|
return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
|
|
6411
7060
|
}
|
|
6412
7061
|
function encodeCompleteRedemptionCalldata(index) {
|
|
6413
|
-
return
|
|
6414
|
-
|
|
6415
|
-
|
|
7062
|
+
return bytesToHex8(
|
|
7063
|
+
concatBytes6(
|
|
7064
|
+
hexToBytes7(DELEGATION_SELECTORS.completeRedemption),
|
|
6416
7065
|
uint64Word2(index, "index")
|
|
6417
7066
|
)
|
|
6418
7067
|
);
|
|
6419
7068
|
}
|
|
6420
7069
|
function encodeDelegateCalldata(cluster, weightBps) {
|
|
6421
|
-
return
|
|
6422
|
-
|
|
6423
|
-
|
|
7070
|
+
return bytesToHex8(
|
|
7071
|
+
concatBytes6(
|
|
7072
|
+
hexToBytes7(DELEGATION_SELECTORS.delegate),
|
|
6424
7073
|
uint32Word2(cluster, "cluster"),
|
|
6425
7074
|
uint16Word(weightBps, "weightBps")
|
|
6426
7075
|
)
|
|
6427
7076
|
);
|
|
6428
7077
|
}
|
|
6429
7078
|
function encodeUndelegateCalldata(cluster) {
|
|
6430
|
-
return
|
|
6431
|
-
|
|
6432
|
-
|
|
7079
|
+
return bytesToHex8(
|
|
7080
|
+
concatBytes6(
|
|
7081
|
+
hexToBytes7(DELEGATION_SELECTORS.undelegate),
|
|
6433
7082
|
uint32Word2(cluster, "cluster")
|
|
6434
7083
|
)
|
|
6435
7084
|
);
|
|
6436
7085
|
}
|
|
6437
7086
|
function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
|
|
6438
|
-
return
|
|
6439
|
-
|
|
6440
|
-
|
|
7087
|
+
return bytesToHex8(
|
|
7088
|
+
concatBytes6(
|
|
7089
|
+
hexToBytes7(DELEGATION_SELECTORS.redelegate),
|
|
6441
7090
|
uint32Word2(fromCluster, "fromCluster"),
|
|
6442
7091
|
uint32Word2(toCluster, "toCluster"),
|
|
6443
7092
|
uint16Word(weightBps, "weightBps")
|
|
@@ -6450,15 +7099,15 @@ function encodeClaimCalldata() {
|
|
|
6450
7099
|
function encodeSetAutoCompoundCalldata(enabled) {
|
|
6451
7100
|
const flag = new Uint8Array(32);
|
|
6452
7101
|
flag[31] = enabled ? 1 : 0;
|
|
6453
|
-
return
|
|
6454
|
-
|
|
7102
|
+
return bytesToHex8(
|
|
7103
|
+
concatBytes6(hexToBytes7(DELEGATION_SELECTORS.setAutoCompound), flag)
|
|
6455
7104
|
);
|
|
6456
7105
|
}
|
|
6457
7106
|
function isRedemptionPrincipalUnavailableRevert(data) {
|
|
6458
|
-
return
|
|
7107
|
+
return bytesToHex8(toBytes5(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
|
|
6459
7108
|
}
|
|
6460
7109
|
function uint64Word2(value, name) {
|
|
6461
|
-
const n =
|
|
7110
|
+
const n = toBigint3(value, name);
|
|
6462
7111
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
6463
7112
|
throw new DelegationPrecompileError(`${name} must fit uint64`);
|
|
6464
7113
|
}
|
|
@@ -6471,7 +7120,7 @@ function uint64Word2(value, name) {
|
|
|
6471
7120
|
return out;
|
|
6472
7121
|
}
|
|
6473
7122
|
function uint32Word2(value, name) {
|
|
6474
|
-
const n =
|
|
7123
|
+
const n = toBigint3(value, name);
|
|
6475
7124
|
if (n < 0n || n > 0xffffffffn) {
|
|
6476
7125
|
throw new DelegationPrecompileError(`${name} must fit uint32`);
|
|
6477
7126
|
}
|
|
@@ -6484,7 +7133,7 @@ function uint32Word2(value, name) {
|
|
|
6484
7133
|
return out;
|
|
6485
7134
|
}
|
|
6486
7135
|
function uint16Word(value, name) {
|
|
6487
|
-
const n =
|
|
7136
|
+
const n = toBigint3(value, name);
|
|
6488
7137
|
if (n < 0n || n > 0xffffn) {
|
|
6489
7138
|
throw new DelegationPrecompileError(`${name} must fit uint16`);
|
|
6490
7139
|
}
|
|
@@ -6496,7 +7145,7 @@ function uint16Word(value, name) {
|
|
|
6496
7145
|
}
|
|
6497
7146
|
return out;
|
|
6498
7147
|
}
|
|
6499
|
-
function
|
|
7148
|
+
function toBigint3(value, name) {
|
|
6500
7149
|
if (typeof value === "bigint") return value;
|
|
6501
7150
|
if (typeof value === "number") {
|
|
6502
7151
|
if (!Number.isInteger(value) || !Number.isSafeInteger(value)) {
|
|
@@ -6509,13 +7158,13 @@ function toBigint2(value, name) {
|
|
|
6509
7158
|
}
|
|
6510
7159
|
return BigInt(value);
|
|
6511
7160
|
}
|
|
6512
|
-
function
|
|
7161
|
+
function toBytes5(value) {
|
|
6513
7162
|
if (typeof value === "string") {
|
|
6514
|
-
return
|
|
7163
|
+
return hexToBytes7(value);
|
|
6515
7164
|
}
|
|
6516
7165
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6517
7166
|
}
|
|
6518
|
-
function
|
|
7167
|
+
function hexToBytes7(hex) {
|
|
6519
7168
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6520
7169
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6521
7170
|
throw new DelegationPrecompileError("invalid hex bytes");
|
|
@@ -6526,10 +7175,10 @@ function hexToBytes5(hex) {
|
|
|
6526
7175
|
}
|
|
6527
7176
|
return out;
|
|
6528
7177
|
}
|
|
6529
|
-
function
|
|
7178
|
+
function bytesToHex8(bytes) {
|
|
6530
7179
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6531
7180
|
}
|
|
6532
|
-
function
|
|
7181
|
+
function concatBytes6(...parts) {
|
|
6533
7182
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6534
7183
|
let offset = 0;
|
|
6535
7184
|
for (const part of parts) {
|
|
@@ -6544,9 +7193,11 @@ var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
|
|
|
6544
7193
|
var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
|
|
6545
7194
|
var ML_DSA_65_SIGNATURE_LEN2 = 3309;
|
|
6546
7195
|
var SPENDING_POLICY_SELECTORS = {
|
|
6547
|
-
setPolicy
|
|
6548
|
-
|
|
6549
|
-
|
|
7196
|
+
// WP §18.8 widened the setPolicy* sighash strings to 11 words, so their
|
|
7197
|
+
// selectors changed; enable/disable/recordSpend are unchanged.
|
|
7198
|
+
setPolicy: "0x8da1a765",
|
|
7199
|
+
setPolicyClaim: "0x35531f6c",
|
|
7200
|
+
claimPolicyByAddress: "0x0c21376c",
|
|
6550
7201
|
enable: "0x5bfa1b68",
|
|
6551
7202
|
disable: "0xe6c09edf",
|
|
6552
7203
|
recordSpend: "0xdca04292"
|
|
@@ -6563,7 +7214,7 @@ function spendingPolicyAddressHex() {
|
|
|
6563
7214
|
function composeClaimBoundMessage(chainId, args, opts) {
|
|
6564
7215
|
const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
|
|
6565
7216
|
const normalized = normalizeArgs(args);
|
|
6566
|
-
return
|
|
7217
|
+
return concatBytes7(
|
|
6567
7218
|
new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
|
|
6568
7219
|
uint64Bytes(chainId, "chainId"),
|
|
6569
7220
|
precompileAddress,
|
|
@@ -6573,22 +7224,30 @@ function composeClaimBoundMessage(chainId, args, opts) {
|
|
|
6573
7224
|
uint128Bytes(normalized.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
6574
7225
|
normalized.allowRoot,
|
|
6575
7226
|
normalized.denyRoot,
|
|
7227
|
+
// WP §18.8 dimensions, in wire order: weekly cap (be16), monthly cap
|
|
7228
|
+
// (be16), category allow-root (32), packed time window (32),
|
|
7229
|
+
// policy expiry (be8). These slot in before the expected-version word.
|
|
7230
|
+
uint128Bytes(normalized.weeklyCapLythoshi, "weeklyCapLythoshi"),
|
|
7231
|
+
uint128Bytes(normalized.monthlyCapLythoshi, "monthlyCapLythoshi"),
|
|
7232
|
+
normalized.categoryAllowRoot,
|
|
7233
|
+
normalized.timeWindow,
|
|
7234
|
+
uint64Bytes(normalized.policyExpiry, "policyExpiry"),
|
|
6576
7235
|
uint64Bytes(opts?.expectedPolicyVersion ?? 0n, "expectedPolicyVersion")
|
|
6577
7236
|
);
|
|
6578
7237
|
}
|
|
6579
7238
|
function encodeSetPolicyCalldata(args) {
|
|
6580
7239
|
const normalized = normalizeArgs(args);
|
|
6581
|
-
return
|
|
6582
|
-
|
|
6583
|
-
|
|
7240
|
+
return bytesToHex9(
|
|
7241
|
+
concatBytes7(
|
|
7242
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicy),
|
|
6584
7243
|
encodePolicyWords(normalized)
|
|
6585
7244
|
)
|
|
6586
7245
|
);
|
|
6587
7246
|
}
|
|
6588
7247
|
function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
6589
7248
|
const normalized = normalizeArgs(args);
|
|
6590
|
-
const pubkey =
|
|
6591
|
-
const sig =
|
|
7249
|
+
const pubkey = toBytes6(subAccountPubkey);
|
|
7250
|
+
const sig = toBytes6(subAccountSig);
|
|
6592
7251
|
if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
|
|
6593
7252
|
throw new SpendingPolicyError(
|
|
6594
7253
|
`subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
|
|
@@ -6599,9 +7258,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
6599
7258
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
6600
7259
|
);
|
|
6601
7260
|
}
|
|
6602
|
-
return
|
|
6603
|
-
|
|
6604
|
-
|
|
7261
|
+
return bytesToHex9(
|
|
7262
|
+
concatBytes7(
|
|
7263
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicyClaim),
|
|
6605
7264
|
encodePolicyWords(normalized),
|
|
6606
7265
|
pubkey,
|
|
6607
7266
|
sig
|
|
@@ -6610,15 +7269,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
6610
7269
|
}
|
|
6611
7270
|
function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
|
|
6612
7271
|
const normalized = normalizeArgs(args);
|
|
6613
|
-
const sig =
|
|
7272
|
+
const sig = toBytes6(subAccountSig);
|
|
6614
7273
|
if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
|
|
6615
7274
|
throw new SpendingPolicyError(
|
|
6616
7275
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
6617
7276
|
);
|
|
6618
7277
|
}
|
|
6619
|
-
return
|
|
6620
|
-
|
|
6621
|
-
|
|
7278
|
+
return bytesToHex9(
|
|
7279
|
+
concatBytes7(
|
|
7280
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
|
|
6622
7281
|
encodePolicyWords(normalized),
|
|
6623
7282
|
sig
|
|
6624
7283
|
)
|
|
@@ -6630,34 +7289,70 @@ function encodeEnableCalldata(subAccount) {
|
|
|
6630
7289
|
function encodeDisableCalldata(subAccount) {
|
|
6631
7290
|
return encodeSingleAddressCall(SPENDING_POLICY_SELECTORS.disable, subAccount, "subAccount");
|
|
6632
7291
|
}
|
|
7292
|
+
var ZERO_WORD = new Uint8Array(32);
|
|
6633
7293
|
function normalizeArgs(args) {
|
|
6634
7294
|
return {
|
|
6635
7295
|
subAccount: toUserAddressBytes(args.subAccount, "subAccount"),
|
|
6636
7296
|
principal: toUserAddressBytes(args.principal, "principal"),
|
|
6637
|
-
dailyCapLythoshi:
|
|
6638
|
-
perTxCapLythoshi:
|
|
6639
|
-
allowRoot:
|
|
6640
|
-
denyRoot:
|
|
7297
|
+
dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
|
|
7298
|
+
perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
7299
|
+
allowRoot: expectLength6(toBytes6(args.allowRoot), 32, "allowRoot"),
|
|
7300
|
+
denyRoot: expectLength6(toBytes6(args.denyRoot), 32, "denyRoot"),
|
|
7301
|
+
weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
|
|
7302
|
+
monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
|
|
7303
|
+
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes6(args.categoryAllowRoot), 32, "categoryAllowRoot"),
|
|
7304
|
+
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes6(args.timeWindow), 32, "timeWindow"),
|
|
7305
|
+
policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
|
|
6641
7306
|
};
|
|
6642
7307
|
}
|
|
6643
7308
|
function encodePolicyWords(args) {
|
|
6644
|
-
return
|
|
7309
|
+
return concatBytes7(
|
|
6645
7310
|
encodeAddressWord(args.subAccount),
|
|
6646
7311
|
encodeAddressWord(args.principal),
|
|
6647
7312
|
encodeUint128Word(args.dailyCapLythoshi),
|
|
6648
7313
|
encodeUint128Word(args.perTxCapLythoshi),
|
|
6649
7314
|
args.allowRoot,
|
|
6650
|
-
args.denyRoot
|
|
7315
|
+
args.denyRoot,
|
|
7316
|
+
// WP §18.8 trailing 5 words: weekly cap, monthly cap, category
|
|
7317
|
+
// allow-root, packed time window, policy expiry.
|
|
7318
|
+
encodeUint128Word(args.weeklyCapLythoshi),
|
|
7319
|
+
encodeUint128Word(args.monthlyCapLythoshi),
|
|
7320
|
+
args.categoryAllowRoot,
|
|
7321
|
+
args.timeWindow,
|
|
7322
|
+
encodeUint64Word(args.policyExpiry)
|
|
6651
7323
|
);
|
|
6652
7324
|
}
|
|
7325
|
+
function packTimeWindow(enabled, startHour, endHour) {
|
|
7326
|
+
const out = new Uint8Array(32);
|
|
7327
|
+
if (!enabled) return out;
|
|
7328
|
+
out[29] = 1;
|
|
7329
|
+
out[30] = clampHour(startHour);
|
|
7330
|
+
out[31] = clampHour(endHour);
|
|
7331
|
+
return out;
|
|
7332
|
+
}
|
|
7333
|
+
function decodeTimeWindow(word) {
|
|
7334
|
+
const bytes = expectLength6(toBytes6(word), 32, "timeWindow");
|
|
7335
|
+
if (bytes.every((b) => b === 0)) return null;
|
|
7336
|
+
if (bytes[29] === 0) return null;
|
|
7337
|
+
return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
|
|
7338
|
+
}
|
|
7339
|
+
function clampHour(hour) {
|
|
7340
|
+
if (!Number.isInteger(hour) || hour < 0) {
|
|
7341
|
+
throw new SpendingPolicyError("time-window hour must be a non-negative integer");
|
|
7342
|
+
}
|
|
7343
|
+
return Math.min(hour, 23);
|
|
7344
|
+
}
|
|
7345
|
+
function encodeUint64Word(value) {
|
|
7346
|
+
return concatBytes7(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
|
|
7347
|
+
}
|
|
6653
7348
|
function encodeSingleAddressCall(selector, address, name) {
|
|
6654
|
-
return
|
|
7349
|
+
return bytesToHex9(concatBytes7(hexToBytes8(selector), encodeAddressWord(toUserAddressBytes(address, name))));
|
|
6655
7350
|
}
|
|
6656
7351
|
function encodeAddressWord(address) {
|
|
6657
|
-
return
|
|
7352
|
+
return concatBytes7(new Uint8Array(12), address);
|
|
6658
7353
|
}
|
|
6659
7354
|
function encodeUint128Word(value) {
|
|
6660
|
-
return
|
|
7355
|
+
return concatBytes7(new Uint8Array(16), uint128Bytes(value, "uint128"));
|
|
6661
7356
|
}
|
|
6662
7357
|
function toUserAddressBytes(value, name) {
|
|
6663
7358
|
if (typeof value !== "string") {
|
|
@@ -6677,15 +7372,15 @@ function toRawAddressBytes(value) {
|
|
|
6677
7372
|
if (typeof value === "string") {
|
|
6678
7373
|
return hexToAddressBytes(value);
|
|
6679
7374
|
}
|
|
6680
|
-
return
|
|
7375
|
+
return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
|
|
6681
7376
|
}
|
|
6682
|
-
function
|
|
7377
|
+
function toBytes6(value) {
|
|
6683
7378
|
if (typeof value === "string") {
|
|
6684
|
-
return
|
|
7379
|
+
return hexToBytes8(value);
|
|
6685
7380
|
}
|
|
6686
7381
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6687
7382
|
}
|
|
6688
|
-
function
|
|
7383
|
+
function hexToBytes8(hex) {
|
|
6689
7384
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6690
7385
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6691
7386
|
throw new SpendingPolicyError("invalid hex bytes");
|
|
@@ -6696,10 +7391,10 @@ function hexToBytes6(hex) {
|
|
|
6696
7391
|
}
|
|
6697
7392
|
return out;
|
|
6698
7393
|
}
|
|
6699
|
-
function
|
|
7394
|
+
function bytesToHex9(bytes) {
|
|
6700
7395
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6701
7396
|
}
|
|
6702
|
-
function
|
|
7397
|
+
function concatBytes7(...parts) {
|
|
6703
7398
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6704
7399
|
let offset = 0;
|
|
6705
7400
|
for (const part of parts) {
|
|
@@ -6708,13 +7403,13 @@ function concatBytes6(...parts) {
|
|
|
6708
7403
|
}
|
|
6709
7404
|
return out;
|
|
6710
7405
|
}
|
|
6711
|
-
function
|
|
7406
|
+
function expectLength6(value, len, name) {
|
|
6712
7407
|
if (value.length !== len) {
|
|
6713
7408
|
throw new SpendingPolicyError(`${name} must be ${len} bytes`);
|
|
6714
7409
|
}
|
|
6715
7410
|
return value;
|
|
6716
7411
|
}
|
|
6717
|
-
function
|
|
7412
|
+
function toBigint4(value, name) {
|
|
6718
7413
|
const n = typeof value === "bigint" ? value : BigInt(value);
|
|
6719
7414
|
if (n < 0n) {
|
|
6720
7415
|
throw new SpendingPolicyError(`${name} must be non-negative`);
|
|
@@ -6722,19 +7417,19 @@ function toBigint3(value, name) {
|
|
|
6722
7417
|
return n;
|
|
6723
7418
|
}
|
|
6724
7419
|
function uint64Bytes(value, name) {
|
|
6725
|
-
const n =
|
|
7420
|
+
const n = toBigint4(value, name);
|
|
6726
7421
|
if (n > 0xffffffffffffffffn) {
|
|
6727
7422
|
throw new SpendingPolicyError(`${name} exceeds uint64`);
|
|
6728
7423
|
}
|
|
6729
|
-
return
|
|
7424
|
+
return bigintBytes2(n, 8);
|
|
6730
7425
|
}
|
|
6731
7426
|
function uint128Bytes(value, name) {
|
|
6732
7427
|
if (value > 0xffffffffffffffffffffffffffffffffn) {
|
|
6733
7428
|
throw new SpendingPolicyError(`${name} exceeds uint128`);
|
|
6734
7429
|
}
|
|
6735
|
-
return
|
|
7430
|
+
return bigintBytes2(value, 16);
|
|
6736
7431
|
}
|
|
6737
|
-
function
|
|
7432
|
+
function bigintBytes2(value, len) {
|
|
6738
7433
|
const out = new Uint8Array(len);
|
|
6739
7434
|
let n = value;
|
|
6740
7435
|
for (let i = len - 1; i >= 0; i--) {
|
|
@@ -6761,15 +7456,15 @@ function pubkeyRegistryAddressHex() {
|
|
|
6761
7456
|
return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
|
|
6762
7457
|
}
|
|
6763
7458
|
function encodeRegisterPubkeyCalldata(pubkey) {
|
|
6764
|
-
const bytes =
|
|
7459
|
+
const bytes = toBytes7(pubkey);
|
|
6765
7460
|
if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
6766
7461
|
throw new PubkeyRegistryError(
|
|
6767
7462
|
`pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
|
|
6768
7463
|
);
|
|
6769
7464
|
}
|
|
6770
|
-
return
|
|
6771
|
-
|
|
6772
|
-
|
|
7465
|
+
return bytesToHex10(
|
|
7466
|
+
concatBytes8(
|
|
7467
|
+
hexToBytes9(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
|
|
6773
7468
|
uint256Word(32n),
|
|
6774
7469
|
uint256Word(BigInt(bytes.length)),
|
|
6775
7470
|
bytes
|
|
@@ -6783,7 +7478,7 @@ function encodeHasPubkeyCalldata(address) {
|
|
|
6783
7478
|
return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
|
|
6784
7479
|
}
|
|
6785
7480
|
function decodeLookupPubkeyReturn(data) {
|
|
6786
|
-
const bytes =
|
|
7481
|
+
const bytes = toBytes7(data);
|
|
6787
7482
|
if (bytes.length < 96) {
|
|
6788
7483
|
throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
|
|
6789
7484
|
}
|
|
@@ -6808,7 +7503,7 @@ function decodeLookupPubkeyReturn(data) {
|
|
|
6808
7503
|
};
|
|
6809
7504
|
}
|
|
6810
7505
|
function decodeHasPubkeyReturn(data) {
|
|
6811
|
-
const bytes =
|
|
7506
|
+
const bytes = toBytes7(data);
|
|
6812
7507
|
if (bytes.length !== 32) {
|
|
6813
7508
|
throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
|
|
6814
7509
|
}
|
|
@@ -6822,10 +7517,10 @@ function decodeHasPubkeyReturn(data) {
|
|
|
6822
7517
|
throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
|
|
6823
7518
|
}
|
|
6824
7519
|
function encodeSingleAddressCall2(selector, address) {
|
|
6825
|
-
return
|
|
7520
|
+
return bytesToHex10(concatBytes8(hexToBytes9(selector), addressWord(toAddressBytes(address))));
|
|
6826
7521
|
}
|
|
6827
7522
|
function addressWord(address) {
|
|
6828
|
-
return
|
|
7523
|
+
return concatBytes8(new Uint8Array(12), address);
|
|
6829
7524
|
}
|
|
6830
7525
|
function toAddressBytes(value) {
|
|
6831
7526
|
if (typeof value !== "string") {
|
|
@@ -6841,13 +7536,13 @@ function toAddressBytes(value) {
|
|
|
6841
7536
|
throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
|
|
6842
7537
|
}
|
|
6843
7538
|
}
|
|
6844
|
-
function
|
|
7539
|
+
function toBytes7(value) {
|
|
6845
7540
|
if (typeof value === "string") {
|
|
6846
|
-
return
|
|
7541
|
+
return hexToBytes9(value);
|
|
6847
7542
|
}
|
|
6848
7543
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6849
7544
|
}
|
|
6850
|
-
function
|
|
7545
|
+
function hexToBytes9(hex) {
|
|
6851
7546
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6852
7547
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6853
7548
|
throw new PubkeyRegistryError("invalid hex bytes");
|
|
@@ -6858,10 +7553,10 @@ function hexToBytes7(hex) {
|
|
|
6858
7553
|
}
|
|
6859
7554
|
return out;
|
|
6860
7555
|
}
|
|
6861
|
-
function
|
|
7556
|
+
function bytesToHex10(bytes) {
|
|
6862
7557
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6863
7558
|
}
|
|
6864
|
-
function
|
|
7559
|
+
function concatBytes8(...parts) {
|
|
6865
7560
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6866
7561
|
let offset = 0;
|
|
6867
7562
|
for (const part of parts) {
|
|
@@ -6930,6 +7625,39 @@ var CLOB_SELECTORS = {
|
|
|
6930
7625
|
/** `setLotSize(bytes32,bytes32,uint256)` — foundation-authorized per-market grid tune. */
|
|
6931
7626
|
setLotSize: "0x9909be80"
|
|
6932
7627
|
};
|
|
7628
|
+
var OPERATOR_ROUTER_SIGS = {
|
|
7629
|
+
/** `registerOperator(address recipient, uint16 feeBps)`. */
|
|
7630
|
+
registerOperator: "registerOperator(address,uint16)",
|
|
7631
|
+
/** `updateOperator(address recipient, uint16 feeBps)`. */
|
|
7632
|
+
updateOperator: "updateOperator(address,uint16)",
|
|
7633
|
+
/** `disableOperator(address operator)` — foundation-authorized. */
|
|
7634
|
+
disableOperator: "disableOperator(address)",
|
|
7635
|
+
/**
|
|
7636
|
+
* `placeLimitOrderVia(address operator, bytes32 base, bytes32 quote,
|
|
7637
|
+
* uint8 side, uint256 price, uint256 amount, uint64 expiresAtBlock)`
|
|
7638
|
+
* → `bytes32 orderId`.
|
|
7639
|
+
*
|
|
7640
|
+
* Skims the operator fee (quote token, `user -> recipient`) then
|
|
7641
|
+
* re-enters the CLOB `placeLimitOrder` op with `caller = user`, so the
|
|
7642
|
+
* resting order is owned + escrowed + cancellable by the user,
|
|
7643
|
+
* identical to a direct CLOB placement.
|
|
7644
|
+
*/
|
|
7645
|
+
placeLimitOrderVia: "placeLimitOrderVia(address,bytes32,bytes32,uint8,uint256,uint256,uint64)"
|
|
7646
|
+
};
|
|
7647
|
+
var OPERATOR_ROUTER_SELECTORS = {
|
|
7648
|
+
registerOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.registerOperator),
|
|
7649
|
+
updateOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.updateOperator),
|
|
7650
|
+
disableOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.disableOperator),
|
|
7651
|
+
placeLimitOrderVia: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.placeLimitOrderVia)
|
|
7652
|
+
};
|
|
7653
|
+
var OPERATOR_ROUTER_EVENT_SIGS = {
|
|
7654
|
+
operatorFeeCharged: "OperatorFeeCharged(address,address,bytes32,address,bytes32,uint256,bytes32)",
|
|
7655
|
+
operatorRegistered: "OperatorRegistered(address,address,uint16)",
|
|
7656
|
+
operatorUpdated: "OperatorUpdated(address,address,uint16,bool)"
|
|
7657
|
+
};
|
|
7658
|
+
function operatorRouterSelectorHex(sig) {
|
|
7659
|
+
return "0x" + [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7660
|
+
}
|
|
6933
7661
|
var MarketActionError = class extends Error {
|
|
6934
7662
|
constructor(message) {
|
|
6935
7663
|
super(message);
|
|
@@ -7308,6 +8036,92 @@ function buildCancelSpotOrderPlan(args) {
|
|
|
7308
8036
|
mempoolClass: MempoolClass.CLOBOp
|
|
7309
8037
|
};
|
|
7310
8038
|
}
|
|
8039
|
+
function encodePlaceLimitOrderViaCalldata(args) {
|
|
8040
|
+
const operator = normalizeNativeMarketAddress(args.operator, "operator");
|
|
8041
|
+
if (operator.kind !== "user") {
|
|
8042
|
+
throw new MarketActionError("operator must be a 'mono' user address");
|
|
8043
|
+
}
|
|
8044
|
+
const side = normalizeSide(args.side);
|
|
8045
|
+
const price = positiveDecimal(args.price, "price");
|
|
8046
|
+
const amount = positiveDecimal(args.amount, "amount");
|
|
8047
|
+
const expiresAtBlock = uint64(args.expiresAtBlock ?? 0n, "expiresAtBlock");
|
|
8048
|
+
return bytesToHex2(
|
|
8049
|
+
concatBytes2(
|
|
8050
|
+
hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
|
|
8051
|
+
addressWord2(operator.bytes),
|
|
8052
|
+
bytes32FromHex(args.base, "base"),
|
|
8053
|
+
bytes32FromHex(args.quote, "quote"),
|
|
8054
|
+
uint8Word2(side),
|
|
8055
|
+
uint256Word2(price, "price"),
|
|
8056
|
+
uint256Word2(amount, "amount"),
|
|
8057
|
+
uint64Word3(expiresAtBlock, "expiresAtBlock")
|
|
8058
|
+
)
|
|
8059
|
+
);
|
|
8060
|
+
}
|
|
8061
|
+
function quoteOperatorFee(args, feeBps) {
|
|
8062
|
+
if (!Number.isInteger(feeBps) || feeBps < 0 || feeBps > PROTOCOL_MAX_OPERATOR_FEE_BPS) {
|
|
8063
|
+
throw new MarketActionError(
|
|
8064
|
+
`feeBps must be an integer in 0..=${PROTOCOL_MAX_OPERATOR_FEE_BPS}`
|
|
8065
|
+
);
|
|
8066
|
+
}
|
|
8067
|
+
const operator = normalizeNativeMarketAddress(args.operator, "operator");
|
|
8068
|
+
if (operator.kind !== "user") {
|
|
8069
|
+
throw new MarketActionError("operator must be a 'mono' user address");
|
|
8070
|
+
}
|
|
8071
|
+
const price = positiveDecimal(args.price, "price");
|
|
8072
|
+
const amount = positiveDecimal(args.amount, "amount");
|
|
8073
|
+
const quoteBasis = price * amount;
|
|
8074
|
+
const feeAmount = quoteBasis * BigInt(feeBps) / 10000n;
|
|
8075
|
+
return {
|
|
8076
|
+
operator: args.operator,
|
|
8077
|
+
feeBps,
|
|
8078
|
+
quoteBasis: quoteBasis.toString(10),
|
|
8079
|
+
feeAmount: feeAmount.toString(10)
|
|
8080
|
+
};
|
|
8081
|
+
}
|
|
8082
|
+
function buildPlaceLimitOrderViaPlan(args, feeBps) {
|
|
8083
|
+
return {
|
|
8084
|
+
method: "eth_sendTransaction",
|
|
8085
|
+
params: [
|
|
8086
|
+
{
|
|
8087
|
+
to: PRECOMPILE_ADDRESSES.OPERATOR_ROUTER,
|
|
8088
|
+
value: "0x0",
|
|
8089
|
+
data: encodePlaceLimitOrderViaCalldata(args)
|
|
8090
|
+
}
|
|
8091
|
+
],
|
|
8092
|
+
mempoolClass: MempoolClass.CLOBOp,
|
|
8093
|
+
operatorFee: quoteOperatorFee(args, feeBps)
|
|
8094
|
+
};
|
|
8095
|
+
}
|
|
8096
|
+
function decodeOperatorFeeChargedEvent(topics, data) {
|
|
8097
|
+
if (topics.length !== 4) {
|
|
8098
|
+
throw new MarketActionError(
|
|
8099
|
+
`OperatorFeeCharged expects 4 topics, got ${topics.length}`
|
|
8100
|
+
);
|
|
8101
|
+
}
|
|
8102
|
+
const topic0 = bytesToHex2(expectWordLen(toEventBytes(topics[0]), "topic0"));
|
|
8103
|
+
const expected = bytesToHex2(
|
|
8104
|
+
keccak_256(new TextEncoder().encode(OPERATOR_ROUTER_EVENT_SIGS.operatorFeeCharged))
|
|
8105
|
+
);
|
|
8106
|
+
if (topic0 !== expected) {
|
|
8107
|
+
throw new MarketActionError("topic0 is not OperatorFeeCharged");
|
|
8108
|
+
}
|
|
8109
|
+
const body = toEventBytes(data);
|
|
8110
|
+
if (body.length !== 4 * 32) {
|
|
8111
|
+
throw new MarketActionError(
|
|
8112
|
+
`OperatorFeeCharged expects 128 data bytes, got ${body.length}`
|
|
8113
|
+
);
|
|
8114
|
+
}
|
|
8115
|
+
return {
|
|
8116
|
+
operator: addressFromEventTopic(topics[1]),
|
|
8117
|
+
user: addressFromEventTopic(topics[2]),
|
|
8118
|
+
marketId: bytesToHex2(expectWordLen(toEventBytes(topics[3]), "marketId")),
|
|
8119
|
+
recipient: bytesToHex2(body.subarray(12, 32)),
|
|
8120
|
+
quoteToken: bytesToHex2(body.subarray(32, 64)),
|
|
8121
|
+
feeAmount: u256DecimalWord(body.subarray(64, 96)),
|
|
8122
|
+
clobOrderId: bytesToHex2(body.subarray(96, 128))
|
|
8123
|
+
};
|
|
8124
|
+
}
|
|
7311
8125
|
function buildNativeCallForwarderArtifact(requestBytes) {
|
|
7312
8126
|
const size = uint64(requestBytes, "requestBytes");
|
|
7313
8127
|
if (size === 0n) {
|
|
@@ -7563,6 +8377,32 @@ function uint256Word2(value, name) {
|
|
|
7563
8377
|
}
|
|
7564
8378
|
return out;
|
|
7565
8379
|
}
|
|
8380
|
+
function addressWord2(addr) {
|
|
8381
|
+
if (addr.length !== 20) {
|
|
8382
|
+
throw new MarketActionError("address must be 20 bytes");
|
|
8383
|
+
}
|
|
8384
|
+
const out = new Uint8Array(32);
|
|
8385
|
+
out.set(addr, 12);
|
|
8386
|
+
return out;
|
|
8387
|
+
}
|
|
8388
|
+
function toEventBytes(value) {
|
|
8389
|
+
if (typeof value === "string") return hexToBytes2(value, "event word");
|
|
8390
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
8391
|
+
}
|
|
8392
|
+
function expectWordLen(value, name) {
|
|
8393
|
+
if (value.length !== 32) {
|
|
8394
|
+
throw new MarketActionError(`${name} must be 32 bytes, got ${value.length}`);
|
|
8395
|
+
}
|
|
8396
|
+
return value;
|
|
8397
|
+
}
|
|
8398
|
+
function addressFromEventTopic(topic) {
|
|
8399
|
+
return bytesToHex2(expectWordLen(toEventBytes(topic), "address topic").subarray(12, 32));
|
|
8400
|
+
}
|
|
8401
|
+
function u256DecimalWord(word) {
|
|
8402
|
+
let v = 0n;
|
|
8403
|
+
for (const b of word) v = v << 8n | BigInt(b);
|
|
8404
|
+
return v.toString(10);
|
|
8405
|
+
}
|
|
7566
8406
|
function spotLimitOrderInto(w, args, prefix) {
|
|
7567
8407
|
w.rawBytes(bytes32FromHex(args.marketId, `${prefix}marketId`));
|
|
7568
8408
|
monoAddressInto(w, args.owner, `${prefix}owner`);
|
|
@@ -8079,6 +8919,6 @@ var MONOLYTHIUM_NETWORKS = {
|
|
|
8079
8919
|
// src/index.ts
|
|
8080
8920
|
var version = "0.2.2";
|
|
8081
8921
|
|
|
8082
|
-
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DelegationPrecompileError, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MarketActionError, MrvValidationError, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NoEvmReceiptProofError, NodeRegistryError, PRECOMPILE_ADDRESSES, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, PubkeyRegistryError, RESERVED_ADDRESS_HRPS, RpcClient, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bridgeAddressHex, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clobAddressHex, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, consumeNativeEvents, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeTxFeedResponse, delegationAddressHex, deriveClobMarketId, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, encodeBlockSelector, encodeCancelOrderCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeUndelegateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseLythToLythoshi, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, pubkeyRegistryAddressHex, rankBridgeRoutes, requireTypedAddress, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
8922
|
+
export { ADDRESS_HRP, ADDRESS_KIND_HRPS, API_STREAM_TOPICS, AddressError, AgentActionError, ApiClient, BRIDGE_QUOTE_API_BLOCKED_REASON, BRIDGE_REVERT_TAGS, BRIDGE_SELECTORS, BRIDGE_SUBMIT_API_BLOCKED_REASON, BURN_ADDR, BridgePrecompileError, BridgeRouteCatalogueError, CHAIN_REGISTRY, CHAIN_REGISTRY_RAW_BASE, CLOB_MARKET_ID_DOMAIN_TAG, CLOB_SELECTORS, CLUSTER_FORMED_EVENT_SIG, DELEGATION_REVERT_TAGS, DELEGATION_SELECTORS, DIVERSITY_SCORE_MAX, DelegationPrecompileError, EXECUTION_UNIT_PRICE_SAFETY_MULTIPLIER, LYTHOSHI_PER_LYTH, LYTH_DECIMALS, MAX_NATIVE_CALL_FORWARDER_REQUEST_BYTES, MAX_NATIVE_RECEIPT_EVENTS, MIN_EXECUTION_UNIT_PRICE_LYTHOSHI, ML_DSA_65_PUBLIC_KEY_LEN2 as ML_DSA_65_PUBLIC_KEY_LEN, ML_DSA_65_SIGNATURE_LEN2 as ML_DSA_65_SIGNATURE_LEN, MONOLYTHIUM_NETWORKS, MONOLYTHIUM_TESTNET_CHAIN_ID, MONOLYTHIUM_TESTNET_NETWORK_NAME, MRV_DEPLOY_PAYLOAD_VERSION, MRV_FORMAT_VERSION, MRV_MAX_ABI_SYMBOLS, MRV_MAX_CODE_BYTES, MRV_MAX_DEBUG_BYTES, MRV_MAX_MEMORY_PAGES, MRV_MAX_STORAGE_NAMESPACE_BYTES, MRV_MEMORY_PAGE_BYTES, MRV_PROFILE_MONO_RV32IM_V1, MRV_STRUCTURED_FEE_FIELDS, MRV_TX_EXTENSION_KIND, MRV_TX_EXTENSION_V1, MULTISIG_ADDRESS_DERIVATION_DOMAIN, MarketActionError, MrvValidationError, NATIVE_AGENT_MODULE_ADDRESS, NATIVE_AGENT_MODULE_ADDRESS_BYTES, NATIVE_CALL_FORWARDER_ARTIFACT_PROFILE, NATIVE_CALL_FORWARDER_RESPONSE_CAPACITY, NATIVE_CALL_FORWARDER_RESPONSE_OFFSET, NATIVE_DEV_HOST_API_VERSION, NATIVE_DEV_IPC_PROTOCOL_VERSION, NATIVE_DEV_MANIFEST_SCHEMA_VERSION, NATIVE_LYTH_DECIMALS, NATIVE_MARKET_EVENT_FAMILY, NATIVE_MARKET_MODULE_ADDRESS, NATIVE_MARKET_MODULE_ADDRESS_BYTES, NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC, NODE_REGISTRY_CAPABILITIES, NODE_REGISTRY_CAPABILITY_MASK, NODE_REGISTRY_PUBLIC_SERVICE_MASK, NODE_REGISTRY_SELECTORS, NO_EVM_ARCHIVE_PROOF_SCHEMA, NO_EVM_ARCHIVE_SIGNATURE_SCHEME, NO_EVM_FINALITY_EVIDENCE_SCHEMA, NO_EVM_FINALITY_EVIDENCE_SOURCE, NO_EVM_RECEIPTS_ROOT_DOMAIN, NO_EVM_RECEIPT_CODEC, NO_EVM_RECEIPT_PROOF_SCHEMA, NO_EVM_RECEIPT_PROOF_TYPE, NO_EVM_RECEIPT_ROOT_ALGORITHM, NoEvmReceiptProofError, NodeRegistryError, OPERATOR_ROUTER_ADDRESS, OPERATOR_ROUTER_EVENT_SIGS, OPERATOR_ROUTER_SELECTORS, OPERATOR_ROUTER_SIGS, ORACLE_EVENT_SIGS, OracleEventError, PRECOMPILE_ADDRESSES, PROTOCOL_MAX_OPERATOR_FEE_BPS, PROVER_MARKET_ADDRESS, PROVER_MARKET_BID_DOMAIN, PROVER_MARKET_EVENT_SIGS, PROVER_MARKET_REQUEST_DOMAIN, PROVER_MARKET_SELECTORS, PROVER_MARKET_SUBMIT_DOMAIN, PROVER_SLASH_REASON_BAD_PROOF, PROVER_SLASH_REASON_NON_DELIVERY, PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN, PUBKEY_REGISTRY_SELECTORS, ProverMarketError, PubkeyRegistryError, REGISTRY_DEFAULT_EXECUTION_UNIT_LIMIT, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, SERVICE_PROBE_STATUS, SET_POLICY_CLAIM_DOMAIN_TAG, SPENDING_POLICY_SELECTORS, SdkError, SpendingPolicyError, TESTNET_69420, TRANSFER_DEFAULT_EXECUTION_UNIT_LIMIT, V1_BRIDGE_ALLOWED_FEE_TOKEN, V1_BRIDGE_ALLOWED_PROTOCOL, addressBytesToHex, addressToBech32, addressToTypedBech32, apiEndpointFromRpcEndpoint, assertMrvCallNativeSubmissionPlan, assertMrvDeployNativeSubmissionPlan, assertMrvFeeDisplayConformance, assertMrvStructuredFeeConformance, assertNativeDevMrcTokenPlan, assertNativeDevMrvDeployPlan, assertNativeDevWalletApprovalRequest, assertNativeMarketOrderBookStreamPayload, assessBridgeRoute, bech32ToAddress, bech32ToAddressBytes, bidSighash, bridgeAddressHex, bridgeDrainRemaining, bridgeQuoteSubmitReadiness, bridgeRoutesReadiness, bridgeTransferCandidates, buildBridgeRouteCatalogue, buildCancelSpotOrderPlan, buildMrvCallNativeTxPlan, buildMrvCallPlan, buildMrvCallRequest, buildMrvDeployNativeTxPlan, buildMrvDeployPayloadNativeTxPlan, buildMrvDeployPayloadPlan, buildMrvDeployPayloadRequest, buildMrvDeployPlan, buildMrvDeployRequest, buildNativeAgentCreateEscrowForwarderInput, buildNativeAgentCreateEscrowModuleCall, buildNativeAgentModuleCallEnvelope, buildNativeAgentRecordReputationForwarderInput, buildNativeAgentRecordReputationModuleCall, buildNativeAgentSetSpendingPolicyForwarderInput, buildNativeAgentSetSpendingPolicyModuleCall, buildNativeCallForwarderArtifact, buildNativeMarketModuleCallEnvelope, buildNativeNftBuyListingForwarderInput, buildNativeNftBuyListingModuleCall, buildNativeNftCancelListingForwarderInput, buildNativeNftCancelListingModuleCall, buildNativeNftCreateListingForwarderInput, buildNativeNftCreateListingModuleCall, buildNativeNftPlaceAuctionBidForwarderInput, buildNativeNftPlaceAuctionBidModuleCall, buildNativeNftSettleAuctionForwarderInput, buildNativeNftSettleAuctionModuleCall, buildNativeNftSweepExpiredListingsForwarderInput, buildNativeNftSweepExpiredListingsModuleCall, buildNativeSpotCancelOrderForwarderInput, buildNativeSpotCancelOrderModuleCall, buildNativeSpotCreateMarketForwarderInput, buildNativeSpotCreateMarketModuleCall, buildNativeSpotLimitOrderForwarderInput, buildNativeSpotLimitOrderModuleCall, buildNativeSpotSettleLimitOrderForwarderInput, buildNativeSpotSettleLimitOrderModuleCall, buildNativeSpotSettleRoutedLimitOrderForwarderInput, buildNativeSpotSettleRoutedLimitOrderModuleCall, buildPlaceLimitOrderViaPlan, buildPlaceSpotLimitOrderPlan, buildPlaceSpotMarketOrderExPlan, buildPlaceSpotMarketOrderPlan, checkMrvFeeDisplayConformance, checkMrvStructuredFeeConformance, checkNativeDevkitCompatibility, clampPriorityTip, clobAddressHex, compareNativeDevVersions, composeClaimBoundMessage, computeNoEvmDacFinalityMessage, computeNoEvmLeaderFinalityMessage, computeNoEvmReceiptsRoot, computeNoEvmRoundFinalityMessage, computeNoEvmTargetReceiptHash, consumeNativeEvents, decodeClusterDiversity, decodeClusterFormedEvent, decodeHasPubkeyReturn, decodeLookupPubkeyReturn, decodeNativeAgentStateResponse, decodeNativeMarketOrderBookDeltasResponse, decodeNativeReceiptResponse, decodeNoEvmReceiptTranscript, decodeOperatorFeeChargedEvent, decodeOperatorNetworkMetadata, decodeOracleEvent, decodeTimeWindow, decodeTxFeedResponse, delegationAddressHex, deriveClobMarketId, deriveClusterAnchorAddress, deriveMrvContractAddress, deriveNativeSpotMarketId, deriveNativeSpotOrderId, encodeBlockSelector, encodeCancelOrderCalldata, encodeClaimCalldata, encodeClaimPolicyByAddressCalldata, encodeCompleteRedemptionCalldata, encodeCreateRequestCalldata, encodeCreateRequestCanonical, encodeDelegateCalldata, encodeDisableCalldata, encodeEnableCalldata, encodeHasPubkeyCalldata, encodeLockBridgeConfigCalldata, encodeLookupPubkeyCalldata, encodeMrvDeployPayload, encodeNativeAgentAcceptEscrowCall, encodeNativeAgentApproveEscrowCall, encodeNativeAgentArbiterGetCall, encodeNativeAgentAttestationGetCall, encodeNativeAgentAvailabilityGetCall, encodeNativeAgentCancelEscrowCall, encodeNativeAgentCloseAvailabilityCall, encodeNativeAgentConsentGetCall, encodeNativeAgentCounterEscrowCall, encodeNativeAgentCreateEscrowCall, encodeNativeAgentDeactivateServiceCall, encodeNativeAgentDisputeEscrowCall, encodeNativeAgentEscrowGetCall, encodeNativeAgentGrantConsentCall, encodeNativeAgentIssueAttestationCall, encodeNativeAgentIssuerGetCall, encodeNativeAgentListServiceCall, encodeNativeAgentModuleForwarderInput, encodeNativeAgentOpenAvailabilityCall, encodeNativeAgentRecordPolicySpendCall, encodeNativeAgentRecordReputationCall, encodeNativeAgentRegisterArbiterCall, encodeNativeAgentRegisterIssuerCall, encodeNativeAgentReputationGetCall, encodeNativeAgentResolveEscrowCall, encodeNativeAgentRevokeAttestationCall, encodeNativeAgentRevokeConsentCall, encodeNativeAgentServiceGetCall, encodeNativeAgentSetAvailabilityCall, encodeNativeAgentSetSpendingPolicyCall, encodeNativeAgentSpendingPolicyGetCall, encodeNativeAgentStartEscrowCall, encodeNativeAgentSubmitEscrowCall, encodeNativeMarketModuleForwarderInput, encodeNativeNftBuyListingCall, encodeNativeNftCancelListingCall, encodeNativeNftCreateListingCall, encodeNativeNftPlaceAuctionBidCall, encodeNativeNftSettleAuctionCall, encodeNativeNftSweepExpiredListingsCall, encodeNativeSpotCancelOrderCall, encodeNativeSpotCreateMarketCall, encodeNativeSpotLimitOrderCall, encodeNativeSpotSettleLimitOrderCall, encodeNativeSpotSettleRoutedLimitOrderCall, encodePlaceLimitOrderCalldata, encodePlaceLimitOrderViaCalldata, encodePlaceMarketOrderCalldata, encodePlaceMarketOrderExCalldata, encodeRedelegateCalldata, encodeRegisterPubkeyCalldata, encodeReportServiceProbeCalldata, encodeSetAutoCompoundCalldata, encodeSetBridgeResumeCooldownCalldata, encodeSetBridgeRouteFinalityCalldata, encodeSetLotSizeCalldata, encodeSetMinNotionalCalldata, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, encodeSetTickSizeCalldata, encodeUndelegateCalldata, exportBridgeRouteCatalogueJson, fetchChainInfoLatest, fetchChainRegistryLatest, formatLyth, formatLythoshi, formatNativeReceiptFeeDisplay, getChainInfo, getNoEvmReceiptTrustPolicy, getP2pSeeds, getRpcEndpoints, hexToAddressBytes, isBridgeAdminLockedRevert, isBridgeCooldownZeroRevert, isBridgeFinalityZeroRevert, isBridgeResumeCooldownActiveRevert, isConcreteServiceProbeStatus, isNativeDecodedEvent, isNativeMarketOrderBookStreamPayload, isRedemptionPrincipalUnavailableRevert, isSinglePublicServiceProbeMask, isValidNodeRegistryCapabilities, isValidPublicServiceProbeMask, mrvAddressToBech32, mrvBech32ToAddress, mrvCodeHashHex, mrvV1TransactionExtension, nativeAgentStateFilterParams, nativeDevSchemaFieldNames, nativeDevUiStrings, nativeEventMatches, nativeEventsFilterParams, nativeEventsFromHistory, nativeEventsFromReceipt, nativeMarketEventFilter, nativeMarketEventsFromHistory, nativeMarketEventsFromReceipt, nativeMarketStateFilterParams, noEvmReceiptTrustPolicyFromChainInfo, nodeHostingClassFromByte, nodeHostingClassToByte, nodeRegistryAddressHex, normalizeAddressHex, normalizeBridgeRouteCatalogue, oracleAddressHex, packTimeWindow, parseAddress, parseBridgeRouteCatalogueJson, parseChainRegistryToml, parseLythToLythoshi, parseNativeDecodedEvent, parseQuantity, parseQuantityBig, proverMarketStateFromByte, pubkeyRegistryAddressHex, quoteOperatorFee, rankBridgeRoutes, requestSighash, requireTypedAddress, resolveExecutionFee, resolveMaxExecutionUnitPrice, resolveRegistryExecutionFee, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitSighash, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
8083
8923
|
//# sourceMappingURL=index.js.map
|
|
8084
8924
|
//# sourceMappingURL=index.js.map
|