@across-protocol/sdk 4.1.46-beta.1 → 4.1.46-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +11 -15
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +6 -52
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +20 -48
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +6 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.js +6 -6
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js +2 -2
- package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +0 -3
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +0 -7
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +5 -5
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/Common.d.ts +2 -2
- package/dist/cjs/utils/EventUtils.d.ts +1 -2
- package/dist/cjs/utils/EventUtils.js +12 -21
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +11 -15
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +7 -58
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +20 -48
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +3 -5
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.js +6 -6
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockConfigStoreClient.js +3 -3
- package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +0 -3
- package/dist/esm/clients/mocks/MockHubPoolClient.js +0 -7
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +5 -5
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/Common.d.ts +2 -2
- package/dist/esm/utils/EventUtils.d.ts +1 -2
- package/dist/esm/utils/EventUtils.js +10 -18
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +20 -48
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +0 -3
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/Common.d.ts +2 -2
- package/dist/types/interfaces/Common.d.ts.map +1 -1
- package/dist/types/utils/EventUtils.d.ts +1 -2
- package/dist/types/utils/EventUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +15 -17
- package/src/clients/BundleDataClient/BundleDataClient.ts +5 -107
- package/src/clients/BundleDataClient/utils/FillUtils.ts +3 -1
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +3 -7
- package/src/clients/HubPoolClient.ts +10 -7
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +1 -2
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +1 -1
- package/src/clients/mocks/MockConfigStoreClient.ts +3 -10
- package/src/clients/mocks/MockHubPoolClient.ts +1 -10
- package/src/clients/mocks/MockSpokePoolClient.ts +5 -5
- package/src/interfaces/Common.ts +2 -2
- package/src/utils/EventUtils.ts +13 -19
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
DisabledChainsUpdate,
|
|
25
25
|
GlobalConfigUpdate,
|
|
26
26
|
LiteChainsIdListUpdate,
|
|
27
|
+
Log,
|
|
27
28
|
ParsedTokenConfig,
|
|
28
29
|
RateModelUpdate,
|
|
29
30
|
RouteRateModelUpdate,
|
|
@@ -42,8 +43,8 @@ type ConfigStoreUpdateSuccess = {
|
|
|
42
43
|
chainId: number;
|
|
43
44
|
searchEndBlock: number;
|
|
44
45
|
events: {
|
|
45
|
-
updatedTokenConfigEvents:
|
|
46
|
-
updatedGlobalConfigEvents:
|
|
46
|
+
updatedTokenConfigEvents: Log[];
|
|
47
|
+
updatedGlobalConfigEvents: Log[];
|
|
47
48
|
globalConfigUpdateTimes: number[];
|
|
48
49
|
};
|
|
49
50
|
};
|
|
@@ -340,13 +341,8 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
340
341
|
paginatedEventQuery(this.configStore, this.configStore.filters.UpdatedGlobalConfig(), searchConfig),
|
|
341
342
|
]);
|
|
342
343
|
|
|
343
|
-
const updatedTokenConfigSortableEvents = updatedTokenConfigEvents.map(spreadEventWithBlockNumber);
|
|
344
|
-
const updatedGlobalConfigSortableEvents = updatedGlobalConfigEvents.map(spreadEventWithBlockNumber);
|
|
345
|
-
|
|
346
344
|
// Events *should* normally be received in ascending order, but explicitly enforce the ordering.
|
|
347
|
-
[
|
|
348
|
-
sortEventsAscendingInPlace(events)
|
|
349
|
-
);
|
|
345
|
+
[updatedTokenConfigEvents, updatedGlobalConfigEvents].forEach((events) => sortEventsAscendingInPlace(events));
|
|
350
346
|
|
|
351
347
|
const globalConfigUpdateTimes = (
|
|
352
348
|
await Promise.all(updatedGlobalConfigEvents.map((event) => this.configStore.provider.getBlock(event.blockNumber)))
|
|
@@ -357,8 +353,8 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
357
353
|
chainId,
|
|
358
354
|
searchEndBlock: searchConfig.toBlock,
|
|
359
355
|
events: {
|
|
360
|
-
updatedTokenConfigEvents
|
|
361
|
-
updatedGlobalConfigEvents
|
|
356
|
+
updatedTokenConfigEvents,
|
|
357
|
+
updatedGlobalConfigEvents,
|
|
362
358
|
globalConfigUpdateTimes,
|
|
363
359
|
},
|
|
364
360
|
};
|
|
@@ -384,11 +380,13 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
384
380
|
// Save new TokenConfig updates.
|
|
385
381
|
for (const event of updatedTokenConfigEvents) {
|
|
386
382
|
// If transaction hash is known to be invalid, skip it immediately to avoid creating extra logs.
|
|
387
|
-
if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event.
|
|
383
|
+
if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event.transactionHash.toLowerCase())) {
|
|
388
384
|
continue;
|
|
389
385
|
}
|
|
390
386
|
|
|
391
|
-
const args =
|
|
387
|
+
const args = {
|
|
388
|
+
...(spreadEventWithBlockNumber(event) as TokenConfig),
|
|
389
|
+
};
|
|
392
390
|
|
|
393
391
|
try {
|
|
394
392
|
const { rateModel, routeRateModel, spokeTargetBalances } = this.validateTokenConfigUpdate(args);
|
|
@@ -420,7 +418,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
420
418
|
this.logger.debug({
|
|
421
419
|
at: "ConfigStoreClient::update",
|
|
422
420
|
message: `Skipping invalid historical update at block ${event.blockNumber}`,
|
|
423
|
-
|
|
421
|
+
transactionHash: event.transactionHash,
|
|
424
422
|
});
|
|
425
423
|
}
|
|
426
424
|
continue;
|
|
@@ -429,7 +427,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
429
427
|
|
|
430
428
|
// Save new Global config updates.
|
|
431
429
|
for (let i = 0; i < updatedGlobalConfigEvents.length; i++) {
|
|
432
|
-
const args = updatedGlobalConfigEvents[i] as SortableEvent & {
|
|
430
|
+
const args = spreadEventWithBlockNumber(updatedGlobalConfigEvents[i]) as SortableEvent & {
|
|
433
431
|
key: string;
|
|
434
432
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
435
433
|
value: any;
|
|
@@ -564,7 +562,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
564
562
|
rateModel: string | undefined;
|
|
565
563
|
routeRateModel: RouteRateModelUpdate["routeRateModel"];
|
|
566
564
|
} {
|
|
567
|
-
const { value, key,
|
|
565
|
+
const { value, key, transactionHash } = args;
|
|
568
566
|
const parsedValue = parseJSONWithNumericString(value) as ParsedTokenConfig;
|
|
569
567
|
const l1Token = key;
|
|
570
568
|
|
|
@@ -580,7 +578,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
580
578
|
const rateModel = parsedValue.rateModel;
|
|
581
579
|
assert(
|
|
582
580
|
this.isValidRateModel(rateModel),
|
|
583
|
-
`Invalid rateModel UBar for ${l1Token} at transaction ${
|
|
581
|
+
`Invalid rateModel UBar for ${l1Token} at transaction ${transactionHash}, ${JSON.stringify(rateModel)}`
|
|
584
582
|
);
|
|
585
583
|
rateModelForToken = JSON.stringify(rateModel);
|
|
586
584
|
|
|
@@ -603,7 +601,7 @@ export class AcrossConfigStoreClient extends BaseAbstractClient {
|
|
|
603
601
|
Object.entries(parsedValue.routeRateModel).map(([path, routeRateModel]) => {
|
|
604
602
|
assert(
|
|
605
603
|
this.isValidRateModel(routeRateModel) &&
|
|
606
|
-
`Invalid routeRateModel UBar for ${path} for ${l1Token} at transaction ${
|
|
604
|
+
`Invalid routeRateModel UBar for ${path} for ${l1Token} at transaction ${transactionHash}, ${JSON.stringify(
|
|
607
605
|
routeRateModel
|
|
608
606
|
)}`
|
|
609
607
|
);
|
|
@@ -237,115 +237,13 @@ export class BundleDataClient {
|
|
|
237
237
|
{} as Record<number, Record<string, UnderlyingType>>
|
|
238
238
|
);
|
|
239
239
|
|
|
240
|
-
const convertSortableEventFieldsIntoRequiredFields = <
|
|
241
|
-
T extends {
|
|
242
|
-
txnIndex?: number;
|
|
243
|
-
transactionIndex?: number;
|
|
244
|
-
txnRef?: string;
|
|
245
|
-
transactionHash?: string;
|
|
246
|
-
},
|
|
247
|
-
>(
|
|
248
|
-
data: T[]
|
|
249
|
-
): Array<
|
|
250
|
-
Omit<T, "txnIndex" | "transactionIndex" | "txnRef" | "transactionHash"> & {
|
|
251
|
-
txnIndex: number;
|
|
252
|
-
txnRef: string;
|
|
253
|
-
}
|
|
254
|
-
> => {
|
|
255
|
-
return data.map((item) => {
|
|
256
|
-
// For txnIndex/transactionIndex: throw if both are defined or both are missing.
|
|
257
|
-
if (
|
|
258
|
-
(item.txnIndex !== undefined && item.transactionIndex !== undefined) ||
|
|
259
|
-
(item.txnIndex === undefined && item.transactionIndex === undefined)
|
|
260
|
-
) {
|
|
261
|
-
throw new Error("Either txnIndex or transactionIndex must be defined, but not both.");
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// For txnRef/transactionHash: throw if both are defined or both are missing.
|
|
265
|
-
if (
|
|
266
|
-
(item.txnRef !== undefined && item.transactionHash !== undefined) ||
|
|
267
|
-
(item.txnRef === undefined && item.transactionHash === undefined)
|
|
268
|
-
) {
|
|
269
|
-
throw new Error("Either txnRef or transactionHash must be defined, but not both.");
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
// Destructure the fields we don't need anymore
|
|
273
|
-
const { txnIndex, transactionIndex, txnRef, transactionHash, ...rest } = item;
|
|
274
|
-
|
|
275
|
-
// Return a new object with normalized fields.
|
|
276
|
-
// The non-null assertion (!) is safe here because our conditions ensure that one of each pair is defined.
|
|
277
|
-
return {
|
|
278
|
-
...rest,
|
|
279
|
-
txnIndex: txnIndex ?? transactionIndex!,
|
|
280
|
-
txnRef: txnRef ?? transactionHash!,
|
|
281
|
-
};
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
const convertEmbeddedSortableEventFieldsIntoRequiredFields = <
|
|
286
|
-
T extends {
|
|
287
|
-
txnIndex?: number;
|
|
288
|
-
transactionIndex?: number;
|
|
289
|
-
txnRef?: string;
|
|
290
|
-
transactionHash?: string;
|
|
291
|
-
},
|
|
292
|
-
>(
|
|
293
|
-
data: Record<string, Record<string, T[]>>
|
|
294
|
-
) => {
|
|
295
|
-
return Object.fromEntries(
|
|
296
|
-
Object.entries(data).map(([chainId, tokenData]) => [
|
|
297
|
-
chainId,
|
|
298
|
-
Object.fromEntries(
|
|
299
|
-
Object.entries(tokenData).map(([token, data]) => [
|
|
300
|
-
token,
|
|
301
|
-
convertSortableEventFieldsIntoRequiredFields(data),
|
|
302
|
-
])
|
|
303
|
-
),
|
|
304
|
-
])
|
|
305
|
-
);
|
|
306
|
-
};
|
|
307
|
-
|
|
308
240
|
const data = persistedData[0].data;
|
|
309
|
-
|
|
310
|
-
// This section processes and transforms bundle data loaded from Arweave storage into the correct format:
|
|
311
|
-
// 1. Each field (bundleFillsV3, expiredDepositsToRefundV3, etc.) contains nested records keyed by chainId and token
|
|
312
|
-
// 2. The chainId keys are converted from strings to numbers using convertTypedStringRecordIntoNumericRecord
|
|
313
|
-
// 3. For arrays of events (fills, deposits, etc.), the transaction fields are normalized:
|
|
314
|
-
// - txnIndex/transactionIndex -> txnIndex
|
|
315
|
-
// - txnRef/transactionHash -> txnRef
|
|
316
|
-
// This ensures consistent field names across all event objects
|
|
317
|
-
// 4. The data structure maintains all other fields like refunds, totalRefundAmount, and realizedLpFees
|
|
318
241
|
const bundleData = {
|
|
319
|
-
bundleFillsV3: convertTypedStringRecordIntoNumericRecord(
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
Object.entries(tokenData).map(([token, data]) => [
|
|
325
|
-
token,
|
|
326
|
-
{
|
|
327
|
-
refunds: data.refunds,
|
|
328
|
-
totalRefundAmount: data.totalRefundAmount,
|
|
329
|
-
realizedLpFees: data.realizedLpFees,
|
|
330
|
-
fills: convertSortableEventFieldsIntoRequiredFields(data.fills),
|
|
331
|
-
},
|
|
332
|
-
])
|
|
333
|
-
),
|
|
334
|
-
])
|
|
335
|
-
)
|
|
336
|
-
),
|
|
337
|
-
expiredDepositsToRefundV3: convertTypedStringRecordIntoNumericRecord(
|
|
338
|
-
convertEmbeddedSortableEventFieldsIntoRequiredFields(data.expiredDepositsToRefundV3)
|
|
339
|
-
),
|
|
340
|
-
bundleDepositsV3: convertTypedStringRecordIntoNumericRecord(
|
|
341
|
-
convertEmbeddedSortableEventFieldsIntoRequiredFields(data.bundleDepositsV3)
|
|
342
|
-
),
|
|
343
|
-
unexecutableSlowFills: convertTypedStringRecordIntoNumericRecord(
|
|
344
|
-
convertEmbeddedSortableEventFieldsIntoRequiredFields(data.unexecutableSlowFills)
|
|
345
|
-
),
|
|
346
|
-
bundleSlowFillsV3: convertTypedStringRecordIntoNumericRecord(
|
|
347
|
-
convertEmbeddedSortableEventFieldsIntoRequiredFields(data.bundleSlowFillsV3)
|
|
348
|
-
),
|
|
242
|
+
bundleFillsV3: convertTypedStringRecordIntoNumericRecord(data.bundleFillsV3),
|
|
243
|
+
expiredDepositsToRefundV3: convertTypedStringRecordIntoNumericRecord(data.expiredDepositsToRefundV3),
|
|
244
|
+
bundleDepositsV3: convertTypedStringRecordIntoNumericRecord(data.bundleDepositsV3),
|
|
245
|
+
unexecutableSlowFills: convertTypedStringRecordIntoNumericRecord(data.unexecutableSlowFills),
|
|
246
|
+
bundleSlowFillsV3: convertTypedStringRecordIntoNumericRecord(data.bundleSlowFillsV3),
|
|
349
247
|
};
|
|
350
248
|
this.logger.debug({
|
|
351
249
|
at: "BundleDataClient#loadPersistedDataFromArweave",
|
|
@@ -87,7 +87,9 @@ export async function verifyFillRepayment(
|
|
|
87
87
|
if (_repaymentAddressNeedsToBeOverwritten(fill)) {
|
|
88
88
|
// TODO: Handle case where fill was sent on non-EVM chain, in which case the following call would fail
|
|
89
89
|
// or return something unexpected. We'd want to return undefined here.
|
|
90
|
-
|
|
90
|
+
|
|
91
|
+
// @todo: If chainIsEvm:
|
|
92
|
+
const fillTransaction = await destinationChainProvider.getTransaction(fill.transactionHash);
|
|
91
93
|
const destinationRelayer = fillTransaction?.from;
|
|
92
94
|
// Repayment chain is still an EVM chain, but the msg.sender is a bytes32 address, so the fill is invalid.
|
|
93
95
|
if (!isDefined(destinationRelayer) || !isValidEvmAddress(destinationRelayer)) {
|
|
@@ -48,15 +48,11 @@ const V3RelayDataSS = {
|
|
|
48
48
|
message: string(),
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
const SortableEventSS = {
|
|
52
52
|
blockNumber: number(),
|
|
53
|
+
transactionIndex: number(),
|
|
53
54
|
logIndex: number(),
|
|
54
|
-
|
|
55
|
-
txnRef: optional(string()),
|
|
56
|
-
txnIndex: optional(number()),
|
|
57
|
-
|
|
58
|
-
transactionHash: optional(string()),
|
|
59
|
-
transactionIndex: optional(number()),
|
|
55
|
+
transactionHash: string(),
|
|
60
56
|
};
|
|
61
57
|
|
|
62
58
|
const V3DepositSS = {
|
|
@@ -884,13 +884,11 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
884
884
|
if (eventsToQuery.includes("CrossChainContractsSet")) {
|
|
885
885
|
for (const event of events["CrossChainContractsSet"]) {
|
|
886
886
|
const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet;
|
|
887
|
-
const dataToAdd
|
|
887
|
+
const dataToAdd = {
|
|
888
888
|
spokePool: args.spokePool,
|
|
889
889
|
blockNumber: args.blockNumber,
|
|
890
|
-
|
|
890
|
+
transactionIndex: args.transactionIndex,
|
|
891
891
|
logIndex: args.logIndex,
|
|
892
|
-
txnIndex: args.txnIndex,
|
|
893
|
-
l2ChainId: args.l2ChainId,
|
|
894
892
|
};
|
|
895
893
|
// If the chain is SVM then our `args.spokePool` will be set to the `solanaSpokePool.toAddressUnchecked()` in the
|
|
896
894
|
// hubpool event because our hub deals with `address` types and not byte32. Therefore, we should confirm that the
|
|
@@ -948,9 +946,9 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
948
946
|
l1Token: args.l1Token,
|
|
949
947
|
l2Token: destinationToken,
|
|
950
948
|
blockNumber: args.blockNumber,
|
|
951
|
-
|
|
949
|
+
transactionIndex: args.transactionIndex,
|
|
952
950
|
logIndex: args.logIndex,
|
|
953
|
-
|
|
951
|
+
transactionHash: args.transactionHash,
|
|
954
952
|
},
|
|
955
953
|
]
|
|
956
954
|
);
|
|
@@ -996,7 +994,12 @@ export class HubPoolClient extends BaseAbstractClient {
|
|
|
996
994
|
this.proposedRootBundles.push(
|
|
997
995
|
...events["ProposeRootBundle"]
|
|
998
996
|
.filter((event) => !this.configOverride.ignoredHubProposedBundles.includes(event.blockNumber))
|
|
999
|
-
.map((event) =>
|
|
997
|
+
.map((event) => {
|
|
998
|
+
return {
|
|
999
|
+
...spreadEventWithBlockNumber(event),
|
|
1000
|
+
transactionHash: event.transactionHash,
|
|
1001
|
+
} as ProposedRootBundle;
|
|
1002
|
+
})
|
|
1000
1003
|
);
|
|
1001
1004
|
}
|
|
1002
1005
|
|
|
@@ -19,7 +19,6 @@ import {
|
|
|
19
19
|
} from "../../utils";
|
|
20
20
|
import {
|
|
21
21
|
EventSearchConfig,
|
|
22
|
-
logToSortableEvent,
|
|
23
22
|
paginatedEventQuery,
|
|
24
23
|
sortEventsAscendingInPlace,
|
|
25
24
|
spreadEventWithBlockNumber,
|
|
@@ -128,7 +127,7 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
128
127
|
}
|
|
129
128
|
|
|
130
129
|
// Sort all events to ensure they are stored in a consistent order.
|
|
131
|
-
events.forEach((events) => sortEventsAscendingInPlace(events
|
|
130
|
+
events.forEach((events) => sortEventsAscendingInPlace(events));
|
|
132
131
|
|
|
133
132
|
return {
|
|
134
133
|
success: true,
|
|
@@ -401,7 +401,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
401
401
|
|
|
402
402
|
// Log any invalid deposits with same deposit id but different params.
|
|
403
403
|
const invalidFillsForDeposit = invalidFills.filter((x) => {
|
|
404
|
-
const txnUid = `${x.
|
|
404
|
+
const txnUid = `${x.transactionHash}:${x.logIndex}`;
|
|
405
405
|
// if txnUid doesn't exist in the invalidFills set, add it now, but log the corresponding fill.
|
|
406
406
|
const newInvalidFill = x.depositId.eq(deposit.depositId) && !this.invalidFills.has(txnUid);
|
|
407
407
|
if (newInvalidFill) {
|
|
@@ -2,14 +2,7 @@ import assert from "assert";
|
|
|
2
2
|
import winston from "winston";
|
|
3
3
|
import { Contract, ethers } from "ethers";
|
|
4
4
|
import { Log } from "../../interfaces";
|
|
5
|
-
import {
|
|
6
|
-
getCurrentTime,
|
|
7
|
-
EventSearchConfig,
|
|
8
|
-
MakeOptional,
|
|
9
|
-
isDefined,
|
|
10
|
-
utf8ToHex,
|
|
11
|
-
spreadEventWithBlockNumber,
|
|
12
|
-
} from "../../utils";
|
|
5
|
+
import { getCurrentTime, EventSearchConfig, MakeOptional, isDefined, utf8ToHex } from "../../utils";
|
|
13
6
|
import {
|
|
14
7
|
AcrossConfigStoreClient,
|
|
15
8
|
ConfigStoreUpdate,
|
|
@@ -99,9 +92,9 @@ export class MockConfigStoreClient extends AcrossConfigStoreClient {
|
|
|
99
92
|
chainId: this.chainId as number,
|
|
100
93
|
searchEndBlock: this.eventSearchConfig.toBlock || latestBlockSearched,
|
|
101
94
|
events: {
|
|
102
|
-
updatedGlobalConfigEvents: events["UpdatedGlobalConfig"]
|
|
95
|
+
updatedGlobalConfigEvents: events["UpdatedGlobalConfig"],
|
|
103
96
|
globalConfigUpdateTimes,
|
|
104
|
-
updatedTokenConfigEvents: events["UpdatedTokenConfig"]
|
|
97
|
+
updatedTokenConfigEvents: events["UpdatedTokenConfig"],
|
|
105
98
|
},
|
|
106
99
|
});
|
|
107
100
|
}
|
|
@@ -23,8 +23,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
23
23
|
private realizedLpFeePctOverride = false;
|
|
24
24
|
|
|
25
25
|
private l1TokensMock: L1Token[] = []; // L1Tokens and their associated info.
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
|
|
28
27
|
private spokePoolTokens: { [l1Token: string]: { [chainId: number]: string } } = {};
|
|
29
28
|
|
|
30
29
|
private eventManager: EventManager;
|
|
@@ -91,10 +90,6 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
91
90
|
return this.l1TokensMock;
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
getTokenInfoForAddress() {
|
|
95
|
-
return this.tokenInfoToReturn;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
93
|
setTokenMapping(l1Token: string, chainId: number, l2Token: string) {
|
|
99
94
|
this.spokePoolTokens[l1Token] ??= {};
|
|
100
95
|
this.spokePoolTokens[l1Token][chainId] = l2Token;
|
|
@@ -136,10 +131,6 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
136
131
|
return this.l1TokensMock.find((token) => token.address === l1Token);
|
|
137
132
|
}
|
|
138
133
|
|
|
139
|
-
setTokenInfoToReturn(tokenInfo: L1Token) {
|
|
140
|
-
this.tokenInfoToReturn = tokenInfo;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
134
|
_update(eventNames: string[]): Promise<HubPoolUpdate> {
|
|
144
135
|
// Generate new "on chain" responses.
|
|
145
136
|
const latestBlockSearched = this.eventManager.blockNumber;
|
|
@@ -129,7 +129,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
protected _deposit(event: string, deposit: Omit<Deposit, "messageHash"> & Partial<SortableEvent>): Log {
|
|
132
|
-
const { blockNumber,
|
|
132
|
+
const { blockNumber, transactionIndex } = deposit;
|
|
133
133
|
let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
|
|
134
134
|
depositId ??= this.numberOfDeposits;
|
|
135
135
|
this.numberOfDeposits = depositId.add(bnOne);
|
|
@@ -171,7 +171,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
171
171
|
topics: topics.map((topic) => topic.toString()),
|
|
172
172
|
args,
|
|
173
173
|
blockNumber,
|
|
174
|
-
transactionIndex
|
|
174
|
+
transactionIndex,
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
|
|
@@ -187,7 +187,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
187
187
|
event: string,
|
|
188
188
|
fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>
|
|
189
189
|
): Log {
|
|
190
|
-
const { blockNumber,
|
|
190
|
+
const { blockNumber, transactionIndex } = fill;
|
|
191
191
|
let { originChainId, depositId, inputAmount, outputAmount, fillDeadline } = fill;
|
|
192
192
|
originChainId ??= random(1, 42161, false);
|
|
193
193
|
depositId ??= BigNumber.from(random(1, 100_000, false));
|
|
@@ -260,7 +260,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
260
260
|
topics: topics.map((topic) => topic.toString()),
|
|
261
261
|
args,
|
|
262
262
|
blockNumber,
|
|
263
|
-
transactionIndex
|
|
263
|
+
transactionIndex,
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
266
|
|
|
@@ -335,7 +335,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
335
335
|
exclusiveRelayer: addressModifier(args.exclusiveRelayer ?? ZERO_ADDRESS),
|
|
336
336
|
},
|
|
337
337
|
blockNumber: request.blockNumber,
|
|
338
|
-
transactionIndex: request.
|
|
338
|
+
transactionIndex: request.transactionIndex,
|
|
339
339
|
});
|
|
340
340
|
}
|
|
341
341
|
|
package/src/interfaces/Common.ts
CHANGED
package/src/utils/EventUtils.ts
CHANGED
|
@@ -204,19 +204,13 @@ export function getPaginatedBlockRanges({
|
|
|
204
204
|
return ranges;
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
-
export function logToSortableEvent(log: Log): SortableEvent {
|
|
208
|
-
return {
|
|
209
|
-
txnIndex: log.transactionIndex,
|
|
210
|
-
txnRef: log.transactionHash,
|
|
211
|
-
logIndex: log.logIndex,
|
|
212
|
-
blockNumber: log.blockNumber,
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
207
|
export function spreadEventWithBlockNumber(event: Log): SortableEvent {
|
|
217
208
|
return {
|
|
218
209
|
...spreadEvent(event.args),
|
|
219
|
-
|
|
210
|
+
blockNumber: event.blockNumber,
|
|
211
|
+
transactionIndex: event.transactionIndex,
|
|
212
|
+
logIndex: event.logIndex,
|
|
213
|
+
transactionHash: event.transactionHash,
|
|
220
214
|
};
|
|
221
215
|
}
|
|
222
216
|
|
|
@@ -232,8 +226,8 @@ export function sortEventsAscendingInPlace<T extends SortableEvent>(events: T[])
|
|
|
232
226
|
if (ex.blockNumber !== ey.blockNumber) {
|
|
233
227
|
return ex.blockNumber - ey.blockNumber;
|
|
234
228
|
}
|
|
235
|
-
if (ex.
|
|
236
|
-
return ex.
|
|
229
|
+
if (ex.transactionIndex !== ey.transactionIndex) {
|
|
230
|
+
return ex.transactionIndex - ey.transactionIndex;
|
|
237
231
|
}
|
|
238
232
|
return ex.logIndex - ey.logIndex;
|
|
239
233
|
});
|
|
@@ -251,8 +245,8 @@ export function sortEventsDescendingInPlace<T extends SortableEvent>(events: T[]
|
|
|
251
245
|
if (ex.blockNumber !== ey.blockNumber) {
|
|
252
246
|
return ey.blockNumber - ex.blockNumber;
|
|
253
247
|
}
|
|
254
|
-
if (ex.
|
|
255
|
-
return ey.
|
|
248
|
+
if (ex.transactionIndex !== ey.transactionIndex) {
|
|
249
|
+
return ey.transactionIndex - ex.transactionIndex;
|
|
256
250
|
}
|
|
257
251
|
return ey.logIndex - ex.logIndex;
|
|
258
252
|
});
|
|
@@ -263,16 +257,16 @@ export function isEventOlder<T extends SortableEvent>(ex: T, ey: T): boolean {
|
|
|
263
257
|
if (ex.blockNumber !== ey.blockNumber) {
|
|
264
258
|
return ex.blockNumber < ey.blockNumber;
|
|
265
259
|
}
|
|
266
|
-
if (ex.
|
|
267
|
-
return ex.
|
|
260
|
+
if (ex.transactionIndex !== ey.transactionIndex) {
|
|
261
|
+
return ex.transactionIndex < ey.transactionIndex;
|
|
268
262
|
}
|
|
269
263
|
return ex.logIndex < ey.logIndex;
|
|
270
264
|
}
|
|
271
265
|
|
|
272
|
-
export function
|
|
273
|
-
return [...Array.from(new Set(events.map((e) => e.
|
|
266
|
+
export function getTransactionHashes(events: SortableEvent[]): string[] {
|
|
267
|
+
return [...Array.from(new Set(events.map((e) => e.transactionHash)))];
|
|
274
268
|
}
|
|
275
269
|
|
|
276
270
|
export function duplicateEvent(a: SortableEvent, b: SortableEvent): boolean {
|
|
277
|
-
return a.
|
|
271
|
+
return a.transactionHash === b.transactionHash && a.logIndex === b.logIndex;
|
|
278
272
|
}
|