@across-protocol/sdk 4.1.46 → 4.1.47-beta.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.
Files changed (73) hide show
  1. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  2. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +15 -11
  3. package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  4. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +52 -6
  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 +48 -20
  9. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +8 -6
  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/MockSpokePoolClient.js +5 -5
  20. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  21. package/dist/cjs/interfaces/Common.d.ts +2 -2
  22. package/dist/cjs/utils/EventUtils.d.ts +2 -1
  23. package/dist/cjs/utils/EventUtils.js +21 -12
  24. package/dist/cjs/utils/EventUtils.js.map +1 -1
  25. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  26. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +15 -11
  27. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  28. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +58 -7
  29. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  30. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +1 -1
  31. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  32. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +48 -20
  33. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +5 -3
  34. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  35. package/dist/esm/clients/HubPoolClient.js +6 -6
  36. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  37. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  38. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  39. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +1 -1
  40. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  41. package/dist/esm/clients/mocks/MockConfigStoreClient.js +3 -3
  42. package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
  43. package/dist/esm/clients/mocks/MockSpokePoolClient.js +5 -5
  44. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  45. package/dist/esm/interfaces/Common.d.ts +2 -2
  46. package/dist/esm/utils/EventUtils.d.ts +2 -1
  47. package/dist/esm/utils/EventUtils.js +18 -10
  48. package/dist/esm/utils/EventUtils.js.map +1 -1
  49. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  50. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  51. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  52. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  53. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +48 -20
  54. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  55. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  56. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  57. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
  58. package/dist/types/interfaces/Common.d.ts +2 -2
  59. package/dist/types/interfaces/Common.d.ts.map +1 -1
  60. package/dist/types/utils/EventUtils.d.ts +2 -1
  61. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +17 -15
  64. package/src/clients/BundleDataClient/BundleDataClient.ts +107 -5
  65. package/src/clients/BundleDataClient/utils/FillUtils.ts +1 -3
  66. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +7 -3
  67. package/src/clients/HubPoolClient.ts +7 -10
  68. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +2 -1
  69. package/src/clients/SpokePoolClient/SpokePoolClient.ts +1 -1
  70. package/src/clients/mocks/MockConfigStoreClient.ts +10 -3
  71. package/src/clients/mocks/MockSpokePoolClient.ts +5 -5
  72. package/src/interfaces/Common.ts +2 -2
  73. package/src/utils/EventUtils.ts +19 -13
@@ -907,11 +907,13 @@ export class HubPoolClient extends BaseAbstractClient {
907
907
  if (eventsToQuery.includes("CrossChainContractsSet")) {
908
908
  for (const event of events["CrossChainContractsSet"]) {
909
909
  const args = spreadEventWithBlockNumber(event) as CrossChainContractsSet;
910
- const dataToAdd = {
910
+ const dataToAdd: CrossChainContractsSet = {
911
911
  spokePool: args.spokePool,
912
912
  blockNumber: args.blockNumber,
913
- transactionIndex: args.transactionIndex,
913
+ txnRef: args.txnRef,
914
914
  logIndex: args.logIndex,
915
+ txnIndex: args.txnIndex,
916
+ l2ChainId: args.l2ChainId,
915
917
  };
916
918
  // If the chain is SVM then our `args.spokePool` will be set to the `solanaSpokePool.toAddressUnchecked()` in the
917
919
  // hubpool event because our hub deals with `address` types and not byte32. Therefore, we should confirm that the
@@ -969,9 +971,9 @@ export class HubPoolClient extends BaseAbstractClient {
969
971
  l1Token: args.l1Token,
970
972
  l2Token: destinationToken,
971
973
  blockNumber: args.blockNumber,
972
- transactionIndex: args.transactionIndex,
974
+ txnIndex: args.txnIndex,
973
975
  logIndex: args.logIndex,
974
- transactionHash: args.transactionHash,
976
+ txnRef: args.txnRef,
975
977
  },
976
978
  ]
977
979
  );
@@ -1017,12 +1019,7 @@ export class HubPoolClient extends BaseAbstractClient {
1017
1019
  this.proposedRootBundles.push(
1018
1020
  ...events["ProposeRootBundle"]
1019
1021
  .filter((event) => !this.configOverride.ignoredHubProposedBundles.includes(event.blockNumber))
1020
- .map((event) => {
1021
- return {
1022
- ...spreadEventWithBlockNumber(event),
1023
- transactionHash: event.transactionHash,
1024
- } as ProposedRootBundle;
1025
- })
1022
+ .map((event) => spreadEventWithBlockNumber(event) as ProposedRootBundle)
1026
1023
  );
1027
1024
  }
1028
1025
 
@@ -19,6 +19,7 @@ import {
19
19
  } from "../../utils";
20
20
  import {
21
21
  EventSearchConfig,
22
+ logToSortableEvent,
22
23
  paginatedEventQuery,
23
24
  sortEventsAscendingInPlace,
24
25
  spreadEventWithBlockNumber,
@@ -127,7 +128,7 @@ export class EVMSpokePoolClient extends SpokePoolClient {
127
128
  }
128
129
 
129
130
  // Sort all events to ensure they are stored in a consistent order.
130
- events.forEach((events) => sortEventsAscendingInPlace(events));
131
+ events.forEach((events) => sortEventsAscendingInPlace(events.map(logToSortableEvent)));
131
132
 
132
133
  return {
133
134
  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.transactionHash}:${x.logIndex}`;
404
+ const txnUid = `${x.txnRef}:${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,7 +2,14 @@ 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 { getCurrentTime, EventSearchConfig, MakeOptional, isDefined, utf8ToHex } from "../../utils";
5
+ import {
6
+ getCurrentTime,
7
+ EventSearchConfig,
8
+ MakeOptional,
9
+ isDefined,
10
+ utf8ToHex,
11
+ spreadEventWithBlockNumber,
12
+ } from "../../utils";
6
13
  import {
7
14
  AcrossConfigStoreClient,
8
15
  ConfigStoreUpdate,
@@ -92,9 +99,9 @@ export class MockConfigStoreClient extends AcrossConfigStoreClient {
92
99
  chainId: this.chainId as number,
93
100
  searchEndBlock: this.eventSearchConfig.toBlock || latestBlockSearched,
94
101
  events: {
95
- updatedGlobalConfigEvents: events["UpdatedGlobalConfig"],
102
+ updatedGlobalConfigEvents: events["UpdatedGlobalConfig"].map(spreadEventWithBlockNumber),
96
103
  globalConfigUpdateTimes,
97
- updatedTokenConfigEvents: events["UpdatedTokenConfig"],
104
+ updatedTokenConfigEvents: events["UpdatedTokenConfig"].map(spreadEventWithBlockNumber),
98
105
  },
99
106
  });
100
107
  }
@@ -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, transactionIndex } = deposit;
132
+ const { blockNumber, txnIndex } = 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: txnIndex,
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, transactionIndex } = fill;
190
+ const { blockNumber, txnIndex } = 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: txnIndex,
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.transactionIndex,
338
+ transactionIndex: request.txnIndex,
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
- transactionIndex: number;
12
+ txnIndex: number;
13
13
  logIndex: number;
14
- transactionHash: string;
14
+ txnRef: string;
15
15
  }
16
16
 
17
17
  export interface BigNumberForToken {
@@ -204,13 +204,19 @@ 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
+
207
216
  export function spreadEventWithBlockNumber(event: Log): SortableEvent {
208
217
  return {
209
218
  ...spreadEvent(event.args),
210
- blockNumber: event.blockNumber,
211
- transactionIndex: event.transactionIndex,
212
- logIndex: event.logIndex,
213
- transactionHash: event.transactionHash,
219
+ ...logToSortableEvent(event),
214
220
  };
215
221
  }
216
222
 
@@ -226,8 +232,8 @@ export function sortEventsAscendingInPlace<T extends SortableEvent>(events: T[])
226
232
  if (ex.blockNumber !== ey.blockNumber) {
227
233
  return ex.blockNumber - ey.blockNumber;
228
234
  }
229
- if (ex.transactionIndex !== ey.transactionIndex) {
230
- return ex.transactionIndex - ey.transactionIndex;
235
+ if (ex.txnIndex !== ey.txnIndex) {
236
+ return ex.txnIndex - ey.txnIndex;
231
237
  }
232
238
  return ex.logIndex - ey.logIndex;
233
239
  });
@@ -245,8 +251,8 @@ export function sortEventsDescendingInPlace<T extends SortableEvent>(events: T[]
245
251
  if (ex.blockNumber !== ey.blockNumber) {
246
252
  return ey.blockNumber - ex.blockNumber;
247
253
  }
248
- if (ex.transactionIndex !== ey.transactionIndex) {
249
- return ey.transactionIndex - ex.transactionIndex;
254
+ if (ex.txnIndex !== ey.txnIndex) {
255
+ return ey.txnIndex - ex.txnIndex;
250
256
  }
251
257
  return ey.logIndex - ex.logIndex;
252
258
  });
@@ -257,16 +263,16 @@ export function isEventOlder<T extends SortableEvent>(ex: T, ey: T): boolean {
257
263
  if (ex.blockNumber !== ey.blockNumber) {
258
264
  return ex.blockNumber < ey.blockNumber;
259
265
  }
260
- if (ex.transactionIndex !== ey.transactionIndex) {
261
- return ex.transactionIndex < ey.transactionIndex;
266
+ if (ex.txnIndex !== ey.txnIndex) {
267
+ return ex.txnIndex < ey.txnIndex;
262
268
  }
263
269
  return ex.logIndex < ey.logIndex;
264
270
  }
265
271
 
266
- export function getTransactionHashes(events: SortableEvent[]): string[] {
267
- return [...Array.from(new Set(events.map((e) => e.transactionHash)))];
272
+ export function getTransactionRefs(events: SortableEvent[]): string[] {
273
+ return [...Array.from(new Set(events.map((e) => e.txnRef)))];
268
274
  }
269
275
 
270
276
  export function duplicateEvent(a: SortableEvent, b: SortableEvent): boolean {
271
- return a.transactionHash === b.transactionHash && a.logIndex === b.logIndex;
277
+ return a.txnRef === b.txnRef && a.logIndex === b.logIndex;
272
278
  }