@monolythium/core-sdk 0.3.8 → 0.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crypto/index.d.cts +2 -2
- package/dist/crypto/index.d.ts +2 -2
- package/dist/index.cjs +935 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -455
- package/dist/index.d.ts +22 -455
- package/dist/index.js +892 -79
- package/dist/index.js.map +1 -1
- package/dist/{submission-D8xzCLNl.d.cts → submission-C19l5ilj.d.cts} +1640 -58
- package/dist/{submission-D8xzCLNl.d.ts → submission-C19l5ilj.d.ts} +1640 -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 = [];
|
|
@@ -6384,6 +6629,358 @@ function assertWholeNumber(field2, value) {
|
|
|
6384
6629
|
throw new Error(`${field2} must be a whole number`);
|
|
6385
6630
|
}
|
|
6386
6631
|
}
|
|
6632
|
+
var ORACLE_EVENT_SIGS = {
|
|
6633
|
+
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
6634
|
+
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
6635
|
+
feedAdded: "FeedAdded(bytes32,uint8,uint16,uint32,uint32)",
|
|
6636
|
+
feedUpdated: "FeedUpdated(bytes32,uint8,uint16,uint32,uint32)",
|
|
6637
|
+
oracleFraudSlashed: "OracleFraudSlashed(bytes32,uint64,address,bytes32)",
|
|
6638
|
+
oracleAdminUpdated: "OracleAdminUpdated(address)",
|
|
6639
|
+
oracleWriterAdded: "OracleWriterAdded(address,address)",
|
|
6640
|
+
oracleWriterRemoved: "OracleWriterRemoved(address,address)"
|
|
6641
|
+
};
|
|
6642
|
+
var OracleEventError = class extends Error {
|
|
6643
|
+
constructor(message) {
|
|
6644
|
+
super(message);
|
|
6645
|
+
this.name = "OracleEventError";
|
|
6646
|
+
}
|
|
6647
|
+
};
|
|
6648
|
+
function oracleAddressHex() {
|
|
6649
|
+
return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
|
|
6650
|
+
}
|
|
6651
|
+
function decodeOracleEvent(topics, data) {
|
|
6652
|
+
if (topics.length === 0) {
|
|
6653
|
+
throw new OracleEventError("event record has no topics");
|
|
6654
|
+
}
|
|
6655
|
+
const topic0 = bytesToHex6(expectLength4(toBytes3(topics[0]), 32, "topic0"));
|
|
6656
|
+
const body = toBytes3(data);
|
|
6657
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
|
|
6658
|
+
checkArity("OracleRoundFinalized", 3, topics.length);
|
|
6659
|
+
checkData("OracleRoundFinalized", 3 * 32, body.length);
|
|
6660
|
+
return {
|
|
6661
|
+
kind: "roundFinalized",
|
|
6662
|
+
feedId: hex32(topics[1]),
|
|
6663
|
+
roundId: u64FromTopic(topics[2]),
|
|
6664
|
+
computedMedian: u256Decimal(body.subarray(0, 32)),
|
|
6665
|
+
finalizedAtBlock: u64FromWord2(body.subarray(32, 64)),
|
|
6666
|
+
observationsLen: u32FromWord2(body.subarray(64, 96))
|
|
6667
|
+
};
|
|
6668
|
+
}
|
|
6669
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.observationSubmitted)) {
|
|
6670
|
+
checkArity("ObservationSubmitted", 4, topics.length);
|
|
6671
|
+
checkData("ObservationSubmitted", 2 * 32, body.length);
|
|
6672
|
+
return {
|
|
6673
|
+
kind: "observationSubmitted",
|
|
6674
|
+
feedId: hex32(topics[1]),
|
|
6675
|
+
roundId: u64FromTopic(topics[2]),
|
|
6676
|
+
writer: addressFromTopic(topics[3]),
|
|
6677
|
+
value: u256Decimal(body.subarray(0, 32)),
|
|
6678
|
+
observedAt: u64FromWord2(body.subarray(32, 64))
|
|
6679
|
+
};
|
|
6680
|
+
}
|
|
6681
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleFraudSlashed)) {
|
|
6682
|
+
checkArity("OracleFraudSlashed", 4, topics.length);
|
|
6683
|
+
checkData("OracleFraudSlashed", 32, body.length);
|
|
6684
|
+
return {
|
|
6685
|
+
kind: "fraudSlashed",
|
|
6686
|
+
feedId: hex32(topics[1]),
|
|
6687
|
+
roundId: u64FromTopic(topics[2]),
|
|
6688
|
+
writer: addressFromTopic(topics[3]),
|
|
6689
|
+
evidenceHash: bytesToHex6(body.subarray(0, 32))
|
|
6690
|
+
};
|
|
6691
|
+
}
|
|
6692
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
|
|
6693
|
+
checkArity("FeedAdded", 2, topics.length);
|
|
6694
|
+
checkData("FeedAdded", 4 * 32, body.length);
|
|
6695
|
+
return { kind: "feedAdded", ...decodeFeedFields(topics[1], body) };
|
|
6696
|
+
}
|
|
6697
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedUpdated)) {
|
|
6698
|
+
checkArity("FeedUpdated", 2, topics.length);
|
|
6699
|
+
checkData("FeedUpdated", 4 * 32, body.length);
|
|
6700
|
+
return { kind: "feedUpdated", ...decodeFeedFields(topics[1], body) };
|
|
6701
|
+
}
|
|
6702
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleAdminUpdated)) {
|
|
6703
|
+
checkArity("OracleAdminUpdated", 2, topics.length);
|
|
6704
|
+
checkData("OracleAdminUpdated", 0, body.length);
|
|
6705
|
+
return { kind: "adminUpdated", admin: addressFromTopic(topics[1]) };
|
|
6706
|
+
}
|
|
6707
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleWriterAdded)) {
|
|
6708
|
+
checkArity("OracleWriterAdded", 3, topics.length);
|
|
6709
|
+
checkData("OracleWriterAdded", 0, body.length);
|
|
6710
|
+
return {
|
|
6711
|
+
kind: "writerAdded",
|
|
6712
|
+
admin: addressFromTopic(topics[1]),
|
|
6713
|
+
writer: addressFromTopic(topics[2])
|
|
6714
|
+
};
|
|
6715
|
+
}
|
|
6716
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleWriterRemoved)) {
|
|
6717
|
+
checkArity("OracleWriterRemoved", 3, topics.length);
|
|
6718
|
+
checkData("OracleWriterRemoved", 0, body.length);
|
|
6719
|
+
return {
|
|
6720
|
+
kind: "writerRemoved",
|
|
6721
|
+
admin: addressFromTopic(topics[1]),
|
|
6722
|
+
writer: addressFromTopic(topics[2])
|
|
6723
|
+
};
|
|
6724
|
+
}
|
|
6725
|
+
throw new OracleEventError("unknown oracle event topic0");
|
|
6726
|
+
}
|
|
6727
|
+
function decodeFeedFields(feedTopic, body) {
|
|
6728
|
+
return {
|
|
6729
|
+
feedId: hex32(feedTopic),
|
|
6730
|
+
decimals: body[31],
|
|
6731
|
+
minSigners: body[62] << 8 | body[63],
|
|
6732
|
+
circuitBreakerBps: u32FromWord2(body.subarray(64, 96)),
|
|
6733
|
+
allowedWritersLen: u32FromWord2(body.subarray(96, 128))
|
|
6734
|
+
};
|
|
6735
|
+
}
|
|
6736
|
+
function topicHex(sig) {
|
|
6737
|
+
return bytesToHex6(keccak_256(new TextEncoder().encode(sig)));
|
|
6738
|
+
}
|
|
6739
|
+
function checkArity(event, expected, found) {
|
|
6740
|
+
if (found !== expected) {
|
|
6741
|
+
throw new OracleEventError(`${event} expected ${expected} topics, found ${found}`);
|
|
6742
|
+
}
|
|
6743
|
+
}
|
|
6744
|
+
function checkData(event, expected, found) {
|
|
6745
|
+
if (found !== expected) {
|
|
6746
|
+
throw new OracleEventError(`${event} expected ${expected} data bytes, found ${found}`);
|
|
6747
|
+
}
|
|
6748
|
+
}
|
|
6749
|
+
function hex32(topic) {
|
|
6750
|
+
return bytesToHex6(expectLength4(toBytes3(topic), 32, "feedId topic"));
|
|
6751
|
+
}
|
|
6752
|
+
function addressFromTopic(topic) {
|
|
6753
|
+
return bytesToHex6(expectLength4(toBytes3(topic), 32, "address topic").subarray(12, 32));
|
|
6754
|
+
}
|
|
6755
|
+
function u64FromTopic(topic) {
|
|
6756
|
+
return u64FromWord2(expectLength4(toBytes3(topic), 32, "u64 topic"));
|
|
6757
|
+
}
|
|
6758
|
+
function u64FromWord2(word) {
|
|
6759
|
+
let v = 0n;
|
|
6760
|
+
for (let i = 24; i < 32; i++) v = v << 8n | BigInt(word[i]);
|
|
6761
|
+
return v;
|
|
6762
|
+
}
|
|
6763
|
+
function u32FromWord2(word) {
|
|
6764
|
+
return (word[28] << 24 | word[29] << 16 | word[30] << 8 | word[31]) >>> 0;
|
|
6765
|
+
}
|
|
6766
|
+
function u256Decimal(word) {
|
|
6767
|
+
let v = 0n;
|
|
6768
|
+
for (const b of word) v = v << 8n | BigInt(b);
|
|
6769
|
+
return v.toString(10);
|
|
6770
|
+
}
|
|
6771
|
+
function toBytes3(value) {
|
|
6772
|
+
if (typeof value === "string") return hexToBytes5(value);
|
|
6773
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6774
|
+
}
|
|
6775
|
+
function hexToBytes5(hex) {
|
|
6776
|
+
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6777
|
+
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6778
|
+
throw new OracleEventError("invalid hex bytes");
|
|
6779
|
+
}
|
|
6780
|
+
const out = new Uint8Array(b.length / 2);
|
|
6781
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6782
|
+
return out;
|
|
6783
|
+
}
|
|
6784
|
+
function bytesToHex6(bytes) {
|
|
6785
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6786
|
+
}
|
|
6787
|
+
function expectLength4(value, len, name) {
|
|
6788
|
+
if (value.length !== len) {
|
|
6789
|
+
throw new OracleEventError(`${name} must be ${len} bytes, got ${value.length}`);
|
|
6790
|
+
}
|
|
6791
|
+
return value;
|
|
6792
|
+
}
|
|
6793
|
+
var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
|
|
6794
|
+
var SERVES_GPU_PROVE = 512;
|
|
6795
|
+
var PROVER_MARKET_SELECTORS = {
|
|
6796
|
+
createRequest: "0x" + selectorHex2("createRequest(bytes)"),
|
|
6797
|
+
submitBid: "0x" + selectorHex2("submitBid(bytes)"),
|
|
6798
|
+
closeRequest: "0x" + selectorHex2("closeRequest(bytes)"),
|
|
6799
|
+
submitProof: "0x" + selectorHex2("submitProof(bytes)"),
|
|
6800
|
+
settle: "0x" + selectorHex2("settle(bytes)"),
|
|
6801
|
+
slash: "0x" + selectorHex2("slash(bytes)")
|
|
6802
|
+
};
|
|
6803
|
+
var PROVER_MARKET_EVENT_SIGS = {
|
|
6804
|
+
proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
|
|
6805
|
+
bidSubmitted: "BidSubmitted(bytes32,address,uint128)",
|
|
6806
|
+
requestAssigned: "RequestAssigned(bytes32,address,uint128)",
|
|
6807
|
+
proofSettled: "ProofSettled(bytes32,address,uint128,uint128)",
|
|
6808
|
+
proverSlashed: "ProverSlashed(bytes32,address,uint16,bytes32)",
|
|
6809
|
+
requestExpired: "RequestExpired(bytes32,address,uint128)"
|
|
6810
|
+
};
|
|
6811
|
+
var PROVER_SLASH_REASON_NON_DELIVERY = 1024;
|
|
6812
|
+
var PROVER_SLASH_REASON_BAD_PROOF = 1025;
|
|
6813
|
+
var PROVER_MARKET_REQUEST_DOMAIN = "prover_market.request.v1";
|
|
6814
|
+
var PROVER_MARKET_BID_DOMAIN = "prover_market.bid.v1";
|
|
6815
|
+
var PROVER_MARKET_SUBMIT_DOMAIN = "prover_market.submit.v1";
|
|
6816
|
+
function proverMarketStateFromByte(b) {
|
|
6817
|
+
switch (b) {
|
|
6818
|
+
case 0:
|
|
6819
|
+
return "open";
|
|
6820
|
+
case 1:
|
|
6821
|
+
return "assigned";
|
|
6822
|
+
case 2:
|
|
6823
|
+
return "settled";
|
|
6824
|
+
case 3:
|
|
6825
|
+
return "slashed";
|
|
6826
|
+
case 4:
|
|
6827
|
+
return "expired";
|
|
6828
|
+
default:
|
|
6829
|
+
return null;
|
|
6830
|
+
}
|
|
6831
|
+
}
|
|
6832
|
+
var ProverMarketError = class extends Error {
|
|
6833
|
+
constructor(message) {
|
|
6834
|
+
super(message);
|
|
6835
|
+
this.name = "ProverMarketError";
|
|
6836
|
+
}
|
|
6837
|
+
};
|
|
6838
|
+
function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
6839
|
+
return bytesToHex7(
|
|
6840
|
+
keccak_256(
|
|
6841
|
+
concatBytes5(
|
|
6842
|
+
new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
|
|
6843
|
+
expectLength5(toBytes4(vkeyHash), 32, "vkeyHash"),
|
|
6844
|
+
expectLength5(toBytes4(inputsHash), 32, "inputsHash"),
|
|
6845
|
+
u128Bytes(maxFee, "maxFee"),
|
|
6846
|
+
u64Bytes(deadline, "deadline"),
|
|
6847
|
+
u64Bytes(nonce, "nonce")
|
|
6848
|
+
)
|
|
6849
|
+
)
|
|
6850
|
+
);
|
|
6851
|
+
}
|
|
6852
|
+
function bidSighash(requestId, fee) {
|
|
6853
|
+
return bytesToHex7(
|
|
6854
|
+
keccak_256(
|
|
6855
|
+
concatBytes5(
|
|
6856
|
+
new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
|
|
6857
|
+
expectLength5(toBytes4(requestId), 32, "requestId"),
|
|
6858
|
+
u128Bytes(fee, "fee")
|
|
6859
|
+
)
|
|
6860
|
+
)
|
|
6861
|
+
);
|
|
6862
|
+
}
|
|
6863
|
+
function submitSighash(requestId, proofHash) {
|
|
6864
|
+
return bytesToHex7(
|
|
6865
|
+
keccak_256(
|
|
6866
|
+
concatBytes5(
|
|
6867
|
+
new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
|
|
6868
|
+
expectLength5(toBytes4(requestId), 32, "requestId"),
|
|
6869
|
+
expectLength5(toBytes4(proofHash), 32, "proofHash")
|
|
6870
|
+
)
|
|
6871
|
+
)
|
|
6872
|
+
);
|
|
6873
|
+
}
|
|
6874
|
+
function encodeCreateRequestCanonical(args) {
|
|
6875
|
+
const buyer = expectLength5(toBytes4(args.buyer), 20, "buyer");
|
|
6876
|
+
const buyerPubkey = toBytes4(args.buyerPubkey);
|
|
6877
|
+
const sig = toBytes4(args.sig);
|
|
6878
|
+
if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
|
|
6879
|
+
throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
|
|
6880
|
+
}
|
|
6881
|
+
if (sig.length === 0 || sig.length > 65535) {
|
|
6882
|
+
throw new ProverMarketError("sig length out of range (1..=65535)");
|
|
6883
|
+
}
|
|
6884
|
+
return bytesToHex7(
|
|
6885
|
+
concatBytes5(
|
|
6886
|
+
buyer,
|
|
6887
|
+
u16Bytes(buyerPubkey.length),
|
|
6888
|
+
buyerPubkey,
|
|
6889
|
+
expectLength5(toBytes4(args.vkeyHash), 32, "vkeyHash"),
|
|
6890
|
+
expectLength5(toBytes4(args.inputsHash), 32, "inputsHash"),
|
|
6891
|
+
u128Bytes(args.maxFee, "maxFee"),
|
|
6892
|
+
u64Bytes(args.deadline, "deadline"),
|
|
6893
|
+
u64Bytes(args.nonce, "nonce"),
|
|
6894
|
+
u16Bytes(sig.length),
|
|
6895
|
+
sig
|
|
6896
|
+
)
|
|
6897
|
+
);
|
|
6898
|
+
}
|
|
6899
|
+
function encodeCreateRequestCalldata(args) {
|
|
6900
|
+
const canonical = toBytes4(encodeCreateRequestCanonical(args));
|
|
6901
|
+
const offset = new Uint8Array(32);
|
|
6902
|
+
offset[31] = 32;
|
|
6903
|
+
const lenWord = new Uint8Array(32);
|
|
6904
|
+
const len = canonical.length;
|
|
6905
|
+
lenWord[28] = len >>> 24 & 255;
|
|
6906
|
+
lenWord[29] = len >>> 16 & 255;
|
|
6907
|
+
lenWord[30] = len >>> 8 & 255;
|
|
6908
|
+
lenWord[31] = len & 255;
|
|
6909
|
+
const pad = (32 - len % 32) % 32;
|
|
6910
|
+
return bytesToHex7(
|
|
6911
|
+
concatBytes5(hexToBytes6(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
|
|
6912
|
+
);
|
|
6913
|
+
}
|
|
6914
|
+
function selectorHex2(sig) {
|
|
6915
|
+
return [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6916
|
+
}
|
|
6917
|
+
function toBytes4(value) {
|
|
6918
|
+
if (typeof value === "string") return hexToBytes6(value);
|
|
6919
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6920
|
+
}
|
|
6921
|
+
function hexToBytes6(hex) {
|
|
6922
|
+
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6923
|
+
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6924
|
+
throw new ProverMarketError("invalid hex bytes");
|
|
6925
|
+
}
|
|
6926
|
+
const out = new Uint8Array(b.length / 2);
|
|
6927
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6928
|
+
return out;
|
|
6929
|
+
}
|
|
6930
|
+
function bytesToHex7(bytes) {
|
|
6931
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6932
|
+
}
|
|
6933
|
+
function concatBytes5(...parts) {
|
|
6934
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6935
|
+
let offset = 0;
|
|
6936
|
+
for (const part of parts) {
|
|
6937
|
+
out.set(part, offset);
|
|
6938
|
+
offset += part.length;
|
|
6939
|
+
}
|
|
6940
|
+
return out;
|
|
6941
|
+
}
|
|
6942
|
+
function expectLength5(value, len, name) {
|
|
6943
|
+
if (value.length !== len) {
|
|
6944
|
+
throw new ProverMarketError(`${name} must be ${len} bytes, got ${value.length}`);
|
|
6945
|
+
}
|
|
6946
|
+
return value;
|
|
6947
|
+
}
|
|
6948
|
+
function toBigint2(value, name) {
|
|
6949
|
+
let n;
|
|
6950
|
+
if (typeof value === "bigint") n = value;
|
|
6951
|
+
else if (typeof value === "number") {
|
|
6952
|
+
if (!Number.isSafeInteger(value)) throw new ProverMarketError(`${name} must be a safe integer`);
|
|
6953
|
+
n = BigInt(value);
|
|
6954
|
+
} else if (/^(0|[1-9][0-9]*|0x[0-9a-fA-F]+)$/.test(value)) n = BigInt(value);
|
|
6955
|
+
else throw new ProverMarketError(`${name} must be a non-negative integer`);
|
|
6956
|
+
if (n < 0n) throw new ProverMarketError(`${name} must be non-negative`);
|
|
6957
|
+
return n;
|
|
6958
|
+
}
|
|
6959
|
+
function u16Bytes(value) {
|
|
6960
|
+
if (!Number.isInteger(value) || value < 0 || value > 65535) {
|
|
6961
|
+
throw new ProverMarketError("u16 value out of range");
|
|
6962
|
+
}
|
|
6963
|
+
return Uint8Array.from([value >> 8 & 255, value & 255]);
|
|
6964
|
+
}
|
|
6965
|
+
function u64Bytes(value, name) {
|
|
6966
|
+
const n = toBigint2(value, name);
|
|
6967
|
+
if (n > 0xffffffffffffffffn) throw new ProverMarketError(`${name} exceeds uint64`);
|
|
6968
|
+
return bigintBytes(n, 8);
|
|
6969
|
+
}
|
|
6970
|
+
function u128Bytes(value, name) {
|
|
6971
|
+
const n = toBigint2(value, name);
|
|
6972
|
+
if (n > (1n << 128n) - 1n) throw new ProverMarketError(`${name} exceeds uint128`);
|
|
6973
|
+
return bigintBytes(n, 16);
|
|
6974
|
+
}
|
|
6975
|
+
function bigintBytes(value, len) {
|
|
6976
|
+
const out = new Uint8Array(len);
|
|
6977
|
+
let n = value;
|
|
6978
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
6979
|
+
out[i] = Number(n & 0xffn);
|
|
6980
|
+
n >>= 8n;
|
|
6981
|
+
}
|
|
6982
|
+
return out;
|
|
6983
|
+
}
|
|
6387
6984
|
|
|
6388
6985
|
// src/delegation.ts
|
|
6389
6986
|
var DELEGATION_SELECTORS = {
|
|
@@ -6410,34 +7007,34 @@ function delegationAddressHex() {
|
|
|
6410
7007
|
return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
|
|
6411
7008
|
}
|
|
6412
7009
|
function encodeCompleteRedemptionCalldata(index) {
|
|
6413
|
-
return
|
|
6414
|
-
|
|
6415
|
-
|
|
7010
|
+
return bytesToHex8(
|
|
7011
|
+
concatBytes6(
|
|
7012
|
+
hexToBytes7(DELEGATION_SELECTORS.completeRedemption),
|
|
6416
7013
|
uint64Word2(index, "index")
|
|
6417
7014
|
)
|
|
6418
7015
|
);
|
|
6419
7016
|
}
|
|
6420
7017
|
function encodeDelegateCalldata(cluster, weightBps) {
|
|
6421
|
-
return
|
|
6422
|
-
|
|
6423
|
-
|
|
7018
|
+
return bytesToHex8(
|
|
7019
|
+
concatBytes6(
|
|
7020
|
+
hexToBytes7(DELEGATION_SELECTORS.delegate),
|
|
6424
7021
|
uint32Word2(cluster, "cluster"),
|
|
6425
7022
|
uint16Word(weightBps, "weightBps")
|
|
6426
7023
|
)
|
|
6427
7024
|
);
|
|
6428
7025
|
}
|
|
6429
7026
|
function encodeUndelegateCalldata(cluster) {
|
|
6430
|
-
return
|
|
6431
|
-
|
|
6432
|
-
|
|
7027
|
+
return bytesToHex8(
|
|
7028
|
+
concatBytes6(
|
|
7029
|
+
hexToBytes7(DELEGATION_SELECTORS.undelegate),
|
|
6433
7030
|
uint32Word2(cluster, "cluster")
|
|
6434
7031
|
)
|
|
6435
7032
|
);
|
|
6436
7033
|
}
|
|
6437
7034
|
function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
|
|
6438
|
-
return
|
|
6439
|
-
|
|
6440
|
-
|
|
7035
|
+
return bytesToHex8(
|
|
7036
|
+
concatBytes6(
|
|
7037
|
+
hexToBytes7(DELEGATION_SELECTORS.redelegate),
|
|
6441
7038
|
uint32Word2(fromCluster, "fromCluster"),
|
|
6442
7039
|
uint32Word2(toCluster, "toCluster"),
|
|
6443
7040
|
uint16Word(weightBps, "weightBps")
|
|
@@ -6450,15 +7047,15 @@ function encodeClaimCalldata() {
|
|
|
6450
7047
|
function encodeSetAutoCompoundCalldata(enabled) {
|
|
6451
7048
|
const flag = new Uint8Array(32);
|
|
6452
7049
|
flag[31] = enabled ? 1 : 0;
|
|
6453
|
-
return
|
|
6454
|
-
|
|
7050
|
+
return bytesToHex8(
|
|
7051
|
+
concatBytes6(hexToBytes7(DELEGATION_SELECTORS.setAutoCompound), flag)
|
|
6455
7052
|
);
|
|
6456
7053
|
}
|
|
6457
7054
|
function isRedemptionPrincipalUnavailableRevert(data) {
|
|
6458
|
-
return
|
|
7055
|
+
return bytesToHex8(toBytes5(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
|
|
6459
7056
|
}
|
|
6460
7057
|
function uint64Word2(value, name) {
|
|
6461
|
-
const n =
|
|
7058
|
+
const n = toBigint3(value, name);
|
|
6462
7059
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
6463
7060
|
throw new DelegationPrecompileError(`${name} must fit uint64`);
|
|
6464
7061
|
}
|
|
@@ -6471,7 +7068,7 @@ function uint64Word2(value, name) {
|
|
|
6471
7068
|
return out;
|
|
6472
7069
|
}
|
|
6473
7070
|
function uint32Word2(value, name) {
|
|
6474
|
-
const n =
|
|
7071
|
+
const n = toBigint3(value, name);
|
|
6475
7072
|
if (n < 0n || n > 0xffffffffn) {
|
|
6476
7073
|
throw new DelegationPrecompileError(`${name} must fit uint32`);
|
|
6477
7074
|
}
|
|
@@ -6484,7 +7081,7 @@ function uint32Word2(value, name) {
|
|
|
6484
7081
|
return out;
|
|
6485
7082
|
}
|
|
6486
7083
|
function uint16Word(value, name) {
|
|
6487
|
-
const n =
|
|
7084
|
+
const n = toBigint3(value, name);
|
|
6488
7085
|
if (n < 0n || n > 0xffffn) {
|
|
6489
7086
|
throw new DelegationPrecompileError(`${name} must fit uint16`);
|
|
6490
7087
|
}
|
|
@@ -6496,7 +7093,7 @@ function uint16Word(value, name) {
|
|
|
6496
7093
|
}
|
|
6497
7094
|
return out;
|
|
6498
7095
|
}
|
|
6499
|
-
function
|
|
7096
|
+
function toBigint3(value, name) {
|
|
6500
7097
|
if (typeof value === "bigint") return value;
|
|
6501
7098
|
if (typeof value === "number") {
|
|
6502
7099
|
if (!Number.isInteger(value) || !Number.isSafeInteger(value)) {
|
|
@@ -6509,13 +7106,13 @@ function toBigint2(value, name) {
|
|
|
6509
7106
|
}
|
|
6510
7107
|
return BigInt(value);
|
|
6511
7108
|
}
|
|
6512
|
-
function
|
|
7109
|
+
function toBytes5(value) {
|
|
6513
7110
|
if (typeof value === "string") {
|
|
6514
|
-
return
|
|
7111
|
+
return hexToBytes7(value);
|
|
6515
7112
|
}
|
|
6516
7113
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6517
7114
|
}
|
|
6518
|
-
function
|
|
7115
|
+
function hexToBytes7(hex) {
|
|
6519
7116
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6520
7117
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6521
7118
|
throw new DelegationPrecompileError("invalid hex bytes");
|
|
@@ -6526,10 +7123,10 @@ function hexToBytes5(hex) {
|
|
|
6526
7123
|
}
|
|
6527
7124
|
return out;
|
|
6528
7125
|
}
|
|
6529
|
-
function
|
|
7126
|
+
function bytesToHex8(bytes) {
|
|
6530
7127
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6531
7128
|
}
|
|
6532
|
-
function
|
|
7129
|
+
function concatBytes6(...parts) {
|
|
6533
7130
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6534
7131
|
let offset = 0;
|
|
6535
7132
|
for (const part of parts) {
|
|
@@ -6544,9 +7141,11 @@ var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
|
|
|
6544
7141
|
var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
|
|
6545
7142
|
var ML_DSA_65_SIGNATURE_LEN2 = 3309;
|
|
6546
7143
|
var SPENDING_POLICY_SELECTORS = {
|
|
6547
|
-
setPolicy
|
|
6548
|
-
|
|
6549
|
-
|
|
7144
|
+
// WP §18.8 widened the setPolicy* sighash strings to 11 words, so their
|
|
7145
|
+
// selectors changed; enable/disable/recordSpend are unchanged.
|
|
7146
|
+
setPolicy: "0x8da1a765",
|
|
7147
|
+
setPolicyClaim: "0x35531f6c",
|
|
7148
|
+
claimPolicyByAddress: "0x0c21376c",
|
|
6550
7149
|
enable: "0x5bfa1b68",
|
|
6551
7150
|
disable: "0xe6c09edf",
|
|
6552
7151
|
recordSpend: "0xdca04292"
|
|
@@ -6563,7 +7162,7 @@ function spendingPolicyAddressHex() {
|
|
|
6563
7162
|
function composeClaimBoundMessage(chainId, args, opts) {
|
|
6564
7163
|
const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
|
|
6565
7164
|
const normalized = normalizeArgs(args);
|
|
6566
|
-
return
|
|
7165
|
+
return concatBytes7(
|
|
6567
7166
|
new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
|
|
6568
7167
|
uint64Bytes(chainId, "chainId"),
|
|
6569
7168
|
precompileAddress,
|
|
@@ -6573,22 +7172,30 @@ function composeClaimBoundMessage(chainId, args, opts) {
|
|
|
6573
7172
|
uint128Bytes(normalized.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
6574
7173
|
normalized.allowRoot,
|
|
6575
7174
|
normalized.denyRoot,
|
|
7175
|
+
// WP §18.8 dimensions, in wire order: weekly cap (be16), monthly cap
|
|
7176
|
+
// (be16), category allow-root (32), packed time window (32),
|
|
7177
|
+
// policy expiry (be8). These slot in before the expected-version word.
|
|
7178
|
+
uint128Bytes(normalized.weeklyCapLythoshi, "weeklyCapLythoshi"),
|
|
7179
|
+
uint128Bytes(normalized.monthlyCapLythoshi, "monthlyCapLythoshi"),
|
|
7180
|
+
normalized.categoryAllowRoot,
|
|
7181
|
+
normalized.timeWindow,
|
|
7182
|
+
uint64Bytes(normalized.policyExpiry, "policyExpiry"),
|
|
6576
7183
|
uint64Bytes(opts?.expectedPolicyVersion ?? 0n, "expectedPolicyVersion")
|
|
6577
7184
|
);
|
|
6578
7185
|
}
|
|
6579
7186
|
function encodeSetPolicyCalldata(args) {
|
|
6580
7187
|
const normalized = normalizeArgs(args);
|
|
6581
|
-
return
|
|
6582
|
-
|
|
6583
|
-
|
|
7188
|
+
return bytesToHex9(
|
|
7189
|
+
concatBytes7(
|
|
7190
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicy),
|
|
6584
7191
|
encodePolicyWords(normalized)
|
|
6585
7192
|
)
|
|
6586
7193
|
);
|
|
6587
7194
|
}
|
|
6588
7195
|
function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
6589
7196
|
const normalized = normalizeArgs(args);
|
|
6590
|
-
const pubkey =
|
|
6591
|
-
const sig =
|
|
7197
|
+
const pubkey = toBytes6(subAccountPubkey);
|
|
7198
|
+
const sig = toBytes6(subAccountSig);
|
|
6592
7199
|
if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
|
|
6593
7200
|
throw new SpendingPolicyError(
|
|
6594
7201
|
`subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
|
|
@@ -6599,9 +7206,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
6599
7206
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
6600
7207
|
);
|
|
6601
7208
|
}
|
|
6602
|
-
return
|
|
6603
|
-
|
|
6604
|
-
|
|
7209
|
+
return bytesToHex9(
|
|
7210
|
+
concatBytes7(
|
|
7211
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicyClaim),
|
|
6605
7212
|
encodePolicyWords(normalized),
|
|
6606
7213
|
pubkey,
|
|
6607
7214
|
sig
|
|
@@ -6610,15 +7217,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
6610
7217
|
}
|
|
6611
7218
|
function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
|
|
6612
7219
|
const normalized = normalizeArgs(args);
|
|
6613
|
-
const sig =
|
|
7220
|
+
const sig = toBytes6(subAccountSig);
|
|
6614
7221
|
if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
|
|
6615
7222
|
throw new SpendingPolicyError(
|
|
6616
7223
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
6617
7224
|
);
|
|
6618
7225
|
}
|
|
6619
|
-
return
|
|
6620
|
-
|
|
6621
|
-
|
|
7226
|
+
return bytesToHex9(
|
|
7227
|
+
concatBytes7(
|
|
7228
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
|
|
6622
7229
|
encodePolicyWords(normalized),
|
|
6623
7230
|
sig
|
|
6624
7231
|
)
|
|
@@ -6630,34 +7237,70 @@ function encodeEnableCalldata(subAccount) {
|
|
|
6630
7237
|
function encodeDisableCalldata(subAccount) {
|
|
6631
7238
|
return encodeSingleAddressCall(SPENDING_POLICY_SELECTORS.disable, subAccount, "subAccount");
|
|
6632
7239
|
}
|
|
7240
|
+
var ZERO_WORD = new Uint8Array(32);
|
|
6633
7241
|
function normalizeArgs(args) {
|
|
6634
7242
|
return {
|
|
6635
7243
|
subAccount: toUserAddressBytes(args.subAccount, "subAccount"),
|
|
6636
7244
|
principal: toUserAddressBytes(args.principal, "principal"),
|
|
6637
|
-
dailyCapLythoshi:
|
|
6638
|
-
perTxCapLythoshi:
|
|
6639
|
-
allowRoot:
|
|
6640
|
-
denyRoot:
|
|
7245
|
+
dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
|
|
7246
|
+
perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
7247
|
+
allowRoot: expectLength6(toBytes6(args.allowRoot), 32, "allowRoot"),
|
|
7248
|
+
denyRoot: expectLength6(toBytes6(args.denyRoot), 32, "denyRoot"),
|
|
7249
|
+
weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
|
|
7250
|
+
monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
|
|
7251
|
+
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes6(args.categoryAllowRoot), 32, "categoryAllowRoot"),
|
|
7252
|
+
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes6(args.timeWindow), 32, "timeWindow"),
|
|
7253
|
+
policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
|
|
6641
7254
|
};
|
|
6642
7255
|
}
|
|
6643
7256
|
function encodePolicyWords(args) {
|
|
6644
|
-
return
|
|
7257
|
+
return concatBytes7(
|
|
6645
7258
|
encodeAddressWord(args.subAccount),
|
|
6646
7259
|
encodeAddressWord(args.principal),
|
|
6647
7260
|
encodeUint128Word(args.dailyCapLythoshi),
|
|
6648
7261
|
encodeUint128Word(args.perTxCapLythoshi),
|
|
6649
7262
|
args.allowRoot,
|
|
6650
|
-
args.denyRoot
|
|
7263
|
+
args.denyRoot,
|
|
7264
|
+
// WP §18.8 trailing 5 words: weekly cap, monthly cap, category
|
|
7265
|
+
// allow-root, packed time window, policy expiry.
|
|
7266
|
+
encodeUint128Word(args.weeklyCapLythoshi),
|
|
7267
|
+
encodeUint128Word(args.monthlyCapLythoshi),
|
|
7268
|
+
args.categoryAllowRoot,
|
|
7269
|
+
args.timeWindow,
|
|
7270
|
+
encodeUint64Word(args.policyExpiry)
|
|
6651
7271
|
);
|
|
6652
7272
|
}
|
|
7273
|
+
function packTimeWindow(enabled, startHour, endHour) {
|
|
7274
|
+
const out = new Uint8Array(32);
|
|
7275
|
+
if (!enabled) return out;
|
|
7276
|
+
out[29] = 1;
|
|
7277
|
+
out[30] = clampHour(startHour);
|
|
7278
|
+
out[31] = clampHour(endHour);
|
|
7279
|
+
return out;
|
|
7280
|
+
}
|
|
7281
|
+
function decodeTimeWindow(word) {
|
|
7282
|
+
const bytes = expectLength6(toBytes6(word), 32, "timeWindow");
|
|
7283
|
+
if (bytes.every((b) => b === 0)) return null;
|
|
7284
|
+
if (bytes[29] === 0) return null;
|
|
7285
|
+
return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
|
|
7286
|
+
}
|
|
7287
|
+
function clampHour(hour) {
|
|
7288
|
+
if (!Number.isInteger(hour) || hour < 0) {
|
|
7289
|
+
throw new SpendingPolicyError("time-window hour must be a non-negative integer");
|
|
7290
|
+
}
|
|
7291
|
+
return Math.min(hour, 23);
|
|
7292
|
+
}
|
|
7293
|
+
function encodeUint64Word(value) {
|
|
7294
|
+
return concatBytes7(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
|
|
7295
|
+
}
|
|
6653
7296
|
function encodeSingleAddressCall(selector, address, name) {
|
|
6654
|
-
return
|
|
7297
|
+
return bytesToHex9(concatBytes7(hexToBytes8(selector), encodeAddressWord(toUserAddressBytes(address, name))));
|
|
6655
7298
|
}
|
|
6656
7299
|
function encodeAddressWord(address) {
|
|
6657
|
-
return
|
|
7300
|
+
return concatBytes7(new Uint8Array(12), address);
|
|
6658
7301
|
}
|
|
6659
7302
|
function encodeUint128Word(value) {
|
|
6660
|
-
return
|
|
7303
|
+
return concatBytes7(new Uint8Array(16), uint128Bytes(value, "uint128"));
|
|
6661
7304
|
}
|
|
6662
7305
|
function toUserAddressBytes(value, name) {
|
|
6663
7306
|
if (typeof value !== "string") {
|
|
@@ -6677,15 +7320,15 @@ function toRawAddressBytes(value) {
|
|
|
6677
7320
|
if (typeof value === "string") {
|
|
6678
7321
|
return hexToAddressBytes(value);
|
|
6679
7322
|
}
|
|
6680
|
-
return
|
|
7323
|
+
return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
|
|
6681
7324
|
}
|
|
6682
|
-
function
|
|
7325
|
+
function toBytes6(value) {
|
|
6683
7326
|
if (typeof value === "string") {
|
|
6684
|
-
return
|
|
7327
|
+
return hexToBytes8(value);
|
|
6685
7328
|
}
|
|
6686
7329
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6687
7330
|
}
|
|
6688
|
-
function
|
|
7331
|
+
function hexToBytes8(hex) {
|
|
6689
7332
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6690
7333
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6691
7334
|
throw new SpendingPolicyError("invalid hex bytes");
|
|
@@ -6696,10 +7339,10 @@ function hexToBytes6(hex) {
|
|
|
6696
7339
|
}
|
|
6697
7340
|
return out;
|
|
6698
7341
|
}
|
|
6699
|
-
function
|
|
7342
|
+
function bytesToHex9(bytes) {
|
|
6700
7343
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6701
7344
|
}
|
|
6702
|
-
function
|
|
7345
|
+
function concatBytes7(...parts) {
|
|
6703
7346
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6704
7347
|
let offset = 0;
|
|
6705
7348
|
for (const part of parts) {
|
|
@@ -6708,13 +7351,13 @@ function concatBytes6(...parts) {
|
|
|
6708
7351
|
}
|
|
6709
7352
|
return out;
|
|
6710
7353
|
}
|
|
6711
|
-
function
|
|
7354
|
+
function expectLength6(value, len, name) {
|
|
6712
7355
|
if (value.length !== len) {
|
|
6713
7356
|
throw new SpendingPolicyError(`${name} must be ${len} bytes`);
|
|
6714
7357
|
}
|
|
6715
7358
|
return value;
|
|
6716
7359
|
}
|
|
6717
|
-
function
|
|
7360
|
+
function toBigint4(value, name) {
|
|
6718
7361
|
const n = typeof value === "bigint" ? value : BigInt(value);
|
|
6719
7362
|
if (n < 0n) {
|
|
6720
7363
|
throw new SpendingPolicyError(`${name} must be non-negative`);
|
|
@@ -6722,19 +7365,19 @@ function toBigint3(value, name) {
|
|
|
6722
7365
|
return n;
|
|
6723
7366
|
}
|
|
6724
7367
|
function uint64Bytes(value, name) {
|
|
6725
|
-
const n =
|
|
7368
|
+
const n = toBigint4(value, name);
|
|
6726
7369
|
if (n > 0xffffffffffffffffn) {
|
|
6727
7370
|
throw new SpendingPolicyError(`${name} exceeds uint64`);
|
|
6728
7371
|
}
|
|
6729
|
-
return
|
|
7372
|
+
return bigintBytes2(n, 8);
|
|
6730
7373
|
}
|
|
6731
7374
|
function uint128Bytes(value, name) {
|
|
6732
7375
|
if (value > 0xffffffffffffffffffffffffffffffffn) {
|
|
6733
7376
|
throw new SpendingPolicyError(`${name} exceeds uint128`);
|
|
6734
7377
|
}
|
|
6735
|
-
return
|
|
7378
|
+
return bigintBytes2(value, 16);
|
|
6736
7379
|
}
|
|
6737
|
-
function
|
|
7380
|
+
function bigintBytes2(value, len) {
|
|
6738
7381
|
const out = new Uint8Array(len);
|
|
6739
7382
|
let n = value;
|
|
6740
7383
|
for (let i = len - 1; i >= 0; i--) {
|
|
@@ -6761,15 +7404,15 @@ function pubkeyRegistryAddressHex() {
|
|
|
6761
7404
|
return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
|
|
6762
7405
|
}
|
|
6763
7406
|
function encodeRegisterPubkeyCalldata(pubkey) {
|
|
6764
|
-
const bytes =
|
|
7407
|
+
const bytes = toBytes7(pubkey);
|
|
6765
7408
|
if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
6766
7409
|
throw new PubkeyRegistryError(
|
|
6767
7410
|
`pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
|
|
6768
7411
|
);
|
|
6769
7412
|
}
|
|
6770
|
-
return
|
|
6771
|
-
|
|
6772
|
-
|
|
7413
|
+
return bytesToHex10(
|
|
7414
|
+
concatBytes8(
|
|
7415
|
+
hexToBytes9(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
|
|
6773
7416
|
uint256Word(32n),
|
|
6774
7417
|
uint256Word(BigInt(bytes.length)),
|
|
6775
7418
|
bytes
|
|
@@ -6783,7 +7426,7 @@ function encodeHasPubkeyCalldata(address) {
|
|
|
6783
7426
|
return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
|
|
6784
7427
|
}
|
|
6785
7428
|
function decodeLookupPubkeyReturn(data) {
|
|
6786
|
-
const bytes =
|
|
7429
|
+
const bytes = toBytes7(data);
|
|
6787
7430
|
if (bytes.length < 96) {
|
|
6788
7431
|
throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
|
|
6789
7432
|
}
|
|
@@ -6808,7 +7451,7 @@ function decodeLookupPubkeyReturn(data) {
|
|
|
6808
7451
|
};
|
|
6809
7452
|
}
|
|
6810
7453
|
function decodeHasPubkeyReturn(data) {
|
|
6811
|
-
const bytes =
|
|
7454
|
+
const bytes = toBytes7(data);
|
|
6812
7455
|
if (bytes.length !== 32) {
|
|
6813
7456
|
throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
|
|
6814
7457
|
}
|
|
@@ -6822,10 +7465,10 @@ function decodeHasPubkeyReturn(data) {
|
|
|
6822
7465
|
throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
|
|
6823
7466
|
}
|
|
6824
7467
|
function encodeSingleAddressCall2(selector, address) {
|
|
6825
|
-
return
|
|
7468
|
+
return bytesToHex10(concatBytes8(hexToBytes9(selector), addressWord(toAddressBytes(address))));
|
|
6826
7469
|
}
|
|
6827
7470
|
function addressWord(address) {
|
|
6828
|
-
return
|
|
7471
|
+
return concatBytes8(new Uint8Array(12), address);
|
|
6829
7472
|
}
|
|
6830
7473
|
function toAddressBytes(value) {
|
|
6831
7474
|
if (typeof value !== "string") {
|
|
@@ -6841,13 +7484,13 @@ function toAddressBytes(value) {
|
|
|
6841
7484
|
throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
|
|
6842
7485
|
}
|
|
6843
7486
|
}
|
|
6844
|
-
function
|
|
7487
|
+
function toBytes7(value) {
|
|
6845
7488
|
if (typeof value === "string") {
|
|
6846
|
-
return
|
|
7489
|
+
return hexToBytes9(value);
|
|
6847
7490
|
}
|
|
6848
7491
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6849
7492
|
}
|
|
6850
|
-
function
|
|
7493
|
+
function hexToBytes9(hex) {
|
|
6851
7494
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6852
7495
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6853
7496
|
throw new PubkeyRegistryError("invalid hex bytes");
|
|
@@ -6858,10 +7501,10 @@ function hexToBytes7(hex) {
|
|
|
6858
7501
|
}
|
|
6859
7502
|
return out;
|
|
6860
7503
|
}
|
|
6861
|
-
function
|
|
7504
|
+
function bytesToHex10(bytes) {
|
|
6862
7505
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6863
7506
|
}
|
|
6864
|
-
function
|
|
7507
|
+
function concatBytes8(...parts) {
|
|
6865
7508
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6866
7509
|
let offset = 0;
|
|
6867
7510
|
for (const part of parts) {
|
|
@@ -6922,8 +7565,47 @@ var CLOB_SELECTORS = {
|
|
|
6922
7565
|
*/
|
|
6923
7566
|
placeMarketOrderEx: "0xa6f092f0",
|
|
6924
7567
|
/** `cancelOrder(bytes32)` */
|
|
6925
|
-
cancelOrder: "0x7489ec23"
|
|
7568
|
+
cancelOrder: "0x7489ec23",
|
|
7569
|
+
/** `setMinNotional(bytes32,bytes32,uint256)` — foundation-authorized. */
|
|
7570
|
+
setMinNotional: "0x395dc48f",
|
|
7571
|
+
/** `setTickSize(bytes32,bytes32,uint256)` — foundation-authorized per-market grid tune. */
|
|
7572
|
+
setTickSize: "0x10666f0b",
|
|
7573
|
+
/** `setLotSize(bytes32,bytes32,uint256)` — foundation-authorized per-market grid tune. */
|
|
7574
|
+
setLotSize: "0x9909be80"
|
|
7575
|
+
};
|
|
7576
|
+
var OPERATOR_ROUTER_SIGS = {
|
|
7577
|
+
/** `registerOperator(address recipient, uint16 feeBps)`. */
|
|
7578
|
+
registerOperator: "registerOperator(address,uint16)",
|
|
7579
|
+
/** `updateOperator(address recipient, uint16 feeBps)`. */
|
|
7580
|
+
updateOperator: "updateOperator(address,uint16)",
|
|
7581
|
+
/** `disableOperator(address operator)` — foundation-authorized. */
|
|
7582
|
+
disableOperator: "disableOperator(address)",
|
|
7583
|
+
/**
|
|
7584
|
+
* `placeLimitOrderVia(address operator, bytes32 base, bytes32 quote,
|
|
7585
|
+
* uint8 side, uint256 price, uint256 amount, uint64 expiresAtBlock)`
|
|
7586
|
+
* → `bytes32 orderId`.
|
|
7587
|
+
*
|
|
7588
|
+
* Skims the operator fee (quote token, `user -> recipient`) then
|
|
7589
|
+
* re-enters the CLOB `placeLimitOrder` op with `caller = user`, so the
|
|
7590
|
+
* resting order is owned + escrowed + cancellable by the user,
|
|
7591
|
+
* identical to a direct CLOB placement.
|
|
7592
|
+
*/
|
|
7593
|
+
placeLimitOrderVia: "placeLimitOrderVia(address,bytes32,bytes32,uint8,uint256,uint256,uint64)"
|
|
7594
|
+
};
|
|
7595
|
+
var OPERATOR_ROUTER_SELECTORS = {
|
|
7596
|
+
registerOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.registerOperator),
|
|
7597
|
+
updateOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.updateOperator),
|
|
7598
|
+
disableOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.disableOperator),
|
|
7599
|
+
placeLimitOrderVia: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.placeLimitOrderVia)
|
|
6926
7600
|
};
|
|
7601
|
+
var OPERATOR_ROUTER_EVENT_SIGS = {
|
|
7602
|
+
operatorFeeCharged: "OperatorFeeCharged(address,address,bytes32,address,bytes32,uint256,bytes32)",
|
|
7603
|
+
operatorRegistered: "OperatorRegistered(address,address,uint16)",
|
|
7604
|
+
operatorUpdated: "OperatorUpdated(address,address,uint16,bool)"
|
|
7605
|
+
};
|
|
7606
|
+
function operatorRouterSelectorHex(sig) {
|
|
7607
|
+
return "0x" + [...keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7608
|
+
}
|
|
6927
7609
|
var MarketActionError = class extends Error {
|
|
6928
7610
|
constructor(message) {
|
|
6929
7611
|
super(message);
|
|
@@ -7020,6 +7702,25 @@ function encodeCancelOrderCalldata(args) {
|
|
|
7020
7702
|
)
|
|
7021
7703
|
);
|
|
7022
7704
|
}
|
|
7705
|
+
function encodeMarketGridTuneCalldata(selector, label, args) {
|
|
7706
|
+
return bytesToHex2(
|
|
7707
|
+
concatBytes2(
|
|
7708
|
+
hexToBytes2(selector, `${label} selector`),
|
|
7709
|
+
bytes32FromHex(args.baseTokenId, "baseTokenId"),
|
|
7710
|
+
bytes32FromHex(args.quoteTokenId, "quoteTokenId"),
|
|
7711
|
+
uint256Word2(BigInt(args.newValue), "newValue")
|
|
7712
|
+
)
|
|
7713
|
+
);
|
|
7714
|
+
}
|
|
7715
|
+
function encodeSetMinNotionalCalldata(args) {
|
|
7716
|
+
return encodeMarketGridTuneCalldata(CLOB_SELECTORS.setMinNotional, "setMinNotional", args);
|
|
7717
|
+
}
|
|
7718
|
+
function encodeSetTickSizeCalldata(args) {
|
|
7719
|
+
return encodeMarketGridTuneCalldata(CLOB_SELECTORS.setTickSize, "setTickSize", args);
|
|
7720
|
+
}
|
|
7721
|
+
function encodeSetLotSizeCalldata(args) {
|
|
7722
|
+
return encodeMarketGridTuneCalldata(CLOB_SELECTORS.setLotSize, "setLotSize", args);
|
|
7723
|
+
}
|
|
7023
7724
|
function encodeNativeSpotLimitOrderCall(args) {
|
|
7024
7725
|
const w = new BincodeWriter();
|
|
7025
7726
|
w.enumVariant(0);
|
|
@@ -7283,6 +7984,92 @@ function buildCancelSpotOrderPlan(args) {
|
|
|
7283
7984
|
mempoolClass: MempoolClass.CLOBOp
|
|
7284
7985
|
};
|
|
7285
7986
|
}
|
|
7987
|
+
function encodePlaceLimitOrderViaCalldata(args) {
|
|
7988
|
+
const operator = normalizeNativeMarketAddress(args.operator, "operator");
|
|
7989
|
+
if (operator.kind !== "user") {
|
|
7990
|
+
throw new MarketActionError("operator must be a 'mono' user address");
|
|
7991
|
+
}
|
|
7992
|
+
const side = normalizeSide(args.side);
|
|
7993
|
+
const price = positiveDecimal(args.price, "price");
|
|
7994
|
+
const amount = positiveDecimal(args.amount, "amount");
|
|
7995
|
+
const expiresAtBlock = uint64(args.expiresAtBlock ?? 0n, "expiresAtBlock");
|
|
7996
|
+
return bytesToHex2(
|
|
7997
|
+
concatBytes2(
|
|
7998
|
+
hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
|
|
7999
|
+
addressWord2(operator.bytes),
|
|
8000
|
+
bytes32FromHex(args.base, "base"),
|
|
8001
|
+
bytes32FromHex(args.quote, "quote"),
|
|
8002
|
+
uint8Word2(side),
|
|
8003
|
+
uint256Word2(price, "price"),
|
|
8004
|
+
uint256Word2(amount, "amount"),
|
|
8005
|
+
uint64Word3(expiresAtBlock, "expiresAtBlock")
|
|
8006
|
+
)
|
|
8007
|
+
);
|
|
8008
|
+
}
|
|
8009
|
+
function quoteOperatorFee(args, feeBps) {
|
|
8010
|
+
if (!Number.isInteger(feeBps) || feeBps < 0 || feeBps > PROTOCOL_MAX_OPERATOR_FEE_BPS) {
|
|
8011
|
+
throw new MarketActionError(
|
|
8012
|
+
`feeBps must be an integer in 0..=${PROTOCOL_MAX_OPERATOR_FEE_BPS}`
|
|
8013
|
+
);
|
|
8014
|
+
}
|
|
8015
|
+
const operator = normalizeNativeMarketAddress(args.operator, "operator");
|
|
8016
|
+
if (operator.kind !== "user") {
|
|
8017
|
+
throw new MarketActionError("operator must be a 'mono' user address");
|
|
8018
|
+
}
|
|
8019
|
+
const price = positiveDecimal(args.price, "price");
|
|
8020
|
+
const amount = positiveDecimal(args.amount, "amount");
|
|
8021
|
+
const quoteBasis = price * amount;
|
|
8022
|
+
const feeAmount = quoteBasis * BigInt(feeBps) / 10000n;
|
|
8023
|
+
return {
|
|
8024
|
+
operator: args.operator,
|
|
8025
|
+
feeBps,
|
|
8026
|
+
quoteBasis: quoteBasis.toString(10),
|
|
8027
|
+
feeAmount: feeAmount.toString(10)
|
|
8028
|
+
};
|
|
8029
|
+
}
|
|
8030
|
+
function buildPlaceLimitOrderViaPlan(args, feeBps) {
|
|
8031
|
+
return {
|
|
8032
|
+
method: "eth_sendTransaction",
|
|
8033
|
+
params: [
|
|
8034
|
+
{
|
|
8035
|
+
to: PRECOMPILE_ADDRESSES.OPERATOR_ROUTER,
|
|
8036
|
+
value: "0x0",
|
|
8037
|
+
data: encodePlaceLimitOrderViaCalldata(args)
|
|
8038
|
+
}
|
|
8039
|
+
],
|
|
8040
|
+
mempoolClass: MempoolClass.CLOBOp,
|
|
8041
|
+
operatorFee: quoteOperatorFee(args, feeBps)
|
|
8042
|
+
};
|
|
8043
|
+
}
|
|
8044
|
+
function decodeOperatorFeeChargedEvent(topics, data) {
|
|
8045
|
+
if (topics.length !== 4) {
|
|
8046
|
+
throw new MarketActionError(
|
|
8047
|
+
`OperatorFeeCharged expects 4 topics, got ${topics.length}`
|
|
8048
|
+
);
|
|
8049
|
+
}
|
|
8050
|
+
const topic0 = bytesToHex2(expectWordLen(toEventBytes(topics[0]), "topic0"));
|
|
8051
|
+
const expected = bytesToHex2(
|
|
8052
|
+
keccak_256(new TextEncoder().encode(OPERATOR_ROUTER_EVENT_SIGS.operatorFeeCharged))
|
|
8053
|
+
);
|
|
8054
|
+
if (topic0 !== expected) {
|
|
8055
|
+
throw new MarketActionError("topic0 is not OperatorFeeCharged");
|
|
8056
|
+
}
|
|
8057
|
+
const body = toEventBytes(data);
|
|
8058
|
+
if (body.length !== 4 * 32) {
|
|
8059
|
+
throw new MarketActionError(
|
|
8060
|
+
`OperatorFeeCharged expects 128 data bytes, got ${body.length}`
|
|
8061
|
+
);
|
|
8062
|
+
}
|
|
8063
|
+
return {
|
|
8064
|
+
operator: addressFromEventTopic(topics[1]),
|
|
8065
|
+
user: addressFromEventTopic(topics[2]),
|
|
8066
|
+
marketId: bytesToHex2(expectWordLen(toEventBytes(topics[3]), "marketId")),
|
|
8067
|
+
recipient: bytesToHex2(body.subarray(12, 32)),
|
|
8068
|
+
quoteToken: bytesToHex2(body.subarray(32, 64)),
|
|
8069
|
+
feeAmount: u256DecimalWord(body.subarray(64, 96)),
|
|
8070
|
+
clobOrderId: bytesToHex2(body.subarray(96, 128))
|
|
8071
|
+
};
|
|
8072
|
+
}
|
|
7286
8073
|
function buildNativeCallForwarderArtifact(requestBytes) {
|
|
7287
8074
|
const size = uint64(requestBytes, "requestBytes");
|
|
7288
8075
|
if (size === 0n) {
|
|
@@ -7538,6 +8325,32 @@ function uint256Word2(value, name) {
|
|
|
7538
8325
|
}
|
|
7539
8326
|
return out;
|
|
7540
8327
|
}
|
|
8328
|
+
function addressWord2(addr) {
|
|
8329
|
+
if (addr.length !== 20) {
|
|
8330
|
+
throw new MarketActionError("address must be 20 bytes");
|
|
8331
|
+
}
|
|
8332
|
+
const out = new Uint8Array(32);
|
|
8333
|
+
out.set(addr, 12);
|
|
8334
|
+
return out;
|
|
8335
|
+
}
|
|
8336
|
+
function toEventBytes(value) {
|
|
8337
|
+
if (typeof value === "string") return hexToBytes2(value, "event word");
|
|
8338
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
8339
|
+
}
|
|
8340
|
+
function expectWordLen(value, name) {
|
|
8341
|
+
if (value.length !== 32) {
|
|
8342
|
+
throw new MarketActionError(`${name} must be 32 bytes, got ${value.length}`);
|
|
8343
|
+
}
|
|
8344
|
+
return value;
|
|
8345
|
+
}
|
|
8346
|
+
function addressFromEventTopic(topic) {
|
|
8347
|
+
return bytesToHex2(expectWordLen(toEventBytes(topic), "address topic").subarray(12, 32));
|
|
8348
|
+
}
|
|
8349
|
+
function u256DecimalWord(word) {
|
|
8350
|
+
let v = 0n;
|
|
8351
|
+
for (const b of word) v = v << 8n | BigInt(b);
|
|
8352
|
+
return v.toString(10);
|
|
8353
|
+
}
|
|
7541
8354
|
function spotLimitOrderInto(w, args, prefix) {
|
|
7542
8355
|
w.rawBytes(bytes32FromHex(args.marketId, `${prefix}marketId`));
|
|
7543
8356
|
monoAddressInto(w, args.owner, `${prefix}owner`);
|
|
@@ -8054,6 +8867,6 @@ var MONOLYTHIUM_NETWORKS = {
|
|
|
8054
8867
|
// src/index.ts
|
|
8055
8868
|
var version = "0.2.2";
|
|
8056
8869
|
|
|
8057
|
-
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, encodeSetPolicyCalldata, encodeSetPolicyClaimCalldata, 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 };
|
|
8870
|
+
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, 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, 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, RESERVED_ADDRESS_HRPS, RpcClient, SERVES_GPU_PROVE, 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, 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, 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, resolveStudioHostStatus, selectBridgeTransferRoute, serviceProbeStatusLabel, spendingPolicyAddressHex, submitMrvCallNativeTx, submitMrvDeployNativeTx, submitMrvDeployPayloadNativeTx, submitSighash, typedBech32ToAddress, validateAddress, validateBridgeRouteCatalogue, validateMrvArtifactMetadata, validateMrvCallRequest, validateMrvDeployRequest, verifyNoEvmArchiveProofSignatures, verifyNoEvmBlockFinalityEvidenceMultisig, verifyNoEvmBlockFinalityEvidenceThreshold, verifyNoEvmFinalityEvidenceMultisig, verifyNoEvmFinalityEvidenceThreshold, verifyNoEvmReceiptProof, verifyNoEvmReceiptProofTrust, version };
|
|
8058
8871
|
//# sourceMappingURL=index.js.map
|
|
8059
8872
|
//# sourceMappingURL=index.js.map
|