@zkp2p/sdk 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -236,6 +236,9 @@ function pickAbi(source, names) {
236
236
  for (const name of names) {
237
237
  const candidate = source[name];
238
238
  if (Array.isArray(candidate)) return candidate;
239
+ if (candidate && typeof candidate === "object" && Array.isArray(candidate.default)) {
240
+ return candidate.default;
241
+ }
239
242
  }
240
243
  return void 0;
241
244
  }
@@ -254,14 +257,6 @@ function uniqueAddresses(...values) {
254
257
  function addressesEqual(left, right) {
255
258
  return Boolean(left && right && left.toLowerCase() === right.toLowerCase());
256
259
  }
257
- function firstDistinctAddress(candidates, current) {
258
- for (const candidate of candidates) {
259
- if (!isValidAddress(candidate)) continue;
260
- if (addressesEqual(candidate, current)) continue;
261
- return candidate;
262
- }
263
- return void 0;
264
- }
265
260
  function readRuntimeEnv(key) {
266
261
  try {
267
262
  const meta = ({ url: (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)) });
@@ -310,14 +305,12 @@ function getContracts(chainId, env = "production") {
310
305
  escrowV2: pickAddress(baseContracts, ["EscrowV2", "Escrow_V2"]),
311
306
  escrowAddresses: uniqueAddresses(
312
307
  pickAddress(baseContracts, ["EscrowV2", "Escrow_V2"]),
313
- pickAddress(baseContracts, ["Escrow"]),
314
308
  ...exports.HISTORICAL_ESCROW_ADDRESSES.base
315
309
  ),
316
310
  orchestrator: pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]) ?? pickAddress(baseContracts, ["Orchestrator"]),
317
311
  orchestratorV2: pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]),
318
312
  orchestratorAddresses: uniqueAddresses(
319
313
  pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]),
320
- pickAddress(baseContracts, ["Orchestrator"]),
321
314
  ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base
322
315
  ),
323
316
  unifiedPaymentVerifier: pickAddress(baseContracts, [
@@ -377,35 +370,25 @@ function getContracts(chainId, env = "production") {
377
370
  "VITE_ESCROW_V2_ADDRESS"
378
371
  ]);
379
372
  const stagingEscrowCurrent = stagingEscrowV2Override ?? pickAddress(sc, ["EscrowV2", "Escrow_V2"]) ?? pickAddress(sc, ["Escrow"]) ?? STAGING_ESCROW_V2_FALLBACK;
380
- const stagingEscrowLegacy = firstDistinctAddress(
381
- [pickAddress(sc, ["Escrow"]), ...exports.HISTORICAL_ESCROW_ADDRESSES.base_staging],
382
- stagingEscrowCurrent
383
- );
384
373
  const stagingOrchestratorV2Override = resolveRuntimeAddressOverride([
385
374
  "VITE_BASE_STAGING_ORCHESTRATOR_V2_ADDRESS",
386
375
  "VITE_ORCHESTRATOR_V2_ADDRESS",
387
376
  "VITE_ORCHESTRATORV2_ADDRESS"
388
377
  ]);
389
378
  const stagingOrchestratorCurrent = stagingOrchestratorV2Override ?? pickAddress(sc, ["OrchestratorV2", "Orchestrator_V2"]) ?? pickAddress(sc, ["Orchestrator"]) ?? STAGING_ORCHESTRATOR_V2_FALLBACK;
390
- const stagingOrchestratorLegacy = firstDistinctAddress(
391
- [pickAddress(sc, ["Orchestrator"]), ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base_staging],
392
- stagingOrchestratorCurrent
393
- );
394
379
  const stagingRateManagerV1 = pickAddress(sc, ["RateManagerV1", "DepositRateManagerRegistryV1"]);
395
380
  return {
396
381
  addresses: {
397
- escrow: stagingEscrowCurrent ?? stagingEscrowLegacy ?? "",
382
+ escrow: stagingEscrowCurrent,
398
383
  escrowV2: stagingEscrowCurrent,
399
384
  escrowAddresses: uniqueAddresses(
400
385
  stagingEscrowCurrent,
401
- stagingEscrowLegacy,
402
386
  ...exports.HISTORICAL_ESCROW_ADDRESSES.base_staging
403
387
  ),
404
- orchestrator: stagingOrchestratorCurrent ?? stagingOrchestratorLegacy,
388
+ orchestrator: stagingOrchestratorCurrent,
405
389
  orchestratorV2: stagingOrchestratorCurrent,
406
390
  orchestratorAddresses: uniqueAddresses(
407
391
  stagingOrchestratorCurrent,
408
- stagingOrchestratorLegacy,
409
392
  ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base_staging
410
393
  ),
411
394
  unifiedPaymentVerifier: pickAddress(sc, [
@@ -1288,19 +1271,14 @@ var ContractRouter = class {
1288
1271
  this._orchestratorContextsByAddress = /* @__PURE__ */ new Map();
1289
1272
  this.escrowAddress = config.escrowAddress;
1290
1273
  this.escrowAbi = config.escrowAbi;
1291
- this.legacyEscrowAddress = config.legacyEscrowAddress;
1292
- this.legacyEscrowAbi = config.legacyEscrowAbi;
1293
1274
  this.escrowV2Address = config.escrowV2Address;
1294
1275
  this.escrowV2Abi = config.escrowV2Abi;
1295
1276
  this.escrowAddresses = config.escrowAddresses;
1296
1277
  this.orchestratorAddress = config.orchestratorAddress;
1297
1278
  this.orchestratorAbi = config.orchestratorAbi;
1298
- this.legacyOrchestratorAddress = config.legacyOrchestratorAddress;
1299
- this.legacyOrchestratorAbi = config.legacyOrchestratorAbi;
1300
1279
  this.orchestratorV2Address = config.orchestratorV2Address;
1301
1280
  this.orchestratorV2Abi = config.orchestratorV2Abi;
1302
1281
  this.orchestratorAddresses = config.orchestratorAddresses;
1303
- this._defaultPreferV2 = config.defaultPreferV2;
1304
1282
  this._registerContexts();
1305
1283
  }
1306
1284
  _registerContexts() {
@@ -1308,17 +1286,20 @@ var ContractRouter = class {
1308
1286
  if (!context?.address || !context.abi) return;
1309
1287
  this._orchestratorContextsByAddress.set(context.address.toLowerCase(), context);
1310
1288
  };
1289
+ const registerEscrow = (context) => {
1290
+ if (!context?.address || !context.abi) return;
1291
+ this._escrowContextsByAddress.set(context.address.toLowerCase(), context);
1292
+ };
1293
+ const primaryOrchestratorAddress = this.orchestratorV2Address ?? this.orchestratorAddress;
1294
+ const primaryEscrowAbi = this.escrowV2Abi ?? this.escrowAbi;
1311
1295
  const escrowToOrchestrator = /* @__PURE__ */ new Map();
1312
- const addEscrowOrchestratorPair = (escrow, orchestrator, overwrite = true) => {
1296
+ const addEscrowOrchestratorPair = (escrow, orchestrator) => {
1313
1297
  if (!escrow || !orchestrator) return;
1314
- const key = escrow.toLowerCase();
1315
- if (!overwrite && escrowToOrchestrator.has(key)) return;
1316
- escrowToOrchestrator.set(key, orchestrator);
1298
+ escrowToOrchestrator.set(escrow.toLowerCase(), orchestrator);
1317
1299
  };
1318
- addEscrowOrchestratorPair(this.legacyEscrowAddress, this.legacyOrchestratorAddress);
1319
1300
  addEscrowOrchestratorPair(
1320
- this.escrowV2Address,
1321
- this.orchestratorV2Address ?? this.orchestratorAddress
1301
+ this.escrowV2Address ?? this.escrowAddress,
1302
+ primaryOrchestratorAddress
1322
1303
  );
1323
1304
  const configuredPairCount = Math.min(
1324
1305
  this.escrowAddresses.length,
@@ -1327,81 +1308,45 @@ var ContractRouter = class {
1327
1308
  for (let index = 0; index < configuredPairCount; index += 1) {
1328
1309
  addEscrowOrchestratorPair(this.escrowAddresses[index], this.orchestratorAddresses[index]);
1329
1310
  }
1330
- for (const address of this.escrowAddresses) {
1331
- if (escrowToOrchestrator.has(address.toLowerCase())) continue;
1332
- const version = isSameAddress(address, this.escrowV2Address) ? "v2" : "legacy";
1333
- const orchestrator = version === "v2" ? this.orchestratorV2Address ?? this.orchestratorAddress : this.legacyOrchestratorAddress ?? this.orchestratorAddress;
1334
- if (orchestrator) {
1335
- addEscrowOrchestratorPair(address, orchestrator, false);
1336
- }
1337
- }
1338
- const resolveOrchestratorAbi = (address) => {
1339
- if (isSameAddress(address, this.orchestratorV2Address)) {
1340
- return this.orchestratorV2Abi ?? this.orchestratorAbi ?? this.legacyOrchestratorAbi;
1341
- }
1342
- if (isSameAddress(address, this.legacyOrchestratorAddress)) {
1343
- return this.legacyOrchestratorAbi ?? this.orchestratorAbi ?? this.orchestratorV2Abi;
1344
- }
1345
- return this.orchestratorAbi ?? this.orchestratorV2Abi ?? this.legacyOrchestratorAbi;
1346
- };
1347
- const resolveOrchestratorVersion = (address) => {
1348
- if (isSameAddress(address, this.legacyOrchestratorAddress)) return "legacy";
1349
- if (isSameAddress(address, this.orchestratorV2Address)) return "v2";
1350
- return this.orchestratorV2Abi ? "v2" : "legacy";
1351
- };
1352
- for (const address of this.orchestratorAddresses) {
1353
- const abi = resolveOrchestratorAbi(address);
1311
+ const resolveOrchestratorAbi = (address) => this.getOrchestratorContextByAddress(address)?.abi ?? (isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi);
1312
+ const uniqueOrchestratorAddresses = /* @__PURE__ */ new Set();
1313
+ for (const address of [
1314
+ primaryOrchestratorAddress,
1315
+ this.orchestratorAddress,
1316
+ this.orchestratorV2Address,
1317
+ ...this.orchestratorAddresses
1318
+ ]) {
1319
+ if (!address) continue;
1320
+ const key = address.toLowerCase();
1321
+ if (uniqueOrchestratorAddresses.has(key)) continue;
1322
+ uniqueOrchestratorAddresses.add(key);
1323
+ const abi = isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi;
1354
1324
  if (!abi) continue;
1355
1325
  registerOrchestrator({
1356
1326
  address,
1357
1327
  abi,
1358
- version: resolveOrchestratorVersion(address)
1328
+ version: "v2"
1359
1329
  });
1360
1330
  }
1361
- const registerEscrow = (context) => {
1362
- if (!context?.address || !context.abi) return;
1363
- this._escrowContextsByAddress.set(context.address.toLowerCase(), context);
1364
- };
1365
- const resolveEscrowVersion = (address) => {
1366
- if (isSameAddress(address, this.legacyEscrowAddress)) return "legacy";
1367
- if (isSameAddress(address, this.escrowV2Address)) return "v2";
1368
- const pairedOrchestrator = escrowToOrchestrator.get(address.toLowerCase());
1369
- if (isSameAddress(pairedOrchestrator, this.legacyOrchestratorAddress)) return "legacy";
1370
- if (isSameAddress(pairedOrchestrator, this.orchestratorV2Address)) return "v2";
1371
- return this.escrowV2Abi ? "v2" : "legacy";
1372
- };
1373
- const resolveEscrowAbi = (version) => version === "legacy" ? this.legacyEscrowAbi ?? this.escrowAbi ?? this.escrowV2Abi : this.escrowV2Abi ?? this.escrowAbi ?? this.legacyEscrowAbi;
1374
- const resolveEscrowOrchestratorAddress = (escrowAddress, version) => escrowToOrchestrator.get(escrowAddress.toLowerCase()) ?? (version === "legacy" ? this.legacyOrchestratorAddress ?? this.orchestratorAddress : this.orchestratorV2Address ?? this.orchestratorAddress);
1375
- const resolveEscrowOrchestratorAbi = (orchestratorAddress, version) => this.getOrchestratorContextByAddress(orchestratorAddress)?.abi ?? (version === "legacy" ? this.legacyOrchestratorAbi ?? this.orchestratorAbi ?? this.orchestratorV2Abi : this.orchestratorV2Abi ?? this.orchestratorAbi ?? this.legacyOrchestratorAbi);
1376
- for (const address of this.escrowAddresses) {
1377
- const version = resolveEscrowVersion(address);
1378
- const abi = resolveEscrowAbi(version);
1379
- const orchAddress = resolveEscrowOrchestratorAddress(address, version);
1380
- const orchAbi = resolveEscrowOrchestratorAbi(orchAddress, version);
1381
- if (!abi) continue;
1331
+ const uniqueEscrowAddresses = /* @__PURE__ */ new Set();
1332
+ for (const address of [
1333
+ this.escrowV2Address ?? this.escrowAddress,
1334
+ this.escrowAddress,
1335
+ ...this.escrowAddresses
1336
+ ]) {
1337
+ if (!address) continue;
1338
+ const key = address.toLowerCase();
1339
+ if (uniqueEscrowAddresses.has(key)) continue;
1340
+ uniqueEscrowAddresses.add(key);
1341
+ const orchestratorAddress = escrowToOrchestrator.get(key) ?? primaryOrchestratorAddress ?? this.orchestratorAddress;
1382
1342
  registerEscrow({
1383
1343
  address,
1384
- abi,
1385
- version,
1386
- orchestratorAddress: orchAddress,
1387
- orchestratorAbi: orchAbi
1344
+ abi: isSameAddress(address, this.escrowV2Address) ? primaryEscrowAbi : this.escrowAbi,
1345
+ orchestratorAddress,
1346
+ orchestratorAbi: resolveOrchestratorAbi(orchestratorAddress),
1347
+ version: "v2"
1388
1348
  });
1389
1349
  }
1390
- const primaryEscrowVersion = resolveEscrowVersion(this.escrowAddress);
1391
- const primaryEscrowOrchestratorAddress = resolveEscrowOrchestratorAddress(
1392
- this.escrowAddress,
1393
- primaryEscrowVersion
1394
- );
1395
- registerEscrow({
1396
- address: this.escrowAddress,
1397
- abi: this.escrowAbi,
1398
- version: primaryEscrowVersion,
1399
- orchestratorAddress: primaryEscrowOrchestratorAddress,
1400
- orchestratorAbi: resolveEscrowOrchestratorAbi(
1401
- primaryEscrowOrchestratorAddress,
1402
- primaryEscrowVersion
1403
- )
1404
- });
1405
1350
  }
1406
1351
  getEscrowContextByAddress(address) {
1407
1352
  if (!address) return void 0;
@@ -1416,33 +1361,21 @@ var ContractRouter = class {
1416
1361
  if (explicitEscrow) {
1417
1362
  const explicitContext = this.getEscrowContextByAddress(explicitEscrow);
1418
1363
  if (explicitContext) return explicitContext;
1419
- const isExplicitV2 = !!this.escrowV2Address && explicitEscrow.toLowerCase() === this.escrowV2Address.toLowerCase();
1420
- const isExplicitLegacy = !!this.legacyEscrowAddress && explicitEscrow.toLowerCase() === this.legacyEscrowAddress.toLowerCase();
1421
- const inferredVersion = isExplicitV2 ? "v2" : isExplicitLegacy ? "legacy" : options?.preferV2 === false ? "legacy" : options?.preferV2 === true ? "v2" : this.escrowV2Abi ? "v2" : "legacy";
1364
+ const fallbackOrchestrator = this.resolveOrchestratorForEscrow(explicitEscrow);
1422
1365
  return {
1423
1366
  address: explicitEscrow,
1424
- abi: inferredVersion === "legacy" ? this.legacyEscrowAbi ?? this.escrowAbi : this.escrowV2Abi ?? this.escrowAbi,
1425
- orchestratorAddress: inferredVersion === "legacy" ? this.legacyOrchestratorAddress ?? this.orchestratorAddress : this.orchestratorV2Address ?? this.orchestratorAddress,
1426
- orchestratorAbi: inferredVersion === "legacy" ? this.legacyOrchestratorAbi ?? this.orchestratorAbi : this.orchestratorV2Abi ?? this.orchestratorAbi,
1427
- version: inferredVersion
1367
+ abi: this.escrowV2Abi ?? this.escrowAbi,
1368
+ orchestratorAddress: fallbackOrchestrator?.address ?? this.orchestratorV2Address ?? this.orchestratorAddress,
1369
+ orchestratorAbi: fallbackOrchestrator?.abi ?? this.orchestratorV2Abi ?? this.orchestratorAbi,
1370
+ version: "v2"
1428
1371
  };
1429
1372
  }
1430
- if (options?.preferV2 === false) {
1431
- const legacyContext = this.getEscrowContexts().find(
1432
- (context) => context.version === "legacy"
1433
- );
1434
- if (legacyContext) return legacyContext;
1435
- }
1436
- if (options?.preferV2) {
1437
- const v2Context = this.getEscrowContexts().find((context) => context.version === "v2");
1438
- if (v2Context) return v2Context;
1439
- }
1440
1373
  return this.getEscrowContextByAddress(this.escrowAddress) ?? {
1441
1374
  address: this.escrowAddress,
1442
1375
  abi: this.escrowAbi,
1443
- orchestratorAddress: this.orchestratorAddress,
1444
- orchestratorAbi: this.orchestratorAbi,
1445
- version: this.escrowV2Address && this.escrowAddress.toLowerCase() === this.escrowV2Address.toLowerCase() ? "v2" : "legacy"
1376
+ orchestratorAddress: this.orchestratorV2Address ?? this.orchestratorAddress,
1377
+ orchestratorAbi: this.orchestratorV2Abi ?? this.orchestratorAbi,
1378
+ version: "v2"
1446
1379
  };
1447
1380
  }
1448
1381
  getEscrowContexts() {
@@ -1452,26 +1385,21 @@ var ContractRouter = class {
1452
1385
  {
1453
1386
  address: this.escrowAddress,
1454
1387
  abi: this.escrowAbi,
1455
- orchestratorAddress: this.orchestratorAddress,
1456
- orchestratorAbi: this.orchestratorAbi,
1457
- version: "legacy"
1388
+ orchestratorAddress: this.orchestratorV2Address ?? this.orchestratorAddress,
1389
+ orchestratorAbi: this.orchestratorV2Abi ?? this.orchestratorAbi,
1390
+ version: "v2"
1458
1391
  }
1459
1392
  ];
1460
1393
  }
1461
- resolveOrchestratorForEscrow(escrowAddress, preferV2 = false) {
1394
+ resolveOrchestratorForEscrow(escrowAddress, _preferV2 = false) {
1462
1395
  if (escrowAddress) {
1463
1396
  const escrowContext = this.getEscrowContextByAddress(escrowAddress);
1464
1397
  const fromEscrow = this.getOrchestratorContextByAddress(escrowContext?.orchestratorAddress);
1465
1398
  if (fromEscrow) return fromEscrow;
1466
1399
  }
1467
- if (preferV2) {
1468
- const v2 = Array.from(this._orchestratorContextsByAddress.values()).find(
1469
- (context) => context.version === "v2"
1470
- );
1471
- if (v2) return v2;
1472
- } else {
1473
- const legacyPrimary = this.getOrchestratorContextByAddress(this.legacyOrchestratorAddress);
1474
- if (legacyPrimary) return legacyPrimary;
1400
+ if (this.orchestratorV2Address) {
1401
+ const primary = this.getOrchestratorContextByAddress(this.orchestratorV2Address);
1402
+ if (primary) return primary;
1475
1403
  }
1476
1404
  if (this.orchestratorAddress) {
1477
1405
  const primary = this.getOrchestratorContextByAddress(this.orchestratorAddress);
@@ -1481,13 +1409,6 @@ var ContractRouter = class {
1481
1409
  const context = this.getOrchestratorContextByAddress(address);
1482
1410
  if (context) return context;
1483
1411
  }
1484
- if (this.legacyOrchestratorAddress && this.legacyOrchestratorAbi) {
1485
- return {
1486
- address: this.legacyOrchestratorAddress,
1487
- abi: this.legacyOrchestratorAbi,
1488
- version: "legacy"
1489
- };
1490
- }
1491
1412
  if (this.orchestratorV2Address && this.orchestratorV2Abi) {
1492
1413
  return {
1493
1414
  address: this.orchestratorV2Address,
@@ -1495,6 +1416,13 @@ var ContractRouter = class {
1495
1416
  version: "v2"
1496
1417
  };
1497
1418
  }
1419
+ if (this.orchestratorAddress && this.orchestratorAbi) {
1420
+ return {
1421
+ address: this.orchestratorAddress,
1422
+ abi: this.orchestratorAbi,
1423
+ version: "v2"
1424
+ };
1425
+ }
1498
1426
  return void 0;
1499
1427
  }
1500
1428
  buildProtocolViewerContexts(options) {
@@ -1509,17 +1437,18 @@ var ContractRouter = class {
1509
1437
  };
1510
1438
  add(options?.escrowAddress, options?.orchestratorAddress);
1511
1439
  if (options?.escrowAddress && !options?.orchestratorAddress) {
1512
- const resolved = this.resolveOrchestratorForEscrow(options.escrowAddress, true)?.address ?? this.resolveOrchestratorForEscrow(options.escrowAddress, false)?.address;
1513
- add(options.escrowAddress, resolved);
1440
+ add(options.escrowAddress, this.resolveOrchestratorForEscrow(options.escrowAddress)?.address);
1514
1441
  }
1515
1442
  for (const context of this.getEscrowContexts()) {
1516
- const fallbackOrchestrator = this.resolveOrchestratorForEscrow(context.address, context.version === "v2")?.address ?? this.resolveOrchestratorForEscrow(context.address)?.address ?? context.orchestratorAddress;
1517
- add(context.address, context.orchestratorAddress ?? fallbackOrchestrator);
1443
+ add(
1444
+ context.address,
1445
+ context.orchestratorAddress ?? this.resolveOrchestratorForEscrow(context.address)?.address
1446
+ );
1518
1447
  }
1519
1448
  return contexts;
1520
1449
  }
1521
1450
  get defaultPreferV2() {
1522
- return this._defaultPreferV2;
1451
+ return true;
1523
1452
  }
1524
1453
  };
1525
1454
 
@@ -3986,6 +3915,20 @@ var RATE_MANAGER_FIELDS = `
3986
3915
  createdAt
3987
3916
  updatedAt
3988
3917
  `;
3918
+ var LEGACY_RATE_MANAGER_FIELDS = `
3919
+ id
3920
+ chainId
3921
+ rateManagerAddress
3922
+ rateManagerId
3923
+ manager
3924
+ feeRecipient
3925
+ maxFee
3926
+ fee
3927
+ name
3928
+ uri
3929
+ createdAt
3930
+ updatedAt
3931
+ `;
3989
3932
  var RATE_MANAGER_AGGREGATE_FIELDS = `
3990
3933
  id
3991
3934
  chainId
@@ -4001,6 +3944,20 @@ var RATE_MANAGER_AGGREGATE_FIELDS = `
4001
3944
  firstSeenAt
4002
3945
  updatedAt
4003
3946
  `;
3947
+ var LEGACY_RATE_MANAGER_AGGREGATE_FIELDS = `
3948
+ id
3949
+ chainId
3950
+ rateManagerId
3951
+ manager
3952
+ totalFilledVolume
3953
+ totalFeeAmount
3954
+ totalPnlUsdCents
3955
+ fulfilledIntents
3956
+ currentDelegatedBalance
3957
+ currentDelegatedDeposits
3958
+ firstSeenAt
3959
+ updatedAt
3960
+ `;
4004
3961
  var RATE_MANAGER_RATE_FIELDS = `
4005
3962
  id
4006
3963
  chainId
@@ -4016,9 +3973,7 @@ var DEPOSIT_DELEGATION_FIELDS = `
4016
3973
  chainId
4017
3974
  rateManagerId
4018
3975
  rateManagerAddress
4019
- depositId: id
4020
3976
  delegatedAt
4021
- createdAt: delegatedAt
4022
3977
  updatedAt
4023
3978
  `;
4024
3979
  var LEGACY_RATE_MANAGER_DELEGATION_FIELDS = `
@@ -4094,6 +4049,7 @@ var RATE_MANAGER_LIST_QUERY = (
4094
4049
  `
4095
4050
  query VaultList(
4096
4051
  $where: RateManager_bool_exp
4052
+ $aggregateWhere: ManagerAggregateStats_bool_exp
4097
4053
  $order_by: [RateManager_order_by!]
4098
4054
  $limit: Int
4099
4055
  $offset: Int
@@ -4101,12 +4057,31 @@ var RATE_MANAGER_LIST_QUERY = (
4101
4057
  RateManager(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {
4102
4058
  ${RATE_MANAGER_FIELDS}
4103
4059
  }
4104
- ManagerAggregateStats {
4060
+ ManagerAggregateStats(where: $aggregateWhere) {
4105
4061
  ${RATE_MANAGER_AGGREGATE_FIELDS}
4106
4062
  }
4107
4063
  }
4108
4064
  `
4109
4065
  );
4066
+ var LEGACY_RATE_MANAGER_LIST_QUERY = (
4067
+ /* GraphQL */
4068
+ `
4069
+ query VaultList(
4070
+ $where: RateManager_bool_exp
4071
+ $aggregateWhere: ManagerAggregateStats_bool_exp
4072
+ $order_by: [RateManager_order_by!]
4073
+ $limit: Int
4074
+ $offset: Int
4075
+ ) {
4076
+ RateManager(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {
4077
+ ${LEGACY_RATE_MANAGER_FIELDS}
4078
+ }
4079
+ ManagerAggregateStats(where: $aggregateWhere) {
4080
+ ${LEGACY_RATE_MANAGER_AGGREGATE_FIELDS}
4081
+ }
4082
+ }
4083
+ `
4084
+ );
4110
4085
  var RATE_MANAGER_DETAIL_QUERY = (
4111
4086
  /* GraphQL */
4112
4087
  `
@@ -4153,13 +4128,13 @@ var LEGACY_RATE_MANAGER_DETAIL_QUERY = (
4153
4128
  $statsLimit: Int
4154
4129
  ) {
4155
4130
  RateManager(where: $managerWhere) {
4156
- ${RATE_MANAGER_FIELDS}
4131
+ ${LEGACY_RATE_MANAGER_FIELDS}
4157
4132
  }
4158
4133
  RateManagerRate(where: $rateWhere) {
4159
4134
  ${RATE_MANAGER_RATE_FIELDS}
4160
4135
  }
4161
4136
  ManagerAggregateStats(where: $aggregateWhere) {
4162
- ${RATE_MANAGER_AGGREGATE_FIELDS}
4137
+ ${LEGACY_RATE_MANAGER_AGGREGATE_FIELDS}
4163
4138
  }
4164
4139
  ManagerStats(
4165
4140
  where: $statsWhere
@@ -5192,6 +5167,25 @@ function extractEscrowAddressFromCompositeDepositId(compositeDepositId) {
5192
5167
  const [escrowAddress] = compositeDepositId.split("_");
5193
5168
  return escrowAddress?.startsWith("0x") ? escrowAddress.toLowerCase() : null;
5194
5169
  }
5170
+ function parseRateManagerFilterIds(rateManagerIds) {
5171
+ const bare = /* @__PURE__ */ new Set();
5172
+ const scoped = /* @__PURE__ */ new Map();
5173
+ for (const value of rateManagerIds) {
5174
+ const scopedRateManager = parseScopedRateManagerFilterId(value);
5175
+ if (scopedRateManager) {
5176
+ scoped.set(
5177
+ getManagerScopeKey(scopedRateManager.rateManagerId, scopedRateManager.rateManagerAddress),
5178
+ scopedRateManager
5179
+ );
5180
+ continue;
5181
+ }
5182
+ const normalizedRateManagerId = normalizeRateManagerId(value);
5183
+ if (normalizedRateManagerId) {
5184
+ bare.add(normalizedRateManagerId);
5185
+ }
5186
+ }
5187
+ return { bare, scoped };
5188
+ }
5195
5189
  function buildDepositScopeKey(scope) {
5196
5190
  return `${scope.escrow}:${scope.depositIdOnContract}`;
5197
5191
  }
@@ -5270,6 +5264,29 @@ var IndexerRateManagerService = class {
5270
5264
  constructor(client) {
5271
5265
  this.client = client;
5272
5266
  }
5267
+ buildRateManagerScopeWhere(rateManagerIds) {
5268
+ if (!rateManagerIds?.length) return void 0;
5269
+ const { bare, scoped } = parseRateManagerFilterIds(rateManagerIds);
5270
+ const scopeConditions = [];
5271
+ if (bare.size > 0) {
5272
+ scopeConditions.push({
5273
+ rateManagerId: { _in: [...bare] }
5274
+ });
5275
+ }
5276
+ for (const scopedRateManager of scoped.values()) {
5277
+ scopeConditions.push({
5278
+ rateManagerId: { _eq: scopedRateManager.rateManagerId },
5279
+ rateManagerAddress: { _eq: scopedRateManager.rateManagerAddress }
5280
+ });
5281
+ }
5282
+ if (scopeConditions.length === 1) {
5283
+ return scopeConditions[0];
5284
+ }
5285
+ if (scopeConditions.length > 1) {
5286
+ return { _or: scopeConditions };
5287
+ }
5288
+ return void 0;
5289
+ }
5273
5290
  buildWhere(filter) {
5274
5291
  if (!filter) return void 0;
5275
5292
  const where = {};
@@ -5282,46 +5299,44 @@ var IndexerRateManagerService = class {
5282
5299
  if (filter.maxFee) {
5283
5300
  where.maxFee = { _lte: filter.maxFee };
5284
5301
  }
5285
- if (filter.rateManagerIds?.length) {
5286
- const bareRateManagerIds = /* @__PURE__ */ new Set();
5287
- const scopedRateManagers = /* @__PURE__ */ new Map();
5288
- for (const value of filter.rateManagerIds) {
5289
- const scopedRateManager = parseScopedRateManagerFilterId(value);
5290
- if (scopedRateManager) {
5291
- scopedRateManagers.set(
5292
- getManagerScopeKey(
5293
- scopedRateManager.rateManagerId,
5294
- scopedRateManager.rateManagerAddress
5295
- ),
5296
- scopedRateManager
5297
- );
5298
- continue;
5299
- }
5300
- const normalizedRateManagerId = normalizeRateManagerId(value);
5301
- if (normalizedRateManagerId) {
5302
- bareRateManagerIds.add(normalizedRateManagerId);
5303
- }
5304
- }
5305
- const scopeConditions = [];
5306
- if (bareRateManagerIds.size > 0) {
5307
- scopeConditions.push({
5308
- rateManagerId: { _in: [...bareRateManagerIds] }
5309
- });
5310
- }
5311
- for (const scopedRateManager of scopedRateManagers.values()) {
5312
- scopeConditions.push({
5313
- rateManagerId: { _eq: scopedRateManager.rateManagerId },
5314
- rateManagerAddress: { _eq: scopedRateManager.rateManagerAddress }
5315
- });
5316
- }
5317
- if (scopeConditions.length === 1) {
5318
- Object.assign(where, scopeConditions[0]);
5319
- } else if (scopeConditions.length > 1) {
5320
- where._or = scopeConditions;
5321
- }
5302
+ const scopeWhere = this.buildRateManagerScopeWhere(filter.rateManagerIds);
5303
+ if (scopeWhere) {
5304
+ Object.assign(where, scopeWhere);
5322
5305
  }
5323
5306
  return Object.keys(where).length ? where : void 0;
5324
5307
  }
5308
+ buildAggregateWhere(filter) {
5309
+ return this.buildRateManagerScopeWhere(filter?.rateManagerIds) ?? {};
5310
+ }
5311
+ buildLegacyAggregateWhere(filter) {
5312
+ const rateManagerIds = filter?.rateManagerIds;
5313
+ if (!rateManagerIds?.length) return {};
5314
+ const { bare, scoped } = parseRateManagerFilterIds(rateManagerIds);
5315
+ const scopeConditions = [];
5316
+ if (bare.size > 0) {
5317
+ scopeConditions.push({
5318
+ rateManagerId: { _in: [...bare] }
5319
+ });
5320
+ }
5321
+ for (const scopedRateManager of scoped.values()) {
5322
+ scopeConditions.push({
5323
+ rateManagerId: { _eq: scopedRateManager.rateManagerId },
5324
+ id: {
5325
+ _ilike: buildRateManagerAddressScopedIdPattern(
5326
+ scopedRateManager.rateManagerId,
5327
+ scopedRateManager.rateManagerAddress
5328
+ )
5329
+ }
5330
+ });
5331
+ }
5332
+ if (scopeConditions.length === 1) {
5333
+ return scopeConditions[0] ?? {};
5334
+ }
5335
+ if (scopeConditions.length > 1) {
5336
+ return { _or: scopeConditions };
5337
+ }
5338
+ return {};
5339
+ }
5325
5340
  buildOrderBy(pagination) {
5326
5341
  const rawField = pagination?.orderBy ?? "createdAt";
5327
5342
  const field = isAggregateOrderField(rawField) ? "createdAt" : rawField;
@@ -5347,11 +5362,21 @@ var IndexerRateManagerService = class {
5347
5362
  if (hasHook === void 0) return rows;
5348
5363
  return hasHook ? [] : rows;
5349
5364
  }
5350
- async queryRateManagerList(variables) {
5351
- return this.client.query({
5352
- query: RATE_MANAGER_LIST_QUERY,
5353
- variables
5354
- });
5365
+ async queryRateManagerList(variables, legacyVariables) {
5366
+ try {
5367
+ return await this.client.query({
5368
+ query: RATE_MANAGER_LIST_QUERY,
5369
+ variables
5370
+ });
5371
+ } catch (error) {
5372
+ if (!isSchemaCompatibilityError(error)) {
5373
+ throw error;
5374
+ }
5375
+ return this.client.query({
5376
+ query: LEGACY_RATE_MANAGER_LIST_QUERY,
5377
+ variables: legacyVariables
5378
+ });
5379
+ }
5355
5380
  }
5356
5381
  buildDelegationOrderBy(pagination) {
5357
5382
  const rawField = pagination?.orderBy ?? "updatedAt";
@@ -5446,11 +5471,21 @@ var IndexerRateManagerService = class {
5446
5471
  const limit = pagination?.limit ?? DEFAULT_LIMIT2;
5447
5472
  const offset = pagination?.offset ?? 0;
5448
5473
  const where = this.buildWhere(filter);
5474
+ const aggregateWhere = this.buildAggregateWhere(filter);
5475
+ const legacyAggregateWhere = this.buildLegacyAggregateWhere(filter);
5449
5476
  if (isAggregateOrderField(orderBy)) {
5450
- const result2 = await this.queryRateManagerList({
5451
- where,
5452
- order_by: [{ createdAt: "desc" }]
5453
- });
5477
+ const result2 = await this.queryRateManagerList(
5478
+ {
5479
+ where,
5480
+ aggregateWhere,
5481
+ order_by: [{ createdAt: "desc" }]
5482
+ },
5483
+ {
5484
+ where,
5485
+ aggregateWhere: legacyAggregateWhere,
5486
+ order_by: [{ createdAt: "desc" }]
5487
+ }
5488
+ );
5454
5489
  const scopedRows = this.applyHookFilter(this.toRateManagerListItems(result2), filter?.hasHook);
5455
5490
  const sorted = scopedRows.sort((a, b) => {
5456
5491
  const av = orderBy === "currentDelegatedBalance" ? toSafeBigInt(a.aggregate?.currentDelegatedBalance) : toSafeBigInt(a.aggregate?.totalFilledVolume);
@@ -5467,12 +5502,22 @@ var IndexerRateManagerService = class {
5467
5502
  });
5468
5503
  return sorted.slice(offset, offset + limit);
5469
5504
  }
5470
- const result = await this.queryRateManagerList({
5471
- where,
5472
- order_by: this.buildOrderBy(pagination),
5473
- limit,
5474
- offset
5475
- });
5505
+ const result = await this.queryRateManagerList(
5506
+ {
5507
+ where,
5508
+ aggregateWhere,
5509
+ order_by: this.buildOrderBy(pagination),
5510
+ limit,
5511
+ offset
5512
+ },
5513
+ {
5514
+ where,
5515
+ aggregateWhere: legacyAggregateWhere,
5516
+ order_by: this.buildOrderBy(pagination),
5517
+ limit,
5518
+ offset
5519
+ }
5520
+ );
5476
5521
  return this.applyHookFilter(this.toRateManagerListItems(result), filter?.hasHook);
5477
5522
  }
5478
5523
  async fetchRateManagerDetail(rateManagerId, options) {
@@ -7034,58 +7079,32 @@ var Zkp2pClient = class {
7034
7079
  }
7035
7080
  return out;
7036
7081
  };
7037
- const isSameAddress2 = (left, right) => !!left && !!right && left.toLowerCase() === right.toLowerCase();
7038
- this.legacyEscrowAddress = toAddress(addresses.escrow);
7039
- this.legacyEscrowAbi = abis.escrow;
7040
- this.escrowV2Address = toAddress(addresses.escrowV2);
7082
+ this.escrowV2Address = toAddress(addresses.escrowV2 ?? addresses.escrow);
7041
7083
  this.escrowV2Abi = abis.escrowV2 ?? abis.escrow;
7042
- this.legacyOrchestratorAddress = toAddress(addresses.orchestrator);
7043
- this.legacyOrchestratorAbi = abis.orchestrator;
7044
- this.orchestratorV2Address = toAddress(addresses.orchestratorV2);
7084
+ this.orchestratorV2Address = toAddress(
7085
+ addresses.orchestratorV2 ?? addresses.orchestrator
7086
+ );
7045
7087
  this.orchestratorV2Abi = abis.orchestratorV2 ?? abis.orchestrator;
7046
7088
  const configuredEscrowAddresses = (addresses.escrowAddresses ?? []).map((value) => toAddress(value)).filter(Boolean);
7047
7089
  const configuredOrchestratorAddresses = (addresses.orchestratorAddresses ?? []).map((value) => toAddress(value)).filter(Boolean);
7048
- const inferLegacyAddress = (legacyAddress, v2Address, configuredAddresses) => {
7049
- if (legacyAddress && (!v2Address || !isSameAddress2(legacyAddress, v2Address))) {
7050
- return legacyAddress;
7051
- }
7052
- return configuredAddresses.find(
7053
- (candidate) => !v2Address || !isSameAddress2(candidate, v2Address)
7054
- ) ?? legacyAddress;
7055
- };
7056
- this.legacyEscrowAddress = inferLegacyAddress(
7057
- this.legacyEscrowAddress,
7058
- this.escrowV2Address,
7059
- configuredEscrowAddresses
7060
- );
7061
- this.legacyOrchestratorAddress = inferLegacyAddress(
7062
- this.legacyOrchestratorAddress,
7063
- this.orchestratorV2Address,
7064
- configuredOrchestratorAddresses
7065
- );
7066
- const defaultPreferV2 = opts.preferV2ByDefault !== void 0 ? opts.preferV2ByDefault : this.runtimeEnv === "staging";
7067
- const preferredEscrowAddress = defaultPreferV2 ? this.escrowV2Address : this.legacyEscrowAddress;
7068
- const fallbackEscrowAddress = defaultPreferV2 ? this.legacyEscrowAddress : this.escrowV2Address;
7069
- const preferredOrchestratorAddress = defaultPreferV2 ? this.orchestratorV2Address : this.legacyOrchestratorAddress;
7070
- const fallbackOrchestratorAddress = defaultPreferV2 ? this.legacyOrchestratorAddress : this.orchestratorV2Address;
7071
7090
  this.escrowAddresses = uniqAddresses([
7072
- preferredEscrowAddress,
7073
- fallbackEscrowAddress,
7091
+ this.escrowV2Address ?? toAddress(addresses.escrow),
7074
7092
  ...configuredEscrowAddresses
7075
7093
  ]);
7076
- this.orchestratorAddresses = uniqAddresses([
7077
- preferredOrchestratorAddress,
7078
- fallbackOrchestratorAddress,
7079
- ...configuredOrchestratorAddresses
7080
- ]);
7081
- this.escrowAddress = preferredEscrowAddress ?? fallbackEscrowAddress ?? this.escrowAddresses[0];
7082
- this.escrowAbi = defaultPreferV2 ? this.escrowV2Abi ?? this.legacyEscrowAbi ?? abis.escrow : this.legacyEscrowAbi ?? this.escrowV2Abi ?? abis.escrow;
7094
+ this.escrowAddress = this.escrowV2Address ?? toAddress(addresses.escrow) ?? this.escrowAddresses[0];
7095
+ this.escrowAbi = this.escrowV2Abi ?? abis.escrow;
7083
7096
  if (!this.escrowAddress || !this.escrowAbi) {
7084
7097
  throw new Error("Escrow not available for this chain/environment");
7085
7098
  }
7086
- this.orchestratorAddress = preferredOrchestratorAddress ?? fallbackOrchestratorAddress ?? this.orchestratorAddresses[0];
7087
- this.orchestratorAbi = defaultPreferV2 ? this.orchestratorV2Abi ?? this.legacyOrchestratorAbi ?? abis.orchestrator : this.legacyOrchestratorAbi ?? this.orchestratorV2Abi ?? abis.orchestrator;
7088
- this.unifiedPaymentVerifier = toAddress(addresses.unifiedPaymentVerifier);
7099
+ this.orchestratorAddresses = uniqAddresses([
7100
+ this.orchestratorV2Address ?? toAddress(addresses.orchestrator),
7101
+ ...configuredOrchestratorAddresses
7102
+ ]);
7103
+ this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
7104
+ this.orchestratorAbi = this.orchestratorV2Abi ?? abis.orchestrator;
7105
+ this.unifiedPaymentVerifier = toAddress(
7106
+ addresses.unifiedPaymentVerifierV2 ?? addresses.unifiedPaymentVerifier
7107
+ );
7089
7108
  this.protocolViewerAddress = toAddress(addresses.protocolViewer);
7090
7109
  this.protocolViewerAbi = abis.protocolViewer;
7091
7110
  const resolvedPvEntries = addresses.protocolViewerEntries;
@@ -7124,19 +7143,14 @@ var Zkp2pClient = class {
7124
7143
  this._router = new ContractRouter({
7125
7144
  escrowAddress: this.escrowAddress,
7126
7145
  escrowAbi: this.escrowAbi,
7127
- legacyEscrowAddress: this.legacyEscrowAddress,
7128
- legacyEscrowAbi: this.legacyEscrowAbi,
7129
7146
  escrowV2Address: this.escrowV2Address,
7130
7147
  escrowV2Abi: this.escrowV2Abi,
7131
7148
  escrowAddresses: this.escrowAddresses,
7132
7149
  orchestratorAddress: this.orchestratorAddress,
7133
7150
  orchestratorAbi: this.orchestratorAbi,
7134
- legacyOrchestratorAddress: this.legacyOrchestratorAddress,
7135
- legacyOrchestratorAbi: this.legacyOrchestratorAbi,
7136
7151
  orchestratorV2Address: this.orchestratorV2Address,
7137
7152
  orchestratorV2Abi: this.orchestratorV2Abi,
7138
- orchestratorAddresses: this.orchestratorAddresses,
7139
- defaultPreferV2
7153
+ orchestratorAddresses: this.orchestratorAddresses
7140
7154
  });
7141
7155
  const maybeUsdc = addresses.usdc;
7142
7156
  if (maybeUsdc) this._usdcAddress = maybeUsdc;
@@ -7265,7 +7279,7 @@ var Zkp2pClient = class {
7265
7279
  const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
7266
7280
  if (resolved) return resolved;
7267
7281
  if (options?.preferV2 !== void 0) {
7268
- return this.resolveEscrowContext({ preferV2: options.preferV2 }).address;
7282
+ return this.resolveEscrowContext().address;
7269
7283
  }
7270
7284
  throw new Error(`${methodName} requires escrowAddress or composite depositId`);
7271
7285
  }
@@ -7303,7 +7317,10 @@ var Zkp2pClient = class {
7303
7317
  return this._router.getOrchestratorContextByAddress(address);
7304
7318
  }
7305
7319
  resolveEscrowContext(options) {
7306
- return this._router.resolveEscrowContext(options);
7320
+ return this._router.resolveEscrowContext({
7321
+ escrowAddress: options?.escrowAddress,
7322
+ depositId: options?.depositId
7323
+ });
7307
7324
  }
7308
7325
  async resolveEscrowContextForDepositWrite(options) {
7309
7326
  const explicitEscrow = options?.escrowAddress ?? (options?.depositId !== void 0 ? this.parseEscrowAddressFromCompositeDepositId(options.depositId) : void 0);
@@ -7406,21 +7423,9 @@ var Zkp2pClient = class {
7406
7423
  if (explicit) return explicit;
7407
7424
  if (options?.orchestratorAddress) {
7408
7425
  const addr = options.orchestratorAddress;
7409
- const isSame = (a, b) => !!a && !!b && a.toLowerCase() === b.toLowerCase();
7410
- let version;
7411
- let abi;
7412
- if (isSame(addr, this.orchestratorV2Address)) {
7413
- version = "v2";
7414
- abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
7415
- } else if (isSame(addr, this.legacyOrchestratorAddress)) {
7416
- version = "legacy";
7417
- abi = this.legacyOrchestratorAbi ?? this.orchestratorAbi;
7418
- } else {
7419
- version = this.orchestratorV2Abi ? "v2" : "legacy";
7420
- abi = this.orchestratorAbi ?? this.orchestratorV2Abi ?? this.legacyOrchestratorAbi;
7421
- }
7426
+ const abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
7422
7427
  if (!abi) throw new Error("Orchestrator not available");
7423
- return { address: addr, abi, version };
7428
+ return { address: addr, abi, version: "v2" };
7424
7429
  }
7425
7430
  if (options?.intentHash) {
7426
7431
  try {
@@ -7455,30 +7460,16 @@ var Zkp2pClient = class {
7455
7460
  if (fromEscrow) return fromEscrow;
7456
7461
  }
7457
7462
  if (options?.intentHash) {
7458
- const preferV2 = options.preferV2 ?? this._router.defaultPreferV2;
7459
- const primaryAddress = preferV2 ? this.orchestratorV2Address : this.legacyOrchestratorAddress;
7460
- const secondaryAddress = preferV2 ? this.legacyOrchestratorAddress : this.orchestratorV2Address;
7463
+ const primaryAddress = this.orchestratorV2Address ?? this.orchestratorAddress;
7461
7464
  const primaryContext = this.getOrchestratorContextByAddress(primaryAddress);
7462
7465
  if (primaryContext) return primaryContext;
7463
- const secondaryContext = this.getOrchestratorContextByAddress(secondaryAddress);
7464
- if (secondaryContext) return secondaryContext;
7465
7466
  if (primaryAddress) {
7466
- const primaryAbi = preferV2 ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.legacyOrchestratorAbi ?? this.orchestratorAbi;
7467
+ const primaryAbi = this.orchestratorV2Abi ?? this.orchestratorAbi;
7467
7468
  if (primaryAbi) {
7468
7469
  return {
7469
7470
  address: primaryAddress,
7470
7471
  abi: primaryAbi,
7471
- version: preferV2 ? "v2" : "legacy"
7472
- };
7473
- }
7474
- }
7475
- if (secondaryAddress) {
7476
- const secondaryAbi = preferV2 ? this.legacyOrchestratorAbi ?? this.orchestratorAbi : this.orchestratorV2Abi ?? this.orchestratorAbi;
7477
- if (secondaryAbi) {
7478
- return {
7479
- address: secondaryAddress,
7480
- abi: secondaryAbi,
7481
- version: preferV2 ? "legacy" : "v2"
7472
+ version: "v2"
7482
7473
  };
7483
7474
  }
7484
7475
  }
@@ -8613,11 +8604,9 @@ var Zkp2pClient = class {
8613
8604
  escrow: this.escrowAddress,
8614
8605
  escrowV2: this.escrowV2Address,
8615
8606
  escrowAddresses: this.escrowAddresses,
8616
- legacyEscrow: this.legacyEscrowAddress,
8617
8607
  orchestrator: this.orchestratorAddress,
8618
8608
  orchestratorV2: this.orchestratorV2Address,
8619
8609
  orchestratorAddresses: this.orchestratorAddresses,
8620
- legacyOrchestrator: this.legacyOrchestratorAddress,
8621
8610
  protocolViewer: this.protocolViewerAddress,
8622
8611
  protocolViewerEntries: this._protocolViewerEntries.map((e) => e.address),
8623
8612
  unifiedPaymentVerifier: this.unifiedPaymentVerifier,
@@ -8867,23 +8856,7 @@ var classifyDelegationState = (currentRateManagerId, currentRegistry, targetRate
8867
8856
  }
8868
8857
  return "delegated_elsewhere";
8869
8858
  };
8870
- var getDelegationRoute = (client, escrow) => {
8871
- const escrowLower = escrow.toLowerCase();
8872
- const legacyLower = client.legacyEscrowAddress?.toLowerCase();
8873
- if (legacyLower && escrowLower === legacyLower) return "legacy";
8874
- if (client.escrowAddresses && client.escrowAddresses.length > 0) {
8875
- const v2Candidates = client.escrowAddresses.filter(
8876
- (addr) => !legacyLower || addr.toLowerCase() !== legacyLower
8877
- );
8878
- if (v2Candidates.some((addr) => addr.toLowerCase() === escrowLower)) {
8879
- return "v2";
8880
- }
8881
- }
8882
- if (client.escrowV2Address && escrowLower === client.escrowV2Address.toLowerCase()) {
8883
- return "v2";
8884
- }
8885
- return "legacy";
8886
- };
8859
+ var getDelegationRoute = (_client, _escrow) => "v2";
8887
8860
 
8888
8861
  exports.BASE_BUILDER_CODE = BASE_BUILDER_CODE;
8889
8862
  exports.CHAINLINK_ORACLE_ADAPTER = CHAINLINK_ORACLE_ADAPTER;
@@ -8916,6 +8889,7 @@ exports.appendAttributionToCalldata = appendAttributionToCalldata;
8916
8889
  exports.asciiToBytes32 = asciiToBytes32;
8917
8890
  exports.assertValidReferrerFeeConfig = assertValidReferrerFeeConfig;
8918
8891
  exports.classifyDelegationState = classifyDelegationState;
8892
+ exports.compareEventCursorIdsByRecency = compareEventCursorIdsByRecency;
8919
8893
  exports.convertDepositsForLiquidity = convertDepositsForLiquidity;
8920
8894
  exports.convertIndexerDepositToEscrowView = convertIndexerDepositToEscrowView;
8921
8895
  exports.convertIndexerIntentsToEscrowViews = convertIndexerIntentsToEscrowViews;