@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.cjs CHANGED
@@ -305,13 +305,12 @@ function getContracts(chainId, env = "production") {
305
305
  escrowV2: pickAddress(baseContracts, ["EscrowV2", "Escrow_V2"]),
306
306
  escrowAddresses: uniqueAddresses(
307
307
  pickAddress(baseContracts, ["EscrowV2", "Escrow_V2"]),
308
- ...exports.HISTORICAL_ESCROW_ADDRESSES.base
308
+ pickAddress(baseContracts, ["Escrow"])
309
309
  ),
310
310
  orchestrator: pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]) ?? pickAddress(baseContracts, ["Orchestrator"]),
311
311
  orchestratorV2: pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]),
312
312
  orchestratorAddresses: uniqueAddresses(
313
- pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]),
314
- ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base
313
+ pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"])
315
314
  ),
316
315
  unifiedPaymentVerifier: pickAddress(baseContracts, [
317
316
  "UnifiedPaymentVerifierV2",
@@ -369,28 +368,22 @@ function getContracts(chainId, env = "production") {
369
368
  "VITE_BASE_STAGING_ESCROW_V2_ADDRESS",
370
369
  "VITE_ESCROW_V2_ADDRESS"
371
370
  ]);
372
- const stagingEscrowCurrent = stagingEscrowV2Override ?? pickAddress(sc, ["EscrowV2", "Escrow_V2"]) ?? pickAddress(sc, ["Escrow"]) ?? STAGING_ESCROW_V2_FALLBACK;
371
+ const stagingEscrowCurrent = stagingEscrowV2Override ?? pickAddress(sc, ["EscrowV2", "Escrow_V2"]) ?? pickAddress(sc, ["Escrow"]);
373
372
  const stagingOrchestratorV2Override = resolveRuntimeAddressOverride([
374
373
  "VITE_BASE_STAGING_ORCHESTRATOR_V2_ADDRESS",
375
374
  "VITE_ORCHESTRATOR_V2_ADDRESS",
376
375
  "VITE_ORCHESTRATORV2_ADDRESS"
377
376
  ]);
378
- const stagingOrchestratorCurrent = stagingOrchestratorV2Override ?? pickAddress(sc, ["OrchestratorV2", "Orchestrator_V2"]) ?? pickAddress(sc, ["Orchestrator"]) ?? STAGING_ORCHESTRATOR_V2_FALLBACK;
377
+ const stagingOrchestratorCurrent = stagingOrchestratorV2Override ?? pickAddress(sc, ["OrchestratorV2", "Orchestrator_V2"]) ?? pickAddress(sc, ["Orchestrator"]);
379
378
  const stagingRateManagerV1 = pickAddress(sc, ["RateManagerV1", "DepositRateManagerRegistryV1"]);
380
379
  return {
381
380
  addresses: {
382
381
  escrow: stagingEscrowCurrent,
383
382
  escrowV2: stagingEscrowCurrent,
384
- escrowAddresses: uniqueAddresses(
385
- stagingEscrowCurrent,
386
- ...exports.HISTORICAL_ESCROW_ADDRESSES.base_staging
387
- ),
383
+ escrowAddresses: uniqueAddresses(stagingEscrowCurrent),
388
384
  orchestrator: stagingOrchestratorCurrent,
389
385
  orchestratorV2: stagingOrchestratorCurrent,
390
- orchestratorAddresses: uniqueAddresses(
391
- stagingOrchestratorCurrent,
392
- ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base_staging
393
- ),
386
+ orchestratorAddresses: uniqueAddresses(stagingOrchestratorCurrent),
394
387
  unifiedPaymentVerifier: pickAddress(sc, [
395
388
  "UnifiedPaymentVerifierV2",
396
389
  "UnifiedPaymentVerifier"
@@ -466,10 +459,7 @@ function getPaymentMethodsCatalog(_chainId, env = "production") {
466
459
  const methods = src?.methods ?? {};
467
460
  return methods;
468
461
  }
469
- function getGatingServiceAddress(_chainId, env = "production") {
470
- if (env === "staging") {
471
- return "0x396D31055Db28C0C6f36e8b36f18FE7227248a97";
472
- }
462
+ function getGatingServiceAddress(_chainId, _env = "production") {
473
463
  return "0x396D31055Db28C0C6f36e8b36f18FE7227248a97";
474
464
  }
475
465
  function getRateManagerContracts(chainId, env = "production") {
@@ -492,41 +482,9 @@ function getRateManagerContracts(chainId, env = "production") {
492
482
  }
493
483
  };
494
484
  }
495
- exports.HISTORICAL_ESCROW_ADDRESSES = void 0; var HISTORICAL_ORCHESTRATOR_ADDRESSES, STAGING_ESCROW_V2_FALLBACK, STAGING_ORCHESTRATOR_V2_FALLBACK, ZERO_ADDRESS2, baseAddresses, baseStagingAddresses, basePaymentMethods, baseStagingPaymentMethods, baseConstants, baseStagingConstants;
485
+ var ZERO_ADDRESS2, baseAddresses, baseStagingAddresses, basePaymentMethods, baseStagingPaymentMethods, baseConstants, baseStagingConstants;
496
486
  var init_contracts = __esm({
497
487
  "src/contracts.ts"() {
498
- exports.HISTORICAL_ESCROW_ADDRESSES = {
499
- base: [
500
- "0x2f121CDDCA6d652f35e8B3E560f9760898888888"
501
- // EscrowV2 production (contracts-v2 0.2.0-rc.6)
502
- ],
503
- base_staging: [
504
- "0x5C2a8D9246777eE4501B6C426a8B8C7635C7b5b5",
505
- // EscrowV2 staging (contracts-v2 0.2.0-rc.5)
506
- "0x18EAcBf3FF19528ABe8035CF5cA266F31A2e3f14",
507
- // EscrowV2 staging (contracts-v2 0.1.11-rc.3)
508
- "0x07Cc97c254A5Fb0957553E9F58E4040699357f28",
509
- // EscrowV2 staging (contracts-v2 0.1.11-rc.2)
510
- "0x8455b9a31041125C785044f45458eCf2cbB12eF7",
511
- // v2.1 staging Escrow (2025-10-18, PR #83)
512
- "0x21f007107269ea1c8Fe0730736548090F4945736"
513
- // v2.1 staging Escrow (2025-10-04, PR #71)
514
- ]
515
- };
516
- HISTORICAL_ORCHESTRATOR_ADDRESSES = {
517
- base: [
518
- "0x88888883Ed048FF0a415271B28b2F52d431810D0"
519
- // OrchestratorV2 production (contracts-v2 0.2.0-rc.6)
520
- ],
521
- base_staging: [
522
- "0xF9b9CD27Deea496B960b3cb5221b514705fCaF5e",
523
- // OrchestratorV2 staging (contracts-v2 0.2.0-rc.5)
524
- "0xC0389b3d7A4E6B823e361e562C4a29F04B6C4fB5"
525
- // OrchestratorV2 staging (contracts-v2 0.1.11-rc.3)
526
- ]
527
- };
528
- STAGING_ESCROW_V2_FALLBACK = "0x77e8f808FE201075e0bD651CD46fdF239fc83265";
529
- STAGING_ORCHESTRATOR_V2_FALLBACK = "0xc17a59227B136c45fAa153086a15EF87ED14bE00";
530
488
  ZERO_ADDRESS2 = "0x0000000000000000000000000000000000000000";
531
489
  baseAddresses = unwrapAddresses(baseAddressesRaw__default.default);
532
490
  baseStagingAddresses = unwrapAddresses(baseStagingAddressesRaw__default.default);
@@ -1391,7 +1349,7 @@ var ContractRouter = class {
1391
1349
  }
1392
1350
  ];
1393
1351
  }
1394
- resolveOrchestratorForEscrow(escrowAddress, _preferV2 = false) {
1352
+ resolveOrchestratorForEscrow(escrowAddress) {
1395
1353
  if (escrowAddress) {
1396
1354
  const escrowContext = this.getEscrowContextByAddress(escrowAddress);
1397
1355
  const fromEscrow = this.getOrchestratorContextByAddress(escrowContext?.orchestratorAddress);
@@ -1447,9 +1405,6 @@ var ContractRouter = class {
1447
1405
  }
1448
1406
  return contexts;
1449
1407
  }
1450
- get defaultPreferV2() {
1451
- return true;
1452
- }
1453
1408
  };
1454
1409
 
1455
1410
  // src/adapters/verification.ts
@@ -1503,9 +1458,9 @@ function createHeaders(apiKey, authorizationToken) {
1503
1458
  headers2["Authorization"] = authorizationToken.startsWith("Bearer ") ? authorizationToken : `Bearer ${authorizationToken}`;
1504
1459
  return headers2;
1505
1460
  }
1506
- async function postSignIntentWithRetry(endpoint, request, opts) {
1507
- const url = `${opts.baseApiUrl.replace(/\/$/, "")}${endpoint}`;
1508
- return withRetry(
1461
+ async function apiSignIntentV3(request, opts) {
1462
+ const url = `${opts.baseApiUrl.replace(/\/$/, "")}/v3/intent`;
1463
+ const json = await withRetry(
1509
1464
  async () => {
1510
1465
  let res;
1511
1466
  try {
@@ -1515,7 +1470,10 @@ async function postSignIntentWithRetry(endpoint, request, opts) {
1515
1470
  body: JSON.stringify(request)
1516
1471
  });
1517
1472
  } catch (error) {
1518
- throw new exports.NetworkError("Failed to connect to API server", { endpoint, error });
1473
+ throw new exports.NetworkError("Failed to connect to API server", {
1474
+ endpoint: "/v3/intent",
1475
+ error
1476
+ });
1519
1477
  }
1520
1478
  if (!res.ok) {
1521
1479
  const text = await res.text().catch(() => "");
@@ -1527,9 +1485,6 @@ async function postSignIntentWithRetry(endpoint, request, opts) {
1527
1485
  1e3,
1528
1486
  opts.timeoutMs
1529
1487
  );
1530
- }
1531
- async function apiSignIntentV3(request, opts) {
1532
- const json = await postSignIntentWithRetry("/v3/intent", request, opts);
1533
1488
  const sig = json?.responseObject?.signedIntent;
1534
1489
  const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
1535
1490
  const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
@@ -1540,22 +1495,6 @@ async function apiSignIntentV3(request, opts) {
1540
1495
  preIntentHookData
1541
1496
  };
1542
1497
  }
1543
- async function apiSignIntentV2(request, opts) {
1544
- const json = await postSignIntentWithRetry(
1545
- "/v2/verify/intent",
1546
- request,
1547
- opts
1548
- );
1549
- const sig = json?.responseObject?.signedIntent;
1550
- const expStr = json?.responseObject?.intentData?.signatureExpiration ?? json?.responseObject?.signatureExpiration;
1551
- const preIntentHookData = json?.responseObject?.intentData?.preIntentHookData ?? json?.responseObject?.preIntentHookData;
1552
- if (!sig || !expStr) throw new Error("verify/intent missing signature or expiration");
1553
- return {
1554
- signature: sig,
1555
- signatureExpiration: BigInt(expStr),
1556
- preIntentHookData
1557
- };
1558
- }
1559
1498
 
1560
1499
  // src/adapters/attestation.ts
1561
1500
  init_errors();
@@ -1951,59 +1890,7 @@ function resolvePlatformAttestationConfig(platformName) {
1951
1890
  return config;
1952
1891
  }
1953
1892
 
1954
- // src/utils/logger.ts
1955
- var currentLevel = "info";
1956
- function setLogLevel(level) {
1957
- currentLevel = level;
1958
- }
1959
- function shouldLog(level) {
1960
- switch (currentLevel) {
1961
- case "debug":
1962
- return true;
1963
- case "info":
1964
- return level !== "debug";
1965
- case "error":
1966
- return level === "error";
1967
- default:
1968
- return true;
1969
- }
1970
- }
1971
- var logger = {
1972
- debug: (...args) => {
1973
- if (shouldLog("debug")) {
1974
- console.log("[DEBUG]", ...args);
1975
- }
1976
- },
1977
- info: (...args) => {
1978
- if (shouldLog("info")) {
1979
- console.log("[INFO]", ...args);
1980
- }
1981
- },
1982
- warn: (...args) => {
1983
- if (shouldLog("info")) {
1984
- console.warn("[WARN]", ...args);
1985
- }
1986
- },
1987
- error: (...args) => {
1988
- console.error("[ERROR]", ...args);
1989
- }
1990
- };
1991
-
1992
1893
  // src/client/IntentOperations.ts
1993
- function isV2SignalIntentAbi(abi) {
1994
- for (const item of abi) {
1995
- if (item.type === "function" && item.name === "signalIntent" && Array.isArray(item.inputs)) {
1996
- const inputs = item.inputs;
1997
- for (const input of inputs) {
1998
- if (input.components) {
1999
- if (input.components.some((c) => c.name === "referralFees")) return true;
2000
- if (input.components.some((c) => c.name === "referrerFee")) return false;
2001
- }
2002
- }
2003
- }
2004
- }
2005
- return true;
2006
- }
2007
1894
  var IntentOperations = class {
2008
1895
  constructor(config) {
2009
1896
  this.config = config;
@@ -2018,18 +1905,14 @@ var IntentOperations = class {
2018
1905
  "signalIntent referrerFeeConfig cannot be combined with referralFees, referrer, or referrerFee."
2019
1906
  );
2020
1907
  }
2021
- const preferV2 = this.config.getDefaultPreferV2();
2022
1908
  const escrowContext = this.config.host.resolveEscrowContext({
2023
1909
  escrowAddress: params.escrowAddress,
2024
- depositId: params.depositId,
2025
- preferV2
1910
+ depositId: params.depositId
2026
1911
  });
2027
1912
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2028
1913
  orchestratorAddress: params.orchestratorAddress,
2029
- escrowAddress: escrowContext.address,
2030
- preferV2
1914
+ escrowAddress: escrowContext.address
2031
1915
  });
2032
- const useV2Encoding = isV2SignalIntentAbi(orchestratorContext.abi);
2033
1916
  const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
2034
1917
  const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
2035
1918
  const fiatCurrency = resolveFiatCurrencyBytes32(params.fiatCurrencyCode);
@@ -2048,28 +1931,25 @@ var IntentOperations = class {
2048
1931
  const apiKey = this.config.getApiKey();
2049
1932
  const authorizationToken = this.config.getAuthorizationToken();
2050
1933
  if ((!gatingServiceSignature || !signatureExpiration) && baseApiUrl && (apiKey || authorizationToken)) {
2051
- const baseRequest = {
2052
- processorName: params.processorName,
2053
- payeeDetails: params.payeeDetails,
2054
- depositId: depositId.toString(),
2055
- amount: amount.toString(),
2056
- toAddress: params.toAddress,
2057
- paymentMethod,
2058
- fiatCurrency,
2059
- conversionRate: conversionRate.toString(),
2060
- chainId: this.config.getChainId().toString(),
2061
- orchestratorAddress: orchestratorContext.address,
2062
- escrowAddress: escrowContext.address
2063
- };
2064
1934
  const apiOpts = {
2065
1935
  baseApiUrl,
2066
1936
  apiKey,
2067
1937
  authorizationToken,
2068
1938
  timeoutMs: this.config.getApiTimeoutMs()
2069
1939
  };
2070
- const response = useV2Encoding ? await apiSignIntentV3(
1940
+ const response = await apiSignIntentV3(
2071
1941
  {
2072
- ...baseRequest,
1942
+ processorName: params.processorName,
1943
+ payeeDetails: params.payeeDetails,
1944
+ depositId: depositId.toString(),
1945
+ amount: amount.toString(),
1946
+ toAddress: params.toAddress,
1947
+ paymentMethod,
1948
+ fiatCurrency,
1949
+ conversionRate: conversionRate.toString(),
1950
+ chainId: this.config.getChainId().toString(),
1951
+ orchestratorAddress: orchestratorContext.address,
1952
+ escrowAddress: escrowContext.address,
2073
1953
  callerAddress: this.config.getWalletClient().account.address,
2074
1954
  referralFees: referralFees.map((referralFee) => ({
2075
1955
  recipient: referralFee.recipient,
@@ -2077,7 +1957,7 @@ var IntentOperations = class {
2077
1957
  }))
2078
1958
  },
2079
1959
  apiOpts
2080
- ) : await apiSignIntentV2(baseRequest, apiOpts);
1960
+ );
2081
1961
  gatingServiceSignature = response.signature;
2082
1962
  signatureExpiration = response.signatureExpiration;
2083
1963
  preIntentHookData = response.preIntentHookData ?? preIntentHookData;
@@ -2085,31 +1965,22 @@ var IntentOperations = class {
2085
1965
  if (!gatingServiceSignature || !signatureExpiration) {
2086
1966
  throw new Error("Missing gatingServiceSignature/signatureExpiration");
2087
1967
  }
2088
- const commonFields = {
2089
- escrow: escrowContext.address,
2090
- depositId,
2091
- amount,
2092
- to: params.toAddress,
2093
- paymentMethod,
2094
- fiatCurrency,
2095
- conversionRate,
2096
- gatingServiceSignature,
2097
- signatureExpiration: typeof signatureExpiration === "bigint" ? signatureExpiration : BigInt(signatureExpiration),
2098
- postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
2099
- data: params.data ?? "0x"
2100
- };
2101
- const args = useV2Encoding ? [
1968
+ const args = [
2102
1969
  {
2103
- ...commonFields,
1970
+ escrow: escrowContext.address,
1971
+ depositId,
1972
+ amount,
1973
+ to: params.toAddress,
1974
+ paymentMethod,
1975
+ fiatCurrency,
1976
+ conversionRate,
1977
+ gatingServiceSignature,
1978
+ signatureExpiration: typeof signatureExpiration === "bigint" ? signatureExpiration : BigInt(signatureExpiration),
1979
+ postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
1980
+ data: params.data ?? "0x",
2104
1981
  referralFees,
2105
1982
  preIntentHookData: preIntentHookData ?? "0x"
2106
1983
  }
2107
- ] : [
2108
- {
2109
- ...commonFields,
2110
- referrer: referralFees[0]?.recipient ?? ZERO_ADDRESS,
2111
- referrerFee: referralFees[0]?.fee ?? 0n
2112
- }
2113
1984
  ];
2114
1985
  const { referrer } = params.txOverrides ?? {};
2115
1986
  const data = encodeWithAttribution(
@@ -2133,8 +2004,7 @@ var IntentOperations = class {
2133
2004
  async prepareCancelIntent(params) {
2134
2005
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2135
2006
  orchestratorAddress: params.orchestratorAddress,
2136
- intentHash: params.intentHash,
2137
- preferV2: this.config.getDefaultPreferV2()
2007
+ intentHash: params.intentHash
2138
2008
  });
2139
2009
  const args = [params.intentHash];
2140
2010
  const { referrer } = params.txOverrides ?? {};
@@ -2159,8 +2029,7 @@ var IntentOperations = class {
2159
2029
  async prepareReleaseFundsToPayer(params) {
2160
2030
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2161
2031
  orchestratorAddress: params.orchestratorAddress,
2162
- intentHash: params.intentHash,
2163
- preferV2: this.config.getDefaultPreferV2()
2032
+ intentHash: params.intentHash
2164
2033
  });
2165
2034
  const args = [params.intentHash];
2166
2035
  const { referrer } = params.txOverrides ?? {};
@@ -2186,13 +2055,11 @@ var IntentOperations = class {
2186
2055
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
2187
2056
  params.escrowAddress,
2188
2057
  params.depositId,
2189
- "setDepositPreIntentHook",
2190
- { preferV2: this.config.getDefaultPreferV2() }
2058
+ "setDepositPreIntentHook"
2191
2059
  );
2192
2060
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2193
2061
  orchestratorAddress: params.orchestratorAddress,
2194
- escrowAddress,
2195
- preferV2: this.config.getDefaultPreferV2()
2062
+ escrowAddress
2196
2063
  });
2197
2064
  return this.config.host.prepareResolvedOrchestratorTransaction({
2198
2065
  orchestrator: orchestratorContext,
@@ -2205,13 +2072,11 @@ var IntentOperations = class {
2205
2072
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
2206
2073
  params.escrowAddress,
2207
2074
  params.depositId,
2208
- "setDepositWhitelistHook",
2209
- { preferV2: this.config.getDefaultPreferV2() }
2075
+ "setDepositWhitelistHook"
2210
2076
  );
2211
2077
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2212
2078
  orchestratorAddress: params.orchestratorAddress,
2213
- escrowAddress,
2214
- preferV2: this.config.getDefaultPreferV2()
2079
+ escrowAddress
2215
2080
  });
2216
2081
  return this.config.host.prepareResolvedOrchestratorTransaction({
2217
2082
  orchestrator: orchestratorContext,
@@ -2223,8 +2088,7 @@ var IntentOperations = class {
2223
2088
  async prepareCleanupOrphanedIntents(params) {
2224
2089
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2225
2090
  orchestratorAddress: params.orchestratorAddress,
2226
- escrowAddress: params.escrowAddress,
2227
- preferV2: this.config.getDefaultPreferV2()
2091
+ escrowAddress: params.escrowAddress
2228
2092
  });
2229
2093
  return this.config.host.prepareResolvedOrchestratorTransaction({
2230
2094
  orchestrator: orchestratorContext,
@@ -2237,13 +2101,11 @@ var IntentOperations = class {
2237
2101
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
2238
2102
  options?.escrowAddress,
2239
2103
  depositId,
2240
- "getDepositPreIntentHook",
2241
- { preferV2: this.config.getDefaultPreferV2() }
2104
+ "getDepositPreIntentHook"
2242
2105
  );
2243
2106
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2244
2107
  orchestratorAddress: options?.orchestratorAddress,
2245
- escrowAddress,
2246
- preferV2: this.config.getDefaultPreferV2()
2108
+ escrowAddress
2247
2109
  });
2248
2110
  const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
2249
2111
  "getDepositPreIntentHook"
@@ -2259,13 +2121,11 @@ var IntentOperations = class {
2259
2121
  const escrowAddress = this.config.host.resolveEscrowAddressOrThrow(
2260
2122
  options?.escrowAddress,
2261
2123
  depositId,
2262
- "getDepositWhitelistHook",
2263
- { preferV2: this.config.getDefaultPreferV2() }
2124
+ "getDepositWhitelistHook"
2264
2125
  );
2265
2126
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2266
2127
  orchestratorAddress: options?.orchestratorAddress,
2267
- escrowAddress,
2268
- preferV2: this.config.getDefaultPreferV2()
2128
+ escrowAddress
2269
2129
  });
2270
2130
  const functionName = resolveAbiFunctionName(orchestratorContext.abi, [
2271
2131
  "getDepositWhitelistHook"
@@ -2281,8 +2141,7 @@ var IntentOperations = class {
2281
2141
  const intentHash = params.intentHash;
2282
2142
  const orchestratorContext = await this.config.host.resolveOrchestratorContext({
2283
2143
  orchestratorAddress: params.orchestratorAddress,
2284
- intentHash,
2285
- preferV2: this.config.getDefaultPreferV2()
2144
+ intentHash
2286
2145
  });
2287
2146
  const precomputed = params.precomputedAttestation;
2288
2147
  let paymentProof;
@@ -2295,7 +2154,9 @@ var IntentOperations = class {
2295
2154
  verificationData = precomputed.verificationData;
2296
2155
  } else {
2297
2156
  const attestationServiceUrl = params.attestationServiceUrl ?? this.defaultAttestationService();
2298
- const inputs = await this.config.host.getFulfillIntentInputs(intentHash);
2157
+ const inputs = await this.config.host.getFulfillIntentInputs(intentHash, {
2158
+ orchestratorAddress: orchestratorContext.address
2159
+ });
2299
2160
  const paymentMethodHash = inputs.paymentMethodHash || "0x";
2300
2161
  const catalog = getPaymentMethodsCatalog(
2301
2162
  this.config.getChainId(),
@@ -2365,31 +2226,30 @@ var IntentOperations = class {
2365
2226
  defaultAttestationService() {
2366
2227
  return this.config.getRuntimeEnv() === "staging" ? "https://attestation-service-staging.zkp2p.xyz" : "https://attestation-service.zkp2p.xyz";
2367
2228
  }
2368
- async getFulfillIntentInputs(intentHash) {
2369
- try {
2370
- if (this.config.getProtocolViewerAddress() && this.config.getProtocolViewerAbi()) {
2371
- const view = await this.config.host.getPvIntent(intentHash);
2372
- const paymentMethodHash = view.intent.paymentMethod.toLowerCase();
2373
- const matched = (view.deposit.paymentMethods || []).find(
2374
- (pm) => pm.paymentMethod?.toLowerCase?.() === paymentMethodHash
2375
- );
2376
- const payee2 = matched?.verificationData?.payeeDetails;
2377
- if (payee2) {
2378
- return {
2379
- amount: view.intent.amount.toString(),
2380
- fiatCurrency: view.intent.fiatCurrency,
2381
- conversionRate: view.intent.conversionRate.toString(),
2382
- payeeDetails: payee2,
2383
- intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
2384
- paymentMethodHash: view.intent.paymentMethod
2385
- };
2229
+ async getFulfillIntentInputs(intentHash, options) {
2230
+ const isCurrentOrchestrator = !options?.orchestratorAddress || options.orchestratorAddress.toLowerCase() === this.config.getOrchestratorV2Address()?.toLowerCase();
2231
+ if (isCurrentOrchestrator) {
2232
+ try {
2233
+ if (this.config.getProtocolViewerAddress() && this.config.getProtocolViewerAbi()) {
2234
+ const view = await this.config.host.getPvIntent(intentHash);
2235
+ const paymentMethodHash = view.intent.paymentMethod.toLowerCase();
2236
+ const matched = (view.deposit.paymentMethods || []).find(
2237
+ (pm) => pm.paymentMethod?.toLowerCase?.() === paymentMethodHash
2238
+ );
2239
+ const payee2 = matched?.verificationData?.payeeDetails;
2240
+ if (payee2) {
2241
+ return {
2242
+ amount: view.intent.amount.toString(),
2243
+ fiatCurrency: view.intent.fiatCurrency,
2244
+ conversionRate: view.intent.conversionRate.toString(),
2245
+ payeeDetails: payee2,
2246
+ intentTimestampMs: (BigInt(view.intent.timestamp) * 1000n).toString(),
2247
+ paymentMethodHash: view.intent.paymentMethod
2248
+ };
2249
+ }
2386
2250
  }
2251
+ } catch {
2387
2252
  }
2388
- } catch (error) {
2389
- logger.debug("ProtocolViewer lookup failed, falling back to indexer", {
2390
- intentHash,
2391
- error: error instanceof Error ? error.message : String(error)
2392
- });
2393
2253
  }
2394
2254
  const response = await this.config.getIndexerClient().query({
2395
2255
  query: (
@@ -3104,8 +2964,7 @@ var VaultOperations = class {
3104
2964
  }
3105
2965
  supportsInlineOracleRateConfig(params) {
3106
2966
  const escrowContext = this.config.host.resolveEscrowContext({
3107
- escrowAddress: params?.escrowAddress,
3108
- preferV2: params?.preferV2
2967
+ escrowAddress: params?.escrowAddress
3109
2968
  });
3110
2969
  return escrowCurrencyHasOracleConfig(escrowContext.abi);
3111
2970
  }
@@ -3222,8 +3081,7 @@ var VaultOperations = class {
3222
3081
  prepareSetOracleRateConfigTransaction(params) {
3223
3082
  const escrowContext = this.config.host.resolveEscrowContext({
3224
3083
  escrowAddress: params.escrowAddress,
3225
- depositId: params.depositId,
3226
- preferV2: true
3084
+ depositId: params.depositId
3227
3085
  });
3228
3086
  if (escrowContext.version !== "v2") {
3229
3087
  throw new Error("setOracleRateConfig requires EscrowV2");
@@ -3245,8 +3103,7 @@ var VaultOperations = class {
3245
3103
  prepareRemoveOracleRateConfigTransaction(params) {
3246
3104
  const escrowContext = this.config.host.resolveEscrowContext({
3247
3105
  escrowAddress: params.escrowAddress,
3248
- depositId: params.depositId,
3249
- preferV2: true
3106
+ depositId: params.depositId
3250
3107
  });
3251
3108
  if (escrowContext.version !== "v2") {
3252
3109
  throw new Error("removeOracleRateConfig requires EscrowV2");
@@ -3263,8 +3120,7 @@ var VaultOperations = class {
3263
3120
  prepareSetOracleRateConfigBatchTransaction(params) {
3264
3121
  const escrowContext = this.config.host.resolveEscrowContext({
3265
3122
  escrowAddress: params.escrowAddress,
3266
- depositId: params.depositId,
3267
- preferV2: true
3123
+ depositId: params.depositId
3268
3124
  });
3269
3125
  if (escrowContext.version !== "v2") {
3270
3126
  throw new Error("setOracleRateConfigBatch requires EscrowV2");
@@ -3286,8 +3142,7 @@ var VaultOperations = class {
3286
3142
  prepareUpdateCurrencyConfigBatchTransaction(params) {
3287
3143
  const escrowContext = this.config.host.resolveEscrowContext({
3288
3144
  escrowAddress: params.escrowAddress,
3289
- depositId: params.depositId,
3290
- preferV2: true
3145
+ depositId: params.depositId
3291
3146
  });
3292
3147
  if (escrowContext.version !== "v2") {
3293
3148
  throw new Error("updateCurrencyConfigBatch requires EscrowV2");
@@ -3315,8 +3170,7 @@ var VaultOperations = class {
3315
3170
  prepareDeactivateCurrenciesBatchTransaction(params) {
3316
3171
  const escrowContext = this.config.host.resolveEscrowContext({
3317
3172
  escrowAddress: params.escrowAddress,
3318
- depositId: params.depositId,
3319
- preferV2: true
3173
+ depositId: params.depositId
3320
3174
  });
3321
3175
  if (escrowContext.version !== "v2") {
3322
3176
  throw new Error("deactivateCurrenciesBatch requires EscrowV2");
@@ -3607,6 +3461,7 @@ var DEPOSIT_FIELDS = `
3607
3461
  timestamp
3608
3462
  txHash
3609
3463
  updatedAt
3464
+ whitelistHookAddress
3610
3465
  `;
3611
3466
  var LEGACY_DEPOSIT_FIELDS = `
3612
3467
  id
@@ -4597,6 +4452,35 @@ var DEPOSIT_DAILY_SNAPSHOTS_QUERY = (
4597
4452
  }
4598
4453
  `
4599
4454
  );
4455
+ var PROFIT_SNAPSHOTS_BY_DEPOSITS_QUERY = (
4456
+ /* GraphQL */
4457
+ `
4458
+ query GetProfitSnapshotsByDeposits($depositIds: [String!]) {
4459
+ profitSnapshots: MakerProfitSnapshot(
4460
+ where: { depositId: { _in: $depositIds } }
4461
+ order_by: { createdAt: desc }
4462
+ ) {
4463
+ id
4464
+ chainId
4465
+ maker
4466
+ intentId
4467
+ depositId
4468
+ fiatCurrency
4469
+ quoteConversionRate
4470
+ oracleRate
4471
+ spreadBps
4472
+ amount
4473
+ notionalFiatUsdCents
4474
+ feeUsd
4475
+ realizedProfitUsdCents
4476
+ priceSnapshotId
4477
+ status
4478
+ createdAt
4479
+ updatedAt
4480
+ }
4481
+ }
4482
+ `
4483
+ );
4600
4484
  var FULFILLMENT_AND_PAYMENT_QUERY = (
4601
4485
  /* GraphQL */
4602
4486
  `
@@ -4708,7 +4592,7 @@ function convertIndexerDepositToEscrowView(deposit, _chainId, _escrowAddress) {
4708
4592
  }
4709
4593
  function convertDepositsForLiquidity(deposits, chainId, escrowAddress) {
4710
4594
  return deposits.filter(
4711
- (d) => d.depositor && d.depositor.toLowerCase() !== ZERO && d.acceptingIntents && toBigInt(d.remainingDeposits) > 0n && d.status === "ACTIVE"
4595
+ (d) => d.depositor && d.depositor.toLowerCase() !== ZERO && normalizeAddress2(d.whitelistHookAddress).toLowerCase() === ZERO && d.acceptingIntents && toBigInt(d.remainingDeposits) > 0n && d.status === "ACTIVE"
4712
4596
  ).map((d) => convertIndexerDepositToEscrowView(d));
4713
4597
  }
4714
4598
  function convertIndexerIntentsToEscrowViews(intents, depositViewsById) {
@@ -4824,14 +4708,16 @@ var IndexerDepositService = class {
4824
4708
  const where = {};
4825
4709
  if (params.depositIds?.length) where.depositId = { _in: params.depositIds };
4826
4710
  if (params.owner) where.owner = { _ilike: params.owner };
4711
+ if (params.rateManagerId) where.rateManagerId = { _ilike: params.rateManagerId };
4827
4712
  if (params.statuses?.length) where.status = { _in: params.statuses };
4828
4713
  if (!Object.keys(where).length) return [];
4714
+ const orderByField = params.orderByField ?? "signalTimestamp";
4829
4715
  const result = await this.queryWithLegacyFallback({
4830
4716
  query: INTENTS_QUERY,
4831
4717
  legacyQuery: LEGACY_INTENTS_QUERY,
4832
4718
  variables: {
4833
4719
  where,
4834
- order_by: [{ signalTimestamp: "desc" }],
4720
+ order_by: [{ [orderByField]: "desc" }],
4835
4721
  limit: params.limit,
4836
4722
  offset: params.offset
4837
4723
  }
@@ -4894,6 +4780,16 @@ var IndexerDepositService = class {
4894
4780
  if (!owner) return [];
4895
4781
  return this.fetchIntents({ owner, statuses });
4896
4782
  }
4783
+ async fetchIntentsByRateManager(rateManagerId, statuses) {
4784
+ const normalizedRateManagerId = rateManagerId?.trim();
4785
+ if (!normalizedRateManagerId) return [];
4786
+ return this.fetchIntents({
4787
+ rateManagerId: normalizedRateManagerId,
4788
+ statuses,
4789
+ limit: 500,
4790
+ orderByField: "fulfillTimestamp"
4791
+ });
4792
+ }
4897
4793
  async fetchIntentByHash(intentHash) {
4898
4794
  if (!intentHash) return null;
4899
4795
  const result = await this.queryWithLegacyFallback({
@@ -5115,12 +5011,33 @@ var IndexerDepositService = class {
5115
5011
  return [];
5116
5012
  }
5117
5013
  }
5014
+ async fetchProfitSnapshotsByDeposits(depositIds) {
5015
+ const normalizedDepositIds = Array.from(
5016
+ new Set(
5017
+ depositIds.map((depositId) => depositId?.trim()).filter((depositId) => Boolean(depositId))
5018
+ )
5019
+ );
5020
+ if (!normalizedDepositIds.length) return [];
5021
+ try {
5022
+ const result = await this.client.query({
5023
+ query: PROFIT_SNAPSHOTS_BY_DEPOSITS_QUERY,
5024
+ variables: { depositIds: normalizedDepositIds }
5025
+ });
5026
+ return result.profitSnapshots ?? result.MakerProfitSnapshot ?? [];
5027
+ } catch (error) {
5028
+ if (!isSchemaCompatibilityError(error)) {
5029
+ throw error;
5030
+ }
5031
+ return [];
5032
+ }
5033
+ }
5118
5034
  };
5119
5035
 
5120
5036
  // src/indexer/rateManagerService.ts
5121
5037
  init_bigint();
5122
5038
  var DEFAULT_LIMIT2 = 50;
5123
5039
  var RATE_MANAGER_HISTORY_PAGE_SIZE = 250;
5040
+ var EVM_ADDRESS_REGEX = /^0x[a-f0-9]{40}$/;
5124
5041
  function normalizeRateManagerId(value) {
5125
5042
  if (!value) return "";
5126
5043
  return value.toLowerCase();
@@ -5129,6 +5046,9 @@ function normalizeAddress3(value) {
5129
5046
  if (!value) return "";
5130
5047
  return value.toLowerCase();
5131
5048
  }
5049
+ function escapeLikePatternLiteral(value) {
5050
+ return value.replace(/\\/g, "\\\\").replace(/%/g, "\\%").replace(/_/g, "\\_");
5051
+ }
5132
5052
  function parseScopedRateManagerFilterId(value) {
5133
5053
  const trimmed = value.trim().toLowerCase();
5134
5054
  if (!trimmed) return null;
@@ -5136,7 +5056,7 @@ function parseScopedRateManagerFilterId(value) {
5136
5056
  if (separatorIndex <= 0) return null;
5137
5057
  const rateManagerAddress = normalizeAddress3(trimmed.slice(0, separatorIndex));
5138
5058
  const rateManagerId = normalizeRateManagerId(trimmed.slice(separatorIndex + 1));
5139
- if (!rateManagerAddress.startsWith("0x") || !rateManagerId) {
5059
+ if (!EVM_ADDRESS_REGEX.test(rateManagerAddress) || !rateManagerId) {
5140
5060
  return null;
5141
5061
  }
5142
5062
  return { rateManagerAddress, rateManagerId };
@@ -5154,12 +5074,14 @@ function extractRateManagerAddressFromScopedId(id) {
5154
5074
  return rateManagerAddress.startsWith("0x") ? rateManagerAddress.toLowerCase() : null;
5155
5075
  }
5156
5076
  function buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress) {
5157
- const normalizedId = normalizeRateManagerId(rateManagerId);
5158
- const normalizedRateManagerAddress = normalizeAddress3(rateManagerAddress);
5159
- return `%_${normalizedRateManagerAddress}_${normalizedId}`;
5077
+ const normalizedId = escapeLikePatternLiteral(normalizeRateManagerId(rateManagerId));
5078
+ const normalizedRateManagerAddress = escapeLikePatternLiteral(
5079
+ normalizeAddress3(rateManagerAddress)
5080
+ );
5081
+ return `%\\_${normalizedRateManagerAddress}\\_${normalizedId}`;
5160
5082
  }
5161
5083
  function buildRateManagerScopedIdPattern(rateManagerId, rateManagerAddress) {
5162
- return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}_%`;
5084
+ return `${buildRateManagerAddressScopedIdPattern(rateManagerId, rateManagerAddress)}\\_%`;
5163
5085
  }
5164
5086
  function normalizeCompositeDepositId(depositId, escrowAddress) {
5165
5087
  const normalizedDepositId = depositId.trim().toLowerCase();
@@ -5194,6 +5116,9 @@ function parseRateManagerFilterIds(rateManagerIds) {
5194
5116
  );
5195
5117
  continue;
5196
5118
  }
5119
+ if (value.includes(":")) {
5120
+ continue;
5121
+ }
5197
5122
  const normalizedRateManagerId = normalizeRateManagerId(value);
5198
5123
  if (normalizedRateManagerId) {
5199
5124
  bare.add(normalizedRateManagerId);
@@ -5732,21 +5657,12 @@ var IndexerRateManagerService = class {
5732
5657
  async fetchManualRateUpdates(rateManagerId, options) {
5733
5658
  if (!rateManagerId) return [];
5734
5659
  const normalizedId = normalizeRateManagerId(rateManagerId);
5735
- const normalizedRateManagerAddress = normalizeAddress3(options?.rateManagerAddress);
5736
5660
  try {
5737
5661
  const result = await this.client.query({
5738
5662
  query: MANUAL_RATE_UPDATES_QUERY,
5739
5663
  variables: {
5740
5664
  where: {
5741
- rateManagerId: { _eq: normalizedId },
5742
- ...normalizedRateManagerAddress ? {
5743
- id: {
5744
- _ilike: buildRateManagerScopedIdPattern(
5745
- normalizedId,
5746
- normalizedRateManagerAddress
5747
- )
5748
- }
5749
- } : {}
5665
+ rateManagerId: { _eq: normalizedId }
5750
5666
  },
5751
5667
  order_by: [{ id: "desc" }],
5752
5668
  limit: options?.limit ?? 100
@@ -5820,15 +5736,7 @@ var IndexerRateManagerService = class {
5820
5736
  query: LEGACY_ORACLE_CONFIG_UPDATES_QUERY,
5821
5737
  variables: {
5822
5738
  where: {
5823
- rateManagerId: { _eq: normalizedId },
5824
- ...normalizedRateManagerAddress ? {
5825
- id: {
5826
- _ilike: buildRateManagerScopedIdPattern(
5827
- normalizedId,
5828
- normalizedRateManagerAddress
5829
- )
5830
- }
5831
- } : {}
5739
+ rateManagerId: { _eq: normalizedId }
5832
5740
  },
5833
5741
  order_by: [{ id: "desc" }],
5834
5742
  limit
@@ -7233,13 +7141,13 @@ var Zkp2pClient = class {
7233
7141
  getProtocolViewerAbi: () => this.protocolViewerAbi,
7234
7142
  getIndexerClient: () => this._indexerClient,
7235
7143
  getIndexerService: () => this._indexerService,
7236
- getDefaultPreferV2: () => this._router.defaultPreferV2,
7144
+ getOrchestratorV2Address: () => this.orchestratorV2Address,
7237
7145
  host: {
7238
7146
  resolveEscrowContext: (options) => this.resolveEscrowContext(options),
7239
7147
  resolveOrchestratorContext: (options) => this.resolveOrchestratorContext(options),
7240
- resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName, options) => this.resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName, options),
7148
+ resolveEscrowAddressOrThrow: (escrowAddress, depositId, methodName) => this.resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName),
7241
7149
  prepareResolvedOrchestratorTransaction: (tx) => this.prepareResolvedOrchestratorTransaction(tx),
7242
- getFulfillIntentInputs: (intentHash) => this.getFulfillIntentInputs(intentHash),
7150
+ getFulfillIntentInputs: (intentHash, options) => this.getFulfillIntentInputs(intentHash, options),
7243
7151
  getPvIntent: (intentHash) => this.getPvIntent(intentHash)
7244
7152
  }
7245
7153
  });
@@ -7271,8 +7179,7 @@ var Zkp2pClient = class {
7271
7179
  }
7272
7180
  supportsInlineOracleRateConfig(params) {
7273
7181
  return this._vaultOps.supportsInlineOracleRateConfig({
7274
- escrowAddress: params?.escrowAddress,
7275
- preferV2: params?.preferV2 ?? this._router.defaultPreferV2
7182
+ escrowAddress: params?.escrowAddress
7276
7183
  });
7277
7184
  }
7278
7185
  parseManagerFeeFromRead(result) {
@@ -7290,13 +7197,10 @@ var Zkp2pClient = class {
7290
7197
  abiFunctionHasInput(abi, functionName, inputName) {
7291
7198
  return abiFunctionHasInput(abi, functionName, inputName);
7292
7199
  }
7293
- resolveEscrowAddressOrThrow(escrowAddress, depositId, methodName, options) {
7200
+ resolveEscrowAddressOrThrow(escrowAddress, depositId, _methodName) {
7294
7201
  const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
7295
7202
  if (resolved) return resolved;
7296
- if (options?.preferV2 !== void 0) {
7297
- return this.resolveEscrowContext().address;
7298
- }
7299
- throw new Error(`${methodName} requires escrowAddress or composite depositId`);
7203
+ return this.resolveEscrowContext().address;
7300
7204
  }
7301
7205
  prepareCreateRateManagerTransaction(params) {
7302
7206
  return this._vaultOps.prepareCreateRateManagerTransaction(params);
@@ -7384,8 +7288,8 @@ var Zkp2pClient = class {
7384
7288
  getEscrowContexts() {
7385
7289
  return this._router.getEscrowContexts();
7386
7290
  }
7387
- resolveOrchestratorForEscrow(escrowAddress, preferV2 = false) {
7388
- return this._router.resolveOrchestratorForEscrow(escrowAddress, preferV2);
7291
+ resolveOrchestratorForEscrow(escrowAddress) {
7292
+ return this._router.resolveOrchestratorForEscrow(escrowAddress);
7389
7293
  }
7390
7294
  async lookupIntentRouting(intentHash) {
7391
7295
  try {
@@ -7419,12 +7323,8 @@ var Zkp2pClient = class {
7419
7323
  try {
7420
7324
  const view = await this.getPvIntent(intentHash);
7421
7325
  return this.normalizeAddress(view?.intent?.escrow);
7422
- } catch (error) {
7423
- if (error instanceof Error && error.message === "Intent not found") {
7424
- return void 0;
7425
- }
7426
- const message = error instanceof Error ? error.message : "Unknown on-chain routing error";
7427
- throw new Error(`Failed to resolve intent escrow on-chain for ${intentHash}: ${message}`);
7326
+ } catch {
7327
+ return void 0;
7428
7328
  }
7429
7329
  }
7430
7330
  warnOrchestratorFallback(intentHash, source, error) {
@@ -7448,10 +7348,7 @@ var Zkp2pClient = class {
7448
7348
  const fromIntent = this.getOrchestratorContextByAddress(routing.orchestratorAddress);
7449
7349
  if (fromIntent) return fromIntent;
7450
7350
  if (routing.escrowAddress) {
7451
- const fromIntentEscrow = this.resolveOrchestratorForEscrow(
7452
- routing.escrowAddress,
7453
- options.preferV2
7454
- );
7351
+ const fromIntentEscrow = this.resolveOrchestratorForEscrow(routing.escrowAddress);
7455
7352
  if (fromIntentEscrow) return fromIntentEscrow;
7456
7353
  }
7457
7354
  } catch (error) {
@@ -7460,10 +7357,7 @@ var Zkp2pClient = class {
7460
7357
  try {
7461
7358
  const onchainEscrow = await this.lookupIntentEscrowOnchain(options.intentHash);
7462
7359
  if (onchainEscrow) {
7463
- const fromOnchainEscrow = this.resolveOrchestratorForEscrow(
7464
- onchainEscrow,
7465
- options.preferV2
7466
- );
7360
+ const fromOnchainEscrow = this.resolveOrchestratorForEscrow(onchainEscrow);
7467
7361
  if (fromOnchainEscrow) return fromOnchainEscrow;
7468
7362
  }
7469
7363
  } catch (error) {
@@ -7471,7 +7365,7 @@ var Zkp2pClient = class {
7471
7365
  }
7472
7366
  }
7473
7367
  if (options?.escrowAddress) {
7474
- const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress, options.preferV2);
7368
+ const fromEscrow = this.resolveOrchestratorForEscrow(options.escrowAddress);
7475
7369
  if (fromEscrow) return fromEscrow;
7476
7370
  }
7477
7371
  if (options?.intentHash) {
@@ -7489,7 +7383,7 @@ var Zkp2pClient = class {
7489
7383
  }
7490
7384
  }
7491
7385
  }
7492
- const fallback = this.resolveOrchestratorForEscrow(void 0, options?.preferV2);
7386
+ const fallback = this.resolveOrchestratorForEscrow();
7493
7387
  if (fallback) return fallback;
7494
7388
  throw new Error("Orchestrator not available");
7495
7389
  }
@@ -7709,8 +7603,7 @@ var Zkp2pClient = class {
7709
7603
  async (params) => {
7710
7604
  const orchestratorContext = await this.resolveOrchestratorContext({
7711
7605
  orchestratorAddress: params.orchestratorAddress,
7712
- escrowAddress: params.escrowAddress,
7713
- preferV2: params.preferV2
7606
+ escrowAddress: params.escrowAddress
7714
7607
  });
7715
7608
  const prepared = this.prepareOrchestratorTransaction({
7716
7609
  functionName,
@@ -7726,8 +7619,7 @@ var Zkp2pClient = class {
7726
7619
  prepare: async (params) => {
7727
7620
  const orchestratorContext = await this.resolveOrchestratorContext({
7728
7621
  orchestratorAddress: params.orchestratorAddress,
7729
- escrowAddress: params.escrowAddress,
7730
- preferV2: params.preferV2
7622
+ escrowAddress: params.escrowAddress
7731
7623
  });
7732
7624
  const prepared = this.prepareOrchestratorTransaction({
7733
7625
  functionName,
@@ -7936,6 +7828,12 @@ var Zkp2pClient = class {
7936
7828
  getOwnerIntents: (owner, statuses) => {
7937
7829
  return service.fetchIntentsByOwner(owner, statuses);
7938
7830
  },
7831
+ /**
7832
+ * Fetches fulfilled intents for a vault by rate manager ID.
7833
+ */
7834
+ getIntentsByRateManager: (rateManagerId, statuses) => {
7835
+ return service.fetchIntentsByRateManager(rateManagerId, statuses);
7836
+ },
7939
7837
  /**
7940
7838
  * Fetches a single intent by hash.
7941
7839
  */
@@ -7986,6 +7884,12 @@ var Zkp2pClient = class {
7986
7884
  getDepositsByIdsWithRelations: (ids, options) => {
7987
7885
  return service.fetchDepositsByIdsWithRelations(ids, options);
7988
7886
  },
7887
+ /**
7888
+ * Fetches maker profit snapshots for the provided deposits.
7889
+ */
7890
+ getProfitSnapshotsByDeposits: (depositIds) => {
7891
+ return service.fetchProfitSnapshotsByDeposits(depositIds);
7892
+ },
7989
7893
  /**
7990
7894
  * Fetches rate managers (vaults) with aggregate stats.
7991
7895
  */
@@ -8062,7 +7966,6 @@ var Zkp2pClient = class {
8062
7966
  * @param params.amount - Minimum required allowance amount
8063
7967
  * @param params.spender - Spender address override
8064
7968
  * @param params.escrowAddress - Escrow context used for default spender resolution
8065
- * @param params.preferV2 - Prefer EscrowV2 for default spender resolution
8066
7969
  * @param params.maxApprove - If true, approves MaxUint256 instead of exact amount
8067
7970
  * @param params.txOverrides - Optional viem transaction overrides
8068
7971
  * @returns Object with `hadAllowance` (true if no approval needed) and optional `hash`
@@ -8085,8 +7988,7 @@ var Zkp2pClient = class {
8085
7988
  const owner = this.walletClient.account?.address;
8086
7989
  if (!owner) throw new Error("Wallet client is missing account");
8087
7990
  const spender = params.spender ?? this.resolveEscrowContext({
8088
- escrowAddress: params.escrowAddress,
8089
- preferV2: params.preferV2 ?? this._router.defaultPreferV2
7991
+ escrowAddress: params.escrowAddress
8090
7992
  }).address;
8091
7993
  const allowance = await this.publicClient.readContract({
8092
7994
  address: params.token,
@@ -8320,8 +8222,7 @@ var Zkp2pClient = class {
8320
8222
  currencies = mapConversionRatesToOnchainMinRate2(normalized, paymentMethods.length);
8321
8223
  }
8322
8224
  const escrowContext = this.resolveEscrowContext({
8323
- escrowAddress: params.escrowAddress,
8324
- preferV2: this._router.defaultPreferV2
8225
+ escrowAddress: params.escrowAddress
8325
8226
  });
8326
8227
  const normalizedCurrencies = currencies.map(
8327
8228
  (group) => this.normalizeCurrencyTuples(group, escrowContext.abi)
@@ -8641,8 +8542,8 @@ var Zkp2pClient = class {
8641
8542
  * @returns Intent parameters needed for fulfillment
8642
8543
  * @throws Error if intent not found or payee details cannot be resolved
8643
8544
  */
8644
- async getFulfillIntentInputs(intentHash) {
8645
- return this._intentOps.getFulfillIntentInputs(intentHash);
8545
+ async getFulfillIntentInputs(intentHash, options) {
8546
+ return this._intentOps.getFulfillIntentInputs(intentHash, options);
8646
8547
  }
8647
8548
  };
8648
8549
 
@@ -8844,6 +8745,46 @@ init_paymentResolution();
8844
8745
  init_contracts();
8845
8746
  init_bytes32();
8846
8747
  init_protocolViewerParsers();
8748
+
8749
+ // src/utils/logger.ts
8750
+ var currentLevel = "info";
8751
+ function setLogLevel(level) {
8752
+ currentLevel = level;
8753
+ }
8754
+ function shouldLog(level) {
8755
+ switch (currentLevel) {
8756
+ case "debug":
8757
+ return true;
8758
+ case "info":
8759
+ return level !== "debug";
8760
+ case "error":
8761
+ return level === "error";
8762
+ default:
8763
+ return true;
8764
+ }
8765
+ }
8766
+ var logger = {
8767
+ debug: (...args) => {
8768
+ if (shouldLog("debug")) {
8769
+ console.log("[DEBUG]", ...args);
8770
+ }
8771
+ },
8772
+ info: (...args) => {
8773
+ if (shouldLog("info")) {
8774
+ console.log("[INFO]", ...args);
8775
+ }
8776
+ },
8777
+ warn: (...args) => {
8778
+ if (shouldLog("info")) {
8779
+ console.warn("[WARN]", ...args);
8780
+ }
8781
+ },
8782
+ error: (...args) => {
8783
+ console.error("[ERROR]", ...args);
8784
+ }
8785
+ };
8786
+
8787
+ // src/index.ts
8847
8788
  init_errors();
8848
8789
 
8849
8790
  // src/react/hooks/vaultUtils.ts