@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.
Files changed (82) hide show
  1. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  2. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +11 -15
  3. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  4. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +6 -52
  5. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  6. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +1 -1
  7. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  8. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +20 -48
  9. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +6 -8
  10. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  11. package/dist/cjs/clients/HubPoolClient.js +6 -6
  12. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  13. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
  14. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  15. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +1 -1
  16. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  17. package/dist/cjs/clients/mocks/MockConfigStoreClient.js +2 -2
  18. package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
  19. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +0 -3
  20. package/dist/cjs/clients/mocks/MockHubPoolClient.js +0 -7
  21. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  22. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +5 -5
  23. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  24. package/dist/cjs/interfaces/Common.d.ts +2 -2
  25. package/dist/cjs/utils/EventUtils.d.ts +1 -2
  26. package/dist/cjs/utils/EventUtils.js +12 -21
  27. package/dist/cjs/utils/EventUtils.js.map +1 -1
  28. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  29. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +11 -15
  30. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  31. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +7 -58
  32. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  33. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +1 -1
  34. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  35. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +20 -48
  36. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +3 -5
  37. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  38. package/dist/esm/clients/HubPoolClient.js +6 -6
  39. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  40. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  41. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  42. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +1 -1
  43. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  44. package/dist/esm/clients/mocks/MockConfigStoreClient.js +3 -3
  45. package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
  46. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +0 -3
  47. package/dist/esm/clients/mocks/MockHubPoolClient.js +0 -7
  48. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  49. package/dist/esm/clients/mocks/MockSpokePoolClient.js +5 -5
  50. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  51. package/dist/esm/interfaces/Common.d.ts +2 -2
  52. package/dist/esm/utils/EventUtils.d.ts +1 -2
  53. package/dist/esm/utils/EventUtils.js +10 -18
  54. package/dist/esm/utils/EventUtils.js.map +1 -1
  55. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  56. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  57. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  58. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  59. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +20 -48
  60. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  61. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  62. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  63. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
  64. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +0 -3
  65. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  66. package/dist/types/interfaces/Common.d.ts +2 -2
  67. package/dist/types/interfaces/Common.d.ts.map +1 -1
  68. package/dist/types/utils/EventUtils.d.ts +1 -2
  69. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  70. package/package.json +1 -1
  71. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +15 -17
  72. package/src/clients/BundleDataClient/BundleDataClient.ts +5 -107
  73. package/src/clients/BundleDataClient/utils/FillUtils.ts +3 -1
  74. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +3 -7
  75. package/src/clients/HubPoolClient.ts +10 -7
  76. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +1 -2
  77. package/src/clients/SpokePoolClient/SpokePoolClient.ts +1 -1
  78. package/src/clients/mocks/MockConfigStoreClient.ts +3 -10
  79. package/src/clients/mocks/MockHubPoolClient.ts +1 -10
  80. package/src/clients/mocks/MockSpokePoolClient.ts +5 -5
  81. package/src/interfaces/Common.ts +2 -2
  82. 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: SortableEvent[];
46
- updatedGlobalConfigEvents: SortableEvent[];
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
- [updatedTokenConfigSortableEvents, updatedGlobalConfigSortableEvents].forEach((events) =>
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: updatedTokenConfigSortableEvents,
361
- updatedGlobalConfigEvents: updatedGlobalConfigSortableEvents,
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.txnRef.toLowerCase())) {
383
+ if (KNOWN_INVALID_TOKEN_CONFIG_UPDATE_HASHES.includes(event.transactionHash.toLowerCase())) {
388
384
  continue;
389
385
  }
390
386
 
391
- const args = event as TokenConfig;
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
- txnRef: event.txnRef,
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, txnRef } = args;
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 ${txnRef}, ${JSON.stringify(rateModel)}`
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 ${txnRef}, ${JSON.stringify(
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
- Object.fromEntries(
321
- Object.entries(data.bundleFillsV3).map(([chainId, tokenData]) => [
322
- chainId,
323
- Object.fromEntries(
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
- const fillTransaction = await destinationChainProvider.getTransaction(fill.txnRef);
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
- export const SortableEventSS = {
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: CrossChainContractsSet = {
887
+ const dataToAdd = {
888
888
  spokePool: args.spokePool,
889
889
  blockNumber: args.blockNumber,
890
- txnRef: args.txnRef,
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
- txnIndex: args.txnIndex,
949
+ transactionIndex: args.transactionIndex,
952
950
  logIndex: args.logIndex,
953
- txnRef: args.txnRef,
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) => spreadEventWithBlockNumber(event) as ProposedRootBundle)
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.map(logToSortableEvent)));
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.txnRef}:${x.logIndex}`;
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"].map(spreadEventWithBlockNumber),
95
+ updatedGlobalConfigEvents: events["UpdatedGlobalConfig"],
103
96
  globalConfigUpdateTimes,
104
- updatedTokenConfigEvents: events["UpdatedTokenConfig"].map(spreadEventWithBlockNumber),
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
- private tokenInfoToReturn: L1Token = { address: "", decimals: 0, symbol: "" };
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, txnIndex } = deposit;
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: txnIndex,
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, txnIndex } = fill;
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: txnIndex,
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.txnIndex,
338
+ transactionIndex: request.transactionIndex,
339
339
  });
340
340
  }
341
341
 
@@ -9,9 +9,9 @@ export type Log = _Log & {
9
9
 
10
10
  export interface SortableEvent {
11
11
  blockNumber: number;
12
- txnIndex: number;
12
+ transactionIndex: number;
13
13
  logIndex: number;
14
- txnRef: string;
14
+ transactionHash: string;
15
15
  }
16
16
 
17
17
  export interface BigNumberForToken {
@@ -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
- ...logToSortableEvent(event),
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.txnIndex !== ey.txnIndex) {
236
- return ex.txnIndex - ey.txnIndex;
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.txnIndex !== ey.txnIndex) {
255
- return ey.txnIndex - ex.txnIndex;
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.txnIndex !== ey.txnIndex) {
267
- return ex.txnIndex < ey.txnIndex;
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 getTransactionRefs(events: SortableEvent[]): string[] {
273
- return [...Array.from(new Set(events.map((e) => e.txnRef)))];
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.txnRef === b.txnRef && a.logIndex === b.logIndex;
271
+ return a.transactionHash === b.transactionHash && a.logIndex === b.logIndex;
278
272
  }