@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/README.md +382 -120
- package/dist/{chunk-JH74HXTS.mjs → chunk-J33LUXNA.mjs} +7 -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 +274 -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-QVG4JP23.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 +18 -18
- package/dist/chunk-JH74HXTS.mjs.map +0 -1
- package/dist/chunk-YLITJ7SI.mjs.map +0 -1
- package/dist/protocolViewerParsers-QVG4JP23.mjs +0 -4
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { ZERO_RATE_MANAGER_ID, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-
|
|
1
|
+
export { ZERO_RATE_MANAGER_ID, classifyDelegationState, getDelegationRoute, isZeroRateManagerId, normalizeRateManagerId, normalizeRegistry } from './chunk-LPJE2MN7.mjs';
|
|
2
2
|
import { ValidationError, NetworkError, APIError } from './chunk-GHQK65J2.mjs';
|
|
3
3
|
export { APIError, ContractError, ErrorCode, NetworkError, ValidationError, ZKP2PError } from './chunk-GHQK65J2.mjs';
|
|
4
|
-
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-
|
|
5
|
-
export { HISTORICAL_ESCROW_ADDRESSES, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-
|
|
4
|
+
import { getContracts, getRateManagerContracts, getPaymentMethodsCatalog, resolvePaymentMethodHashFromCatalog, getGatingServiceAddress, parseBigIntLike, resolveFiatCurrencyBytes32, resolvePaymentMethodNameFromHash } from './chunk-J33LUXNA.mjs';
|
|
5
|
+
export { HISTORICAL_ESCROW_ADDRESSES, asciiToBytes32, enrichPvDepositView, enrichPvIntentView, ensureBytes32, getContracts, getGatingServiceAddress, getPaymentMethodsCatalog, getRateManagerContracts, parseDepositView, parseIntentView, resolveFiatCurrencyBytes32, resolvePaymentMethodHash, resolvePaymentMethodHashFromCatalog, resolvePaymentMethodNameFromHash } from './chunk-J33LUXNA.mjs';
|
|
6
6
|
import { Currency, currencyKeccak256 } from './chunk-ZFBH4HD7.mjs';
|
|
7
7
|
export { Currency, currencyInfo, getCurrencyCodeFromHash, getCurrencyInfoFromCountryCode, getCurrencyInfoFromHash, isSupportedCurrencyHash, mapConversionRatesToOnchainMinRate } from './chunk-ZFBH4HD7.mjs';
|
|
8
8
|
import { concatHex, encodeFunctionData, encodeAbiParameters, createPublicClient, http, formatUnits } from 'viem';
|
|
@@ -142,19 +142,14 @@ var ContractRouter = class {
|
|
|
142
142
|
this._orchestratorContextsByAddress = /* @__PURE__ */ new Map();
|
|
143
143
|
this.escrowAddress = config.escrowAddress;
|
|
144
144
|
this.escrowAbi = config.escrowAbi;
|
|
145
|
-
this.legacyEscrowAddress = config.legacyEscrowAddress;
|
|
146
|
-
this.legacyEscrowAbi = config.legacyEscrowAbi;
|
|
147
145
|
this.escrowV2Address = config.escrowV2Address;
|
|
148
146
|
this.escrowV2Abi = config.escrowV2Abi;
|
|
149
147
|
this.escrowAddresses = config.escrowAddresses;
|
|
150
148
|
this.orchestratorAddress = config.orchestratorAddress;
|
|
151
149
|
this.orchestratorAbi = config.orchestratorAbi;
|
|
152
|
-
this.legacyOrchestratorAddress = config.legacyOrchestratorAddress;
|
|
153
|
-
this.legacyOrchestratorAbi = config.legacyOrchestratorAbi;
|
|
154
150
|
this.orchestratorV2Address = config.orchestratorV2Address;
|
|
155
151
|
this.orchestratorV2Abi = config.orchestratorV2Abi;
|
|
156
152
|
this.orchestratorAddresses = config.orchestratorAddresses;
|
|
157
|
-
this._defaultPreferV2 = config.defaultPreferV2;
|
|
158
153
|
this._registerContexts();
|
|
159
154
|
}
|
|
160
155
|
_registerContexts() {
|
|
@@ -162,17 +157,20 @@ var ContractRouter = class {
|
|
|
162
157
|
if (!context?.address || !context.abi) return;
|
|
163
158
|
this._orchestratorContextsByAddress.set(context.address.toLowerCase(), context);
|
|
164
159
|
};
|
|
160
|
+
const registerEscrow = (context) => {
|
|
161
|
+
if (!context?.address || !context.abi) return;
|
|
162
|
+
this._escrowContextsByAddress.set(context.address.toLowerCase(), context);
|
|
163
|
+
};
|
|
164
|
+
const primaryOrchestratorAddress = this.orchestratorV2Address ?? this.orchestratorAddress;
|
|
165
|
+
const primaryEscrowAbi = this.escrowV2Abi ?? this.escrowAbi;
|
|
165
166
|
const escrowToOrchestrator = /* @__PURE__ */ new Map();
|
|
166
|
-
const addEscrowOrchestratorPair = (escrow, orchestrator
|
|
167
|
+
const addEscrowOrchestratorPair = (escrow, orchestrator) => {
|
|
167
168
|
if (!escrow || !orchestrator) return;
|
|
168
|
-
|
|
169
|
-
if (!overwrite && escrowToOrchestrator.has(key)) return;
|
|
170
|
-
escrowToOrchestrator.set(key, orchestrator);
|
|
169
|
+
escrowToOrchestrator.set(escrow.toLowerCase(), orchestrator);
|
|
171
170
|
};
|
|
172
|
-
addEscrowOrchestratorPair(this.legacyEscrowAddress, this.legacyOrchestratorAddress);
|
|
173
171
|
addEscrowOrchestratorPair(
|
|
174
|
-
this.escrowV2Address,
|
|
175
|
-
|
|
172
|
+
this.escrowV2Address ?? this.escrowAddress,
|
|
173
|
+
primaryOrchestratorAddress
|
|
176
174
|
);
|
|
177
175
|
const configuredPairCount = Math.min(
|
|
178
176
|
this.escrowAddresses.length,
|
|
@@ -181,81 +179,45 @@ var ContractRouter = class {
|
|
|
181
179
|
for (let index = 0; index < configuredPairCount; index += 1) {
|
|
182
180
|
addEscrowOrchestratorPair(this.escrowAddresses[index], this.orchestratorAddresses[index]);
|
|
183
181
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return this.legacyOrchestratorAbi ?? this.orchestratorAbi ?? this.orchestratorV2Abi;
|
|
198
|
-
}
|
|
199
|
-
return this.orchestratorAbi ?? this.orchestratorV2Abi ?? this.legacyOrchestratorAbi;
|
|
200
|
-
};
|
|
201
|
-
const resolveOrchestratorVersion = (address) => {
|
|
202
|
-
if (isSameAddress(address, this.legacyOrchestratorAddress)) return "legacy";
|
|
203
|
-
if (isSameAddress(address, this.orchestratorV2Address)) return "v2";
|
|
204
|
-
return this.orchestratorV2Abi ? "v2" : "legacy";
|
|
205
|
-
};
|
|
206
|
-
for (const address of this.orchestratorAddresses) {
|
|
207
|
-
const abi = resolveOrchestratorAbi(address);
|
|
182
|
+
const resolveOrchestratorAbi = (address) => this.getOrchestratorContextByAddress(address)?.abi ?? (isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi);
|
|
183
|
+
const uniqueOrchestratorAddresses = /* @__PURE__ */ new Set();
|
|
184
|
+
for (const address of [
|
|
185
|
+
primaryOrchestratorAddress,
|
|
186
|
+
this.orchestratorAddress,
|
|
187
|
+
this.orchestratorV2Address,
|
|
188
|
+
...this.orchestratorAddresses
|
|
189
|
+
]) {
|
|
190
|
+
if (!address) continue;
|
|
191
|
+
const key = address.toLowerCase();
|
|
192
|
+
if (uniqueOrchestratorAddresses.has(key)) continue;
|
|
193
|
+
uniqueOrchestratorAddresses.add(key);
|
|
194
|
+
const abi = isSameAddress(address, this.orchestratorV2Address) ? this.orchestratorV2Abi ?? this.orchestratorAbi : this.orchestratorAbi ?? this.orchestratorV2Abi;
|
|
208
195
|
if (!abi) continue;
|
|
209
196
|
registerOrchestrator({
|
|
210
197
|
address,
|
|
211
198
|
abi,
|
|
212
|
-
version:
|
|
199
|
+
version: "v2"
|
|
213
200
|
});
|
|
214
201
|
}
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
this.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
if (
|
|
222
|
-
const
|
|
223
|
-
if (
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
};
|
|
227
|
-
const resolveEscrowAbi = (version) => version === "legacy" ? this.legacyEscrowAbi ?? this.escrowAbi ?? this.escrowV2Abi : this.escrowV2Abi ?? this.escrowAbi ?? this.legacyEscrowAbi;
|
|
228
|
-
const resolveEscrowOrchestratorAddress = (escrowAddress, version) => escrowToOrchestrator.get(escrowAddress.toLowerCase()) ?? (version === "legacy" ? this.legacyOrchestratorAddress ?? this.orchestratorAddress : this.orchestratorV2Address ?? this.orchestratorAddress);
|
|
229
|
-
const resolveEscrowOrchestratorAbi = (orchestratorAddress, version) => this.getOrchestratorContextByAddress(orchestratorAddress)?.abi ?? (version === "legacy" ? this.legacyOrchestratorAbi ?? this.orchestratorAbi ?? this.orchestratorV2Abi : this.orchestratorV2Abi ?? this.orchestratorAbi ?? this.legacyOrchestratorAbi);
|
|
230
|
-
for (const address of this.escrowAddresses) {
|
|
231
|
-
const version = resolveEscrowVersion(address);
|
|
232
|
-
const abi = resolveEscrowAbi(version);
|
|
233
|
-
const orchAddress = resolveEscrowOrchestratorAddress(address, version);
|
|
234
|
-
const orchAbi = resolveEscrowOrchestratorAbi(orchAddress, version);
|
|
235
|
-
if (!abi) continue;
|
|
202
|
+
const uniqueEscrowAddresses = /* @__PURE__ */ new Set();
|
|
203
|
+
for (const address of [
|
|
204
|
+
this.escrowV2Address ?? this.escrowAddress,
|
|
205
|
+
this.escrowAddress,
|
|
206
|
+
...this.escrowAddresses
|
|
207
|
+
]) {
|
|
208
|
+
if (!address) continue;
|
|
209
|
+
const key = address.toLowerCase();
|
|
210
|
+
if (uniqueEscrowAddresses.has(key)) continue;
|
|
211
|
+
uniqueEscrowAddresses.add(key);
|
|
212
|
+
const orchestratorAddress = escrowToOrchestrator.get(key) ?? primaryOrchestratorAddress ?? this.orchestratorAddress;
|
|
236
213
|
registerEscrow({
|
|
237
214
|
address,
|
|
238
|
-
abi,
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
215
|
+
abi: isSameAddress(address, this.escrowV2Address) ? primaryEscrowAbi : this.escrowAbi,
|
|
216
|
+
orchestratorAddress,
|
|
217
|
+
orchestratorAbi: resolveOrchestratorAbi(orchestratorAddress),
|
|
218
|
+
version: "v2"
|
|
242
219
|
});
|
|
243
220
|
}
|
|
244
|
-
const primaryEscrowVersion = resolveEscrowVersion(this.escrowAddress);
|
|
245
|
-
const primaryEscrowOrchestratorAddress = resolveEscrowOrchestratorAddress(
|
|
246
|
-
this.escrowAddress,
|
|
247
|
-
primaryEscrowVersion
|
|
248
|
-
);
|
|
249
|
-
registerEscrow({
|
|
250
|
-
address: this.escrowAddress,
|
|
251
|
-
abi: this.escrowAbi,
|
|
252
|
-
version: primaryEscrowVersion,
|
|
253
|
-
orchestratorAddress: primaryEscrowOrchestratorAddress,
|
|
254
|
-
orchestratorAbi: resolveEscrowOrchestratorAbi(
|
|
255
|
-
primaryEscrowOrchestratorAddress,
|
|
256
|
-
primaryEscrowVersion
|
|
257
|
-
)
|
|
258
|
-
});
|
|
259
221
|
}
|
|
260
222
|
getEscrowContextByAddress(address) {
|
|
261
223
|
if (!address) return void 0;
|
|
@@ -270,33 +232,21 @@ var ContractRouter = class {
|
|
|
270
232
|
if (explicitEscrow) {
|
|
271
233
|
const explicitContext = this.getEscrowContextByAddress(explicitEscrow);
|
|
272
234
|
if (explicitContext) return explicitContext;
|
|
273
|
-
const
|
|
274
|
-
const isExplicitLegacy = !!this.legacyEscrowAddress && explicitEscrow.toLowerCase() === this.legacyEscrowAddress.toLowerCase();
|
|
275
|
-
const inferredVersion = isExplicitV2 ? "v2" : isExplicitLegacy ? "legacy" : options?.preferV2 === false ? "legacy" : options?.preferV2 === true ? "v2" : this.escrowV2Abi ? "v2" : "legacy";
|
|
235
|
+
const fallbackOrchestrator = this.resolveOrchestratorForEscrow(explicitEscrow);
|
|
276
236
|
return {
|
|
277
237
|
address: explicitEscrow,
|
|
278
|
-
abi:
|
|
279
|
-
orchestratorAddress:
|
|
280
|
-
orchestratorAbi:
|
|
281
|
-
version:
|
|
238
|
+
abi: this.escrowV2Abi ?? this.escrowAbi,
|
|
239
|
+
orchestratorAddress: fallbackOrchestrator?.address ?? this.orchestratorV2Address ?? this.orchestratorAddress,
|
|
240
|
+
orchestratorAbi: fallbackOrchestrator?.abi ?? this.orchestratorV2Abi ?? this.orchestratorAbi,
|
|
241
|
+
version: "v2"
|
|
282
242
|
};
|
|
283
243
|
}
|
|
284
|
-
if (options?.preferV2 === false) {
|
|
285
|
-
const legacyContext = this.getEscrowContexts().find(
|
|
286
|
-
(context) => context.version === "legacy"
|
|
287
|
-
);
|
|
288
|
-
if (legacyContext) return legacyContext;
|
|
289
|
-
}
|
|
290
|
-
if (options?.preferV2) {
|
|
291
|
-
const v2Context = this.getEscrowContexts().find((context) => context.version === "v2");
|
|
292
|
-
if (v2Context) return v2Context;
|
|
293
|
-
}
|
|
294
244
|
return this.getEscrowContextByAddress(this.escrowAddress) ?? {
|
|
295
245
|
address: this.escrowAddress,
|
|
296
246
|
abi: this.escrowAbi,
|
|
297
|
-
orchestratorAddress: this.orchestratorAddress,
|
|
298
|
-
orchestratorAbi: this.orchestratorAbi,
|
|
299
|
-
version:
|
|
247
|
+
orchestratorAddress: this.orchestratorV2Address ?? this.orchestratorAddress,
|
|
248
|
+
orchestratorAbi: this.orchestratorV2Abi ?? this.orchestratorAbi,
|
|
249
|
+
version: "v2"
|
|
300
250
|
};
|
|
301
251
|
}
|
|
302
252
|
getEscrowContexts() {
|
|
@@ -306,26 +256,21 @@ var ContractRouter = class {
|
|
|
306
256
|
{
|
|
307
257
|
address: this.escrowAddress,
|
|
308
258
|
abi: this.escrowAbi,
|
|
309
|
-
orchestratorAddress: this.orchestratorAddress,
|
|
310
|
-
orchestratorAbi: this.orchestratorAbi,
|
|
311
|
-
version: "
|
|
259
|
+
orchestratorAddress: this.orchestratorV2Address ?? this.orchestratorAddress,
|
|
260
|
+
orchestratorAbi: this.orchestratorV2Abi ?? this.orchestratorAbi,
|
|
261
|
+
version: "v2"
|
|
312
262
|
}
|
|
313
263
|
];
|
|
314
264
|
}
|
|
315
|
-
resolveOrchestratorForEscrow(escrowAddress,
|
|
265
|
+
resolveOrchestratorForEscrow(escrowAddress, _preferV2 = false) {
|
|
316
266
|
if (escrowAddress) {
|
|
317
267
|
const escrowContext = this.getEscrowContextByAddress(escrowAddress);
|
|
318
268
|
const fromEscrow = this.getOrchestratorContextByAddress(escrowContext?.orchestratorAddress);
|
|
319
269
|
if (fromEscrow) return fromEscrow;
|
|
320
270
|
}
|
|
321
|
-
if (
|
|
322
|
-
const
|
|
323
|
-
|
|
324
|
-
);
|
|
325
|
-
if (v2) return v2;
|
|
326
|
-
} else {
|
|
327
|
-
const legacyPrimary = this.getOrchestratorContextByAddress(this.legacyOrchestratorAddress);
|
|
328
|
-
if (legacyPrimary) return legacyPrimary;
|
|
271
|
+
if (this.orchestratorV2Address) {
|
|
272
|
+
const primary = this.getOrchestratorContextByAddress(this.orchestratorV2Address);
|
|
273
|
+
if (primary) return primary;
|
|
329
274
|
}
|
|
330
275
|
if (this.orchestratorAddress) {
|
|
331
276
|
const primary = this.getOrchestratorContextByAddress(this.orchestratorAddress);
|
|
@@ -335,13 +280,6 @@ var ContractRouter = class {
|
|
|
335
280
|
const context = this.getOrchestratorContextByAddress(address);
|
|
336
281
|
if (context) return context;
|
|
337
282
|
}
|
|
338
|
-
if (this.legacyOrchestratorAddress && this.legacyOrchestratorAbi) {
|
|
339
|
-
return {
|
|
340
|
-
address: this.legacyOrchestratorAddress,
|
|
341
|
-
abi: this.legacyOrchestratorAbi,
|
|
342
|
-
version: "legacy"
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
283
|
if (this.orchestratorV2Address && this.orchestratorV2Abi) {
|
|
346
284
|
return {
|
|
347
285
|
address: this.orchestratorV2Address,
|
|
@@ -349,6 +287,13 @@ var ContractRouter = class {
|
|
|
349
287
|
version: "v2"
|
|
350
288
|
};
|
|
351
289
|
}
|
|
290
|
+
if (this.orchestratorAddress && this.orchestratorAbi) {
|
|
291
|
+
return {
|
|
292
|
+
address: this.orchestratorAddress,
|
|
293
|
+
abi: this.orchestratorAbi,
|
|
294
|
+
version: "v2"
|
|
295
|
+
};
|
|
296
|
+
}
|
|
352
297
|
return void 0;
|
|
353
298
|
}
|
|
354
299
|
buildProtocolViewerContexts(options) {
|
|
@@ -363,17 +308,18 @@ var ContractRouter = class {
|
|
|
363
308
|
};
|
|
364
309
|
add(options?.escrowAddress, options?.orchestratorAddress);
|
|
365
310
|
if (options?.escrowAddress && !options?.orchestratorAddress) {
|
|
366
|
-
|
|
367
|
-
add(options.escrowAddress, resolved);
|
|
311
|
+
add(options.escrowAddress, this.resolveOrchestratorForEscrow(options.escrowAddress)?.address);
|
|
368
312
|
}
|
|
369
313
|
for (const context of this.getEscrowContexts()) {
|
|
370
|
-
|
|
371
|
-
|
|
314
|
+
add(
|
|
315
|
+
context.address,
|
|
316
|
+
context.orchestratorAddress ?? this.resolveOrchestratorForEscrow(context.address)?.address
|
|
317
|
+
);
|
|
372
318
|
}
|
|
373
319
|
return contexts;
|
|
374
320
|
}
|
|
375
321
|
get defaultPreferV2() {
|
|
376
|
-
return
|
|
322
|
+
return true;
|
|
377
323
|
}
|
|
378
324
|
};
|
|
379
325
|
|
|
@@ -1576,7 +1522,7 @@ var ProtocolViewerReader = class {
|
|
|
1576
1522
|
if (inputCount === null) {
|
|
1577
1523
|
throw new Error("Configured ProtocolViewer ABI does not expose getDeposit");
|
|
1578
1524
|
}
|
|
1579
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1525
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
|
|
1580
1526
|
if (inputCount >= 3) {
|
|
1581
1527
|
return tryContexts(
|
|
1582
1528
|
protocolViewerContexts,
|
|
@@ -1655,7 +1601,7 @@ var ProtocolViewerReader = class {
|
|
|
1655
1601
|
return Promise.all(ids.map((id) => this.config.host.getPvDepositById(id)));
|
|
1656
1602
|
}
|
|
1657
1603
|
const bn = ids.map((id) => typeof id === "bigint" ? id : parseRawDepositId(id));
|
|
1658
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1604
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
|
|
1659
1605
|
if (inputCount >= 2) {
|
|
1660
1606
|
const requests = ids.map((id, index) => ({
|
|
1661
1607
|
index,
|
|
@@ -1760,7 +1706,7 @@ var ProtocolViewerReader = class {
|
|
|
1760
1706
|
if (!protocolViewerAddress || !protocolViewerAbi || inputCount === null) {
|
|
1761
1707
|
return this.config.host.getPvAccountDepositsFromIndexer(owner);
|
|
1762
1708
|
}
|
|
1763
|
-
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-
|
|
1709
|
+
const { parseDepositView: parseDepositView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
|
|
1764
1710
|
const { address, abi } = this.config.host.requireProtocolViewer();
|
|
1765
1711
|
if (inputCount >= 2) {
|
|
1766
1712
|
const readAndFilter = async (raw2) => {
|
|
@@ -1831,7 +1777,7 @@ var ProtocolViewerReader = class {
|
|
|
1831
1777
|
if (protocolViewerEntries.length === 0) {
|
|
1832
1778
|
throw new Error("ProtocolViewer not available for this network");
|
|
1833
1779
|
}
|
|
1834
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1780
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
|
|
1835
1781
|
const intentsByHash = /* @__PURE__ */ new Map();
|
|
1836
1782
|
let attemptedRead = false;
|
|
1837
1783
|
let hadSuccessfulRead = false;
|
|
@@ -1939,7 +1885,7 @@ var ProtocolViewerReader = class {
|
|
|
1939
1885
|
if (protocolViewerEntries.length === 0) {
|
|
1940
1886
|
throw new Error("ProtocolViewer not available for this network");
|
|
1941
1887
|
}
|
|
1942
|
-
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-
|
|
1888
|
+
const { parseIntentView: parseIntentView2 } = await import('./protocolViewerParsers-VVASNOXW.mjs');
|
|
1943
1889
|
let lastError;
|
|
1944
1890
|
for (const pvEntry of protocolViewerEntries) {
|
|
1945
1891
|
const inputCount = this.pvEntryFunctionInputCount(pvEntry, "getIntent");
|
|
@@ -2827,6 +2773,20 @@ var RATE_MANAGER_FIELDS = `
|
|
|
2827
2773
|
createdAt
|
|
2828
2774
|
updatedAt
|
|
2829
2775
|
`;
|
|
2776
|
+
var LEGACY_RATE_MANAGER_FIELDS = `
|
|
2777
|
+
id
|
|
2778
|
+
chainId
|
|
2779
|
+
rateManagerAddress
|
|
2780
|
+
rateManagerId
|
|
2781
|
+
manager
|
|
2782
|
+
feeRecipient
|
|
2783
|
+
maxFee
|
|
2784
|
+
fee
|
|
2785
|
+
name
|
|
2786
|
+
uri
|
|
2787
|
+
createdAt
|
|
2788
|
+
updatedAt
|
|
2789
|
+
`;
|
|
2830
2790
|
var RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
2831
2791
|
id
|
|
2832
2792
|
chainId
|
|
@@ -2842,6 +2802,20 @@ var RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
|
2842
2802
|
firstSeenAt
|
|
2843
2803
|
updatedAt
|
|
2844
2804
|
`;
|
|
2805
|
+
var LEGACY_RATE_MANAGER_AGGREGATE_FIELDS = `
|
|
2806
|
+
id
|
|
2807
|
+
chainId
|
|
2808
|
+
rateManagerId
|
|
2809
|
+
manager
|
|
2810
|
+
totalFilledVolume
|
|
2811
|
+
totalFeeAmount
|
|
2812
|
+
totalPnlUsdCents
|
|
2813
|
+
fulfilledIntents
|
|
2814
|
+
currentDelegatedBalance
|
|
2815
|
+
currentDelegatedDeposits
|
|
2816
|
+
firstSeenAt
|
|
2817
|
+
updatedAt
|
|
2818
|
+
`;
|
|
2845
2819
|
var RATE_MANAGER_RATE_FIELDS = `
|
|
2846
2820
|
id
|
|
2847
2821
|
chainId
|
|
@@ -2857,9 +2831,7 @@ var DEPOSIT_DELEGATION_FIELDS = `
|
|
|
2857
2831
|
chainId
|
|
2858
2832
|
rateManagerId
|
|
2859
2833
|
rateManagerAddress
|
|
2860
|
-
depositId: id
|
|
2861
2834
|
delegatedAt
|
|
2862
|
-
createdAt: delegatedAt
|
|
2863
2835
|
updatedAt
|
|
2864
2836
|
`;
|
|
2865
2837
|
var LEGACY_RATE_MANAGER_DELEGATION_FIELDS = `
|
|
@@ -2935,6 +2907,7 @@ var RATE_MANAGER_LIST_QUERY = (
|
|
|
2935
2907
|
`
|
|
2936
2908
|
query VaultList(
|
|
2937
2909
|
$where: RateManager_bool_exp
|
|
2910
|
+
$aggregateWhere: ManagerAggregateStats_bool_exp
|
|
2938
2911
|
$order_by: [RateManager_order_by!]
|
|
2939
2912
|
$limit: Int
|
|
2940
2913
|
$offset: Int
|
|
@@ -2942,12 +2915,31 @@ var RATE_MANAGER_LIST_QUERY = (
|
|
|
2942
2915
|
RateManager(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {
|
|
2943
2916
|
${RATE_MANAGER_FIELDS}
|
|
2944
2917
|
}
|
|
2945
|
-
ManagerAggregateStats {
|
|
2918
|
+
ManagerAggregateStats(where: $aggregateWhere) {
|
|
2946
2919
|
${RATE_MANAGER_AGGREGATE_FIELDS}
|
|
2947
2920
|
}
|
|
2948
2921
|
}
|
|
2949
2922
|
`
|
|
2950
2923
|
);
|
|
2924
|
+
var LEGACY_RATE_MANAGER_LIST_QUERY = (
|
|
2925
|
+
/* GraphQL */
|
|
2926
|
+
`
|
|
2927
|
+
query VaultList(
|
|
2928
|
+
$where: RateManager_bool_exp
|
|
2929
|
+
$aggregateWhere: ManagerAggregateStats_bool_exp
|
|
2930
|
+
$order_by: [RateManager_order_by!]
|
|
2931
|
+
$limit: Int
|
|
2932
|
+
$offset: Int
|
|
2933
|
+
) {
|
|
2934
|
+
RateManager(where: $where, order_by: $order_by, limit: $limit, offset: $offset) {
|
|
2935
|
+
${LEGACY_RATE_MANAGER_FIELDS}
|
|
2936
|
+
}
|
|
2937
|
+
ManagerAggregateStats(where: $aggregateWhere) {
|
|
2938
|
+
${LEGACY_RATE_MANAGER_AGGREGATE_FIELDS}
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
`
|
|
2942
|
+
);
|
|
2951
2943
|
var RATE_MANAGER_DETAIL_QUERY = (
|
|
2952
2944
|
/* GraphQL */
|
|
2953
2945
|
`
|
|
@@ -2994,13 +2986,13 @@ var LEGACY_RATE_MANAGER_DETAIL_QUERY = (
|
|
|
2994
2986
|
$statsLimit: Int
|
|
2995
2987
|
) {
|
|
2996
2988
|
RateManager(where: $managerWhere) {
|
|
2997
|
-
${
|
|
2989
|
+
${LEGACY_RATE_MANAGER_FIELDS}
|
|
2998
2990
|
}
|
|
2999
2991
|
RateManagerRate(where: $rateWhere) {
|
|
3000
2992
|
${RATE_MANAGER_RATE_FIELDS}
|
|
3001
2993
|
}
|
|
3002
2994
|
ManagerAggregateStats(where: $aggregateWhere) {
|
|
3003
|
-
${
|
|
2995
|
+
${LEGACY_RATE_MANAGER_AGGREGATE_FIELDS}
|
|
3004
2996
|
}
|
|
3005
2997
|
ManagerStats(
|
|
3006
2998
|
where: $statsWhere
|
|
@@ -4031,6 +4023,25 @@ function extractEscrowAddressFromCompositeDepositId(compositeDepositId) {
|
|
|
4031
4023
|
const [escrowAddress] = compositeDepositId.split("_");
|
|
4032
4024
|
return escrowAddress?.startsWith("0x") ? escrowAddress.toLowerCase() : null;
|
|
4033
4025
|
}
|
|
4026
|
+
function parseRateManagerFilterIds(rateManagerIds) {
|
|
4027
|
+
const bare = /* @__PURE__ */ new Set();
|
|
4028
|
+
const scoped = /* @__PURE__ */ new Map();
|
|
4029
|
+
for (const value of rateManagerIds) {
|
|
4030
|
+
const scopedRateManager = parseScopedRateManagerFilterId(value);
|
|
4031
|
+
if (scopedRateManager) {
|
|
4032
|
+
scoped.set(
|
|
4033
|
+
getManagerScopeKey(scopedRateManager.rateManagerId, scopedRateManager.rateManagerAddress),
|
|
4034
|
+
scopedRateManager
|
|
4035
|
+
);
|
|
4036
|
+
continue;
|
|
4037
|
+
}
|
|
4038
|
+
const normalizedRateManagerId = normalizeRateManagerId2(value);
|
|
4039
|
+
if (normalizedRateManagerId) {
|
|
4040
|
+
bare.add(normalizedRateManagerId);
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
return { bare, scoped };
|
|
4044
|
+
}
|
|
4034
4045
|
function buildDepositScopeKey(scope) {
|
|
4035
4046
|
return `${scope.escrow}:${scope.depositIdOnContract}`;
|
|
4036
4047
|
}
|
|
@@ -4109,6 +4120,29 @@ var IndexerRateManagerService = class {
|
|
|
4109
4120
|
constructor(client) {
|
|
4110
4121
|
this.client = client;
|
|
4111
4122
|
}
|
|
4123
|
+
buildRateManagerScopeWhere(rateManagerIds) {
|
|
4124
|
+
if (!rateManagerIds?.length) return void 0;
|
|
4125
|
+
const { bare, scoped } = parseRateManagerFilterIds(rateManagerIds);
|
|
4126
|
+
const scopeConditions = [];
|
|
4127
|
+
if (bare.size > 0) {
|
|
4128
|
+
scopeConditions.push({
|
|
4129
|
+
rateManagerId: { _in: [...bare] }
|
|
4130
|
+
});
|
|
4131
|
+
}
|
|
4132
|
+
for (const scopedRateManager of scoped.values()) {
|
|
4133
|
+
scopeConditions.push({
|
|
4134
|
+
rateManagerId: { _eq: scopedRateManager.rateManagerId },
|
|
4135
|
+
rateManagerAddress: { _eq: scopedRateManager.rateManagerAddress }
|
|
4136
|
+
});
|
|
4137
|
+
}
|
|
4138
|
+
if (scopeConditions.length === 1) {
|
|
4139
|
+
return scopeConditions[0];
|
|
4140
|
+
}
|
|
4141
|
+
if (scopeConditions.length > 1) {
|
|
4142
|
+
return { _or: scopeConditions };
|
|
4143
|
+
}
|
|
4144
|
+
return void 0;
|
|
4145
|
+
}
|
|
4112
4146
|
buildWhere(filter) {
|
|
4113
4147
|
if (!filter) return void 0;
|
|
4114
4148
|
const where = {};
|
|
@@ -4121,46 +4155,44 @@ var IndexerRateManagerService = class {
|
|
|
4121
4155
|
if (filter.maxFee) {
|
|
4122
4156
|
where.maxFee = { _lte: filter.maxFee };
|
|
4123
4157
|
}
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
for (const value of filter.rateManagerIds) {
|
|
4128
|
-
const scopedRateManager = parseScopedRateManagerFilterId(value);
|
|
4129
|
-
if (scopedRateManager) {
|
|
4130
|
-
scopedRateManagers.set(
|
|
4131
|
-
getManagerScopeKey(
|
|
4132
|
-
scopedRateManager.rateManagerId,
|
|
4133
|
-
scopedRateManager.rateManagerAddress
|
|
4134
|
-
),
|
|
4135
|
-
scopedRateManager
|
|
4136
|
-
);
|
|
4137
|
-
continue;
|
|
4138
|
-
}
|
|
4139
|
-
const normalizedRateManagerId = normalizeRateManagerId2(value);
|
|
4140
|
-
if (normalizedRateManagerId) {
|
|
4141
|
-
bareRateManagerIds.add(normalizedRateManagerId);
|
|
4142
|
-
}
|
|
4143
|
-
}
|
|
4144
|
-
const scopeConditions = [];
|
|
4145
|
-
if (bareRateManagerIds.size > 0) {
|
|
4146
|
-
scopeConditions.push({
|
|
4147
|
-
rateManagerId: { _in: [...bareRateManagerIds] }
|
|
4148
|
-
});
|
|
4149
|
-
}
|
|
4150
|
-
for (const scopedRateManager of scopedRateManagers.values()) {
|
|
4151
|
-
scopeConditions.push({
|
|
4152
|
-
rateManagerId: { _eq: scopedRateManager.rateManagerId },
|
|
4153
|
-
rateManagerAddress: { _eq: scopedRateManager.rateManagerAddress }
|
|
4154
|
-
});
|
|
4155
|
-
}
|
|
4156
|
-
if (scopeConditions.length === 1) {
|
|
4157
|
-
Object.assign(where, scopeConditions[0]);
|
|
4158
|
-
} else if (scopeConditions.length > 1) {
|
|
4159
|
-
where._or = scopeConditions;
|
|
4160
|
-
}
|
|
4158
|
+
const scopeWhere = this.buildRateManagerScopeWhere(filter.rateManagerIds);
|
|
4159
|
+
if (scopeWhere) {
|
|
4160
|
+
Object.assign(where, scopeWhere);
|
|
4161
4161
|
}
|
|
4162
4162
|
return Object.keys(where).length ? where : void 0;
|
|
4163
4163
|
}
|
|
4164
|
+
buildAggregateWhere(filter) {
|
|
4165
|
+
return this.buildRateManagerScopeWhere(filter?.rateManagerIds) ?? {};
|
|
4166
|
+
}
|
|
4167
|
+
buildLegacyAggregateWhere(filter) {
|
|
4168
|
+
const rateManagerIds = filter?.rateManagerIds;
|
|
4169
|
+
if (!rateManagerIds?.length) return {};
|
|
4170
|
+
const { bare, scoped } = parseRateManagerFilterIds(rateManagerIds);
|
|
4171
|
+
const scopeConditions = [];
|
|
4172
|
+
if (bare.size > 0) {
|
|
4173
|
+
scopeConditions.push({
|
|
4174
|
+
rateManagerId: { _in: [...bare] }
|
|
4175
|
+
});
|
|
4176
|
+
}
|
|
4177
|
+
for (const scopedRateManager of scoped.values()) {
|
|
4178
|
+
scopeConditions.push({
|
|
4179
|
+
rateManagerId: { _eq: scopedRateManager.rateManagerId },
|
|
4180
|
+
id: {
|
|
4181
|
+
_ilike: buildRateManagerAddressScopedIdPattern(
|
|
4182
|
+
scopedRateManager.rateManagerId,
|
|
4183
|
+
scopedRateManager.rateManagerAddress
|
|
4184
|
+
)
|
|
4185
|
+
}
|
|
4186
|
+
});
|
|
4187
|
+
}
|
|
4188
|
+
if (scopeConditions.length === 1) {
|
|
4189
|
+
return scopeConditions[0] ?? {};
|
|
4190
|
+
}
|
|
4191
|
+
if (scopeConditions.length > 1) {
|
|
4192
|
+
return { _or: scopeConditions };
|
|
4193
|
+
}
|
|
4194
|
+
return {};
|
|
4195
|
+
}
|
|
4164
4196
|
buildOrderBy(pagination) {
|
|
4165
4197
|
const rawField = pagination?.orderBy ?? "createdAt";
|
|
4166
4198
|
const field = isAggregateOrderField(rawField) ? "createdAt" : rawField;
|
|
@@ -4186,11 +4218,21 @@ var IndexerRateManagerService = class {
|
|
|
4186
4218
|
if (hasHook === void 0) return rows;
|
|
4187
4219
|
return hasHook ? [] : rows;
|
|
4188
4220
|
}
|
|
4189
|
-
async queryRateManagerList(variables) {
|
|
4190
|
-
|
|
4191
|
-
query
|
|
4192
|
-
|
|
4193
|
-
|
|
4221
|
+
async queryRateManagerList(variables, legacyVariables) {
|
|
4222
|
+
try {
|
|
4223
|
+
return await this.client.query({
|
|
4224
|
+
query: RATE_MANAGER_LIST_QUERY,
|
|
4225
|
+
variables
|
|
4226
|
+
});
|
|
4227
|
+
} catch (error) {
|
|
4228
|
+
if (!isSchemaCompatibilityError(error)) {
|
|
4229
|
+
throw error;
|
|
4230
|
+
}
|
|
4231
|
+
return this.client.query({
|
|
4232
|
+
query: LEGACY_RATE_MANAGER_LIST_QUERY,
|
|
4233
|
+
variables: legacyVariables
|
|
4234
|
+
});
|
|
4235
|
+
}
|
|
4194
4236
|
}
|
|
4195
4237
|
buildDelegationOrderBy(pagination) {
|
|
4196
4238
|
const rawField = pagination?.orderBy ?? "updatedAt";
|
|
@@ -4285,11 +4327,21 @@ var IndexerRateManagerService = class {
|
|
|
4285
4327
|
const limit = pagination?.limit ?? DEFAULT_LIMIT2;
|
|
4286
4328
|
const offset = pagination?.offset ?? 0;
|
|
4287
4329
|
const where = this.buildWhere(filter);
|
|
4330
|
+
const aggregateWhere = this.buildAggregateWhere(filter);
|
|
4331
|
+
const legacyAggregateWhere = this.buildLegacyAggregateWhere(filter);
|
|
4288
4332
|
if (isAggregateOrderField(orderBy)) {
|
|
4289
|
-
const result2 = await this.queryRateManagerList(
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4333
|
+
const result2 = await this.queryRateManagerList(
|
|
4334
|
+
{
|
|
4335
|
+
where,
|
|
4336
|
+
aggregateWhere,
|
|
4337
|
+
order_by: [{ createdAt: "desc" }]
|
|
4338
|
+
},
|
|
4339
|
+
{
|
|
4340
|
+
where,
|
|
4341
|
+
aggregateWhere: legacyAggregateWhere,
|
|
4342
|
+
order_by: [{ createdAt: "desc" }]
|
|
4343
|
+
}
|
|
4344
|
+
);
|
|
4293
4345
|
const scopedRows = this.applyHookFilter(this.toRateManagerListItems(result2), filter?.hasHook);
|
|
4294
4346
|
const sorted = scopedRows.sort((a, b) => {
|
|
4295
4347
|
const av = orderBy === "currentDelegatedBalance" ? toSafeBigInt(a.aggregate?.currentDelegatedBalance) : toSafeBigInt(a.aggregate?.totalFilledVolume);
|
|
@@ -4306,12 +4358,22 @@ var IndexerRateManagerService = class {
|
|
|
4306
4358
|
});
|
|
4307
4359
|
return sorted.slice(offset, offset + limit);
|
|
4308
4360
|
}
|
|
4309
|
-
const result = await this.queryRateManagerList(
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
|
|
4361
|
+
const result = await this.queryRateManagerList(
|
|
4362
|
+
{
|
|
4363
|
+
where,
|
|
4364
|
+
aggregateWhere,
|
|
4365
|
+
order_by: this.buildOrderBy(pagination),
|
|
4366
|
+
limit,
|
|
4367
|
+
offset
|
|
4368
|
+
},
|
|
4369
|
+
{
|
|
4370
|
+
where,
|
|
4371
|
+
aggregateWhere: legacyAggregateWhere,
|
|
4372
|
+
order_by: this.buildOrderBy(pagination),
|
|
4373
|
+
limit,
|
|
4374
|
+
offset
|
|
4375
|
+
}
|
|
4376
|
+
);
|
|
4315
4377
|
return this.applyHookFilter(this.toRateManagerListItems(result), filter?.hasHook);
|
|
4316
4378
|
}
|
|
4317
4379
|
async fetchRateManagerDetail(rateManagerId, options) {
|
|
@@ -5864,58 +5926,32 @@ var Zkp2pClient = class {
|
|
|
5864
5926
|
}
|
|
5865
5927
|
return out;
|
|
5866
5928
|
};
|
|
5867
|
-
|
|
5868
|
-
this.legacyEscrowAddress = toAddress(addresses.escrow);
|
|
5869
|
-
this.legacyEscrowAbi = abis.escrow;
|
|
5870
|
-
this.escrowV2Address = toAddress(addresses.escrowV2);
|
|
5929
|
+
this.escrowV2Address = toAddress(addresses.escrowV2 ?? addresses.escrow);
|
|
5871
5930
|
this.escrowV2Abi = abis.escrowV2 ?? abis.escrow;
|
|
5872
|
-
this.
|
|
5873
|
-
|
|
5874
|
-
|
|
5931
|
+
this.orchestratorV2Address = toAddress(
|
|
5932
|
+
addresses.orchestratorV2 ?? addresses.orchestrator
|
|
5933
|
+
);
|
|
5875
5934
|
this.orchestratorV2Abi = abis.orchestratorV2 ?? abis.orchestrator;
|
|
5876
5935
|
const configuredEscrowAddresses = (addresses.escrowAddresses ?? []).map((value) => toAddress(value)).filter(Boolean);
|
|
5877
5936
|
const configuredOrchestratorAddresses = (addresses.orchestratorAddresses ?? []).map((value) => toAddress(value)).filter(Boolean);
|
|
5878
|
-
const inferLegacyAddress = (legacyAddress, v2Address, configuredAddresses) => {
|
|
5879
|
-
if (legacyAddress && (!v2Address || !isSameAddress2(legacyAddress, v2Address))) {
|
|
5880
|
-
return legacyAddress;
|
|
5881
|
-
}
|
|
5882
|
-
return configuredAddresses.find(
|
|
5883
|
-
(candidate) => !v2Address || !isSameAddress2(candidate, v2Address)
|
|
5884
|
-
) ?? legacyAddress;
|
|
5885
|
-
};
|
|
5886
|
-
this.legacyEscrowAddress = inferLegacyAddress(
|
|
5887
|
-
this.legacyEscrowAddress,
|
|
5888
|
-
this.escrowV2Address,
|
|
5889
|
-
configuredEscrowAddresses
|
|
5890
|
-
);
|
|
5891
|
-
this.legacyOrchestratorAddress = inferLegacyAddress(
|
|
5892
|
-
this.legacyOrchestratorAddress,
|
|
5893
|
-
this.orchestratorV2Address,
|
|
5894
|
-
configuredOrchestratorAddresses
|
|
5895
|
-
);
|
|
5896
|
-
const defaultPreferV2 = opts.preferV2ByDefault !== void 0 ? opts.preferV2ByDefault : this.runtimeEnv === "staging";
|
|
5897
|
-
const preferredEscrowAddress = defaultPreferV2 ? this.escrowV2Address : this.legacyEscrowAddress;
|
|
5898
|
-
const fallbackEscrowAddress = defaultPreferV2 ? this.legacyEscrowAddress : this.escrowV2Address;
|
|
5899
|
-
const preferredOrchestratorAddress = defaultPreferV2 ? this.orchestratorV2Address : this.legacyOrchestratorAddress;
|
|
5900
|
-
const fallbackOrchestratorAddress = defaultPreferV2 ? this.legacyOrchestratorAddress : this.orchestratorV2Address;
|
|
5901
5937
|
this.escrowAddresses = uniqAddresses([
|
|
5902
|
-
|
|
5903
|
-
fallbackEscrowAddress,
|
|
5938
|
+
this.escrowV2Address ?? toAddress(addresses.escrow),
|
|
5904
5939
|
...configuredEscrowAddresses
|
|
5905
5940
|
]);
|
|
5906
|
-
this.
|
|
5907
|
-
|
|
5908
|
-
fallbackOrchestratorAddress,
|
|
5909
|
-
...configuredOrchestratorAddresses
|
|
5910
|
-
]);
|
|
5911
|
-
this.escrowAddress = preferredEscrowAddress ?? fallbackEscrowAddress ?? this.escrowAddresses[0];
|
|
5912
|
-
this.escrowAbi = defaultPreferV2 ? this.escrowV2Abi ?? this.legacyEscrowAbi ?? abis.escrow : this.legacyEscrowAbi ?? this.escrowV2Abi ?? abis.escrow;
|
|
5941
|
+
this.escrowAddress = this.escrowV2Address ?? toAddress(addresses.escrow) ?? this.escrowAddresses[0];
|
|
5942
|
+
this.escrowAbi = this.escrowV2Abi ?? abis.escrow;
|
|
5913
5943
|
if (!this.escrowAddress || !this.escrowAbi) {
|
|
5914
5944
|
throw new Error("Escrow not available for this chain/environment");
|
|
5915
5945
|
}
|
|
5916
|
-
this.
|
|
5917
|
-
|
|
5918
|
-
|
|
5946
|
+
this.orchestratorAddresses = uniqAddresses([
|
|
5947
|
+
this.orchestratorV2Address ?? toAddress(addresses.orchestrator),
|
|
5948
|
+
...configuredOrchestratorAddresses
|
|
5949
|
+
]);
|
|
5950
|
+
this.orchestratorAddress = this.orchestratorV2Address ?? toAddress(addresses.orchestrator) ?? this.orchestratorAddresses[0];
|
|
5951
|
+
this.orchestratorAbi = this.orchestratorV2Abi ?? abis.orchestrator;
|
|
5952
|
+
this.unifiedPaymentVerifier = toAddress(
|
|
5953
|
+
addresses.unifiedPaymentVerifierV2 ?? addresses.unifiedPaymentVerifier
|
|
5954
|
+
);
|
|
5919
5955
|
this.protocolViewerAddress = toAddress(addresses.protocolViewer);
|
|
5920
5956
|
this.protocolViewerAbi = abis.protocolViewer;
|
|
5921
5957
|
const resolvedPvEntries = addresses.protocolViewerEntries;
|
|
@@ -5954,19 +5990,14 @@ var Zkp2pClient = class {
|
|
|
5954
5990
|
this._router = new ContractRouter({
|
|
5955
5991
|
escrowAddress: this.escrowAddress,
|
|
5956
5992
|
escrowAbi: this.escrowAbi,
|
|
5957
|
-
legacyEscrowAddress: this.legacyEscrowAddress,
|
|
5958
|
-
legacyEscrowAbi: this.legacyEscrowAbi,
|
|
5959
5993
|
escrowV2Address: this.escrowV2Address,
|
|
5960
5994
|
escrowV2Abi: this.escrowV2Abi,
|
|
5961
5995
|
escrowAddresses: this.escrowAddresses,
|
|
5962
5996
|
orchestratorAddress: this.orchestratorAddress,
|
|
5963
5997
|
orchestratorAbi: this.orchestratorAbi,
|
|
5964
|
-
legacyOrchestratorAddress: this.legacyOrchestratorAddress,
|
|
5965
|
-
legacyOrchestratorAbi: this.legacyOrchestratorAbi,
|
|
5966
5998
|
orchestratorV2Address: this.orchestratorV2Address,
|
|
5967
5999
|
orchestratorV2Abi: this.orchestratorV2Abi,
|
|
5968
|
-
orchestratorAddresses: this.orchestratorAddresses
|
|
5969
|
-
defaultPreferV2
|
|
6000
|
+
orchestratorAddresses: this.orchestratorAddresses
|
|
5970
6001
|
});
|
|
5971
6002
|
const maybeUsdc = addresses.usdc;
|
|
5972
6003
|
if (maybeUsdc) this._usdcAddress = maybeUsdc;
|
|
@@ -6095,7 +6126,7 @@ var Zkp2pClient = class {
|
|
|
6095
6126
|
const resolved = escrowAddress ?? this.parseEscrowAddressFromCompositeDepositId(depositId);
|
|
6096
6127
|
if (resolved) return resolved;
|
|
6097
6128
|
if (options?.preferV2 !== void 0) {
|
|
6098
|
-
return this.resolveEscrowContext(
|
|
6129
|
+
return this.resolveEscrowContext().address;
|
|
6099
6130
|
}
|
|
6100
6131
|
throw new Error(`${methodName} requires escrowAddress or composite depositId`);
|
|
6101
6132
|
}
|
|
@@ -6133,7 +6164,10 @@ var Zkp2pClient = class {
|
|
|
6133
6164
|
return this._router.getOrchestratorContextByAddress(address);
|
|
6134
6165
|
}
|
|
6135
6166
|
resolveEscrowContext(options) {
|
|
6136
|
-
return this._router.resolveEscrowContext(
|
|
6167
|
+
return this._router.resolveEscrowContext({
|
|
6168
|
+
escrowAddress: options?.escrowAddress,
|
|
6169
|
+
depositId: options?.depositId
|
|
6170
|
+
});
|
|
6137
6171
|
}
|
|
6138
6172
|
async resolveEscrowContextForDepositWrite(options) {
|
|
6139
6173
|
const explicitEscrow = options?.escrowAddress ?? (options?.depositId !== void 0 ? this.parseEscrowAddressFromCompositeDepositId(options.depositId) : void 0);
|
|
@@ -6236,21 +6270,9 @@ var Zkp2pClient = class {
|
|
|
6236
6270
|
if (explicit) return explicit;
|
|
6237
6271
|
if (options?.orchestratorAddress) {
|
|
6238
6272
|
const addr = options.orchestratorAddress;
|
|
6239
|
-
const
|
|
6240
|
-
let version;
|
|
6241
|
-
let abi;
|
|
6242
|
-
if (isSame(addr, this.orchestratorV2Address)) {
|
|
6243
|
-
version = "v2";
|
|
6244
|
-
abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
6245
|
-
} else if (isSame(addr, this.legacyOrchestratorAddress)) {
|
|
6246
|
-
version = "legacy";
|
|
6247
|
-
abi = this.legacyOrchestratorAbi ?? this.orchestratorAbi;
|
|
6248
|
-
} else {
|
|
6249
|
-
version = this.orchestratorV2Abi ? "v2" : "legacy";
|
|
6250
|
-
abi = this.orchestratorAbi ?? this.orchestratorV2Abi ?? this.legacyOrchestratorAbi;
|
|
6251
|
-
}
|
|
6273
|
+
const abi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
6252
6274
|
if (!abi) throw new Error("Orchestrator not available");
|
|
6253
|
-
return { address: addr, abi, version };
|
|
6275
|
+
return { address: addr, abi, version: "v2" };
|
|
6254
6276
|
}
|
|
6255
6277
|
if (options?.intentHash) {
|
|
6256
6278
|
try {
|
|
@@ -6285,30 +6307,16 @@ var Zkp2pClient = class {
|
|
|
6285
6307
|
if (fromEscrow) return fromEscrow;
|
|
6286
6308
|
}
|
|
6287
6309
|
if (options?.intentHash) {
|
|
6288
|
-
const
|
|
6289
|
-
const primaryAddress = preferV2 ? this.orchestratorV2Address : this.legacyOrchestratorAddress;
|
|
6290
|
-
const secondaryAddress = preferV2 ? this.legacyOrchestratorAddress : this.orchestratorV2Address;
|
|
6310
|
+
const primaryAddress = this.orchestratorV2Address ?? this.orchestratorAddress;
|
|
6291
6311
|
const primaryContext = this.getOrchestratorContextByAddress(primaryAddress);
|
|
6292
6312
|
if (primaryContext) return primaryContext;
|
|
6293
|
-
const secondaryContext = this.getOrchestratorContextByAddress(secondaryAddress);
|
|
6294
|
-
if (secondaryContext) return secondaryContext;
|
|
6295
6313
|
if (primaryAddress) {
|
|
6296
|
-
const primaryAbi =
|
|
6314
|
+
const primaryAbi = this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
6297
6315
|
if (primaryAbi) {
|
|
6298
6316
|
return {
|
|
6299
6317
|
address: primaryAddress,
|
|
6300
6318
|
abi: primaryAbi,
|
|
6301
|
-
version:
|
|
6302
|
-
};
|
|
6303
|
-
}
|
|
6304
|
-
}
|
|
6305
|
-
if (secondaryAddress) {
|
|
6306
|
-
const secondaryAbi = preferV2 ? this.legacyOrchestratorAbi ?? this.orchestratorAbi : this.orchestratorV2Abi ?? this.orchestratorAbi;
|
|
6307
|
-
if (secondaryAbi) {
|
|
6308
|
-
return {
|
|
6309
|
-
address: secondaryAddress,
|
|
6310
|
-
abi: secondaryAbi,
|
|
6311
|
-
version: preferV2 ? "legacy" : "v2"
|
|
6319
|
+
version: "v2"
|
|
6312
6320
|
};
|
|
6313
6321
|
}
|
|
6314
6322
|
}
|
|
@@ -7443,11 +7451,9 @@ var Zkp2pClient = class {
|
|
|
7443
7451
|
escrow: this.escrowAddress,
|
|
7444
7452
|
escrowV2: this.escrowV2Address,
|
|
7445
7453
|
escrowAddresses: this.escrowAddresses,
|
|
7446
|
-
legacyEscrow: this.legacyEscrowAddress,
|
|
7447
7454
|
orchestrator: this.orchestratorAddress,
|
|
7448
7455
|
orchestratorV2: this.orchestratorV2Address,
|
|
7449
7456
|
orchestratorAddresses: this.orchestratorAddresses,
|
|
7450
|
-
legacyOrchestrator: this.legacyOrchestratorAddress,
|
|
7451
7457
|
protocolViewer: this.protocolViewerAddress,
|
|
7452
7458
|
protocolViewerEntries: this._protocolViewerEntries.map((e) => e.address),
|
|
7453
7459
|
unifiedPaymentVerifier: this.unifiedPaymentVerifier,
|
|
@@ -7664,6 +7670,6 @@ var createPeerExtensionSdk = (options = {}) => ({
|
|
|
7664
7670
|
});
|
|
7665
7671
|
var peerExtensionSdk = createPeerExtensionSdk();
|
|
7666
7672
|
|
|
7667
|
-
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
7673
|
+
export { BASE_BUILDER_CODE, CHAINLINK_ORACLE_ADAPTER, CHAINLINK_ORACLE_FEEDS, ContractRouter, DEFAULT_ORACLE_MAX_STALENESS_SECONDS, IndexerClient, IndexerDepositService, IndexerRateManagerService, Zkp2pClient as OfframpClient, PAYMENT_PLATFORMS, PEER_EXTENSION_CHROME_URL, PLATFORM_METADATA, PYTH_CONTRACT_BASE, PYTH_ORACLE_ADAPTER, PYTH_ORACLE_FEEDS, SPREAD_ORACLE_FEEDS, SUPPORTED_CHAIN_IDS, TOKEN_METADATA, ZKP2P_ANDROID_REFERRER, ZKP2P_IOS_REFERRER, Zkp2pClient, apiGetOwnerDeposits, apiGetPayeeDetails, apiGetTakerTier, apiPostDepositDetails, apiValidatePayeeDetails, appendAttributionToCalldata, assertValidReferrerFeeConfig, compareEventCursorIdsByRecency, convertDepositsForLiquidity, convertIndexerDepositToEscrowView, convertIndexerIntentsToEscrowViews, createCompositeDepositId, createPeerExtensionSdk, defaultIndexerEndpoint, encodePythAdapterConfig, encodeSpreadOracleAdapterConfig, encodeWithAttribution, fetchFulfillmentAndPayment as fetchIndexerFulfillmentAndPayment, getAttributionDataSuffix, getPeerExtensionState, getSpreadOracleConfig, isPeerExtensionAvailable, isValidReferrerFeeBps, isValidReferrerFeeRecipient, logger, openPeerExtensionInstallPage, parseReferrerFeeConfig, peerExtensionSdk, referrerFeeConfigToPreciseUnits, sendTransactionWithAttribution, setLogLevel, validateOracleFeedsOnChain };
|
|
7668
7674
|
//# sourceMappingURL=index.mjs.map
|
|
7669
7675
|
//# sourceMappingURL=index.mjs.map
|