@zkp2p/sdk 0.14.2 → 0.14.4

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.
@@ -1,4 +1,4 @@
1
1
  export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchain, mapConversionRatesToOnchainMinRate } from './chunk-ZB22BZLZ.mjs';
2
- import './chunk-BVBHBKX7.mjs';
3
- //# sourceMappingURL=currency-GBDKE3OV.mjs.map
4
- //# sourceMappingURL=currency-GBDKE3OV.mjs.map
2
+ import './chunk-HQACV3RF.mjs';
3
+ //# sourceMappingURL=currency-Y5AB4CKQ.mjs.map
4
+ //# sourceMappingURL=currency-Y5AB4CKQ.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-GBDKE3OV.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"currency-Y5AB4CKQ.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: "a87f38c512f987fc3b9234b5aee31115bf840a18", kind: "github", distributable: true }, sdkPackageVersion: "0.14.2", contractsPackageVersion: "0.4.2-rc.2", 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: "c34d74604e3cab83656d6ba85203099456962b0c", kind: "github", distributable: true }, sdkPackageVersion: "0.14.4", contractsPackageVersion: "0.4.2-rc.2", indexerSchemaPackageVersion: "0.22.0", activeDisputeStack: { base: { version: 2, selectionHash: "ba40c2954b408d0c658881a8d28e5bfcc9bade5cc3d953fd17eae1eca69d841c" }, baseStaging: { version: 2, selectionHash: "6c49c1ce51eec594a22385c4efcab08aa9926b6b63a725e14a0027ec5d2f4fc9" } } };
25
25
  }
26
26
  });
27
27
 
@@ -105153,7 +105153,7 @@ var getRateManagerReadFunction = (abi, functionName) => Array.isArray(abi) && ab
105153
105153
 
105154
105154
  // src/client/AccessPolicyOperations.ts
105155
105155
  init_define_ZKP2P_SDK_BUILD_METADATA();
105156
- var PEER_PAY_MERCHANT_GROUP_ID_BY_ENVIRONMENT = {
105156
+ var DEPOSIT_WHITELIST_GROUP_ID_BY_ENVIRONMENT = {
105157
105157
  production: "0x174b8a29536721a3eae290bfd55651b85a53fc334b971d993fa93ed8dde15e48",
105158
105158
  preproduction: "0x174b8a29536721a3eae290bfd55651b85a53fc334b971d993fa93ed8dde15e48",
105159
105159
  staging: "0xc82c20c00033046a2f017b65532d7148a337282f17c73296663a530e49ba00f7"
@@ -105185,6 +105185,13 @@ var AccessPolicyOperations = class {
105185
105185
  if (!address || !abi) throw new AccessPolicyUnsupportedError("AddressGroupRegistry");
105186
105186
  return { address, abi };
105187
105187
  }
105188
+ depositWhitelistGroupId() {
105189
+ const runtimeEnv = this.config.getRuntimeEnv?.();
105190
+ if (!runtimeEnv) {
105191
+ throw new Error("Runtime environment is required for the Peer Pay deposit whitelist.");
105192
+ }
105193
+ return DEPOSIT_WHITELIST_GROUP_ID_BY_ENVIRONMENT[runtimeEnv];
105194
+ }
105188
105195
  /* ============ Reads ============ */
105189
105196
  async isEnabled(params) {
105190
105197
  const { address, abi } = this.requirePolicy();
@@ -105195,6 +105202,15 @@ var AccessPolicyOperations = class {
105195
105202
  args: [params.escrow, params.depositId, params.paymentMethod]
105196
105203
  });
105197
105204
  }
105205
+ /** True only when this deposit enables the current environment's whitelist group. */
105206
+ async isDepositWhitelistConfigured(params) {
105207
+ const depositWhitelistGroupId = this.depositWhitelistGroupId();
105208
+ const [enabled, groups] = await Promise.all([
105209
+ this.isEnabled(params),
105210
+ this.getAllowedGroups(params)
105211
+ ]);
105212
+ return enabled && groups.some((group) => group.toLowerCase() === depositWhitelistGroupId);
105213
+ }
105198
105214
  /** Groups are enumerable onchain; direct addresses deliberately are not. */
105199
105215
  async getAllowedGroups(params) {
105200
105216
  const { address, abi } = this.requirePolicy();
@@ -105256,16 +105272,12 @@ var AccessPolicyOperations = class {
105256
105272
  txOverrides
105257
105273
  });
105258
105274
  }
105259
- /** Configure the fixed Peer Pay merchant default while creating a sell deposit. */
105275
+ /** Configure the fixed Peer Pay deposit whitelist for a sell deposit. */
105260
105276
  prepareConfigurePeerPayMerchantDeposit(params) {
105261
- const runtimeEnv = this.config.getRuntimeEnv?.();
105262
- if (!runtimeEnv) {
105263
- throw new Error("Runtime environment is required to configure the Peer Pay merchant policy.");
105264
- }
105265
- const merchantGroupId = PEER_PAY_MERCHANT_GROUP_ID_BY_ENVIRONMENT[runtimeEnv];
105277
+ const depositWhitelistGroupId = this.depositWhitelistGroupId();
105266
105278
  return this.preparePolicyCall(
105267
105279
  "configureDeposit",
105268
- [params.escrow, params.depositId, params.paymentMethod, true, [merchantGroupId], []],
105280
+ [params.escrow, params.depositId, params.paymentMethod, true, [depositWhitelistGroupId], []],
105269
105281
  params.txOverrides
105270
105282
  );
105271
105283
  }
@@ -110714,6 +110726,25 @@ var Zkp2pClient = class {
110714
110726
  };
110715
110727
  }
110716
110728
  async prepareCreateDepositInternal(params) {
110729
+ let txOverrides = params.txOverrides;
110730
+ if (params.referralCode !== void 0) {
110731
+ if (!isValidReferralCode(params.referralCode)) {
110732
+ throw new Error("createDeposit referralCode must be six alphanumeric characters");
110733
+ }
110734
+ const referrer = params.txOverrides?.referrer;
110735
+ const referrers = referrer === void 0 ? [] : Array.isArray(referrer) ? referrer : [referrer];
110736
+ if (referrers.some(
110737
+ (code) => code.split(",").some((part) => part.trim().toLowerCase().startsWith("peer-ref-"))
110738
+ )) {
110739
+ throw new Error(
110740
+ "createDeposit referralCode cannot be combined with a peer-ref- marker in txOverrides.referrer"
110741
+ );
110742
+ }
110743
+ txOverrides = {
110744
+ ...params.txOverrides,
110745
+ referrer: [`peer-ref-${normalizeReferralCode(params.referralCode)}`, ...referrers]
110746
+ };
110747
+ }
110717
110748
  const hasOverrides = Boolean(
110718
110749
  params.paymentMethodsOverride || params.paymentMethodDataOverride || params.currenciesOverride
110719
110750
  );
@@ -110841,7 +110872,7 @@ var Zkp2pClient = class {
110841
110872
  const prepared = this.prepareEscrowTransaction({
110842
110873
  functionName: "createDeposit",
110843
110874
  args,
110844
- txOverrides: params.txOverrides,
110875
+ txOverrides,
110845
110876
  escrowAddress: escrowContext.address,
110846
110877
  escrowAbi: escrowContext.abi
110847
110878
  });
@@ -111647,7 +111678,8 @@ var VenmoGmailConnectError = class extends Error {
111647
111678
  function getVenmoGmailConnectUrl({
111648
111679
  payeeDetails,
111649
111680
  peerOrigin = "https://app.peer.xyz",
111650
- appearance
111681
+ appearance,
111682
+ returnUrl
111651
111683
  }) {
111652
111684
  if (!/^0x[0-9a-f]{64}$/i.test(payeeDetails)) {
111653
111685
  throw new exports.ValidationError("Expected a Venmo payee hash", "payeeDetails");
@@ -111662,6 +111694,14 @@ function getVenmoGmailConnectUrl({
111662
111694
  throw new exports.ValidationError("Expected an HTTPS Peer web origin", "peerOrigin");
111663
111695
  }
111664
111696
  const url = new URL("/connect/venmo", origin);
111697
+ if (returnUrl) {
111698
+ try {
111699
+ new URL(returnUrl);
111700
+ } catch {
111701
+ throw new exports.ValidationError("Expected an absolute app callback URI", "returnUrl");
111702
+ }
111703
+ url.searchParams.set("returnUrl", returnUrl);
111704
+ }
111665
111705
  if (appearance)
111666
111706
  url.searchParams.set("appearance", JSON.stringify(parseVenmoGmailAppearance(appearance)));
111667
111707
  url.hash = payeeDetails;