@zkp2p/sdk 0.1.1 → 0.2.1
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 +288 -302
- 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 +293 -272
- 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
|
|
|
@@ -2064,6 +1990,20 @@ var logger = {
|
|
|
2064
1990
|
};
|
|
2065
1991
|
|
|
2066
1992
|
// 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
|
+
}
|
|
2067
2007
|
var IntentOperations = class {
|
|
2068
2008
|
constructor(config) {
|
|
2069
2009
|
this.config = config;
|
|
@@ -2089,6 +2029,7 @@ var IntentOperations = class {
|
|
|
2089
2029
|
escrowAddress: escrowContext.address,
|
|
2090
2030
|
preferV2
|
|
2091
2031
|
});
|
|
2032
|
+
const useV2Encoding = isV2SignalIntentAbi(orchestratorContext.abi);
|
|
2092
2033
|
const catalog = getPaymentMethodsCatalog(this.config.getChainId(), this.config.getRuntimeEnv());
|
|
2093
2034
|
const paymentMethod = resolvePaymentMethodHashFromCatalog(params.processorName, catalog);
|
|
2094
2035
|
const fiatCurrency = resolveFiatCurrencyBytes32(params.fiatCurrencyCode);
|
|
@@ -2126,7 +2067,7 @@ var IntentOperations = class {
|
|
|
2126
2067
|
authorizationToken,
|
|
2127
2068
|
timeoutMs: this.config.getApiTimeoutMs()
|
|
2128
2069
|
};
|
|
2129
|
-
const response =
|
|
2070
|
+
const response = useV2Encoding ? await apiSignIntentV3(
|
|
2130
2071
|
{
|
|
2131
2072
|
...baseRequest,
|
|
2132
2073
|
callerAddress: this.config.getWalletClient().account.address,
|
|
@@ -2157,7 +2098,7 @@ var IntentOperations = class {
|
|
|
2157
2098
|
postIntentHook: params.postIntentHook ?? ZERO_ADDRESS,
|
|
2158
2099
|
data: params.data ?? "0x"
|
|
2159
2100
|
};
|
|
2160
|
-
const args =
|
|
2101
|
+
const args = useV2Encoding ? [
|
|
2161
2102
|
{
|
|
2162
2103
|
...commonFields,
|
|
2163
2104
|
referralFees,
|
|
@@ -3989,6 +3930,20 @@ var RATE_MANAGER_FIELDS = `
|
|
|
3989
3930
|
createdAt
|
|
3990
3931
|
updatedAt
|
|
3991
3932
|
`;
|
|
3933
|
+
var LEGACY_RATE_MANAGER_FIELDS = `
|
|
3934
|
+
id
|
|
3935
|
+
chainId
|
|
3936
|
+
rateManagerAddress
|
|
3937
|
+
rateManagerId
|
|
3938
|
+
manager
|
|
3939
|
+
feeRecipient
|
|
3940
|
+
maxFee
|
|
3941
|
+
fee
|
|
3942
|
+
name
|
|
3943
|
+
uri
|
|
3944
|
+
createdAt
|
|
3945
|
+
updatedAt
|
|
3946
|
+
`;
|
|
3992
3947
|
var RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
3993
3948
|
id
|
|
3994
3949
|
chainId
|
|
@@ -4004,6 +3959,20 @@ var RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
|
4004
3959
|
firstSeenAt
|
|
4005
3960
|
updatedAt
|
|
4006
3961
|
`;
|
|
3962
|
+
var LEGACY_RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
3963
|
+
id
|
|
3964
|
+
chainId
|
|
3965
|
+
rateManagerId
|
|
3966
|
+
manager
|
|
3967
|
+
totalFilledVolume
|
|
3968
|
+
totalFeeAmount
|
|
3969
|
+
totalPnlUsdCents
|
|
3970
|
+
fulfilledIntents
|
|
3971
|
+
currentDelegatedBalance
|
|
3972
|
+
currentDelegatedDeposits
|
|
3973
|
+
firstSeenAt
|
|
3974
|
+
updatedAt
|
|
3975
|
+
`;
|
|
4007
3976
|
var RATE_MANAGER_RATE_FIELDS = `
|
|
4008
3977
|
id
|
|
4009
3978
|
chainId
|
|
@@ -4019,9 +3988,7 @@ var DEPOSIT_DELEGATION_FIELDS = `
|
|
|
4019
3988
|
chainId
|
|
4020
3989
|
rateManagerId
|
|
4021
3990
|
rateManagerAddress
|
|
4022
|
-
depositId: id
|
|
4023
3991
|
delegatedAt
|
|
4024
|
-
createdAt: delegatedAt
|
|
4025
3992
|
updatedAt
|
|
4026
3993
|
`;
|
|
4027
3994
|
var LEGACY_RATE_MANAGER_DELEGATION_FIELDS = `
|
|
@@ -4097,6 +4064,7 @@ var RATE_MANAGER_LIST_QUERY = (
|
|
|
4097
4064
|
`
|
|
4098
4065
|
query VaultList(
|
|
4099
4066
|
$where: RateManager_bool_exp
|
|
4067
|
+
$aggregateWhere: ManagerAggregateStats_bool_exp
|
|
4100
4068
|
$order_by: [RateManager_order_by!]
|
|
4101
4069
|
$limit: Int
|
|
4102
4070
|
$offset: Int
|
|
@@ -4104,12 +4072,31 @@ var RATE_MANAGER_LIST_QUERY = (
|
|
|
4104
4072
|
RateManager(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {
|
|
4105
4073
|
${RATE_MANAGER_FIELDS}
|
|
4106
4074
|
}
|
|
4107
|
-
ManagerAggregateStats {
|
|
4075
|
+
ManagerAggregateStats(where: $aggregateWhere) {
|
|
4108
4076
|
${RATE_MANAGER_AGGREGATE_FIELDS}
|
|
4109
4077
|
}
|
|
4110
4078
|
}
|
|
4111
4079
|
`
|
|
4112
4080
|
);
|
|
4081
|
+
var LEGACY_RATE_MANAGER_LIST_QUERY = (
|
|
4082
|
+
/* GraphQL */
|
|
4083
|
+
`
|
|
4084
|
+
query VaultList(
|
|
4085
|
+
$where: RateManager_bool_exp
|
|
4086
|
+
$aggregateWhere: ManagerAggregateStats_bool_exp
|
|
4087
|
+
$order_by: [RateManager_order_by!]
|
|
4088
|
+
$limit: Int
|
|
4089
|
+
$offset: Int
|
|
4090
|
+
) {
|
|
4091
|
+
RateManager(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {
|
|
4092
|
+
${LEGACY_RATE_MANAGER_FIELDS}
|
|
4093
|
+
}
|
|
4094
|
+
ManagerAggregateStats(where: $aggregateWhere) {
|
|
4095
|
+
${LEGACY_RATE_MANAGER_AGGREGATE_FIELDS}
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
`
|
|
4099
|
+
);
|
|
4113
4100
|
var RATE_MANAGER_DETAIL_QUERY = (
|
|
4114
4101
|
/* GraphQL */
|
|
4115
4102
|
`
|
|
@@ -4156,13 +4143,13 @@ var LEGACY_RATE_MANAGER_DETAIL_QUERY = (
|
|
|
4156
4143
|
$statsLimit: Int
|
|
4157
4144
|
) {
|
|
4158
4145
|
RateManager(where: $managerWhere) {
|
|
4159
|
-
${
|
|
4146
|
+
${LEGACY_RATE_MANAGER_FIELDS}
|
|
4160
4147
|
}
|
|
4161
4148
|
RateManagerRate(where: $rateWhere) {
|
|
4162
4149
|
${RATE_MANAGER_RATE_FIELDS}
|
|
4163
4150
|
}
|
|
4164
4151
|
ManagerAggregateStats(where: $aggregateWhere) {
|
|
4165
|
-
${
|
|
4152
|
+
${LEGACY_RATE_MANAGER_AGGREGATE_FIELDS}
|
|
4166
4153
|
}
|
|
4167
4154
|
ManagerStats(
|
|
4168
4155
|
where: $statsWhere
|
|
@@ -5195,6 +5182,25 @@ function extractEscrowAddressFromCompositeDepositId(compositeDepositId) {
|
|
|
5195
5182
|
const [escrowAddress] = compositeDepositId.split("_");
|
|
5196
5183
|
return escrowAddress?.startsWith("0x") ? escrowAddress.toLowerCase() : null;
|
|
5197
5184
|
}
|
|
5185
|
+
function parseRateManagerFilterIds(rateManagerIds) {
|
|
5186
|
+
const bare = /* @__PURE__ */ new Set();
|
|
5187
|
+
const scoped = /* @__PURE__ */ new Map();
|
|
5188
|
+
for (const value of rateManagerIds) {
|
|
5189
|
+
const scopedRateManager = parseScopedRateManagerFilterId(value);
|
|
5190
|
+
if (scopedRateManager) {
|
|
5191
|
+
scoped.set(
|
|
5192
|
+
getManagerScopeKey(scopedRateManager.rateManagerId, scopedRateManager.rateManagerAddress),
|
|
5193
|
+
scopedRateManager
|
|
5194
|
+
);
|
|
5195
|
+
continue;
|
|
5196
|
+
}
|
|
5197
|
+
const normalizedRateManagerId = normalizeRateManagerId(value);
|
|
5198
|
+
if (normalizedRateManagerId) {
|
|
5199
|
+
bare.add(normalizedRateManagerId);
|
|
5200
|
+
}
|
|
5201
|
+
}
|
|
5202
|
+
return { bare, scoped };
|
|
5203
|
+
}
|
|
5198
5204
|
function buildDepositScopeKey(scope) {
|
|
5199
5205
|
return `${scope.escrow}:${scope.depositIdOnContract}`;
|
|
5200
5206
|
}
|
|
@@ -5273,6 +5279,29 @@ var IndexerRateManagerService = class {
|
|
|
5273
5279
|
constructor(client) {
|
|
5274
5280
|
this.client = client;
|
|
5275
5281
|
}
|
|
5282
|
+
buildRateManagerScopeWhere(rateManagerIds) {
|
|
5283
|
+
if (!rateManagerIds?.length) return void 0;
|
|
5284
|
+
const { bare, scoped } = parseRateManagerFilterIds(rateManagerIds);
|
|
5285
|
+
const scopeConditions = [];
|
|
5286
|
+
if (bare.size > 0) {
|
|
5287
|
+
scopeConditions.push({
|
|
5288
|
+
rateManagerId: { _in: [...bare] }
|
|
5289
|
+
});
|
|
5290
|
+
}
|
|
5291
|
+
for (const scopedRateManager of scoped.values()) {
|
|
5292
|
+
scopeConditions.push({
|
|
5293
|
+
rateManagerId: { _eq: scopedRateManager.rateManagerId },
|
|
5294
|
+
rateManagerAddress: { _eq: scopedRateManager.rateManagerAddress }
|
|
5295
|
+
});
|
|
5296
|
+
}
|
|
5297
|
+
if (scopeConditions.length === 1) {
|
|
5298
|
+
return scopeConditions[0];
|
|
5299
|
+
}
|
|
5300
|
+
if (scopeConditions.length > 1) {
|
|
5301
|
+
return { _or: scopeConditions };
|
|
5302
|
+
}
|
|
5303
|
+
return void 0;
|
|
5304
|
+
}
|
|
5276
5305
|
buildWhere(filter) {
|
|
5277
5306
|
if (!filter) return void 0;
|
|
5278
5307
|
const where = {};
|
|
@@ -5285,46 +5314,44 @@ var IndexerRateManagerService = class {
|
|
|
5285
5314
|
if (filter.maxFee) {
|
|
5286
5315
|
where.maxFee = { _lte: filter.maxFee };
|
|
5287
5316
|
}
|
|
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
|
-
}
|
|
5317
|
+
const scopeWhere = this.buildRateManagerScopeWhere(filter.rateManagerIds);
|
|
5318
|
+
if (scopeWhere) {
|
|
5319
|
+
Object.assign(where, scopeWhere);
|
|
5325
5320
|
}
|
|
5326
5321
|
return Object.keys(where).length ? where : void 0;
|
|
5327
5322
|
}
|
|
5323
|
+
buildAggregateWhere(filter) {
|
|
5324
|
+
return this.buildRateManagerScopeWhere(filter?.rateManagerIds) ?? {};
|
|
5325
|
+
}
|
|
5326
|
+
buildLegacyAggregateWhere(filter) {
|
|
5327
|
+
const rateManagerIds = filter?.rateManagerIds;
|
|
5328
|
+
if (!rateManagerIds?.length) return {};
|
|
5329
|
+
const { bare, scoped } = parseRateManagerFilterIds(rateManagerIds);
|
|
5330
|
+
const scopeConditions = [];
|
|
5331
|
+
if (bare.size > 0) {
|
|
5332
|
+
scopeConditions.push({
|
|
5333
|
+
rateManagerId: { _in: [...bare] }
|
|
5334
|
+
});
|
|
5335
|
+
}
|
|
5336
|
+
for (const scopedRateManager of scoped.values()) {
|
|
5337
|
+
scopeConditions.push({
|
|
5338
|
+
rateManagerId: { _eq: scopedRateManager.rateManagerId },
|
|
5339
|
+
id: {
|
|
5340
|
+
_ilike: buildRateManagerAddressScopedIdPattern(
|
|
5341
|
+
scopedRateManager.rateManagerId,
|
|
5342
|
+
scopedRateManager.rateManagerAddress
|
|
5343
|
+
)
|
|
5344
|
+
}
|
|
5345
|
+
});
|
|
5346
|
+
}
|
|
5347
|
+
if (scopeConditions.length === 1) {
|
|
5348
|
+
return scopeConditions[0] ?? {};
|
|
5349
|
+
}
|
|
5350
|
+
if (scopeConditions.length > 1) {
|
|
5351
|
+
return { _or: scopeConditions };
|
|
5352
|
+
}
|
|
5353
|
+
return {};
|
|
5354
|
+
}
|
|
5328
5355
|
buildOrderBy(pagination) {
|
|
5329
5356
|
const rawField = pagination?.orderBy ?? "createdAt";
|
|
5330
5357
|
const field = isAggregateOrderField(rawField) ? "createdAt" : rawField;
|
|
@@ -5350,11 +5377,21 @@ var IndexerRateManagerService = class {
|
|
|
5350
5377
|
if (hasHook === void 0) return rows;
|
|
5351
5378
|
return hasHook ? [] : rows;
|
|
5352
5379
|
}
|
|
5353
|
-
async queryRateManagerList(variables) {
|
|
5354
|
-
|
|
5355
|
-
query
|
|
5356
|
-
|
|
5357
|
-
|
|
5380
|
+
async queryRateManagerList(variables, legacyVariables) {
|
|
5381
|
+
try {
|
|
5382
|
+
return await this.client.query({
|
|
5383
|
+
query: RATE_MANAGER_LIST_QUERY,
|
|
5384
|
+
variables
|
|
5385
|
+
});
|
|
5386
|
+
} catch (error) {
|
|
5387
|
+
if (!isSchemaCompatibilityError(error)) {
|
|
5388
|
+
throw error;
|
|
5389
|
+
}
|
|
5390
|
+
return this.client.query({
|
|
5391
|
+
query: LEGACY_RATE_MANAGER_LIST_QUERY,
|
|
5392
|
+
variables: legacyVariables
|
|
5393
|
+
});
|
|
5394
|
+
}
|
|
5358
5395
|
}
|
|
5359
5396
|
buildDelegationOrderBy(pagination) {
|
|
5360
5397
|
const rawField = pagination?.orderBy ?? "updatedAt";
|
|
@@ -5449,11 +5486,21 @@ var IndexerRateManagerService = class {
|
|
|
5449
5486
|
const limit = pagination?.limit ?? DEFAULT_LIMIT2;
|
|
5450
5487
|
const offset = pagination?.offset ?? 0;
|
|
5451
5488
|
const where = this.buildWhere(filter);
|
|
5489
|
+
const aggregateWhere = this.buildAggregateWhere(filter);
|
|
5490
|
+
const legacyAggregateWhere = this.buildLegacyAggregateWhere(filter);
|
|
5452
5491
|
if (isAggregateOrderField(orderBy)) {
|
|
5453
|
-
const result2 = await this.queryRateManagerList(
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5492
|
+
const result2 = await this.queryRateManagerList(
|
|
5493
|
+
{
|
|
5494
|
+
where,
|
|
5495
|
+
aggregateWhere,
|
|
5496
|
+
order_by: [{ createdAt: "desc" }]
|
|
5497
|
+
},
|
|
5498
|
+
{
|
|
5499
|
+
where,
|
|
5500
|
+
aggregateWhere: legacyAggregateWhere,
|
|
5501
|
+
order_by: [{ createdAt: "desc" }]
|
|
5502
|
+
}
|
|
5503
|
+
);
|
|
5457
5504
|
const scopedRows = this.applyHookFilter(this.toRateManagerListItems(result2), filter?.hasHook);
|
|
5458
5505
|
const sorted = scopedRows.sort((a, b) => {
|
|
5459
5506
|
const av = orderBy === "currentDelegatedBalance" ? toSafeBigInt(a.aggregate?.currentDelegatedBalance) : toSafeBigInt(a.aggregate?.totalFilledVolume);
|
|
@@ -5470,12 +5517,22 @@ var IndexerRateManagerService = class {
|
|
|
5470
5517
|
});
|
|
5471
5518
|
return sorted.slice(offset, offset + limit);
|
|
5472
5519
|
}
|
|
5473
|
-
const result = await this.queryRateManagerList(
|
|
5474
|
-
|
|
5475
|
-
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5520
|
+
const result = await this.queryRateManagerList(
|
|
5521
|
+
{
|
|
5522
|
+
where,
|
|
5523
|
+
aggregateWhere,
|
|
5524
|
+
order_by: this.buildOrderBy(pagination),
|
|
5525
|
+
limit,
|
|
5526
|
+
offset
|
|
5527
|
+
},
|
|
5528
|
+
{
|
|
5529
|
+
where,
|
|
5530
|
+
aggregateWhere: legacyAggregateWhere,
|
|
5531
|
+
order_by: this.buildOrderBy(pagination),
|
|
5532
|
+
limit,
|
|
5533
|
+
offset
|
|
5534
|
+
}
|
|
5535
|
+
);
|
|
5479
5536
|
return this.applyHookFilter(this.toRateManagerListItems(result), filter?.hasHook);
|
|
5480
5537
|
}
|
|
5481
5538
|
async fetchRateManagerDetail(rateManagerId, options) {
|
|
@@ -7037,58 +7094,32 @@ var Zkp2pClient = class {
|
|
|
7037
7094
|
}
|
|
7038
7095
|
return out;
|
|
7039
7096
|
};
|
|
7040
|
-
|
|
7041
|
-
this.legacyEscrowAddress = toAddress(addresses.escrow);
|
|
7042
|
-
this.legacyEscrowAbi = abis.escrow;
|
|
7043
|
-
this.escrowV2Address = toAddress(addresses.escrowV2);
|
|
7097
|
+
this.escrowV2Address = toAddress(addresses.escrowV2 ?? addresses.escrow);
|
|
7044
7098
|
this.escrowV2Abi = abis.escrowV2 ?? abis.escrow;
|
|
7045
|
-
this.
|
|
7046
|
-
|
|
7047
|
-
|
|
7099
|
+
this.orchestratorV2Address = toAddress(
|
|
7100
|
+
addresses.orchestratorV2 ?? addresses.orchestrator
|
|
7101
|
+
);
|
|
7048
7102
|
this.orchestratorV2Abi = abis.orchestratorV2 ?? abis.orchestrator;
|
|
7049
7103
|
const configuredEscrowAddresses = (addresses.escrowAddresses ?? []).map((value) => toAddress(value)).filter(Boolean);
|
|
7050
7104
|
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
7105
|
this.escrowAddresses = uniqAddresses([
|
|
7075
|
-
|
|
7076
|
-
fallbackEscrowAddress,
|
|
7106
|
+
this.escrowV2Address ?? toAddress(addresses.escrow),
|
|
7077
7107
|
...configuredEscrowAddresses
|
|
7078
7108
|
]);
|
|
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;
|
|
7109
|
+
this.escrowAddress = this.escrowV2Address ?? toAddress(addresses.escrow) ?? this.escrowAddresses[0];
|
|
7110
|
+
this.escrowAbi = this.escrowV2Abi ?? abis.escrow;
|
|
7086
7111
|
if (!this.escrowAddress || !this.escrowAbi) {
|
|
7087
7112
|
throw new Error("Escrow not available for this chain/environment");
|
|
7088
7113
|
}
|
|
7089
|
-
this.
|
|
7090
|
-
|
|
7091
|
-
|
|
7114
|
+
this.orchestratorAddresses = uniqAddresses([
|
|
7115
|
+
this.orchestratorV2Address ?? toAddress(addresses.orchestrator),
|
|
7116
|
+
...configuredOrchestratorAddresses
|
|
7117
|
+
]);
|
|
7118
|
+
this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
|
|
7119
|
+
this.orchestratorAbi = abis.orchestrator ?? this.orchestratorV2Abi;
|
|
7120
|
+
this.unifiedPaymentVerifier = toAddress(
|
|
7121
|
+
addresses.unifiedPaymentVerifierV2 ?? addresses.unifiedPaymentVerifier
|
|
7122
|
+
);
|
|
7092
7123
|
this.protocolViewerAddress = toAddress(addresses.protocolViewer);
|
|
7093
7124
|
this.protocolViewerAbi = abis.protocolViewer;
|
|
7094
7125
|
const resolvedPvEntries = addresses.protocolViewerEntries;
|
|
@@ -7127,19 +7158,14 @@ var Zkp2pClient = class {
|
|
|
7127
7158
|
this._router = new ContractRouter({
|
|
7128
7159
|
escrowAddress: this.escrowAddress,
|
|
7129
7160
|
escrowAbi: this.escrowAbi,
|
|
7130
|
-
legacyEscrowAddress: this.legacyEscrowAddress,
|
|
7131
|
-
legacyEscrowAbi: this.legacyEscrowAbi,
|
|
7132
7161
|
escrowV2Address: this.escrowV2Address,
|
|
7133
7162
|
escrowV2Abi: this.escrowV2Abi,
|
|
7134
7163
|
escrowAddresses: this.escrowAddresses,
|
|
7135
7164
|
orchestratorAddress: this.orchestratorAddress,
|
|
7136
7165
|
orchestratorAbi: this.orchestratorAbi,
|
|
7137
|
-
legacyOrchestratorAddress: this.legacyOrchestratorAddress,
|
|
7138
|
-
legacyOrchestratorAbi: this.legacyOrchestratorAbi,
|
|
7139
7166
|
orchestratorV2Address: this.orchestratorV2Address,
|
|
7140
7167
|
orchestratorV2Abi: this.orchestratorV2Abi,
|
|
7141
|
-
orchestratorAddresses: this.orchestratorAddresses
|
|
7142
|
-
defaultPreferV2
|
|
7168
|
+
orchestratorAddresses: this.orchestratorAddresses
|
|
7143
7169
|
});
|
|
7144
7170
|
const maybeUsdc = addresses.usdc;
|
|
7145
7171
|
if (maybeUsdc) this._usdcAddress = maybeUsdc;
|
|
@@ -7268,7 +7294,7 @@ var Zkp2pClient = class {
|
|
|
7268
7294
|
const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
|
|
7269
7295
|
if (resolved) return resolved;
|
|
7270
7296
|
if (options?.preferV2 !== void 0) {
|
|
7271
|
-
return this.resolveEscrowContext(
|
|
7297
|
+
return this.resolveEscrowContext().address;
|
|
7272
7298
|
}
|
|
7273
7299
|
throw new Error(`${methodName} requires escrowAddress or composite depositId`);
|
|
7274
7300
|
}
|
|
@@ -7306,7 +7332,10 @@ var Zkp2pClient = class {
|
|
|
7306
7332
|
return this._router.getOrchestratorContextByAddress(address);
|
|
7307
7333
|
}
|
|
7308
7334
|
resolveEscrowContext(options) {
|
|
7309
|
-
return this._router.resolveEscrowContext(
|
|
7335
|
+
return this._router.resolveEscrowContext({
|
|
7336
|
+
escrowAddress: options?.escrowAddress,
|
|
7337
|
+
depositId: options?.depositId
|
|
7338
|
+
});
|
|
7310
7339
|
}
|
|
7311
7340
|
async resolveEscrowContextForDepositWrite(options) {
|
|
7312
7341
|
const explicitEscrow = options?.escrowAddress ?? (options?.depositId !== void 0 ? this.parseEscrowAddressFromCompositeDepositId(options.depositId) : void 0);
|
|
@@ -7409,21 +7438,9 @@ var Zkp2pClient = class {
|
|
|
7409
7438
|
if (explicit) return explicit;
|
|
7410
7439
|
if (options?.orchestratorAddress) {
|
|
7411
7440
|
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
|
-
}
|
|
7441
|
+
const abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
7425
7442
|
if (!abi) throw new Error("Orchestrator not available");
|
|
7426
|
-
return { address: addr, abi, version };
|
|
7443
|
+
return { address: addr, abi, version: "v2" };
|
|
7427
7444
|
}
|
|
7428
7445
|
if (options?.intentHash) {
|
|
7429
7446
|
try {
|
|
@@ -7458,30 +7475,16 @@ var Zkp2pClient = class {
|
|
|
7458
7475
|
if (fromEscrow) return fromEscrow;
|
|
7459
7476
|
}
|
|
7460
7477
|
if (options?.intentHash) {
|
|
7461
|
-
const
|
|
7462
|
-
const primaryAddress = preferV2 ? this.orchestratorV2Address : this.legacyOrchestratorAddress;
|
|
7463
|
-
const secondaryAddress = preferV2 ? this.legacyOrchestratorAddress : this.orchestratorV2Address;
|
|
7478
|
+
const primaryAddress = this.orchestratorV2Address ?? this.orchestratorAddress;
|
|
7464
7479
|
const primaryContext = this.getOrchestratorContextByAddress(primaryAddress);
|
|
7465
7480
|
if (primaryContext) return primaryContext;
|
|
7466
|
-
const secondaryContext = this.getOrchestratorContextByAddress(secondaryAddress);
|
|
7467
|
-
if (secondaryContext) return secondaryContext;
|
|
7468
7481
|
if (primaryAddress) {
|
|
7469
|
-
const primaryAbi =
|
|
7482
|
+
const primaryAbi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
7470
7483
|
if (primaryAbi) {
|
|
7471
7484
|
return {
|
|
7472
7485
|
address: primaryAddress,
|
|
7473
7486
|
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"
|
|
7487
|
+
version: "v2"
|
|
7485
7488
|
};
|
|
7486
7489
|
}
|
|
7487
7490
|
}
|
|
@@ -8616,11 +8619,9 @@ var Zkp2pClient = class {
|
|
|
8616
8619
|
escrow: this.escrowAddress,
|
|
8617
8620
|
escrowV2: this.escrowV2Address,
|
|
8618
8621
|
escrowAddresses: this.escrowAddresses,
|
|
8619
|
-
legacyEscrow: this.legacyEscrowAddress,
|
|
8620
8622
|
orchestrator: this.orchestratorAddress,
|
|
8621
8623
|
orchestratorV2: this.orchestratorV2Address,
|
|
8622
8624
|
orchestratorAddresses: this.orchestratorAddresses,
|
|
8623
|
-
legacyOrchestrator: this.legacyOrchestratorAddress,
|
|
8624
8625
|
protocolViewer: this.protocolViewerAddress,
|
|
8625
8626
|
protocolViewerEntries: this._protocolViewerEntries.map((e) => e.address),
|
|
8626
8627
|
unifiedPaymentVerifier: this.unifiedPaymentVerifier,
|
|
@@ -8870,23 +8871,7 @@ var classifyDelegationState = (currentRateManagerId, currentRegistry, targetRate
|
|
|
8870
8871
|
}
|
|
8871
8872
|
return "delegated_elsewhere";
|
|
8872
8873
|
};
|
|
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
|
-
};
|
|
8874
|
+
var getDelegationRoute = (_client, _escrow) => "v2";
|
|
8890
8875
|
|
|
8891
8876
|
exports.BASE_BUILDER_CODE = BASE_BUILDER_CODE;
|
|
8892
8877
|
exports.CHAINLINK_ORACLE_ADAPTER = CHAINLINK_ORACLE_ADAPTER;
|
|
@@ -8919,6 +8904,7 @@ exports.appendAttributionToCalldata = appendAttributionToCalldata;
|
|
|
8919
8904
|
exports.asciiToBytes32 = asciiToBytes32;
|
|
8920
8905
|
exports.assertValidReferrerFeeConfig = assertValidReferrerFeeConfig;
|
|
8921
8906
|
exports.classifyDelegationState = classifyDelegationState;
|
|
8907
|
+
exports.compareEventCursorIdsByRecency = compareEventCursorIdsByRecency;
|
|
8922
8908
|
exports.convertDepositsForLiquidity = convertDepositsForLiquidity;
|
|
8923
8909
|
exports.convertIndexerDepositToEscrowView = convertIndexerDepositToEscrowView;
|
|
8924
8910
|
exports.convertIndexerIntentsToEscrowViews = convertIndexerIntentsToEscrowViews;
|