@zkp2p/sdk 0.13.0 → 0.14.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.
@@ -5,8 +5,8 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // <define:__ZKP2P_SDK_BUILD_METADATA__>
8
- var define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "32b0342dc76aba9a63d0f56cc16c4addb8ebce43", kind: "github", distributable: true }, sdkPackageVersion: "0.13.0", contractsPackageVersion: "0.4.1-rc.9", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
8
+ var define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "fc7daa489d5236d1480acf3ce5f4a5c0251b70b3", kind: "github", distributable: true }, sdkPackageVersion: "0.14.0", contractsPackageVersion: "0.4.1-rc.9", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
9
9
 
10
10
  export { __export, define_ZKP2P_SDK_BUILD_METADATA_default };
11
- //# sourceMappingURL=chunk-EHLMW7OM.mjs.map
12
- //# sourceMappingURL=chunk-EHLMW7OM.mjs.map
11
+ //# sourceMappingURL=chunk-GUGMFD2K.mjs.map
12
+ //# sourceMappingURL=chunk-GUGMFD2K.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["%3Cdefine:__ZKP2P_SDK_BUILD_METADATA__%3E"],"names":[],"mappings":";;;;;;;AAAA,IAAA,uCAAA,GAAA,EAAC,aAAA,EAAgB,CAAA,EAAE,MAAA,EAAS,EAAC,YAAa,qBAAA,EAAsB,SAAA,EAAY,0CAAA,EAA2C,IAAA,EAAO,UAAS,aAAA,EAAgB,IAAA,EAAI,EAAE,iBAAA,EAAoB,UAAS,uBAAA,EAA0B,YAAA,EAAa,2BAAA,EAA8B,QAAA,EAAS,oBAAqB,EAAC,IAAA,EAAO,EAAC,OAAA,EAAU,GAAE,aAAA,EAAgB,kEAAA,EAAkE,EAAE,WAAA,EAAc,EAAC,OAAA,EAAU,CAAA,EAAE,aAAA,EAAgB,kEAAA,IAAmE","file":"chunk-EHLMW7OM.mjs","sourcesContent":["{\"schemaVersion\":2,\"source\":{\"repository\":\"zkp2p/zkp2p-clients\",\"commitSha\":\"32b0342dc76aba9a63d0f56cc16c4addb8ebce43\",\"kind\":\"github\",\"distributable\":true},\"sdkPackageVersion\":\"0.13.0\",\"contractsPackageVersion\":\"0.4.1-rc.9\",\"indexerSchemaPackageVersion\":\"0.22.0\",\"activeDisputeStack\":{\"base\":{\"version\":2,\"selectionHash\":\"ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c\"},\"baseStaging\":{\"version\":2,\"selectionHash\":\"6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9\"}}}"]}
1
+ {"version":3,"sources":["%3Cdefine:__ZKP2P_SDK_BUILD_METADATA__%3E"],"names":[],"mappings":";;;;;;;AAAA,IAAA,uCAAA,GAAA,EAAC,aAAA,EAAgB,CAAA,EAAE,MAAA,EAAS,EAAC,YAAa,qBAAA,EAAsB,SAAA,EAAY,0CAAA,EAA2C,IAAA,EAAO,UAAS,aAAA,EAAgB,IAAA,EAAI,EAAE,iBAAA,EAAoB,UAAS,uBAAA,EAA0B,YAAA,EAAa,2BAAA,EAA8B,QAAA,EAAS,oBAAqB,EAAC,IAAA,EAAO,EAAC,OAAA,EAAU,GAAE,aAAA,EAAgB,kEAAA,EAAkE,EAAE,WAAA,EAAc,EAAC,OAAA,EAAU,CAAA,EAAE,aAAA,EAAgB,kEAAA,IAAmE","file":"chunk-GUGMFD2K.mjs","sourcesContent":["{\"schemaVersion\":2,\"source\":{\"repository\":\"zkp2p/zkp2p-clients\",\"commitSha\":\"fc7daa489d5236d1480acf3ce5f4a5c0251b70b3\",\"kind\":\"github\",\"distributable\":true},\"sdkPackageVersion\":\"0.14.0\",\"contractsPackageVersion\":\"0.4.1-rc.9\",\"indexerSchemaPackageVersion\":\"0.22.0\",\"activeDisputeStack\":{\"base\":{\"version\":2,\"selectionHash\":\"ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c\"},\"baseStaging\":{\"version\":2,\"selectionHash\":\"6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9\"}}}"]}
@@ -1,4 +1,4 @@
1
1
  export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchain, mapConversionRatesToOnchainMinRate } from './chunk-ZB22BZLZ.mjs';
2
- import './chunk-EHLMW7OM.mjs';
3
- //# sourceMappingURL=currency-5W2J2RG5.mjs.map
4
- //# sourceMappingURL=currency-5W2J2RG5.mjs.map
2
+ import './chunk-GUGMFD2K.mjs';
3
+ //# sourceMappingURL=currency-HMJXK46S.mjs.map
4
+ //# sourceMappingURL=currency-HMJXK46S.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-5W2J2RG5.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-HMJXK46S.mjs"}
package/dist/index.cjs CHANGED
@@ -21,7 +21,7 @@ var __export = (target, all) => {
21
21
  var define_ZKP2P_SDK_BUILD_METADATA_default;
22
22
  var init_define_ZKP2P_SDK_BUILD_METADATA = __esm({
23
23
  "<define:__ZKP2P_SDK_BUILD_METADATA__>"() {
24
- define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "32b0342dc76aba9a63d0f56cc16c4addb8ebce43", kind: "github", distributable: true }, sdkPackageVersion: "0.13.0", contractsPackageVersion: "0.4.1-rc.9", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
24
+ define_ZKP2P_SDK_BUILD_METADATA_default = { schemaVersion: 2, source: { repository: "zkp2p/zkp2p-clients", commitSha: "fc7daa489d5236d1480acf3ce5f4a5c0251b70b3", kind: "github", distributable: true }, sdkPackageVersion: "0.14.0", contractsPackageVersion: "0.4.1-rc.9", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
25
25
  }
26
26
  });
27
27
 
@@ -111940,7 +111940,12 @@ var applyReferrerFeeDisplayFieldsToQuote = (quote, referrerFeeConfig, decimals)
111940
111940
  { signalIntentAmount }
111941
111941
  );
111942
111942
  if (!adjusted) {
111943
- return quote;
111943
+ return {
111944
+ ...quote,
111945
+ referrerFeeAmount: quote.referrerFeeAmount ?? void 0,
111946
+ referrerFeeAmountFormatted: quote.referrerFeeAmountFormatted ?? void 0,
111947
+ referrerFeeBps: quote.referrerFeeBps ?? void 0
111948
+ };
111944
111949
  }
111945
111950
  return {
111946
111951
  ...quote,
@@ -112053,12 +112058,7 @@ function isObjectRecord(value) {
112053
112058
  }
112054
112059
  return true;
112055
112060
  }
112056
- function normalizeTelegramUsername(value) {
112057
- if (typeof value !== "string") return null;
112058
- const normalized = value.trim();
112059
- return normalized.length > 0 ? normalized : null;
112060
- }
112061
- function extractLegacyQuotePayeeData(depositData) {
112061
+ function extractLegacyPayeeDataInput(depositData) {
112062
112062
  if (!depositData || typeof depositData !== "object" || Array.isArray(depositData)) {
112063
112063
  return void 0;
112064
112064
  }
@@ -112077,17 +112077,26 @@ function extractLegacyQuotePayeeData(depositData) {
112077
112077
  metadata: metadataEntries.length > 0 ? Object.fromEntries(metadataEntries) : null
112078
112078
  };
112079
112079
  }
112080
- function normalizeQuotePayeeData(maker) {
112081
- const legacy = extractLegacyQuotePayeeData(maker?.depositData);
112082
- const offchainId = typeof maker?.offchainId === "string" && maker.offchainId.trim().length > 0 ? maker.offchainId : legacy?.offchainId;
112083
- if (!offchainId) {
112080
+ function readQuoteMakerIdentity(quote) {
112081
+ if (typeof quote.maker?.offchainId !== "string") {
112084
112082
  return void 0;
112085
112083
  }
112086
- return {
112087
- offchainId,
112088
- telegramUsername: normalizeTelegramUsername(maker?.telegramUsername) ?? legacy?.telegramUsername ?? null,
112089
- metadata: isObjectRecord(maker?.metadata) ? maker.metadata : legacy?.metadata ?? null
112090
- };
112084
+ const offchainId = quote.maker.offchainId.trim();
112085
+ return offchainId.length > 0 ? { offchainId } : void 0;
112086
+ }
112087
+ function warnDroppedQuoteWithoutMakerIdentity(method, quote) {
112088
+ console.warn(`[zkp2p/sdk] ${method}: dropping quote without maker.offchainId`, {
112089
+ depositId: quote.intent?.depositId,
112090
+ processorName: quote.intent?.processorName
112091
+ });
112092
+ }
112093
+ function withQuotePayeeData(method, quote) {
112094
+ const payeeData = readQuoteMakerIdentity(quote);
112095
+ if (!payeeData) {
112096
+ warnDroppedQuoteWithoutMakerIdentity(method, quote);
112097
+ return void 0;
112098
+ }
112099
+ return { ...quote, maker: payeeData, payeeData };
112091
112100
  }
112092
112101
  function isActiveQuotePaymentMethod(quote) {
112093
112102
  if (!quote?.intent || typeof quote.intent.processorName !== "string" || typeof quote.paymentMethod !== "string") {
@@ -112095,6 +112104,19 @@ function isActiveQuotePaymentMethod(quote) {
112095
112104
  }
112096
112105
  return matchesQuotePaymentMethod(quote.intent.processorName, quote.paymentMethod);
112097
112106
  }
112107
+ function enrichActiveQuotes(quotes) {
112108
+ return quotes.map((quote) => {
112109
+ if (!isActiveQuotePaymentMethod(quote)) return void 0;
112110
+ return withQuotePayeeData("getQuote", quote);
112111
+ }).filter((quote) => quote !== void 0);
112112
+ }
112113
+ function enrichNearbySuggestions(suggestions) {
112114
+ return suggestions.map((suggestion) => {
112115
+ if (!isActiveQuotePaymentMethod(suggestion.quote)) return void 0;
112116
+ const quote = withQuotePayeeData("getQuote", suggestion.quote);
112117
+ return quote ? { ...suggestion, quote } : void 0;
112118
+ }).filter((suggestion) => suggestion !== void 0);
112119
+ }
112098
112120
  function normalizePayeeDataInputItem(raw) {
112099
112121
  if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
112100
112122
  return null;
@@ -112103,7 +112125,7 @@ function normalizePayeeDataInputItem(raw) {
112103
112125
  if (typeof candidate.offchainId === "string" && candidate.offchainId.trim().length > 0) {
112104
112126
  return candidate;
112105
112127
  }
112106
- const legacy = extractLegacyQuotePayeeData(raw);
112128
+ const legacy = extractLegacyPayeeDataInput(raw);
112107
112129
  if (!legacy) {
112108
112130
  return null;
112109
112131
  }
@@ -114692,7 +114714,8 @@ var Zkp2pClient = class {
114692
114714
  * > use it to see how their deposits appear to takers.
114693
114715
  *
114694
114716
  * Returns available quotes from liquidity providers matching the request
114695
- * criteria. When authenticated, the API returns payee details in each quote.
114717
+ * criteria. Quotes carry `payeeData.offchainId` derived from the curator v3
114718
+ * `maker` identity; quotes without it are dropped.
114696
114719
  *
114697
114720
  * @param req - Quote request parameters
114698
114721
  * @param req.paymentPlatforms - Payment platforms to search (e.g., ['wise', 'revolut'])
@@ -114747,31 +114770,26 @@ var Zkp2pClient = class {
114747
114770
  timeoutMs,
114748
114771
  headers: this.apiHeaders
114749
114772
  });
114750
- const quotes = (quote?.responseObject?.quotes ?? []).filter(isActiveQuotePaymentMethod);
114751
- quote.responseObject.quotes = quotes;
114752
- if (quote.responseObject.nearbySuggestions) {
114753
- quote.responseObject.nearbySuggestions = {
114754
- below: quote.responseObject.nearbySuggestions.below.filter(
114755
- (suggestion) => isActiveQuotePaymentMethod(suggestion.quote)
114756
- ),
114757
- above: quote.responseObject.nearbySuggestions.above.filter(
114758
- (suggestion) => isActiveQuotePaymentMethod(suggestion.quote)
114759
- )
114760
- };
114761
- }
114762
- for (const q of quotes) {
114763
- const payeeData = normalizeQuotePayeeData(q.maker);
114764
- if (payeeData) {
114765
- q.payeeData = payeeData;
114773
+ const quotes = enrichActiveQuotes(quote.responseObject.quotes);
114774
+ const enrichedQuote = {
114775
+ ...quote,
114776
+ responseObject: {
114777
+ ...quote.responseObject,
114778
+ quotes,
114779
+ nearbySuggestions: quote.responseObject.nearbySuggestions ? {
114780
+ below: enrichNearbySuggestions(quote.responseObject.nearbySuggestions.below),
114781
+ above: enrichNearbySuggestions(quote.responseObject.nearbySuggestions.above)
114782
+ } : void 0
114766
114783
  }
114767
- }
114768
- return appendReferrerFeeDisplayFields(quote, referrerFeeConfig);
114784
+ };
114785
+ return appendReferrerFeeDisplayFields(enrichedQuote, referrerFeeConfig);
114769
114786
  }
114770
114787
  /**
114771
114788
  * **Supporting Method** - Fetches the best available quote per supported payment platform.
114772
114789
  *
114773
- * Returns one quote per platform when available. The API returns payee details
114774
- * in each platform's best quote when available.
114790
+ * Returns one quote per platform when available. Best quotes carry
114791
+ * `payeeData.offchainId` derived from the curator v3 `maker` identity; best
114792
+ * quotes without it are dropped.
114775
114793
  *
114776
114794
  * @param req - Best-by-platform quote request parameters
114777
114795
  * @param opts - Optional overrides for API URL and timeout
@@ -114799,25 +114817,23 @@ var Zkp2pClient = class {
114799
114817
  timeoutMs,
114800
114818
  headers: this.apiHeaders
114801
114819
  });
114802
- const enrichedQuote = quote ? {
114820
+ const platformQuotes = quote.responseObject.platformQuotes.filter((platformQuote) => {
114821
+ const platform = platformQuote.platform.trim().toLowerCase();
114822
+ if (!METHOD_NAME_TO_HASH2[platform]) return false;
114823
+ return !platformQuote.bestQuote || platform === platformQuote.bestQuote.intent.processorName.trim().toLowerCase() && isActiveQuotePaymentMethod(platformQuote.bestQuote);
114824
+ }).flatMap((platformQuote) => {
114825
+ const bestQuote = platformQuote.bestQuote;
114826
+ if (!bestQuote) return [{ ...platformQuote, bestQuote: void 0 }];
114827
+ const enrichedBestQuote = withQuotePayeeData("getQuotesBestByPlatform", bestQuote);
114828
+ return enrichedBestQuote ? [{ ...platformQuote, bestQuote: enrichedBestQuote }] : [];
114829
+ });
114830
+ const enrichedQuote = {
114803
114831
  ...quote,
114804
114832
  responseObject: {
114805
114833
  ...quote.responseObject,
114806
- platformQuotes: (quote.responseObject?.platformQuotes ?? []).filter((platformQuote) => {
114807
- const platform = platformQuote.platform.trim().toLowerCase();
114808
- if (!METHOD_NAME_TO_HASH2[platform]) return false;
114809
- return !platformQuote.bestQuote || platform === platformQuote.bestQuote.intent.processorName.trim().toLowerCase() && isActiveQuotePaymentMethod(platformQuote.bestQuote);
114810
- }).map((platformQuote) => {
114811
- const bestQuote = platformQuote?.bestQuote;
114812
- const payeeData = normalizeQuotePayeeData(bestQuote?.maker);
114813
- if (!bestQuote || !payeeData) return platformQuote;
114814
- return {
114815
- ...platformQuote,
114816
- bestQuote: { ...bestQuote, payeeData }
114817
- };
114818
- })
114834
+ platformQuotes
114819
114835
  }
114820
- } : quote;
114836
+ };
114821
114837
  return appendReferrerFeeDisplayFieldsToBestByPlatform(enrichedQuote, referrerFeeConfig);
114822
114838
  }
114823
114839
  /**