@monolythium/core-sdk 0.2.1 → 0.2.2

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
@@ -349,23 +349,23 @@ var PRECOMPILE_ADDRESSES = {
349
349
  TOKEN_FACTORY: "0x0000000000000000000000000000000000001000",
350
350
  /** Native central-limit order book — gateable. */
351
351
  CLOB: "0x0000000000000000000000000000000000001001",
352
- /** Agent execution surface (zkML-gated, ADR-0011/ADR-0020) — gateable. */
352
+ /** Agent execution surface — gateable. */
353
353
  AGENT: "0x0000000000000000000000000000000000001003",
354
354
  /** Account privacy policy + stealth/confidential ops — gateable. */
355
355
  PRIVACY: "0x0000000000000000000000000000000000001004",
356
356
  /** Operator + RPC node registry — non-gateable consensus invariant. */
357
357
  NODE_REGISTRY: "0x0000000000000000000000000000000000001005",
358
- /** Native zk-light-client bridge — gateable. */
358
+ /** Native bridge route-control surface — gateable. */
359
359
  BRIDGE: "0x0000000000000000000000000000000000001008",
360
- /** Decentralized multi-signer oracle (OI-0036) — non-gateable. */
360
+ /** Decentralized multi-signer oracle — non-gateable. */
361
361
  ORACLE: "0x0000000000000000000000000000000000001009",
362
- /** Distributed delegation primitive (Stage E.5a, Law §7.6) — gateable. */
362
+ /** Distributed delegation primitive — gateable. */
363
363
  DELEGATION: "0x000000000000000000000000000000000000100A",
364
- /** One-time emergency-key registry (Law §5.4 / §2.9) — non-gateable. */
364
+ /** One-time emergency-key registry — non-gateable. */
365
365
  EMERGENCY_KEY: "0x0000000000000000000000000000000000001100",
366
- /** VRF precompile (Law §5.4 / §5.6). */
366
+ /** VRF precompile. */
367
367
  VRF: "0x0000000000000000000000000000000000001101",
368
- /** Streaming-payments primitive (Law §5.4 / §5.7) — gateable. */
368
+ /** Streaming-payments primitive — gateable. */
369
369
  STREAMING_PAYMENTS: "0x0000000000000000000000000000000000001102",
370
370
  /** Cluster-name registry. */
371
371
  CLUSTER_NAME_REGISTRY: "0x0000000000000000000000000000000000001104",
@@ -383,11 +383,11 @@ var PRECOMPILE_ADDRESSES = {
383
383
  ESCROW: "0x000000000000000000000000000000000000110A",
384
384
  /** Agent-commerce arbiter registry. */
385
385
  ARBITER_REGISTRY: "0x000000000000000000000000000000000000110B",
386
- /** Agent spending policy — gateable, activated by Stage 7 milestones. */
386
+ /** Agent spending policy — gateable. */
387
387
  SPENDING_POLICY: "0x000000000000000000000000000000000000110C",
388
- /** Primary ML-DSA-65 pubkey registry — gateable, ADR-0034. */
388
+ /** Primary ML-DSA-65 pubkey registry — gateable. */
389
389
  PUBKEY_REGISTRY: "0x000000000000000000000000000000000000110D",
390
- /** Hierarchical name registry (Law §5.10, whitepaper §22.8) — gateable. */
390
+ /** Hierarchical name registry — gateable. */
391
391
  NAME_REGISTRY: "0x000000000000000000000000000000000000110E"
392
392
  };
393
393
 
@@ -2388,7 +2388,7 @@ var RpcClient = class _RpcClient {
2388
2388
  async web3Sha3(data) {
2389
2389
  return this.call("web3_sha3", [data]);
2390
2390
  }
2391
- // ---- lyth_* (Law §13.2 native namespace) --------------------------
2391
+ // ---- lyth_* native namespace --------------------------------------
2392
2392
  /** `lyth_listProviders` — paged registry enumeration. */
2393
2393
  async lythListProviders(capabilityMask, cursor = null, limit = 100) {
2394
2394
  return this.call("lyth_listProviders", [capabilityMask, cursor, limit]);
@@ -2620,14 +2620,26 @@ var RpcClient = class _RpcClient {
2620
2620
  async lythCurrentRound() {
2621
2621
  return normalizeRoundInfo(await this.call("lyth_currentRound", []));
2622
2622
  }
2623
+ /** `lyth_getTransactionCount` — native sender nonce. */
2624
+ async lythGetTransactionCount(address) {
2625
+ return parseRpcBigint(
2626
+ await this.call("lyth_getTransactionCount", [
2627
+ sdkTypedAddress(address, "user", "address")
2628
+ ]),
2629
+ "lyth_getTransactionCount"
2630
+ );
2631
+ }
2632
+ /** `lyth_executionUnitPrice` — native execution-unit price in lythoshi. */
2633
+ async lythExecutionUnitPrice() {
2634
+ return normalizeExecutionUnitPriceResponse(
2635
+ await this.call("lyth_executionUnitPrice", [])
2636
+ );
2637
+ }
2623
2638
  /** `lyth_peerSummary` — public-safe aggregate peer-network diagnostics. */
2624
2639
  async lythPeerSummary() {
2625
2640
  return this.call("lyth_peerSummary", []);
2626
2641
  }
2627
- /**
2628
- * `lyth_listActivePrecompiles` — milestone-gated precompile catalogue
2629
- * (OI-0170 / ADR-0015 §5).
2630
- */
2642
+ /** `lyth_listActivePrecompiles` — native precompile catalogue. */
2631
2643
  async lythListActivePrecompiles(block = "latest") {
2632
2644
  return this.call("lyth_listActivePrecompiles", [encodeBlockSelector(block)]);
2633
2645
  }
@@ -3552,6 +3564,34 @@ function normalizeRoundInfo(value) {
3552
3564
  height: parseRpcBigint(row["height"], "round height")
3553
3565
  };
3554
3566
  }
3567
+ function normalizeExecutionUnitPriceResponse(value) {
3568
+ if (!value || typeof value !== "object") {
3569
+ throw SdkError.malformed("execution unit price response must be an object");
3570
+ }
3571
+ const row = value;
3572
+ return {
3573
+ executionUnitPriceLythoshi: parseRpcBigint(
3574
+ fieldAlias(row, ["executionUnitPriceLythoshi", "execution_unit_price_lythoshi"]),
3575
+ "executionUnitPriceLythoshi"
3576
+ ).toString(),
3577
+ basePricePerExecutionUnitLythoshi: parseRpcBigint(
3578
+ fieldAlias(row, [
3579
+ "basePricePerExecutionUnitLythoshi",
3580
+ "base_price_per_execution_unit_lythoshi"
3581
+ ]),
3582
+ "basePricePerExecutionUnitLythoshi"
3583
+ ).toString(),
3584
+ priorityTipLythoshi: parseRpcBigint(
3585
+ fieldAlias(row, ["priorityTipLythoshi", "priority_tip_lythoshi"]),
3586
+ "priorityTipLythoshi"
3587
+ ).toString(),
3588
+ blockNumber: parseRpcNumberNullable(
3589
+ fieldAlias(row, ["blockNumber", "block_number"]),
3590
+ "blockNumber"
3591
+ ),
3592
+ source: readStringField(row, ["source"], "execution unit price source")
3593
+ };
3594
+ }
3555
3595
  function normalizeMempoolSnapshot(value) {
3556
3596
  if (!value || typeof value !== "object") {
3557
3597
  throw SdkError.malformed("mempool snapshot must be an object");
@@ -3568,6 +3608,19 @@ function normalizeMempoolSnapshot(value) {
3568
3608
  bytes_by_class: bytesByClass.map((v, i) => parseRpcBigint(v, `mempool bytes_by_class[${i}]`))
3569
3609
  };
3570
3610
  }
3611
+ function fieldAlias(record, keys) {
3612
+ for (const key of keys) {
3613
+ if (Object.prototype.hasOwnProperty.call(record, key)) return record[key];
3614
+ }
3615
+ return void 0;
3616
+ }
3617
+ function readStringField(record, keys, label) {
3618
+ const value = fieldAlias(record, keys);
3619
+ if (typeof value !== "string" || value.trim().length === 0) {
3620
+ throw SdkError.malformed(`${label} must be a non-empty string`);
3621
+ }
3622
+ return value.trim();
3623
+ }
3571
3624
  function normalizeCapabilitiesResponse(value) {
3572
3625
  return {
3573
3626
  ...value,
@@ -4072,6 +4125,8 @@ var BRIDGE_REVERT_TAGS = {
4072
4125
  };
4073
4126
  var BRIDGE_QUOTE_API_BLOCKED_REASON = "bridge quote requires a mono-core live quote API/runtime primitive";
4074
4127
  var BRIDGE_SUBMIT_API_BLOCKED_REASON = "bridge submit requires a mono-core live submit API/runtime primitive";
4128
+ var V1_BRIDGE_ALLOWED_FEE_TOKEN = "LINK";
4129
+ var V1_BRIDGE_ALLOWED_PROTOCOL = "chainlink-ccip";
4075
4130
  var BridgePrecompileError = class extends Error {
4076
4131
  constructor(message) {
4077
4132
  super(message);
@@ -4130,9 +4185,18 @@ function isBridgeFinalityZeroRevert(data) {
4130
4185
  function assessBridgeRoute(route) {
4131
4186
  const blockedReasons = [];
4132
4187
  const warnings = [];
4188
+ const feeToken = String(route.feeToken ?? "").trim();
4133
4189
  if (route.routeId.trim() === "") blockedReasons.push("route id missing");
4134
4190
  if (route.bridge.trim() === "") blockedReasons.push("bridge name missing");
4191
+ if (!isChainlinkCcipRoute(route.protocol, route.bridge, route.verifier.model)) {
4192
+ blockedReasons.push("bridge protocol must be Chainlink CCIP");
4193
+ }
4135
4194
  if (route.asset.trim() === "") blockedReasons.push("asset disclosure missing");
4195
+ if (feeToken === "") {
4196
+ blockedReasons.push("route fee token missing");
4197
+ } else if (feeToken.toUpperCase() !== V1_BRIDGE_ALLOWED_FEE_TOKEN) {
4198
+ blockedReasons.push("CCIP route fee token must be LINK");
4199
+ }
4136
4200
  if (route.verifier.model.trim() === "") blockedReasons.push("verifier model missing");
4137
4201
  if (route.verifier.threshold < 2 || route.verifier.participantCount < 2) {
4138
4202
  blockedReasons.push("verifier set must not be 1-of-1");
@@ -4374,8 +4438,23 @@ function validateBridgeRouteCatalogueRoute(idx, value, seen, blockedReasons) {
4374
4438
  20,
4375
4439
  blockedReasons
4376
4440
  );
4377
- validateTextField(`${prefix}.bridge`, value.bridge, 64, blockedReasons);
4441
+ const bridge = validateTextField(`${prefix}.bridge`, value.bridge, 64, blockedReasons);
4442
+ const protocol = validateOptionalTextField(
4443
+ `${prefix}.protocol`,
4444
+ field(value, "protocol", "routeProtocol", "route_protocol"),
4445
+ 64,
4446
+ blockedReasons
4447
+ );
4378
4448
  validateTextField(`${prefix}.asset`, value.asset, 64, blockedReasons);
4449
+ const feeToken = validateTextField(
4450
+ `${prefix}.feeToken`,
4451
+ field(value, "feeToken", "fee_token"),
4452
+ 32,
4453
+ blockedReasons
4454
+ );
4455
+ if (feeToken != null && feeToken.toUpperCase() !== V1_BRIDGE_ALLOWED_FEE_TOKEN) {
4456
+ blockedReasons.push(`${prefix}.feeToken must be LINK for CCIP routes`);
4457
+ }
4379
4458
  validateTextField(
4380
4459
  `${prefix}.sourceChain`,
4381
4460
  field(value, "sourceChain", "source_chain"),
@@ -4389,10 +4468,11 @@ function validateBridgeRouteCatalogueRoute(idx, value, seen, blockedReasons) {
4389
4468
  blockedReasons
4390
4469
  );
4391
4470
  const verifier = value.verifier;
4471
+ let verifierModel = null;
4392
4472
  if (!isRecord2(verifier)) {
4393
4473
  blockedReasons.push(`${prefix}.verifier must be an object`);
4394
4474
  } else {
4395
- validateTextField(`${prefix}.verifier.model`, verifier.model, 64, blockedReasons);
4475
+ verifierModel = validateTextField(`${prefix}.verifier.model`, verifier.model, 64, blockedReasons);
4396
4476
  const participantCount = field(verifier, "participantCount", "participant_count");
4397
4477
  if (!isU16(participantCount) || participantCount === 0) {
4398
4478
  blockedReasons.push(`${prefix}.verifier.participantCount must be non-zero`);
@@ -4403,6 +4483,9 @@ function validateBridgeRouteCatalogueRoute(idx, value, seen, blockedReasons) {
4403
4483
  blockedReasons.push(`${prefix}.verifier.threshold must be in 1..=participantCount`);
4404
4484
  }
4405
4485
  }
4486
+ if (!isChainlinkCcipRoute(protocol, bridge ?? "", verifierModel ?? "")) {
4487
+ blockedReasons.push(`${prefix}.protocol must be Chainlink CCIP`);
4488
+ }
4406
4489
  if (!decimalStringIsPositiveU256(field(value, "drainCapAtomic", "drain_cap_atomic"))) {
4407
4490
  blockedReasons.push(`${prefix}.drainCapAtomic must be a non-zero decimal u256`);
4408
4491
  }
@@ -4444,7 +4527,9 @@ function coerceBridgeRouteCatalogueRoute(value) {
4444
4527
  bridgeId: stringField2(value, "bridgeId", "bridge_id"),
4445
4528
  wrappedAsset: stringField2(value, "wrappedAsset", "wrapped_asset"),
4446
4529
  bridge: stringField2(value, "bridge").trim(),
4530
+ protocol: optionalStringField(value, "protocol", "routeProtocol", "route_protocol"),
4447
4531
  asset: stringField2(value, "asset").trim(),
4532
+ feeToken: stringField2(value, "feeToken", "fee_token").trim(),
4448
4533
  sourceChain: stringField2(value, "sourceChain", "source_chain").trim(),
4449
4534
  destinationChain: stringField2(value, "destinationChain", "destination_chain").trim(),
4450
4535
  verifier: {
@@ -4473,6 +4558,19 @@ function cloneBridgeRouteCatalogueRoute(route) {
4473
4558
  verifier: { ...route.verifier }
4474
4559
  };
4475
4560
  }
4561
+ function isChainlinkCcipRoute(protocol, bridge, verifierModel) {
4562
+ const normalizedProtocol = normalizeBridgeProtocol(protocol ?? "");
4563
+ if (normalizedProtocol.length > 0) {
4564
+ return normalizedProtocol === "chainlinkccip" || normalizedProtocol === "ccip";
4565
+ }
4566
+ return bridgeLabelLooksCcip(bridge) || bridgeLabelLooksCcip(verifierModel);
4567
+ }
4568
+ function bridgeLabelLooksCcip(value) {
4569
+ return normalizeBridgeProtocol(value).includes("ccip");
4570
+ }
4571
+ function normalizeBridgeProtocol(value) {
4572
+ return value.trim().toLowerCase().replace(/[^a-z0-9]/g, "");
4573
+ }
4476
4574
  function bridgeRouteCandidate(intent, intentReasons, route) {
4477
4575
  const assessment = assessBridgeRoute(route);
4478
4576
  const blockedReasons = [...intentReasons, ...assessment.blockedReasons];
@@ -4568,16 +4666,28 @@ function trimmedEq(left, right) {
4568
4666
  function isRecord2(value) {
4569
4667
  return typeof value === "object" && value !== null && !Array.isArray(value);
4570
4668
  }
4571
- function field(record, camel, snake) {
4572
- if (Object.prototype.hasOwnProperty.call(record, camel)) return record[camel];
4573
- if (snake != null && Object.prototype.hasOwnProperty.call(record, snake)) return record[snake];
4669
+ function field(record, ...keys) {
4670
+ for (const key of keys) {
4671
+ if (Object.prototype.hasOwnProperty.call(record, key)) return record[key];
4672
+ }
4574
4673
  return void 0;
4575
4674
  }
4576
- function stringField2(record, camel, snake) {
4577
- return field(record, camel, snake);
4675
+ function stringField2(record, ...keys) {
4676
+ return field(record, ...keys);
4578
4677
  }
4579
- function numberField(record, camel, snake) {
4580
- return field(record, camel, snake);
4678
+ function optionalStringField(record, ...keys) {
4679
+ let raw;
4680
+ for (const key of keys) {
4681
+ if (Object.prototype.hasOwnProperty.call(record, key)) {
4682
+ raw = record[key];
4683
+ break;
4684
+ }
4685
+ }
4686
+ if (raw === void 0 || raw === null) return null;
4687
+ return typeof raw === "string" ? raw.trim() : "";
4688
+ }
4689
+ function numberField(record, ...keys) {
4690
+ return field(record, ...keys);
4581
4691
  }
4582
4692
  function validateTextField(name, value, maxLen, blockedReasons) {
4583
4693
  if (typeof value !== "string") {
@@ -4591,6 +4701,10 @@ function validateTextField(name, value, maxLen, blockedReasons) {
4591
4701
  }
4592
4702
  return trimmed;
4593
4703
  }
4704
+ function validateOptionalTextField(name, value, maxLen, blockedReasons) {
4705
+ if (value === void 0 || value === null) return null;
4706
+ return validateTextField(name, value, maxLen, blockedReasons);
4707
+ }
4594
4708
  function validateHexBytes(name, value, expectedBytes, blockedReasons) {
4595
4709
  if (typeof value !== "string") {
4596
4710
  blockedReasons.push(`${name} must be ${expectedBytes} bytes of hex`);
@@ -4720,9 +4834,10 @@ function concatBytes4(...parts) {
4720
4834
  var NO_EVM_RECEIPT_PROOF_SCHEMA = "mono.no_evm_receipt_proof.v1";
4721
4835
  var NO_EVM_RECEIPT_PROOF_TYPE = "canonicalReceiptsTranscript";
4722
4836
  var NO_EVM_RECEIPT_INCLUSION_PROOF_TYPE = "canonicalReceiptInclusion";
4723
- var NO_EVM_RECEIPT_ROOT_ALGORITHM = "keccak256(monolythium/v4.1/receipts_root_empty/1|receipt_leaf/1|receipt_node/1 binary Merkle)";
4837
+ var NO_EVM_RECEIPT_ROOT_ALGORITHM = "keccak256-binary-merkle(monolythium/v4.1/receipt_leaf/1, monolythium/v4.1/receipt_node/1, duplicate-last padding)";
4838
+ var NO_EVM_LEGACY_BINARY_RECEIPT_ROOT_ALGORITHM = "keccak256(monolythium/v4.1/receipts_root_empty/1|receipt_leaf/1|receipt_node/1 binary Merkle)";
4724
4839
  var NO_EVM_LEGACY_RECEIPT_ROOT_ALGORITHM = "keccak256(monolythium/v2/receipts_root/1 || len || indexed bincode receipts)";
4725
- var NO_EVM_RECEIPT_CODEC = "bincode(protocore_evm::Receipt)";
4840
+ var NO_EVM_RECEIPT_CODEC = "bincode(protocore_execution_types::Receipt)";
4726
4841
  var NO_EVM_RECEIPTS_ROOT_DOMAIN = "monolythium/v4.1/receipts_root_empty/1";
4727
4842
  var NO_EVM_RECEIPT_LEAF_DOMAIN = "monolythium/v4.1/receipt_leaf/1";
4728
4843
  var NO_EVM_RECEIPT_NODE_DOMAIN = "monolythium/v4.1/receipt_node/1";
@@ -5959,7 +6074,7 @@ function getOptionalHistorySource(proof) {
5959
6074
  return value === void 0 ? void 0 : String(value);
5960
6075
  }
5961
6076
  function assertSupportedRootAlgorithm(actual) {
5962
- if (actual !== NO_EVM_RECEIPT_ROOT_ALGORITHM && actual !== NO_EVM_LEGACY_RECEIPT_ROOT_ALGORITHM && actual !== NO_EVM_COMPACT_INCLUSION_TREE_ALGORITHM) {
6077
+ if (actual !== NO_EVM_RECEIPT_ROOT_ALGORITHM && actual !== NO_EVM_LEGACY_BINARY_RECEIPT_ROOT_ALGORITHM && actual !== NO_EVM_LEGACY_RECEIPT_ROOT_ALGORITHM && actual !== NO_EVM_COMPACT_INCLUSION_TREE_ALGORITHM) {
5963
6078
  throw new NoEvmReceiptProofError(
5964
6079
  "unsupported_root_algorithm",
5965
6080
  `unsupported no-EVM receipt proof rootAlgorithm: ${actual}`
@@ -7887,7 +8002,7 @@ var MONOLYTHIUM_TESTNET_CHAIN_ID = 69420n;
7887
8002
  var MONOLYTHIUM_TESTNET_NETWORK_NAME = "monolythium-testnet";
7888
8003
 
7889
8004
  // src/index.ts
7890
- var version = "0.2.1";
8005
+ var version = "0.2.2";
7891
8006
 
7892
8007
  exports.ADDRESS_HRP = ADDRESS_HRP;
7893
8008
  exports.ADDRESS_KIND_HRPS = ADDRESS_KIND_HRPS;
@@ -7971,6 +8086,8 @@ exports.SPENDING_POLICY_SELECTORS = SPENDING_POLICY_SELECTORS;
7971
8086
  exports.SdkError = SdkError;
7972
8087
  exports.SpendingPolicyError = SpendingPolicyError;
7973
8088
  exports.TESTNET_69420 = TESTNET_69420;
8089
+ exports.V1_BRIDGE_ALLOWED_FEE_TOKEN = V1_BRIDGE_ALLOWED_FEE_TOKEN;
8090
+ exports.V1_BRIDGE_ALLOWED_PROTOCOL = V1_BRIDGE_ALLOWED_PROTOCOL;
7974
8091
  exports.addressBytesToHex = addressBytesToHex;
7975
8092
  exports.addressToBech32 = addressToBech32;
7976
8093
  exports.addressToTypedBech32 = addressToTypedBech32;