@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.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var blake3_js = require('@noble/hashes/blake3.js');
|
|
4
|
+
var sha3_js = require('@noble/hashes/sha3.js');
|
|
4
5
|
var mlKem_js = require('@noble/post-quantum/ml-kem.js');
|
|
5
6
|
var chacha_js = require('@noble/ciphers/chacha.js');
|
|
6
|
-
var sha3_js = require('@noble/hashes/sha3.js');
|
|
7
7
|
var utils_js = require('@noble/hashes/utils.js');
|
|
8
8
|
var mlDsa_js = require('@noble/post-quantum/ml-dsa.js');
|
|
9
9
|
var bls12381_js = require('@noble/curves/bls12-381.js');
|
|
@@ -361,6 +361,10 @@ var PRECOMPILE_ADDRESSES = {
|
|
|
361
361
|
ORACLE: "0x0000000000000000000000000000000000001009",
|
|
362
362
|
/** Distributed delegation primitive — gateable. */
|
|
363
363
|
DELEGATION: "0x000000000000000000000000000000000000100A",
|
|
364
|
+
/** Operator-fee router — skims an operator surcharge on routed CLOB ops; gateable. */
|
|
365
|
+
OPERATOR_ROUTER: "0x000000000000000000000000000000000000100B",
|
|
366
|
+
/** GPU prover market — gateable, genesis-disabled (foundation milestone flip). */
|
|
367
|
+
PROVER_MARKET: "0x000000000000000000000000000000000000100C",
|
|
364
368
|
/** One-time emergency-key registry — non-gateable. */
|
|
365
369
|
EMERGENCY_KEY: "0x0000000000000000000000000000000000001100",
|
|
366
370
|
/** VRF precompile. */
|
|
@@ -390,6 +394,8 @@ var PRECOMPILE_ADDRESSES = {
|
|
|
390
394
|
/** Hierarchical name registry — gateable. */
|
|
391
395
|
NAME_REGISTRY: "0x000000000000000000000000000000000000110E"
|
|
392
396
|
};
|
|
397
|
+
var OPERATOR_ROUTER_ADDRESS = PRECOMPILE_ADDRESSES.OPERATOR_ROUTER;
|
|
398
|
+
var PROTOCOL_MAX_OPERATOR_FEE_BPS = 100;
|
|
393
399
|
|
|
394
400
|
// src/node-registry.ts
|
|
395
401
|
var NODE_REGISTRY_CAPABILITIES = {
|
|
@@ -401,8 +407,12 @@ var NODE_REGISTRY_CAPABILITIES = {
|
|
|
401
407
|
SERVES_LIGHT_CLIENT: 32,
|
|
402
408
|
SERVES_ORACLE_WRITER: 64,
|
|
403
409
|
SERVES_BRIDGE_RELAY: 128,
|
|
404
|
-
SERVES_PUBLIC_API: 256
|
|
410
|
+
SERVES_PUBLIC_API: 256,
|
|
411
|
+
/** GPU prover — may bid on + serve the GPU prover market (MB-4, bit 9). */
|
|
412
|
+
SERVES_GPU_PROVE: 512
|
|
405
413
|
};
|
|
414
|
+
var DIVERSITY_SCORE_MAX = 1e4;
|
|
415
|
+
var MULTISIG_ADDRESS_DERIVATION_DOMAIN = "MONO_MULTISIG_BLAKE3_20_V1";
|
|
406
416
|
var NODE_REGISTRY_CAPABILITY_MASK = 65535;
|
|
407
417
|
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;
|
|
408
418
|
var SERVICE_PROBE_STATUS = {
|
|
@@ -413,8 +423,15 @@ var SERVICE_PROBE_STATUS = {
|
|
|
413
423
|
};
|
|
414
424
|
var NODE_REGISTRY_SELECTORS = {
|
|
415
425
|
reportServiceProbe: "0xeee31bba",
|
|
416
|
-
getServiceProbe: "0x1fcbfbce"
|
|
426
|
+
getServiceProbe: "0x1fcbfbce",
|
|
427
|
+
/** `setNetworkMetadata(bytes32,uint16,bytes3,bytes)` — owner-callable (PF-6). */
|
|
428
|
+
setNetworkMetadata: "0x" + selectorHex("setNetworkMetadata(bytes32,uint16,bytes3,bytes)"),
|
|
429
|
+
/** `getOperatorNetworkMetadata(bytes32)` view (PF-6). */
|
|
430
|
+
getOperatorNetworkMetadata: "0x" + selectorHex("getOperatorNetworkMetadata(bytes32)"),
|
|
431
|
+
/** `getClusterDiversity(uint32)` view (PF-6). */
|
|
432
|
+
getClusterDiversity: "0x" + selectorHex("getClusterDiversity(uint32)")
|
|
417
433
|
};
|
|
434
|
+
var CLUSTER_FORMED_EVENT_SIG = "ClusterFormed(uint32,uint64,address,bytes)";
|
|
418
435
|
var NodeRegistryError = class extends Error {
|
|
419
436
|
constructor(message) {
|
|
420
437
|
super(message);
|
|
@@ -469,6 +486,112 @@ function encodeReportServiceProbeCalldata(args) {
|
|
|
469
486
|
)
|
|
470
487
|
);
|
|
471
488
|
}
|
|
489
|
+
function nodeHostingClassFromByte(b) {
|
|
490
|
+
if (b === 0) return "bareMetal";
|
|
491
|
+
if (b === 1) return "coLocation";
|
|
492
|
+
return "cloud";
|
|
493
|
+
}
|
|
494
|
+
function nodeHostingClassToByte(c) {
|
|
495
|
+
switch (c) {
|
|
496
|
+
case "bareMetal":
|
|
497
|
+
return 0;
|
|
498
|
+
case "coLocation":
|
|
499
|
+
return 1;
|
|
500
|
+
default:
|
|
501
|
+
return 2;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function decodeOperatorNetworkMetadata(returnData) {
|
|
505
|
+
const bytes = expectLength2(toBytes(returnData), 5 * 32, "operatorNetworkMetadata");
|
|
506
|
+
return {
|
|
507
|
+
asn: bytes[30] << 8 | bytes[31],
|
|
508
|
+
// bytes3 is left-aligned in the head word.
|
|
509
|
+
geoRegion: bytesToHex(bytes.slice(64, 67)),
|
|
510
|
+
hostingClass: nodeHostingClassFromByte(bytes[95]),
|
|
511
|
+
ipAddressHash: bytesToHex(bytes.slice(96, 128)),
|
|
512
|
+
pcrDigest: bytesToHex(bytes.slice(128, 160))
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
function decodeClusterDiversity(returnData) {
|
|
516
|
+
const bytes = expectLength2(toBytes(returnData), 4 * 32, "clusterDiversity");
|
|
517
|
+
const word = (i) => bytes[i * 32 + 30] << 8 | bytes[i * 32 + 31];
|
|
518
|
+
return {
|
|
519
|
+
score: word(0),
|
|
520
|
+
asnVariance: word(1),
|
|
521
|
+
geoVariance: word(2),
|
|
522
|
+
hostingSpread: word(3)
|
|
523
|
+
};
|
|
524
|
+
}
|
|
525
|
+
function decodeClusterFormedEvent(topics, data) {
|
|
526
|
+
if (topics.length !== 3) {
|
|
527
|
+
throw new NodeRegistryError(`ClusterFormed expects 3 topics, got ${topics.length}`);
|
|
528
|
+
}
|
|
529
|
+
const body = toBytes(data);
|
|
530
|
+
if (body.length < 96) {
|
|
531
|
+
throw new NodeRegistryError("ClusterFormed data shorter than head + roster length");
|
|
532
|
+
}
|
|
533
|
+
const clusterIdTopic = expectLength2(toBytes(topics[1]), 32, "clusterId topic");
|
|
534
|
+
const epochTopic = expectLength2(toBytes(topics[2]), 32, "effectiveEpoch topic");
|
|
535
|
+
const clusterId = u32FromWord(clusterIdTopic);
|
|
536
|
+
const effectiveEpoch = u64FromWord(epochTopic);
|
|
537
|
+
const anchorAddress = bytesToHex(body.slice(12, 32));
|
|
538
|
+
const rosterLen = Number(u64FromWord(body.slice(64, 96)));
|
|
539
|
+
const rosterEnd = 96 + rosterLen;
|
|
540
|
+
if (body.length < rosterEnd) {
|
|
541
|
+
throw new NodeRegistryError("ClusterFormed roster payload truncated");
|
|
542
|
+
}
|
|
543
|
+
return {
|
|
544
|
+
clusterId,
|
|
545
|
+
effectiveEpoch,
|
|
546
|
+
anchorAddress,
|
|
547
|
+
operatorRoster: bytesToHex(body.slice(96, rosterEnd))
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
function deriveClusterAnchorAddress(roster, threshold) {
|
|
551
|
+
if (!Number.isInteger(threshold) || threshold < 0 || threshold > 65535) {
|
|
552
|
+
throw new NodeRegistryError("threshold must be a uint16");
|
|
553
|
+
}
|
|
554
|
+
const members = roster.map((m, i) => expectLength2(toBytes(m), 48, `roster[${i}]`));
|
|
555
|
+
members.sort(compareBytes);
|
|
556
|
+
const parts = [
|
|
557
|
+
new TextEncoder().encode(MULTISIG_ADDRESS_DERIVATION_DOMAIN),
|
|
558
|
+
Uint8Array.from([threshold >> 8 & 255, threshold & 255])
|
|
559
|
+
];
|
|
560
|
+
for (const member of members) {
|
|
561
|
+
parts.push(u64BeBytes(BigInt(member.length)));
|
|
562
|
+
parts.push(member);
|
|
563
|
+
}
|
|
564
|
+
return bytesToHex(blake3_js.blake3(concatBytes(...parts)).slice(0, 20));
|
|
565
|
+
}
|
|
566
|
+
function selectorHex(sig) {
|
|
567
|
+
return [...sha3_js.keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
568
|
+
}
|
|
569
|
+
function u32FromWord(word) {
|
|
570
|
+
return (word[28] << 24 | word[29] << 16 | word[30] << 8 | word[31]) >>> 0;
|
|
571
|
+
}
|
|
572
|
+
function u64FromWord(word) {
|
|
573
|
+
let v = 0n;
|
|
574
|
+
for (let i = 24; i < 32; i++) {
|
|
575
|
+
v = v << 8n | BigInt(word[i]);
|
|
576
|
+
}
|
|
577
|
+
return v;
|
|
578
|
+
}
|
|
579
|
+
function u64BeBytes(value) {
|
|
580
|
+
const out = new Uint8Array(8);
|
|
581
|
+
let n = value;
|
|
582
|
+
for (let i = 7; i >= 0; i--) {
|
|
583
|
+
out[i] = Number(n & 0xffn);
|
|
584
|
+
n >>= 8n;
|
|
585
|
+
}
|
|
586
|
+
return out;
|
|
587
|
+
}
|
|
588
|
+
function compareBytes(a, b) {
|
|
589
|
+
const len = Math.min(a.length, b.length);
|
|
590
|
+
for (let i = 0; i < len; i++) {
|
|
591
|
+
if (a[i] !== b[i]) return a[i] - b[i];
|
|
592
|
+
}
|
|
593
|
+
return a.length - b.length;
|
|
594
|
+
}
|
|
472
595
|
function bitCount(value) {
|
|
473
596
|
let n = value >>> 0;
|
|
474
597
|
let count = 0;
|
|
@@ -2744,6 +2867,121 @@ var RpcClient = class _RpcClient {
|
|
|
2744
2867
|
async lythClusters(page = 0, limit = 25) {
|
|
2745
2868
|
return normalizeClusterDirectoryPage(await this.call("lyth_clusters", [page, limit]));
|
|
2746
2869
|
}
|
|
2870
|
+
// --- PF-4 / PF-6 / MB-6 / MB-4 / MB-2 + operator-router read wrappers ----
|
|
2871
|
+
//
|
|
2872
|
+
// Reconciled against the FINAL mono-core RPC surface (master 2eff9fed):
|
|
2873
|
+
// every method name + response shape below matches the chain's `lyth_*`
|
|
2874
|
+
// dispatch + impls exactly (camelCase keys, 0x-hex uint256 amounts,
|
|
2875
|
+
// bech32m addresses). The three indexer-backed methods —
|
|
2876
|
+
// `lyth_oracleSigners`, `lyth_listProofRequests`, `lyth_proverMarketStatus`
|
|
2877
|
+
// — return a graceful `{ status: "indexer_unavailable", … }` envelope
|
|
2878
|
+
// when the node runs without its indexer projection.
|
|
2879
|
+
/** PF-4 — `lyth_getSpendingPolicy`: the §18.8 spending-policy view for a sub-account. */
|
|
2880
|
+
async lythGetSpendingPolicy(subAccount) {
|
|
2881
|
+
return this.call("lyth_getSpendingPolicy", [sdkTypedAddress(subAccount, "user", "subAccount")]);
|
|
2882
|
+
}
|
|
2883
|
+
/** PF-6 — `lyth_getClusterDiversity`: diversity score + asn/geo/hosting breakdown. */
|
|
2884
|
+
async lythGetClusterDiversity(clusterId) {
|
|
2885
|
+
return this.call("lyth_getClusterDiversity", [clusterId]);
|
|
2886
|
+
}
|
|
2887
|
+
/**
|
|
2888
|
+
* PF-6 — `lyth_getOperatorNetworkMetadata`: ASN/geo/hosting-class/IP/PCR
|
|
2889
|
+
* for a peer. `operatorId` is the 32-byte operator/peer id as `0x…` hex
|
|
2890
|
+
* (the form `lyth_operatorInfo` returns).
|
|
2891
|
+
*/
|
|
2892
|
+
async lythGetOperatorNetworkMetadata(operatorId) {
|
|
2893
|
+
return this.call("lyth_getOperatorNetworkMetadata", [operatorId]);
|
|
2894
|
+
}
|
|
2895
|
+
/**
|
|
2896
|
+
* MB-6 — `lyth_oracleSigners`: the global oracle writer roster (folded
|
|
2897
|
+
* from `OracleWriterAdded` / `OracleWriterRemoved`). Returns the
|
|
2898
|
+
* `{ status: "indexer_unavailable", writers: [] }` fallback when the
|
|
2899
|
+
* node runs without the oracle writer-roster indexer projection.
|
|
2900
|
+
*/
|
|
2901
|
+
async lythOracleSigners() {
|
|
2902
|
+
return this.call("lyth_oracleSigners", []);
|
|
2903
|
+
}
|
|
2904
|
+
/** MB-6 — `lyth_oracleWriters`: the allowed writer set for a feed. */
|
|
2905
|
+
async lythOracleWriters(feedId) {
|
|
2906
|
+
return this.call("lyth_oracleWriters", [feedId]);
|
|
2907
|
+
}
|
|
2908
|
+
/** MB-6 — `lyth_oracleLatestPrice`: the latest finalized median for a feed. */
|
|
2909
|
+
async lythOracleLatestPrice(feedId) {
|
|
2910
|
+
return this.call("lyth_oracleLatestPrice", [feedId]);
|
|
2911
|
+
}
|
|
2912
|
+
/** MB-6 — `lyth_oracleFeedConfig`: a feed's decimals / min-signers / circuit-breaker config. */
|
|
2913
|
+
async lythOracleFeedConfig(feedId) {
|
|
2914
|
+
return this.call("lyth_oracleFeedConfig", [feedId]);
|
|
2915
|
+
}
|
|
2916
|
+
/** MB-4 — `lyth_getProofRequest`: a single GPU prover-market proof request. */
|
|
2917
|
+
async lythGetProofRequest(requestId) {
|
|
2918
|
+
return this.call("lyth_getProofRequest", [requestId]);
|
|
2919
|
+
}
|
|
2920
|
+
/**
|
|
2921
|
+
* MB-4 — `lyth_listProofRequests`: open/recent prover-market proof
|
|
2922
|
+
* requests. Params are `[stateFilter?, limit?]` (the chain's order),
|
|
2923
|
+
* where `stateFilter` is one of `open|assigned|settled|slashed|expired`.
|
|
2924
|
+
* Returns the `{ status: "indexer_unavailable", requests: [] }` fallback
|
|
2925
|
+
* when the node runs without the prover-market indexer projection.
|
|
2926
|
+
*/
|
|
2927
|
+
async lythListProofRequests(stateFilter, limit) {
|
|
2928
|
+
const params = [];
|
|
2929
|
+
if (stateFilter != null || limit != null) params.push(stateFilter ?? null);
|
|
2930
|
+
if (limit != null) params.push(limit);
|
|
2931
|
+
return this.call("lyth_listProofRequests", params);
|
|
2932
|
+
}
|
|
2933
|
+
/** MB-4 — `lyth_getProverBids`: the fee bids placed on one proof request. */
|
|
2934
|
+
async lythGetProverBids(requestId) {
|
|
2935
|
+
return this.call("lyth_getProverBids", [requestId]);
|
|
2936
|
+
}
|
|
2937
|
+
/**
|
|
2938
|
+
* MB-4 — `lyth_proverMarketStatus`: prover-market summary. `feeFloor` is
|
|
2939
|
+
* always present (on-chain genesis singleton); the aggregate counts are
|
|
2940
|
+
* `null` on the `{ status: "indexer_unavailable" }` fallback path.
|
|
2941
|
+
*/
|
|
2942
|
+
async lythProverMarketStatus() {
|
|
2943
|
+
return this.call("lyth_proverMarketStatus", []);
|
|
2944
|
+
}
|
|
2945
|
+
/**
|
|
2946
|
+
* Operator-router — `lyth_operatorRouterConfig`: the router's static
|
|
2947
|
+
* posture (`0x100B` address, the protocol fee ceiling, and whether the
|
|
2948
|
+
* gateable router precompile is currently milestone-activated).
|
|
2949
|
+
*/
|
|
2950
|
+
async lythOperatorRouterConfig() {
|
|
2951
|
+
return this.call("lyth_operatorRouterConfig", []);
|
|
2952
|
+
}
|
|
2953
|
+
/**
|
|
2954
|
+
* Operator-router — `lyth_operatorFeeConfig`: one operator's fee
|
|
2955
|
+
* registration (recipient, fee bps, enabled flag, registered-at block).
|
|
2956
|
+
* `operator` is a `mono` bech32m user address.
|
|
2957
|
+
*/
|
|
2958
|
+
async lythOperatorFeeConfig(operator) {
|
|
2959
|
+
return this.call("lyth_operatorFeeConfig", [sdkTypedAddress(operator, "user", "operator")]);
|
|
2960
|
+
}
|
|
2961
|
+
/**
|
|
2962
|
+
* MB-2 — `lyth_bridgeHealth`: a paged set of bridge-record health
|
|
2963
|
+
* envelopes. Each record carries the circuit-breaker posture
|
|
2964
|
+
* (`defaultDrainCapPerWindow`, `defaultDrainWindowBlocks`, `paused`,
|
|
2965
|
+
* `pausedAtBlock`, `resumeCooldownBlocks`). Params are `[cursor?, limit?]`
|
|
2966
|
+
* (the chain pages the global bridge set; there is no single-bridge form).
|
|
2967
|
+
*/
|
|
2968
|
+
async lythBridgeHealth(cursor, limit) {
|
|
2969
|
+
const params = [];
|
|
2970
|
+
if (cursor != null || limit != null) params.push(cursor ?? null);
|
|
2971
|
+
if (limit != null) params.push(limit);
|
|
2972
|
+
return this.call("lyth_bridgeHealth", params);
|
|
2973
|
+
}
|
|
2974
|
+
/**
|
|
2975
|
+
* MB-2 — `lyth_bridgeDrainStatus`: the live per-route circuit-breaker
|
|
2976
|
+
* drain bucket for one `(bridgeId, wrappedAsset)` route. `bridgeId` is a
|
|
2977
|
+
* 32-byte `0x…` hex id; `wrappedAsset` is a `mono` bech32m user address.
|
|
2978
|
+
*/
|
|
2979
|
+
async lythBridgeDrainStatus(bridgeId, wrappedAsset) {
|
|
2980
|
+
return this.call("lyth_bridgeDrainStatus", [
|
|
2981
|
+
bridgeId,
|
|
2982
|
+
sdkTypedAddress(wrappedAsset, "user", "wrappedAsset")
|
|
2983
|
+
]);
|
|
2984
|
+
}
|
|
2747
2985
|
/**
|
|
2748
2986
|
* `lyth_submitPendingChange` — operator-onboarding transport for the
|
|
2749
2987
|
* pending-change ledger. Server validates the envelope shape.
|
|
@@ -4160,6 +4398,13 @@ function isBridgeCooldownZeroRevert(data) {
|
|
|
4160
4398
|
function isBridgeFinalityZeroRevert(data) {
|
|
4161
4399
|
return bytesToHex4(toBytes2(data)).toLowerCase() === BRIDGE_REVERT_TAGS.bridgeFinalityZero;
|
|
4162
4400
|
}
|
|
4401
|
+
function bridgeDrainRemaining(capPerWindow, drained) {
|
|
4402
|
+
const cap = BigInt(capPerWindow);
|
|
4403
|
+
if (cap === 0n) return null;
|
|
4404
|
+
const used = BigInt(drained);
|
|
4405
|
+
const left = cap > used ? cap - used : 0n;
|
|
4406
|
+
return left.toString(10);
|
|
4407
|
+
}
|
|
4163
4408
|
function assessBridgeRoute(route) {
|
|
4164
4409
|
const blockedReasons = [];
|
|
4165
4410
|
const warnings = [];
|
|
@@ -6386,6 +6631,358 @@ function assertWholeNumber(field2, value) {
|
|
|
6386
6631
|
throw new Error(`${field2} must be a whole number`);
|
|
6387
6632
|
}
|
|
6388
6633
|
}
|
|
6634
|
+
var ORACLE_EVENT_SIGS = {
|
|
6635
|
+
oracleRoundFinalized: "OracleRoundFinalized(bytes32,uint64,uint256,uint64,uint32)",
|
|
6636
|
+
observationSubmitted: "ObservationSubmitted(bytes32,uint64,address,uint256,uint64)",
|
|
6637
|
+
feedAdded: "FeedAdded(bytes32,uint8,uint16,uint32,uint32)",
|
|
6638
|
+
feedUpdated: "FeedUpdated(bytes32,uint8,uint16,uint32,uint32)",
|
|
6639
|
+
oracleFraudSlashed: "OracleFraudSlashed(bytes32,uint64,address,bytes32)",
|
|
6640
|
+
oracleAdminUpdated: "OracleAdminUpdated(address)",
|
|
6641
|
+
oracleWriterAdded: "OracleWriterAdded(address,address)",
|
|
6642
|
+
oracleWriterRemoved: "OracleWriterRemoved(address,address)"
|
|
6643
|
+
};
|
|
6644
|
+
var OracleEventError = class extends Error {
|
|
6645
|
+
constructor(message) {
|
|
6646
|
+
super(message);
|
|
6647
|
+
this.name = "OracleEventError";
|
|
6648
|
+
}
|
|
6649
|
+
};
|
|
6650
|
+
function oracleAddressHex() {
|
|
6651
|
+
return PRECOMPILE_ADDRESSES.ORACLE.toLowerCase();
|
|
6652
|
+
}
|
|
6653
|
+
function decodeOracleEvent(topics, data) {
|
|
6654
|
+
if (topics.length === 0) {
|
|
6655
|
+
throw new OracleEventError("event record has no topics");
|
|
6656
|
+
}
|
|
6657
|
+
const topic0 = bytesToHex6(expectLength4(toBytes3(topics[0]), 32, "topic0"));
|
|
6658
|
+
const body = toBytes3(data);
|
|
6659
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleRoundFinalized)) {
|
|
6660
|
+
checkArity("OracleRoundFinalized", 3, topics.length);
|
|
6661
|
+
checkData("OracleRoundFinalized", 3 * 32, body.length);
|
|
6662
|
+
return {
|
|
6663
|
+
kind: "roundFinalized",
|
|
6664
|
+
feedId: hex32(topics[1]),
|
|
6665
|
+
roundId: u64FromTopic(topics[2]),
|
|
6666
|
+
computedMedian: u256Decimal(body.subarray(0, 32)),
|
|
6667
|
+
finalizedAtBlock: u64FromWord2(body.subarray(32, 64)),
|
|
6668
|
+
observationsLen: u32FromWord2(body.subarray(64, 96))
|
|
6669
|
+
};
|
|
6670
|
+
}
|
|
6671
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.observationSubmitted)) {
|
|
6672
|
+
checkArity("ObservationSubmitted", 4, topics.length);
|
|
6673
|
+
checkData("ObservationSubmitted", 2 * 32, body.length);
|
|
6674
|
+
return {
|
|
6675
|
+
kind: "observationSubmitted",
|
|
6676
|
+
feedId: hex32(topics[1]),
|
|
6677
|
+
roundId: u64FromTopic(topics[2]),
|
|
6678
|
+
writer: addressFromTopic(topics[3]),
|
|
6679
|
+
value: u256Decimal(body.subarray(0, 32)),
|
|
6680
|
+
observedAt: u64FromWord2(body.subarray(32, 64))
|
|
6681
|
+
};
|
|
6682
|
+
}
|
|
6683
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleFraudSlashed)) {
|
|
6684
|
+
checkArity("OracleFraudSlashed", 4, topics.length);
|
|
6685
|
+
checkData("OracleFraudSlashed", 32, body.length);
|
|
6686
|
+
return {
|
|
6687
|
+
kind: "fraudSlashed",
|
|
6688
|
+
feedId: hex32(topics[1]),
|
|
6689
|
+
roundId: u64FromTopic(topics[2]),
|
|
6690
|
+
writer: addressFromTopic(topics[3]),
|
|
6691
|
+
evidenceHash: bytesToHex6(body.subarray(0, 32))
|
|
6692
|
+
};
|
|
6693
|
+
}
|
|
6694
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedAdded)) {
|
|
6695
|
+
checkArity("FeedAdded", 2, topics.length);
|
|
6696
|
+
checkData("FeedAdded", 4 * 32, body.length);
|
|
6697
|
+
return { kind: "feedAdded", ...decodeFeedFields(topics[1], body) };
|
|
6698
|
+
}
|
|
6699
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.feedUpdated)) {
|
|
6700
|
+
checkArity("FeedUpdated", 2, topics.length);
|
|
6701
|
+
checkData("FeedUpdated", 4 * 32, body.length);
|
|
6702
|
+
return { kind: "feedUpdated", ...decodeFeedFields(topics[1], body) };
|
|
6703
|
+
}
|
|
6704
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleAdminUpdated)) {
|
|
6705
|
+
checkArity("OracleAdminUpdated", 2, topics.length);
|
|
6706
|
+
checkData("OracleAdminUpdated", 0, body.length);
|
|
6707
|
+
return { kind: "adminUpdated", admin: addressFromTopic(topics[1]) };
|
|
6708
|
+
}
|
|
6709
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleWriterAdded)) {
|
|
6710
|
+
checkArity("OracleWriterAdded", 3, topics.length);
|
|
6711
|
+
checkData("OracleWriterAdded", 0, body.length);
|
|
6712
|
+
return {
|
|
6713
|
+
kind: "writerAdded",
|
|
6714
|
+
admin: addressFromTopic(topics[1]),
|
|
6715
|
+
writer: addressFromTopic(topics[2])
|
|
6716
|
+
};
|
|
6717
|
+
}
|
|
6718
|
+
if (topic0 === topicHex(ORACLE_EVENT_SIGS.oracleWriterRemoved)) {
|
|
6719
|
+
checkArity("OracleWriterRemoved", 3, topics.length);
|
|
6720
|
+
checkData("OracleWriterRemoved", 0, body.length);
|
|
6721
|
+
return {
|
|
6722
|
+
kind: "writerRemoved",
|
|
6723
|
+
admin: addressFromTopic(topics[1]),
|
|
6724
|
+
writer: addressFromTopic(topics[2])
|
|
6725
|
+
};
|
|
6726
|
+
}
|
|
6727
|
+
throw new OracleEventError("unknown oracle event topic0");
|
|
6728
|
+
}
|
|
6729
|
+
function decodeFeedFields(feedTopic, body) {
|
|
6730
|
+
return {
|
|
6731
|
+
feedId: hex32(feedTopic),
|
|
6732
|
+
decimals: body[31],
|
|
6733
|
+
minSigners: body[62] << 8 | body[63],
|
|
6734
|
+
circuitBreakerBps: u32FromWord2(body.subarray(64, 96)),
|
|
6735
|
+
allowedWritersLen: u32FromWord2(body.subarray(96, 128))
|
|
6736
|
+
};
|
|
6737
|
+
}
|
|
6738
|
+
function topicHex(sig) {
|
|
6739
|
+
return bytesToHex6(sha3_js.keccak_256(new TextEncoder().encode(sig)));
|
|
6740
|
+
}
|
|
6741
|
+
function checkArity(event, expected, found) {
|
|
6742
|
+
if (found !== expected) {
|
|
6743
|
+
throw new OracleEventError(`${event} expected ${expected} topics, found ${found}`);
|
|
6744
|
+
}
|
|
6745
|
+
}
|
|
6746
|
+
function checkData(event, expected, found) {
|
|
6747
|
+
if (found !== expected) {
|
|
6748
|
+
throw new OracleEventError(`${event} expected ${expected} data bytes, found ${found}`);
|
|
6749
|
+
}
|
|
6750
|
+
}
|
|
6751
|
+
function hex32(topic) {
|
|
6752
|
+
return bytesToHex6(expectLength4(toBytes3(topic), 32, "feedId topic"));
|
|
6753
|
+
}
|
|
6754
|
+
function addressFromTopic(topic) {
|
|
6755
|
+
return bytesToHex6(expectLength4(toBytes3(topic), 32, "address topic").subarray(12, 32));
|
|
6756
|
+
}
|
|
6757
|
+
function u64FromTopic(topic) {
|
|
6758
|
+
return u64FromWord2(expectLength4(toBytes3(topic), 32, "u64 topic"));
|
|
6759
|
+
}
|
|
6760
|
+
function u64FromWord2(word) {
|
|
6761
|
+
let v = 0n;
|
|
6762
|
+
for (let i = 24; i < 32; i++) v = v << 8n | BigInt(word[i]);
|
|
6763
|
+
return v;
|
|
6764
|
+
}
|
|
6765
|
+
function u32FromWord2(word) {
|
|
6766
|
+
return (word[28] << 24 | word[29] << 16 | word[30] << 8 | word[31]) >>> 0;
|
|
6767
|
+
}
|
|
6768
|
+
function u256Decimal(word) {
|
|
6769
|
+
let v = 0n;
|
|
6770
|
+
for (const b of word) v = v << 8n | BigInt(b);
|
|
6771
|
+
return v.toString(10);
|
|
6772
|
+
}
|
|
6773
|
+
function toBytes3(value) {
|
|
6774
|
+
if (typeof value === "string") return hexToBytes5(value);
|
|
6775
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6776
|
+
}
|
|
6777
|
+
function hexToBytes5(hex) {
|
|
6778
|
+
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6779
|
+
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6780
|
+
throw new OracleEventError("invalid hex bytes");
|
|
6781
|
+
}
|
|
6782
|
+
const out = new Uint8Array(b.length / 2);
|
|
6783
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6784
|
+
return out;
|
|
6785
|
+
}
|
|
6786
|
+
function bytesToHex6(bytes) {
|
|
6787
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6788
|
+
}
|
|
6789
|
+
function expectLength4(value, len, name) {
|
|
6790
|
+
if (value.length !== len) {
|
|
6791
|
+
throw new OracleEventError(`${name} must be ${len} bytes, got ${value.length}`);
|
|
6792
|
+
}
|
|
6793
|
+
return value;
|
|
6794
|
+
}
|
|
6795
|
+
var PROVER_MARKET_ADDRESS = PRECOMPILE_ADDRESSES.PROVER_MARKET;
|
|
6796
|
+
var SERVES_GPU_PROVE = 512;
|
|
6797
|
+
var PROVER_MARKET_SELECTORS = {
|
|
6798
|
+
createRequest: "0x" + selectorHex2("createRequest(bytes)"),
|
|
6799
|
+
submitBid: "0x" + selectorHex2("submitBid(bytes)"),
|
|
6800
|
+
closeRequest: "0x" + selectorHex2("closeRequest(bytes)"),
|
|
6801
|
+
submitProof: "0x" + selectorHex2("submitProof(bytes)"),
|
|
6802
|
+
settle: "0x" + selectorHex2("settle(bytes)"),
|
|
6803
|
+
slash: "0x" + selectorHex2("slash(bytes)")
|
|
6804
|
+
};
|
|
6805
|
+
var PROVER_MARKET_EVENT_SIGS = {
|
|
6806
|
+
proofRequested: "ProofRequested(bytes32,address,bytes32,uint128,uint64)",
|
|
6807
|
+
bidSubmitted: "BidSubmitted(bytes32,address,uint128)",
|
|
6808
|
+
requestAssigned: "RequestAssigned(bytes32,address,uint128)",
|
|
6809
|
+
proofSettled: "ProofSettled(bytes32,address,uint128,uint128)",
|
|
6810
|
+
proverSlashed: "ProverSlashed(bytes32,address,uint16,bytes32)",
|
|
6811
|
+
requestExpired: "RequestExpired(bytes32,address,uint128)"
|
|
6812
|
+
};
|
|
6813
|
+
var PROVER_SLASH_REASON_NON_DELIVERY = 1024;
|
|
6814
|
+
var PROVER_SLASH_REASON_BAD_PROOF = 1025;
|
|
6815
|
+
var PROVER_MARKET_REQUEST_DOMAIN = "prover_market.request.v1";
|
|
6816
|
+
var PROVER_MARKET_BID_DOMAIN = "prover_market.bid.v1";
|
|
6817
|
+
var PROVER_MARKET_SUBMIT_DOMAIN = "prover_market.submit.v1";
|
|
6818
|
+
function proverMarketStateFromByte(b) {
|
|
6819
|
+
switch (b) {
|
|
6820
|
+
case 0:
|
|
6821
|
+
return "open";
|
|
6822
|
+
case 1:
|
|
6823
|
+
return "assigned";
|
|
6824
|
+
case 2:
|
|
6825
|
+
return "settled";
|
|
6826
|
+
case 3:
|
|
6827
|
+
return "slashed";
|
|
6828
|
+
case 4:
|
|
6829
|
+
return "expired";
|
|
6830
|
+
default:
|
|
6831
|
+
return null;
|
|
6832
|
+
}
|
|
6833
|
+
}
|
|
6834
|
+
var ProverMarketError = class extends Error {
|
|
6835
|
+
constructor(message) {
|
|
6836
|
+
super(message);
|
|
6837
|
+
this.name = "ProverMarketError";
|
|
6838
|
+
}
|
|
6839
|
+
};
|
|
6840
|
+
function requestSighash(vkeyHash, inputsHash, maxFee, deadline, nonce) {
|
|
6841
|
+
return bytesToHex7(
|
|
6842
|
+
sha3_js.keccak_256(
|
|
6843
|
+
concatBytes5(
|
|
6844
|
+
new TextEncoder().encode(PROVER_MARKET_REQUEST_DOMAIN),
|
|
6845
|
+
expectLength5(toBytes4(vkeyHash), 32, "vkeyHash"),
|
|
6846
|
+
expectLength5(toBytes4(inputsHash), 32, "inputsHash"),
|
|
6847
|
+
u128Bytes(maxFee, "maxFee"),
|
|
6848
|
+
u64Bytes(deadline, "deadline"),
|
|
6849
|
+
u64Bytes(nonce, "nonce")
|
|
6850
|
+
)
|
|
6851
|
+
)
|
|
6852
|
+
);
|
|
6853
|
+
}
|
|
6854
|
+
function bidSighash(requestId, fee) {
|
|
6855
|
+
return bytesToHex7(
|
|
6856
|
+
sha3_js.keccak_256(
|
|
6857
|
+
concatBytes5(
|
|
6858
|
+
new TextEncoder().encode(PROVER_MARKET_BID_DOMAIN),
|
|
6859
|
+
expectLength5(toBytes4(requestId), 32, "requestId"),
|
|
6860
|
+
u128Bytes(fee, "fee")
|
|
6861
|
+
)
|
|
6862
|
+
)
|
|
6863
|
+
);
|
|
6864
|
+
}
|
|
6865
|
+
function submitSighash(requestId, proofHash) {
|
|
6866
|
+
return bytesToHex7(
|
|
6867
|
+
sha3_js.keccak_256(
|
|
6868
|
+
concatBytes5(
|
|
6869
|
+
new TextEncoder().encode(PROVER_MARKET_SUBMIT_DOMAIN),
|
|
6870
|
+
expectLength5(toBytes4(requestId), 32, "requestId"),
|
|
6871
|
+
expectLength5(toBytes4(proofHash), 32, "proofHash")
|
|
6872
|
+
)
|
|
6873
|
+
)
|
|
6874
|
+
);
|
|
6875
|
+
}
|
|
6876
|
+
function encodeCreateRequestCanonical(args) {
|
|
6877
|
+
const buyer = expectLength5(toBytes4(args.buyer), 20, "buyer");
|
|
6878
|
+
const buyerPubkey = toBytes4(args.buyerPubkey);
|
|
6879
|
+
const sig = toBytes4(args.sig);
|
|
6880
|
+
if (buyerPubkey.length === 0 || buyerPubkey.length > 65535) {
|
|
6881
|
+
throw new ProverMarketError("buyerPubkey length out of range (1..=65535)");
|
|
6882
|
+
}
|
|
6883
|
+
if (sig.length === 0 || sig.length > 65535) {
|
|
6884
|
+
throw new ProverMarketError("sig length out of range (1..=65535)");
|
|
6885
|
+
}
|
|
6886
|
+
return bytesToHex7(
|
|
6887
|
+
concatBytes5(
|
|
6888
|
+
buyer,
|
|
6889
|
+
u16Bytes(buyerPubkey.length),
|
|
6890
|
+
buyerPubkey,
|
|
6891
|
+
expectLength5(toBytes4(args.vkeyHash), 32, "vkeyHash"),
|
|
6892
|
+
expectLength5(toBytes4(args.inputsHash), 32, "inputsHash"),
|
|
6893
|
+
u128Bytes(args.maxFee, "maxFee"),
|
|
6894
|
+
u64Bytes(args.deadline, "deadline"),
|
|
6895
|
+
u64Bytes(args.nonce, "nonce"),
|
|
6896
|
+
u16Bytes(sig.length),
|
|
6897
|
+
sig
|
|
6898
|
+
)
|
|
6899
|
+
);
|
|
6900
|
+
}
|
|
6901
|
+
function encodeCreateRequestCalldata(args) {
|
|
6902
|
+
const canonical = toBytes4(encodeCreateRequestCanonical(args));
|
|
6903
|
+
const offset = new Uint8Array(32);
|
|
6904
|
+
offset[31] = 32;
|
|
6905
|
+
const lenWord = new Uint8Array(32);
|
|
6906
|
+
const len = canonical.length;
|
|
6907
|
+
lenWord[28] = len >>> 24 & 255;
|
|
6908
|
+
lenWord[29] = len >>> 16 & 255;
|
|
6909
|
+
lenWord[30] = len >>> 8 & 255;
|
|
6910
|
+
lenWord[31] = len & 255;
|
|
6911
|
+
const pad = (32 - len % 32) % 32;
|
|
6912
|
+
return bytesToHex7(
|
|
6913
|
+
concatBytes5(hexToBytes6(PROVER_MARKET_SELECTORS.createRequest), offset, lenWord, canonical, new Uint8Array(pad))
|
|
6914
|
+
);
|
|
6915
|
+
}
|
|
6916
|
+
function selectorHex2(sig) {
|
|
6917
|
+
return [...sha3_js.keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
6918
|
+
}
|
|
6919
|
+
function toBytes4(value) {
|
|
6920
|
+
if (typeof value === "string") return hexToBytes6(value);
|
|
6921
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6922
|
+
}
|
|
6923
|
+
function hexToBytes6(hex) {
|
|
6924
|
+
const b = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6925
|
+
if (b.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(b)) {
|
|
6926
|
+
throw new ProverMarketError("invalid hex bytes");
|
|
6927
|
+
}
|
|
6928
|
+
const out = new Uint8Array(b.length / 2);
|
|
6929
|
+
for (let i = 0; i < out.length; i++) out[i] = Number.parseInt(b.slice(i * 2, i * 2 + 2), 16);
|
|
6930
|
+
return out;
|
|
6931
|
+
}
|
|
6932
|
+
function bytesToHex7(bytes) {
|
|
6933
|
+
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6934
|
+
}
|
|
6935
|
+
function concatBytes5(...parts) {
|
|
6936
|
+
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6937
|
+
let offset = 0;
|
|
6938
|
+
for (const part of parts) {
|
|
6939
|
+
out.set(part, offset);
|
|
6940
|
+
offset += part.length;
|
|
6941
|
+
}
|
|
6942
|
+
return out;
|
|
6943
|
+
}
|
|
6944
|
+
function expectLength5(value, len, name) {
|
|
6945
|
+
if (value.length !== len) {
|
|
6946
|
+
throw new ProverMarketError(`${name} must be ${len} bytes, got ${value.length}`);
|
|
6947
|
+
}
|
|
6948
|
+
return value;
|
|
6949
|
+
}
|
|
6950
|
+
function toBigint2(value, name) {
|
|
6951
|
+
let n;
|
|
6952
|
+
if (typeof value === "bigint") n = value;
|
|
6953
|
+
else if (typeof value === "number") {
|
|
6954
|
+
if (!Number.isSafeInteger(value)) throw new ProverMarketError(`${name} must be a safe integer`);
|
|
6955
|
+
n = BigInt(value);
|
|
6956
|
+
} else if (/^(0|[1-9][0-9]*|0x[0-9a-fA-F]+)$/.test(value)) n = BigInt(value);
|
|
6957
|
+
else throw new ProverMarketError(`${name} must be a non-negative integer`);
|
|
6958
|
+
if (n < 0n) throw new ProverMarketError(`${name} must be non-negative`);
|
|
6959
|
+
return n;
|
|
6960
|
+
}
|
|
6961
|
+
function u16Bytes(value) {
|
|
6962
|
+
if (!Number.isInteger(value) || value < 0 || value > 65535) {
|
|
6963
|
+
throw new ProverMarketError("u16 value out of range");
|
|
6964
|
+
}
|
|
6965
|
+
return Uint8Array.from([value >> 8 & 255, value & 255]);
|
|
6966
|
+
}
|
|
6967
|
+
function u64Bytes(value, name) {
|
|
6968
|
+
const n = toBigint2(value, name);
|
|
6969
|
+
if (n > 0xffffffffffffffffn) throw new ProverMarketError(`${name} exceeds uint64`);
|
|
6970
|
+
return bigintBytes(n, 8);
|
|
6971
|
+
}
|
|
6972
|
+
function u128Bytes(value, name) {
|
|
6973
|
+
const n = toBigint2(value, name);
|
|
6974
|
+
if (n > (1n << 128n) - 1n) throw new ProverMarketError(`${name} exceeds uint128`);
|
|
6975
|
+
return bigintBytes(n, 16);
|
|
6976
|
+
}
|
|
6977
|
+
function bigintBytes(value, len) {
|
|
6978
|
+
const out = new Uint8Array(len);
|
|
6979
|
+
let n = value;
|
|
6980
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
6981
|
+
out[i] = Number(n & 0xffn);
|
|
6982
|
+
n >>= 8n;
|
|
6983
|
+
}
|
|
6984
|
+
return out;
|
|
6985
|
+
}
|
|
6389
6986
|
|
|
6390
6987
|
// src/delegation.ts
|
|
6391
6988
|
var DELEGATION_SELECTORS = {
|
|
@@ -6412,34 +7009,34 @@ function delegationAddressHex() {
|
|
|
6412
7009
|
return PRECOMPILE_ADDRESSES.DELEGATION.toLowerCase();
|
|
6413
7010
|
}
|
|
6414
7011
|
function encodeCompleteRedemptionCalldata(index) {
|
|
6415
|
-
return
|
|
6416
|
-
|
|
6417
|
-
|
|
7012
|
+
return bytesToHex8(
|
|
7013
|
+
concatBytes6(
|
|
7014
|
+
hexToBytes7(DELEGATION_SELECTORS.completeRedemption),
|
|
6418
7015
|
uint64Word2(index, "index")
|
|
6419
7016
|
)
|
|
6420
7017
|
);
|
|
6421
7018
|
}
|
|
6422
7019
|
function encodeDelegateCalldata(cluster, weightBps) {
|
|
6423
|
-
return
|
|
6424
|
-
|
|
6425
|
-
|
|
7020
|
+
return bytesToHex8(
|
|
7021
|
+
concatBytes6(
|
|
7022
|
+
hexToBytes7(DELEGATION_SELECTORS.delegate),
|
|
6426
7023
|
uint32Word2(cluster, "cluster"),
|
|
6427
7024
|
uint16Word(weightBps, "weightBps")
|
|
6428
7025
|
)
|
|
6429
7026
|
);
|
|
6430
7027
|
}
|
|
6431
7028
|
function encodeUndelegateCalldata(cluster) {
|
|
6432
|
-
return
|
|
6433
|
-
|
|
6434
|
-
|
|
7029
|
+
return bytesToHex8(
|
|
7030
|
+
concatBytes6(
|
|
7031
|
+
hexToBytes7(DELEGATION_SELECTORS.undelegate),
|
|
6435
7032
|
uint32Word2(cluster, "cluster")
|
|
6436
7033
|
)
|
|
6437
7034
|
);
|
|
6438
7035
|
}
|
|
6439
7036
|
function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
|
|
6440
|
-
return
|
|
6441
|
-
|
|
6442
|
-
|
|
7037
|
+
return bytesToHex8(
|
|
7038
|
+
concatBytes6(
|
|
7039
|
+
hexToBytes7(DELEGATION_SELECTORS.redelegate),
|
|
6443
7040
|
uint32Word2(fromCluster, "fromCluster"),
|
|
6444
7041
|
uint32Word2(toCluster, "toCluster"),
|
|
6445
7042
|
uint16Word(weightBps, "weightBps")
|
|
@@ -6452,15 +7049,15 @@ function encodeClaimCalldata() {
|
|
|
6452
7049
|
function encodeSetAutoCompoundCalldata(enabled) {
|
|
6453
7050
|
const flag = new Uint8Array(32);
|
|
6454
7051
|
flag[31] = enabled ? 1 : 0;
|
|
6455
|
-
return
|
|
6456
|
-
|
|
7052
|
+
return bytesToHex8(
|
|
7053
|
+
concatBytes6(hexToBytes7(DELEGATION_SELECTORS.setAutoCompound), flag)
|
|
6457
7054
|
);
|
|
6458
7055
|
}
|
|
6459
7056
|
function isRedemptionPrincipalUnavailableRevert(data) {
|
|
6460
|
-
return
|
|
7057
|
+
return bytesToHex8(toBytes5(data)).toLowerCase() === DELEGATION_REVERT_TAGS.redemptionPrincipalUnavailable;
|
|
6461
7058
|
}
|
|
6462
7059
|
function uint64Word2(value, name) {
|
|
6463
|
-
const n =
|
|
7060
|
+
const n = toBigint3(value, name);
|
|
6464
7061
|
if (n < 0n || n > 0xffffffffffffffffn) {
|
|
6465
7062
|
throw new DelegationPrecompileError(`${name} must fit uint64`);
|
|
6466
7063
|
}
|
|
@@ -6473,7 +7070,7 @@ function uint64Word2(value, name) {
|
|
|
6473
7070
|
return out;
|
|
6474
7071
|
}
|
|
6475
7072
|
function uint32Word2(value, name) {
|
|
6476
|
-
const n =
|
|
7073
|
+
const n = toBigint3(value, name);
|
|
6477
7074
|
if (n < 0n || n > 0xffffffffn) {
|
|
6478
7075
|
throw new DelegationPrecompileError(`${name} must fit uint32`);
|
|
6479
7076
|
}
|
|
@@ -6486,7 +7083,7 @@ function uint32Word2(value, name) {
|
|
|
6486
7083
|
return out;
|
|
6487
7084
|
}
|
|
6488
7085
|
function uint16Word(value, name) {
|
|
6489
|
-
const n =
|
|
7086
|
+
const n = toBigint3(value, name);
|
|
6490
7087
|
if (n < 0n || n > 0xffffn) {
|
|
6491
7088
|
throw new DelegationPrecompileError(`${name} must fit uint16`);
|
|
6492
7089
|
}
|
|
@@ -6498,7 +7095,7 @@ function uint16Word(value, name) {
|
|
|
6498
7095
|
}
|
|
6499
7096
|
return out;
|
|
6500
7097
|
}
|
|
6501
|
-
function
|
|
7098
|
+
function toBigint3(value, name) {
|
|
6502
7099
|
if (typeof value === "bigint") return value;
|
|
6503
7100
|
if (typeof value === "number") {
|
|
6504
7101
|
if (!Number.isInteger(value) || !Number.isSafeInteger(value)) {
|
|
@@ -6511,13 +7108,13 @@ function toBigint2(value, name) {
|
|
|
6511
7108
|
}
|
|
6512
7109
|
return BigInt(value);
|
|
6513
7110
|
}
|
|
6514
|
-
function
|
|
7111
|
+
function toBytes5(value) {
|
|
6515
7112
|
if (typeof value === "string") {
|
|
6516
|
-
return
|
|
7113
|
+
return hexToBytes7(value);
|
|
6517
7114
|
}
|
|
6518
7115
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6519
7116
|
}
|
|
6520
|
-
function
|
|
7117
|
+
function hexToBytes7(hex) {
|
|
6521
7118
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6522
7119
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6523
7120
|
throw new DelegationPrecompileError("invalid hex bytes");
|
|
@@ -6528,10 +7125,10 @@ function hexToBytes5(hex) {
|
|
|
6528
7125
|
}
|
|
6529
7126
|
return out;
|
|
6530
7127
|
}
|
|
6531
|
-
function
|
|
7128
|
+
function bytesToHex8(bytes) {
|
|
6532
7129
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6533
7130
|
}
|
|
6534
|
-
function
|
|
7131
|
+
function concatBytes6(...parts) {
|
|
6535
7132
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6536
7133
|
let offset = 0;
|
|
6537
7134
|
for (const part of parts) {
|
|
@@ -6546,9 +7143,11 @@ var SET_POLICY_CLAIM_DOMAIN_TAG = "lyth.spending-policy.claim.v1";
|
|
|
6546
7143
|
var ML_DSA_65_PUBLIC_KEY_LEN2 = 1952;
|
|
6547
7144
|
var ML_DSA_65_SIGNATURE_LEN2 = 3309;
|
|
6548
7145
|
var SPENDING_POLICY_SELECTORS = {
|
|
6549
|
-
setPolicy
|
|
6550
|
-
|
|
6551
|
-
|
|
7146
|
+
// WP §18.8 widened the setPolicy* sighash strings to 11 words, so their
|
|
7147
|
+
// selectors changed; enable/disable/recordSpend are unchanged.
|
|
7148
|
+
setPolicy: "0x8da1a765",
|
|
7149
|
+
setPolicyClaim: "0x35531f6c",
|
|
7150
|
+
claimPolicyByAddress: "0x0c21376c",
|
|
6552
7151
|
enable: "0x5bfa1b68",
|
|
6553
7152
|
disable: "0xe6c09edf",
|
|
6554
7153
|
recordSpend: "0xdca04292"
|
|
@@ -6565,7 +7164,7 @@ function spendingPolicyAddressHex() {
|
|
|
6565
7164
|
function composeClaimBoundMessage(chainId, args, opts) {
|
|
6566
7165
|
const precompileAddress = toRawAddressBytes(opts?.precompileAddress ?? PRECOMPILE_ADDRESSES.SPENDING_POLICY);
|
|
6567
7166
|
const normalized = normalizeArgs(args);
|
|
6568
|
-
return
|
|
7167
|
+
return concatBytes7(
|
|
6569
7168
|
new TextEncoder().encode(SET_POLICY_CLAIM_DOMAIN_TAG),
|
|
6570
7169
|
uint64Bytes(chainId, "chainId"),
|
|
6571
7170
|
precompileAddress,
|
|
@@ -6575,22 +7174,30 @@ function composeClaimBoundMessage(chainId, args, opts) {
|
|
|
6575
7174
|
uint128Bytes(normalized.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
6576
7175
|
normalized.allowRoot,
|
|
6577
7176
|
normalized.denyRoot,
|
|
7177
|
+
// WP §18.8 dimensions, in wire order: weekly cap (be16), monthly cap
|
|
7178
|
+
// (be16), category allow-root (32), packed time window (32),
|
|
7179
|
+
// policy expiry (be8). These slot in before the expected-version word.
|
|
7180
|
+
uint128Bytes(normalized.weeklyCapLythoshi, "weeklyCapLythoshi"),
|
|
7181
|
+
uint128Bytes(normalized.monthlyCapLythoshi, "monthlyCapLythoshi"),
|
|
7182
|
+
normalized.categoryAllowRoot,
|
|
7183
|
+
normalized.timeWindow,
|
|
7184
|
+
uint64Bytes(normalized.policyExpiry, "policyExpiry"),
|
|
6578
7185
|
uint64Bytes(opts?.expectedPolicyVersion ?? 0n, "expectedPolicyVersion")
|
|
6579
7186
|
);
|
|
6580
7187
|
}
|
|
6581
7188
|
function encodeSetPolicyCalldata(args) {
|
|
6582
7189
|
const normalized = normalizeArgs(args);
|
|
6583
|
-
return
|
|
6584
|
-
|
|
6585
|
-
|
|
7190
|
+
return bytesToHex9(
|
|
7191
|
+
concatBytes7(
|
|
7192
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicy),
|
|
6586
7193
|
encodePolicyWords(normalized)
|
|
6587
7194
|
)
|
|
6588
7195
|
);
|
|
6589
7196
|
}
|
|
6590
7197
|
function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
6591
7198
|
const normalized = normalizeArgs(args);
|
|
6592
|
-
const pubkey =
|
|
6593
|
-
const sig =
|
|
7199
|
+
const pubkey = toBytes6(subAccountPubkey);
|
|
7200
|
+
const sig = toBytes6(subAccountSig);
|
|
6594
7201
|
if (pubkey.length !== ML_DSA_65_PUBLIC_KEY_LEN2) {
|
|
6595
7202
|
throw new SpendingPolicyError(
|
|
6596
7203
|
`subAccountPubkey must be ${ML_DSA_65_PUBLIC_KEY_LEN2} bytes, got ${pubkey.length}`
|
|
@@ -6601,9 +7208,9 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
6601
7208
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
6602
7209
|
);
|
|
6603
7210
|
}
|
|
6604
|
-
return
|
|
6605
|
-
|
|
6606
|
-
|
|
7211
|
+
return bytesToHex9(
|
|
7212
|
+
concatBytes7(
|
|
7213
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.setPolicyClaim),
|
|
6607
7214
|
encodePolicyWords(normalized),
|
|
6608
7215
|
pubkey,
|
|
6609
7216
|
sig
|
|
@@ -6612,15 +7219,15 @@ function encodeSetPolicyClaimCalldata(args, subAccountPubkey, subAccountSig) {
|
|
|
6612
7219
|
}
|
|
6613
7220
|
function encodeClaimPolicyByAddressCalldata(args, subAccountSig) {
|
|
6614
7221
|
const normalized = normalizeArgs(args);
|
|
6615
|
-
const sig =
|
|
7222
|
+
const sig = toBytes6(subAccountSig);
|
|
6616
7223
|
if (sig.length !== ML_DSA_65_SIGNATURE_LEN2) {
|
|
6617
7224
|
throw new SpendingPolicyError(
|
|
6618
7225
|
`subAccountSig must be ${ML_DSA_65_SIGNATURE_LEN2} bytes, got ${sig.length}`
|
|
6619
7226
|
);
|
|
6620
7227
|
}
|
|
6621
|
-
return
|
|
6622
|
-
|
|
6623
|
-
|
|
7228
|
+
return bytesToHex9(
|
|
7229
|
+
concatBytes7(
|
|
7230
|
+
hexToBytes8(SPENDING_POLICY_SELECTORS.claimPolicyByAddress),
|
|
6624
7231
|
encodePolicyWords(normalized),
|
|
6625
7232
|
sig
|
|
6626
7233
|
)
|
|
@@ -6632,34 +7239,70 @@ function encodeEnableCalldata(subAccount) {
|
|
|
6632
7239
|
function encodeDisableCalldata(subAccount) {
|
|
6633
7240
|
return encodeSingleAddressCall(SPENDING_POLICY_SELECTORS.disable, subAccount, "subAccount");
|
|
6634
7241
|
}
|
|
7242
|
+
var ZERO_WORD = new Uint8Array(32);
|
|
6635
7243
|
function normalizeArgs(args) {
|
|
6636
7244
|
return {
|
|
6637
7245
|
subAccount: toUserAddressBytes(args.subAccount, "subAccount"),
|
|
6638
7246
|
principal: toUserAddressBytes(args.principal, "principal"),
|
|
6639
|
-
dailyCapLythoshi:
|
|
6640
|
-
perTxCapLythoshi:
|
|
6641
|
-
allowRoot:
|
|
6642
|
-
denyRoot:
|
|
7247
|
+
dailyCapLythoshi: toBigint4(args.dailyCapLythoshi, "dailyCapLythoshi"),
|
|
7248
|
+
perTxCapLythoshi: toBigint4(args.perTxCapLythoshi, "perTxCapLythoshi"),
|
|
7249
|
+
allowRoot: expectLength6(toBytes6(args.allowRoot), 32, "allowRoot"),
|
|
7250
|
+
denyRoot: expectLength6(toBytes6(args.denyRoot), 32, "denyRoot"),
|
|
7251
|
+
weeklyCapLythoshi: toBigint4(args.weeklyCapLythoshi ?? 0n, "weeklyCapLythoshi"),
|
|
7252
|
+
monthlyCapLythoshi: toBigint4(args.monthlyCapLythoshi ?? 0n, "monthlyCapLythoshi"),
|
|
7253
|
+
categoryAllowRoot: args.categoryAllowRoot == null ? ZERO_WORD : expectLength6(toBytes6(args.categoryAllowRoot), 32, "categoryAllowRoot"),
|
|
7254
|
+
timeWindow: args.timeWindow == null ? ZERO_WORD : expectLength6(toBytes6(args.timeWindow), 32, "timeWindow"),
|
|
7255
|
+
policyExpiry: toBigint4(args.policyExpiry ?? 0n, "policyExpiry")
|
|
6643
7256
|
};
|
|
6644
7257
|
}
|
|
6645
7258
|
function encodePolicyWords(args) {
|
|
6646
|
-
return
|
|
7259
|
+
return concatBytes7(
|
|
6647
7260
|
encodeAddressWord(args.subAccount),
|
|
6648
7261
|
encodeAddressWord(args.principal),
|
|
6649
7262
|
encodeUint128Word(args.dailyCapLythoshi),
|
|
6650
7263
|
encodeUint128Word(args.perTxCapLythoshi),
|
|
6651
7264
|
args.allowRoot,
|
|
6652
|
-
args.denyRoot
|
|
7265
|
+
args.denyRoot,
|
|
7266
|
+
// WP §18.8 trailing 5 words: weekly cap, monthly cap, category
|
|
7267
|
+
// allow-root, packed time window, policy expiry.
|
|
7268
|
+
encodeUint128Word(args.weeklyCapLythoshi),
|
|
7269
|
+
encodeUint128Word(args.monthlyCapLythoshi),
|
|
7270
|
+
args.categoryAllowRoot,
|
|
7271
|
+
args.timeWindow,
|
|
7272
|
+
encodeUint64Word(args.policyExpiry)
|
|
6653
7273
|
);
|
|
6654
7274
|
}
|
|
7275
|
+
function packTimeWindow(enabled, startHour, endHour) {
|
|
7276
|
+
const out = new Uint8Array(32);
|
|
7277
|
+
if (!enabled) return out;
|
|
7278
|
+
out[29] = 1;
|
|
7279
|
+
out[30] = clampHour(startHour);
|
|
7280
|
+
out[31] = clampHour(endHour);
|
|
7281
|
+
return out;
|
|
7282
|
+
}
|
|
7283
|
+
function decodeTimeWindow(word) {
|
|
7284
|
+
const bytes = expectLength6(toBytes6(word), 32, "timeWindow");
|
|
7285
|
+
if (bytes.every((b) => b === 0)) return null;
|
|
7286
|
+
if (bytes[29] === 0) return null;
|
|
7287
|
+
return [Math.min(bytes[30], 23), Math.min(bytes[31], 23)];
|
|
7288
|
+
}
|
|
7289
|
+
function clampHour(hour) {
|
|
7290
|
+
if (!Number.isInteger(hour) || hour < 0) {
|
|
7291
|
+
throw new SpendingPolicyError("time-window hour must be a non-negative integer");
|
|
7292
|
+
}
|
|
7293
|
+
return Math.min(hour, 23);
|
|
7294
|
+
}
|
|
7295
|
+
function encodeUint64Word(value) {
|
|
7296
|
+
return concatBytes7(new Uint8Array(24), uint64Bytes(value, "policyExpiry"));
|
|
7297
|
+
}
|
|
6655
7298
|
function encodeSingleAddressCall(selector, address, name) {
|
|
6656
|
-
return
|
|
7299
|
+
return bytesToHex9(concatBytes7(hexToBytes8(selector), encodeAddressWord(toUserAddressBytes(address, name))));
|
|
6657
7300
|
}
|
|
6658
7301
|
function encodeAddressWord(address) {
|
|
6659
|
-
return
|
|
7302
|
+
return concatBytes7(new Uint8Array(12), address);
|
|
6660
7303
|
}
|
|
6661
7304
|
function encodeUint128Word(value) {
|
|
6662
|
-
return
|
|
7305
|
+
return concatBytes7(new Uint8Array(16), uint128Bytes(value, "uint128"));
|
|
6663
7306
|
}
|
|
6664
7307
|
function toUserAddressBytes(value, name) {
|
|
6665
7308
|
if (typeof value !== "string") {
|
|
@@ -6679,15 +7322,15 @@ function toRawAddressBytes(value) {
|
|
|
6679
7322
|
if (typeof value === "string") {
|
|
6680
7323
|
return hexToAddressBytes(value);
|
|
6681
7324
|
}
|
|
6682
|
-
return
|
|
7325
|
+
return expectLength6(value instanceof Uint8Array ? value : Uint8Array.from(value), 20, "address");
|
|
6683
7326
|
}
|
|
6684
|
-
function
|
|
7327
|
+
function toBytes6(value) {
|
|
6685
7328
|
if (typeof value === "string") {
|
|
6686
|
-
return
|
|
7329
|
+
return hexToBytes8(value);
|
|
6687
7330
|
}
|
|
6688
7331
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6689
7332
|
}
|
|
6690
|
-
function
|
|
7333
|
+
function hexToBytes8(hex) {
|
|
6691
7334
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6692
7335
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6693
7336
|
throw new SpendingPolicyError("invalid hex bytes");
|
|
@@ -6698,10 +7341,10 @@ function hexToBytes6(hex) {
|
|
|
6698
7341
|
}
|
|
6699
7342
|
return out;
|
|
6700
7343
|
}
|
|
6701
|
-
function
|
|
7344
|
+
function bytesToHex9(bytes) {
|
|
6702
7345
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6703
7346
|
}
|
|
6704
|
-
function
|
|
7347
|
+
function concatBytes7(...parts) {
|
|
6705
7348
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6706
7349
|
let offset = 0;
|
|
6707
7350
|
for (const part of parts) {
|
|
@@ -6710,13 +7353,13 @@ function concatBytes6(...parts) {
|
|
|
6710
7353
|
}
|
|
6711
7354
|
return out;
|
|
6712
7355
|
}
|
|
6713
|
-
function
|
|
7356
|
+
function expectLength6(value, len, name) {
|
|
6714
7357
|
if (value.length !== len) {
|
|
6715
7358
|
throw new SpendingPolicyError(`${name} must be ${len} bytes`);
|
|
6716
7359
|
}
|
|
6717
7360
|
return value;
|
|
6718
7361
|
}
|
|
6719
|
-
function
|
|
7362
|
+
function toBigint4(value, name) {
|
|
6720
7363
|
const n = typeof value === "bigint" ? value : BigInt(value);
|
|
6721
7364
|
if (n < 0n) {
|
|
6722
7365
|
throw new SpendingPolicyError(`${name} must be non-negative`);
|
|
@@ -6724,19 +7367,19 @@ function toBigint3(value, name) {
|
|
|
6724
7367
|
return n;
|
|
6725
7368
|
}
|
|
6726
7369
|
function uint64Bytes(value, name) {
|
|
6727
|
-
const n =
|
|
7370
|
+
const n = toBigint4(value, name);
|
|
6728
7371
|
if (n > 0xffffffffffffffffn) {
|
|
6729
7372
|
throw new SpendingPolicyError(`${name} exceeds uint64`);
|
|
6730
7373
|
}
|
|
6731
|
-
return
|
|
7374
|
+
return bigintBytes2(n, 8);
|
|
6732
7375
|
}
|
|
6733
7376
|
function uint128Bytes(value, name) {
|
|
6734
7377
|
if (value > 0xffffffffffffffffffffffffffffffffn) {
|
|
6735
7378
|
throw new SpendingPolicyError(`${name} exceeds uint128`);
|
|
6736
7379
|
}
|
|
6737
|
-
return
|
|
7380
|
+
return bigintBytes2(value, 16);
|
|
6738
7381
|
}
|
|
6739
|
-
function
|
|
7382
|
+
function bigintBytes2(value, len) {
|
|
6740
7383
|
const out = new Uint8Array(len);
|
|
6741
7384
|
let n = value;
|
|
6742
7385
|
for (let i = len - 1; i >= 0; i--) {
|
|
@@ -6763,15 +7406,15 @@ function pubkeyRegistryAddressHex() {
|
|
|
6763
7406
|
return PRECOMPILE_ADDRESSES.PUBKEY_REGISTRY.toLowerCase();
|
|
6764
7407
|
}
|
|
6765
7408
|
function encodeRegisterPubkeyCalldata(pubkey) {
|
|
6766
|
-
const bytes =
|
|
7409
|
+
const bytes = toBytes7(pubkey);
|
|
6767
7410
|
if (bytes.length !== PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN) {
|
|
6768
7411
|
throw new PubkeyRegistryError(
|
|
6769
7412
|
`pubkey must be ${PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN} bytes, got ${bytes.length}`
|
|
6770
7413
|
);
|
|
6771
7414
|
}
|
|
6772
|
-
return
|
|
6773
|
-
|
|
6774
|
-
|
|
7415
|
+
return bytesToHex10(
|
|
7416
|
+
concatBytes8(
|
|
7417
|
+
hexToBytes9(PUBKEY_REGISTRY_SELECTORS.registerPubkey),
|
|
6775
7418
|
uint256Word(32n),
|
|
6776
7419
|
uint256Word(BigInt(bytes.length)),
|
|
6777
7420
|
bytes
|
|
@@ -6785,7 +7428,7 @@ function encodeHasPubkeyCalldata(address) {
|
|
|
6785
7428
|
return encodeSingleAddressCall2(PUBKEY_REGISTRY_SELECTORS.hasPubkey, address);
|
|
6786
7429
|
}
|
|
6787
7430
|
function decodeLookupPubkeyReturn(data) {
|
|
6788
|
-
const bytes =
|
|
7431
|
+
const bytes = toBytes7(data);
|
|
6789
7432
|
if (bytes.length < 96) {
|
|
6790
7433
|
throw new PubkeyRegistryError("lookup return must be at least 96 bytes");
|
|
6791
7434
|
}
|
|
@@ -6810,7 +7453,7 @@ function decodeLookupPubkeyReturn(data) {
|
|
|
6810
7453
|
};
|
|
6811
7454
|
}
|
|
6812
7455
|
function decodeHasPubkeyReturn(data) {
|
|
6813
|
-
const bytes =
|
|
7456
|
+
const bytes = toBytes7(data);
|
|
6814
7457
|
if (bytes.length !== 32) {
|
|
6815
7458
|
throw new PubkeyRegistryError("hasPubkey return must be 32 bytes");
|
|
6816
7459
|
}
|
|
@@ -6824,10 +7467,10 @@ function decodeHasPubkeyReturn(data) {
|
|
|
6824
7467
|
throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
|
|
6825
7468
|
}
|
|
6826
7469
|
function encodeSingleAddressCall2(selector, address) {
|
|
6827
|
-
return
|
|
7470
|
+
return bytesToHex10(concatBytes8(hexToBytes9(selector), addressWord(toAddressBytes(address))));
|
|
6828
7471
|
}
|
|
6829
7472
|
function addressWord(address) {
|
|
6830
|
-
return
|
|
7473
|
+
return concatBytes8(new Uint8Array(12), address);
|
|
6831
7474
|
}
|
|
6832
7475
|
function toAddressBytes(value) {
|
|
6833
7476
|
if (typeof value !== "string") {
|
|
@@ -6843,13 +7486,13 @@ function toAddressBytes(value) {
|
|
|
6843
7486
|
throw new PubkeyRegistryError(`address must be a typed mono bech32m address${detail}`);
|
|
6844
7487
|
}
|
|
6845
7488
|
}
|
|
6846
|
-
function
|
|
7489
|
+
function toBytes7(value) {
|
|
6847
7490
|
if (typeof value === "string") {
|
|
6848
|
-
return
|
|
7491
|
+
return hexToBytes9(value);
|
|
6849
7492
|
}
|
|
6850
7493
|
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
6851
7494
|
}
|
|
6852
|
-
function
|
|
7495
|
+
function hexToBytes9(hex) {
|
|
6853
7496
|
const body = hex.startsWith("0x") || hex.startsWith("0X") ? hex.slice(2) : hex;
|
|
6854
7497
|
if (body.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(body)) {
|
|
6855
7498
|
throw new PubkeyRegistryError("invalid hex bytes");
|
|
@@ -6860,10 +7503,10 @@ function hexToBytes7(hex) {
|
|
|
6860
7503
|
}
|
|
6861
7504
|
return out;
|
|
6862
7505
|
}
|
|
6863
|
-
function
|
|
7506
|
+
function bytesToHex10(bytes) {
|
|
6864
7507
|
return `0x${[...bytes].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
|
|
6865
7508
|
}
|
|
6866
|
-
function
|
|
7509
|
+
function concatBytes8(...parts) {
|
|
6867
7510
|
const out = new Uint8Array(parts.reduce((acc, p) => acc + p.length, 0));
|
|
6868
7511
|
let offset = 0;
|
|
6869
7512
|
for (const part of parts) {
|
|
@@ -6924,8 +7567,47 @@ var CLOB_SELECTORS = {
|
|
|
6924
7567
|
*/
|
|
6925
7568
|
placeMarketOrderEx: "0xa6f092f0",
|
|
6926
7569
|
/** `cancelOrder(bytes32)` */
|
|
6927
|
-
cancelOrder: "0x7489ec23"
|
|
7570
|
+
cancelOrder: "0x7489ec23",
|
|
7571
|
+
/** `setMinNotional(bytes32,bytes32,uint256)` — foundation-authorized. */
|
|
7572
|
+
setMinNotional: "0x395dc48f",
|
|
7573
|
+
/** `setTickSize(bytes32,bytes32,uint256)` — foundation-authorized per-market grid tune. */
|
|
7574
|
+
setTickSize: "0x10666f0b",
|
|
7575
|
+
/** `setLotSize(bytes32,bytes32,uint256)` — foundation-authorized per-market grid tune. */
|
|
7576
|
+
setLotSize: "0x9909be80"
|
|
7577
|
+
};
|
|
7578
|
+
var OPERATOR_ROUTER_SIGS = {
|
|
7579
|
+
/** `registerOperator(address recipient, uint16 feeBps)`. */
|
|
7580
|
+
registerOperator: "registerOperator(address,uint16)",
|
|
7581
|
+
/** `updateOperator(address recipient, uint16 feeBps)`. */
|
|
7582
|
+
updateOperator: "updateOperator(address,uint16)",
|
|
7583
|
+
/** `disableOperator(address operator)` — foundation-authorized. */
|
|
7584
|
+
disableOperator: "disableOperator(address)",
|
|
7585
|
+
/**
|
|
7586
|
+
* `placeLimitOrderVia(address operator, bytes32 base, bytes32 quote,
|
|
7587
|
+
* uint8 side, uint256 price, uint256 amount, uint64 expiresAtBlock)`
|
|
7588
|
+
* → `bytes32 orderId`.
|
|
7589
|
+
*
|
|
7590
|
+
* Skims the operator fee (quote token, `user -> recipient`) then
|
|
7591
|
+
* re-enters the CLOB `placeLimitOrder` op with `caller = user`, so the
|
|
7592
|
+
* resting order is owned + escrowed + cancellable by the user,
|
|
7593
|
+
* identical to a direct CLOB placement.
|
|
7594
|
+
*/
|
|
7595
|
+
placeLimitOrderVia: "placeLimitOrderVia(address,bytes32,bytes32,uint8,uint256,uint256,uint64)"
|
|
7596
|
+
};
|
|
7597
|
+
var OPERATOR_ROUTER_SELECTORS = {
|
|
7598
|
+
registerOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.registerOperator),
|
|
7599
|
+
updateOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.updateOperator),
|
|
7600
|
+
disableOperator: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.disableOperator),
|
|
7601
|
+
placeLimitOrderVia: operatorRouterSelectorHex(OPERATOR_ROUTER_SIGS.placeLimitOrderVia)
|
|
6928
7602
|
};
|
|
7603
|
+
var OPERATOR_ROUTER_EVENT_SIGS = {
|
|
7604
|
+
operatorFeeCharged: "OperatorFeeCharged(address,address,bytes32,address,bytes32,uint256,bytes32)",
|
|
7605
|
+
operatorRegistered: "OperatorRegistered(address,address,uint16)",
|
|
7606
|
+
operatorUpdated: "OperatorUpdated(address,address,uint16,bool)"
|
|
7607
|
+
};
|
|
7608
|
+
function operatorRouterSelectorHex(sig) {
|
|
7609
|
+
return "0x" + [...sha3_js.keccak_256(new TextEncoder().encode(sig)).slice(0, 4)].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
7610
|
+
}
|
|
6929
7611
|
var MarketActionError = class extends Error {
|
|
6930
7612
|
constructor(message) {
|
|
6931
7613
|
super(message);
|
|
@@ -7022,6 +7704,25 @@ function encodeCancelOrderCalldata(args) {
|
|
|
7022
7704
|
)
|
|
7023
7705
|
);
|
|
7024
7706
|
}
|
|
7707
|
+
function encodeMarketGridTuneCalldata(selector, label, args) {
|
|
7708
|
+
return bytesToHex2(
|
|
7709
|
+
concatBytes2(
|
|
7710
|
+
hexToBytes2(selector, `${label} selector`),
|
|
7711
|
+
bytes32FromHex(args.baseTokenId, "baseTokenId"),
|
|
7712
|
+
bytes32FromHex(args.quoteTokenId, "quoteTokenId"),
|
|
7713
|
+
uint256Word2(BigInt(args.newValue), "newValue")
|
|
7714
|
+
)
|
|
7715
|
+
);
|
|
7716
|
+
}
|
|
7717
|
+
function encodeSetMinNotionalCalldata(args) {
|
|
7718
|
+
return encodeMarketGridTuneCalldata(CLOB_SELECTORS.setMinNotional, "setMinNotional", args);
|
|
7719
|
+
}
|
|
7720
|
+
function encodeSetTickSizeCalldata(args) {
|
|
7721
|
+
return encodeMarketGridTuneCalldata(CLOB_SELECTORS.setTickSize, "setTickSize", args);
|
|
7722
|
+
}
|
|
7723
|
+
function encodeSetLotSizeCalldata(args) {
|
|
7724
|
+
return encodeMarketGridTuneCalldata(CLOB_SELECTORS.setLotSize, "setLotSize", args);
|
|
7725
|
+
}
|
|
7025
7726
|
function encodeNativeSpotLimitOrderCall(args) {
|
|
7026
7727
|
const w = new BincodeWriter();
|
|
7027
7728
|
w.enumVariant(0);
|
|
@@ -7285,6 +7986,92 @@ function buildCancelSpotOrderPlan(args) {
|
|
|
7285
7986
|
mempoolClass: MempoolClass.CLOBOp
|
|
7286
7987
|
};
|
|
7287
7988
|
}
|
|
7989
|
+
function encodePlaceLimitOrderViaCalldata(args) {
|
|
7990
|
+
const operator = normalizeNativeMarketAddress(args.operator, "operator");
|
|
7991
|
+
if (operator.kind !== "user") {
|
|
7992
|
+
throw new MarketActionError("operator must be a 'mono' user address");
|
|
7993
|
+
}
|
|
7994
|
+
const side = normalizeSide(args.side);
|
|
7995
|
+
const price = positiveDecimal(args.price, "price");
|
|
7996
|
+
const amount = positiveDecimal(args.amount, "amount");
|
|
7997
|
+
const expiresAtBlock = uint64(args.expiresAtBlock ?? 0n, "expiresAtBlock");
|
|
7998
|
+
return bytesToHex2(
|
|
7999
|
+
concatBytes2(
|
|
8000
|
+
hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
|
|
8001
|
+
addressWord2(operator.bytes),
|
|
8002
|
+
bytes32FromHex(args.base, "base"),
|
|
8003
|
+
bytes32FromHex(args.quote, "quote"),
|
|
8004
|
+
uint8Word2(side),
|
|
8005
|
+
uint256Word2(price, "price"),
|
|
8006
|
+
uint256Word2(amount, "amount"),
|
|
8007
|
+
uint64Word3(expiresAtBlock, "expiresAtBlock")
|
|
8008
|
+
)
|
|
8009
|
+
);
|
|
8010
|
+
}
|
|
8011
|
+
function quoteOperatorFee(args, feeBps) {
|
|
8012
|
+
if (!Number.isInteger(feeBps) || feeBps < 0 || feeBps > PROTOCOL_MAX_OPERATOR_FEE_BPS) {
|
|
8013
|
+
throw new MarketActionError(
|
|
8014
|
+
`feeBps must be an integer in 0..=${PROTOCOL_MAX_OPERATOR_FEE_BPS}`
|
|
8015
|
+
);
|
|
8016
|
+
}
|
|
8017
|
+
const operator = normalizeNativeMarketAddress(args.operator, "operator");
|
|
8018
|
+
if (operator.kind !== "user") {
|
|
8019
|
+
throw new MarketActionError("operator must be a 'mono' user address");
|
|
8020
|
+
}
|
|
8021
|
+
const price = positiveDecimal(args.price, "price");
|
|
8022
|
+
const amount = positiveDecimal(args.amount, "amount");
|
|
8023
|
+
const quoteBasis = price * amount;
|
|
8024
|
+
const feeAmount = quoteBasis * BigInt(feeBps) / 10000n;
|
|
8025
|
+
return {
|
|
8026
|
+
operator: args.operator,
|
|
8027
|
+
feeBps,
|
|
8028
|
+
quoteBasis: quoteBasis.toString(10),
|
|
8029
|
+
feeAmount: feeAmount.toString(10)
|
|
8030
|
+
};
|
|
8031
|
+
}
|
|
8032
|
+
function buildPlaceLimitOrderViaPlan(args, feeBps) {
|
|
8033
|
+
return {
|
|
8034
|
+
method: "eth_sendTransaction",
|
|
8035
|
+
params: [
|
|
8036
|
+
{
|
|
8037
|
+
to: PRECOMPILE_ADDRESSES.OPERATOR_ROUTER,
|
|
8038
|
+
value: "0x0",
|
|
8039
|
+
data: encodePlaceLimitOrderViaCalldata(args)
|
|
8040
|
+
}
|
|
8041
|
+
],
|
|
8042
|
+
mempoolClass: MempoolClass.CLOBOp,
|
|
8043
|
+
operatorFee: quoteOperatorFee(args, feeBps)
|
|
8044
|
+
};
|
|
8045
|
+
}
|
|
8046
|
+
function decodeOperatorFeeChargedEvent(topics, data) {
|
|
8047
|
+
if (topics.length !== 4) {
|
|
8048
|
+
throw new MarketActionError(
|
|
8049
|
+
`OperatorFeeCharged expects 4 topics, got ${topics.length}`
|
|
8050
|
+
);
|
|
8051
|
+
}
|
|
8052
|
+
const topic0 = bytesToHex2(expectWordLen(toEventBytes(topics[0]), "topic0"));
|
|
8053
|
+
const expected = bytesToHex2(
|
|
8054
|
+
sha3_js.keccak_256(new TextEncoder().encode(OPERATOR_ROUTER_EVENT_SIGS.operatorFeeCharged))
|
|
8055
|
+
);
|
|
8056
|
+
if (topic0 !== expected) {
|
|
8057
|
+
throw new MarketActionError("topic0 is not OperatorFeeCharged");
|
|
8058
|
+
}
|
|
8059
|
+
const body = toEventBytes(data);
|
|
8060
|
+
if (body.length !== 4 * 32) {
|
|
8061
|
+
throw new MarketActionError(
|
|
8062
|
+
`OperatorFeeCharged expects 128 data bytes, got ${body.length}`
|
|
8063
|
+
);
|
|
8064
|
+
}
|
|
8065
|
+
return {
|
|
8066
|
+
operator: addressFromEventTopic(topics[1]),
|
|
8067
|
+
user: addressFromEventTopic(topics[2]),
|
|
8068
|
+
marketId: bytesToHex2(expectWordLen(toEventBytes(topics[3]), "marketId")),
|
|
8069
|
+
recipient: bytesToHex2(body.subarray(12, 32)),
|
|
8070
|
+
quoteToken: bytesToHex2(body.subarray(32, 64)),
|
|
8071
|
+
feeAmount: u256DecimalWord(body.subarray(64, 96)),
|
|
8072
|
+
clobOrderId: bytesToHex2(body.subarray(96, 128))
|
|
8073
|
+
};
|
|
8074
|
+
}
|
|
7288
8075
|
function buildNativeCallForwarderArtifact(requestBytes) {
|
|
7289
8076
|
const size = uint64(requestBytes, "requestBytes");
|
|
7290
8077
|
if (size === 0n) {
|
|
@@ -7540,6 +8327,32 @@ function uint256Word2(value, name) {
|
|
|
7540
8327
|
}
|
|
7541
8328
|
return out;
|
|
7542
8329
|
}
|
|
8330
|
+
function addressWord2(addr) {
|
|
8331
|
+
if (addr.length !== 20) {
|
|
8332
|
+
throw new MarketActionError("address must be 20 bytes");
|
|
8333
|
+
}
|
|
8334
|
+
const out = new Uint8Array(32);
|
|
8335
|
+
out.set(addr, 12);
|
|
8336
|
+
return out;
|
|
8337
|
+
}
|
|
8338
|
+
function toEventBytes(value) {
|
|
8339
|
+
if (typeof value === "string") return hexToBytes2(value, "event word");
|
|
8340
|
+
return value instanceof Uint8Array ? value : Uint8Array.from(value);
|
|
8341
|
+
}
|
|
8342
|
+
function expectWordLen(value, name) {
|
|
8343
|
+
if (value.length !== 32) {
|
|
8344
|
+
throw new MarketActionError(`${name} must be 32 bytes, got ${value.length}`);
|
|
8345
|
+
}
|
|
8346
|
+
return value;
|
|
8347
|
+
}
|
|
8348
|
+
function addressFromEventTopic(topic) {
|
|
8349
|
+
return bytesToHex2(expectWordLen(toEventBytes(topic), "address topic").subarray(12, 32));
|
|
8350
|
+
}
|
|
8351
|
+
function u256DecimalWord(word) {
|
|
8352
|
+
let v = 0n;
|
|
8353
|
+
for (const b of word) v = v << 8n | BigInt(b);
|
|
8354
|
+
return v.toString(10);
|
|
8355
|
+
}
|
|
7543
8356
|
function spotLimitOrderInto(w, args, prefix) {
|
|
7544
8357
|
w.rawBytes(bytes32FromHex(args.marketId, `${prefix}marketId`));
|
|
7545
8358
|
monoAddressInto(w, args.owner, `${prefix}owner`);
|
|
@@ -8073,8 +8886,10 @@ exports.CHAIN_REGISTRY = CHAIN_REGISTRY;
|
|
|
8073
8886
|
exports.CHAIN_REGISTRY_RAW_BASE = CHAIN_REGISTRY_RAW_BASE;
|
|
8074
8887
|
exports.CLOB_MARKET_ID_DOMAIN_TAG = CLOB_MARKET_ID_DOMAIN_TAG;
|
|
8075
8888
|
exports.CLOB_SELECTORS = CLOB_SELECTORS;
|
|
8889
|
+
exports.CLUSTER_FORMED_EVENT_SIG = CLUSTER_FORMED_EVENT_SIG;
|
|
8076
8890
|
exports.DELEGATION_REVERT_TAGS = DELEGATION_REVERT_TAGS;
|
|
8077
8891
|
exports.DELEGATION_SELECTORS = DELEGATION_SELECTORS;
|
|
8892
|
+
exports.DIVERSITY_SCORE_MAX = DIVERSITY_SCORE_MAX;
|
|
8078
8893
|
exports.DelegationPrecompileError = DelegationPrecompileError;
|
|
8079
8894
|
exports.LYTHOSHI_PER_LYTH = LYTHOSHI_PER_LYTH;
|
|
8080
8895
|
exports.LYTH_DECIMALS = LYTH_DECIMALS;
|
|
@@ -8097,6 +8912,7 @@ exports.MRV_PROFILE_MONO_RV32IM_V1 = MRV_PROFILE_MONO_RV32IM_V1;
|
|
|
8097
8912
|
exports.MRV_STRUCTURED_FEE_FIELDS = MRV_STRUCTURED_FEE_FIELDS;
|
|
8098
8913
|
exports.MRV_TX_EXTENSION_KIND = MRV_TX_EXTENSION_KIND;
|
|
8099
8914
|
exports.MRV_TX_EXTENSION_V1 = MRV_TX_EXTENSION_V1;
|
|
8915
|
+
exports.MULTISIG_ADDRESS_DERIVATION_DOMAIN = MULTISIG_ADDRESS_DERIVATION_DOMAIN;
|
|
8100
8916
|
exports.MarketActionError = MarketActionError;
|
|
8101
8917
|
exports.MrvValidationError = MrvValidationError;
|
|
8102
8918
|
exports.NATIVE_AGENT_MODULE_ADDRESS = NATIVE_AGENT_MODULE_ADDRESS;
|
|
@@ -8127,12 +8943,29 @@ exports.NO_EVM_RECEIPT_PROOF_TYPE = NO_EVM_RECEIPT_PROOF_TYPE;
|
|
|
8127
8943
|
exports.NO_EVM_RECEIPT_ROOT_ALGORITHM = NO_EVM_RECEIPT_ROOT_ALGORITHM;
|
|
8128
8944
|
exports.NoEvmReceiptProofError = NoEvmReceiptProofError;
|
|
8129
8945
|
exports.NodeRegistryError = NodeRegistryError;
|
|
8946
|
+
exports.OPERATOR_ROUTER_ADDRESS = OPERATOR_ROUTER_ADDRESS;
|
|
8947
|
+
exports.OPERATOR_ROUTER_EVENT_SIGS = OPERATOR_ROUTER_EVENT_SIGS;
|
|
8948
|
+
exports.OPERATOR_ROUTER_SELECTORS = OPERATOR_ROUTER_SELECTORS;
|
|
8949
|
+
exports.OPERATOR_ROUTER_SIGS = OPERATOR_ROUTER_SIGS;
|
|
8950
|
+
exports.ORACLE_EVENT_SIGS = ORACLE_EVENT_SIGS;
|
|
8951
|
+
exports.OracleEventError = OracleEventError;
|
|
8130
8952
|
exports.PRECOMPILE_ADDRESSES = PRECOMPILE_ADDRESSES;
|
|
8953
|
+
exports.PROTOCOL_MAX_OPERATOR_FEE_BPS = PROTOCOL_MAX_OPERATOR_FEE_BPS;
|
|
8954
|
+
exports.PROVER_MARKET_ADDRESS = PROVER_MARKET_ADDRESS;
|
|
8955
|
+
exports.PROVER_MARKET_BID_DOMAIN = PROVER_MARKET_BID_DOMAIN;
|
|
8956
|
+
exports.PROVER_MARKET_EVENT_SIGS = PROVER_MARKET_EVENT_SIGS;
|
|
8957
|
+
exports.PROVER_MARKET_REQUEST_DOMAIN = PROVER_MARKET_REQUEST_DOMAIN;
|
|
8958
|
+
exports.PROVER_MARKET_SELECTORS = PROVER_MARKET_SELECTORS;
|
|
8959
|
+
exports.PROVER_MARKET_SUBMIT_DOMAIN = PROVER_MARKET_SUBMIT_DOMAIN;
|
|
8960
|
+
exports.PROVER_SLASH_REASON_BAD_PROOF = PROVER_SLASH_REASON_BAD_PROOF;
|
|
8961
|
+
exports.PROVER_SLASH_REASON_NON_DELIVERY = PROVER_SLASH_REASON_NON_DELIVERY;
|
|
8131
8962
|
exports.PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN = PUBKEY_REGISTRY_ML_DSA_65_PUBLIC_KEY_LEN;
|
|
8132
8963
|
exports.PUBKEY_REGISTRY_SELECTORS = PUBKEY_REGISTRY_SELECTORS;
|
|
8964
|
+
exports.ProverMarketError = ProverMarketError;
|
|
8133
8965
|
exports.PubkeyRegistryError = PubkeyRegistryError;
|
|
8134
8966
|
exports.RESERVED_ADDRESS_HRPS = RESERVED_ADDRESS_HRPS;
|
|
8135
8967
|
exports.RpcClient = RpcClient;
|
|
8968
|
+
exports.SERVES_GPU_PROVE = SERVES_GPU_PROVE;
|
|
8136
8969
|
exports.SERVICE_PROBE_STATUS = SERVICE_PROBE_STATUS;
|
|
8137
8970
|
exports.SET_POLICY_CLAIM_DOMAIN_TAG = SET_POLICY_CLAIM_DOMAIN_TAG;
|
|
8138
8971
|
exports.SPENDING_POLICY_SELECTORS = SPENDING_POLICY_SELECTORS;
|
|
@@ -8156,7 +8989,9 @@ exports.assertNativeMarketOrderBookStreamPayload = assertNativeMarketOrderBookSt
|
|
|
8156
8989
|
exports.assessBridgeRoute = assessBridgeRoute;
|
|
8157
8990
|
exports.bech32ToAddress = bech32ToAddress;
|
|
8158
8991
|
exports.bech32ToAddressBytes = bech32ToAddressBytes;
|
|
8992
|
+
exports.bidSighash = bidSighash;
|
|
8159
8993
|
exports.bridgeAddressHex = bridgeAddressHex;
|
|
8994
|
+
exports.bridgeDrainRemaining = bridgeDrainRemaining;
|
|
8160
8995
|
exports.bridgeQuoteSubmitReadiness = bridgeQuoteSubmitReadiness;
|
|
8161
8996
|
exports.bridgeRoutesReadiness = bridgeRoutesReadiness;
|
|
8162
8997
|
exports.bridgeTransferCandidates = bridgeTransferCandidates;
|
|
@@ -8202,6 +9037,7 @@ exports.buildNativeSpotSettleLimitOrderForwarderInput = buildNativeSpotSettleLim
|
|
|
8202
9037
|
exports.buildNativeSpotSettleLimitOrderModuleCall = buildNativeSpotSettleLimitOrderModuleCall;
|
|
8203
9038
|
exports.buildNativeSpotSettleRoutedLimitOrderForwarderInput = buildNativeSpotSettleRoutedLimitOrderForwarderInput;
|
|
8204
9039
|
exports.buildNativeSpotSettleRoutedLimitOrderModuleCall = buildNativeSpotSettleRoutedLimitOrderModuleCall;
|
|
9040
|
+
exports.buildPlaceLimitOrderViaPlan = buildPlaceLimitOrderViaPlan;
|
|
8205
9041
|
exports.buildPlaceSpotLimitOrderPlan = buildPlaceSpotLimitOrderPlan;
|
|
8206
9042
|
exports.buildPlaceSpotMarketOrderExPlan = buildPlaceSpotMarketOrderExPlan;
|
|
8207
9043
|
exports.buildPlaceSpotMarketOrderPlan = buildPlaceSpotMarketOrderPlan;
|
|
@@ -8217,15 +9053,22 @@ exports.computeNoEvmReceiptsRoot = computeNoEvmReceiptsRoot;
|
|
|
8217
9053
|
exports.computeNoEvmRoundFinalityMessage = computeNoEvmRoundFinalityMessage;
|
|
8218
9054
|
exports.computeNoEvmTargetReceiptHash = computeNoEvmTargetReceiptHash;
|
|
8219
9055
|
exports.consumeNativeEvents = consumeNativeEvents;
|
|
9056
|
+
exports.decodeClusterDiversity = decodeClusterDiversity;
|
|
9057
|
+
exports.decodeClusterFormedEvent = decodeClusterFormedEvent;
|
|
8220
9058
|
exports.decodeHasPubkeyReturn = decodeHasPubkeyReturn;
|
|
8221
9059
|
exports.decodeLookupPubkeyReturn = decodeLookupPubkeyReturn;
|
|
8222
9060
|
exports.decodeNativeAgentStateResponse = decodeNativeAgentStateResponse;
|
|
8223
9061
|
exports.decodeNativeMarketOrderBookDeltasResponse = decodeNativeMarketOrderBookDeltasResponse;
|
|
8224
9062
|
exports.decodeNativeReceiptResponse = decodeNativeReceiptResponse;
|
|
8225
9063
|
exports.decodeNoEvmReceiptTranscript = decodeNoEvmReceiptTranscript;
|
|
9064
|
+
exports.decodeOperatorFeeChargedEvent = decodeOperatorFeeChargedEvent;
|
|
9065
|
+
exports.decodeOperatorNetworkMetadata = decodeOperatorNetworkMetadata;
|
|
9066
|
+
exports.decodeOracleEvent = decodeOracleEvent;
|
|
9067
|
+
exports.decodeTimeWindow = decodeTimeWindow;
|
|
8226
9068
|
exports.decodeTxFeedResponse = decodeTxFeedResponse;
|
|
8227
9069
|
exports.delegationAddressHex = delegationAddressHex;
|
|
8228
9070
|
exports.deriveClobMarketId = deriveClobMarketId;
|
|
9071
|
+
exports.deriveClusterAnchorAddress = deriveClusterAnchorAddress;
|
|
8229
9072
|
exports.deriveMrvContractAddress = deriveMrvContractAddress;
|
|
8230
9073
|
exports.deriveNativeSpotMarketId = deriveNativeSpotMarketId;
|
|
8231
9074
|
exports.deriveNativeSpotOrderId = deriveNativeSpotOrderId;
|
|
@@ -8234,6 +9077,8 @@ exports.encodeCancelOrderCalldata = encodeCancelOrderCalldata;
|
|
|
8234
9077
|
exports.encodeClaimCalldata = encodeClaimCalldata;
|
|
8235
9078
|
exports.encodeClaimPolicyByAddressCalldata = encodeClaimPolicyByAddressCalldata;
|
|
8236
9079
|
exports.encodeCompleteRedemptionCalldata = encodeCompleteRedemptionCalldata;
|
|
9080
|
+
exports.encodeCreateRequestCalldata = encodeCreateRequestCalldata;
|
|
9081
|
+
exports.encodeCreateRequestCanonical = encodeCreateRequestCanonical;
|
|
8237
9082
|
exports.encodeDelegateCalldata = encodeDelegateCalldata;
|
|
8238
9083
|
exports.encodeDisableCalldata = encodeDisableCalldata;
|
|
8239
9084
|
exports.encodeEnableCalldata = encodeEnableCalldata;
|
|
@@ -8287,6 +9132,7 @@ exports.encodeNativeSpotLimitOrderCall = encodeNativeSpotLimitOrderCall;
|
|
|
8287
9132
|
exports.encodeNativeSpotSettleLimitOrderCall = encodeNativeSpotSettleLimitOrderCall;
|
|
8288
9133
|
exports.encodeNativeSpotSettleRoutedLimitOrderCall = encodeNativeSpotSettleRoutedLimitOrderCall;
|
|
8289
9134
|
exports.encodePlaceLimitOrderCalldata = encodePlaceLimitOrderCalldata;
|
|
9135
|
+
exports.encodePlaceLimitOrderViaCalldata = encodePlaceLimitOrderViaCalldata;
|
|
8290
9136
|
exports.encodePlaceMarketOrderCalldata = encodePlaceMarketOrderCalldata;
|
|
8291
9137
|
exports.encodePlaceMarketOrderExCalldata = encodePlaceMarketOrderExCalldata;
|
|
8292
9138
|
exports.encodeRedelegateCalldata = encodeRedelegateCalldata;
|
|
@@ -8295,8 +9141,11 @@ exports.encodeReportServiceProbeCalldata = encodeReportServiceProbeCalldata;
|
|
|
8295
9141
|
exports.encodeSetAutoCompoundCalldata = encodeSetAutoCompoundCalldata;
|
|
8296
9142
|
exports.encodeSetBridgeResumeCooldownCalldata = encodeSetBridgeResumeCooldownCalldata;
|
|
8297
9143
|
exports.encodeSetBridgeRouteFinalityCalldata = encodeSetBridgeRouteFinalityCalldata;
|
|
9144
|
+
exports.encodeSetLotSizeCalldata = encodeSetLotSizeCalldata;
|
|
9145
|
+
exports.encodeSetMinNotionalCalldata = encodeSetMinNotionalCalldata;
|
|
8298
9146
|
exports.encodeSetPolicyCalldata = encodeSetPolicyCalldata;
|
|
8299
9147
|
exports.encodeSetPolicyClaimCalldata = encodeSetPolicyClaimCalldata;
|
|
9148
|
+
exports.encodeSetTickSizeCalldata = encodeSetTickSizeCalldata;
|
|
8300
9149
|
exports.encodeUndelegateCalldata = encodeUndelegateCalldata;
|
|
8301
9150
|
exports.exportBridgeRouteCatalogueJson = exportBridgeRouteCatalogueJson;
|
|
8302
9151
|
exports.fetchChainInfoLatest = fetchChainInfoLatest;
|
|
@@ -8336,9 +9185,13 @@ exports.nativeMarketEventsFromHistory = nativeMarketEventsFromHistory;
|
|
|
8336
9185
|
exports.nativeMarketEventsFromReceipt = nativeMarketEventsFromReceipt;
|
|
8337
9186
|
exports.nativeMarketStateFilterParams = nativeMarketStateFilterParams;
|
|
8338
9187
|
exports.noEvmReceiptTrustPolicyFromChainInfo = noEvmReceiptTrustPolicyFromChainInfo;
|
|
9188
|
+
exports.nodeHostingClassFromByte = nodeHostingClassFromByte;
|
|
9189
|
+
exports.nodeHostingClassToByte = nodeHostingClassToByte;
|
|
8339
9190
|
exports.nodeRegistryAddressHex = nodeRegistryAddressHex;
|
|
8340
9191
|
exports.normalizeAddressHex = normalizeAddressHex;
|
|
8341
9192
|
exports.normalizeBridgeRouteCatalogue = normalizeBridgeRouteCatalogue;
|
|
9193
|
+
exports.oracleAddressHex = oracleAddressHex;
|
|
9194
|
+
exports.packTimeWindow = packTimeWindow;
|
|
8342
9195
|
exports.parseAddress = parseAddress;
|
|
8343
9196
|
exports.parseBridgeRouteCatalogueJson = parseBridgeRouteCatalogueJson;
|
|
8344
9197
|
exports.parseChainRegistryToml = parseChainRegistryToml;
|
|
@@ -8346,8 +9199,11 @@ exports.parseLythToLythoshi = parseLythToLythoshi;
|
|
|
8346
9199
|
exports.parseNativeDecodedEvent = parseNativeDecodedEvent;
|
|
8347
9200
|
exports.parseQuantity = parseQuantity;
|
|
8348
9201
|
exports.parseQuantityBig = parseQuantityBig;
|
|
9202
|
+
exports.proverMarketStateFromByte = proverMarketStateFromByte;
|
|
8349
9203
|
exports.pubkeyRegistryAddressHex = pubkeyRegistryAddressHex;
|
|
9204
|
+
exports.quoteOperatorFee = quoteOperatorFee;
|
|
8350
9205
|
exports.rankBridgeRoutes = rankBridgeRoutes;
|
|
9206
|
+
exports.requestSighash = requestSighash;
|
|
8351
9207
|
exports.requireTypedAddress = requireTypedAddress;
|
|
8352
9208
|
exports.resolveStudioHostStatus = resolveStudioHostStatus;
|
|
8353
9209
|
exports.selectBridgeTransferRoute = selectBridgeTransferRoute;
|
|
@@ -8356,6 +9212,7 @@ exports.spendingPolicyAddressHex = spendingPolicyAddressHex;
|
|
|
8356
9212
|
exports.submitMrvCallNativeTx = submitMrvCallNativeTx;
|
|
8357
9213
|
exports.submitMrvDeployNativeTx = submitMrvDeployNativeTx;
|
|
8358
9214
|
exports.submitMrvDeployPayloadNativeTx = submitMrvDeployPayloadNativeTx;
|
|
9215
|
+
exports.submitSighash = submitSighash;
|
|
8359
9216
|
exports.typedBech32ToAddress = typedBech32ToAddress;
|
|
8360
9217
|
exports.validateAddress = validateAddress;
|
|
8361
9218
|
exports.validateBridgeRouteCatalogue = validateBridgeRouteCatalogue;
|