@zkp2p/sdk 0.10.0 → 0.11.0-rc.1

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.mjs CHANGED
@@ -1,9 +1,9 @@
1
- import { IntentGuardianOperations } from './chunk-WXEP544Y.mjs';
2
- export { TAKER_TIER_CAPS, TAKER_TIER_FEE_DISCOUNT_BPS, TAKER_TIER_ORDER, TAKER_TIER_SCHEDULE, ZERO_RATE_MANAGER_ID, classifyDelegationState, classifyIntentGuardianError, getDelegationRoute, getNextTakerTier, getTakerTierFeeDiscountBps, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-WXEP544Y.mjs';
1
+ import { IntentGuardianOperations } from './chunk-FCOH36IX.mjs';
2
+ export { ZERO_RATE_MANAGER_ID, classifyDelegationState, classifyIntentGuardianError, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-FCOH36IX.mjs';
3
3
  import { ValidationError, APIError, NetworkError } from './chunk-GHQK65J2.mjs';
4
4
  export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
5
- import { METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-JRLUSPR3.mjs';
6
- export { PAYMENT_PLATFORMS, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getIntentGuardianContract, getPaymentMethodsCatalog, getRateManagerContracts, hasIntentGuardian, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-JRLUSPR3.mjs';
5
+ import { METHOD_NAME_TO_HASH, matchesQuotePaymentMethod, matchesPaymentMethodNameAndHash, getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, SUPPORTED_PAYMENT_METHOD_HASHES, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-BRIDD433.mjs';
6
+ export { PAYMENT_PLATFORMS, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getIntentGuardianContract, getPaymentMethodsCatalog, getRateManagerContracts, hasIntentGuardian, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-BRIDD433.mjs';
7
7
  import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
8
8
  export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
9
9
  import './chunk-J5LGTIGS.mjs';
@@ -154,6 +154,8 @@ var ContractRouter = class {
154
154
  this.orchestratorAbi = config.orchestratorAbi;
155
155
  this.orchestratorV2Address = config.orchestratorV2Address;
156
156
  this.orchestratorV2Abi = config.orchestratorV2Abi;
157
+ this.orchestratorV3Address = config.orchestratorV3Address;
158
+ this.orchestratorV3Abi = config.orchestratorV3Abi;
157
159
  this.orchestratorAddresses = config.orchestratorAddresses;
158
160
  this._registerContexts();
159
161
  }
@@ -184,24 +186,26 @@ var ContractRouter = class {
184
186
  for (let index = 0; index < configuredPairCount; index += 1) {
185
187
  addEscrowOrchestratorPair(this.escrowAddresses[index], this.orchestratorAddresses[index]);
186
188
  }
187
- const resolveOrchestratorAbi = (address) => this.getOrchestratorContextByAddress(address)?.abi ?? (isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi);
189
+ const resolveOrchestratorAbi = (address) => this.getOrchestratorContextByAddress(address)?.abi ?? (isSameAddress(address, this.orchestratorV3Address) ? this.orchestratorV3Abi : isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi);
188
190
  const uniqueOrchestratorAddresses = /* @__PURE__ */ new Set();
189
191
  for (const address of [
190
192
  primaryOrchestratorAddress,
191
193
  this.orchestratorAddress,
192
194
  this.orchestratorV2Address,
195
+ this.orchestratorV3Address,
193
196
  ...this.orchestratorAddresses
194
197
  ]) {
195
198
  if (!address) continue;
196
199
  const key = address.toLowerCase();
197
200
  if (uniqueOrchestratorAddresses.has(key)) continue;
198
201
  uniqueOrchestratorAddresses.add(key);
199
- const abi = isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi;
202
+ const isV3 = isSameAddress(address, this.orchestratorV3Address);
203
+ const abi = isV3 ? this.orchestratorV3Abi : isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi;
200
204
  if (!abi) continue;
201
205
  registerOrchestrator({
202
206
  address,
203
207
  abi,
204
- version: "v2"
208
+ version: isV3 ? "v3" : "v2"
205
209
  });
206
210
  }
207
211
  const uniqueEscrowAddresses = /* @__PURE__ */ new Set();
@@ -320,6 +324,9 @@ var ContractRouter = class {
320
324
  context.address,
321
325
  context.orchestratorAddress ?? this.resolveOrchestratorForEscrow(context.address)?.address
322
326
  );
327
+ for (const orchestratorAddress of this.orchestratorAddresses) {
328
+ add(context.address, orchestratorAddress);
329
+ }
323
330
  }
324
331
  return contexts;
325
332
  }
@@ -367,24 +374,26 @@ async function withRetry(fn, maxRetries = 3, delayMs = 1e3, timeoutMs) {
367
374
 
368
375
  // src/adapters/verification.ts
369
376
  async function apiSignIntentV3(request, opts) {
370
- const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent/sign`;
377
+ const baseApiUrl = opts.baseApiUrl.replace(/\/+$/, "").replace(/\/v[123]$/i, "");
378
+ const url = `${baseApiUrl}/v3/sign`;
371
379
  const json = await withRetry(
372
380
  async () => {
373
381
  let res;
374
382
  try {
375
- const headers2 = { "Content-Type": "application/json" };
376
- if (opts.apiKey) headers2["x-api-key"] = opts.apiKey;
377
383
  res = await fetch(url, {
378
384
  method: "POST",
379
- headers: headers2,
385
+ headers: { "Content-Type": "application/json" },
380
386
  body: JSON.stringify(request)
381
387
  });
382
388
  } catch (error) {
383
389
  throw new NetworkError("Failed to connect to API server", {
384
- endpoint: "/v3/intent/sign",
390
+ endpoint: "/v3/sign",
385
391
  error
386
392
  });
387
393
  }
394
+ if (res.status === 409) {
395
+ return null;
396
+ }
388
397
  if (!res.ok) {
389
398
  const text = await res.text().catch(() => "");
390
399
  throw parseAPIError(res, text);
@@ -395,11 +404,17 @@ async function apiSignIntentV3(request, opts) {
395
404
  1e3,
396
405
  opts.timeoutMs
397
406
  );
407
+ if (json === null) {
408
+ return {
409
+ signature: "0x",
410
+ signatureExpiration: 0n
411
+ };
412
+ }
398
413
  const sig = json?.responseObject?.signedIntent;
399
414
  const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
400
415
  const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
401
416
  const referralFees = json?.responseObject?.intentData?.referralFees ?? json?.responseObject?.referralFees;
402
- if (!sig || !expStr) throw new Error("v3/intent/sign missing signature or expiration");
417
+ if (!sig || !expStr) throw new Error("/v3/sign missing signature or expiration");
403
418
  return {
404
419
  signature: sig,
405
420
  signatureExpiration: BigInt(expStr),
@@ -817,7 +832,7 @@ async function sendTransactionWithAttribution(walletClient, request, referrer, o
817
832
  // src/utils/constants.ts
818
833
  var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
819
834
 
820
- // ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.0-rc.0_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.2.1/node_modules/@zkp2p/contracts-v2/oracleFeeds/chainlink.json
835
+ // ../../node_modules/.pnpm/@zkp2p+contracts-v2@0.4.0-rc.5_ethers@6.16.0_bufferutil@4.1.0_utf-8-validate@5.0.10__typescript@5.9.3_zod@4.2.1/node_modules/@zkp2p/contracts-v2/oracleFeeds/chainlink.json
821
836
  var chainlink_default = {
822
837
  feeds: [
823
838
  {
@@ -1116,54 +1131,7 @@ function resolvePlatformAttestationConfig(platformName) {
1116
1131
  return config;
1117
1132
  }
1118
1133
 
1119
- // src/utils/logger.ts
1120
- var currentLevel = "info";
1121
- function setLogLevel(level) {
1122
- currentLevel = level;
1123
- }
1124
- function shouldLog(level) {
1125
- switch (currentLevel) {
1126
- case "debug":
1127
- return true;
1128
- case "info":
1129
- return level !== "debug";
1130
- case "error":
1131
- return level === "error";
1132
- default:
1133
- return true;
1134
- }
1135
- }
1136
- var logger = {
1137
- debug: (...args) => {
1138
- if (shouldLog("debug")) {
1139
- console.log("[DEBUG]", ...args);
1140
- }
1141
- },
1142
- info: (...args) => {
1143
- if (shouldLog("info")) {
1144
- console.log("[INFO]", ...args);
1145
- }
1146
- },
1147
- warn: (...args) => {
1148
- if (shouldLog("info")) {
1149
- console.warn("[WARN]", ...args);
1150
- }
1151
- },
1152
- error: (...args) => {
1153
- console.error("[ERROR]", ...args);
1154
- }
1155
- };
1156
-
1157
1134
  // src/client/IntentOperations.ts
1158
- var INTENT_MIN_AT_SIGNAL_ABI = [
1159
- {
1160
- type: "function",
1161
- name: "getIntentMinAtSignal",
1162
- stateMutability: "view",
1163
- inputs: [{ name: "_intentHash", type: "bytes32" }],
1164
- outputs: [{ name: "", type: "uint256" }]
1165
- }
1166
- ];
1167
1135
  var GENERIC_ZELLE_ATTESTATION_ACTION_TYPES = /* @__PURE__ */ new Set([
1168
1136
  "transfer_zelle_bofa",
1169
1137
  "transfer_zelle_chase",
@@ -1215,15 +1183,15 @@ var IntentOperations = class {
1215
1183
  escrowAddress: params.escrowAddress,
1216
1184
  depositId: params.depositId
1217
1185
  });
1186
+ const currentOrchestratorV3 = this.config.getOrchestratorV3Address();
1218
1187
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1219
- orchestratorAddress: params.orchestratorAddress,
1188
+ orchestratorAddress: params.orchestratorAddress ?? currentOrchestratorV3,
1220
1189
  escrowAddress: escrowContext.address
1221
1190
  });
1222
1191
  const currentEscrow = this.config.getEscrowV2Address();
1223
- const currentOrchestrator = this.config.getOrchestratorV2Address();
1224
- if (currentEscrow && escrowContext.address.toLowerCase() !== currentEscrow.toLowerCase() || currentOrchestrator && orchestratorContext.address.toLowerCase() !== currentOrchestrator.toLowerCase()) {
1192
+ if (currentEscrow && escrowContext.address.toLowerCase() !== currentEscrow.toLowerCase() || !currentOrchestratorV3 || orchestratorContext.address.toLowerCase() !== currentOrchestratorV3.toLowerCase()) {
1225
1193
  throw new Error(
1226
- "signalIntent is only supported on the current EscrowV2 / OrchestratorV2 deployment"
1194
+ "signalIntent is only supported on the current EscrowV2 / OrchestratorV3 deployment"
1227
1195
  );
1228
1196
  }
1229
1197
  const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
@@ -1241,10 +1209,9 @@ var IntentOperations = class {
1241
1209
  let { gatingServiceSignature, signatureExpiration } = params;
1242
1210
  let preIntentHookData = params.preIntentHookData;
1243
1211
  const baseApiUrl = this.config.getBaseApiUrl();
1244
- if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl) {
1212
+ if ((gatingServiceSignature === void 0 || signatureExpiration === void 0) && baseApiUrl) {
1245
1213
  const apiOpts = {
1246
1214
  baseApiUrl,
1247
- apiKey: this.config.getApiKey(),
1248
1215
  timeoutMs: this.config.getApiTimeoutMs()
1249
1216
  };
1250
1217
  const response = await apiSignIntentV3(
@@ -1264,7 +1231,9 @@ var IntentOperations = class {
1264
1231
  referralFees: referralFees.map((referralFee) => ({
1265
1232
  recipient: referralFee.recipient,
1266
1233
  fee: referralFee.fee.toString()
1267
- }))
1234
+ })),
1235
+ postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
1236
+ data: params.data ?? "0x"
1268
1237
  },
1269
1238
  apiOpts
1270
1239
  );
@@ -1274,13 +1243,13 @@ var IntentOperations = class {
1274
1243
  if (response.referralFees !== void 0) {
1275
1244
  referralFees = response.referralFees.map((referralFee) => {
1276
1245
  if (!isValidReferrerFeeRecipient(referralFee.recipient)) {
1277
- throw new Error("v3/intent/sign returned invalid referral fee recipient");
1246
+ throw new Error("/v3/sign returned invalid referral fee recipient");
1278
1247
  }
1279
1248
  let fee;
1280
1249
  try {
1281
1250
  fee = BigInt(referralFee.fee);
1282
1251
  } catch {
1283
- throw new Error("v3/intent/sign returned non-integer referral fee value");
1252
+ throw new Error("/v3/sign returned non-integer referral fee value");
1284
1253
  }
1285
1254
  return {
1286
1255
  recipient: referralFee.recipient,
@@ -1289,7 +1258,7 @@ var IntentOperations = class {
1289
1258
  });
1290
1259
  }
1291
1260
  }
1292
- if (!gatingServiceSignature || !signatureExpiration) {
1261
+ if (gatingServiceSignature === void 0 || signatureExpiration === void 0) {
1293
1262
  throw new Error("Missing gatingServiceSignature/signatureExpiration");
1294
1263
  }
1295
1264
  const args = [
@@ -1517,7 +1486,6 @@ var IntentOperations = class {
1517
1486
  attestationRoute.actionType,
1518
1487
  { fallbackUrls: params.attestationServiceFallbackUrls }
1519
1488
  );
1520
- assertReleaseAmountMeetsMinimum(attestation, inputs.minimumReleaseAmount);
1521
1489
  paymentProof = encodePaymentAttestation(attestation);
1522
1490
  verificationData = encodeVerifyPaymentData({
1523
1491
  intentHash,
@@ -1568,19 +1536,13 @@ var IntentOperations = class {
1568
1536
  );
1569
1537
  const payee2 = matched?.verificationData?.payeeDetails;
1570
1538
  if (payee2) {
1571
- const minimumReleaseAmount2 = await this.resolveIntentMinimumReleaseAmount(
1572
- intentHash,
1573
- options?.orchestratorAddress,
1574
- view.deposit.deposit.intentAmountRange.min
1575
- );
1576
1539
  return {
1577
1540
  amount: view.intent.amount.toString(),
1578
1541
  fiatCurrency: view.intent.fiatCurrency,
1579
1542
  conversionRate: view.intent.conversionRate.toString(),
1580
1543
  payeeDetails: payee2,
1581
1544
  intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
1582
- paymentMethodHash: view.intent.paymentMethod,
1583
- ...minimumReleaseAmount2 ? { minimumReleaseAmount: minimumReleaseAmount2 } : {}
1545
+ paymentMethodHash: view.intent.paymentMethod
1584
1546
  };
1585
1547
  }
1586
1548
  }
@@ -1638,11 +1600,6 @@ var IntentOperations = class {
1638
1600
  }
1639
1601
  }
1640
1602
  if (!payee) throw new Error("Payee details not found for intent");
1641
- const minimumReleaseAmount = await this.resolveIntentMinimumReleaseAmount(
1642
- intentHash,
1643
- options?.orchestratorAddress,
1644
- deposit.intentAmountMin
1645
- );
1646
1603
  return {
1647
1604
  amount: record.amount,
1648
1605
  fiatCurrency: record.fiatCurrency,
@@ -1650,59 +1607,10 @@ var IntentOperations = class {
1650
1607
  payeeDetails: payee,
1651
1608
  intentTimestampMs: (BigInt(record.signalTimestamp) * 1000n).toString(),
1652
1609
  paymentMethodHash: record.paymentMethodHash || "0x0000000000000000000000000000000000000000000000000000000000000000",
1653
- paymentVerifier: record.verifier || void 0,
1654
- ...minimumReleaseAmount ? { minimumReleaseAmount } : {}
1610
+ paymentVerifier: record.verifier || void 0
1655
1611
  };
1656
1612
  }
1657
- async resolveIntentMinimumReleaseAmount(intentHash, orchestratorAddress, fallbackMinimum) {
1658
- const snapshotMinimum = await this.readIntentMinAtSignal(intentHash, orchestratorAddress);
1659
- if (snapshotMinimum && snapshotMinimum !== "0") {
1660
- return snapshotMinimum;
1661
- }
1662
- if (fallbackMinimum === void 0 || fallbackMinimum === null) {
1663
- return snapshotMinimum;
1664
- }
1665
- return BigInt(fallbackMinimum).toString();
1666
- }
1667
- async readIntentMinAtSignal(intentHash, orchestratorAddress) {
1668
- const address = orchestratorAddress ?? this.config.getOrchestratorV2Address();
1669
- if (!address) return void 0;
1670
- const read = async () => this.config.getPublicClient().readContract({
1671
- address,
1672
- abi: INTENT_MIN_AT_SIGNAL_ABI,
1673
- functionName: "getIntentMinAtSignal",
1674
- args: [intentHash]
1675
- });
1676
- try {
1677
- return (await read()).toString();
1678
- } catch (error) {
1679
- logger.warn(
1680
- `[sdk] getIntentMinAtSignal read failed for ${intentHash}; retrying once`,
1681
- error instanceof Error ? error.message : error
1682
- );
1683
- try {
1684
- return (await read()).toString();
1685
- } catch {
1686
- return void 0;
1687
- }
1688
- }
1689
- }
1690
1613
  };
1691
- function assertReleaseAmountMeetsMinimum(attestation, minimumReleaseAmount) {
1692
- if (!minimumReleaseAmount) return;
1693
- const minimum = BigInt(minimumReleaseAmount);
1694
- if (minimum === 0n) return;
1695
- const releaseAmount = BigInt(attestation.responseObject.typedDataValue.releaseAmount);
1696
- if (releaseAmount >= minimum) return;
1697
- throw new ValidationError(
1698
- `Payment amount is below the minimum required for this intent. Release amount ${releaseAmount.toString()} is below minimum ${minimum.toString()}.`,
1699
- "releaseAmount",
1700
- {
1701
- releaseAmount: releaseAmount.toString(),
1702
- minimumReleaseAmount: minimum.toString()
1703
- }
1704
- );
1705
- }
1706
1614
  function isRecord(value) {
1707
1615
  return typeof value === "object" && value !== null && !Array.isArray(value);
1708
1616
  }
@@ -1969,7 +1877,7 @@ var ProtocolViewerReader = class {
1969
1877
  if (inputCount === null) {
1970
1878
  throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
1971
1879
  }
1972
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
1880
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
1973
1881
  if (inputCount >= 3) {
1974
1882
  return tryContexts(
1975
1883
  protocolViewerContexts,
@@ -1987,8 +1895,15 @@ var ProtocolViewerReader = class {
1987
1895
  );
1988
1896
  }
1989
1897
  if (inputCount >= 2) {
1898
+ const seenEscrows = /* @__PURE__ */ new Set();
1899
+ const uniqueEscrowContexts = protocolViewerContexts.filter((context) => {
1900
+ const key = context.escrow.toLowerCase();
1901
+ if (seenEscrows.has(key)) return false;
1902
+ seenEscrows.add(key);
1903
+ return true;
1904
+ });
1990
1905
  return tryContexts(
1991
- protocolViewerContexts,
1906
+ uniqueEscrowContexts,
1992
1907
  async (context) => {
1993
1908
  const raw = await this.config.getPublicClient().readContract({
1994
1909
  address,
@@ -2048,7 +1963,7 @@ var ProtocolViewerReader = class {
2048
1963
  return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
2049
1964
  }
2050
1965
  const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
2051
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
1966
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2052
1967
  if (inputCount >= 2) {
2053
1968
  const requests = ids.map((id, index) => ({
2054
1969
  index,
@@ -2153,7 +2068,7 @@ var ProtocolViewerReader = class {
2153
2068
  if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
2154
2069
  return this.config.host.getPvAccountDepositsFromIndexer(owner);
2155
2070
  }
2156
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
2071
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2157
2072
  const { address, abi } = this.config.host.requireProtocolViewer();
2158
2073
  if (inputCount >= 2) {
2159
2074
  const readAndFilter = async (raw2) => {
@@ -2224,7 +2139,7 @@ var ProtocolViewerReader = class {
2224
2139
  if (protocolViewerEntries.length === 0) {
2225
2140
  throw new Error("ProtocolViewer not available for this network");
2226
2141
  }
2227
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
2142
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2228
2143
  const intentsByHash = /* @__PURE__ */ new Map();
2229
2144
  let attemptedRead = false;
2230
2145
  let hadSuccessfulRead = false;
@@ -2332,7 +2247,7 @@ var ProtocolViewerReader = class {
2332
2247
  if (protocolViewerEntries.length === 0) {
2333
2248
  throw new Error("ProtocolViewer not available for this network");
2334
2249
  }
2335
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
2250
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2336
2251
  let lastError;
2337
2252
  for (const pvEntry of protocolViewerEntries) {
2338
2253
  const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
@@ -3742,6 +3657,44 @@ function isSchemaCompatibilityError(error) {
3742
3657
  return message.includes("cannot query field") || message.includes("does not exist") || message.includes("not found in type");
3743
3658
  }
3744
3659
 
3660
+ // src/utils/logger.ts
3661
+ var currentLevel = "info";
3662
+ function setLogLevel(level) {
3663
+ currentLevel = level;
3664
+ }
3665
+ function shouldLog(level) {
3666
+ switch (currentLevel) {
3667
+ case "debug":
3668
+ return true;
3669
+ case "info":
3670
+ return level !== "debug";
3671
+ case "error":
3672
+ return level === "error";
3673
+ default:
3674
+ return true;
3675
+ }
3676
+ }
3677
+ var logger = {
3678
+ debug: (...args) => {
3679
+ if (shouldLog("debug")) {
3680
+ console.log("[DEBUG]", ...args);
3681
+ }
3682
+ },
3683
+ info: (...args) => {
3684
+ if (shouldLog("info")) {
3685
+ console.log("[INFO]", ...args);
3686
+ }
3687
+ },
3688
+ warn: (...args) => {
3689
+ if (shouldLog("info")) {
3690
+ console.warn("[WARN]", ...args);
3691
+ }
3692
+ },
3693
+ error: (...args) => {
3694
+ console.error("[ERROR]", ...args);
3695
+ }
3696
+ };
3697
+
3745
3698
  // src/indexer/service.ts
3746
3699
  function groupByDepositId(items) {
3747
3700
  const map = /* @__PURE__ */ new Map();
@@ -4190,8 +4143,7 @@ function createHeaders(apiKey, authorizationToken) {
4190
4143
  function withApiBase(baseApiUrl) {
4191
4144
  const trimmed = (baseApiUrl || "").trim();
4192
4145
  let base2 = trimmed.replace(/\/+$/, "");
4193
- base2 = base2.replace(/\/v1$/i, "");
4194
- base2 = base2.replace(/\/v2$/i, "");
4146
+ base2 = base2.replace(/\/v[123]$/i, "");
4195
4147
  return base2;
4196
4148
  }
4197
4149
  async function apiFetch({
@@ -4396,7 +4348,7 @@ async function apiPostDepositDetails(req, baseApiUrl, timeoutMs) {
4396
4348
  timeoutMs
4397
4349
  });
4398
4350
  }
4399
- async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey) {
4351
+ async function apiGetQuote(req, baseApiUrl, timeoutMs) {
4400
4352
  if (req.quotesToReturn !== void 0) {
4401
4353
  if (!Number.isInteger(req.quotesToReturn) || req.quotesToReturn < 1) {
4402
4354
  throw new ValidationError("quotesToReturn must be a positive integer", "quotesToReturn");
@@ -4416,7 +4368,7 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey) {
4416
4368
  }
4417
4369
  const isExactFiat = req.isExactFiat !== false;
4418
4370
  const endpoint = isExactFiat ? "exact-fiat" : "exact-token";
4419
- let url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
4371
+ let url = `${withApiBase(baseApiUrl)}/v3/quote/${endpoint}`;
4420
4372
  if (req.quotesToReturn) url += `?quotesToReturn=${req.quotesToReturn}`;
4421
4373
  const requestBody = {
4422
4374
  ...req,
@@ -4424,27 +4376,28 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey) {
4424
4376
  amount: void 0,
4425
4377
  isExactFiat: void 0,
4426
4378
  quotesToReturn: void 0,
4427
- includePrivateOrderbooks: req.includePrivateOrderbooks
4379
+ referrerFeeConfig: void 0,
4380
+ referralFees: req.referralFees ?? (req.referrerFeeConfig ? [req.referrerFeeConfig] : void 0)
4428
4381
  };
4429
4382
  Object.keys(requestBody).forEach((k) => requestBody[k] === void 0 && delete requestBody[k]);
4430
4383
  return apiFetch({
4431
4384
  url,
4432
4385
  method: "POST",
4433
4386
  body: requestBody,
4434
- apiKey,
4435
4387
  timeoutMs
4436
4388
  });
4437
4389
  }
4438
- async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey) {
4390
+ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs) {
4439
4391
  const isExactFiat = req.isExactFiat !== false;
4440
4392
  const endpoint = isExactFiat ? "best-by-platform" : "best-by-platform-exact-token";
4441
- const url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
4393
+ const url = `${withApiBase(baseApiUrl)}/v3/quote/${endpoint}`;
4442
4394
  const requestBody = {
4443
4395
  ...req,
4444
4396
  [isExactFiat ? "exactFiatAmount" : "exactTokenAmount"]: String(req.amount),
4445
4397
  amount: void 0,
4446
4398
  isExactFiat: void 0,
4447
- referrerFeeConfig: void 0
4399
+ referrerFeeConfig: void 0,
4400
+ referralFees: req.referralFees ?? (req.referrerFeeConfig ? [req.referrerFeeConfig] : void 0)
4448
4401
  };
4449
4402
  Object.keys(requestBody).forEach(
4450
4403
  (key) => requestBody[key] === void 0 && delete requestBody[key]
@@ -4453,7 +4406,6 @@ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey) {
4453
4406
  url,
4454
4407
  method: "POST",
4455
4408
  body: requestBody,
4456
- apiKey,
4457
4409
  timeoutMs
4458
4410
  });
4459
4411
  return {
@@ -4526,19 +4478,6 @@ async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs
4526
4478
  statusCode: 200
4527
4479
  };
4528
4480
  }
4529
- async function apiGetTakerTier(req, baseApiUrl, timeoutMs) {
4530
- const normalizedOwner = req.owner.toLowerCase();
4531
- const query = new URLSearchParams({
4532
- owner: normalizedOwner,
4533
- chainId: String(req.chainId)
4534
- });
4535
- const endpoint = `/v2/taker/tier?${query.toString()}`;
4536
- return apiFetch({
4537
- url: `${withApiBase(baseApiUrl)}${endpoint}`,
4538
- method: "GET",
4539
- timeoutMs
4540
- });
4541
- }
4542
4481
  async function apiGetReferralDashboard(opts) {
4543
4482
  const address = opts.address ? normalizeReferralAddress(opts.address, "address") : void 0;
4544
4483
  const endpoint = address ? `/v2/referral?${new URLSearchParams({ address }).toString()}` : "/v2/referral";
@@ -4693,7 +4632,7 @@ async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs) {
4693
4632
  query.set(key, String(value));
4694
4633
  });
4695
4634
  const response = await apiFetch({
4696
- url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook?${query.toString()}`,
4635
+ url: `${withApiBase(opts.baseApiUrl)}/v3/orderbook?${query.toString()}`,
4697
4636
  method: "GET",
4698
4637
  timeoutMs: opts.timeoutMs
4699
4638
  });
@@ -4715,7 +4654,7 @@ async function apiGetOrderbookTable(params, optsOrBaseApiUrl, timeoutMs) {
4715
4654
  query.set(key, String(value));
4716
4655
  });
4717
4656
  const response = await apiFetch({
4718
- url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook/table?${query.toString()}`,
4657
+ url: `${withApiBase(opts.baseApiUrl)}/v3/orderbook/table?${query.toString()}`,
4719
4658
  method: "GET",
4720
4659
  timeoutMs: opts.timeoutMs
4721
4660
  });
@@ -6273,9 +6212,14 @@ var applyReferrerFeeDisplayFieldsToTokenAmount = (tokenAmount, referrerFeeConfig
6273
6212
  };
6274
6213
  var applyReferrerFeeDisplayFieldsToQuote = (quote, referrerFeeConfig, decimals) => {
6275
6214
  const enrichedQuote = quote;
6276
- const hasCuratorReferrerFeeFields = enrichedQuote.referrerFeeAmount != null || enrichedQuote.referrerFeeBps != null;
6215
+ const hasCuratorReferrerFeeFields = enrichedQuote.referrerFeeAmount != null || enrichedQuote.referrerFeeBps != null || quote.takerReferralFeeAmount != null || quote.takerReferralFeeBps != null;
6277
6216
  if (hasCuratorReferrerFeeFields) {
6278
- return enrichedQuote;
6217
+ return {
6218
+ ...enrichedQuote,
6219
+ referrerFeeAmount: enrichedQuote.referrerFeeAmount ?? quote.takerReferralFeeAmount,
6220
+ referrerFeeAmountFormatted: enrichedQuote.referrerFeeAmountFormatted ?? quote.takerReferralFeeAmountFormatted,
6221
+ referrerFeeBps: enrichedQuote.referrerFeeBps ?? quote.takerReferralFeeBps
6222
+ };
6279
6223
  }
6280
6224
  const signalIntentAmount = quote.signalIntentAmount ?? quote.intent?.amount ?? quote.tokenAmount;
6281
6225
  const adjusted = applyReferrerFeeDisplayFieldsToTokenAmount(
@@ -7097,7 +7041,8 @@ var Zkp2pClient = class {
7097
7041
  * sending fiat payment to the deposit's payee.
7098
7042
  *
7099
7043
  * If `gatingServiceSignature` is not provided, the SDK will automatically
7100
- * fetch one from curator `/v3/intent/sign` when `baseApiUrl` is configured.
7044
+ * fetch one from curator `/v3/sign` when `baseApiUrl` is configured. Deposits
7045
+ * using zero-address gating are signaled directly with an empty signature.
7101
7046
  * Otherwise you must provide `gatingServiceSignature` and `signatureExpiration`
7102
7047
  * yourself.
7103
7048
  *
@@ -7405,6 +7350,8 @@ var Zkp2pClient = class {
7405
7350
  this.escrowV2Abi = abis.escrowV2 ?? abis.escrow;
7406
7351
  this.orchestratorV2Address = toAddress(addresses.orchestratorV2 ?? addresses.orchestrator);
7407
7352
  this.orchestratorV2Abi = abis.orchestratorV2 ?? abis.orchestrator;
7353
+ this.orchestratorV3Address = toAddress(addresses.orchestratorV3);
7354
+ this.orchestratorV3Abi = abis.orchestratorV3;
7408
7355
  const configuredEscrowAddresses = (addresses.escrowAddresses ?? []).map((value) => toAddress(value)).filter((value) => Boolean(value));
7409
7356
  const configuredOrchestratorAddresses = (addresses.orchestratorAddresses ?? []).map((value) => toAddress(value)).filter((value) => Boolean(value));
7410
7357
  this.escrowAddresses = uniqAddresses([
@@ -7418,6 +7365,7 @@ var Zkp2pClient = class {
7418
7365
  }
7419
7366
  this.orchestratorAddresses = uniqAddresses([
7420
7367
  this.orchestratorV2Address ?? toAddress(addresses.orchestrator),
7368
+ this.orchestratorV3Address,
7421
7369
  ...configuredOrchestratorAddresses
7422
7370
  ]);
7423
7371
  this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
@@ -7476,6 +7424,8 @@ var Zkp2pClient = class {
7476
7424
  orchestratorAbi: this.orchestratorAbi,
7477
7425
  orchestratorV2Address: this.orchestratorV2Address,
7478
7426
  orchestratorV2Abi: this.orchestratorV2Abi,
7427
+ orchestratorV3Address: this.orchestratorV3Address,
7428
+ orchestratorV3Abi: this.orchestratorV3Abi,
7479
7429
  orchestratorAddresses: this.orchestratorAddresses
7480
7430
  });
7481
7431
  if (addresses.usdc) this._usdcAddress = addresses.usdc;
@@ -7550,6 +7500,7 @@ var Zkp2pClient = class {
7550
7500
  getIndexerService: () => this._indexerService,
7551
7501
  getEscrowV2Address: () => this.escrowV2Address,
7552
7502
  getOrchestratorV2Address: () => this.orchestratorV2Address,
7503
+ getOrchestratorV3Address: () => this.orchestratorV3Address,
7553
7504
  host: {
7554
7505
  resolveEscrowContext: (options) => this.resolveEscrowContext(options),
7555
7506
  resolveOrchestratorContext: (options) => this.resolveOrchestratorContext(options),
@@ -8863,7 +8814,7 @@ var Zkp2pClient = class {
8863
8814
  reqWithEscrow.escrowAddresses = configuredEscrows;
8864
8815
  }
8865
8816
  }
8866
- const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs, this.apiKey);
8817
+ const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs);
8867
8818
  const quotes = (quote?.responseObject?.quotes ?? []).filter(isActiveQuotePaymentMethod);
8868
8819
  quote.responseObject.quotes = quotes;
8869
8820
  if (quote.responseObject.nearbySuggestions) {
@@ -8911,12 +8862,7 @@ var Zkp2pClient = class {
8911
8862
  reqWithEscrow.escrowAddresses = configuredEscrows;
8912
8863
  }
8913
8864
  }
8914
- const quote = await apiGetQuotesBestByPlatform(
8915
- reqWithEscrow,
8916
- baseApiUrl,
8917
- timeoutMs,
8918
- this.apiKey
8919
- );
8865
+ const quote = await apiGetQuotesBestByPlatform(reqWithEscrow, baseApiUrl, timeoutMs);
8920
8866
  const enrichedQuote = quote ? {
8921
8867
  ...quote,
8922
8868
  responseObject: {
@@ -8938,27 +8884,6 @@ var Zkp2pClient = class {
8938
8884
  } : quote;
8939
8885
  return appendReferrerFeeDisplayFieldsToBestByPlatform(enrichedQuote, referrerFeeConfig);
8940
8886
  }
8941
- // ───────────────────────────────────────────────────────────────────────────
8942
- // SUPPORTING: TAKER TIER
8943
- // (Used by frontends to display taker limits)
8944
- // ───────────────────────────────────────────────────────────────────────────
8945
- /**
8946
- * **Supporting Method** - Fetches taker tier information for an address.
8947
- *
8948
- * @param req - Taker tier request parameters
8949
- * @param req.owner - Taker address
8950
- * @param req.chainId - Chain ID
8951
- * @param opts - Optional overrides for API URL and timeout
8952
- * @returns Taker tier response
8953
- */
8954
- async getTakerTier(req, opts) {
8955
- const baseApiUrl = (opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL).replace(
8956
- /\/$/,
8957
- ""
8958
- );
8959
- const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
8960
- return apiGetTakerTier(req, baseApiUrl, timeoutMs);
8961
- }
8962
8887
  /**
8963
8888
  * Fetch a referral dashboard. Pass `address` for a public wallet-keyed read;
8964
8889
  * omit it to use the authenticated caller mode.
@@ -9276,6 +9201,7 @@ var Zkp2pClient = class {
9276
9201
  escrowAddresses: this.escrowAddresses,
9277
9202
  orchestrator: this.orchestratorAddress,
9278
9203
  orchestratorV2: this.orchestratorV2Address,
9204
+ orchestratorV3: this.orchestratorV3Address,
9279
9205
  orchestratorAddresses: this.orchestratorAddresses,
9280
9206
  protocolViewer: this.protocolViewerAddress,
9281
9207
  protocolViewerEntries: this._protocolViewerEntries.map((e) => e.address),
@@ -9512,6 +9438,6 @@ var planAccessPolicyUpdate = (persistedInput, draftInput) => {
9512
9438
  };
9513
9439
  };
9514
9440
 
9515
- export { AccessPolicyOperations, AccessPolicyUnsupportedError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, MAX_ADDRESSES_PER_CALL, MAX_GROUPS_PER_DEPOSIT, MAX_WHITELISTED_ADDRESSES, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, REFERRAL_SIGNATURE_DOMAIN, REFERRAL_SIGNATURE_TYPES, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiCreateReferralCode, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOrderbookTable, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetReferralDashboard, apiGetReferralEarnings, apiGetTakerTier, apiLookupReferralCode, apiPostDepositDetails, apiRedeemReferralCode, apiRequestIdentityAttestation, apiUpdateReferralCode, apiUploadGoogleOAuthSellerCredential, apiUploadSellerCredentialBundle, apiValidatePayeeDetails, apiVerifyBuyerTeePayment, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, diffAccessPolicy, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferralCode, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, normalizeAccessPolicyState, normalizeReferralCode, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, planAccessPolicyUpdate, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
9441
+ export { AccessPolicyOperations, AccessPolicyUnsupportedError, BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, MAX_ADDRESSES_PER_CALL, MAX_GROUPS_PER_DEPOSIT, MAX_WHITELISTED_ADDRESSES, Zkp2pClient as OfframpClient, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, REFERRAL_SIGNATURE_DOMAIN, REFERRAL_SIGNATURE_TYPES, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiCreateReferralCode, apiCreateSellerCredentialBundle, apiGetDepositBundle, apiGetOrderbook, apiGetOrderbookTable, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetReferralDashboard, apiGetReferralEarnings, apiLookupReferralCode, apiPostDepositDetails, apiRedeemReferralCode, apiRequestIdentityAttestation, apiUpdateReferralCode, apiUploadGoogleOAuthSellerCredential, apiUploadSellerCredentialBundle, apiValidatePayeeDetails, apiVerifyBuyerTeePayment, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createEncryptedBuyerTeeSessionMaterial, createPeerExtensionSdk, defaultIndexerEndpoint, diffAccessPolicy, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferralCode, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, normalizeAccessPolicyState, normalizeReferralCode, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, planAccessPolicyUpdate, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
9516
9442
  //# sourceMappingURL=index.mjs.map
9517
9443
  //# sourceMappingURL=index.mjs.map