@monolythium/core-sdk 0.4.15 → 0.4.17

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/index.cjs CHANGED
@@ -266,84 +266,6 @@ function expectLength(value, len, name) {
266
266
  return value instanceof Uint8Array ? value : Uint8Array.from(value);
267
267
  }
268
268
 
269
- // src/native-events.ts
270
- var NATIVE_MARKET_EVENT_FAMILY = "market";
271
- function nativeMarketEventFilter(filter = {}) {
272
- return { ...filter, family: NATIVE_MARKET_EVENT_FAMILY };
273
- }
274
- function isNativeDecodedEvent(value) {
275
- const row = asRecord(value);
276
- return row !== null && typeof row["block_height"] === "number" && typeof row["tx_index"] === "number" && typeof row["sequence"] === "number" && typeof row["family"] === "string" && typeof row["event_name"] === "string" && typeof row["payload_hash"] === "string";
277
- }
278
- function parseNativeDecodedEvent(event) {
279
- if (isNativeDecodedEvent(event.decoded)) {
280
- return event.decoded;
281
- }
282
- try {
283
- const parsed = JSON.parse(event.decodedJson);
284
- if (isNativeDecodedEvent(parsed)) {
285
- return parsed;
286
- }
287
- } catch {
288
- }
289
- throw SdkError.malformed(
290
- `native event ${event.eventTopic} at logIndex ${event.logIndex} is missing a typed decoded payload`
291
- );
292
- }
293
- function nativeEventMatches(event, filter = {}) {
294
- if (filter.address !== void 0 && event.address !== filter.address) return false;
295
- if (filter.eventTopic !== void 0 && event.eventTopic !== filter.eventTopic) return false;
296
- if (filter.family === void 0 && filter.eventName === void 0) return true;
297
- let decoded;
298
- try {
299
- decoded = parseNativeDecodedEvent(event);
300
- } catch {
301
- return false;
302
- }
303
- if (filter.family !== void 0 && decoded.family !== filter.family) return false;
304
- if (filter.eventName !== void 0 && decoded.event_name !== filter.eventName) return false;
305
- return true;
306
- }
307
- function nativeEventsFromReceipt(receipt, filter = {}) {
308
- return receipt.events.filter((event) => nativeEventMatches(event, filter)).map((event) => ({
309
- ...event,
310
- decoded: parseNativeDecodedEvent(event)
311
- }));
312
- }
313
- function nativeMarketEventsFromReceipt(receipt, filter = {}) {
314
- return nativeEventsFromReceipt(receipt, nativeMarketEventFilter(filter));
315
- }
316
- function nativeEventsFromHistory(response) {
317
- return {
318
- ...response,
319
- events: response.events.map((event) => ({
320
- ...event,
321
- decoded: parseNativeDecodedEvent(event)
322
- }))
323
- };
324
- }
325
- function nativeMarketEventsFromHistory(response) {
326
- return {
327
- ...response,
328
- filters: { ...response.filters, family: NATIVE_MARKET_EVENT_FAMILY },
329
- events: response.events.filter((event) => nativeEventMatches(event, { family: NATIVE_MARKET_EVENT_FAMILY })).map((event) => ({
330
- ...event,
331
- decoded: parseNativeDecodedEvent(event)
332
- }))
333
- };
334
- }
335
- async function consumeNativeEvents(receipt, consumer, filter = {}) {
336
- const events = nativeEventsFromReceipt(receipt, filter);
337
- for (const event of events) {
338
- await consumer(event);
339
- }
340
- return events.length;
341
- }
342
- function asRecord(value) {
343
- if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
344
- return value;
345
- }
346
-
347
269
  // src/consts.ts
348
270
  var BURN_ADDR = "0x0000000000000000000000000000000000000000";
349
271
  var PRECOMPILE_ADDRESSES = {
@@ -463,7 +385,33 @@ var NODE_REGISTRY_SELECTORS = {
463
385
  /** `publishOperatorSealKey(bytes32,bytes)` — owner-callable LythiumSeal EK publication. */
464
386
  publishOperatorSealKey: "0x" + selectorHex("publishOperatorSealKey(bytes32,bytes)"),
465
387
  /** `getOperatorSealKey(bytes32)` view — returns the operator's published LythiumSeal EK. */
466
- getOperatorSealKey: "0x" + selectorHex("getOperatorSealKey(bytes32)")
388
+ getOperatorSealKey: "0x" + selectorHex("getOperatorSealKey(bytes32)"),
389
+ /**
390
+ * `updateCharter(uint32,bytes,bytes,bytes)` — Component H live charter
391
+ * amendment (Law §6.8); re-signs a new 30-byte charter for a LIVE cluster
392
+ * with a delegator-protective cooldown. Consents verify over
393
+ * `updateCharterMessage` (NOT the formCluster digests).
394
+ */
395
+ updateCharter: "0x" + selectorHex("updateCharter(uint32,bytes,bytes,bytes)"),
396
+ /** `getPendingCharter(uint32)` view — Component H pending-amendment status. */
397
+ getPendingCharter: "0x" + selectorHex("getPendingCharter(uint32)"),
398
+ /** `commitArchiveRoot(bytes32,uint16,bytes32,uint64)` — Component B archive serve-challenge commit. */
399
+ commitArchiveRoot: "0x" + selectorHex("commitArchiveRoot(bytes32,uint16,bytes32,uint64)"),
400
+ /**
401
+ * `answerArchiveChallenge(bytes32,uint16,uint64,bytes,bytes32[])` —
402
+ * Component B answer. BLOCKER-1 (mono-core `service-rewards` d2ee4548):
403
+ * the caller-supplied `roundCertDigest` + `nonce` were REMOVED — the
404
+ * challenge seed is now the protocol-pinned per-epoch quorum-certificate
405
+ * digest and the nonce is derived from it. 5 args: peerId, shardIndex,
406
+ * epoch, leaf, proof.
407
+ */
408
+ answerArchiveChallenge: "0x" + selectorHex("answerArchiveChallenge(bytes32,uint16,uint64,bytes,bytes32[])"),
409
+ /** `setProbeAuthority(address)` — Component C foundation-gated probe-authority rotation. */
410
+ setProbeAuthority: "0x" + selectorHex("setProbeAuthority(address)"),
411
+ /** `getProbeAuthority()` view — Component C configured probe-authority address. */
412
+ getProbeAuthority: "0x" + selectorHex("getProbeAuthority()"),
413
+ /** `attestServiceProbe(bytes32,uint32,uint8,uint64)` — Component C attested score-eligibility path. */
414
+ attestServiceProbe: "0x" + selectorHex("attestServiceProbe(bytes32,uint32,uint8,uint64)")
467
415
  };
468
416
  var NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES = 48;
469
417
  var NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES = NODE_REGISTRY_CLUSTER_MEMBER_REF_BYTES;
@@ -488,6 +436,23 @@ var NODE_REGISTRY_CLUSTER_CHARTER_DELEGATOR_FLOOR_BPS = 2e3;
488
436
  var NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS = 1e4;
489
437
  var NODE_REGISTRY_OPERATOR_MONIKER_MAX_BYTES = 128;
490
438
  var NODE_REGISTRY_OPERATOR_ALIAS_MAX_BYTES = 64;
439
+ var NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD = NODE_REGISTRY_FORM_CLUSTER_THRESHOLD;
440
+ var NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN = "PROTOCORE_NODE_REGISTRY_CLUSTER_UPDATE_CHARTER_V1\0";
441
+ var NODE_REGISTRY_CHARTER_COOLDOWN_EPOCHS = 2;
442
+ var NODE_REGISTRY_ARCHIVE_CHALLENGE_DOMAIN = "monolythium.archive-challenge.v1";
443
+ var NODE_REGISTRY_ARCHIVE_NONCE_DOMAIN = "monolythium.archive-challenge.nonce.v1";
444
+ var NODE_REGISTRY_MERKLE_LEAF_DOMAIN = 0;
445
+ var NODE_REGISTRY_MERKLE_INNER_DOMAIN = 1;
446
+ var NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH = 40;
447
+ var NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT = 65536n;
448
+ var NODE_REGISTRY_CHALLENGE_EPOCH_WINDOW = 2n;
449
+ var NODE_REGISTRY_ARCHIVE_KIND_EPOCH_SEED = 3;
450
+ var NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE = 50;
451
+ var NODE_REGISTRY_TAG_SERVICE_SCORE = 36;
452
+ var NODE_REGISTRY_TAG_TREASURY = 31;
453
+ var NODE_REGISTRY_TAG_CLUSTER_CHARTER = 49;
454
+ var NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS = 0;
455
+ var NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES = 1;
491
456
  var PENDING_CHANGE_KIND_CODES = {
492
457
  add: 1,
493
458
  remove: 2,
@@ -965,6 +930,356 @@ function encodeFormClusterV2Calldata(args) {
965
930
  )
966
931
  );
967
932
  }
933
+ function decodeClusterCharter(charter) {
934
+ const bytes = expectLength2(toBytes(charter), NODE_REGISTRY_CLUSTER_CHARTER_BYTES, "charter");
935
+ const memberShareBps = [];
936
+ let sum = 0;
937
+ for (let i = 0; i < NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT; i += 1) {
938
+ const bps = bytes[2 * i] << 8 | bytes[2 * i + 1];
939
+ memberShareBps.push(bps);
940
+ sum += bps;
941
+ }
942
+ if (sum !== NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS) {
943
+ throw new NodeRegistryError(
944
+ `memberShareBps must sum to ${NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS}, got ${sum}`
945
+ );
946
+ }
947
+ const delegatorShareBps = bytes[20] << 8 | bytes[21];
948
+ if (delegatorShareBps < NODE_REGISTRY_CLUSTER_CHARTER_DELEGATOR_FLOOR_BPS || delegatorShareBps > NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS) {
949
+ throw new NodeRegistryError(
950
+ `delegatorShareBps must be within [${NODE_REGISTRY_CLUSTER_CHARTER_DELEGATOR_FLOOR_BPS}, ${NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS}], got ${delegatorShareBps}`
951
+ );
952
+ }
953
+ let expiresMs = 0n;
954
+ for (let i = 22; i < 30; i += 1) {
955
+ expiresMs = expiresMs << 8n | BigInt(bytes[i]);
956
+ }
957
+ return { memberShareBps, delegatorShareBps, expiresMs };
958
+ }
959
+ function updateCharterMessage(clusterId, charter) {
960
+ const id = toUint32(clusterId, "clusterId");
961
+ const charterBytes = expectLength2(toBytes(charter), NODE_REGISTRY_CLUSTER_CHARTER_BYTES, "charter");
962
+ return blake3_js.blake3(
963
+ concatBytes(
964
+ new TextEncoder().encode(NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN),
965
+ u32BeBytes(id),
966
+ u16BeBytes(NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD),
967
+ u32BeBytes(charterBytes.length),
968
+ charterBytes
969
+ )
970
+ );
971
+ }
972
+ function updateCharterMessageHex(clusterId, charter) {
973
+ return bytesToHex(updateCharterMessage(clusterId, charter));
974
+ }
975
+ function encodeUpdateCharterCalldata(args) {
976
+ const id = toUint32(args.clusterId, "clusterId");
977
+ const charter = expectLength2(
978
+ toBytes(args.charter),
979
+ NODE_REGISTRY_CLUSTER_CHARTER_BYTES,
980
+ "charter"
981
+ );
982
+ const signerPubkeys = flattenFixedWidth(
983
+ args.signerPubkeys,
984
+ NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES,
985
+ "signerPubkeys"
986
+ );
987
+ const signatures = flattenFixedWidth(
988
+ args.signatures,
989
+ NODE_REGISTRY_CONSENSUS_SIGNATURE_BYTES,
990
+ "signatures"
991
+ );
992
+ const nPubkeys = signerPubkeys.length / NODE_REGISTRY_CONSENSUS_PUBKEY_BYTES;
993
+ const nSigs = signatures.length / NODE_REGISTRY_CONSENSUS_SIGNATURE_BYTES;
994
+ if (nPubkeys !== nSigs) {
995
+ throw new NodeRegistryError(
996
+ `signerPubkeys (${nPubkeys}) and signatures (${nSigs}) counts must match`
997
+ );
998
+ }
999
+ if (nPubkeys < NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD || nPubkeys > NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT) {
1000
+ throw new NodeRegistryError(
1001
+ `signer count must be in [${NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD}, ${NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT}], got ${nPubkeys}`
1002
+ );
1003
+ }
1004
+ const charterPadded = padToWord(charter);
1005
+ const signerPadded = padToWord(signerPubkeys);
1006
+ const sigsPadded = padToWord(signatures);
1007
+ const charterOffset = 4n * 32n;
1008
+ const signerOffset = charterOffset + 32n + BigInt(charterPadded.length);
1009
+ const sigsOffset = signerOffset + 32n + BigInt(signerPadded.length);
1010
+ return bytesToHex(
1011
+ concatBytes(
1012
+ hexToBytes(NODE_REGISTRY_SELECTORS.updateCharter),
1013
+ uint32Word(id),
1014
+ uint64Word(charterOffset, "charterOffset"),
1015
+ uint64Word(signerOffset, "signerPubkeysOffset"),
1016
+ uint64Word(sigsOffset, "signaturesOffset"),
1017
+ uint64Word(BigInt(charter.length), "charterLength"),
1018
+ charterPadded,
1019
+ uint64Word(BigInt(signerPubkeys.length), "signerPubkeysLength"),
1020
+ signerPadded,
1021
+ uint64Word(BigInt(signatures.length), "signaturesLength"),
1022
+ sigsPadded
1023
+ )
1024
+ );
1025
+ }
1026
+ function encodeGetPendingCharterCalldata(clusterId) {
1027
+ return bytesToHex(
1028
+ concatBytes(hexToBytes(NODE_REGISTRY_SELECTORS.getPendingCharter), uint32Word(toUint32(clusterId, "clusterId")))
1029
+ );
1030
+ }
1031
+ function decodePendingCharter(returnData) {
1032
+ const bytes = toBytes(returnData);
1033
+ if (bytes.length < 5 * 32) {
1034
+ throw new NodeRegistryError("getPendingCharter return shorter than the 5-word head");
1035
+ }
1036
+ const word = (i) => bytes.slice(i * 32, (i + 1) * 32);
1037
+ const present = numberFromWord(word(0), "present", 1) === 1;
1038
+ const delegatorShareBps = numberFromWord(word(1), "delegatorShareBps", 65535);
1039
+ const effectiveEpoch = u64FromWord(word(2));
1040
+ const signerCount = numberFromWord(word(3), "signerCount", 65535);
1041
+ if (!present) {
1042
+ return { present: false, delegatorShareBps: 0, effectiveEpoch, signerCount: 0, memberShareBps: [] };
1043
+ }
1044
+ const bytesOffset = Number(u64FromWord(word(4)));
1045
+ const lenAt = bytesOffset;
1046
+ if (bytes.length < lenAt + 32) {
1047
+ throw new NodeRegistryError("getPendingCharter bytes-length word out of range");
1048
+ }
1049
+ const sharesLen = Number(u64FromWord(bytes.slice(lenAt, lenAt + 32)));
1050
+ const sharesAt = lenAt + 32;
1051
+ if (sharesLen < 32 || bytes.length < sharesAt + 32) {
1052
+ throw new NodeRegistryError("getPendingCharter packed-shares word truncated");
1053
+ }
1054
+ const packed = bytes.slice(sharesAt, sharesAt + 32);
1055
+ const memberShareBps = [];
1056
+ for (let i = 0; i < NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT; i += 1) {
1057
+ const at = 12 + 2 * i;
1058
+ memberShareBps.push(packed[at] << 8 | packed[at + 1]);
1059
+ }
1060
+ return { present: true, delegatorShareBps, effectiveEpoch, signerCount, memberShareBps };
1061
+ }
1062
+ function encodeCommitArchiveRootCalldata(args) {
1063
+ const leafCount = toUint64(args.leafCount, "leafCount");
1064
+ if (leafCount < NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT) {
1065
+ throw new NodeRegistryError(
1066
+ `leafCount must be >= ${NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT} (MIN_ARCHIVE_LEAF_COUNT), got ${leafCount}`
1067
+ );
1068
+ }
1069
+ return bytesToHex(
1070
+ concatBytes(
1071
+ hexToBytes(NODE_REGISTRY_SELECTORS.commitArchiveRoot),
1072
+ expectLength2(toBytes(args.peerId), 32, "peerId"),
1073
+ uint16Word(args.shardIndex),
1074
+ expectLength2(toBytes(args.shardRoot), 32, "shardRoot"),
1075
+ uint64Word(leafCount, "leafCount")
1076
+ )
1077
+ );
1078
+ }
1079
+ function encodeAnswerArchiveChallengeCalldata(args) {
1080
+ const leaf = toBytes(args.leaf);
1081
+ const proof = args.proof.map((p, i) => expectLength2(toBytes(p), 32, `proof[${i}]`));
1082
+ if (proof.length > NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH) {
1083
+ throw new NodeRegistryError(
1084
+ `proof length must be <= ${NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH}, got ${proof.length}`
1085
+ );
1086
+ }
1087
+ const leafPadded = padToWord(leaf);
1088
+ const leafOffset = 5n * 32n;
1089
+ const proofOffset = leafOffset + 32n + BigInt(leafPadded.length);
1090
+ const proofTail = concatBytes(
1091
+ uint64Word(BigInt(proof.length), "proofLength"),
1092
+ ...proof
1093
+ );
1094
+ return bytesToHex(
1095
+ concatBytes(
1096
+ hexToBytes(NODE_REGISTRY_SELECTORS.answerArchiveChallenge),
1097
+ expectLength2(toBytes(args.peerId), 32, "peerId"),
1098
+ uint16Word(args.shardIndex),
1099
+ uint64Word(args.epoch, "epoch"),
1100
+ uint64Word(leafOffset, "leafOffset"),
1101
+ uint64Word(proofOffset, "proofOffset"),
1102
+ uint64Word(BigInt(leaf.length), "leafLength"),
1103
+ leafPadded,
1104
+ proofTail
1105
+ )
1106
+ );
1107
+ }
1108
+ function slotEpochChallengeSeed(epoch) {
1109
+ const buf = new Uint8Array(1 + 8 + 1);
1110
+ buf[0] = NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE;
1111
+ buf.set(u64BeBytes(toUint64(epoch, "epoch")), 1);
1112
+ buf[9] = NODE_REGISTRY_ARCHIVE_KIND_EPOCH_SEED;
1113
+ return bytesToHex(sha3_js.keccak_256(buf));
1114
+ }
1115
+ function protocolNonceForEpoch(seed, epoch) {
1116
+ const s = expectLength2(toBytes(seed), 32, "seed");
1117
+ const e = toUint64(epoch, "epoch");
1118
+ const digest = blake3_js.blake3(
1119
+ concatBytes(new TextEncoder().encode(NODE_REGISTRY_ARCHIVE_NONCE_DOMAIN), u64BeBytes(e), s)
1120
+ );
1121
+ let n = 0n;
1122
+ for (let i = 0; i < 8; i += 1) {
1123
+ n = n << 8n | BigInt(digest[i]);
1124
+ }
1125
+ return n;
1126
+ }
1127
+ function deriveArchiveChallenge(seed, opHash, shardIndex, epoch, leafCount) {
1128
+ const pinnedSeed = expectLength2(toBytes(seed), 32, "seed");
1129
+ const op = expectLength2(toBytes(opHash), 32, "opHash");
1130
+ const shard = expectUint16(shardIndex, "shardIndex");
1131
+ const e = toUint64(epoch, "epoch");
1132
+ const count = toUint64(leafCount, "leafCount");
1133
+ if (count === 0n) {
1134
+ return null;
1135
+ }
1136
+ const nonce = protocolNonceForEpoch(pinnedSeed, e);
1137
+ const challengeSeed = blake3_js.blake3(
1138
+ concatBytes(
1139
+ new TextEncoder().encode(NODE_REGISTRY_ARCHIVE_CHALLENGE_DOMAIN),
1140
+ pinnedSeed,
1141
+ op,
1142
+ u16BeBytes(shard),
1143
+ u64BeBytes(e),
1144
+ u64BeBytes(nonce)
1145
+ )
1146
+ );
1147
+ let idx = 0n;
1148
+ for (let i = 0; i < 8; i += 1) {
1149
+ idx = idx << 8n | BigInt(challengeSeed[i]);
1150
+ }
1151
+ return {
1152
+ opHash: bytesToHex(op),
1153
+ shardIndex: shard,
1154
+ leafIndex: idx % count,
1155
+ seed: bytesToHex(challengeSeed)
1156
+ };
1157
+ }
1158
+ function archiveMerkleLeafHash(leaf) {
1159
+ return blake3_js.blake3(concatBytes(Uint8Array.from([NODE_REGISTRY_MERKLE_LEAF_DOMAIN]), toBytes(leaf)));
1160
+ }
1161
+ function archiveMerkleInnerHash(left, right) {
1162
+ return blake3_js.blake3(
1163
+ concatBytes(
1164
+ Uint8Array.from([NODE_REGISTRY_MERKLE_INNER_DOMAIN]),
1165
+ expectLength2(toBytes(left), 32, "left"),
1166
+ expectLength2(toBytes(right), 32, "right")
1167
+ )
1168
+ );
1169
+ }
1170
+ function encodeSetProbeAuthorityCalldata(probeAuthority) {
1171
+ return bytesToHex(
1172
+ concatBytes(
1173
+ hexToBytes(NODE_REGISTRY_SELECTORS.setProbeAuthority),
1174
+ addressWord(probeAuthority, "probeAuthority")
1175
+ )
1176
+ );
1177
+ }
1178
+ function encodeGetProbeAuthorityCalldata() {
1179
+ return NODE_REGISTRY_SELECTORS.getProbeAuthority;
1180
+ }
1181
+ function decodeProbeAuthority(returnData) {
1182
+ const bytes = expectLength2(toBytes(returnData), 32, "probeAuthority");
1183
+ return bytesToHex(bytes.slice(12, 32));
1184
+ }
1185
+ function encodeAttestServiceProbeCalldata(args) {
1186
+ if (!isValidPublicServiceProbeMask(args.serviceMask)) {
1187
+ throw new NodeRegistryError(
1188
+ `serviceMask 0x${args.serviceMask.toString(16).padStart(8, "0")} is not a valid public-service mask`
1189
+ );
1190
+ }
1191
+ if (!isConcreteServiceProbeStatus(args.status)) {
1192
+ throw new NodeRegistryError(`status ${args.status} is not a concrete service-probe outcome`);
1193
+ }
1194
+ return bytesToHex(
1195
+ concatBytes(
1196
+ hexToBytes(NODE_REGISTRY_SELECTORS.attestServiceProbe),
1197
+ expectLength2(toBytes(args.opHash), 32, "opHash"),
1198
+ uint32Word(args.serviceMask),
1199
+ uint8Word(args.status),
1200
+ uint64Word(args.epoch, "epoch")
1201
+ )
1202
+ );
1203
+ }
1204
+ function slotClusterServiceScore(clusterId) {
1205
+ return scoreSlotHex(0, u32BeBytes(toUint32(clusterId, "clusterId")));
1206
+ }
1207
+ function slotArchiveChallengePass(clusterId, epoch) {
1208
+ return scoreSlotHex(
1209
+ 1,
1210
+ concatBytes(u32BeBytes(toUint32(clusterId, "clusterId")), u64BeBytes(toUint64(epoch, "epoch")))
1211
+ );
1212
+ }
1213
+ function slotScoreServiceProbe(opHash, serviceBit) {
1214
+ if (!Number.isInteger(serviceBit) || serviceBit < 0 || serviceBit > 255) {
1215
+ throw new NodeRegistryError("serviceBit must be a u8 bit index");
1216
+ }
1217
+ return scoreSlotHex(
1218
+ 2,
1219
+ concatBytes(expectLength2(toBytes(opHash), 32, "opHash"), Uint8Array.from([serviceBit]))
1220
+ );
1221
+ }
1222
+ function serviceMaskToBitIndex(mask) {
1223
+ if (!Number.isInteger(mask) || mask <= 0 || (mask & mask - 1) !== 0) {
1224
+ return null;
1225
+ }
1226
+ let bit = 0;
1227
+ let m = mask >>> 0;
1228
+ while ((m & 1) === 0) {
1229
+ m >>>= 1;
1230
+ bit += 1;
1231
+ }
1232
+ return bit;
1233
+ }
1234
+ function decodeScoreServiceProbe(word) {
1235
+ const bytes = expectLength2(toBytes(word), 32, "scoreServiceProbeWord");
1236
+ const status = bytes[31];
1237
+ let packed = 0n;
1238
+ for (const b of bytes) {
1239
+ packed = packed << 8n | BigInt(b);
1240
+ }
1241
+ return { epoch: packed >> 8n, status };
1242
+ }
1243
+ function slotProbeAuthority() {
1244
+ const buf = new Uint8Array(1 + 32 + 1);
1245
+ buf[0] = NODE_REGISTRY_TAG_TREASURY;
1246
+ buf[33] = 10;
1247
+ return bytesToHex(sha3_js.keccak_256(buf));
1248
+ }
1249
+ function slotClusterCharter(clusterId, subkind) {
1250
+ if (!Number.isInteger(subkind) || subkind < 0 || subkind > 255) {
1251
+ throw new NodeRegistryError("charter subkind must be a u8");
1252
+ }
1253
+ const buf = new Uint8Array(1 + 4 + 1);
1254
+ buf[0] = NODE_REGISTRY_TAG_CLUSTER_CHARTER;
1255
+ buf.set(u32BeBytes(toUint32(clusterId, "clusterId")), 1);
1256
+ buf[5] = subkind;
1257
+ return bytesToHex(sha3_js.keccak_256(buf));
1258
+ }
1259
+ function slotClusterCharterDelegator(clusterId) {
1260
+ return slotClusterCharter(clusterId, NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS);
1261
+ }
1262
+ function slotClusterCharterMembers(clusterId) {
1263
+ return slotClusterCharter(clusterId, NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES);
1264
+ }
1265
+ function decodeActiveCharter(delegatorWord, membersWord) {
1266
+ const presence = expectLength2(toBytes(delegatorWord), 32, "charterDelegatorWord");
1267
+ let raw = 0n;
1268
+ for (const b of presence) {
1269
+ raw = raw << 8n | BigInt(b);
1270
+ }
1271
+ if (raw === 0n) {
1272
+ return { present: false, delegatorShareBps: 0, memberShareBps: [] };
1273
+ }
1274
+ const delegatorShareBps = Number(raw - 1n > 0xffffn ? 0xffffn : raw - 1n);
1275
+ const packed = expectLength2(toBytes(membersWord), 32, "charterMembersWord");
1276
+ const memberShareBps = [];
1277
+ for (let i = 0; i < NODE_REGISTRY_FORM_CLUSTER_MEMBER_COUNT; i += 1) {
1278
+ const at = 12 + 2 * i;
1279
+ memberShareBps.push(packed[at] << 8 | packed[at + 1]);
1280
+ }
1281
+ return { present: true, delegatorShareBps, memberShareBps };
1282
+ }
968
1283
  function decodeClusterJoinRequest(returnData) {
969
1284
  const bytes = expectLength2(toBytes(returnData), 8 * 32, "clusterJoinRequest");
970
1285
  const word = (i) => bytes.slice(i * 32, (i + 1) * 32);
@@ -1143,6 +1458,43 @@ function u16BeBytes(value) {
1143
1458
  }
1144
1459
  return Uint8Array.from([value >>> 8 & 255, value & 255]);
1145
1460
  }
1461
+ function expectUint16(value, name) {
1462
+ if (!Number.isInteger(value) || value < 0 || value > 65535) {
1463
+ throw new NodeRegistryError(`${name} must be a uint16`);
1464
+ }
1465
+ return value;
1466
+ }
1467
+ function uint16Word(value) {
1468
+ const out = new Uint8Array(32);
1469
+ out.set(u16BeBytes(value), 30);
1470
+ return out;
1471
+ }
1472
+ function addressWord(value, name) {
1473
+ const addr = expectLength2(toBytes(value), 20, name);
1474
+ const out = new Uint8Array(32);
1475
+ out.set(addr, 12);
1476
+ return out;
1477
+ }
1478
+ function flattenFixedWidth(value, width, name) {
1479
+ let flat;
1480
+ if (Array.isArray(value) && value.length > 0 && typeof value[0] !== "number") {
1481
+ const parts = value.map(
1482
+ (v, i) => expectLength2(toBytes(v), width, `${name}[${i}]`)
1483
+ );
1484
+ flat = concatBytes(...parts);
1485
+ } else {
1486
+ flat = toBytes(value);
1487
+ }
1488
+ if (flat.length === 0 || flat.length % width !== 0) {
1489
+ throw new NodeRegistryError(`${name} must be a non-empty multiple of ${width} bytes, got ${flat.length}`);
1490
+ }
1491
+ return flat;
1492
+ }
1493
+ function scoreSlotHex(kind, tail) {
1494
+ return bytesToHex(
1495
+ sha3_js.keccak_256(concatBytes(Uint8Array.from([NODE_REGISTRY_TAG_SERVICE_SCORE, kind]), tail))
1496
+ );
1497
+ }
1146
1498
  function compareBytes(a, b) {
1147
1499
  const len = Math.min(a.length, b.length);
1148
1500
  for (let i = 0; i < len; i++) {
@@ -1314,6 +1666,84 @@ function decodeDynamicBytesResult(bytes, expectedLength, label) {
1314
1666
  return bytes.slice(64, 64 + expectedLength);
1315
1667
  }
1316
1668
 
1669
+ // src/native-events.ts
1670
+ var NATIVE_MARKET_EVENT_FAMILY = "market";
1671
+ function nativeMarketEventFilter(filter = {}) {
1672
+ return { ...filter, family: NATIVE_MARKET_EVENT_FAMILY };
1673
+ }
1674
+ function isNativeDecodedEvent(value) {
1675
+ const row = asRecord(value);
1676
+ return row !== null && typeof row["block_height"] === "number" && typeof row["tx_index"] === "number" && typeof row["sequence"] === "number" && typeof row["family"] === "string" && typeof row["event_name"] === "string" && typeof row["payload_hash"] === "string";
1677
+ }
1678
+ function parseNativeDecodedEvent(event) {
1679
+ if (isNativeDecodedEvent(event.decoded)) {
1680
+ return event.decoded;
1681
+ }
1682
+ try {
1683
+ const parsed = JSON.parse(event.decodedJson);
1684
+ if (isNativeDecodedEvent(parsed)) {
1685
+ return parsed;
1686
+ }
1687
+ } catch {
1688
+ }
1689
+ throw SdkError.malformed(
1690
+ `native event ${event.eventTopic} at logIndex ${event.logIndex} is missing a typed decoded payload`
1691
+ );
1692
+ }
1693
+ function nativeEventMatches(event, filter = {}) {
1694
+ if (filter.address !== void 0 && event.address !== filter.address) return false;
1695
+ if (filter.eventTopic !== void 0 && event.eventTopic !== filter.eventTopic) return false;
1696
+ if (filter.family === void 0 && filter.eventName === void 0) return true;
1697
+ let decoded;
1698
+ try {
1699
+ decoded = parseNativeDecodedEvent(event);
1700
+ } catch {
1701
+ return false;
1702
+ }
1703
+ if (filter.family !== void 0 && decoded.family !== filter.family) return false;
1704
+ if (filter.eventName !== void 0 && decoded.event_name !== filter.eventName) return false;
1705
+ return true;
1706
+ }
1707
+ function nativeEventsFromReceipt(receipt, filter = {}) {
1708
+ return receipt.events.filter((event) => nativeEventMatches(event, filter)).map((event) => ({
1709
+ ...event,
1710
+ decoded: parseNativeDecodedEvent(event)
1711
+ }));
1712
+ }
1713
+ function nativeMarketEventsFromReceipt(receipt, filter = {}) {
1714
+ return nativeEventsFromReceipt(receipt, nativeMarketEventFilter(filter));
1715
+ }
1716
+ function nativeEventsFromHistory(response) {
1717
+ return {
1718
+ ...response,
1719
+ events: response.events.map((event) => ({
1720
+ ...event,
1721
+ decoded: parseNativeDecodedEvent(event)
1722
+ }))
1723
+ };
1724
+ }
1725
+ function nativeMarketEventsFromHistory(response) {
1726
+ return {
1727
+ ...response,
1728
+ filters: { ...response.filters, family: NATIVE_MARKET_EVENT_FAMILY },
1729
+ events: response.events.filter((event) => nativeEventMatches(event, { family: NATIVE_MARKET_EVENT_FAMILY })).map((event) => ({
1730
+ ...event,
1731
+ decoded: parseNativeDecodedEvent(event)
1732
+ }))
1733
+ };
1734
+ }
1735
+ async function consumeNativeEvents(receipt, consumer, filter = {}) {
1736
+ const events = nativeEventsFromReceipt(receipt, filter);
1737
+ for (const event of events) {
1738
+ await consumer(event);
1739
+ }
1740
+ return events.length;
1741
+ }
1742
+ function asRecord(value) {
1743
+ if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
1744
+ return value;
1745
+ }
1746
+
1317
1747
  // src/crypto/bytes.ts
1318
1748
  function concatBytes2(...chunks) {
1319
1749
  const len = chunks.reduce((n, c) => n + c.length, 0);
@@ -2968,8 +3398,8 @@ var TESTNET_69420 = {
2968
3398
  network: "testnet-69420",
2969
3399
  display_name: "Monolythium Testnet",
2970
3400
  description: "Public Monolythium testnet. Testnet state may reset without notice; do not store value on this network.",
2971
- genesis_hash: "0x0d2903aeac5aa127b3fb75cd1405c2c193896981e8897671792d3817a6fdf689",
2972
- binary_sha: "52f1694c5a6d",
3401
+ genesis_hash: "0x11774775b5c3bfc36ecb9c37e7252b49898caaacdb55668de3913fe60c660258",
3402
+ binary_sha: "b4257f14",
2973
3403
  rpc: [
2974
3404
  {
2975
3405
  url: "http://178.105.12.9:8545",
@@ -3028,18 +3458,18 @@ var TESTNET_69420 = {
3028
3458
  notes: "operator-8"
3029
3459
  },
3030
3460
  {
3031
- url: "http://162.55.54.198:8545",
3461
+ url: "http://95.217.156.190:8545",
3032
3462
  provider: "monolythium-foundation",
3033
- region: "fsn1",
3463
+ region: "hel1",
3034
3464
  tier: "official",
3035
- notes: "operator-9"
3465
+ notes: "operator-10"
3036
3466
  },
3037
3467
  {
3038
- url: "http://95.217.156.190:8545",
3468
+ url: "http://162.55.54.198:8545",
3039
3469
  provider: "monolythium-foundation",
3040
- region: "hel1",
3470
+ region: "fsn1",
3041
3471
  tier: "official",
3042
- notes: "operator-10"
3472
+ notes: "operator-9"
3043
3473
  },
3044
3474
  {
3045
3475
  url: "http://178.105.45.210:8545",
@@ -3670,7 +4100,7 @@ function encodeStringAddressCall(selector, name, address) {
3670
4100
  hexToBytes4(selector),
3671
4101
  // Two head words (string offset, address) → string tail starts at 0x40.
3672
4102
  uint256Word(0x40n),
3673
- addressWord(address),
4103
+ addressWord2(address),
3674
4104
  uint256Word(BigInt(nameBytes.length)),
3675
4105
  padTo32(nameBytes)
3676
4106
  )
@@ -3694,7 +4124,7 @@ function selectorHex2(signature) {
3694
4124
  const sel = sha3_js.keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
3695
4125
  return `0x${[...sel].map((b) => b.toString(16).padStart(2, "0")).join("")}`;
3696
4126
  }
3697
- function addressWord(value) {
4127
+ function addressWord2(value) {
3698
4128
  const out = new Uint8Array(32);
3699
4129
  if (value == null) return out;
3700
4130
  const bytes = toBytes2(value);
@@ -4372,6 +4802,55 @@ var RpcClient = class _RpcClient {
4372
4802
  async lythGetClusterDiversity(clusterId) {
4373
4803
  return this.call("lyth_getClusterDiversity", [clusterId]);
4374
4804
  }
4805
+ /**
4806
+ * Component H — read a cluster's ACTIVE economics charter (Law §6.8).
4807
+ *
4808
+ * There is no `lyth_*` / view-selector for the active charter, so this
4809
+ * SLOADs the two `TAG_CLUSTER_CHARTER` (`0x31`) storage words from the
4810
+ * node-registry account `0x1005` via `eth_getStorageAt` and decodes them
4811
+ * with {@link decodeActiveCharter}. Returns `{ present: false }` (zeroed
4812
+ * shares) for genesis / 3-arg-formCluster clusters that never adopted a
4813
+ * charter. The active record carries no `effectiveEpoch` — that lives on
4814
+ * the pending amendment ({@link lythGetPendingCharter}).
4815
+ */
4816
+ async lythGetClusterCharter(clusterId, block = "latest") {
4817
+ const registry = nodeRegistryAddressHex();
4818
+ const [delegator, members] = await Promise.all([
4819
+ this.ethGetStorageAt(registry, slotClusterCharterDelegator(clusterId), block),
4820
+ this.ethGetStorageAt(registry, slotClusterCharterMembers(clusterId), block)
4821
+ ]);
4822
+ return decodeActiveCharter(delegator.value, members.value);
4823
+ }
4824
+ /**
4825
+ * Component H — read a cluster's PENDING charter amendment (Law §6.8).
4826
+ *
4827
+ * Calls the `getPendingCharter(uint32)` view on the node-registry account
4828
+ * `0x1005` over `eth_call` and decodes the return with
4829
+ * {@link decodePendingCharter}. Returns `{ present: false }` when no
4830
+ * amendment is posted; otherwise carries the proposed shares plus the
4831
+ * `effectiveEpoch` at which the delegator-protective cooldown lands.
4832
+ */
4833
+ async lythGetPendingCharter(clusterId, block = "latest") {
4834
+ const data = await this.ethCall(
4835
+ { to: nodeRegistryAddressHex(), data: encodeGetPendingCharterCalldata(clusterId) },
4836
+ block
4837
+ );
4838
+ return decodePendingCharter(data);
4839
+ }
4840
+ /**
4841
+ * Component A — read a cluster's settled per-cluster ServiceScore (the
4842
+ * `u64` the reward path reads each block). SLOADs the `TAG_SERVICE_SCORE`
4843
+ * (`0x24`) score slot from `0x1005` via `eth_getStorageAt`; `0n` means the
4844
+ * cluster has never been scored.
4845
+ */
4846
+ async lythGetClusterServiceScore(clusterId, block = "latest") {
4847
+ const word = await this.ethGetStorageAt(
4848
+ nodeRegistryAddressHex(),
4849
+ slotClusterServiceScore(clusterId),
4850
+ block
4851
+ );
4852
+ return parseQuantityBig(word.value);
4853
+ }
4375
4854
  /**
4376
4855
  * PF-6 — `lyth_getOperatorNetworkMetadata`: ASN/geo/hosting-class/IP/PCR
4377
4856
  * for a peer. `operatorId` is the 32-byte operator/peer id as `0x…` hex
@@ -6238,7 +6717,7 @@ function encodeSetBridgeRouteFinalityCalldata(bridgeId, finalityBlocks) {
6238
6717
  function bridgeSelector(signature) {
6239
6718
  return sha3_js.keccak_256(new TextEncoder().encode(signature)).slice(0, 4);
6240
6719
  }
6241
- function addressWord2(value, name) {
6720
+ function addressWord3(value, name) {
6242
6721
  const addr = expectLength3(toBytes3(value), 20, name);
6243
6722
  const out = new Uint8Array(32);
6244
6723
  out.set(addr, 12);
@@ -6257,7 +6736,7 @@ function encodeBridgeClaimCalldata(bridgeId, depositId, recipient) {
6257
6736
  bridgeSelector("claim(bytes32,bytes32,address)"),
6258
6737
  expectLength3(toBytes3(bridgeId), 32, "bridgeId"),
6259
6738
  expectLength3(toBytes3(depositId), 32, "depositId"),
6260
- addressWord2(recipient, "recipient")
6739
+ addressWord3(recipient, "recipient")
6261
6740
  )
6262
6741
  );
6263
6742
  }
@@ -9251,8 +9730,8 @@ function encodeTokenFactoryTransferFromCalldata(tokenId, from, to, amount) {
9251
9730
  concatBytes2(
9252
9731
  hexToBytes2(TOKEN_FACTORY_SELECTORS.transferFrom, "transferFrom selector"),
9253
9732
  bytes32(tokenId, "tokenId"),
9254
- addressWord3(from, "from"),
9255
- addressWord3(to, "to"),
9733
+ addressWord4(from, "from"),
9734
+ addressWord4(to, "to"),
9256
9735
  uint256Word2(parseUint(amount, "amount"), "amount")
9257
9736
  )
9258
9737
  );
@@ -9274,8 +9753,8 @@ function encodeTokenFactoryAllowanceCalldata(tokenId, owner, spender) {
9274
9753
  concatBytes2(
9275
9754
  hexToBytes2(TOKEN_FACTORY_SELECTORS.allowance, "allowance selector"),
9276
9755
  bytes32(tokenId, "tokenId"),
9277
- addressWord3(owner, "owner"),
9278
- addressWord3(spender, "spender")
9756
+ addressWord4(owner, "owner"),
9757
+ addressWord4(spender, "spender")
9279
9758
  )
9280
9759
  );
9281
9760
  }
@@ -9342,7 +9821,7 @@ function encodeBytes32Address(selector, tokenId, address) {
9342
9821
  concatBytes2(
9343
9822
  hexToBytes2(selector, "selector"),
9344
9823
  bytes32(tokenId, "tokenId"),
9345
- addressWord3(address, "address")
9824
+ addressWord4(address, "address")
9346
9825
  )
9347
9826
  );
9348
9827
  }
@@ -9351,7 +9830,7 @@ function encodeBytes32AddressUint(selector, tokenId, address, amount) {
9351
9830
  concatBytes2(
9352
9831
  hexToBytes2(selector, "selector"),
9353
9832
  bytes32(tokenId, "tokenId"),
9354
- addressWord3(address, "address"),
9833
+ addressWord4(address, "address"),
9355
9834
  uint256Word2(parseUint(amount, "amount"), "amount")
9356
9835
  )
9357
9836
  );
@@ -9377,7 +9856,7 @@ function padTo323(bytes) {
9377
9856
  out.set(bytes);
9378
9857
  return out;
9379
9858
  }
9380
- function addressWord3(value, label) {
9859
+ function addressWord4(value, label) {
9381
9860
  const out = new Uint8Array(32);
9382
9861
  out.set(addressBytes(value, label), 12);
9383
9862
  return out;
@@ -9892,7 +10371,7 @@ function encodeDelegateCalldata(cluster, weightBps) {
9892
10371
  concatBytes8(
9893
10372
  hexToBytes8(DELEGATION_SELECTORS.delegate),
9894
10373
  uint32Word2(cluster, "cluster"),
9895
- uint16Word(weightBps, "weightBps")
10374
+ uint16Word2(weightBps, "weightBps")
9896
10375
  )
9897
10376
  );
9898
10377
  }
@@ -9910,7 +10389,7 @@ function encodeRedelegateCalldata(fromCluster, toCluster, weightBps) {
9910
10389
  hexToBytes8(DELEGATION_SELECTORS.redelegate),
9911
10390
  uint32Word2(fromCluster, "fromCluster"),
9912
10391
  uint32Word2(toCluster, "toCluster"),
9913
- uint16Word(weightBps, "weightBps")
10392
+ uint16Word2(weightBps, "weightBps")
9914
10393
  )
9915
10394
  );
9916
10395
  }
@@ -9940,7 +10419,7 @@ function uint32Word2(value, name) {
9940
10419
  }
9941
10420
  return out;
9942
10421
  }
9943
- function uint16Word(value, name) {
10422
+ function uint16Word2(value, name) {
9944
10423
  const n = toBigint3(value, name);
9945
10424
  if (n < 0n || n > 0xffffn) {
9946
10425
  throw new DelegationPrecompileError(`${name} must fit uint16`);
@@ -10351,9 +10830,9 @@ function decodeHasPubkeyReturn(data) {
10351
10830
  throw new PubkeyRegistryError("hasPubkey bool must be 0 or 1");
10352
10831
  }
10353
10832
  function encodeSingleAddressCall2(selector, address) {
10354
- return bytesToHex11(concatBytes10(hexToBytes10(selector), addressWord4(toAddressBytes(address))));
10833
+ return bytesToHex11(concatBytes10(hexToBytes10(selector), addressWord5(toAddressBytes(address))));
10355
10834
  }
10356
- function addressWord4(address) {
10835
+ function addressWord5(address) {
10357
10836
  return concatBytes10(new Uint8Array(12), address);
10358
10837
  }
10359
10838
  function toAddressBytes(value) {
@@ -10562,7 +11041,7 @@ function encodePlaceMarketOrderCalldata(args) {
10562
11041
  normalized.quoteTokenId,
10563
11042
  uint8Word2(normalized.side),
10564
11043
  uint256Word5(normalized.quantity, "quantity"),
10565
- uint16Word2(normalized.maxSlippageBps, "maxSlippageBps")
11044
+ uint16Word3(normalized.maxSlippageBps, "maxSlippageBps")
10566
11045
  )
10567
11046
  );
10568
11047
  }
@@ -10575,7 +11054,7 @@ function encodePlaceMarketOrderExCalldata(args) {
10575
11054
  normalized.quoteTokenId,
10576
11055
  uint8Word2(normalized.side),
10577
11056
  uint256Word5(normalized.quantity, "quantity"),
10578
- uint16Word2(normalized.maxSlippageBps, "maxSlippageBps"),
11057
+ uint16Word3(normalized.maxSlippageBps, "maxSlippageBps"),
10579
11058
  uint8Word2(normalized.mode)
10580
11059
  )
10581
11060
  );
@@ -10882,7 +11361,7 @@ function encodePlaceLimitOrderViaCalldata(args) {
10882
11361
  return bytesToHex2(
10883
11362
  concatBytes2(
10884
11363
  hexToBytes2(OPERATOR_ROUTER_SELECTORS.placeLimitOrderVia, "placeLimitOrderVia selector"),
10885
- addressWord5(operator.bytes),
11364
+ addressWord6(operator.bytes),
10886
11365
  bytes32FromHex(args.base, "base"),
10887
11366
  bytes32FromHex(args.quote, "quote"),
10888
11367
  uint8Word2(side),
@@ -11190,7 +11669,7 @@ function uint64Word3(value, name) {
11190
11669
  }
11191
11670
  return out;
11192
11671
  }
11193
- function uint16Word2(value, name) {
11672
+ function uint16Word3(value, name) {
11194
11673
  if (value < 0n || value > 0xffffn) {
11195
11674
  throw new MarketActionError(`${name} must fit uint16`);
11196
11675
  }
@@ -11211,7 +11690,7 @@ function uint256Word5(value, name) {
11211
11690
  }
11212
11691
  return out;
11213
11692
  }
11214
- function addressWord5(addr) {
11693
+ function addressWord6(addr) {
11215
11694
  if (addr.length !== 20) {
11216
11695
  throw new MarketActionError("address must be 20 bytes");
11217
11696
  }
@@ -11751,7 +12230,7 @@ var MONOLYTHIUM_NETWORKS = {
11751
12230
  };
11752
12231
 
11753
12232
  // src/index.ts
11754
- var version = "0.4.8";
12233
+ var version = "0.4.17";
11755
12234
 
11756
12235
  exports.ADDRESS_HRP = ADDRESS_HRP;
11757
12236
  exports.ADDRESS_KIND_HRPS = ADDRESS_KIND_HRPS;
@@ -11829,9 +12308,14 @@ exports.NATIVE_MARKET_EVENT_FAMILY = NATIVE_MARKET_EVENT_FAMILY;
11829
12308
  exports.NATIVE_MARKET_MODULE_ADDRESS = NATIVE_MARKET_MODULE_ADDRESS;
11830
12309
  exports.NATIVE_MARKET_MODULE_ADDRESS_BYTES = NATIVE_MARKET_MODULE_ADDRESS_BYTES;
11831
12310
  exports.NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC = NATIVE_MARKET_ORDER_BOOK_STREAM_TOPIC;
12311
+ exports.NODE_REGISTRY_ARCHIVE_CHALLENGE_DOMAIN = NODE_REGISTRY_ARCHIVE_CHALLENGE_DOMAIN;
12312
+ exports.NODE_REGISTRY_ARCHIVE_KIND_EPOCH_SEED = NODE_REGISTRY_ARCHIVE_KIND_EPOCH_SEED;
12313
+ exports.NODE_REGISTRY_ARCHIVE_NONCE_DOMAIN = NODE_REGISTRY_ARCHIVE_NONCE_DOMAIN;
11832
12314
  exports.NODE_REGISTRY_BLS_PUBKEY_BYTES = NODE_REGISTRY_BLS_PUBKEY_BYTES;
11833
12315
  exports.NODE_REGISTRY_CAPABILITIES = NODE_REGISTRY_CAPABILITIES;
11834
12316
  exports.NODE_REGISTRY_CAPABILITY_MASK = NODE_REGISTRY_CAPABILITY_MASK;
12317
+ exports.NODE_REGISTRY_CHALLENGE_EPOCH_WINDOW = NODE_REGISTRY_CHALLENGE_EPOCH_WINDOW;
12318
+ exports.NODE_REGISTRY_CHARTER_COOLDOWN_EPOCHS = NODE_REGISTRY_CHARTER_COOLDOWN_EPOCHS;
11835
12319
  exports.NODE_REGISTRY_CLUSTER_CHARTER_BYTES = NODE_REGISTRY_CLUSTER_CHARTER_BYTES;
11836
12320
  exports.NODE_REGISTRY_CLUSTER_CHARTER_DELEGATOR_FLOOR_BPS = NODE_REGISTRY_CLUSTER_CHARTER_DELEGATOR_FLOOR_BPS;
11837
12321
  exports.NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS = NODE_REGISTRY_CLUSTER_CHARTER_SHARE_DENOM_BPS;
@@ -11850,12 +12334,24 @@ exports.NODE_REGISTRY_FORM_CLUSTER_MESSAGE_DOMAIN_V2 = NODE_REGISTRY_FORM_CLUSTE
11850
12334
  exports.NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT = NODE_REGISTRY_FORM_CLUSTER_STANDBY_COUNT;
11851
12335
  exports.NODE_REGISTRY_FORM_CLUSTER_THRESHOLD = NODE_REGISTRY_FORM_CLUSTER_THRESHOLD;
11852
12336
  exports.NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES = NODE_REGISTRY_LEGACY_CLUSTER_MEMBER_PUBKEY_BYTES;
12337
+ exports.NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH = NODE_REGISTRY_MAX_MERKLE_PROOF_DEPTH;
12338
+ exports.NODE_REGISTRY_MERKLE_INNER_DOMAIN = NODE_REGISTRY_MERKLE_INNER_DOMAIN;
12339
+ exports.NODE_REGISTRY_MERKLE_LEAF_DOMAIN = NODE_REGISTRY_MERKLE_LEAF_DOMAIN;
12340
+ exports.NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT = NODE_REGISTRY_MIN_ARCHIVE_LEAF_COUNT;
11853
12341
  exports.NODE_REGISTRY_OPERATOR_ALIAS_MAX_BYTES = NODE_REGISTRY_OPERATOR_ALIAS_MAX_BYTES;
11854
12342
  exports.NODE_REGISTRY_OPERATOR_MONIKER_MAX_BYTES = NODE_REGISTRY_OPERATOR_MONIKER_MAX_BYTES;
11855
12343
  exports.NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES = NODE_REGISTRY_OPERATOR_SEAL_EK_BYTES;
11856
12344
  exports.NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID = NODE_REGISTRY_PENDING_CHANGE_MAX_INTENT_ID;
11857
12345
  exports.NODE_REGISTRY_PUBLIC_SERVICE_MASK = NODE_REGISTRY_PUBLIC_SERVICE_MASK;
11858
12346
  exports.NODE_REGISTRY_SELECTORS = NODE_REGISTRY_SELECTORS;
12347
+ exports.NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS = NODE_REGISTRY_SUBKIND_CHARTER_DELEGATOR_BPS;
12348
+ exports.NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES = NODE_REGISTRY_SUBKIND_CHARTER_MEMBER_SHARES;
12349
+ exports.NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE = NODE_REGISTRY_TAG_ARCHIVE_CHALLENGE;
12350
+ exports.NODE_REGISTRY_TAG_CLUSTER_CHARTER = NODE_REGISTRY_TAG_CLUSTER_CHARTER;
12351
+ exports.NODE_REGISTRY_TAG_SERVICE_SCORE = NODE_REGISTRY_TAG_SERVICE_SCORE;
12352
+ exports.NODE_REGISTRY_TAG_TREASURY = NODE_REGISTRY_TAG_TREASURY;
12353
+ exports.NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN = NODE_REGISTRY_UPDATE_CHARTER_MESSAGE_DOMAIN;
12354
+ exports.NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD = NODE_REGISTRY_UPDATE_CHARTER_THRESHOLD;
11859
12355
  exports.NO_EVM_ARCHIVE_PROOF_SCHEMA = NO_EVM_ARCHIVE_PROOF_SCHEMA;
11860
12356
  exports.NO_EVM_ARCHIVE_SIGNATURE_SCHEME = NO_EVM_ARCHIVE_SIGNATURE_SCHEME;
11861
12357
  exports.NO_EVM_FINALITY_EVIDENCE_SCHEMA = NO_EVM_FINALITY_EVIDENCE_SCHEMA;
@@ -11924,6 +12420,8 @@ exports.addressToBech32 = addressToBech32;
11924
12420
  exports.addressToTypedBech32 = addressToTypedBech32;
11925
12421
  exports.allowRootFor = allowRootFor;
11926
12422
  exports.apiEndpointFromRpcEndpoint = apiEndpointFromRpcEndpoint;
12423
+ exports.archiveMerkleInnerHash = archiveMerkleInnerHash;
12424
+ exports.archiveMerkleLeafHash = archiveMerkleLeafHash;
11927
12425
  exports.assembleMultisigSigned = assembleMultisigSigned;
11928
12426
  exports.assembleMultisigWitness = assembleMultisigWitness;
11929
12427
  exports.assertMrvCallNativeSubmissionPlan = assertMrvCallNativeSubmissionPlan;
@@ -12009,6 +12507,8 @@ exports.computeNoEvmRoundFinalityMessage = computeNoEvmRoundFinalityMessage;
12009
12507
  exports.computeNoEvmTargetReceiptHash = computeNoEvmTargetReceiptHash;
12010
12508
  exports.computeQuoteLiquidity = computeQuoteLiquidity;
12011
12509
  exports.consumeNativeEvents = consumeNativeEvents;
12510
+ exports.decodeActiveCharter = decodeActiveCharter;
12511
+ exports.decodeClusterCharter = decodeClusterCharter;
12012
12512
  exports.decodeClusterDiversity = decodeClusterDiversity;
12013
12513
  exports.decodeClusterFormedEvent = decodeClusterFormedEvent;
12014
12514
  exports.decodeClusterJoinRequest = decodeClusterJoinRequest;
@@ -12022,12 +12522,16 @@ exports.decodeOperatorFeeChargedEvent = decodeOperatorFeeChargedEvent;
12022
12522
  exports.decodeOperatorNetworkMetadata = decodeOperatorNetworkMetadata;
12023
12523
  exports.decodeOperatorSealKey = decodeOperatorSealKey;
12024
12524
  exports.decodeOracleEvent = decodeOracleEvent;
12525
+ exports.decodePendingCharter = decodePendingCharter;
12526
+ exports.decodeProbeAuthority = decodeProbeAuthority;
12527
+ exports.decodeScoreServiceProbe = decodeScoreServiceProbe;
12025
12528
  exports.decodeTimeWindow = decodeTimeWindow;
12026
12529
  exports.decodeTokenFactoryTokenId = decodeTokenFactoryTokenId;
12027
12530
  exports.decodeTxFeedResponse = decodeTxFeedResponse;
12028
12531
  exports.decodeVrfOutput = decodeVrfOutput;
12029
12532
  exports.delegationAddressHex = delegationAddressHex;
12030
12533
  exports.denyRootFor = denyRootFor;
12534
+ exports.deriveArchiveChallenge = deriveArchiveChallenge;
12031
12535
  exports.deriveClobMarketId = deriveClobMarketId;
12032
12536
  exports.deriveClusterAnchorAddress = deriveClusterAnchorAddress;
12033
12537
  exports.deriveClusterJoinOperatorId = deriveClusterJoinOperatorId;
@@ -12039,7 +12543,9 @@ exports.deriveNativeSpotMarketId = deriveNativeSpotMarketId;
12039
12543
  exports.deriveNativeSpotOrderId = deriveNativeSpotOrderId;
12040
12544
  exports.deriveTokenFactoryTokenId = deriveTokenFactoryTokenId;
12041
12545
  exports.destinationRoot = destinationRoot;
12546
+ exports.encodeAnswerArchiveChallengeCalldata = encodeAnswerArchiveChallengeCalldata;
12042
12547
  exports.encodeAttestDkgReshareCalldata = encodeAttestDkgReshareCalldata;
12548
+ exports.encodeAttestServiceProbeCalldata = encodeAttestServiceProbeCalldata;
12043
12549
  exports.encodeBlockSelector = encodeBlockSelector;
12044
12550
  exports.encodeBridgeChallengeCalldata = encodeBridgeChallengeCalldata;
12045
12551
  exports.encodeBridgeClaimCalldata = encodeBridgeClaimCalldata;
@@ -12049,6 +12555,7 @@ exports.encodeCancelPendingChangeCalldata = encodeCancelPendingChangeCalldata;
12049
12555
  exports.encodeClaimCalldata = encodeClaimCalldata;
12050
12556
  exports.encodeClaimPolicyByAddressCalldata = encodeClaimPolicyByAddressCalldata;
12051
12557
  exports.encodeClusterCharter = encodeClusterCharter;
12558
+ exports.encodeCommitArchiveRootCalldata = encodeCommitArchiveRootCalldata;
12052
12559
  exports.encodeCreateFixedSupplyMrc20Calldata = encodeCreateFixedSupplyMrc20Calldata;
12053
12560
  exports.encodeCreateRequestCalldata = encodeCreateRequestCalldata;
12054
12561
  exports.encodeCreateRequestCanonical = encodeCreateRequestCanonical;
@@ -12061,6 +12568,8 @@ exports.encodeFormClusterCalldata = encodeFormClusterCalldata;
12061
12568
  exports.encodeFormClusterV2Calldata = encodeFormClusterV2Calldata;
12062
12569
  exports.encodeGetClusterJoinRequestCalldata = encodeGetClusterJoinRequestCalldata;
12063
12570
  exports.encodeGetOperatorSealKeyCalldata = encodeGetOperatorSealKeyCalldata;
12571
+ exports.encodeGetPendingCharterCalldata = encodeGetPendingCharterCalldata;
12572
+ exports.encodeGetProbeAuthorityCalldata = encodeGetProbeAuthorityCalldata;
12064
12573
  exports.encodeHasPubkeyCalldata = encodeHasPubkeyCalldata;
12065
12574
  exports.encodeLockBridgeConfigCalldata = encodeLockBridgeConfigCalldata;
12066
12575
  exports.encodeLookupPubkeyCalldata = encodeLookupPubkeyCalldata;
@@ -12132,6 +12641,7 @@ exports.encodeSetMinNotionalCalldata = encodeSetMinNotionalCalldata;
12132
12641
  exports.encodeSetOperatorDisplayCalldata = encodeSetOperatorDisplayCalldata;
12133
12642
  exports.encodeSetPolicyCalldata = encodeSetPolicyCalldata;
12134
12643
  exports.encodeSetPolicyClaimCalldata = encodeSetPolicyClaimCalldata;
12644
+ exports.encodeSetProbeAuthorityCalldata = encodeSetProbeAuthorityCalldata;
12135
12645
  exports.encodeSetTickSizeCalldata = encodeSetTickSizeCalldata;
12136
12646
  exports.encodeSubmitBridgeProofCalldata = encodeSubmitBridgeProofCalldata;
12137
12647
  exports.encodeSubmitPendingChangeCalldata = encodeSubmitPendingChangeCalldata;
@@ -12150,6 +12660,7 @@ exports.encodeTokenFactoryTransferCalldata = encodeTokenFactoryTransferCalldata;
12150
12660
  exports.encodeTokenFactoryTransferFromCalldata = encodeTokenFactoryTransferFromCalldata;
12151
12661
  exports.encodeTokenFactoryTransferOwnershipCalldata = encodeTokenFactoryTransferOwnershipCalldata;
12152
12662
  exports.encodeUndelegateCalldata = encodeUndelegateCalldata;
12663
+ exports.encodeUpdateCharterCalldata = encodeUpdateCharterCalldata;
12153
12664
  exports.encodeVoteClusterAdmitCalldata = encodeVoteClusterAdmitCalldata;
12154
12665
  exports.encodeVrfEvaluateCalldata = encodeVrfEvaluateCalldata;
12155
12666
  exports.exportBridgeRouteCatalogueJson = exportBridgeRouteCatalogueJson;
@@ -12221,6 +12732,7 @@ exports.parseQuantityBig = parseQuantityBig;
12221
12732
  exports.preflightClusterJoinRequest = preflightClusterJoinRequest;
12222
12733
  exports.previewRequestClusterJoin = previewRequestClusterJoin;
12223
12734
  exports.previewVoteClusterAdmit = previewVoteClusterAdmit;
12735
+ exports.protocolNonceForEpoch = protocolNonceForEpoch;
12224
12736
  exports.proverMarketStateFromByte = proverMarketStateFromByte;
12225
12737
  exports.pubkeyRegistryAddressHex = pubkeyRegistryAddressHex;
12226
12738
  exports.quoteOperatorFee = quoteOperatorFee;
@@ -12235,8 +12747,17 @@ exports.resolveMaxExecutionUnitPrice = resolveMaxExecutionUnitPrice;
12235
12747
  exports.resolveRegistryExecutionFee = resolveRegistryExecutionFee;
12236
12748
  exports.resolveStudioHostStatus = resolveStudioHostStatus;
12237
12749
  exports.selectBridgeTransferRoute = selectBridgeTransferRoute;
12750
+ exports.serviceMaskToBitIndex = serviceMaskToBitIndex;
12238
12751
  exports.serviceProbeStatusLabel = serviceProbeStatusLabel;
12239
12752
  exports.setDestinationRoot = setDestinationRoot;
12753
+ exports.slotArchiveChallengePass = slotArchiveChallengePass;
12754
+ exports.slotClusterCharter = slotClusterCharter;
12755
+ exports.slotClusterCharterDelegator = slotClusterCharterDelegator;
12756
+ exports.slotClusterCharterMembers = slotClusterCharterMembers;
12757
+ exports.slotClusterServiceScore = slotClusterServiceScore;
12758
+ exports.slotEpochChallengeSeed = slotEpochChallengeSeed;
12759
+ exports.slotProbeAuthority = slotProbeAuthority;
12760
+ exports.slotScoreServiceProbe = slotScoreServiceProbe;
12240
12761
  exports.sortMultisigMembers = sortMultisigMembers;
12241
12762
  exports.spendingPolicyAddressHex = spendingPolicyAddressHex;
12242
12763
  exports.submitMrvCallNativeTx = submitMrvCallNativeTx;
@@ -12249,6 +12770,8 @@ exports.submitVoteClusterAdmit = submitVoteClusterAdmit;
12249
12770
  exports.tokenFactoryAddressHex = tokenFactoryAddressHex;
12250
12771
  exports.transactionFeeExposure = transactionFeeExposure;
12251
12772
  exports.typedBech32ToAddress = typedBech32ToAddress;
12773
+ exports.updateCharterMessage = updateCharterMessage;
12774
+ exports.updateCharterMessageHex = updateCharterMessageHex;
12252
12775
  exports.validateAddress = validateAddress;
12253
12776
  exports.validateBridgeRouteCatalogue = validateBridgeRouteCatalogue;
12254
12777
  exports.validateMrvArtifactMetadata = validateMrvArtifactMetadata;