@molpha/sdk 0.2.0-dev-20261002062009 → 0.2.0-dev-20261005112114

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.js CHANGED
@@ -313,18 +313,19 @@ function secp256k1PublicKeyFromCoordinates(x, y, label = "secp256k1 public key c
313
313
  }
314
314
  var SELECTION_SEED_DOMAIN = keccak_256(utf8("MOLPHA_SELECTION_V1"));
315
315
  var SELECTION_DERIVE_DOMAIN = keccak_256(utf8("MOLPHA_SELECTION_DERIVE"));
316
+ var SELECTION_WINDOW_MS = 1000n;
316
317
  var MAX_ROUNDS = 65536;
317
318
  var BITMAP_BYTES = 32;
318
319
  var MAX_NODES = BITMAP_BYTES * 8;
319
320
  var U32_MAX = 4294967295;
320
- function deriveSelectionSeed(sourceId, registryVersion, canonicalTimestamp) {
321
+ function deriveSelectionSeed(sourceId, registryVersion, timestamp) {
321
322
  ensureLength(sourceId, 32, "sourceId");
322
323
  return keccak_256(
323
324
  concatBytes(
324
325
  SELECTION_SEED_DOMAIN,
325
326
  sourceId,
326
327
  u32be(registryVersion),
327
- u64be(canonicalTimestamp)
328
+ u64be(BigInt(timestamp) / SELECTION_WINDOW_MS)
328
329
  )
329
330
  );
330
331
  }
@@ -390,7 +391,7 @@ function deriveGroupBitmap(seed, nodeCount, groupSize) {
390
391
  }
391
392
  return bitmap;
392
393
  }
393
- function deriveSelectionBitmap(sourceId, registryVersion, nodeCount, signaturesRequired, redundancy = 0, ts = Math.floor(Date.now() / 1e3)) {
394
+ function deriveSelectionBitmap(sourceId, registryVersion, nodeCount, signaturesRequired, redundancy = 0, ts = Date.now()) {
394
395
  const seed = deriveSelectionSeed(sourceId, registryVersion, ts);
395
396
  const size = effectiveSelectionSize(signaturesRequired, redundancy, nodeCount);
396
397
  return deriveGroupBitmap(seed, nodeCount, size);
@@ -405,7 +406,7 @@ function encodeRequestAuth(fields) {
405
406
  ensureLength(fields.gateway, 32, "gateway"),
406
407
  toFixedBytes(fields.sourceId, 32, "sourceId"),
407
408
  Uint8Array.of(fields.signaturesRequired),
408
- u64le(fields.timestamp)
409
+ u64le(fields.authTimestamp)
409
410
  );
410
411
  }
411
412
  function hashRequestAuth(fields) {
@@ -779,6 +780,12 @@ function parseGatewayInfo(data) {
779
780
 
780
781
  // src/gateway/index.ts
781
782
  var ZERO_AUTH_SIG = new Uint8Array(64);
783
+ var authTimestampNow = () => Math.floor(Date.now() / 1e3);
784
+ var DEFAULT_TICK_MS = 1e3;
785
+ function msUntilNextTick(nowMs, tickMs) {
786
+ return tickMs - nowMs % tickMs + 1;
787
+ }
788
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
782
789
  var DEFAULT_GATEWAY_ENDPOINT = "https://dev-gateway.molpha.io/";
783
790
  var GatewayError = class extends Error {
784
791
  constructor(message, status) {
@@ -831,13 +838,12 @@ var MolphaGateway = class {
831
838
  * selection policy, which sizes the eligible set a paid source must fund.
832
839
  *
833
840
  * The `registry` block is advisory: it is whatever the gateway read from the
834
- * chain, and is absent on older gateways or when that read failed. Prefer the
841
+ * chain, and is absent when that read failed. Prefer the
835
842
  * on-chain read (`MolphaSolanaClient.getRegistrySelectionConfig`) whenever a
836
843
  * Solana connection is available — `requestSignedData` already does.
837
844
  */
838
845
  async getNodesInfo() {
839
846
  const data = await this.firstReachableData("/v1/nodes");
840
- if (Array.isArray(data)) return { nodes: data };
841
847
  return {
842
848
  nodes: data.nodes,
843
849
  ...data.registry ? { registry: data.registry } : {}
@@ -890,12 +896,23 @@ var MolphaGateway = class {
890
896
  }
891
897
  /**
892
898
  * Request a threshold-signed data update from the gateway, with retry +
893
- * failover. Per attempt a fresh timestamp yields a fresh selection bitmap; the
894
- * body is POSTed to each endpoint in order until one `completed`s.
899
+ * failover. The body is POSTed to each endpoint in order until one `completed`s.
900
+ *
901
+ * The round's `sourceId` is derived from `apiConfig`. The request carries no round timestamp:
902
+ * the gateway assigns the round's `timestamp` (unix milliseconds) from its own clock
903
+ * on a tick grid, and the committee follows from it. The result carries the assigned
904
+ * timestamp and the signers' bitmap. A retry waits for a later tick, because a round that was
905
+ * already reserved or dispatched cannot run again in the same one (HTTP 409).
895
906
  *
896
- * The round's `sourceId` is derived from `apiConfig`. The request authorization
897
- * binds the program id and each gateway's on-chain account, so the auth signature
898
- * is recomputed for every endpoint tried.
907
+ * The request is authorized by a `RequestAuth` signature (`authSig`) over the program id, the
908
+ * endpoint's Gateway PDA, the source id, the quorum and `authTimestamp` (unix seconds, read
909
+ * from the local clock for every attempt). It only proves the caller may spend the
910
+ * subscription's rounds; it is not part of the round, so the signature is recomputed for every
911
+ * endpoint tried.
912
+ *
913
+ * Because the committee is unknown until the gateway stamps the round, private API
914
+ * secrets are encrypted for **every** node of the registry; the gateway forwards only the
915
+ * selected nodes' envelopes.
899
916
  *
900
917
  * By default this fetches the registry selection config up front and the node
901
918
  * set only when the round needs it (private API encryption, or when the registry
@@ -970,28 +987,23 @@ var MolphaGateway = class {
970
987
  }
971
988
  }
972
989
  let lastError;
973
- let lastTimestamp = 0;
990
+ const tickMs = opts.tickMs ?? DEFAULT_TICK_MS;
991
+ const groupSize = effectiveSelectionSize(signaturesRequired, redundancyBuffer, nodeCount);
992
+ const registryIndexes = Array.from({ length: nodeCount }, (_, index) => index);
974
993
  for (let attempt = 0; attempt < maxRetries; attempt++) {
975
- let timestamp = Math.floor(Date.now() / 1e3);
976
- if (timestamp <= lastTimestamp) timestamp = lastTimestamp + 1;
977
- lastTimestamp = timestamp;
978
- const seed = deriveSelectionSeed(sourceIdBytes, registryVersion, timestamp);
979
- const groupSize = effectiveSelectionSize(signaturesRequired, redundancyBuffer, nodeCount);
980
- const bitmap = deriveGroupBitmap(seed, nodeCount, groupSize);
981
- const indices = selectedIndices(bitmap, nodeCount);
994
+ if (attempt > 0) await sleep(msUntilNextTick(Date.now(), tickMs));
982
995
  let encKeyBundle;
983
996
  if (encrypt) {
984
- const selected = selectedNodesForPrivateApiEncryption(round.nodes ?? [], indices);
997
+ const recipients = selectedNodesForPrivateApiEncryption(round.nodes ?? [], registryIndexes);
985
998
  if (verifyNodeKeys) {
986
999
  await verifyNodeKeys({
987
1000
  sourceId,
988
1001
  registryVersion,
989
- timestamp,
990
- selectedIndexes: [...indices],
991
- selectedNodes: selected.map((node) => ({ ...node }))
1002
+ nodeIndexes: [...registryIndexes],
1003
+ nodes: recipients.map((node) => ({ ...node }))
992
1004
  });
993
1005
  }
994
- encKeyBundle = encryptForNodes(requestApiConfig, encrypt.secrets, selected);
1006
+ encKeyBundle = encryptForNodes(requestApiConfig, encrypt.secrets, recipients);
995
1007
  }
996
1008
  let sourcePayments;
997
1009
  if (terms && sourcePayment && authorizations > 0) {
@@ -1004,7 +1016,6 @@ var MolphaGateway = class {
1004
1016
  const baseBody = {
1005
1017
  sourceId,
1006
1018
  registryVersion,
1007
- timestamp,
1008
1019
  maxAge,
1009
1020
  signaturesRequired,
1010
1021
  subscriptionOwner,
@@ -1017,19 +1028,21 @@ var MolphaGateway = class {
1017
1028
  for (const endpoint of this.endpoints) {
1018
1029
  try {
1019
1030
  let authSig = ZERO_AUTH_SIG;
1031
+ let authTimestamp = authTimestampNow();
1020
1032
  if (authSigner) {
1021
1033
  const gateway = await this.resolveGatewayPda(endpoint, timeoutMs);
1034
+ authTimestamp = authTimestampNow();
1022
1035
  authSig = await authSigner(
1023
1036
  hashRequestAuth({
1024
1037
  programId: this.programIdBytes,
1025
1038
  gateway,
1026
1039
  sourceId: sourceIdBytes,
1027
1040
  signaturesRequired,
1028
- timestamp
1041
+ authTimestamp
1029
1042
  })
1030
1043
  );
1031
1044
  }
1032
- const body = { ...baseBody, authSig: bytesToHex0x(authSig) };
1045
+ const body = { ...baseBody, authSig: bytesToHex0x(authSig), authTimestamp };
1033
1046
  const res = await this.post(
1034
1047
  `${endpoint.url}/v1/round/execute`,
1035
1048
  body,
@@ -1106,14 +1119,10 @@ var MolphaGateway = class {
1106
1119
  continue;
1107
1120
  }
1108
1121
  const json = await res.json();
1109
- const payload = json.data ?? (json.status === "completed" ? json : void 0);
1110
- if (json.status === "completed" && payload) {
1111
- return toResult(payload, {
1122
+ if (json.status === "completed" && json.data) {
1123
+ return toResult(json.data, {
1112
1124
  sourceId,
1113
- registryVersion,
1114
- timestamp,
1115
1125
  signaturesRequired,
1116
- bitmap,
1117
1126
  ...requestApiConfig.aggregation ? { aggregation: requestApiConfig.aggregation } : {}
1118
1127
  });
1119
1128
  }
@@ -1216,14 +1225,11 @@ function assertSignaturesRequired(value) {
1216
1225
  return value;
1217
1226
  }
1218
1227
  function unwrapEnvelope(json, path, status) {
1219
- if (json && typeof json === "object" && "data" in json) {
1220
- const wrapped = json;
1221
- if (wrapped.data === void 0) {
1222
- throw new GatewayError(`GET ${path} returned malformed payload`, status);
1223
- }
1224
- return wrapped.data;
1228
+ const wrapped = json;
1229
+ if (wrapped === null || typeof wrapped !== "object" || wrapped.data === void 0) {
1230
+ throw new GatewayError(`GET ${path} returned malformed payload`, status);
1225
1231
  }
1226
- return json;
1232
+ return wrapped.data;
1227
1233
  }
1228
1234
  function selectedNodesForPrivateApiEncryption(nodes, selectedIndexes) {
1229
1235
  if (!Array.isArray(nodes)) {
@@ -1309,11 +1315,12 @@ function flattenGatewayData(data) {
1309
1315
  if (!nested) return data;
1310
1316
  const { attestation: _nested, ...rest } = data;
1311
1317
  const { payload, signature } = nested;
1318
+ const timestamp = payload?.timestamp ?? payload?.canonicalTimestamp;
1312
1319
  return {
1313
1320
  ...rest,
1314
1321
  ...payload?.sourceId !== void 0 ? { sourceId: payload.sourceId } : {},
1315
1322
  ...payload?.value !== void 0 ? { valuePacked: payload.value } : {},
1316
- ...payload?.canonicalTimestamp !== void 0 ? { timestamp: payload.canonicalTimestamp } : {},
1323
+ ...timestamp !== void 0 ? { timestamp } : {},
1317
1324
  ...payload?.registryVersion !== void 0 ? { registryVersion: payload.registryVersion } : {},
1318
1325
  ...payload?.signaturesRequired !== void 0 ? { signaturesRequired: payload.signaturesRequired } : {},
1319
1326
  ...signature?.signersBitmap !== void 0 ? { signersBitmap: signature.signersBitmap } : {},
@@ -1322,6 +1329,12 @@ function flattenGatewayData(data) {
1322
1329
  };
1323
1330
  }
1324
1331
  function toResult(raw, ctx) {
1332
+ if (raw.attestation) {
1333
+ const { payload, signature } = raw.attestation;
1334
+ if (!payload || !signature) {
1335
+ throw new GatewayError("Gateway response is missing the attestation");
1336
+ }
1337
+ }
1325
1338
  const data = flattenGatewayData(raw);
1326
1339
  if (data.sourceId !== void 0 && normalizeHex(data.sourceId) !== ctx.sourceId) {
1327
1340
  throw new GatewayError(
@@ -1358,33 +1371,41 @@ function toResult(raw, ctx) {
1358
1371
  );
1359
1372
  }
1360
1373
  }
1374
+ const fields = {
1375
+ timestamp: data.timestamp,
1376
+ registryVersion: data.registryVersion,
1377
+ value: data.valuePacked,
1378
+ signersBitmap: data.signersBitmap,
1379
+ s: data.s,
1380
+ commitmentAddr: data.commitmentAddr
1381
+ };
1382
+ for (const [name, field] of Object.entries(fields)) {
1383
+ if (field === void 0 || field === "") {
1384
+ throw new GatewayError(`Gateway response is missing ${name}`);
1385
+ }
1386
+ }
1361
1387
  let value = data.value ?? "";
1362
1388
  if (ctx.aggregation) {
1363
- for (const field of ["valuePacked", "signersBitmap", "s", "commitmentAddr"]) {
1364
- if (!data[field]) {
1365
- throw new GatewayError(`Gateway tolerance response is missing ${field}`);
1366
- }
1367
- }
1368
1389
  try {
1369
- value = formatInt256Decimal(data.valuePacked, ctx.aggregation.numeric.decimals);
1390
+ value = formatInt256Decimal(fields.value, ctx.aggregation.numeric.decimals);
1370
1391
  } catch (err) {
1371
1392
  throw new GatewayError(
1372
- `Gateway tolerance response valuePacked is not an int256 word: ${err instanceof Error ? err.message : String(err)}`
1393
+ `Gateway tolerance response value is not an int256 word: ${err instanceof Error ? err.message : String(err)}`
1373
1394
  );
1374
1395
  }
1375
1396
  }
1376
1397
  return {
1377
1398
  payload: {
1378
1399
  sourceId: ctx.sourceId,
1379
- value: data.valuePacked ?? "",
1380
- canonicalTimestamp: data.timestamp ?? ctx.timestamp,
1381
- registryVersion: data.registryVersion ?? ctx.registryVersion,
1400
+ value: fields.value,
1401
+ timestamp: fields.timestamp,
1402
+ registryVersion: fields.registryVersion,
1382
1403
  signaturesRequired: ctx.signaturesRequired
1383
1404
  },
1384
1405
  signature: {
1385
- signersBitmap: data.signersBitmap ?? bytesToHex(ctx.bitmap),
1386
- s: data.s ?? "",
1387
- commitmentAddr: data.commitmentAddr ?? ""
1406
+ signersBitmap: fields.signersBitmap,
1407
+ s: fields.s,
1408
+ commitmentAddr: fields.commitmentAddr
1388
1409
  },
1389
1410
  value,
1390
1411
  fresh: data.fresh ?? true
@@ -6103,7 +6124,7 @@ var molpha_default = {
6103
6124
  {
6104
6125
  code: 6030,
6105
6126
  name: "FeedNotNewer",
6106
- msg: "canonical_timestamp <= feed.canonical_timestamp"
6127
+ msg: "timestamp <= feed.timestamp"
6107
6128
  },
6108
6129
  {
6109
6130
  code: 6031,
@@ -6248,12 +6269,12 @@ var molpha_default = {
6248
6269
  {
6249
6270
  code: 6059,
6250
6271
  name: "AttestationTooStale",
6251
- msg: "canonical_timestamp is older than now - max_settlement_delay_seconds"
6272
+ msg: "timestamp is older than now - max_settlement_delay_seconds"
6252
6273
  },
6253
6274
  {
6254
6275
  code: 6060,
6255
6276
  name: "AttestationInFuture",
6256
- msg: "canonical_timestamp is further ahead of cluster time than the allowed drift"
6277
+ msg: "timestamp is further ahead of cluster time than the allowed drift"
6257
6278
  },
6258
6279
  {
6259
6280
  code: 6061,
@@ -6378,7 +6399,7 @@ var molpha_default = {
6378
6399
  {
6379
6400
  code: 6085,
6380
6401
  name: "RoundOutsideEpoch",
6381
- msg: "canonical_timestamp is outside the epoch window"
6402
+ msg: "timestamp is outside the epoch window"
6382
6403
  },
6383
6404
  {
6384
6405
  code: 6086,
@@ -6535,7 +6556,7 @@ var molpha_default = {
6535
6556
  type: "u8"
6536
6557
  },
6537
6558
  {
6538
- name: "canonical_timestamp",
6559
+ name: "timestamp",
6539
6560
  type: "u64"
6540
6561
  }
6541
6562
  ]
@@ -7186,7 +7207,7 @@ var molpha_default = {
7186
7207
  type: "pubkey"
7187
7208
  },
7188
7209
  {
7189
- name: "canonical_timestamp",
7210
+ name: "timestamp",
7190
7211
  type: "u64"
7191
7212
  },
7192
7213
  {
@@ -7232,7 +7253,7 @@ var molpha_default = {
7232
7253
  type: "u32"
7233
7254
  },
7234
7255
  {
7235
- name: "canonical_timestamp",
7256
+ name: "timestamp",
7236
7257
  type: "u64"
7237
7258
  },
7238
7259
  {
@@ -8287,7 +8308,7 @@ var molpha_default = {
8287
8308
  {
8288
8309
  name: "max_settlement_delay_seconds",
8289
8310
  docs: [
8290
- "Max age in seconds of `canonical_timestamp` relative to cluster time at attestation",
8311
+ "Max age in seconds of `timestamp` relative to cluster time at attestation",
8291
8312
  "ingress, and the grace period of a superseded registry version."
8292
8313
  ],
8293
8314
  type: "u64"
@@ -9643,7 +9664,7 @@ function buildSubmitAttestationArgs(attestation, coalitionKey, rawValue) {
9643
9664
  sourceId: Array.from(toFixedBytes(payload.sourceId, 32, "sourceId")),
9644
9665
  registryVersion: payload.registryVersion,
9645
9666
  signaturesRequired: payload.signaturesRequired,
9646
- canonicalTimestamp: new BN(payload.canonicalTimestamp)
9667
+ timestamp: new BN(payload.timestamp)
9647
9668
  },
9648
9669
  signature: {
9649
9670
  aggSigS: Array.from(toFixedBytes(signature.s, 32, "signature.s")),
@@ -9699,16 +9720,16 @@ function nodeCoordinate(account, camelCaseField, snakeCaseField) {
9699
9720
  return toFixedBytes(Uint8Array.from(value), 32, `Node.${camelCaseField}`);
9700
9721
  }
9701
9722
  function selectedNodesForVerifier(args) {
9702
- if (args.selectedIndexes.length === 0) {
9723
+ if (args.nodeIndexes.length === 0) {
9703
9724
  throw new Error("Private API node-key verification requires at least one selected index");
9704
9725
  }
9705
- if (args.selectedNodes.length !== args.selectedIndexes.length) {
9726
+ if (args.nodes.length !== args.nodeIndexes.length) {
9706
9727
  throw new Error(
9707
- `Private API node-key verification expected ${args.selectedIndexes.length} selected nodes, got ${args.selectedNodes.length}`
9728
+ `Private API node-key verification expected ${args.nodeIndexes.length} selected nodes, got ${args.nodes.length}`
9708
9729
  );
9709
9730
  }
9710
9731
  const expected = /* @__PURE__ */ new Set();
9711
- for (const index of args.selectedIndexes) {
9732
+ for (const index of args.nodeIndexes) {
9712
9733
  if (!Number.isInteger(index) || index < 0) {
9713
9734
  throw new Error(`Private API selected index must be a non-negative integer: ${index}`);
9714
9735
  }
@@ -9718,7 +9739,7 @@ function selectedNodesForVerifier(args) {
9718
9739
  expected.add(index);
9719
9740
  }
9720
9741
  const byIndex = /* @__PURE__ */ new Map();
9721
- for (const node of args.selectedNodes) {
9742
+ for (const node of args.nodes) {
9722
9743
  if (!Number.isInteger(node.index) || node.index < 0) {
9723
9744
  throw new Error(
9724
9745
  `Private API selected node index must be a non-negative integer: ${node.index}`
@@ -9732,7 +9753,7 @@ function selectedNodesForVerifier(args) {
9732
9753
  }
9733
9754
  byIndex.set(node.index, node);
9734
9755
  }
9735
- return args.selectedIndexes.map((index) => {
9756
+ return args.nodeIndexes.map((index) => {
9736
9757
  const node = byIndex.get(index);
9737
9758
  if (!node) {
9738
9759
  throw new Error(`Private API selected node is missing for index: ${index}`);
@@ -9763,7 +9784,7 @@ function attestationMessageHash(fields) {
9763
9784
  toFixedBytes(fields.sourceId, 32, "sourceId"),
9764
9785
  u32be(fields.registryVersion),
9765
9786
  u8(fields.signaturesRequired),
9766
- u64be(fields.canonicalTimestamp),
9787
+ u64be(fields.timestamp),
9767
9788
  toFixedBytes(fields.signersBitmap, 32, "signersBitmap")
9768
9789
  )
9769
9790
  );
@@ -9776,10 +9797,20 @@ function attestationMessageHashFromAttestation(attestation) {
9776
9797
  signaturesRequired: payload.signaturesRequired,
9777
9798
  signersBitmap: signature.signersBitmap,
9778
9799
  value: payload.value,
9779
- canonicalTimestamp: payload.canonicalTimestamp
9800
+ timestamp: payload.timestamp
9780
9801
  });
9781
9802
  }
9782
9803
 
9804
+ // src/core/timestamp.ts
9805
+ function timestampSeconds(timestamp) {
9806
+ const ms = typeof timestamp === "bigint" ? timestamp : BigInt(timestamp);
9807
+ if (ms < 0n) throw new RangeError("timestamp must not be negative");
9808
+ return Number(ms / 1000n);
9809
+ }
9810
+ function timestampAgeSeconds(timestamp, nowSeconds) {
9811
+ return Math.max(0, nowSeconds - timestampSeconds(timestamp));
9812
+ }
9813
+
9783
9814
  // src/core/verifyCodes.ts
9784
9815
  var VERIFY_CODES = {
9785
9816
  OK: 0,
@@ -9787,11 +9818,11 @@ var VERIFY_CODES = {
9787
9818
  FEED_WITNESS: 1,
9788
9819
  /** The payload's `registryVersion` does not exist on this verifier. */
9789
9820
  BAD_REGISTRY_VERSION: 2,
9790
- /** Structurally invalid input, or a `canonicalTimestamp` in the future when `maxAge != 0`. */
9821
+ /** Structurally invalid input, or a `timestamp` in the future when `maxAge != 0`. */
9791
9822
  MALFORMED: 3,
9792
- /** `canonicalTimestamp` predates the registry version's activation. */
9823
+ /** `timestamp` predates the registry version's activation. */
9793
9824
  NOT_YET_ACTIVE: 4,
9794
- /** The registry version was superseded more than the grace window before `canonicalTimestamp`. */
9825
+ /** The registry version was superseded more than the grace window before `timestamp`. */
9795
9826
  VERSION_EXPIRED: 5,
9796
9827
  /** Reserved. Never returned. */
9797
9828
  COMPROMISED_QUORUM: 6,
@@ -9835,7 +9866,7 @@ var MOLPHA_VERIFIER_ABI = [
9835
9866
  { name: "sourceId", type: "bytes32", internalType: "bytes32" },
9836
9867
  { name: "registryVersion", type: "uint32", internalType: "uint32" },
9837
9868
  { name: "signaturesRequired", type: "uint8", internalType: "uint8" },
9838
- { name: "canonicalTimestamp", type: "uint64", internalType: "uint64" }
9869
+ { name: "timestamp", type: "uint64", internalType: "uint64" }
9839
9870
  ]
9840
9871
  },
9841
9872
  {
@@ -10008,7 +10039,7 @@ function buildEvmVerifierArgs(attestation, options) {
10008
10039
  sourceId: toFixedHex(signed.sourceId, 32, "sourceId"),
10009
10040
  registryVersion: assertUint2(signed.registryVersion, U32_MAX2, "registryVersion"),
10010
10041
  signaturesRequired: assertUint2(signed.signaturesRequired, U8_MAX, "signaturesRequired"),
10011
- canonicalTimestamp: assertBigUint(signed.canonicalTimestamp, U64_MAX, "canonicalTimestamp")
10042
+ timestamp: assertBigUint(signed.timestamp, U64_MAX, "timestamp")
10012
10043
  };
10013
10044
  const signature = {
10014
10045
  signature: toFixedHex(sig.s, 32, "signature"),
@@ -10030,7 +10061,7 @@ function encodeEvmVerifyCalldata(args) {
10030
10061
  u256beFromBigInt(
10031
10062
  BigInt(assertUint2(payload.signaturesRequired, U8_MAX, "signaturesRequired"))
10032
10063
  ),
10033
- u256beFromBigInt(assertBigUint(payload.canonicalTimestamp, U64_MAX, "canonicalTimestamp")),
10064
+ u256beFromBigInt(assertBigUint(payload.timestamp, U64_MAX, "timestamp")),
10034
10065
  word2(signature.signature, 32, "signature"),
10035
10066
  word2(signature.commitment, 20, "commitment"),
10036
10067
  u256beFromBigInt(assertBigUint(signature.signersBitmap, U256_MAX, "signersBitmap")),
@@ -10160,7 +10191,7 @@ function buildStarknetVerifierArgs(attestation, options) {
10160
10191
  source_id: fixedHexToBigInt(signed.sourceId, 32, "sourceId"),
10161
10192
  registry_version: assertUint3(signed.registryVersion, U32_MAX3, "registryVersion"),
10162
10193
  signatures_required: assertUint3(signed.signaturesRequired, U8_MAX2, "signaturesRequired"),
10163
- canonical_timestamp: assertUint3(signed.canonicalTimestamp, U64_MAX2, "canonicalTimestamp")
10194
+ timestamp: assertUint3(signed.timestamp, U64_MAX2, "timestamp")
10164
10195
  };
10165
10196
  const signature = {
10166
10197
  signature: fixedHexToBigInt(sig.s, 32, "signature"),
@@ -10179,7 +10210,7 @@ function encodeStarknetVerifyCalldata(args) {
10179
10210
  ...u256Felts(payload.source_id, "source_id"),
10180
10211
  toFelt(assertUint3(payload.registry_version, U32_MAX3, "registry_version")),
10181
10212
  toFelt(assertUint3(payload.signatures_required, U8_MAX2, "signatures_required")),
10182
- toFelt(assertUint3(payload.canonical_timestamp, U64_MAX2, "canonical_timestamp")),
10213
+ toFelt(assertUint3(payload.timestamp, U64_MAX2, "timestamp")),
10183
10214
  ...u256Felts(signature.signature, "signature"),
10184
10215
  // An Ethereum-style address, so it must fit 160 bits (the verifier reports a wider one
10185
10216
  // as `MALFORMED`; one past the field prime would not even deserialize).
@@ -10246,6 +10277,6 @@ var MolphaSDK = class {
10246
10277
  }
10247
10278
  };
10248
10279
 
10249
- export { AggregationConfigError, DEFAULT_GATEWAY_ENDPOINT, EIP712_DOMAIN_TYPEHASH, GatewayError, INT256_MAX, INT256_MIN, MESSAGE_PREFIX, MIN_TOLERANCE_SIGNATURES, MOLPHA_IDL, MOLPHA_PROGRAM_ADDRESS, MOLPHA_PROGRAM_ID, MOLPHA_VERIFIER_ABI, MOLPHA_VERIFIER_ADDRESS, MOLPHA_VERIFIER_STARKNET_ADDRESSES, MOLPHA_VERIFIER_STARKNET_SEPOLIA, MolphaGateway, MolphaSDK, MolphaSolanaClient, PlanType, REQUEST_AUTH_DOMAIN, TRANSFER_WITH_AUTHORIZATION_TYPEHASH, UpstreamPaymentRequiredError, VERIFY_CODES, addressToBytes, assertAggregationQuorum, attestationMessageHash, attestationMessageHashFromAttestation, base64ToBytes, bigIntFromBytesBe, bitmapBitSet, bitmapToIndices, buildEvmVerifierArgs, buildStarknetVerifierArgs, buildSubmitAttestationArgs, bytesToBase64, bytesToHex, bytesToHex0x, canonicalizeAPIConfig, canonicalizeAggregation, commitmentAddressToStarknetFelt, computeCoalitionKey, concatBytes, createEvmSignerFromPrivateKey, decodeInt256, deriveGatewayPda, deriveGatewayPdaAddress, deriveGroupBitmap, deriveSelectionBitmap, deriveSelectionSeed, deriveSourceId, deriveSourceIdString, domainSeparator, effectiveSelectionSize, eligibleSetSize, encodeEvmVerifyCalldata, encodeInt256, encodeInt256Decimal, encodeRequestAuth, encodeStarknetVerifyCalldata, ensureLength, evmAddressFromPrivateKey, feedPda, formatInt256Decimal, gatewayPda, gatewaySignerFromWallet, getMolphaStarknetVerifierAddress, hashRequestAuth, hexToBytes, nodePda, normalizeEndpoint, normalizeSecp256k1PublicKeyHex, parseEvmVerifyResult, parseGatewayInfo, parseStarknetVerifyResult, parseUpstreamQuote, planIdFromVariant, planPda, planVariant, probeSource, protocolConfigPda, registryPda, registryStatePda, resolveRemainingAccounts, secp256k1PublicKeyFromCoordinates, selectedIndices, signSourcePayments, signerFromKeypair, signersBitmapToDecimal, signersBitmapToStarknetUint256, signersBitmapToUint256, subscriptionPda, toChecksumAddress, toFixedBytes, toFixedHex, transferWithAuthorizationDigest, transferWithAuthorizationHash, u256beFromBigInt, u32be, u32le, u64be, u64le, u8, utf8, validateSuppliedTerms, verifyCodeName };
10280
+ export { AggregationConfigError, DEFAULT_GATEWAY_ENDPOINT, EIP712_DOMAIN_TYPEHASH, GatewayError, INT256_MAX, INT256_MIN, MESSAGE_PREFIX, MIN_TOLERANCE_SIGNATURES, MOLPHA_IDL, MOLPHA_PROGRAM_ADDRESS, MOLPHA_PROGRAM_ID, MOLPHA_VERIFIER_ABI, MOLPHA_VERIFIER_ADDRESS, MOLPHA_VERIFIER_STARKNET_ADDRESSES, MOLPHA_VERIFIER_STARKNET_SEPOLIA, MolphaGateway, MolphaSDK, MolphaSolanaClient, PlanType, REQUEST_AUTH_DOMAIN, SELECTION_WINDOW_MS, TRANSFER_WITH_AUTHORIZATION_TYPEHASH, UpstreamPaymentRequiredError, VERIFY_CODES, addressToBytes, assertAggregationQuorum, attestationMessageHash, attestationMessageHashFromAttestation, base64ToBytes, bigIntFromBytesBe, bitmapBitSet, bitmapToIndices, buildEvmVerifierArgs, buildStarknetVerifierArgs, buildSubmitAttestationArgs, bytesToBase64, bytesToHex, bytesToHex0x, canonicalizeAPIConfig, canonicalizeAggregation, commitmentAddressToStarknetFelt, computeCoalitionKey, concatBytes, createEvmSignerFromPrivateKey, decodeInt256, deriveGatewayPda, deriveGatewayPdaAddress, deriveGroupBitmap, deriveSelectionBitmap, deriveSelectionSeed, deriveSourceId, deriveSourceIdString, domainSeparator, effectiveSelectionSize, eligibleSetSize, encodeEvmVerifyCalldata, encodeInt256, encodeInt256Decimal, encodeRequestAuth, encodeStarknetVerifyCalldata, ensureLength, evmAddressFromPrivateKey, feedPda, formatInt256Decimal, gatewayPda, gatewaySignerFromWallet, getMolphaStarknetVerifierAddress, hashRequestAuth, hexToBytes, msUntilNextTick, nodePda, normalizeEndpoint, normalizeSecp256k1PublicKeyHex, parseEvmVerifyResult, parseGatewayInfo, parseStarknetVerifyResult, parseUpstreamQuote, planIdFromVariant, planPda, planVariant, probeSource, protocolConfigPda, registryPda, registryStatePda, resolveRemainingAccounts, secp256k1PublicKeyFromCoordinates, selectedIndices, signSourcePayments, signerFromKeypair, signersBitmapToDecimal, signersBitmapToStarknetUint256, signersBitmapToUint256, subscriptionPda, timestampAgeSeconds, timestampSeconds, toChecksumAddress, toFixedBytes, toFixedHex, transferWithAuthorizationDigest, transferWithAuthorizationHash, u256beFromBigInt, u32be, u32le, u64be, u64le, u8, utf8, validateSuppliedTerms, verifyCodeName };
10250
10281
  //# sourceMappingURL=index.js.map
10251
10282
  //# sourceMappingURL=index.js.map