@zkp2p/sdk 0.10.0 → 0.11.0-rc.0

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,18 @@ 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
+ signatureRequired: false
412
+ };
413
+ }
398
414
  const sig = json?.responseObject?.signedIntent;
399
415
  const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
400
416
  const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
401
417
  const referralFees = json?.responseObject?.intentData?.referralFees ?? json?.responseObject?.referralFees;
402
- if (!sig || !expStr) throw new Error("v3/intent/sign missing signature or expiration");
418
+ if (!sig || !expStr) throw new Error("/v3/sign missing signature or expiration");
403
419
  return {
404
420
  signature: sig,
405
421
  signatureExpiration: BigInt(expStr),
@@ -817,7 +833,7 @@ async function sendTransactionWithAttribution(walletClient, request, referrer, o
817
833
  // src/utils/constants.ts
818
834
  var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
819
835
 
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
836
+ // ../../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
837
  var chainlink_default = {
822
838
  feeds: [
823
839
  {
@@ -1116,54 +1132,7 @@ function resolvePlatformAttestationConfig(platformName) {
1116
1132
  return config;
1117
1133
  }
1118
1134
 
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
1135
  // 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
1136
  var GENERIC_ZELLE_ATTESTATION_ACTION_TYPES = /* @__PURE__ */ new Set([
1168
1137
  "transfer_zelle_bofa",
1169
1138
  "transfer_zelle_chase",
@@ -1215,15 +1184,15 @@ var IntentOperations = class {
1215
1184
  escrowAddress: params.escrowAddress,
1216
1185
  depositId: params.depositId
1217
1186
  });
1187
+ const currentOrchestratorV3 = this.config.getOrchestratorV3Address();
1218
1188
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1219
- orchestratorAddress: params.orchestratorAddress,
1189
+ orchestratorAddress: params.orchestratorAddress ?? currentOrchestratorV3,
1220
1190
  escrowAddress: escrowContext.address
1221
1191
  });
1222
1192
  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()) {
1193
+ if (currentEscrow && escrowContext.address.toLowerCase() !== currentEscrow.toLowerCase() || !currentOrchestratorV3 || orchestratorContext.address.toLowerCase() !== currentOrchestratorV3.toLowerCase()) {
1225
1194
  throw new Error(
1226
- "signalIntent is only supported on the current EscrowV2 / OrchestratorV2 deployment"
1195
+ "signalIntent is only supported on the current EscrowV2 / OrchestratorV3 deployment"
1227
1196
  );
1228
1197
  }
1229
1198
  const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
@@ -1241,10 +1210,9 @@ var IntentOperations = class {
1241
1210
  let { gatingServiceSignature, signatureExpiration } = params;
1242
1211
  let preIntentHookData = params.preIntentHookData;
1243
1212
  const baseApiUrl = this.config.getBaseApiUrl();
1244
- if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl) {
1213
+ if ((gatingServiceSignature === void 0 || signatureExpiration === void 0) && baseApiUrl) {
1245
1214
  const apiOpts = {
1246
1215
  baseApiUrl,
1247
- apiKey: this.config.getApiKey(),
1248
1216
  timeoutMs: this.config.getApiTimeoutMs()
1249
1217
  };
1250
1218
  const response = await apiSignIntentV3(
@@ -1264,7 +1232,9 @@ var IntentOperations = class {
1264
1232
  referralFees: referralFees.map((referralFee) => ({
1265
1233
  recipient: referralFee.recipient,
1266
1234
  fee: referralFee.fee.toString()
1267
- }))
1235
+ })),
1236
+ postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
1237
+ data: params.data ?? "0x"
1268
1238
  },
1269
1239
  apiOpts
1270
1240
  );
@@ -1274,13 +1244,13 @@ var IntentOperations = class {
1274
1244
  if (response.referralFees !== void 0) {
1275
1245
  referralFees = response.referralFees.map((referralFee) => {
1276
1246
  if (!isValidReferrerFeeRecipient(referralFee.recipient)) {
1277
- throw new Error("v3/intent/sign returned invalid referral fee recipient");
1247
+ throw new Error("/v3/sign returned invalid referral fee recipient");
1278
1248
  }
1279
1249
  let fee;
1280
1250
  try {
1281
1251
  fee = BigInt(referralFee.fee);
1282
1252
  } catch {
1283
- throw new Error("v3/intent/sign returned non-integer referral fee value");
1253
+ throw new Error("/v3/sign returned non-integer referral fee value");
1284
1254
  }
1285
1255
  return {
1286
1256
  recipient: referralFee.recipient,
@@ -1289,7 +1259,7 @@ var IntentOperations = class {
1289
1259
  });
1290
1260
  }
1291
1261
  }
1292
- if (!gatingServiceSignature || !signatureExpiration) {
1262
+ if (gatingServiceSignature === void 0 || signatureExpiration === void 0) {
1293
1263
  throw new Error("Missing gatingServiceSignature/signatureExpiration");
1294
1264
  }
1295
1265
  const args = [
@@ -1517,7 +1487,6 @@ var IntentOperations = class {
1517
1487
  attestationRoute.actionType,
1518
1488
  { fallbackUrls: params.attestationServiceFallbackUrls }
1519
1489
  );
1520
- assertReleaseAmountMeetsMinimum(attestation, inputs.minimumReleaseAmount);
1521
1490
  paymentProof = encodePaymentAttestation(attestation);
1522
1491
  verificationData = encodeVerifyPaymentData({
1523
1492
  intentHash,
@@ -1568,19 +1537,13 @@ var IntentOperations = class {
1568
1537
  );
1569
1538
  const payee2 = matched?.verificationData?.payeeDetails;
1570
1539
  if (payee2) {
1571
- const minimumReleaseAmount2 = await this.resolveIntentMinimumReleaseAmount(
1572
- intentHash,
1573
- options?.orchestratorAddress,
1574
- view.deposit.deposit.intentAmountRange.min
1575
- );
1576
1540
  return {
1577
1541
  amount: view.intent.amount.toString(),
1578
1542
  fiatCurrency: view.intent.fiatCurrency,
1579
1543
  conversionRate: view.intent.conversionRate.toString(),
1580
1544
  payeeDetails: payee2,
1581
1545
  intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
1582
- paymentMethodHash: view.intent.paymentMethod,
1583
- ...minimumReleaseAmount2 ? { minimumReleaseAmount: minimumReleaseAmount2 } : {}
1546
+ paymentMethodHash: view.intent.paymentMethod
1584
1547
  };
1585
1548
  }
1586
1549
  }
@@ -1638,11 +1601,6 @@ var IntentOperations = class {
1638
1601
  }
1639
1602
  }
1640
1603
  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
1604
  return {
1647
1605
  amount: record.amount,
1648
1606
  fiatCurrency: record.fiatCurrency,
@@ -1650,59 +1608,10 @@ var IntentOperations = class {
1650
1608
  payeeDetails: payee,
1651
1609
  intentTimestampMs: (BigInt(record.signalTimestamp) * 1000n).toString(),
1652
1610
  paymentMethodHash: record.paymentMethodHash || "0x0000000000000000000000000000000000000000000000000000000000000000",
1653
- paymentVerifier: record.verifier || void 0,
1654
- ...minimumReleaseAmount ? { minimumReleaseAmount } : {}
1611
+ paymentVerifier: record.verifier || void 0
1655
1612
  };
1656
1613
  }
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
1614
  };
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
1615
  function isRecord(value) {
1707
1616
  return typeof value === "object" && value !== null && !Array.isArray(value);
1708
1617
  }
@@ -1969,7 +1878,7 @@ var ProtocolViewerReader = class {
1969
1878
  if (inputCount === null) {
1970
1879
  throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
1971
1880
  }
1972
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
1881
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
1973
1882
  if (inputCount >= 3) {
1974
1883
  return tryContexts(
1975
1884
  protocolViewerContexts,
@@ -1987,8 +1896,15 @@ var ProtocolViewerReader = class {
1987
1896
  );
1988
1897
  }
1989
1898
  if (inputCount >= 2) {
1899
+ const seenEscrows = /* @__PURE__ */ new Set();
1900
+ const uniqueEscrowContexts = protocolViewerContexts.filter((context) => {
1901
+ const key = context.escrow.toLowerCase();
1902
+ if (seenEscrows.has(key)) return false;
1903
+ seenEscrows.add(key);
1904
+ return true;
1905
+ });
1990
1906
  return tryContexts(
1991
- protocolViewerContexts,
1907
+ uniqueEscrowContexts,
1992
1908
  async (context) => {
1993
1909
  const raw = await this.config.getPublicClient().readContract({
1994
1910
  address,
@@ -2048,7 +1964,7 @@ var ProtocolViewerReader = class {
2048
1964
  return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
2049
1965
  }
2050
1966
  const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
2051
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
1967
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2052
1968
  if (inputCount >= 2) {
2053
1969
  const requests = ids.map((id, index) => ({
2054
1970
  index,
@@ -2153,7 +2069,7 @@ var ProtocolViewerReader = class {
2153
2069
  if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
2154
2070
  return this.config.host.getPvAccountDepositsFromIndexer(owner);
2155
2071
  }
2156
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
2072
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2157
2073
  const { address, abi } = this.config.host.requireProtocolViewer();
2158
2074
  if (inputCount >= 2) {
2159
2075
  const readAndFilter = async (raw2) => {
@@ -2224,7 +2140,7 @@ var ProtocolViewerReader = class {
2224
2140
  if (protocolViewerEntries.length === 0) {
2225
2141
  throw new Error("ProtocolViewer not available for this network");
2226
2142
  }
2227
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
2143
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2228
2144
  const intentsByHash = /* @__PURE__ */ new Map();
2229
2145
  let attemptedRead = false;
2230
2146
  let hadSuccessfulRead = false;
@@ -2332,7 +2248,7 @@ var ProtocolViewerReader = class {
2332
2248
  if (protocolViewerEntries.length === 0) {
2333
2249
  throw new Error("ProtocolViewer not available for this network");
2334
2250
  }
2335
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-QMHI74AA.mjs');
2251
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-ZZKVAPPA.mjs');
2336
2252
  let lastError;
2337
2253
  for (const pvEntry of protocolViewerEntries) {
2338
2254
  const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
@@ -3742,6 +3658,44 @@ function isSchemaCompatibilityError(error) {
3742
3658
  return message.includes("cannot query field") || message.includes("does not exist") || message.includes("not found in type");
3743
3659
  }
3744
3660
 
3661
+ // src/utils/logger.ts
3662
+ var currentLevel = "info";
3663
+ function setLogLevel(level) {
3664
+ currentLevel = level;
3665
+ }
3666
+ function shouldLog(level) {
3667
+ switch (currentLevel) {
3668
+ case "debug":
3669
+ return true;
3670
+ case "info":
3671
+ return level !== "debug";
3672
+ case "error":
3673
+ return level === "error";
3674
+ default:
3675
+ return true;
3676
+ }
3677
+ }
3678
+ var logger = {
3679
+ debug: (...args) => {
3680
+ if (shouldLog("debug")) {
3681
+ console.log("[DEBUG]", ...args);
3682
+ }
3683
+ },
3684
+ info: (...args) => {
3685
+ if (shouldLog("info")) {
3686
+ console.log("[INFO]", ...args);
3687
+ }
3688
+ },
3689
+ warn: (...args) => {
3690
+ if (shouldLog("info")) {
3691
+ console.warn("[WARN]", ...args);
3692
+ }
3693
+ },
3694
+ error: (...args) => {
3695
+ console.error("[ERROR]", ...args);
3696
+ }
3697
+ };
3698
+
3745
3699
  // src/indexer/service.ts
3746
3700
  function groupByDepositId(items) {
3747
3701
  const map = /* @__PURE__ */ new Map();
@@ -4190,8 +4144,7 @@ function createHeaders(apiKey, authorizationToken) {
4190
4144
  function withApiBase(baseApiUrl) {
4191
4145
  const trimmed = (baseApiUrl || "").trim();
4192
4146
  let base2 = trimmed.replace(/\/+$/, "");
4193
- base2 = base2.replace(/\/v1$/i, "");
4194
- base2 = base2.replace(/\/v2$/i, "");
4147
+ base2 = base2.replace(/\/v[123]$/i, "");
4195
4148
  return base2;
4196
4149
  }
4197
4150
  async function apiFetch({
@@ -4396,7 +4349,7 @@ async function apiPostDepositDetails(req, baseApiUrl, timeoutMs) {
4396
4349
  timeoutMs
4397
4350
  });
4398
4351
  }
4399
- async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey) {
4352
+ async function apiGetQuote(req, baseApiUrl, timeoutMs) {
4400
4353
  if (req.quotesToReturn !== void 0) {
4401
4354
  if (!Number.isInteger(req.quotesToReturn) || req.quotesToReturn < 1) {
4402
4355
  throw new ValidationError("quotesToReturn must be a positive integer", "quotesToReturn");
@@ -4416,7 +4369,7 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey) {
4416
4369
  }
4417
4370
  const isExactFiat = req.isExactFiat !== false;
4418
4371
  const endpoint = isExactFiat ? "exact-fiat" : "exact-token";
4419
- let url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
4372
+ let url = `${withApiBase(baseApiUrl)}/v3/quote/${endpoint}`;
4420
4373
  if (req.quotesToReturn) url += `?quotesToReturn=${req.quotesToReturn}`;
4421
4374
  const requestBody = {
4422
4375
  ...req,
@@ -4424,27 +4377,28 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey) {
4424
4377
  amount: void 0,
4425
4378
  isExactFiat: void 0,
4426
4379
  quotesToReturn: void 0,
4427
- includePrivateOrderbooks: req.includePrivateOrderbooks
4380
+ referrerFeeConfig: void 0,
4381
+ referralFees: req.referralFees ?? (req.referrerFeeConfig ? [req.referrerFeeConfig] : void 0)
4428
4382
  };
4429
4383
  Object.keys(requestBody).forEach((k) => requestBody[k] === void 0 && delete requestBody[k]);
4430
4384
  return apiFetch({
4431
4385
  url,
4432
4386
  method: "POST",
4433
4387
  body: requestBody,
4434
- apiKey,
4435
4388
  timeoutMs
4436
4389
  });
4437
4390
  }
4438
- async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey) {
4391
+ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs) {
4439
4392
  const isExactFiat = req.isExactFiat !== false;
4440
4393
  const endpoint = isExactFiat ? "best-by-platform" : "best-by-platform-exact-token";
4441
- const url = `${withApiBase(baseApiUrl)}/v2/quote/${endpoint}`;
4394
+ const url = `${withApiBase(baseApiUrl)}/v3/quote/${endpoint}`;
4442
4395
  const requestBody = {
4443
4396
  ...req,
4444
4397
  [isExactFiat ? "exactFiatAmount" : "exactTokenAmount"]: String(req.amount),
4445
4398
  amount: void 0,
4446
4399
  isExactFiat: void 0,
4447
- referrerFeeConfig: void 0
4400
+ referrerFeeConfig: void 0,
4401
+ referralFees: req.referralFees ?? (req.referrerFeeConfig ? [req.referrerFeeConfig] : void 0)
4448
4402
  };
4449
4403
  Object.keys(requestBody).forEach(
4450
4404
  (key) => requestBody[key] === void 0 && delete requestBody[key]
@@ -4453,7 +4407,6 @@ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey) {
4453
4407
  url,
4454
4408
  method: "POST",
4455
4409
  body: requestBody,
4456
- apiKey,
4457
4410
  timeoutMs
4458
4411
  });
4459
4412
  return {
@@ -4526,19 +4479,6 @@ async function apiGetOwnerDeposits(req, apiKey, baseApiUrl, authToken, timeoutMs
4526
4479
  statusCode: 200
4527
4480
  };
4528
4481
  }
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
4482
  async function apiGetReferralDashboard(opts) {
4543
4483
  const address = opts.address ? normalizeReferralAddress(opts.address, "address") : void 0;
4544
4484
  const endpoint = address ? `/v2/referral?${new URLSearchParams({ address }).toString()}` : "/v2/referral";
@@ -4693,7 +4633,7 @@ async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs) {
4693
4633
  query.set(key, String(value));
4694
4634
  });
4695
4635
  const response = await apiFetch({
4696
- url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook?${query.toString()}`,
4636
+ url: `${withApiBase(opts.baseApiUrl)}/v3/orderbook?${query.toString()}`,
4697
4637
  method: "GET",
4698
4638
  timeoutMs: opts.timeoutMs
4699
4639
  });
@@ -4715,7 +4655,7 @@ async function apiGetOrderbookTable(params, optsOrBaseApiUrl, timeoutMs) {
4715
4655
  query.set(key, String(value));
4716
4656
  });
4717
4657
  const response = await apiFetch({
4718
- url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook/table?${query.toString()}`,
4658
+ url: `${withApiBase(opts.baseApiUrl)}/v3/orderbook/table?${query.toString()}`,
4719
4659
  method: "GET",
4720
4660
  timeoutMs: opts.timeoutMs
4721
4661
  });
@@ -6273,9 +6213,14 @@ var applyReferrerFeeDisplayFieldsToTokenAmount = (tokenAmount, referrerFeeConfig
6273
6213
  };
6274
6214
  var applyReferrerFeeDisplayFieldsToQuote = (quote, referrerFeeConfig, decimals) => {
6275
6215
  const enrichedQuote = quote;
6276
- const hasCuratorReferrerFeeFields = enrichedQuote.referrerFeeAmount != null || enrichedQuote.referrerFeeBps != null;
6216
+ const hasCuratorReferrerFeeFields = enrichedQuote.referrerFeeAmount != null || enrichedQuote.referrerFeeBps != null || quote.takerReferralFeeAmount != null || quote.takerReferralFeeBps != null;
6277
6217
  if (hasCuratorReferrerFeeFields) {
6278
- return enrichedQuote;
6218
+ return {
6219
+ ...enrichedQuote,
6220
+ referrerFeeAmount: enrichedQuote.referrerFeeAmount ?? quote.takerReferralFeeAmount,
6221
+ referrerFeeAmountFormatted: enrichedQuote.referrerFeeAmountFormatted ?? quote.takerReferralFeeAmountFormatted,
6222
+ referrerFeeBps: enrichedQuote.referrerFeeBps ?? quote.takerReferralFeeBps
6223
+ };
6279
6224
  }
6280
6225
  const signalIntentAmount = quote.signalIntentAmount ?? quote.intent?.amount ?? quote.tokenAmount;
6281
6226
  const adjusted = applyReferrerFeeDisplayFieldsToTokenAmount(
@@ -7097,7 +7042,8 @@ var Zkp2pClient = class {
7097
7042
  * sending fiat payment to the deposit's payee.
7098
7043
  *
7099
7044
  * If `gatingServiceSignature` is not provided, the SDK will automatically
7100
- * fetch one from curator `/v3/intent/sign` when `baseApiUrl` is configured.
7045
+ * fetch one from curator `/v3/sign` when `baseApiUrl` is configured. Deposits
7046
+ * using zero-address gating are signaled directly with an empty signature.
7101
7047
  * Otherwise you must provide `gatingServiceSignature` and `signatureExpiration`
7102
7048
  * yourself.
7103
7049
  *
@@ -7405,6 +7351,8 @@ var Zkp2pClient = class {
7405
7351
  this.escrowV2Abi = abis.escrowV2 ?? abis.escrow;
7406
7352
  this.orchestratorV2Address = toAddress(addresses.orchestratorV2 ?? addresses.orchestrator);
7407
7353
  this.orchestratorV2Abi = abis.orchestratorV2 ?? abis.orchestrator;
7354
+ this.orchestratorV3Address = toAddress(addresses.orchestratorV3);
7355
+ this.orchestratorV3Abi = abis.orchestratorV3;
7408
7356
  const configuredEscrowAddresses = (addresses.escrowAddresses ?? []).map((value) => toAddress(value)).filter((value) => Boolean(value));
7409
7357
  const configuredOrchestratorAddresses = (addresses.orchestratorAddresses ?? []).map((value) => toAddress(value)).filter((value) => Boolean(value));
7410
7358
  this.escrowAddresses = uniqAddresses([
@@ -7418,6 +7366,7 @@ var Zkp2pClient = class {
7418
7366
  }
7419
7367
  this.orchestratorAddresses = uniqAddresses([
7420
7368
  this.orchestratorV2Address ?? toAddress(addresses.orchestrator),
7369
+ this.orchestratorV3Address,
7421
7370
  ...configuredOrchestratorAddresses
7422
7371
  ]);
7423
7372
  this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
@@ -7476,6 +7425,8 @@ var Zkp2pClient = class {
7476
7425
  orchestratorAbi: this.orchestratorAbi,
7477
7426
  orchestratorV2Address: this.orchestratorV2Address,
7478
7427
  orchestratorV2Abi: this.orchestratorV2Abi,
7428
+ orchestratorV3Address: this.orchestratorV3Address,
7429
+ orchestratorV3Abi: this.orchestratorV3Abi,
7479
7430
  orchestratorAddresses: this.orchestratorAddresses
7480
7431
  });
7481
7432
  if (addresses.usdc) this._usdcAddress = addresses.usdc;
@@ -7550,6 +7501,7 @@ var Zkp2pClient = class {
7550
7501
  getIndexerService: () => this._indexerService,
7551
7502
  getEscrowV2Address: () => this.escrowV2Address,
7552
7503
  getOrchestratorV2Address: () => this.orchestratorV2Address,
7504
+ getOrchestratorV3Address: () => this.orchestratorV3Address,
7553
7505
  host: {
7554
7506
  resolveEscrowContext: (options) => this.resolveEscrowContext(options),
7555
7507
  resolveOrchestratorContext: (options) => this.resolveOrchestratorContext(options),
@@ -8863,7 +8815,7 @@ var Zkp2pClient = class {
8863
8815
  reqWithEscrow.escrowAddresses = configuredEscrows;
8864
8816
  }
8865
8817
  }
8866
- const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs, this.apiKey);
8818
+ const quote = await apiGetQuote(reqWithEscrow, baseApiUrl, timeoutMs);
8867
8819
  const quotes = (quote?.responseObject?.quotes ?? []).filter(isActiveQuotePaymentMethod);
8868
8820
  quote.responseObject.quotes = quotes;
8869
8821
  if (quote.responseObject.nearbySuggestions) {
@@ -8911,12 +8863,7 @@ var Zkp2pClient = class {
8911
8863
  reqWithEscrow.escrowAddresses = configuredEscrows;
8912
8864
  }
8913
8865
  }
8914
- const quote = await apiGetQuotesBestByPlatform(
8915
- reqWithEscrow,
8916
- baseApiUrl,
8917
- timeoutMs,
8918
- this.apiKey
8919
- );
8866
+ const quote = await apiGetQuotesBestByPlatform(reqWithEscrow, baseApiUrl, timeoutMs);
8920
8867
  const enrichedQuote = quote ? {
8921
8868
  ...quote,
8922
8869
  responseObject: {
@@ -8938,27 +8885,6 @@ var Zkp2pClient = class {
8938
8885
  } : quote;
8939
8886
  return appendReferrerFeeDisplayFieldsToBestByPlatform(enrichedQuote, referrerFeeConfig);
8940
8887
  }
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
8888
  /**
8963
8889
  * Fetch a referral dashboard. Pass `address` for a public wallet-keyed read;
8964
8890
  * omit it to use the authenticated caller mode.
@@ -9276,6 +9202,7 @@ var Zkp2pClient = class {
9276
9202
  escrowAddresses: this.escrowAddresses,
9277
9203
  orchestrator: this.orchestratorAddress,
9278
9204
  orchestratorV2: this.orchestratorV2Address,
9205
+ orchestratorV3: this.orchestratorV3Address,
9279
9206
  orchestratorAddresses: this.orchestratorAddresses,
9280
9207
  protocolViewer: this.protocolViewerAddress,
9281
9208
  protocolViewerEntries: this._protocolViewerEntries.map((e) => e.address),
@@ -9512,6 +9439,6 @@ var planAccessPolicyUpdate = (persistedInput, draftInput) => {
9512
9439
  };
9513
9440
  };
9514
9441
 
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 };
9442
+ 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
9443
  //# sourceMappingURL=index.mjs.map
9517
9444
  //# sourceMappingURL=index.mjs.map