@zkp2p/sdk 0.3.0 → 0.3.2-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,8 +1,8 @@
1
1
  export { ZERO_RATE_MANAGER_ID, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-LPJE2MN7.mjs';
2
2
  import { ValidationError, NetworkError, APIError } from './chunk-GHQK65J2.mjs';
3
3
  export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
4
- import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-AXX3QCRW.mjs';
5
- export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-AXX3QCRW.mjs';
4
+ import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-ENH4KRFK.mjs';
5
+ export { asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-ENH4KRFK.mjs';
6
6
  import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
7
7
  export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
8
8
  import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, formatUnits } from 'viem';
@@ -367,7 +367,7 @@ function createHeaders(apiKey, authorizationToken) {
367
367
  return headers2;
368
368
  }
369
369
  async function apiSignIntentV3(request, opts) {
370
- const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent`;
370
+ const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent/sign`;
371
371
  const json = await withRetry(
372
372
  async () => {
373
373
  let res;
@@ -379,7 +379,7 @@ async function apiSignIntentV3(request, opts) {
379
379
  });
380
380
  } catch (error) {
381
381
  throw new NetworkError("Failed to connect to API server", {
382
- endpoint: "/v3/intent",
382
+ endpoint: "/v3/intent/sign",
383
383
  error
384
384
  });
385
385
  }
@@ -397,7 +397,7 @@ async function apiSignIntentV3(request, opts) {
397
397
  const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
398
398
  const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
399
399
  const referralFees = json?.responseObject?.intentData?.referralFees ?? json?.responseObject?.referralFees;
400
- if (!sig || !expStr) throw new Error("v3/intent missing signature or expiration");
400
+ if (!sig || !expStr) throw new Error("v3/intent/sign missing signature or expiration");
401
401
  return {
402
402
  signature: sig,
403
403
  signatureExpiration: BigInt(expStr),
@@ -433,6 +433,34 @@ async function apiCreatePaymentAttestation(payload, attestationServiceUrl, platf
433
433
  return res.json();
434
434
  });
435
435
  }
436
+ async function apiCreateSellerCredentialBundle(payload, attestationServiceUrl, platform, timeoutMs) {
437
+ return withRetry(
438
+ async () => {
439
+ let res;
440
+ try {
441
+ const endpoint = `/seller/credentials/${encodeURIComponent(platform)}`;
442
+ res = await fetch(`${attestationServiceUrl}${endpoint}`, {
443
+ method: "POST",
444
+ headers: headers(),
445
+ body: JSON.stringify(payload)
446
+ });
447
+ } catch (error) {
448
+ throw new NetworkError("Failed to connect to Attestation Service", {
449
+ endpoint: `/seller/credentials/${platform}`,
450
+ error
451
+ });
452
+ }
453
+ if (!res.ok) {
454
+ const errorText = await res.text();
455
+ throw parseAPIError(res, errorText);
456
+ }
457
+ return res.json();
458
+ },
459
+ 3,
460
+ 1e3,
461
+ timeoutMs
462
+ );
463
+ }
436
464
  var abiCoder = AbiCoder.defaultAbiCoder();
437
465
  function encodeVerifyPaymentData(params) {
438
466
  return abiCoder.encode(
@@ -571,6 +599,9 @@ var PAYMENT_PLATFORMS = [
571
599
  "luxon",
572
600
  "n26"
573
601
  ];
602
+
603
+ // src/utils/constants.ts
604
+ var DEFAULT_BASE_API_URL = "https://api.zkp2p.xyz";
574
605
  var ZERO_ADDRESS2 = "0x0000000000000000000000000000000000000000";
575
606
  var CHAINLINK_ORACLE_ADAPTER = "0xfc81d1b5841e697973af3072fc8e03af76cb39ef";
576
607
  var PYTH_ORACLE_ADAPTER = "0xaa2bBDa3072bD37af76613846268Ec48bd0bB885";
@@ -815,6 +846,13 @@ var IntentOperations = class {
815
846
  orchestratorAddress: params.orchestratorAddress,
816
847
  escrowAddress: escrowContext.address
817
848
  });
849
+ const currentEscrow = this.config.getEscrowV2Address();
850
+ const currentOrchestrator = this.config.getOrchestratorV2Address();
851
+ if (currentEscrow && escrowContext.address.toLowerCase() !== currentEscrow.toLowerCase() || currentOrchestrator && orchestratorContext.address.toLowerCase() !== currentOrchestrator.toLowerCase()) {
852
+ throw new Error(
853
+ "signalIntent is only supported on the current EscrowV2 / OrchestratorV2 deployment"
854
+ );
855
+ }
818
856
  const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
819
857
  const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
820
858
  const fiatCurrency = resolveFiatCurrencyBytes32(params.fiatCurrencyCode);
@@ -866,13 +904,13 @@ var IntentOperations = class {
866
904
  if (response.referralFees !== void 0) {
867
905
  referralFees = response.referralFees.map((referralFee) => {
868
906
  if (!isValidReferrerFeeRecipient(referralFee.recipient)) {
869
- throw new Error("v3/intent returned invalid referral fee recipient");
907
+ throw new Error("v3/intent/sign returned invalid referral fee recipient");
870
908
  }
871
909
  let fee;
872
910
  try {
873
911
  fee = BigInt(referralFee.fee);
874
912
  } catch {
875
- throw new Error("v3/intent returned non-integer referral fee value");
913
+ throw new Error("v3/intent/sign returned non-integer referral fee value");
876
914
  }
877
915
  return {
878
916
  recipient: referralFee.recipient,
@@ -1457,7 +1495,7 @@ var ProtocolViewerReader = class {
1457
1495
  if (inputCount === null) {
1458
1496
  throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
1459
1497
  }
1460
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1498
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZQZ6QGEX.mjs');
1461
1499
  if (inputCount >= 3) {
1462
1500
  return tryContexts(
1463
1501
  protocolViewerContexts,
@@ -1536,7 +1574,7 @@ var ProtocolViewerReader = class {
1536
1574
  return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
1537
1575
  }
1538
1576
  const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
1539
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1577
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZQZ6QGEX.mjs');
1540
1578
  if (inputCount >= 2) {
1541
1579
  const requests = ids.map((id, index) => ({
1542
1580
  index,
@@ -1641,7 +1679,7 @@ var ProtocolViewerReader = class {
1641
1679
  if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
1642
1680
  return this.config.host.getPvAccountDepositsFromIndexer(owner);
1643
1681
  }
1644
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1682
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-ZQZ6QGEX.mjs');
1645
1683
  const { address, abi } = this.config.host.requireProtocolViewer();
1646
1684
  if (inputCount >= 2) {
1647
1685
  const readAndFilter = async (raw2) => {
@@ -1712,7 +1750,7 @@ var ProtocolViewerReader = class {
1712
1750
  if (protocolViewerEntries.length === 0) {
1713
1751
  throw new Error("ProtocolViewer not available for this network");
1714
1752
  }
1715
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1753
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-ZQZ6QGEX.mjs');
1716
1754
  const intentsByHash = /* @__PURE__ */ new Map();
1717
1755
  let attemptedRead = false;
1718
1756
  let hadSuccessfulRead = false;
@@ -1820,7 +1858,7 @@ var ProtocolViewerReader = class {
1820
1858
  if (protocolViewerEntries.length === 0) {
1821
1859
  throw new Error("ProtocolViewer not available for this network");
1822
1860
  }
1823
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1861
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-ZQZ6QGEX.mjs');
1824
1862
  let lastError;
1825
1863
  for (const pvEntry of protocolViewerEntries) {
1826
1864
  const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
@@ -4842,7 +4880,7 @@ function convertIndexerDepositToLegacyApiDeposit(deposit) {
4842
4880
  }
4843
4881
  async function apiPostDepositDetails(req, baseApiUrl, timeoutMs, _apiKey, _authToken) {
4844
4882
  return apiFetch({
4845
- url: `${withApiBase(baseApiUrl)}/v1/makers/create`,
4883
+ url: `${withApiBase(baseApiUrl)}/v2/makers/create`,
4846
4884
  method: "POST",
4847
4885
  body: req,
4848
4886
  timeoutMs
@@ -4875,7 +4913,8 @@ async function apiGetQuote(req, baseApiUrl, timeoutMs, apiKey, authToken) {
4875
4913
  [isExactFiat ? "exactFiatAmount" : "exactTokenAmount"]: String(req.amount),
4876
4914
  amount: void 0,
4877
4915
  isExactFiat: void 0,
4878
- quotesToReturn: void 0
4916
+ quotesToReturn: void 0,
4917
+ includePrivateOrderbooks: req.includePrivateOrderbooks
4879
4918
  };
4880
4919
  Object.keys(requestBody).forEach((k) => requestBody[k] === void 0 && delete requestBody[k]);
4881
4920
  return apiFetch({
@@ -4912,7 +4951,7 @@ async function apiGetQuotesBestByPlatform(req, baseApiUrl, timeoutMs, apiKey, au
4912
4951
  }
4913
4952
  async function apiGetPayeeDetails(req, apiKey, baseApiUrl, authToken, timeoutMs) {
4914
4953
  return apiFetch({
4915
- url: `${baseApiUrl.replace(/\/$/, "")}/v1/makers/${req.processorName}/${req.hashedOnchainId}`,
4954
+ url: `${baseApiUrl.replace(/\/$/, "")}/v2/makers/${req.processorName}/${req.hashedOnchainId}`,
4916
4955
  method: "GET",
4917
4956
  apiKey,
4918
4957
  authToken,
@@ -4921,7 +4960,7 @@ async function apiGetPayeeDetails(req, apiKey, baseApiUrl, authToken, timeoutMs)
4921
4960
  }
4922
4961
  async function apiValidatePayeeDetails(req, baseApiUrl, timeoutMs) {
4923
4962
  const data = await apiFetch({
4924
- url: `${baseApiUrl.replace(/\/$/, "")}/v1/makers/validate`,
4963
+ url: `${baseApiUrl.replace(/\/$/, "")}/v2/makers/validate`,
4925
4964
  method: "POST",
4926
4965
  body: req,
4927
4966
  timeoutMs
@@ -4979,6 +5018,78 @@ async function apiGetTakerTier(req, apiKey, baseApiUrl, timeoutMs) {
4979
5018
  timeoutMs
4980
5019
  });
4981
5020
  }
5021
+ async function apiUploadSellerCredential(makerId, bundle, baseApiUrl, timeoutMs, apiKey, authToken) {
5022
+ return apiFetch({
5023
+ url: `${withApiBase(baseApiUrl)}/v2/makers/${makerId}/seller-credential`,
5024
+ method: "POST",
5025
+ body: bundle,
5026
+ apiKey,
5027
+ authToken,
5028
+ timeoutMs
5029
+ });
5030
+ }
5031
+ async function apiGetSellerCredentialStatus(makerId, baseApiUrl, timeoutMs, apiKey, authToken) {
5032
+ return apiFetch({
5033
+ url: `${withApiBase(baseApiUrl)}/v2/makers/${makerId}/seller-credential/status`,
5034
+ method: "GET",
5035
+ apiKey,
5036
+ authToken,
5037
+ timeoutMs
5038
+ });
5039
+ }
5040
+ async function apiVerifySellerPayment(platform, req, baseApiUrl, timeoutMs, apiKey, authToken) {
5041
+ return apiFetch({
5042
+ url: `${withApiBase(baseApiUrl)}/v2/verify/seller/${encodeURIComponent(platform)}`,
5043
+ method: "POST",
5044
+ body: req,
5045
+ apiKey,
5046
+ authToken,
5047
+ timeoutMs
5048
+ });
5049
+ }
5050
+ async function apiGetOrderbook(params, optsOrBaseApiUrl, timeoutMs, apiKey) {
5051
+ const opts = typeof optsOrBaseApiUrl === "string" ? {
5052
+ baseApiUrl: optsOrBaseApiUrl,
5053
+ timeoutMs,
5054
+ apiKey
5055
+ } : optsOrBaseApiUrl;
5056
+ const query = new URLSearchParams();
5057
+ Object.entries(params).forEach(([key, value]) => {
5058
+ if (value === void 0 || value === null) return;
5059
+ query.set(key, String(value));
5060
+ });
5061
+ const response = await apiFetch({
5062
+ url: `${withApiBase(opts.baseApiUrl)}/v2/orderbook?${query.toString()}`,
5063
+ method: "GET",
5064
+ apiKey: opts.apiKey,
5065
+ authToken: opts.authToken,
5066
+ timeoutMs: opts.timeoutMs
5067
+ });
5068
+ return response.responseObject;
5069
+ }
5070
+ async function apiGetDepositBundle(params, optsOrBaseApiUrl, timeoutMs, apiKey) {
5071
+ const opts = typeof optsOrBaseApiUrl === "string" ? {
5072
+ baseApiUrl: optsOrBaseApiUrl,
5073
+ timeoutMs,
5074
+ apiKey
5075
+ } : optsOrBaseApiUrl;
5076
+ const escrowAddress = requireEscrowAddress(
5077
+ params.escrowAddress,
5078
+ "apiGetDepositBundle requires escrowAddress"
5079
+ );
5080
+ const query = new URLSearchParams({ escrowAddress });
5081
+ if (params.dailySnapshotLimit !== void 0) {
5082
+ query.set("dailySnapshotLimit", String(params.dailySnapshotLimit));
5083
+ }
5084
+ const response = await apiFetch({
5085
+ url: `${withApiBase(opts.baseApiUrl)}/v2/deposits/${params.depositId}/bundle?${query.toString()}`,
5086
+ method: "GET",
5087
+ apiKey: opts.apiKey,
5088
+ authToken: opts.authToken,
5089
+ timeoutMs: opts.timeoutMs
5090
+ });
5091
+ return response.responseObject;
5092
+ }
4982
5093
  var formatTokenAmountForDisplay = (amount, decimals) => {
4983
5094
  const formatted = formatUnits(amount, decimals);
4984
5095
  if (!formatted.includes(".")) {
@@ -5115,6 +5226,95 @@ var ERC20_ABI = [
5115
5226
  ];
5116
5227
 
5117
5228
  // src/client/Zkp2pClient.ts
5229
+ function isStringRecord(value) {
5230
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
5231
+ return false;
5232
+ }
5233
+ return Object.values(value).every((entry) => typeof entry === "string");
5234
+ }
5235
+ function normalizeTelegramUsername(value) {
5236
+ if (typeof value !== "string") {
5237
+ return value === null ? null : null;
5238
+ }
5239
+ const normalized = value.trim();
5240
+ return normalized.length > 0 ? normalized : null;
5241
+ }
5242
+ function extractLegacyQuotePayeeData(depositData) {
5243
+ if (!depositData || typeof depositData !== "object" || Array.isArray(depositData)) {
5244
+ return void 0;
5245
+ }
5246
+ const stringEntries = Object.entries(depositData).filter(
5247
+ (entry) => typeof entry[1] === "string" && entry[1].trim().length > 0
5248
+ );
5249
+ const telegramUsername = stringEntries.find(([key]) => key === "telegramUsername")?.[1] ?? null;
5250
+ const identifierEntries = stringEntries.filter(([key]) => key !== "telegramUsername");
5251
+ const [primaryEntry, ...metadataEntries] = identifierEntries;
5252
+ if (!primaryEntry) {
5253
+ return void 0;
5254
+ }
5255
+ return {
5256
+ offchainId: primaryEntry[1],
5257
+ telegramUsername,
5258
+ metadata: metadataEntries.length > 0 ? Object.fromEntries(metadataEntries) : null
5259
+ };
5260
+ }
5261
+ function normalizeQuotePayeeData(maker) {
5262
+ const legacy = extractLegacyQuotePayeeData(maker?.depositData);
5263
+ const offchainId = typeof maker?.offchainId === "string" && maker.offchainId.trim().length > 0 ? maker.offchainId : legacy?.offchainId;
5264
+ if (!offchainId) {
5265
+ return void 0;
5266
+ }
5267
+ return {
5268
+ offchainId,
5269
+ telegramUsername: normalizeTelegramUsername(maker?.telegramUsername) ?? legacy?.telegramUsername ?? null,
5270
+ metadata: isStringRecord(maker?.metadata) ? maker.metadata : legacy?.metadata ?? null
5271
+ };
5272
+ }
5273
+ function normalizePayeeDataInputItem(raw) {
5274
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
5275
+ return null;
5276
+ }
5277
+ const candidate = raw;
5278
+ if (typeof candidate.offchainId === "string" && candidate.offchainId.trim().length > 0) {
5279
+ return candidate;
5280
+ }
5281
+ const legacy = extractLegacyQuotePayeeData(raw);
5282
+ if (!legacy) {
5283
+ return null;
5284
+ }
5285
+ return {
5286
+ offchainId: legacy.offchainId,
5287
+ telegramUsername: legacy.telegramUsername,
5288
+ metadata: legacy.metadata
5289
+ };
5290
+ }
5291
+ function resolvePayeeDataInput(params, methodName) {
5292
+ const payeeData = params.payeeData ?? params.depositData;
5293
+ if (!Array.isArray(payeeData)) {
5294
+ throw new Error(`${methodName} requires payeeData`);
5295
+ }
5296
+ const normalized = payeeData.map((item, index) => {
5297
+ const result = normalizePayeeDataInputItem(item);
5298
+ if (!result) {
5299
+ throw new Error(
5300
+ `${methodName}: payeeData[${index}] must include a non-empty offchainId or a recognizable legacy identifier`
5301
+ );
5302
+ }
5303
+ return result;
5304
+ });
5305
+ return normalized;
5306
+ }
5307
+ function toPostDepositDetailsRequest(processorName, payeeData, index) {
5308
+ if (!payeeData || typeof payeeData.offchainId !== "string" || payeeData.offchainId.length === 0) {
5309
+ throw new Error(`payeeData[${index}] must include a non-empty offchainId`);
5310
+ }
5311
+ return {
5312
+ processorName,
5313
+ offchainId: payeeData.offchainId,
5314
+ telegramUsername: payeeData.telegramUsername,
5315
+ metadata: payeeData.metadata
5316
+ };
5317
+ }
5118
5318
  var Zkp2pClient = class {
5119
5319
  /**
5120
5320
  * Creates a new Zkp2pClient instance.
@@ -5661,7 +5861,7 @@ var Zkp2pClient = class {
5661
5861
  * sending fiat payment to the deposit's payee.
5662
5862
  *
5663
5863
  * If `gatingServiceSignature` is not provided, the SDK will automatically
5664
- * fetch one from curator `/v3/intent` when `apiKey` or `authorizationToken`
5864
+ * fetch one from curator `/v3/intent/sign` when `apiKey` or `authorizationToken`
5665
5865
  * is available. Otherwise you must provide `gatingServiceSignature` and
5666
5866
  * `signatureExpiration` yourself.
5667
5867
  *
@@ -6100,6 +6300,7 @@ var Zkp2pClient = class {
6100
6300
  getProtocolViewerAbi: () => this.protocolViewerAbi,
6101
6301
  getIndexerClient: () => this._indexerClient,
6102
6302
  getIndexerService: () => this._indexerService,
6303
+ getEscrowV2Address: () => this.escrowV2Address,
6103
6304
  getOrchestratorV2Address: () => this.orchestratorV2Address,
6104
6305
  host: {
6105
6306
  resolveEscrowContext: (options) => this.resolveEscrowContext(options),
@@ -6123,6 +6324,30 @@ var Zkp2pClient = class {
6123
6324
  parseRawDepositId(depositId) {
6124
6325
  return parseRawDepositId(depositId);
6125
6326
  }
6327
+ stripTrailingSlash(url) {
6328
+ return url.replace(/\/$/, "");
6329
+ }
6330
+ defaultAttestationServiceForBaseApiUrl(baseApiUrl) {
6331
+ try {
6332
+ const { hostname } = new URL(baseApiUrl);
6333
+ if (hostname === "api-staging.zkp2p.xyz") {
6334
+ return "https://attestation-service-staging.zkp2p.xyz";
6335
+ }
6336
+ if (hostname === "api-preprod.zkp2p.xyz") {
6337
+ return "https://attestation-service.zkp2p.xyz";
6338
+ }
6339
+ if (hostname === "api.zkp2p.xyz") {
6340
+ return "https://attestation-service.zkp2p.xyz";
6341
+ }
6342
+ } catch {
6343
+ }
6344
+ if (baseApiUrl === DEFAULT_BASE_API_URL) {
6345
+ return "https://attestation-service.zkp2p.xyz";
6346
+ }
6347
+ throw new Error(
6348
+ `attestationServiceUrl is required when baseApiUrl is not a supported zkp2p API host: ${baseApiUrl}`
6349
+ );
6350
+ }
6126
6351
  normalizeOracleRateConfig(config) {
6127
6352
  return normalizeOracleRateConfig(config);
6128
6353
  }
@@ -6975,31 +7200,29 @@ var Zkp2pClient = class {
6975
7200
  * register maker payment details with the curator service.
6976
7201
  *
6977
7202
  * @param params.processorNames - Payment platforms (e.g., ['wise', 'revolut'])
6978
- * @param params.depositData - Payee details per processor (e.g., [{ email: '...' }])
7203
+ * @param params.payeeData - Payee details per processor (e.g., [{ offchainId: 'you@example.com' }]). Required when the SDK needs to register payee details with the curator.
6979
7204
  * @returns The posted deposit details and their corresponding hashed on-chain IDs
6980
7205
  *
6981
7206
  * @example
6982
7207
  * ```typescript
6983
7208
  * const { hashedOnchainIds } = await client.registerPayeeDetails({
6984
7209
  * processorNames: ['wise'],
6985
- * depositData: [{ email: 'you@example.com' }],
7210
+ * payeeData: [{ offchainId: 'you@example.com' }],
6986
7211
  * });
6987
7212
  * // Then pass hashedOnchainIds to createDeposit
6988
7213
  * ```
6989
7214
  */
6990
7215
  async registerPayeeDetails(params) {
7216
+ const payeeData = resolvePayeeDataInput(params, "registerPayeeDetails");
6991
7217
  if (!Array.isArray(params.processorNames) || params.processorNames.length === 0) {
6992
7218
  throw new Error("processorNames must be a non-empty array");
6993
7219
  }
6994
- if (params.processorNames.length !== params.depositData.length) {
6995
- throw new Error("processorNames and depositData length mismatch");
7220
+ if (params.processorNames.length !== payeeData.length) {
7221
+ throw new Error("processorNames and payeeData length mismatch");
6996
7222
  }
6997
7223
  const baseApiUrl = (this.baseApiUrl ?? "https://api.zkp2p.xyz").replace(/\/$/, "");
6998
7224
  const depositDetails = params.processorNames.map(
6999
- (processorName, index) => ({
7000
- processorName,
7001
- depositData: params.depositData[index] || {}
7002
- })
7225
+ (processorName, index) => toPostDepositDetailsRequest(processorName, payeeData[index], index)
7003
7226
  );
7004
7227
  const apiResponses = await Promise.all(
7005
7228
  depositDetails.map((req) => apiPostDepositDetails(req, baseApiUrl, this.apiTimeoutMs))
@@ -7026,16 +7249,17 @@ var Zkp2pClient = class {
7026
7249
  * @param params.amount - Total deposit amount in token units (6 decimals for USDC)
7027
7250
  * @param params.intentAmountRange - Min/max amount per intent
7028
7251
  * @param params.processorNames - Payment platforms to accept (e.g., ['wise', 'revolut'])
7029
- * @param params.depositData - Payee details per processor (e.g., [{ email: '...' }])
7252
+ * @param params.payeeData - Payee details per processor (e.g., [{ offchainId: 'you@example.com' }])
7030
7253
  * @param params.conversionRates - Conversion rates per processor, grouped by currency
7031
7254
  * @param params.payeeDetailsHashes - Pre-computed hashed on-chain IDs (from registerPayeeDetails). When provided, skips the curator API call entirely.
7032
7255
  * @param params.delegate - Optional delegate address that can manage the deposit
7033
7256
  * @param params.intentGuardian - Optional guardian for intent approval
7034
7257
  * @param params.retainOnEmpty - Keep deposit active when balance reaches zero
7035
7258
  * @param params.txOverrides - Optional viem transaction overrides
7036
- * @returns The deposit details posted to API and the transaction hash
7259
+ * @returns The deposit details posted to API (empty when payee registration is skipped) and the transaction hash
7037
7260
  *
7038
- * @throws Error if processorNames, depositData, and conversionRates lengths don't match
7261
+ * @throws Error if processorNames, payeeData, and conversionRates lengths don't match
7262
+ * @throws Error if payeeData is missing and neither payeeDetailsHashes nor full payment method overrides are provided
7039
7263
  * @throws Error if a currency is not supported by the specified processor
7040
7264
  *
7041
7265
  * @example
@@ -7046,7 +7270,7 @@ var Zkp2pClient = class {
7046
7270
  * amount: 1000_000000n,
7047
7271
  * intentAmountRange: { min: 10_000000n, max: 500_000000n },
7048
7272
  * processorNames: ['wise'],
7049
- * depositData: [{ email: 'you@example.com' }],
7273
+ * payeeData: [{ offchainId: 'you@example.com' }],
7050
7274
  * conversionRates: [[
7051
7275
  * { currency: 'USD', conversionRate: '1020000000000000000' }, // 1.02
7052
7276
  * { currency: 'EUR', conversionRate: '1100000000000000000' }, // 1.10
@@ -7079,24 +7303,30 @@ var Zkp2pClient = class {
7079
7303
  };
7080
7304
  }
7081
7305
  async prepareCreateDepositInternal(params) {
7306
+ const hasOverrides = Boolean(
7307
+ params.paymentMethodsOverride || params.paymentMethodDataOverride || params.currenciesOverride
7308
+ );
7309
+ const payeeDetailsHashes = params.payeeDetailsHashes;
7310
+ const hasPayeeHashes = payeeDetailsHashes !== void 0;
7311
+ const shouldResolvePayeeData = params.payeeData !== void 0 || params.depositData !== void 0;
7312
+ const payeeData = shouldResolvePayeeData ? resolvePayeeDataInput(params, "createDeposit") : null;
7082
7313
  if (!Array.isArray(params.processorNames) || params.processorNames.length === 0) {
7083
7314
  throw new Error("processorNames must be a non-empty array");
7084
7315
  }
7085
7316
  if (params.processorNames.length !== params.conversionRates.length) {
7086
7317
  throw new Error("processorNames and conversionRates length mismatch");
7087
7318
  }
7088
- if (params.processorNames.length !== params.depositData.length) {
7089
- throw new Error("processorNames and depositData length mismatch");
7319
+ if (payeeData && params.processorNames.length !== payeeData.length) {
7320
+ throw new Error("processorNames and payeeData length mismatch");
7090
7321
  }
7091
- const depositDetails = params.processorNames.map(
7092
- (processorName, index) => ({
7093
- processorName,
7094
- depositData: params.depositData[index] || {}
7095
- })
7096
- );
7097
- const hasOverrides = Boolean(
7098
- params.paymentMethodsOverride || params.paymentMethodDataOverride || params.currenciesOverride
7099
- );
7322
+ if (!hasOverrides && !hasPayeeHashes && !payeeData) {
7323
+ throw new Error(
7324
+ "createDeposit requires payeeData unless payeeDetailsHashes or full payment method overrides are provided"
7325
+ );
7326
+ }
7327
+ const depositDetails = payeeData ? params.processorNames.map(
7328
+ (processorName, index) => toPostDepositDetailsRequest(processorName, payeeData[index], index)
7329
+ ) : [];
7100
7330
  let paymentMethods;
7101
7331
  let paymentMethodData;
7102
7332
  let currencies;
@@ -7121,11 +7351,11 @@ var Zkp2pClient = class {
7121
7351
  );
7122
7352
  const intentGatingService = getGatingServiceAddress(this.chainId, this.runtimeEnv);
7123
7353
  let hashedOnchainIds;
7124
- if (params.payeeDetailsHashes) {
7125
- if (params.payeeDetailsHashes.length !== params.processorNames.length) {
7354
+ if (payeeDetailsHashes !== void 0) {
7355
+ if (payeeDetailsHashes.length !== params.processorNames.length) {
7126
7356
  throw new Error("payeeDetailsHashes length must match processorNames length");
7127
7357
  }
7128
- hashedOnchainIds = params.payeeDetailsHashes;
7358
+ hashedOnchainIds = payeeDetailsHashes;
7129
7359
  } else {
7130
7360
  const baseApiUrl = (this.baseApiUrl ?? "https://api.zkp2p.xyz").replace(/\/$/, "");
7131
7361
  const apiResponses = await Promise.all(
@@ -7311,7 +7541,7 @@ var Zkp2pClient = class {
7311
7541
  const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
7312
7542
  const reqWithEscrow = { ...req };
7313
7543
  if (!reqWithEscrow.escrowAddresses || reqWithEscrow.escrowAddresses.length === 0) {
7314
- const configuredEscrows = this.escrowAddresses.length > 0 ? this.escrowAddresses.map((address) => address) : this.escrowAddress ? [this.escrowAddress] : [];
7544
+ const configuredEscrows = this.escrowV2Address ? [this.escrowV2Address] : this.escrowAddress ? [this.escrowAddress] : [];
7315
7545
  if (configuredEscrows.length > 0) {
7316
7546
  reqWithEscrow.escrowAddresses = configuredEscrows;
7317
7547
  }
@@ -7326,8 +7556,9 @@ var Zkp2pClient = class {
7326
7556
  const quotes = quote?.responseObject?.quotes ?? [];
7327
7557
  for (const q of quotes) {
7328
7558
  const maker = q?.maker;
7329
- if (maker?.depositData && typeof q === "object") {
7330
- q.payeeData = maker.depositData;
7559
+ const payeeData = normalizeQuotePayeeData(maker);
7560
+ if (payeeData && typeof q === "object") {
7561
+ q.payeeData = payeeData;
7331
7562
  }
7332
7563
  }
7333
7564
  return appendReferrerFeeDisplayFields(quote, referrerFeeConfig);
@@ -7354,7 +7585,7 @@ var Zkp2pClient = class {
7354
7585
  const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
7355
7586
  const reqWithEscrow = { ...req };
7356
7587
  if (!reqWithEscrow.escrowAddresses || reqWithEscrow.escrowAddresses.length === 0) {
7357
- const configuredEscrows = this.escrowAddresses.length > 0 ? [...this.escrowAddresses] : this.escrowAddress ? [this.escrowAddress] : [];
7588
+ const configuredEscrows = this.escrowV2Address ? [this.escrowV2Address] : this.escrowAddress ? [this.escrowAddress] : [];
7358
7589
  if (configuredEscrows.length > 0) {
7359
7590
  reqWithEscrow.escrowAddresses = configuredEscrows;
7360
7591
  }
@@ -7372,11 +7603,11 @@ var Zkp2pClient = class {
7372
7603
  ...quote.responseObject,
7373
7604
  platformQuotes: (quote.responseObject?.platformQuotes ?? []).map((platformQuote) => {
7374
7605
  const bestQuote = platformQuote?.bestQuote;
7375
- const makerDepositData = bestQuote?.maker?.depositData;
7376
- if (!bestQuote || !makerDepositData) return platformQuote;
7606
+ const payeeData = normalizeQuotePayeeData(bestQuote?.maker);
7607
+ if (!bestQuote || !payeeData) return platformQuote;
7377
7608
  return {
7378
7609
  ...platformQuote,
7379
- bestQuote: { ...bestQuote, payeeData: makerDepositData }
7610
+ bestQuote: { ...bestQuote, payeeData }
7380
7611
  };
7381
7612
  })
7382
7613
  }
@@ -7404,6 +7635,92 @@ var Zkp2pClient = class {
7404
7635
  const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
7405
7636
  return apiGetTakerTier(req, void 0, baseApiUrl, timeoutMs);
7406
7637
  }
7638
+ /**
7639
+ * The signed `expiresAtMs` field is an upload-time freshness token minted by attestation-service.
7640
+ * Once curator persists the bundle, seller-automated-release availability is governed by curator's
7641
+ * probe/revalidation state rather than this timestamp.
7642
+ *
7643
+ * Curator accepts either a configured API key or bearer token for this endpoint.
7644
+ *
7645
+ * Create a signed seller credential bundle with attestation-service and store it on the maker via curator.
7646
+ */
7647
+ async uploadSellerCredential(params, opts) {
7648
+ const baseApiUrl = this.stripTrailingSlash(
7649
+ opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
7650
+ );
7651
+ const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
7652
+ const attestationServiceUrl = this.stripTrailingSlash(
7653
+ opts?.attestationServiceUrl ?? this.defaultAttestationServiceForBaseApiUrl(baseApiUrl)
7654
+ );
7655
+ const uploadPayload = {
7656
+ payeeId: params.payeeId,
7657
+ sessionMaterial: params.sessionMaterial
7658
+ };
7659
+ const bundleResponse = await apiCreateSellerCredentialBundle(
7660
+ uploadPayload,
7661
+ attestationServiceUrl,
7662
+ params.platform,
7663
+ timeoutMs
7664
+ );
7665
+ if (!bundleResponse.success || !bundleResponse.responseObject) {
7666
+ throw new Error(bundleResponse.message || "Failed to create seller credential bundle");
7667
+ }
7668
+ return apiUploadSellerCredential(
7669
+ params.makerId,
7670
+ bundleResponse.responseObject,
7671
+ baseApiUrl,
7672
+ timeoutMs,
7673
+ this.apiKey,
7674
+ this.authorizationToken
7675
+ );
7676
+ }
7677
+ /**
7678
+ * Status is a coarse curator-owned signal (`active` / `inactive` / `missing`) and intentionally
7679
+ * omits low-level diagnostics. Curator may still re-probe stale credentials during verify, so callers
7680
+ * should continue to handle a 410 from `verifySellerPayment`.
7681
+ *
7682
+ * Curator accepts either a configured API key or bearer token for this endpoint.
7683
+ *
7684
+ * Fetch seller credential status for a maker from curator.
7685
+ */
7686
+ async getSellerCredentialStatus(params, opts) {
7687
+ const baseApiUrl = this.stripTrailingSlash(
7688
+ opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
7689
+ );
7690
+ const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
7691
+ return apiGetSellerCredentialStatus(
7692
+ params.makerId,
7693
+ baseApiUrl,
7694
+ timeoutMs,
7695
+ this.apiKey,
7696
+ this.authorizationToken
7697
+ );
7698
+ }
7699
+ /**
7700
+ * Internal-use endpoint. The curator route requires an internal `x-api-key`; standard SDK consumer
7701
+ * API keys will be rejected with 401. Returns 410 GONE when curator has marked the credential inactive
7702
+ * or a stale credential fails its synchronous re-probe.
7703
+ *
7704
+ * Verify a seller payment via curator's seller-credential proxy.
7705
+ */
7706
+ async verifySellerPayment(params, opts) {
7707
+ const baseApiUrl = this.stripTrailingSlash(
7708
+ opts?.baseApiUrl ?? this.baseApiUrl ?? DEFAULT_BASE_API_URL
7709
+ );
7710
+ const timeoutMs = opts?.timeoutMs ?? this.apiTimeoutMs;
7711
+ return apiVerifySellerPayment(
7712
+ params.platform,
7713
+ {
7714
+ txId: params.txId,
7715
+ chainId: params.chainId,
7716
+ intent: params.intent
7717
+ },
7718
+ baseApiUrl,
7719
+ timeoutMs,
7720
+ this.apiKey,
7721
+ this.authorizationToken
7722
+ );
7723
+ }
7407
7724
  // ╔═══════════════════════════════════════════════════════════════════════════╗
7408
7725
  // ║ CORE: ON-CHAIN DEPOSIT VIEWS ║
7409
7726
  // ╚═══════════════════════════════════════════════════════════════════════════╝
@@ -7771,6 +8088,6 @@ var logger = {
7771
8088
  }
7772
8089
  };
7773
8090
 
7774
- export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
8091
+ export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetDepositBundle, apiGetOrderbook, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetQuotesBestByPlatform, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
7775
8092
  //# sourceMappingURL=index.mjs.map
7776
8093
  //# sourceMappingURL=index.mjs.map