@across-protocol/sdk 4.1.45 → 4.1.46-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) 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.d.ts +0 -3
  12. package/dist/cjs/clients/HubPoolClient.js +38 -27
  13. package/dist/cjs/clients/HubPoolClient.js.map +1 -1
  14. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
  15. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  16. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +1 -1
  17. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  18. package/dist/cjs/clients/mocks/MockConfigStoreClient.js +2 -2
  19. package/dist/cjs/clients/mocks/MockConfigStoreClient.js.map +1 -1
  20. package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +2 -1
  21. package/dist/cjs/clients/mocks/MockHubPoolClient.js +18 -1
  22. package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
  23. package/dist/cjs/clients/mocks/MockSpokePoolClient.js +5 -5
  24. package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
  25. package/dist/cjs/interfaces/Common.d.ts +2 -2
  26. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +0 -1
  27. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +0 -5
  28. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  29. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +0 -1
  30. package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  31. package/dist/cjs/utils/AddressUtils.d.ts +1 -0
  32. package/dist/cjs/utils/AddressUtils.js +3 -0
  33. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  34. package/dist/cjs/utils/EventUtils.d.ts +2 -1
  35. package/dist/cjs/utils/EventUtils.js +21 -12
  36. package/dist/cjs/utils/EventUtils.js.map +1 -1
  37. package/dist/cjs/utils/TokenUtils.js +2 -0
  38. package/dist/cjs/utils/TokenUtils.js.map +1 -1
  39. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  40. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +15 -11
  41. package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
  42. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +58 -7
  43. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  44. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +1 -1
  45. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  46. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +48 -20
  47. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +5 -3
  48. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
  49. package/dist/esm/clients/HubPoolClient.d.ts +0 -10
  50. package/dist/esm/clients/HubPoolClient.js +46 -36
  51. package/dist/esm/clients/HubPoolClient.js.map +1 -1
  52. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
  53. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  54. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +1 -1
  55. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  56. package/dist/esm/clients/mocks/MockConfigStoreClient.js +3 -3
  57. package/dist/esm/clients/mocks/MockConfigStoreClient.js.map +1 -1
  58. package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +2 -1
  59. package/dist/esm/clients/mocks/MockHubPoolClient.js +18 -1
  60. package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
  61. package/dist/esm/clients/mocks/MockSpokePoolClient.js +5 -5
  62. package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
  63. package/dist/esm/interfaces/Common.d.ts +2 -2
  64. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +0 -6
  65. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +0 -10
  66. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  67. package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +0 -1
  68. package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
  69. package/dist/esm/utils/AddressUtils.d.ts +1 -0
  70. package/dist/esm/utils/AddressUtils.js +3 -0
  71. package/dist/esm/utils/AddressUtils.js.map +1 -1
  72. package/dist/esm/utils/EventUtils.d.ts +2 -1
  73. package/dist/esm/utils/EventUtils.js +18 -10
  74. package/dist/esm/utils/EventUtils.js.map +1 -1
  75. package/dist/esm/utils/TokenUtils.js +2 -0
  76. package/dist/esm/utils/TokenUtils.js.map +1 -1
  77. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
  78. package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
  79. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  80. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  81. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +48 -20
  82. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
  83. package/dist/types/clients/HubPoolClient.d.ts +0 -10
  84. package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
  85. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  86. package/dist/types/clients/mocks/MockConfigStoreClient.d.ts.map +1 -1
  87. package/dist/types/clients/mocks/MockHubPoolClient.d.ts +2 -1
  88. package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
  89. package/dist/types/interfaces/Common.d.ts +2 -2
  90. package/dist/types/interfaces/Common.d.ts.map +1 -1
  91. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +0 -6
  92. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  93. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +0 -1
  94. package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
  95. package/dist/types/utils/AddressUtils.d.ts +1 -0
  96. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  97. package/dist/types/utils/EventUtils.d.ts +2 -1
  98. package/dist/types/utils/EventUtils.d.ts.map +1 -1
  99. package/dist/types/utils/TokenUtils.d.ts.map +1 -1
  100. package/package.json +1 -1
  101. package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +17 -15
  102. package/src/clients/BundleDataClient/BundleDataClient.ts +107 -5
  103. package/src/clients/BundleDataClient/utils/FillUtils.ts +1 -3
  104. package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +7 -3
  105. package/src/clients/HubPoolClient.ts +56 -47
  106. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +2 -1
  107. package/src/clients/SpokePoolClient/SpokePoolClient.ts +1 -1
  108. package/src/clients/mocks/MockConfigStoreClient.ts +10 -3
  109. package/src/clients/mocks/MockHubPoolClient.ts +26 -2
  110. package/src/clients/mocks/MockSpokePoolClient.ts +5 -5
  111. package/src/interfaces/Common.ts +2 -2
  112. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +0 -10
  113. package/src/relayFeeCalculator/relayFeeCalculator.ts +0 -1
  114. package/src/utils/AddressUtils.ts +4 -0
  115. package/src/utils/EventUtils.ts +19 -13
  116. package/src/utils/TokenUtils.ts +2 -0
@@ -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
  }
@@ -147,6 +147,8 @@ export function getUsdcSymbol(l2Token: string, chainId: number): string | undefi
147
147
  }
148
148
 
149
149
  export function getL1TokenInfo(l2TokenAddress: string, chainId: number): L1Token {
150
+ if (chainId === CHAIN_IDs.MAINNET)
151
+ throw new Error("chainId should be an L2 chainId because many mappings re-use the same L1 token address");
150
152
  const tokenObject = Object.values(TOKEN_SYMBOLS_MAP).find(({ addresses }) => addresses[chainId] === l2TokenAddress);
151
153
  const l1TokenAddress = tokenObject?.addresses[CHAIN_IDs.MAINNET];
152
154
  if (!l1TokenAddress) {