@zkp2p/sdk 0.1.1 → 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/README.md +2 -3
- package/dist/{chunk-YQ7VL7ZJ.mjs → chunk-J33LUXNA.mjs} +4 -24
- package/dist/chunk-J33LUXNA.mjs.map +1 -0
- package/dist/{chunk-YLITJ7SI.mjs → chunk-LPJE2MN7.mjs} +11 -48
- package/dist/chunk-LPJE2MN7.mjs.map +1 -0
- package/dist/index.cjs +271 -300
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +5 -16
- package/dist/index.d.ts +5 -16
- package/dist/index.mjs +276 -270
- package/dist/index.mjs.map +1 -1
- package/dist/protocolViewerParsers-VVASNOXW.mjs +4 -0
- package/dist/{protocolViewerParsers-63MFZ5OF.mjs.map → protocolViewerParsers-VVASNOXW.mjs.map} +1 -1
- package/dist/react.cjs +9 -54
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.mjs +2 -2
- package/dist/{vaultUtils-J1WboG1T.d.mts → vaultUtils-zw4Xgu-G.d.mts} +27 -38
- package/dist/{vaultUtils-J1WboG1T.d.ts → vaultUtils-zw4Xgu-G.d.ts} +27 -38
- package/package.json +17 -17
- package/dist/chunk-YLITJ7SI.mjs.map +0 -1
- package/dist/chunk-YQ7VL7ZJ.mjs.map +0 -1
- package/dist/protocolViewerParsers-63MFZ5OF.mjs +0 -4
package/dist/index.cjs
CHANGED
|
@@ -257,14 +257,6 @@ function uniqueAddresses(...values) {
|
|
|
257
257
|
function addressesEqual(left, right) {
|
|
258
258
|
return Boolean(left && right && left.toLowerCase() === right.toLowerCase());
|
|
259
259
|
}
|
|
260
|
-
function firstDistinctAddress(candidates, current) {
|
|
261
|
-
for (const candidate of candidates) {
|
|
262
|
-
if (!isValidAddress(candidate)) continue;
|
|
263
|
-
if (addressesEqual(candidate, current)) continue;
|
|
264
|
-
return candidate;
|
|
265
|
-
}
|
|
266
|
-
return void 0;
|
|
267
|
-
}
|
|
268
260
|
function readRuntimeEnv(key) {
|
|
269
261
|
try {
|
|
270
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)) });
|
|
@@ -313,14 +305,12 @@ function getContracts(chainId, env = "production") {
|
|
|
313
305
|
escrowV2: pickAddress(baseContracts, ["EscrowV2", "Escrow_V2"]),
|
|
314
306
|
escrowAddresses: uniqueAddresses(
|
|
315
307
|
pickAddress(baseContracts, ["EscrowV2", "Escrow_V2"]),
|
|
316
|
-
pickAddress(baseContracts, ["Escrow"]),
|
|
317
308
|
...exports.HISTORICAL_ESCROW_ADDRESSES.base
|
|
318
309
|
),
|
|
319
310
|
orchestrator: pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]) ?? pickAddress(baseContracts, ["Orchestrator"]),
|
|
320
311
|
orchestratorV2: pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]),
|
|
321
312
|
orchestratorAddresses: uniqueAddresses(
|
|
322
313
|
pickAddress(baseContracts, ["OrchestratorV2", "Orchestrator_V2"]),
|
|
323
|
-
pickAddress(baseContracts, ["Orchestrator"]),
|
|
324
314
|
...HISTORICAL_ORCHESTRATOR_ADDRESSES.base
|
|
325
315
|
),
|
|
326
316
|
unifiedPaymentVerifier: pickAddress(baseContracts, [
|
|
@@ -380,35 +370,25 @@ function getContracts(chainId, env = "production") {
|
|
|
380
370
|
"VITE_ESCROW_V2_ADDRESS"
|
|
381
371
|
]);
|
|
382
372
|
const stagingEscrowCurrent = stagingEscrowV2Override ?? pickAddress(sc, ["EscrowV2", "Escrow_V2"]) ?? pickAddress(sc, ["Escrow"]) ?? STAGING_ESCROW_V2_FALLBACK;
|
|
383
|
-
const stagingEscrowLegacy = firstDistinctAddress(
|
|
384
|
-
[pickAddress(sc, ["Escrow"]), ...exports.HISTORICAL_ESCROW_ADDRESSES.base_staging],
|
|
385
|
-
stagingEscrowCurrent
|
|
386
|
-
);
|
|
387
373
|
const stagingOrchestratorV2Override = resolveRuntimeAddressOverride([
|
|
388
374
|
"VITE_BASE_STAGING_ORCHESTRATOR_V2_ADDRESS",
|
|
389
375
|
"VITE_ORCHESTRATOR_V2_ADDRESS",
|
|
390
376
|
"VITE_ORCHESTRATORV2_ADDRESS"
|
|
391
377
|
]);
|
|
392
378
|
const stagingOrchestratorCurrent = stagingOrchestratorV2Override ?? pickAddress(sc, ["OrchestratorV2", "Orchestrator_V2"]) ?? pickAddress(sc, ["Orchestrator"]) ?? STAGING_ORCHESTRATOR_V2_FALLBACK;
|
|
393
|
-
const stagingOrchestratorLegacy = firstDistinctAddress(
|
|
394
|
-
[pickAddress(sc, ["Orchestrator"]), ...HISTORICAL_ORCHESTRATOR_ADDRESSES.base_staging],
|
|
395
|
-
stagingOrchestratorCurrent
|
|
396
|
-
);
|
|
397
379
|
const stagingRateManagerV1 = pickAddress(sc, ["RateManagerV1", "DepositRateManagerRegistryV1"]);
|
|
398
380
|
return {
|
|
399
381
|
addresses: {
|
|
400
|
-
escrow: stagingEscrowCurrent
|
|
382
|
+
escrow: stagingEscrowCurrent,
|
|
401
383
|
escrowV2: stagingEscrowCurrent,
|
|
402
384
|
escrowAddresses: uniqueAddresses(
|
|
403
385
|
stagingEscrowCurrent,
|
|
404
|
-
stagingEscrowLegacy,
|
|
405
386
|
...exports.HISTORICAL_ESCROW_ADDRESSES.base_staging
|
|
406
387
|
),
|
|
407
|
-
orchestrator: stagingOrchestratorCurrent
|
|
388
|
+
orchestrator: stagingOrchestratorCurrent,
|
|
408
389
|
orchestratorV2: stagingOrchestratorCurrent,
|
|
409
390
|
orchestratorAddresses: uniqueAddresses(
|
|
410
391
|
stagingOrchestratorCurrent,
|
|
411
|
-
stagingOrchestratorLegacy,
|
|
412
392
|
...HISTORICAL_ORCHESTRATOR_ADDRESSES.base_staging
|
|
413
393
|
),
|
|
414
394
|
unifiedPaymentVerifier: pickAddress(sc, [
|
|
@@ -1291,19 +1271,14 @@ var ContractRouter = class {
|
|
|
1291
1271
|
this._orchestratorContextsByAddress = /* @__PURE__ */ new Map();
|
|
1292
1272
|
this.escrowAddress = config.escrowAddress;
|
|
1293
1273
|
this.escrowAbi = config.escrowAbi;
|
|
1294
|
-
this.legacyEscrowAddress = config.legacyEscrowAddress;
|
|
1295
|
-
this.legacyEscrowAbi = config.legacyEscrowAbi;
|
|
1296
1274
|
this.escrowV2Address = config.escrowV2Address;
|
|
1297
1275
|
this.escrowV2Abi = config.escrowV2Abi;
|
|
1298
1276
|
this.escrowAddresses = config.escrowAddresses;
|
|
1299
1277
|
this.orchestratorAddress = config.orchestratorAddress;
|
|
1300
1278
|
this.orchestratorAbi = config.orchestratorAbi;
|
|
1301
|
-
this.legacyOrchestratorAddress = config.legacyOrchestratorAddress;
|
|
1302
|
-
this.legacyOrchestratorAbi = config.legacyOrchestratorAbi;
|
|
1303
1279
|
this.orchestratorV2Address = config.orchestratorV2Address;
|
|
1304
1280
|
this.orchestratorV2Abi = config.orchestratorV2Abi;
|
|
1305
1281
|
this.orchestratorAddresses = config.orchestratorAddresses;
|
|
1306
|
-
this._defaultPreferV2 = config.defaultPreferV2;
|
|
1307
1282
|
this._registerContexts();
|
|
1308
1283
|
}
|
|
1309
1284
|
_registerContexts() {
|
|
@@ -1311,17 +1286,20 @@ var ContractRouter = class {
|
|
|
1311
1286
|
if (!context?.address || !context.abi) return;
|
|
1312
1287
|
this._orchestratorContextsByAddress.set(context.address.toLowerCase(), context);
|
|
1313
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;
|
|
1314
1295
|
const escrowToOrchestrator = /* @__PURE__ */ new Map();
|
|
1315
|
-
const addEscrowOrchestratorPair = (escrow, orchestrator
|
|
1296
|
+
const addEscrowOrchestratorPair = (escrow, orchestrator) => {
|
|
1316
1297
|
if (!escrow || !orchestrator) return;
|
|
1317
|
-
|
|
1318
|
-
if (!overwrite && escrowToOrchestrator.has(key)) return;
|
|
1319
|
-
escrowToOrchestrator.set(key, orchestrator);
|
|
1298
|
+
escrowToOrchestrator.set(escrow.toLowerCase(), orchestrator);
|
|
1320
1299
|
};
|
|
1321
|
-
addEscrowOrchestratorPair(this.legacyEscrowAddress, this.legacyOrchestratorAddress);
|
|
1322
1300
|
addEscrowOrchestratorPair(
|
|
1323
|
-
this.escrowV2Address,
|
|
1324
|
-
|
|
1301
|
+
this.escrowV2Address ?? this.escrowAddress,
|
|
1302
|
+
primaryOrchestratorAddress
|
|
1325
1303
|
);
|
|
1326
1304
|
const configuredPairCount = Math.min(
|
|
1327
1305
|
this.escrowAddresses.length,
|
|
@@ -1330,81 +1308,45 @@ var ContractRouter = class {
|
|
|
1330
1308
|
for (let index = 0; index < configuredPairCount; index += 1) {
|
|
1331
1309
|
addEscrowOrchestratorPair(this.escrowAddresses[index], this.orchestratorAddresses[index]);
|
|
1332
1310
|
}
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
return this.legacyOrchestratorAbi ?? this.orchestratorAbi ?? this.orchestratorV2Abi;
|
|
1347
|
-
}
|
|
1348
|
-
return this.orchestratorAbi ?? this.orchestratorV2Abi ?? this.legacyOrchestratorAbi;
|
|
1349
|
-
};
|
|
1350
|
-
const resolveOrchestratorVersion = (address) => {
|
|
1351
|
-
if (isSameAddress(address, this.legacyOrchestratorAddress)) return "legacy";
|
|
1352
|
-
if (isSameAddress(address, this.orchestratorV2Address)) return "v2";
|
|
1353
|
-
return this.orchestratorV2Abi ? "v2" : "legacy";
|
|
1354
|
-
};
|
|
1355
|
-
for (const address of this.orchestratorAddresses) {
|
|
1356
|
-
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;
|
|
1357
1324
|
if (!abi) continue;
|
|
1358
1325
|
registerOrchestrator({
|
|
1359
1326
|
address,
|
|
1360
1327
|
abi,
|
|
1361
|
-
version:
|
|
1328
|
+
version: "v2"
|
|
1362
1329
|
});
|
|
1363
1330
|
}
|
|
1364
|
-
const
|
|
1365
|
-
|
|
1366
|
-
this.
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
if (
|
|
1371
|
-
const
|
|
1372
|
-
if (
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
};
|
|
1376
|
-
const resolveEscrowAbi = (version) => version === "legacy" ? this.legacyEscrowAbi ?? this.escrowAbi ?? this.escrowV2Abi : this.escrowV2Abi ?? this.escrowAbi ?? this.legacyEscrowAbi;
|
|
1377
|
-
const resolveEscrowOrchestratorAddress = (escrowAddress, version) => escrowToOrchestrator.get(escrowAddress.toLowerCase()) ?? (version === "legacy" ? this.legacyOrchestratorAddress ?? this.orchestratorAddress : this.orchestratorV2Address ?? this.orchestratorAddress);
|
|
1378
|
-
const resolveEscrowOrchestratorAbi = (orchestratorAddress, version) => this.getOrchestratorContextByAddress(orchestratorAddress)?.abi ?? (version === "legacy" ? this.legacyOrchestratorAbi ?? this.orchestratorAbi ?? this.orchestratorV2Abi : this.orchestratorV2Abi ?? this.orchestratorAbi ?? this.legacyOrchestratorAbi);
|
|
1379
|
-
for (const address of this.escrowAddresses) {
|
|
1380
|
-
const version = resolveEscrowVersion(address);
|
|
1381
|
-
const abi = resolveEscrowAbi(version);
|
|
1382
|
-
const orchAddress = resolveEscrowOrchestratorAddress(address, version);
|
|
1383
|
-
const orchAbi = resolveEscrowOrchestratorAbi(orchAddress, version);
|
|
1384
|
-
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;
|
|
1385
1342
|
registerEscrow({
|
|
1386
1343
|
address,
|
|
1387
|
-
abi,
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1344
|
+
abi: isSameAddress(address, this.escrowV2Address) ? primaryEscrowAbi : this.escrowAbi,
|
|
1345
|
+
orchestratorAddress,
|
|
1346
|
+
orchestratorAbi: resolveOrchestratorAbi(orchestratorAddress),
|
|
1347
|
+
version: "v2"
|
|
1391
1348
|
});
|
|
1392
1349
|
}
|
|
1393
|
-
const primaryEscrowVersion = resolveEscrowVersion(this.escrowAddress);
|
|
1394
|
-
const primaryEscrowOrchestratorAddress = resolveEscrowOrchestratorAddress(
|
|
1395
|
-
this.escrowAddress,
|
|
1396
|
-
primaryEscrowVersion
|
|
1397
|
-
);
|
|
1398
|
-
registerEscrow({
|
|
1399
|
-
address: this.escrowAddress,
|
|
1400
|
-
abi: this.escrowAbi,
|
|
1401
|
-
version: primaryEscrowVersion,
|
|
1402
|
-
orchestratorAddress: primaryEscrowOrchestratorAddress,
|
|
1403
|
-
orchestratorAbi: resolveEscrowOrchestratorAbi(
|
|
1404
|
-
primaryEscrowOrchestratorAddress,
|
|
1405
|
-
primaryEscrowVersion
|
|
1406
|
-
)
|
|
1407
|
-
});
|
|
1408
1350
|
}
|
|
1409
1351
|
getEscrowContextByAddress(address) {
|
|
1410
1352
|
if (!address) return void 0;
|
|
@@ -1419,33 +1361,21 @@ var ContractRouter = class {
|
|
|
1419
1361
|
if (explicitEscrow) {
|
|
1420
1362
|
const explicitContext = this.getEscrowContextByAddress(explicitEscrow);
|
|
1421
1363
|
if (explicitContext) return explicitContext;
|
|
1422
|
-
const
|
|
1423
|
-
const isExplicitLegacy = !!this.legacyEscrowAddress && explicitEscrow.toLowerCase() === this.legacyEscrowAddress.toLowerCase();
|
|
1424
|
-
const inferredVersion = isExplicitV2 ? "v2" : isExplicitLegacy ? "legacy" : options?.preferV2 === false ? "legacy" : options?.preferV2 === true ? "v2" : this.escrowV2Abi ? "v2" : "legacy";
|
|
1364
|
+
const fallbackOrchestrator = this.resolveOrchestratorForEscrow(explicitEscrow);
|
|
1425
1365
|
return {
|
|
1426
1366
|
address: explicitEscrow,
|
|
1427
|
-
abi:
|
|
1428
|
-
orchestratorAddress:
|
|
1429
|
-
orchestratorAbi:
|
|
1430
|
-
version:
|
|
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"
|
|
1431
1371
|
};
|
|
1432
1372
|
}
|
|
1433
|
-
if (options?.preferV2 === false) {
|
|
1434
|
-
const legacyContext = this.getEscrowContexts().find(
|
|
1435
|
-
(context) => context.version === "legacy"
|
|
1436
|
-
);
|
|
1437
|
-
if (legacyContext) return legacyContext;
|
|
1438
|
-
}
|
|
1439
|
-
if (options?.preferV2) {
|
|
1440
|
-
const v2Context = this.getEscrowContexts().find((context) => context.version === "v2");
|
|
1441
|
-
if (v2Context) return v2Context;
|
|
1442
|
-
}
|
|
1443
1373
|
return this.getEscrowContextByAddress(this.escrowAddress) ?? {
|
|
1444
1374
|
address: this.escrowAddress,
|
|
1445
1375
|
abi: this.escrowAbi,
|
|
1446
|
-
orchestratorAddress: this.orchestratorAddress,
|
|
1447
|
-
orchestratorAbi: this.orchestratorAbi,
|
|
1448
|
-
version:
|
|
1376
|
+
orchestratorAddress: this.orchestratorV2Address ?? this.orchestratorAddress,
|
|
1377
|
+
orchestratorAbi: this.orchestratorV2Abi ?? this.orchestratorAbi,
|
|
1378
|
+
version: "v2"
|
|
1449
1379
|
};
|
|
1450
1380
|
}
|
|
1451
1381
|
getEscrowContexts() {
|
|
@@ -1455,26 +1385,21 @@ var ContractRouter = class {
|
|
|
1455
1385
|
{
|
|
1456
1386
|
address: this.escrowAddress,
|
|
1457
1387
|
abi: this.escrowAbi,
|
|
1458
|
-
orchestratorAddress: this.orchestratorAddress,
|
|
1459
|
-
orchestratorAbi: this.orchestratorAbi,
|
|
1460
|
-
version: "
|
|
1388
|
+
orchestratorAddress: this.orchestratorV2Address ?? this.orchestratorAddress,
|
|
1389
|
+
orchestratorAbi: this.orchestratorV2Abi ?? this.orchestratorAbi,
|
|
1390
|
+
version: "v2"
|
|
1461
1391
|
}
|
|
1462
1392
|
];
|
|
1463
1393
|
}
|
|
1464
|
-
resolveOrchestratorForEscrow(escrowAddress,
|
|
1394
|
+
resolveOrchestratorForEscrow(escrowAddress, _preferV2 = false) {
|
|
1465
1395
|
if (escrowAddress) {
|
|
1466
1396
|
const escrowContext = this.getEscrowContextByAddress(escrowAddress);
|
|
1467
1397
|
const fromEscrow = this.getOrchestratorContextByAddress(escrowContext?.orchestratorAddress);
|
|
1468
1398
|
if (fromEscrow) return fromEscrow;
|
|
1469
1399
|
}
|
|
1470
|
-
if (
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1473
|
-
);
|
|
1474
|
-
if (v2) return v2;
|
|
1475
|
-
} else {
|
|
1476
|
-
const legacyPrimary = this.getOrchestratorContextByAddress(this.legacyOrchestratorAddress);
|
|
1477
|
-
if (legacyPrimary) return legacyPrimary;
|
|
1400
|
+
if (this.orchestratorV2Address) {
|
|
1401
|
+
const primary = this.getOrchestratorContextByAddress(this.orchestratorV2Address);
|
|
1402
|
+
if (primary) return primary;
|
|
1478
1403
|
}
|
|
1479
1404
|
if (this.orchestratorAddress) {
|
|
1480
1405
|
const primary = this.getOrchestratorContextByAddress(this.orchestratorAddress);
|
|
@@ -1484,13 +1409,6 @@ var ContractRouter = class {
|
|
|
1484
1409
|
const context = this.getOrchestratorContextByAddress(address);
|
|
1485
1410
|
if (context) return context;
|
|
1486
1411
|
}
|
|
1487
|
-
if (this.legacyOrchestratorAddress && this.legacyOrchestratorAbi) {
|
|
1488
|
-
return {
|
|
1489
|
-
address: this.legacyOrchestratorAddress,
|
|
1490
|
-
abi: this.legacyOrchestratorAbi,
|
|
1491
|
-
version: "legacy"
|
|
1492
|
-
};
|
|
1493
|
-
}
|
|
1494
1412
|
if (this.orchestratorV2Address && this.orchestratorV2Abi) {
|
|
1495
1413
|
return {
|
|
1496
1414
|
address: this.orchestratorV2Address,
|
|
@@ -1498,6 +1416,13 @@ var ContractRouter = class {
|
|
|
1498
1416
|
version: "v2"
|
|
1499
1417
|
};
|
|
1500
1418
|
}
|
|
1419
|
+
if (this.orchestratorAddress && this.orchestratorAbi) {
|
|
1420
|
+
return {
|
|
1421
|
+
address: this.orchestratorAddress,
|
|
1422
|
+
abi: this.orchestratorAbi,
|
|
1423
|
+
version: "v2"
|
|
1424
|
+
};
|
|
1425
|
+
}
|
|
1501
1426
|
return void 0;
|
|
1502
1427
|
}
|
|
1503
1428
|
buildProtocolViewerContexts(options) {
|
|
@@ -1512,17 +1437,18 @@ var ContractRouter = class {
|
|
|
1512
1437
|
};
|
|
1513
1438
|
add(options?.escrowAddress, options?.orchestratorAddress);
|
|
1514
1439
|
if (options?.escrowAddress && !options?.orchestratorAddress) {
|
|
1515
|
-
|
|
1516
|
-
add(options.escrowAddress, resolved);
|
|
1440
|
+
add(options.escrowAddress, this.resolveOrchestratorForEscrow(options.escrowAddress)?.address);
|
|
1517
1441
|
}
|
|
1518
1442
|
for (const context of this.getEscrowContexts()) {
|
|
1519
|
-
|
|
1520
|
-
|
|
1443
|
+
add(
|
|
1444
|
+
context.address,
|
|
1445
|
+
context.orchestratorAddress ?? this.resolveOrchestratorForEscrow(context.address)?.address
|
|
1446
|
+
);
|
|
1521
1447
|
}
|
|
1522
1448
|
return contexts;
|
|
1523
1449
|
}
|
|
1524
1450
|
get defaultPreferV2() {
|
|
1525
|
-
return
|
|
1451
|
+
return true;
|
|
1526
1452
|
}
|
|
1527
1453
|
};
|
|
1528
1454
|
|
|
@@ -3989,6 +3915,20 @@ var RATE_MANAGER_FIELDS = `
|
|
|
3989
3915
|
createdAt
|
|
3990
3916
|
updatedAt
|
|
3991
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
|
+
`;
|
|
3992
3932
|
var RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
3993
3933
|
id
|
|
3994
3934
|
chainId
|
|
@@ -4004,6 +3944,20 @@ var RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
|
4004
3944
|
firstSeenAt
|
|
4005
3945
|
updatedAt
|
|
4006
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
|
+
`;
|
|
4007
3961
|
var RATE_MANAGER_RATE_FIELDS = `
|
|
4008
3962
|
id
|
|
4009
3963
|
chainId
|
|
@@ -4019,9 +3973,7 @@ var DEPOSIT_DELEGATION_FIELDS = `
|
|
|
4019
3973
|
chainId
|
|
4020
3974
|
rateManagerId
|
|
4021
3975
|
rateManagerAddress
|
|
4022
|
-
depositId: id
|
|
4023
3976
|
delegatedAt
|
|
4024
|
-
createdAt: delegatedAt
|
|
4025
3977
|
updatedAt
|
|
4026
3978
|
`;
|
|
4027
3979
|
var LEGACY_RATE_MANAGER_DELEGATION_FIELDS = `
|
|
@@ -4097,6 +4049,7 @@ var RATE_MANAGER_LIST_QUERY = (
|
|
|
4097
4049
|
`
|
|
4098
4050
|
query VaultList(
|
|
4099
4051
|
$where: RateManager_bool_exp
|
|
4052
|
+
$aggregateWhere: ManagerAggregateStats_bool_exp
|
|
4100
4053
|
$order_by: [RateManager_order_by!]
|
|
4101
4054
|
$limit: Int
|
|
4102
4055
|
$offset: Int
|
|
@@ -4104,12 +4057,31 @@ var RATE_MANAGER_LIST_QUERY = (
|
|
|
4104
4057
|
RateManager(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {
|
|
4105
4058
|
${RATE_MANAGER_FIELDS}
|
|
4106
4059
|
}
|
|
4107
|
-
ManagerAggregateStats {
|
|
4060
|
+
ManagerAggregateStats(where: $aggregateWhere) {
|
|
4108
4061
|
${RATE_MANAGER_AGGREGATE_FIELDS}
|
|
4109
4062
|
}
|
|
4110
4063
|
}
|
|
4111
4064
|
`
|
|
4112
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
|
+
);
|
|
4113
4085
|
var RATE_MANAGER_DETAIL_QUERY = (
|
|
4114
4086
|
/* GraphQL */
|
|
4115
4087
|
`
|
|
@@ -4156,13 +4128,13 @@ var LEGACY_RATE_MANAGER_DETAIL_QUERY = (
|
|
|
4156
4128
|
$statsLimit: Int
|
|
4157
4129
|
) {
|
|
4158
4130
|
RateManager(where: $managerWhere) {
|
|
4159
|
-
${
|
|
4131
|
+
${LEGACY_RATE_MANAGER_FIELDS}
|
|
4160
4132
|
}
|
|
4161
4133
|
RateManagerRate(where: $rateWhere) {
|
|
4162
4134
|
${RATE_MANAGER_RATE_FIELDS}
|
|
4163
4135
|
}
|
|
4164
4136
|
ManagerAggregateStats(where: $aggregateWhere) {
|
|
4165
|
-
${
|
|
4137
|
+
${LEGACY_RATE_MANAGER_AGGREGATE_FIELDS}
|
|
4166
4138
|
}
|
|
4167
4139
|
ManagerStats(
|
|
4168
4140
|
where: $statsWhere
|
|
@@ -5195,6 +5167,25 @@ function extractEscrowAddressFromCompositeDepositId(compositeDepositId) {
|
|
|
5195
5167
|
const [escrowAddress] = compositeDepositId.split("_");
|
|
5196
5168
|
return escrowAddress?.startsWith("0x") ? escrowAddress.toLowerCase() : null;
|
|
5197
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
|
+
}
|
|
5198
5189
|
function buildDepositScopeKey(scope) {
|
|
5199
5190
|
return `${scope.escrow}:${scope.depositIdOnContract}`;
|
|
5200
5191
|
}
|
|
@@ -5273,6 +5264,29 @@ var IndexerRateManagerService = class {
|
|
|
5273
5264
|
constructor(client) {
|
|
5274
5265
|
this.client = client;
|
|
5275
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
|
+
}
|
|
5276
5290
|
buildWhere(filter) {
|
|
5277
5291
|
if (!filter) return void 0;
|
|
5278
5292
|
const where = {};
|
|
@@ -5285,46 +5299,44 @@ var IndexerRateManagerService = class {
|
|
|
5285
5299
|
if (filter.maxFee) {
|
|
5286
5300
|
where.maxFee = { _lte: filter.maxFee };
|
|
5287
5301
|
}
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
for (const value of filter.rateManagerIds) {
|
|
5292
|
-
const scopedRateManager = parseScopedRateManagerFilterId(value);
|
|
5293
|
-
if (scopedRateManager) {
|
|
5294
|
-
scopedRateManagers.set(
|
|
5295
|
-
getManagerScopeKey(
|
|
5296
|
-
scopedRateManager.rateManagerId,
|
|
5297
|
-
scopedRateManager.rateManagerAddress
|
|
5298
|
-
),
|
|
5299
|
-
scopedRateManager
|
|
5300
|
-
);
|
|
5301
|
-
continue;
|
|
5302
|
-
}
|
|
5303
|
-
const normalizedRateManagerId = normalizeRateManagerId(value);
|
|
5304
|
-
if (normalizedRateManagerId) {
|
|
5305
|
-
bareRateManagerIds.add(normalizedRateManagerId);
|
|
5306
|
-
}
|
|
5307
|
-
}
|
|
5308
|
-
const scopeConditions = [];
|
|
5309
|
-
if (bareRateManagerIds.size > 0) {
|
|
5310
|
-
scopeConditions.push({
|
|
5311
|
-
rateManagerId: { _in: [...bareRateManagerIds] }
|
|
5312
|
-
});
|
|
5313
|
-
}
|
|
5314
|
-
for (const scopedRateManager of scopedRateManagers.values()) {
|
|
5315
|
-
scopeConditions.push({
|
|
5316
|
-
rateManagerId: { _eq: scopedRateManager.rateManagerId },
|
|
5317
|
-
rateManagerAddress: { _eq: scopedRateManager.rateManagerAddress }
|
|
5318
|
-
});
|
|
5319
|
-
}
|
|
5320
|
-
if (scopeConditions.length === 1) {
|
|
5321
|
-
Object.assign(where, scopeConditions[0]);
|
|
5322
|
-
} else if (scopeConditions.length > 1) {
|
|
5323
|
-
where._or = scopeConditions;
|
|
5324
|
-
}
|
|
5302
|
+
const scopeWhere = this.buildRateManagerScopeWhere(filter.rateManagerIds);
|
|
5303
|
+
if (scopeWhere) {
|
|
5304
|
+
Object.assign(where, scopeWhere);
|
|
5325
5305
|
}
|
|
5326
5306
|
return Object.keys(where).length ? where : void 0;
|
|
5327
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
|
+
}
|
|
5328
5340
|
buildOrderBy(pagination) {
|
|
5329
5341
|
const rawField = pagination?.orderBy ?? "createdAt";
|
|
5330
5342
|
const field = isAggregateOrderField(rawField) ? "createdAt" : rawField;
|
|
@@ -5350,11 +5362,21 @@ var IndexerRateManagerService = class {
|
|
|
5350
5362
|
if (hasHook === void 0) return rows;
|
|
5351
5363
|
return hasHook ? [] : rows;
|
|
5352
5364
|
}
|
|
5353
|
-
async queryRateManagerList(variables) {
|
|
5354
|
-
|
|
5355
|
-
query
|
|
5356
|
-
|
|
5357
|
-
|
|
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
|
+
}
|
|
5358
5380
|
}
|
|
5359
5381
|
buildDelegationOrderBy(pagination) {
|
|
5360
5382
|
const rawField = pagination?.orderBy ?? "updatedAt";
|
|
@@ -5449,11 +5471,21 @@ var IndexerRateManagerService = class {
|
|
|
5449
5471
|
const limit = pagination?.limit ?? DEFAULT_LIMIT2;
|
|
5450
5472
|
const offset = pagination?.offset ?? 0;
|
|
5451
5473
|
const where = this.buildWhere(filter);
|
|
5474
|
+
const aggregateWhere = this.buildAggregateWhere(filter);
|
|
5475
|
+
const legacyAggregateWhere = this.buildLegacyAggregateWhere(filter);
|
|
5452
5476
|
if (isAggregateOrderField(orderBy)) {
|
|
5453
|
-
const result2 = await this.queryRateManagerList(
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
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
|
+
);
|
|
5457
5489
|
const scopedRows = this.applyHookFilter(this.toRateManagerListItems(result2), filter?.hasHook);
|
|
5458
5490
|
const sorted = scopedRows.sort((a, b) => {
|
|
5459
5491
|
const av = orderBy === "currentDelegatedBalance" ? toSafeBigInt(a.aggregate?.currentDelegatedBalance) : toSafeBigInt(a.aggregate?.totalFilledVolume);
|
|
@@ -5470,12 +5502,22 @@ var IndexerRateManagerService = class {
|
|
|
5470
5502
|
});
|
|
5471
5503
|
return sorted.slice(offset, offset + limit);
|
|
5472
5504
|
}
|
|
5473
|
-
const result = await this.queryRateManagerList(
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
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
|
+
);
|
|
5479
5521
|
return this.applyHookFilter(this.toRateManagerListItems(result), filter?.hasHook);
|
|
5480
5522
|
}
|
|
5481
5523
|
async fetchRateManagerDetail(rateManagerId, options) {
|
|
@@ -7037,58 +7079,32 @@ var Zkp2pClient = class {
|
|
|
7037
7079
|
}
|
|
7038
7080
|
return out;
|
|
7039
7081
|
};
|
|
7040
|
-
|
|
7041
|
-
this.legacyEscrowAddress = toAddress(addresses.escrow);
|
|
7042
|
-
this.legacyEscrowAbi = abis.escrow;
|
|
7043
|
-
this.escrowV2Address = toAddress(addresses.escrowV2);
|
|
7082
|
+
this.escrowV2Address = toAddress(addresses.escrowV2 ?? addresses.escrow);
|
|
7044
7083
|
this.escrowV2Abi = abis.escrowV2 ?? abis.escrow;
|
|
7045
|
-
this.
|
|
7046
|
-
|
|
7047
|
-
|
|
7084
|
+
this.orchestratorV2Address = toAddress(
|
|
7085
|
+
addresses.orchestratorV2 ?? addresses.orchestrator
|
|
7086
|
+
);
|
|
7048
7087
|
this.orchestratorV2Abi = abis.orchestratorV2 ?? abis.orchestrator;
|
|
7049
7088
|
const configuredEscrowAddresses = (addresses.escrowAddresses ?? []).map((value) => toAddress(value)).filter(Boolean);
|
|
7050
7089
|
const configuredOrchestratorAddresses = (addresses.orchestratorAddresses ?? []).map((value) => toAddress(value)).filter(Boolean);
|
|
7051
|
-
const inferLegacyAddress = (legacyAddress, v2Address, configuredAddresses) => {
|
|
7052
|
-
if (legacyAddress && (!v2Address || !isSameAddress2(legacyAddress, v2Address))) {
|
|
7053
|
-
return legacyAddress;
|
|
7054
|
-
}
|
|
7055
|
-
return configuredAddresses.find(
|
|
7056
|
-
(candidate) => !v2Address || !isSameAddress2(candidate, v2Address)
|
|
7057
|
-
) ?? legacyAddress;
|
|
7058
|
-
};
|
|
7059
|
-
this.legacyEscrowAddress = inferLegacyAddress(
|
|
7060
|
-
this.legacyEscrowAddress,
|
|
7061
|
-
this.escrowV2Address,
|
|
7062
|
-
configuredEscrowAddresses
|
|
7063
|
-
);
|
|
7064
|
-
this.legacyOrchestratorAddress = inferLegacyAddress(
|
|
7065
|
-
this.legacyOrchestratorAddress,
|
|
7066
|
-
this.orchestratorV2Address,
|
|
7067
|
-
configuredOrchestratorAddresses
|
|
7068
|
-
);
|
|
7069
|
-
const defaultPreferV2 = opts.preferV2ByDefault !== void 0 ? opts.preferV2ByDefault : this.runtimeEnv === "staging";
|
|
7070
|
-
const preferredEscrowAddress = defaultPreferV2 ? this.escrowV2Address : this.legacyEscrowAddress;
|
|
7071
|
-
const fallbackEscrowAddress = defaultPreferV2 ? this.legacyEscrowAddress : this.escrowV2Address;
|
|
7072
|
-
const preferredOrchestratorAddress = defaultPreferV2 ? this.orchestratorV2Address : this.legacyOrchestratorAddress;
|
|
7073
|
-
const fallbackOrchestratorAddress = defaultPreferV2 ? this.legacyOrchestratorAddress : this.orchestratorV2Address;
|
|
7074
7090
|
this.escrowAddresses = uniqAddresses([
|
|
7075
|
-
|
|
7076
|
-
fallbackEscrowAddress,
|
|
7091
|
+
this.escrowV2Address ?? toAddress(addresses.escrow),
|
|
7077
7092
|
...configuredEscrowAddresses
|
|
7078
7093
|
]);
|
|
7079
|
-
this.
|
|
7080
|
-
|
|
7081
|
-
fallbackOrchestratorAddress,
|
|
7082
|
-
...configuredOrchestratorAddresses
|
|
7083
|
-
]);
|
|
7084
|
-
this.escrowAddress = preferredEscrowAddress ?? fallbackEscrowAddress ?? this.escrowAddresses[0];
|
|
7085
|
-
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;
|
|
7086
7096
|
if (!this.escrowAddress || !this.escrowAbi) {
|
|
7087
7097
|
throw new Error("Escrow not available for this chain/environment");
|
|
7088
7098
|
}
|
|
7089
|
-
this.
|
|
7090
|
-
|
|
7091
|
-
|
|
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
|
+
);
|
|
7092
7108
|
this.protocolViewerAddress = toAddress(addresses.protocolViewer);
|
|
7093
7109
|
this.protocolViewerAbi = abis.protocolViewer;
|
|
7094
7110
|
const resolvedPvEntries = addresses.protocolViewerEntries;
|
|
@@ -7127,19 +7143,14 @@ var Zkp2pClient = class {
|
|
|
7127
7143
|
this._router = new ContractRouter({
|
|
7128
7144
|
escrowAddress: this.escrowAddress,
|
|
7129
7145
|
escrowAbi: this.escrowAbi,
|
|
7130
|
-
legacyEscrowAddress: this.legacyEscrowAddress,
|
|
7131
|
-
legacyEscrowAbi: this.legacyEscrowAbi,
|
|
7132
7146
|
escrowV2Address: this.escrowV2Address,
|
|
7133
7147
|
escrowV2Abi: this.escrowV2Abi,
|
|
7134
7148
|
escrowAddresses: this.escrowAddresses,
|
|
7135
7149
|
orchestratorAddress: this.orchestratorAddress,
|
|
7136
7150
|
orchestratorAbi: this.orchestratorAbi,
|
|
7137
|
-
legacyOrchestratorAddress: this.legacyOrchestratorAddress,
|
|
7138
|
-
legacyOrchestratorAbi: this.legacyOrchestratorAbi,
|
|
7139
7151
|
orchestratorV2Address: this.orchestratorV2Address,
|
|
7140
7152
|
orchestratorV2Abi: this.orchestratorV2Abi,
|
|
7141
|
-
orchestratorAddresses: this.orchestratorAddresses
|
|
7142
|
-
defaultPreferV2
|
|
7153
|
+
orchestratorAddresses: this.orchestratorAddresses
|
|
7143
7154
|
});
|
|
7144
7155
|
const maybeUsdc = addresses.usdc;
|
|
7145
7156
|
if (maybeUsdc) this._usdcAddress = maybeUsdc;
|
|
@@ -7268,7 +7279,7 @@ var Zkp2pClient = class {
|
|
|
7268
7279
|
const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
|
|
7269
7280
|
if (resolved) return resolved;
|
|
7270
7281
|
if (options?.preferV2 !== void 0) {
|
|
7271
|
-
return this.resolveEscrowContext(
|
|
7282
|
+
return this.resolveEscrowContext().address;
|
|
7272
7283
|
}
|
|
7273
7284
|
throw new Error(`${methodName} requires escrowAddress or composite depositId`);
|
|
7274
7285
|
}
|
|
@@ -7306,7 +7317,10 @@ var Zkp2pClient = class {
|
|
|
7306
7317
|
return this._router.getOrchestratorContextByAddress(address);
|
|
7307
7318
|
}
|
|
7308
7319
|
resolveEscrowContext(options) {
|
|
7309
|
-
return this._router.resolveEscrowContext(
|
|
7320
|
+
return this._router.resolveEscrowContext({
|
|
7321
|
+
escrowAddress: options?.escrowAddress,
|
|
7322
|
+
depositId: options?.depositId
|
|
7323
|
+
});
|
|
7310
7324
|
}
|
|
7311
7325
|
async resolveEscrowContextForDepositWrite(options) {
|
|
7312
7326
|
const explicitEscrow = options?.escrowAddress ?? (options?.depositId !== void 0 ? this.parseEscrowAddressFromCompositeDepositId(options.depositId) : void 0);
|
|
@@ -7409,21 +7423,9 @@ var Zkp2pClient = class {
|
|
|
7409
7423
|
if (explicit) return explicit;
|
|
7410
7424
|
if (options?.orchestratorAddress) {
|
|
7411
7425
|
const addr = options.orchestratorAddress;
|
|
7412
|
-
const
|
|
7413
|
-
let version;
|
|
7414
|
-
let abi;
|
|
7415
|
-
if (isSame(addr, this.orchestratorV2Address)) {
|
|
7416
|
-
version = "v2";
|
|
7417
|
-
abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
7418
|
-
} else if (isSame(addr, this.legacyOrchestratorAddress)) {
|
|
7419
|
-
version = "legacy";
|
|
7420
|
-
abi = this.legacyOrchestratorAbi ?? this.orchestratorAbi;
|
|
7421
|
-
} else {
|
|
7422
|
-
version = this.orchestratorV2Abi ? "v2" : "legacy";
|
|
7423
|
-
abi = this.orchestratorAbi ?? this.orchestratorV2Abi ?? this.legacyOrchestratorAbi;
|
|
7424
|
-
}
|
|
7426
|
+
const abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
7425
7427
|
if (!abi) throw new Error("Orchestrator not available");
|
|
7426
|
-
return { address: addr, abi, version };
|
|
7428
|
+
return { address: addr, abi, version: "v2" };
|
|
7427
7429
|
}
|
|
7428
7430
|
if (options?.intentHash) {
|
|
7429
7431
|
try {
|
|
@@ -7458,30 +7460,16 @@ var Zkp2pClient = class {
|
|
|
7458
7460
|
if (fromEscrow) return fromEscrow;
|
|
7459
7461
|
}
|
|
7460
7462
|
if (options?.intentHash) {
|
|
7461
|
-
const
|
|
7462
|
-
const primaryAddress = preferV2 ? this.orchestratorV2Address : this.legacyOrchestratorAddress;
|
|
7463
|
-
const secondaryAddress = preferV2 ? this.legacyOrchestratorAddress : this.orchestratorV2Address;
|
|
7463
|
+
const primaryAddress = this.orchestratorV2Address ?? this.orchestratorAddress;
|
|
7464
7464
|
const primaryContext = this.getOrchestratorContextByAddress(primaryAddress);
|
|
7465
7465
|
if (primaryContext) return primaryContext;
|
|
7466
|
-
const secondaryContext = this.getOrchestratorContextByAddress(secondaryAddress);
|
|
7467
|
-
if (secondaryContext) return secondaryContext;
|
|
7468
7466
|
if (primaryAddress) {
|
|
7469
|
-
const primaryAbi =
|
|
7467
|
+
const primaryAbi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
7470
7468
|
if (primaryAbi) {
|
|
7471
7469
|
return {
|
|
7472
7470
|
address: primaryAddress,
|
|
7473
7471
|
abi: primaryAbi,
|
|
7474
|
-
version:
|
|
7475
|
-
};
|
|
7476
|
-
}
|
|
7477
|
-
}
|
|
7478
|
-
if (secondaryAddress) {
|
|
7479
|
-
const secondaryAbi = preferV2 ? this.legacyOrchestratorAbi ?? this.orchestratorAbi : this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
7480
|
-
if (secondaryAbi) {
|
|
7481
|
-
return {
|
|
7482
|
-
address: secondaryAddress,
|
|
7483
|
-
abi: secondaryAbi,
|
|
7484
|
-
version: preferV2 ? "legacy" : "v2"
|
|
7472
|
+
version: "v2"
|
|
7485
7473
|
};
|
|
7486
7474
|
}
|
|
7487
7475
|
}
|
|
@@ -8616,11 +8604,9 @@ var Zkp2pClient = class {
|
|
|
8616
8604
|
escrow: this.escrowAddress,
|
|
8617
8605
|
escrowV2: this.escrowV2Address,
|
|
8618
8606
|
escrowAddresses: this.escrowAddresses,
|
|
8619
|
-
legacyEscrow: this.legacyEscrowAddress,
|
|
8620
8607
|
orchestrator: this.orchestratorAddress,
|
|
8621
8608
|
orchestratorV2: this.orchestratorV2Address,
|
|
8622
8609
|
orchestratorAddresses: this.orchestratorAddresses,
|
|
8623
|
-
legacyOrchestrator: this.legacyOrchestratorAddress,
|
|
8624
8610
|
protocolViewer: this.protocolViewerAddress,
|
|
8625
8611
|
protocolViewerEntries: this._protocolViewerEntries.map((e) => e.address),
|
|
8626
8612
|
unifiedPaymentVerifier: this.unifiedPaymentVerifier,
|
|
@@ -8870,23 +8856,7 @@ var classifyDelegationState = (currentRateManagerId, currentRegistry, targetRate
|
|
|
8870
8856
|
}
|
|
8871
8857
|
return "delegated_elsewhere";
|
|
8872
8858
|
};
|
|
8873
|
-
var getDelegationRoute = (
|
|
8874
|
-
const escrowLower = escrow.toLowerCase();
|
|
8875
|
-
const legacyLower = client.legacyEscrowAddress?.toLowerCase();
|
|
8876
|
-
if (legacyLower && escrowLower === legacyLower) return "legacy";
|
|
8877
|
-
if (client.escrowAddresses && client.escrowAddresses.length > 0) {
|
|
8878
|
-
const v2Candidates = client.escrowAddresses.filter(
|
|
8879
|
-
(addr) => !legacyLower || addr.toLowerCase() !== legacyLower
|
|
8880
|
-
);
|
|
8881
|
-
if (v2Candidates.some((addr) => addr.toLowerCase() === escrowLower)) {
|
|
8882
|
-
return "v2";
|
|
8883
|
-
}
|
|
8884
|
-
}
|
|
8885
|
-
if (client.escrowV2Address && escrowLower === client.escrowV2Address.toLowerCase()) {
|
|
8886
|
-
return "v2";
|
|
8887
|
-
}
|
|
8888
|
-
return "legacy";
|
|
8889
|
-
};
|
|
8859
|
+
var getDelegationRoute = (_client, _escrow) => "v2";
|
|
8890
8860
|
|
|
8891
8861
|
exports.BASE_BUILDER_CODE = BASE_BUILDER_CODE;
|
|
8892
8862
|
exports.CHAINLINK_ORACLE_ADAPTER = CHAINLINK_ORACLE_ADAPTER;
|
|
@@ -8919,6 +8889,7 @@ exports.appendAttributionToCalldata = appendAttributionToCalldata;
|
|
|
8919
8889
|
exports.asciiToBytes32 = asciiToBytes32;
|
|
8920
8890
|
exports.assertValidReferrerFeeConfig = assertValidReferrerFeeConfig;
|
|
8921
8891
|
exports.classifyDelegationState = classifyDelegationState;
|
|
8892
|
+
exports.compareEventCursorIdsByRecency = compareEventCursorIdsByRecency;
|
|
8922
8893
|
exports.convertDepositsForLiquidity = convertDepositsForLiquidity;
|
|
8923
8894
|
exports.convertIndexerDepositToEscrowView = convertIndexerDepositToEscrowView;
|
|
8924
8895
|
exports.convertIndexerIntentsToEscrowViews = convertIndexerIntentsToEscrowViews;
|