@zkp2p/sdk 0.2.1 → 0.2.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.
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-J33LUXNA.mjs';
5
- export { HISTORICAL_ESCROW_ADDRESSES, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-J33LUXNA.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';
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';
@@ -262,7 +262,7 @@ var ContractRouter = class {
262
262
  }
263
263
  ];
264
264
  }
265
- resolveOrchestratorForEscrow(escrowAddress, _preferV2 = false) {
265
+ resolveOrchestratorForEscrow(escrowAddress) {
266
266
  if (escrowAddress) {
267
267
  const escrowContext = this.getEscrowContextByAddress(escrowAddress);
268
268
  const fromEscrow = this.getOrchestratorContextByAddress(escrowContext?.orchestratorAddress);
@@ -318,9 +318,6 @@ var ContractRouter = class {
318
318
  }
319
319
  return contexts;
320
320
  }
321
- get defaultPreferV2() {
322
- return true;
323
- }
324
321
  };
325
322
 
326
323
  // src/errors/utils.ts
@@ -370,9 +367,9 @@ function createHeaders(apiKey, authorizationToken) {
370
367
  headers2["Authorization"] = authorizationToken.startsWith("Bearer ") ? authorizationToken : `Bearer ${authorizationToken}`;
371
368
  return headers2;
372
369
  }
373
- async function postSignIntentWithRetry(endpoint, request, opts) {
374
- const url = `${opts.baseApiUrl.replace(/\/$/, "")}${endpoint}`;
375
- return withRetry(
370
+ async function apiSignIntentV3(request, opts) {
371
+ const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent`;
372
+ const json = await withRetry(
376
373
  async () => {
377
374
  let res;
378
375
  try {
@@ -382,7 +379,10 @@ async function postSignIntentWithRetry(endpoint, request, opts) {
382
379
  body: JSON.stringify(request)
383
380
  });
384
381
  } catch (error) {
385
- throw new NetworkError("Failed to connect to API server", { endpoint, error });
382
+ throw new NetworkError("Failed to connect to API server", {
383
+ endpoint: "/v3/intent",
384
+ error
385
+ });
386
386
  }
387
387
  if (!res.ok) {
388
388
  const text = await res.text().catch(() => "");
@@ -394,9 +394,6 @@ async function postSignIntentWithRetry(endpoint, request, opts) {
394
394
  1e3,
395
395
  opts.timeoutMs
396
396
  );
397
- }
398
- async function apiSignIntentV3(request, opts) {
399
- const json = await postSignIntentWithRetry("/v3/intent", request, opts);
400
397
  const sig = json?.responseObject?.signedIntent;
401
398
  const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
402
399
  const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
@@ -407,22 +404,6 @@ async function apiSignIntentV3(request, opts) {
407
404
  preIntentHookData
408
405
  };
409
406
  }
410
- async function apiSignIntentV2(request, opts) {
411
- const json = await postSignIntentWithRetry(
412
- "/v2/verify/intent",
413
- request,
414
- opts
415
- );
416
- const sig = json?.responseObject?.signedIntent;
417
- const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
418
- const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
419
- if (!sig || !expStr) throw new Error("verify/intent missing signature or expiration");
420
- return {
421
- signature: sig,
422
- signatureExpiration: BigInt(expStr),
423
- preIntentHookData
424
- };
425
- }
426
407
 
427
408
  // src/adapters/attestation.ts
428
409
  function headers() {
@@ -810,59 +791,7 @@ function resolvePlatformAttestationConfig(platformName) {
810
791
  return config;
811
792
  }
812
793
 
813
- // src/utils/logger.ts
814
- var currentLevel = "info";
815
- function setLogLevel(level) {
816
- currentLevel = level;
817
- }
818
- function shouldLog(level) {
819
- switch (currentLevel) {
820
- case "debug":
821
- return true;
822
- case "info":
823
- return level !== "debug";
824
- case "error":
825
- return level === "error";
826
- default:
827
- return true;
828
- }
829
- }
830
- var logger = {
831
- debug: (...args) => {
832
- if (shouldLog("debug")) {
833
- console.log("[DEBUG]", ...args);
834
- }
835
- },
836
- info: (...args) => {
837
- if (shouldLog("info")) {
838
- console.log("[INFO]", ...args);
839
- }
840
- },
841
- warn: (...args) => {
842
- if (shouldLog("info")) {
843
- console.warn("[WARN]", ...args);
844
- }
845
- },
846
- error: (...args) => {
847
- console.error("[ERROR]", ...args);
848
- }
849
- };
850
-
851
794
  // src/client/IntentOperations.ts
852
- function isV2SignalIntentAbi(abi) {
853
- for (const item of abi) {
854
- if (item.type === "function" && item.name === "signalIntent" && Array.isArray(item.inputs)) {
855
- const inputs = item.inputs;
856
- for (const input of inputs) {
857
- if (input.components) {
858
- if (input.components.some((c) => c.name === "referralFees")) return true;
859
- if (input.components.some((c) => c.name === "referrerFee")) return false;
860
- }
861
- }
862
- }
863
- }
864
- return true;
865
- }
866
795
  var IntentOperations = class {
867
796
  constructor(config) {
868
797
  this.config = config;
@@ -877,18 +806,14 @@ var IntentOperations = class {
877
806
  "signalIntent referrerFeeConfig cannot be combined with referralFees, referrer, or referrerFee."
878
807
  );
879
808
  }
880
- const preferV2 = this.config.getDefaultPreferV2();
881
809
  const escrowContext = this.config.host.resolveEscrowContext({
882
810
  escrowAddress: params.escrowAddress,
883
- depositId: params.depositId,
884
- preferV2
811
+ depositId: params.depositId
885
812
  });
886
813
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
887
814
  orchestratorAddress: params.orchestratorAddress,
888
- escrowAddress: escrowContext.address,
889
- preferV2
815
+ escrowAddress: escrowContext.address
890
816
  });
891
- const useV2Encoding = isV2SignalIntentAbi(orchestratorContext.abi);
892
817
  const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
893
818
  const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
894
819
  const fiatCurrency = resolveFiatCurrencyBytes32(params.fiatCurrencyCode);
@@ -907,28 +832,25 @@ var IntentOperations = class {
907
832
  const apiKey = this.config.getApiKey();
908
833
  const authorizationToken = this.config.getAuthorizationToken();
909
834
  if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl && (apiKey || authorizationToken)) {
910
- const baseRequest = {
911
- processorName: params.processorName,
912
- payeeDetails: params.payeeDetails,
913
- depositId: depositId.toString(),
914
- amount: amount.toString(),
915
- toAddress: params.toAddress,
916
- paymentMethod,
917
- fiatCurrency,
918
- conversionRate: conversionRate.toString(),
919
- chainId: this.config.getChainId().toString(),
920
- orchestratorAddress: orchestratorContext.address,
921
- escrowAddress: escrowContext.address
922
- };
923
835
  const apiOpts = {
924
836
  baseApiUrl,
925
837
  apiKey,
926
838
  authorizationToken,
927
839
  timeoutMs: this.config.getApiTimeoutMs()
928
840
  };
929
- const response = useV2Encoding ? await apiSignIntentV3(
841
+ const response = await apiSignIntentV3(
930
842
  {
931
- ...baseRequest,
843
+ processorName: params.processorName,
844
+ payeeDetails: params.payeeDetails,
845
+ depositId: depositId.toString(),
846
+ amount: amount.toString(),
847
+ toAddress: params.toAddress,
848
+ paymentMethod,
849
+ fiatCurrency,
850
+ conversionRate: conversionRate.toString(),
851
+ chainId: this.config.getChainId().toString(),
852
+ orchestratorAddress: orchestratorContext.address,
853
+ escrowAddress: escrowContext.address,
932
854
  callerAddress: this.config.getWalletClient().account.address,
933
855
  referralFees: referralFees.map((referralFee) => ({
934
856
  recipient: referralFee.recipient,
@@ -936,7 +858,7 @@ var IntentOperations = class {
936
858
  }))
937
859
  },
938
860
  apiOpts
939
- ) : await apiSignIntentV2(baseRequest, apiOpts);
861
+ );
940
862
  gatingServiceSignature = response.signature;
941
863
  signatureExpiration = response.signatureExpiration;
942
864
  preIntentHookData = response.preIntentHookData ?? preIntentHookData;
@@ -944,31 +866,22 @@ var IntentOperations = class {
944
866
  if (!gatingServiceSignature || !signatureExpiration) {
945
867
  throw new Error("Missing gatingServiceSignature/signatureExpiration");
946
868
  }
947
- const commonFields = {
948
- escrow: escrowContext.address,
949
- depositId,
950
- amount,
951
- to: params.toAddress,
952
- paymentMethod,
953
- fiatCurrency,
954
- conversionRate,
955
- gatingServiceSignature,
956
- signatureExpiration: typeof signatureExpiration === "bigint" ? signatureExpiration : BigInt(signatureExpiration),
957
- postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
958
- data: params.data ?? "0x"
959
- };
960
- const args = useV2Encoding ? [
869
+ const args = [
961
870
  {
962
- ...commonFields,
871
+ escrow: escrowContext.address,
872
+ depositId,
873
+ amount,
874
+ to: params.toAddress,
875
+ paymentMethod,
876
+ fiatCurrency,
877
+ conversionRate,
878
+ gatingServiceSignature,
879
+ signatureExpiration: typeof signatureExpiration === "bigint" ? signatureExpiration : BigInt(signatureExpiration),
880
+ postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
881
+ data: params.data ?? "0x",
963
882
  referralFees,
964
883
  preIntentHookData: preIntentHookData ?? "0x"
965
884
  }
966
- ] : [
967
- {
968
- ...commonFields,
969
- referrer: referralFees[0]?.recipient ?? ZERO_ADDRESS,
970
- referrerFee: referralFees[0]?.fee ?? 0n
971
- }
972
885
  ];
973
886
  const { referrer } = params.txOverrides ?? {};
974
887
  const data = encodeWithAttribution(
@@ -992,8 +905,7 @@ var IntentOperations = class {
992
905
  async prepareCancelIntent(params) {
993
906
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
994
907
  orchestratorAddress: params.orchestratorAddress,
995
- intentHash: params.intentHash,
996
- preferV2: this.config.getDefaultPreferV2()
908
+ intentHash: params.intentHash
997
909
  });
998
910
  const args = [params.intentHash];
999
911
  const { referrer } = params.txOverrides ?? {};
@@ -1018,8 +930,7 @@ var IntentOperations = class {
1018
930
  async prepareReleaseFundsToPayer(params) {
1019
931
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1020
932
  orchestratorAddress: params.orchestratorAddress,
1021
- intentHash: params.intentHash,
1022
- preferV2: this.config.getDefaultPreferV2()
933
+ intentHash: params.intentHash
1023
934
  });
1024
935
  const args = [params.intentHash];
1025
936
  const { referrer } = params.txOverrides ?? {};
@@ -1045,13 +956,11 @@ var IntentOperations = class {
1045
956
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
1046
957
  params.escrowAddress,
1047
958
  params.depositId,
1048
- "setDepositPreIntentHook",
1049
- { preferV2: this.config.getDefaultPreferV2() }
959
+ "setDepositPreIntentHook"
1050
960
  );
1051
961
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1052
962
  orchestratorAddress: params.orchestratorAddress,
1053
- escrowAddress,
1054
- preferV2: this.config.getDefaultPreferV2()
963
+ escrowAddress
1055
964
  });
1056
965
  return this.config.host.prepareResolvedOrchestratorTransaction({
1057
966
  orchestrator: orchestratorContext,
@@ -1064,13 +973,11 @@ var IntentOperations = class {
1064
973
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
1065
974
  params.escrowAddress,
1066
975
  params.depositId,
1067
- "setDepositWhitelistHook",
1068
- { preferV2: this.config.getDefaultPreferV2() }
976
+ "setDepositWhitelistHook"
1069
977
  );
1070
978
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1071
979
  orchestratorAddress: params.orchestratorAddress,
1072
- escrowAddress,
1073
- preferV2: this.config.getDefaultPreferV2()
980
+ escrowAddress
1074
981
  });
1075
982
  return this.config.host.prepareResolvedOrchestratorTransaction({
1076
983
  orchestrator: orchestratorContext,
@@ -1082,8 +989,7 @@ var IntentOperations = class {
1082
989
  async prepareCleanupOrphanedIntents(params) {
1083
990
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1084
991
  orchestratorAddress: params.orchestratorAddress,
1085
- escrowAddress: params.escrowAddress,
1086
- preferV2: this.config.getDefaultPreferV2()
992
+ escrowAddress: params.escrowAddress
1087
993
  });
1088
994
  return this.config.host.prepareResolvedOrchestratorTransaction({
1089
995
  orchestrator: orchestratorContext,
@@ -1096,13 +1002,11 @@ var IntentOperations = class {
1096
1002
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
1097
1003
  options?.escrowAddress,
1098
1004
  depositId,
1099
- "getDepositPreIntentHook",
1100
- { preferV2: this.config.getDefaultPreferV2() }
1005
+ "getDepositPreIntentHook"
1101
1006
  );
1102
1007
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1103
1008
  orchestratorAddress: options?.orchestratorAddress,
1104
- escrowAddress,
1105
- preferV2: this.config.getDefaultPreferV2()
1009
+ escrowAddress
1106
1010
  });
1107
1011
  const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
1108
1012
  "getDepositPreIntentHook"
@@ -1118,13 +1022,11 @@ var IntentOperations = class {
1118
1022
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
1119
1023
  options?.escrowAddress,
1120
1024
  depositId,
1121
- "getDepositWhitelistHook",
1122
- { preferV2: this.config.getDefaultPreferV2() }
1025
+ "getDepositWhitelistHook"
1123
1026
  );
1124
1027
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1125
1028
  orchestratorAddress: options?.orchestratorAddress,
1126
- escrowAddress,
1127
- preferV2: this.config.getDefaultPreferV2()
1029
+ escrowAddress
1128
1030
  });
1129
1031
  const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
1130
1032
  "getDepositWhitelistHook"
@@ -1140,8 +1042,7 @@ var IntentOperations = class {
1140
1042
  const intentHash = params.intentHash;
1141
1043
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
1142
1044
  orchestratorAddress: params.orchestratorAddress,
1143
- intentHash,
1144
- preferV2: this.config.getDefaultPreferV2()
1045
+ intentHash
1145
1046
  });
1146
1047
  const precomputed = params.precomputedAttestation;
1147
1048
  let paymentProof;
@@ -1154,7 +1055,9 @@ var IntentOperations = class {
1154
1055
  verificationData = precomputed.verificationData;
1155
1056
  } else {
1156
1057
  const attestationServiceUrl = params.attestationServiceUrl ?? this.defaultAttestationService();
1157
- const inputs = await this.config.host.getFulfillIntentInputs(intentHash);
1058
+ const inputs = await this.config.host.getFulfillIntentInputs(intentHash, {
1059
+ orchestratorAddress: orchestratorContext.address
1060
+ });
1158
1061
  const paymentMethodHash = inputs.paymentMethodHash || "0x";
1159
1062
  const catalog = getPaymentMethodsCatalog(
1160
1063
  this.config.getChainId(),
@@ -1224,31 +1127,30 @@ var IntentOperations = class {
1224
1127
  defaultAttestationService() {
1225
1128
  return this.config.getRuntimeEnv() === "staging" ? "https://attestation-service-staging.zkp2p.xyz" : "https://attestation-service.zkp2p.xyz";
1226
1129
  }
1227
- async getFulfillIntentInputs(intentHash) {
1228
- try {
1229
- if (this.config.getProtocolViewerAddress() && this.config.getProtocolViewerAbi()) {
1230
- const view = await this.config.host.getPvIntent(intentHash);
1231
- const paymentMethodHash = view.intent.paymentMethod.toLowerCase();
1232
- const matched = (view.deposit.paymentMethods || []).find(
1233
- (pm) => pm.paymentMethod?.toLowerCase?.() === paymentMethodHash
1234
- );
1235
- const payee2 = matched?.verificationData?.payeeDetails;
1236
- if (payee2) {
1237
- return {
1238
- amount: view.intent.amount.toString(),
1239
- fiatCurrency: view.intent.fiatCurrency,
1240
- conversionRate: view.intent.conversionRate.toString(),
1241
- payeeDetails: payee2,
1242
- intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
1243
- paymentMethodHash: view.intent.paymentMethod
1244
- };
1130
+ async getFulfillIntentInputs(intentHash, options) {
1131
+ const isCurrentOrchestrator = !options?.orchestratorAddress || options.orchestratorAddress.toLowerCase() === this.config.getOrchestratorV2Address()?.toLowerCase();
1132
+ if (isCurrentOrchestrator) {
1133
+ try {
1134
+ if (this.config.getProtocolViewerAddress() && this.config.getProtocolViewerAbi()) {
1135
+ const view = await this.config.host.getPvIntent(intentHash);
1136
+ const paymentMethodHash = view.intent.paymentMethod.toLowerCase();
1137
+ const matched = (view.deposit.paymentMethods || []).find(
1138
+ (pm) => pm.paymentMethod?.toLowerCase?.() === paymentMethodHash
1139
+ );
1140
+ const payee2 = matched?.verificationData?.payeeDetails;
1141
+ if (payee2) {
1142
+ return {
1143
+ amount: view.intent.amount.toString(),
1144
+ fiatCurrency: view.intent.fiatCurrency,
1145
+ conversionRate: view.intent.conversionRate.toString(),
1146
+ payeeDetails: payee2,
1147
+ intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
1148
+ paymentMethodHash: view.intent.paymentMethod
1149
+ };
1150
+ }
1245
1151
  }
1152
+ } catch {
1246
1153
  }
1247
- } catch (error) {
1248
- logger.debug("ProtocolViewer lookup failed, falling back to indexer", {
1249
- intentHash,
1250
- error: error instanceof Error ? error.message : String(error)
1251
- });
1252
1154
  }
1253
1155
  const response = await this.config.getIndexerClient().query({
1254
1156
  query: (
@@ -1537,7 +1439,7 @@ var ProtocolViewerReader = class {
1537
1439
  if (inputCount === null) {
1538
1440
  throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
1539
1441
  }
1540
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
1442
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1541
1443
  if (inputCount >= 3) {
1542
1444
  return tryContexts(
1543
1445
  protocolViewerContexts,
@@ -1616,7 +1518,7 @@ var ProtocolViewerReader = class {
1616
1518
  return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
1617
1519
  }
1618
1520
  const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
1619
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
1521
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1620
1522
  if (inputCount >= 2) {
1621
1523
  const requests = ids.map((id, index) => ({
1622
1524
  index,
@@ -1721,7 +1623,7 @@ var ProtocolViewerReader = class {
1721
1623
  if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
1722
1624
  return this.config.host.getPvAccountDepositsFromIndexer(owner);
1723
1625
  }
1724
- const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
1626
+ const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1725
1627
  const { address, abi } = this.config.host.requireProtocolViewer();
1726
1628
  if (inputCount >= 2) {
1727
1629
  const readAndFilter = async (raw2) => {
@@ -1792,7 +1694,7 @@ var ProtocolViewerReader = class {
1792
1694
  if (protocolViewerEntries.length === 0) {
1793
1695
  throw new Error("ProtocolViewer not available for this network");
1794
1696
  }
1795
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
1697
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1796
1698
  const intentsByHash = /* @__PURE__ */ new Map();
1797
1699
  let attemptedRead = false;
1798
1700
  let hadSuccessfulRead = false;
@@ -1900,7 +1802,7 @@ var ProtocolViewerReader = class {
1900
1802
  if (protocolViewerEntries.length === 0) {
1901
1803
  throw new Error("ProtocolViewer not available for this network");
1902
1804
  }
1903
- const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
1805
+ const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-TPB47QOH.mjs');
1904
1806
  let lastError;
1905
1807
  for (const pvEntry of protocolViewerEntries) {
1906
1808
  const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
@@ -1962,8 +1864,7 @@ var VaultOperations = class {
1962
1864
  }
1963
1865
  supportsInlineOracleRateConfig(params) {
1964
1866
  const escrowContext = this.config.host.resolveEscrowContext({
1965
- escrowAddress: params?.escrowAddress,
1966
- preferV2: params?.preferV2
1867
+ escrowAddress: params?.escrowAddress
1967
1868
  });
1968
1869
  return escrowCurrencyHasOracleConfig(escrowContext.abi);
1969
1870
  }
@@ -2080,8 +1981,7 @@ var VaultOperations = class {
2080
1981
  prepareSetOracleRateConfigTransaction(params) {
2081
1982
  const escrowContext = this.config.host.resolveEscrowContext({
2082
1983
  escrowAddress: params.escrowAddress,
2083
- depositId: params.depositId,
2084
- preferV2: true
1984
+ depositId: params.depositId
2085
1985
  });
2086
1986
  if (escrowContext.version !== "v2") {
2087
1987
  throw new Error("setOracleRateConfig requires EscrowV2");
@@ -2103,8 +2003,7 @@ var VaultOperations = class {
2103
2003
  prepareRemoveOracleRateConfigTransaction(params) {
2104
2004
  const escrowContext = this.config.host.resolveEscrowContext({
2105
2005
  escrowAddress: params.escrowAddress,
2106
- depositId: params.depositId,
2107
- preferV2: true
2006
+ depositId: params.depositId
2108
2007
  });
2109
2008
  if (escrowContext.version !== "v2") {
2110
2009
  throw new Error("removeOracleRateConfig requires EscrowV2");
@@ -2121,8 +2020,7 @@ var VaultOperations = class {
2121
2020
  prepareSetOracleRateConfigBatchTransaction(params) {
2122
2021
  const escrowContext = this.config.host.resolveEscrowContext({
2123
2022
  escrowAddress: params.escrowAddress,
2124
- depositId: params.depositId,
2125
- preferV2: true
2023
+ depositId: params.depositId
2126
2024
  });
2127
2025
  if (escrowContext.version !== "v2") {
2128
2026
  throw new Error("setOracleRateConfigBatch requires EscrowV2");
@@ -2144,8 +2042,7 @@ var VaultOperations = class {
2144
2042
  prepareUpdateCurrencyConfigBatchTransaction(params) {
2145
2043
  const escrowContext = this.config.host.resolveEscrowContext({
2146
2044
  escrowAddress: params.escrowAddress,
2147
- depositId: params.depositId,
2148
- preferV2: true
2045
+ depositId: params.depositId
2149
2046
  });
2150
2047
  if (escrowContext.version !== "v2") {
2151
2048
  throw new Error("updateCurrencyConfigBatch requires EscrowV2");
@@ -2173,8 +2070,7 @@ var VaultOperations = class {
2173
2070
  prepareDeactivateCurrenciesBatchTransaction(params) {
2174
2071
  const escrowContext = this.config.host.resolveEscrowContext({
2175
2072
  escrowAddress: params.escrowAddress,
2176
- depositId: params.depositId,
2177
- preferV2: true
2073
+ depositId: params.depositId
2178
2074
  });
2179
2075
  if (escrowContext.version !== "v2") {
2180
2076
  throw new Error("deactivateCurrenciesBatch requires EscrowV2");
@@ -2465,6 +2361,7 @@ var DEPOSIT_FIELDS = `
2465
2361
  timestamp
2466
2362
  txHash
2467
2363
  updatedAt
2364
+ whitelistHookAddress
2468
2365
  `;
2469
2366
  var LEGACY_DEPOSIT_FIELDS = `
2470
2367
  id
@@ -3455,6 +3352,35 @@ var DEPOSIT_DAILY_SNAPSHOTS_QUERY = (
3455
3352
  }
3456
3353
  `
3457
3354
  );
3355
+ var PROFIT_SNAPSHOTS_BY_DEPOSITS_QUERY = (
3356
+ /* GraphQL */
3357
+ `
3358
+ query GetProfitSnapshotsByDeposits($depositIds: [String!]) {
3359
+ profitSnapshots: MakerProfitSnapshot(
3360
+ where: { depositId: { _in: $depositIds } }
3361
+ order_by: { createdAt: desc }
3362
+ ) {
3363
+ id
3364
+ chainId
3365
+ maker
3366
+ intentId
3367
+ depositId
3368
+ fiatCurrency
3369
+ quoteConversionRate
3370
+ oracleRate
3371
+ spreadBps
3372
+ amount
3373
+ notionalFiatUsdCents
3374
+ feeUsd
3375
+ realizedProfitUsdCents
3376
+ priceSnapshotId
3377
+ status
3378
+ createdAt
3379
+ updatedAt
3380
+ }
3381
+ }
3382
+ `
3383
+ );
3458
3384
  var FULFILLMENT_AND_PAYMENT_QUERY = (
3459
3385
  /* GraphQL */
3460
3386
  `
@@ -3565,7 +3491,7 @@ function convertIndexerDepositToEscrowView(deposit, _chainId, _escrowAddress) {
3565
3491
  }
3566
3492
  function convertDepositsForLiquidity(deposits, chainId, escrowAddress) {
3567
3493
  return deposits.filter(
3568
- (d) => d.depositor && d.depositor.toLowerCase() !== ZERO && d.acceptingIntents && toBigInt(d.remainingDeposits) > 0n && d.status === "ACTIVE"
3494
+ (d) => d.depositor && d.depositor.toLowerCase() !== ZERO && normalizeAddress2(d.whitelistHookAddress).toLowerCase() === ZERO && d.acceptingIntents && toBigInt(d.remainingDeposits) > 0n && d.status === "ACTIVE"
3569
3495
  ).map((d) => convertIndexerDepositToEscrowView(d));
3570
3496
  }
3571
3497
  function convertIndexerIntentsToEscrowViews(intents, depositViewsById) {
@@ -3681,14 +3607,16 @@ var IndexerDepositService = class {
3681
3607
  const where = {};
3682
3608
  if (params.depositIds?.length) where.depositId = { _in: params.depositIds };
3683
3609
  if (params.owner) where.owner = { _ilike: params.owner };
3610
+ if (params.rateManagerId) where.rateManagerId = { _ilike: params.rateManagerId };
3684
3611
  if (params.statuses?.length) where.status = { _in: params.statuses };
3685
3612
  if (!Object.keys(where).length) return [];
3613
+ const orderByField = params.orderByField ?? "signalTimestamp";
3686
3614
  const result = await this.queryWithLegacyFallback({
3687
3615
  query: INTENTS_QUERY,
3688
3616
  legacyQuery: LEGACY_INTENTS_QUERY,
3689
3617
  variables: {
3690
3618
  where,
3691
- order_by: [{ signalTimestamp: "desc" }],
3619
+ order_by: [{ [orderByField]: "desc" }],
3692
3620
  limit: params.limit,
3693
3621
  offset: params.offset
3694
3622
  }
@@ -3751,6 +3679,16 @@ var IndexerDepositService = class {
3751
3679
  if (!owner) return [];
3752
3680
  return this.fetchIntents({ owner, statuses });
3753
3681
  }
3682
+ async fetchIntentsByRateManager(rateManagerId, statuses) {
3683
+ const normalizedRateManagerId = rateManagerId?.trim();
3684
+ if (!normalizedRateManagerId) return [];
3685
+ return this.fetchIntents({
3686
+ rateManagerId: normalizedRateManagerId,
3687
+ statuses,
3688
+ limit: 500,
3689
+ orderByField: "fulfillTimestamp"
3690
+ });
3691
+ }
3754
3692
  async fetchIntentByHash(intentHash) {
3755
3693
  if (!intentHash) return null;
3756
3694
  const result = await this.queryWithLegacyFallback({
@@ -3972,11 +3910,32 @@ var IndexerDepositService = class {
3972
3910
  return [];
3973
3911
  }
3974
3912
  }
3913
+ async fetchProfitSnapshotsByDeposits(depositIds) {
3914
+ const normalizedDepositIds = Array.from(
3915
+ new Set(
3916
+ depositIds.map((depositId) => depositId?.trim()).filter((depositId) => Boolean(depositId))
3917
+ )
3918
+ );
3919
+ if (!normalizedDepositIds.length) return [];
3920
+ try {
3921
+ const result = await this.client.query({
3922
+ query: PROFIT_SNAPSHOTS_BY_DEPOSITS_QUERY,
3923
+ variables: { depositIds: normalizedDepositIds }
3924
+ });
3925
+ return result.profitSnapshots ?? result.MakerProfitSnapshot ?? [];
3926
+ } catch (error) {
3927
+ if (!isSchemaCompatibilityError(error)) {
3928
+ throw error;
3929
+ }
3930
+ return [];
3931
+ }
3932
+ }
3975
3933
  };
3976
3934
 
3977
3935
  // src/indexer/rateManagerService.ts
3978
3936
  var DEFAULT_LIMIT2 = 50;
3979
3937
  var RATE_MANAGER_HISTORY_PAGE_SIZE = 250;
3938
+ var EVM_ADDRESS_REGEX = /^0x[a-f0-9]{40}$/;
3980
3939
  function normalizeRateManagerId2(value) {
3981
3940
  if (!value) return "";
3982
3941
  return value.toLowerCase();
@@ -3985,6 +3944,9 @@ function normalizeAddress3(value) {
3985
3944
  if (!value) return "";
3986
3945
  return value.toLowerCase();
3987
3946
  }
3947
+ function escapeLikePatternLiteral(value) {
3948
+ return value.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
3949
+ }
3988
3950
  function parseScopedRateManagerFilterId(value) {
3989
3951
  const trimmed = value.trim().toLowerCase();
3990
3952
  if (!trimmed) return null;
@@ -3992,7 +3954,7 @@ function parseScopedRateManagerFilterId(value) {
3992
3954
  if (separatorIndex <= 0) return null;
3993
3955
  const rateManagerAddress = normalizeAddress3(trimmed.slice(0, separatorIndex));
3994
3956
  const rateManagerId = normalizeRateManagerId2(trimmed.slice(separatorIndex + 1));
3995
- if (!rateManagerAddress.startsWith("0x") || !rateManagerId) {
3957
+ if (!EVM_ADDRESS_REGEX.test(rateManagerAddress) || !rateManagerId) {
3996
3958
  return null;
3997
3959
  }
3998
3960
  return { rateManagerAddress, rateManagerId };
@@ -4010,12 +3972,14 @@ function extractRateManagerAddressFromScopedId(id) {
4010
3972
  return rateManagerAddress.startsWith("0x") ? rateManagerAddress.toLowerCase() : null;
4011
3973
  }
4012
3974
  function buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress) {
4013
- const normalizedId = normalizeRateManagerId2(rateManagerId);
4014
- const normalizedRateManagerAddress = normalizeAddress3(rateManagerAddress);
4015
- return `%_${normalizedRateManagerAddress}_${normalizedId}`;
3975
+ const normalizedId = escapeLikePatternLiteral(normalizeRateManagerId2(rateManagerId));
3976
+ const normalizedRateManagerAddress = escapeLikePatternLiteral(
3977
+ normalizeAddress3(rateManagerAddress)
3978
+ );
3979
+ return `%\\_${normalizedRateManagerAddress}\\_${normalizedId}`;
4016
3980
  }
4017
3981
  function buildRateManagerScopedIdPattern(rateManagerId, rateManagerAddress) {
4018
- return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}_%`;
3982
+ return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}\\_%`;
4019
3983
  }
4020
3984
  function normalizeCompositeDepositId(depositId, escrowAddress) {
4021
3985
  const normalizedDepositId = depositId.trim().toLowerCase();
@@ -4050,6 +4014,9 @@ function parseRateManagerFilterIds(rateManagerIds) {
4050
4014
  );
4051
4015
  continue;
4052
4016
  }
4017
+ if (value.includes(":")) {
4018
+ continue;
4019
+ }
4053
4020
  const normalizedRateManagerId = normalizeRateManagerId2(value);
4054
4021
  if (normalizedRateManagerId) {
4055
4022
  bare.add(normalizedRateManagerId);
@@ -4588,21 +4555,12 @@ var IndexerRateManagerService = class {
4588
4555
  async fetchManualRateUpdates(rateManagerId, options) {
4589
4556
  if (!rateManagerId) return [];
4590
4557
  const normalizedId = normalizeRateManagerId2(rateManagerId);
4591
- const normalizedRateManagerAddress = normalizeAddress3(options?.rateManagerAddress);
4592
4558
  try {
4593
4559
  const result = await this.client.query({
4594
4560
  query: MANUAL_RATE_UPDATES_QUERY,
4595
4561
  variables: {
4596
4562
  where: {
4597
- rateManagerId: { _eq: normalizedId },
4598
- ...normalizedRateManagerAddress ? {
4599
- id: {
4600
- _ilike: buildRateManagerScopedIdPattern(
4601
- normalizedId,
4602
- normalizedRateManagerAddress
4603
- )
4604
- }
4605
- } : {}
4563
+ rateManagerId: { _eq: normalizedId }
4606
4564
  },
4607
4565
  order_by: [{ id: "desc" }],
4608
4566
  limit: options?.limit ?? 100
@@ -4676,15 +4634,7 @@ var IndexerRateManagerService = class {
4676
4634
  query: LEGACY_ORACLE_CONFIG_UPDATES_QUERY,
4677
4635
  variables: {
4678
4636
  where: {
4679
- rateManagerId: { _eq: normalizedId },
4680
- ...normalizedRateManagerAddress ? {
4681
- id: {
4682
- _ilike: buildRateManagerScopedIdPattern(
4683
- normalizedId,
4684
- normalizedRateManagerAddress
4685
- )
4686
- }
4687
- } : {}
4637
+ rateManagerId: { _eq: normalizedId }
4688
4638
  },
4689
4639
  order_by: [{ id: "desc" }],
4690
4640
  limit
@@ -6080,13 +6030,13 @@ var Zkp2pClient = class {
6080
6030
  getProtocolViewerAbi: () => this.protocolViewerAbi,
6081
6031
  getIndexerClient: () => this._indexerClient,
6082
6032
  getIndexerService: () => this._indexerService,
6083
- getDefaultPreferV2: () => this._router.defaultPreferV2,
6033
+ getOrchestratorV2Address: () => this.orchestratorV2Address,
6084
6034
  host: {
6085
6035
  resolveEscrowContext: (options) => this.resolveEscrowContext(options),
6086
6036
  resolveOrchestratorContext: (options) => this.resolveOrchestratorContext(options),
6087
- resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName, options) => this.resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName, options),
6037
+ resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName) => this.resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName),
6088
6038
  prepareResolvedOrchestratorTransaction: (tx) => this.prepareResolvedOrchestratorTransaction(tx),
6089
- getFulfillIntentInputs: (intentHash) => this.getFulfillIntentInputs(intentHash),
6039
+ getFulfillIntentInputs: (intentHash, options) => this.getFulfillIntentInputs(intentHash, options),
6090
6040
  getPvIntent: (intentHash) => this.getPvIntent(intentHash)
6091
6041
  }
6092
6042
  });
@@ -6118,8 +6068,7 @@ var Zkp2pClient = class {
6118
6068
  }
6119
6069
  supportsInlineOracleRateConfig(params) {
6120
6070
  return this._vaultOps.supportsInlineOracleRateConfig({
6121
- escrowAddress: params?.escrowAddress,
6122
- preferV2: params?.preferV2 ?? this._router.defaultPreferV2
6071
+ escrowAddress: params?.escrowAddress
6123
6072
  });
6124
6073
  }
6125
6074
  parseManagerFeeFromRead(result) {
@@ -6137,13 +6086,10 @@ var Zkp2pClient = class {
6137
6086
  abiFunctionHasInput(abi, functionName, inputName) {
6138
6087
  return abiFunctionHasInput(abi, functionName, inputName);
6139
6088
  }
6140
- resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName, options) {
6089
+ resolveEscrowAddressOrThrow(escrowAddress, depositId, _methodName) {
6141
6090
  const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
6142
6091
  if (resolved) return resolved;
6143
- if (options?.preferV2 !== void 0) {
6144
- return this.resolveEscrowContext().address;
6145
- }
6146
- throw new Error(`${methodName} requires escrowAddress or composite depositId`);
6092
+ return this.resolveEscrowContext().address;
6147
6093
  }
6148
6094
  prepareCreateRateManagerTransaction(params) {
6149
6095
  return this._vaultOps.prepareCreateRateManagerTransaction(params);
@@ -6231,8 +6177,8 @@ var Zkp2pClient = class {
6231
6177
  getEscrowContexts() {
6232
6178
  return this._router.getEscrowContexts();
6233
6179
  }
6234
- resolveOrchestratorForEscrow(escrowAddress, preferV2 = false) {
6235
- return this._router.resolveOrchestratorForEscrow(escrowAddress, preferV2);
6180
+ resolveOrchestratorForEscrow(escrowAddress) {
6181
+ return this._router.resolveOrchestratorForEscrow(escrowAddress);
6236
6182
  }
6237
6183
  async lookupIntentRouting(intentHash) {
6238
6184
  try {
@@ -6266,12 +6212,8 @@ var Zkp2pClient = class {
6266
6212
  try {
6267
6213
  const view = await this.getPvIntent(intentHash);
6268
6214
  return this.normalizeAddress(view?.intent?.escrow);
6269
- } catch (error) {
6270
- if (error instanceof Error && error.message === "Intent not found") {
6271
- return void 0;
6272
- }
6273
- const message = error instanceof Error ? error.message : "Unknown on-chain routing error";
6274
- throw new Error(`Failed to resolve intent escrow on-chain for ${intentHash}: ${message}`);
6215
+ } catch {
6216
+ return void 0;
6275
6217
  }
6276
6218
  }
6277
6219
  warnOrchestratorFallback(intentHash, source, error) {
@@ -6295,10 +6237,7 @@ var Zkp2pClient = class {
6295
6237
  const fromIntent = this.getOrchestratorContextByAddress(routing.orchestratorAddress);
6296
6238
  if (fromIntent) return fromIntent;
6297
6239
  if (routing.escrowAddress) {
6298
- const fromIntentEscrow = this.resolveOrchestratorForEscrow(
6299
- routing.escrowAddress,
6300
- options.preferV2
6301
- );
6240
+ const fromIntentEscrow = this.resolveOrchestratorForEscrow(routing.escrowAddress);
6302
6241
  if (fromIntentEscrow) return fromIntentEscrow;
6303
6242
  }
6304
6243
  } catch (error) {
@@ -6307,10 +6246,7 @@ var Zkp2pClient = class {
6307
6246
  try {
6308
6247
  const onchainEscrow = await this.lookupIntentEscrowOnchain(options.intentHash);
6309
6248
  if (onchainEscrow) {
6310
- const fromOnchainEscrow = this.resolveOrchestratorForEscrow(
6311
- onchainEscrow,
6312
- options.preferV2
6313
- );
6249
+ const fromOnchainEscrow = this.resolveOrchestratorForEscrow(onchainEscrow);
6314
6250
  if (fromOnchainEscrow) return fromOnchainEscrow;
6315
6251
  }
6316
6252
  } catch (error) {
@@ -6318,7 +6254,7 @@ var Zkp2pClient = class {
6318
6254
  }
6319
6255
  }
6320
6256
  if (options?.escrowAddress) {
6321
- const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress, options.preferV2);
6257
+ const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress);
6322
6258
  if (fromEscrow) return fromEscrow;
6323
6259
  }
6324
6260
  if (options?.intentHash) {
@@ -6336,7 +6272,7 @@ var Zkp2pClient = class {
6336
6272
  }
6337
6273
  }
6338
6274
  }
6339
- const fallback = this.resolveOrchestratorForEscrow(void 0, options?.preferV2);
6275
+ const fallback = this.resolveOrchestratorForEscrow();
6340
6276
  if (fallback) return fallback;
6341
6277
  throw new Error("Orchestrator not available");
6342
6278
  }
@@ -6556,8 +6492,7 @@ var Zkp2pClient = class {
6556
6492
  async (params) => {
6557
6493
  const orchestratorContext = await this.resolveOrchestratorContext({
6558
6494
  orchestratorAddress: params.orchestratorAddress,
6559
- escrowAddress: params.escrowAddress,
6560
- preferV2: params.preferV2
6495
+ escrowAddress: params.escrowAddress
6561
6496
  });
6562
6497
  const prepared = this.prepareOrchestratorTransaction({
6563
6498
  functionName,
@@ -6573,8 +6508,7 @@ var Zkp2pClient = class {
6573
6508
  prepare: async (params) => {
6574
6509
  const orchestratorContext = await this.resolveOrchestratorContext({
6575
6510
  orchestratorAddress: params.orchestratorAddress,
6576
- escrowAddress: params.escrowAddress,
6577
- preferV2: params.preferV2
6511
+ escrowAddress: params.escrowAddress
6578
6512
  });
6579
6513
  const prepared = this.prepareOrchestratorTransaction({
6580
6514
  functionName,
@@ -6783,6 +6717,12 @@ var Zkp2pClient = class {
6783
6717
  getOwnerIntents: (owner, statuses) => {
6784
6718
  return service.fetchIntentsByOwner(owner, statuses);
6785
6719
  },
6720
+ /**
6721
+ * Fetches fulfilled intents for a vault by rate manager ID.
6722
+ */
6723
+ getIntentsByRateManager: (rateManagerId, statuses) => {
6724
+ return service.fetchIntentsByRateManager(rateManagerId, statuses);
6725
+ },
6786
6726
  /**
6787
6727
  * Fetches a single intent by hash.
6788
6728
  */
@@ -6833,6 +6773,12 @@ var Zkp2pClient = class {
6833
6773
  getDepositsByIdsWithRelations: (ids, options) => {
6834
6774
  return service.fetchDepositsByIdsWithRelations(ids, options);
6835
6775
  },
6776
+ /**
6777
+ * Fetches maker profit snapshots for the provided deposits.
6778
+ */
6779
+ getProfitSnapshotsByDeposits: (depositIds) => {
6780
+ return service.fetchProfitSnapshotsByDeposits(depositIds);
6781
+ },
6836
6782
  /**
6837
6783
  * Fetches rate managers (vaults) with aggregate stats.
6838
6784
  */
@@ -6909,7 +6855,6 @@ var Zkp2pClient = class {
6909
6855
  * @param params.amount - Minimum required allowance amount
6910
6856
  * @param params.spender - Spender address override
6911
6857
  * @param params.escrowAddress - Escrow context used for default spender resolution
6912
- * @param params.preferV2 - Prefer EscrowV2 for default spender resolution
6913
6858
  * @param params.maxApprove - If true, approves MaxUint256 instead of exact amount
6914
6859
  * @param params.txOverrides - Optional viem transaction overrides
6915
6860
  * @returns Object with `hadAllowance` (true if no approval needed) and optional `hash`
@@ -6932,8 +6877,7 @@ var Zkp2pClient = class {
6932
6877
  const owner = this.walletClient.account?.address;
6933
6878
  if (!owner) throw new Error("Wallet client is missing account");
6934
6879
  const spender = params.spender ?? this.resolveEscrowContext({
6935
- escrowAddress: params.escrowAddress,
6936
- preferV2: params.preferV2 ?? this._router.defaultPreferV2
6880
+ escrowAddress: params.escrowAddress
6937
6881
  }).address;
6938
6882
  const allowance = await this.publicClient.readContract({
6939
6883
  address: params.token,
@@ -7167,8 +7111,7 @@ var Zkp2pClient = class {
7167
7111
  currencies = mapConversionRatesToOnchainMinRate2(normalized, paymentMethods.length);
7168
7112
  }
7169
7113
  const escrowContext = this.resolveEscrowContext({
7170
- escrowAddress: params.escrowAddress,
7171
- preferV2: this._router.defaultPreferV2
7114
+ escrowAddress: params.escrowAddress
7172
7115
  });
7173
7116
  const normalizedCurrencies = currencies.map(
7174
7117
  (group) => this.normalizeCurrencyTuples(group, escrowContext.abi)
@@ -7488,8 +7431,8 @@ var Zkp2pClient = class {
7488
7431
  * @returns Intent parameters needed for fulfillment
7489
7432
  * @throws Error if intent not found or payee details cannot be resolved
7490
7433
  */
7491
- async getFulfillIntentInputs(intentHash) {
7492
- return this._intentOps.getFulfillIntentInputs(intentHash);
7434
+ async getFulfillIntentInputs(intentHash, options) {
7435
+ return this._intentOps.getFulfillIntentInputs(intentHash, options);
7493
7436
  }
7494
7437
  };
7495
7438
 
@@ -7685,6 +7628,44 @@ var createPeerExtensionSdk = (options = {}) => ({
7685
7628
  });
7686
7629
  var peerExtensionSdk = createPeerExtensionSdk();
7687
7630
 
7631
+ // src/utils/logger.ts
7632
+ var currentLevel = "info";
7633
+ function setLogLevel(level) {
7634
+ currentLevel = level;
7635
+ }
7636
+ function shouldLog(level) {
7637
+ switch (currentLevel) {
7638
+ case "debug":
7639
+ return true;
7640
+ case "info":
7641
+ return level !== "debug";
7642
+ case "error":
7643
+ return level === "error";
7644
+ default:
7645
+ return true;
7646
+ }
7647
+ }
7648
+ var logger = {
7649
+ debug: (...args) => {
7650
+ if (shouldLog("debug")) {
7651
+ console.log("[DEBUG]", ...args);
7652
+ }
7653
+ },
7654
+ info: (...args) => {
7655
+ if (shouldLog("info")) {
7656
+ console.log("[INFO]", ...args);
7657
+ }
7658
+ },
7659
+ warn: (...args) => {
7660
+ if (shouldLog("info")) {
7661
+ console.warn("[WARN]", ...args);
7662
+ }
7663
+ },
7664
+ error: (...args) => {
7665
+ console.error("[ERROR]", ...args);
7666
+ }
7667
+ };
7668
+
7688
7669
  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, 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 };
7689
7670
  //# sourceMappingURL=index.mjs.map
7690
7671
  //# sourceMappingURL=index.mjs.map