@across-protocol/sdk 4.1.41 → 4.1.43

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 (77) hide show
  1. package/dist/cjs/arch/evm/SpokeUtils.d.ts +15 -0
  2. package/dist/cjs/arch/evm/SpokeUtils.js +312 -0
  3. package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -0
  4. package/dist/cjs/arch/evm/index.d.ts +1 -1
  5. package/dist/cjs/arch/evm/index.js +2 -2
  6. package/dist/cjs/arch/evm/index.js.map +1 -1
  7. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +3 -2
  8. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  9. package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +8 -8
  10. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -2
  11. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +11 -8
  12. package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  13. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -1
  14. package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  15. package/dist/cjs/index.d.ts +1 -0
  16. package/dist/cjs/index.js +2 -1
  17. package/dist/cjs/index.js.map +1 -1
  18. package/dist/cjs/providers/types.d.ts +2 -2
  19. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +2 -1
  20. package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  21. package/dist/cjs/utils/DepositUtils.js +1 -1
  22. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  23. package/dist/cjs/utils/SpokeUtils.d.ts +2 -14
  24. package/dist/cjs/utils/SpokeUtils.js +8 -313
  25. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  26. package/dist/esm/arch/evm/SpokeUtils.d.ts +58 -0
  27. package/dist/esm/arch/evm/SpokeUtils.js +345 -0
  28. package/dist/esm/arch/evm/SpokeUtils.js.map +1 -0
  29. package/dist/esm/arch/evm/index.d.ts +1 -1
  30. package/dist/esm/arch/evm/index.js +1 -1
  31. package/dist/esm/arch/evm/index.js.map +1 -1
  32. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +3 -2
  33. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  34. package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +8 -8
  35. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -2
  36. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +7 -4
  37. package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
  38. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +9 -1
  39. package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
  40. package/dist/esm/index.d.ts +1 -0
  41. package/dist/esm/index.js +2 -0
  42. package/dist/esm/index.js.map +1 -1
  43. package/dist/esm/providers/types.d.ts +2 -2
  44. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +2 -1
  45. package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
  46. package/dist/esm/utils/DepositUtils.js +2 -1
  47. package/dist/esm/utils/DepositUtils.js.map +1 -1
  48. package/dist/esm/utils/SpokeUtils.d.ts +5 -55
  49. package/dist/esm/utils/SpokeUtils.js +11 -348
  50. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  51. package/dist/types/arch/evm/SpokeUtils.d.ts +59 -0
  52. package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -0
  53. package/dist/types/arch/evm/index.d.ts +1 -1
  54. package/dist/types/arch/evm/index.d.ts.map +1 -1
  55. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  56. package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +8 -8
  57. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts +3 -2
  58. package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
  59. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +9 -1
  60. package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
  61. package/dist/types/index.d.ts +1 -0
  62. package/dist/types/index.d.ts.map +1 -1
  63. package/dist/types/providers/types.d.ts +2 -2
  64. package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
  65. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  66. package/dist/types/utils/SpokeUtils.d.ts +5 -55
  67. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  68. package/package.json +2 -2
  69. package/src/arch/evm/SpokeUtils.ts +324 -0
  70. package/src/arch/evm/index.ts +1 -1
  71. package/src/clients/BundleDataClient/BundleDataClient.ts +2 -3
  72. package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +27 -16
  73. package/src/clients/SpokePoolClient/SpokePoolClient.ts +13 -5
  74. package/src/index.ts +1 -0
  75. package/src/relayFeeCalculator/chain-queries/baseQuery.ts +1 -1
  76. package/src/utils/DepositUtils.ts +2 -1
  77. package/src/utils/SpokeUtils.ts +16 -314
@@ -6,10 +6,10 @@ import { Coingecko } from "../../coingecko";
6
6
  import { CHAIN_IDs, DEFAULT_SIMULATED_RELAYER_ADDRESS } from "../../constants";
7
7
  import { Deposit } from "../../interfaces";
8
8
  import { SpokePool, SpokePool__factory } from "../../typechain";
9
+ import { populateV3Relay } from "../../arch/evm";
9
10
  import {
10
11
  BigNumberish,
11
12
  TransactionCostEstimate,
12
- populateV3Relay,
13
13
  BigNumber,
14
14
  toBNWei,
15
15
  bnZero,
@@ -2,10 +2,10 @@ import assert from "assert";
2
2
  import { SpokePoolClient } from "../clients";
3
3
  import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE, UNDEFINED_MESSAGE_HASH, ZERO_BYTES } from "../constants";
4
4
  import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, RelayData, SlowFillRequest } from "../interfaces";
5
+ import { getMessageHash, isUnsafeDepositId } from "./SpokeUtils";
5
6
  import { getNetworkName } from "./NetworkUtils";
6
7
  import { bnZero } from "./BigNumberUtils";
7
8
  import { getDepositInCache, getDepositKey, setDepositInCache } from "./CachingUtils";
8
- import { getMessageHash, isUnsafeDepositId } from "./SpokeUtils";
9
9
  import { getCurrentTime } from "./TimeUtils";
10
10
  import { isDefined } from "./TypeGuards";
11
11
  import { isDepositFormedCorrectly } from "./ValidatorUtils";
@@ -37,6 +37,7 @@ export type DepositSearchResult =
37
37
  * @throws If the fill's origin chain ID does not match the spoke pool client's chain ID.
38
38
  * @throws If the spoke pool client has not been updated.
39
39
  */
40
+ // @todo relocate
40
41
  export async function queryHistoricalDepositForFill(
41
42
  spokePoolClient: SpokePoolClient,
42
43
  fill: Fill | SlowFillRequest,
@@ -1,31 +1,18 @@
1
- import assert from "assert";
2
- import { BytesLike, Contract, PopulatedTransaction, providers, utils as ethersUtils } from "ethers";
3
- import { CHAIN_IDs, MAX_SAFE_DEPOSIT_ID, ZERO_ADDRESS, ZERO_BYTES } from "../constants";
4
- import { Deposit, FillStatus, FillWithBlock, RelayData } from "../interfaces";
5
- import { chunk } from "./ArrayUtils";
6
- import { bnUint32Max, BigNumber, toBN, bnZero } from "./BigNumberUtils";
1
+ import { utils as ethersUtils } from "ethers";
2
+ import { MAX_SAFE_DEPOSIT_ID, ZERO_ADDRESS, ZERO_BYTES } from "../constants";
3
+ import { Deposit, RelayData } from "../interfaces";
4
+ import { toBytes32 } from "./AddressUtils";
7
5
  import { keccak256 } from "./common";
6
+ import { BigNumber } from "./BigNumberUtils";
8
7
  import { isMessageEmpty } from "./DepositUtils";
9
- import { isDefined } from "./TypeGuards";
10
- import { getNetworkName } from "./NetworkUtils";
11
- import { paginatedEventQuery, spreadEventWithBlockNumber } from "./EventUtils";
12
- import { toBytes32 } from "./AddressUtils";
13
-
14
- type BlockTag = providers.BlockTag;
15
8
 
16
9
  /**
17
- * @param spokePool SpokePool Contract instance.
18
- * @param deposit V3Deopsit instance.
19
- * @param repaymentChainId Optional repaymentChainId (defaults to destinationChainId).
20
- * @returns An Ethers UnsignedTransaction instance.
10
+ * Produce the RelayData for a Deposit.
11
+ * @param deposit Deposit instance.
12
+ * @returns The corresponding RelayData object.
21
13
  */
22
- export function populateV3Relay(
23
- spokePool: Contract,
24
- deposit: Omit<Deposit, "messageHash">,
25
- relayer: string,
26
- repaymentChainId = deposit.destinationChainId
27
- ): Promise<PopulatedTransaction> {
28
- const v3RelayData: RelayData = {
14
+ export function getDepositRelayData(deposit: Omit<Deposit, "messageHash">): RelayData {
15
+ return {
29
16
  depositor: toBytes32(deposit.depositor),
30
17
  recipient: toBytes32(deposit.recipient),
31
18
  exclusiveRelayer: toBytes32(deposit.exclusiveRelayer),
@@ -39,77 +26,6 @@ export function populateV3Relay(
39
26
  exclusivityDeadline: deposit.exclusivityDeadline,
40
27
  message: deposit.message,
41
28
  };
42
- if (isDefined(deposit.speedUpSignature)) {
43
- assert(isDefined(deposit.updatedRecipient) && !isZeroAddress(deposit.updatedRecipient));
44
- assert(isDefined(deposit.updatedOutputAmount));
45
- assert(isDefined(deposit.updatedMessage));
46
- return spokePool.populateTransaction.fillRelayWithUpdatedDeposit(
47
- v3RelayData,
48
- repaymentChainId,
49
- toBytes32(relayer),
50
- deposit.updatedOutputAmount,
51
- toBytes32(deposit.updatedRecipient),
52
- deposit.updatedMessage,
53
- deposit.speedUpSignature,
54
- { from: relayer }
55
- );
56
- }
57
-
58
- return spokePool.populateTransaction.fillRelay(v3RelayData, repaymentChainId, toBytes32(relayer), { from: relayer });
59
- }
60
-
61
- /**
62
- * Retrieves the time from the SpokePool contract at a particular block.
63
- * @returns The time at the specified block tag.
64
- */
65
- export async function getTimeAt(spokePool: Contract, blockNumber: number): Promise<number> {
66
- const currentTime = await spokePool.getCurrentTime({ blockTag: blockNumber });
67
- assert(BigNumber.isBigNumber(currentTime) && currentTime.lt(bnUint32Max));
68
- return currentTime.toNumber();
69
- }
70
-
71
- /**
72
- * Retrieves the chain time at a particular block.
73
- * @note This should be the same as getTimeAt() but can differ in test. These two functions should be consolidated.
74
- * @returns The chain time at the specified block tag.
75
- */
76
- export async function getTimestampForBlock(provider: providers.Provider, blockNumber: number): Promise<number> {
77
- const block = await provider.getBlock(blockNumber);
78
- return block.timestamp;
79
- }
80
-
81
- /**
82
- * Return maximum of fill deadline buffer at start and end of block range.
83
- * @param spokePool SpokePool contract instance
84
- * @param startBlock start block
85
- * @param endBlock end block
86
- * @returns maximum of fill deadline buffer at start and end block
87
- */
88
- export async function getMaxFillDeadlineInRange(
89
- spokePool: Contract,
90
- startBlock: number,
91
- endBlock: number
92
- ): Promise<number> {
93
- const fillDeadlineBuffers = await Promise.all([
94
- spokePool.fillDeadlineBuffer({ blockTag: startBlock }),
95
- spokePool.fillDeadlineBuffer({ blockTag: endBlock }),
96
- ]);
97
- return Math.max(fillDeadlineBuffers[0], fillDeadlineBuffers[1]);
98
- }
99
-
100
- /**
101
- * Finds the deposit id at a specific block number.
102
- * @param blockTag The block number to search for the deposit ID at.
103
- * @returns The deposit ID.
104
- */
105
- export async function getDepositIdAtBlock(contract: Contract, blockTag: number): Promise<BigNumber> {
106
- const _depositIdAtBlock = await contract.numberOfDeposits({ blockTag });
107
- const depositIdAtBlock = toBN(_depositIdAtBlock);
108
- // Sanity check to ensure that the deposit ID is greater than or equal to zero.
109
- if (depositIdAtBlock.lt(bnZero)) {
110
- throw new Error("Invalid deposit count");
111
- }
112
- return depositIdAtBlock;
113
29
  }
114
30
 
115
31
  /**
@@ -121,13 +37,13 @@ export async function getDepositIdAtBlock(contract: Contract, blockTag: number):
121
37
  export function getRelayDataHash(relayData: RelayData, destinationChainId: number): string {
122
38
  const _relayData = {
123
39
  ...relayData,
124
- depositor: ethersUtils.hexZeroPad(relayData.depositor, 32),
125
- recipient: ethersUtils.hexZeroPad(relayData.recipient, 32),
126
- inputToken: ethersUtils.hexZeroPad(relayData.inputToken, 32),
127
- outputToken: ethersUtils.hexZeroPad(relayData.outputToken, 32),
128
- exclusiveRelayer: ethersUtils.hexZeroPad(relayData.exclusiveRelayer, 32),
40
+ depositor: toBytes32(relayData.depositor),
41
+ recipient: toBytes32(relayData.recipient),
42
+ inputToken: toBytes32(relayData.inputToken),
43
+ outputToken: toBytes32(relayData.outputToken),
44
+ exclusiveRelayer: toBytes32(relayData.exclusiveRelayer),
129
45
  };
130
- return ethersUtils.keccak256(
46
+ return keccak256(
131
47
  ethersUtils.defaultAbiCoder.encode(
132
48
  [
133
49
  "tuple(" +
@@ -155,47 +71,6 @@ export function getRelayHashFromEvent(e: RelayData & { destinationChainId: numbe
155
71
  return getRelayDataHash(e, e.destinationChainId);
156
72
  }
157
73
 
158
- export async function findDepositBlock(
159
- spokePool: Contract,
160
- depositId: BigNumber,
161
- lowBlock: number,
162
- highBlock?: number
163
- ): Promise<number | undefined> {
164
- // We can only perform this search when we have a safe deposit ID.
165
- if (isUnsafeDepositId(depositId)) {
166
- throw new Error(`Cannot binary search for depositId ${depositId}`);
167
- }
168
-
169
- highBlock ??= await spokePool.provider.getBlockNumber();
170
- assert(highBlock > lowBlock, `Block numbers out of range (${lowBlock} >= ${highBlock})`);
171
-
172
- // Make sure the deposit occurred within the block range supplied by the caller.
173
- const [nDepositsLow, nDepositsHigh] = (
174
- await Promise.all([
175
- spokePool.numberOfDeposits({ blockTag: lowBlock }),
176
- spokePool.numberOfDeposits({ blockTag: highBlock }),
177
- ])
178
- ).map((n) => toBN(n));
179
-
180
- if (nDepositsLow.gt(depositId) || nDepositsHigh.lte(depositId)) {
181
- return undefined; // Deposit did not occur within the specified block range.
182
- }
183
-
184
- // Find the lowest block number where numberOfDeposits is greater than the requested depositId.
185
- do {
186
- const midBlock = Math.floor((highBlock + lowBlock) / 2);
187
- const nDeposits = toBN(await spokePool.numberOfDeposits({ blockTag: midBlock }));
188
-
189
- if (nDeposits.gt(depositId)) {
190
- highBlock = midBlock; // depositId occurred at or earlier than midBlock.
191
- } else {
192
- lowBlock = midBlock + 1; // depositId occurred later than midBlock.
193
- }
194
- } while (lowBlock < highBlock);
195
-
196
- return lowBlock;
197
- }
198
-
199
74
  export function isUnsafeDepositId(depositId: BigNumber): boolean {
200
75
  // SpokePool.unsafeDepositV3() produces a uint256 depositId by hashing the msg.sender, depositor and input
201
76
  // uint256 depositNonce. There is a possibility that this resultant uint256 is less than the maxSafeDepositId (i.e.
@@ -206,179 +81,6 @@ export function isUnsafeDepositId(depositId: BigNumber): boolean {
206
81
  return maxSafeDepositId.lt(depositId);
207
82
  }
208
83
 
209
- /**
210
- * Find the amount filled for a deposit at a particular block.
211
- * @param spokePool SpokePool contract instance.
212
- * @param relayData Deposit information that is used to complete a fill.
213
- * @param blockTag Block tag (numeric or "latest") to query at.
214
- * @returns The amount filled for the specified deposit at the requested block (or latest).
215
- */
216
- export async function relayFillStatus(
217
- spokePool: Contract,
218
- relayData: RelayData,
219
- blockTag?: number | "latest",
220
- destinationChainId?: number
221
- ): Promise<FillStatus> {
222
- destinationChainId ??= await spokePool.chainId();
223
- assert(isDefined(destinationChainId));
224
-
225
- const hash = getRelayDataHash(relayData, destinationChainId);
226
- const _fillStatus = await spokePool.fillStatuses(hash, { blockTag });
227
- const fillStatus = Number(_fillStatus);
228
-
229
- if (![FillStatus.Unfilled, FillStatus.RequestedSlowFill, FillStatus.Filled].includes(fillStatus)) {
230
- const { originChainId, depositId } = relayData;
231
- throw new Error(
232
- `relayFillStatus: Unexpected fillStatus for ${originChainId} deposit ${depositId.toString()} (${fillStatus})`
233
- );
234
- }
235
-
236
- return fillStatus;
237
- }
238
-
239
- export async function fillStatusArray(
240
- spokePool: Contract,
241
- relayData: RelayData[],
242
- blockTag: BlockTag = "latest"
243
- ): Promise<(FillStatus | undefined)[]> {
244
- const fillStatuses = "fillStatuses";
245
- const destinationChainId = await spokePool.chainId();
246
-
247
- const queries = relayData.map((relayData) => {
248
- const hash = getRelayDataHash(relayData, destinationChainId);
249
- return spokePool.interface.encodeFunctionData(fillStatuses, [hash]);
250
- });
251
-
252
- // Chunk the hashes into appropriate sizes to avoid death by rpc.
253
- const chunkSize = 250;
254
- const chunkedQueries = chunk(queries, chunkSize);
255
-
256
- const multicalls = await Promise.all(
257
- chunkedQueries.map((queries) => spokePool.callStatic.multicall(queries, { blockTag }))
258
- );
259
- const status = multicalls
260
- .map((multicall: BytesLike[]) =>
261
- multicall.map((result) => spokePool.interface.decodeFunctionResult(fillStatuses, result)[0])
262
- )
263
- .flat();
264
-
265
- const bnUnfilled = toBN(FillStatus.Unfilled);
266
- const bnFilled = toBN(FillStatus.Filled);
267
-
268
- return status.map((status: unknown) => {
269
- return BigNumber.isBigNumber(status) && status.gte(bnUnfilled) && status.lte(bnFilled)
270
- ? status.toNumber()
271
- : undefined;
272
- });
273
- }
274
-
275
- /**
276
- * Find the block at which a fill was completed.
277
- * @todo After SpokePool upgrade, this function can be simplified to use the FillStatus enum.
278
- * @param spokePool SpokePool contract instance.
279
- * @param relayData Deposit information that is used to complete a fill.
280
- * @param lowBlockNumber The lower bound of the search. Must be bounded by SpokePool deployment.
281
- * @param highBlocknumber Optional upper bound for the search.
282
- * @returns The block number at which the relay was completed, or undefined.
283
- */
284
- export async function findFillBlock(
285
- spokePool: Contract,
286
- relayData: RelayData,
287
- lowBlockNumber: number,
288
- highBlockNumber?: number
289
- ): Promise<number | undefined> {
290
- const { provider } = spokePool;
291
- highBlockNumber ??= await provider.getBlockNumber();
292
- assert(highBlockNumber > lowBlockNumber, `Block numbers out of range (${lowBlockNumber} >= ${highBlockNumber})`);
293
-
294
- // In production the chainId returned from the provider matches 1:1 with the actual chainId. Querying the provider
295
- // object saves an RPC query because the chainId is cached by StaticJsonRpcProvider instances. In hre, the SpokePool
296
- // may be configured with a different chainId than what is returned by the provider.
297
- const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
298
- ? (await provider.getNetwork()).chainId
299
- : Number(await spokePool.chainId());
300
- assert(
301
- relayData.originChainId !== destinationChainId,
302
- `Origin & destination chain IDs must not be equal (${destinationChainId})`
303
- );
304
-
305
- // Make sure the relay was completed within the block range supplied by the caller.
306
- const [initialFillStatus, finalFillStatus] = (
307
- await Promise.all([
308
- relayFillStatus(spokePool, relayData, lowBlockNumber, destinationChainId),
309
- relayFillStatus(spokePool, relayData, highBlockNumber, destinationChainId),
310
- ])
311
- ).map(Number);
312
-
313
- if (finalFillStatus !== FillStatus.Filled) {
314
- return undefined; // Wasn't filled within the specified block range.
315
- }
316
-
317
- // Was filled earlier than the specified lowBlock. This is an error by the caller.
318
- if (initialFillStatus === FillStatus.Filled) {
319
- const { depositId, originChainId } = relayData;
320
- const [srcChain, dstChain] = [getNetworkName(originChainId), getNetworkName(destinationChainId)];
321
- throw new Error(`${srcChain} deposit ${depositId.toString()} filled on ${dstChain} before block ${lowBlockNumber}`);
322
- }
323
-
324
- // Find the leftmost block where filledAmount equals the deposit amount.
325
- do {
326
- const midBlockNumber = Math.floor((highBlockNumber + lowBlockNumber) / 2);
327
- const fillStatus = await relayFillStatus(spokePool, relayData, midBlockNumber, destinationChainId);
328
-
329
- if (fillStatus === FillStatus.Filled) {
330
- highBlockNumber = midBlockNumber;
331
- } else {
332
- lowBlockNumber = midBlockNumber + 1;
333
- }
334
- } while (lowBlockNumber < highBlockNumber);
335
-
336
- return lowBlockNumber;
337
- }
338
-
339
- export async function findFillEvent(
340
- spokePool: Contract,
341
- relayData: RelayData,
342
- lowBlockNumber: number,
343
- highBlockNumber?: number
344
- ): Promise<FillWithBlock | undefined> {
345
- const blockNumber = await findFillBlock(spokePool, relayData, lowBlockNumber, highBlockNumber);
346
- if (!blockNumber) return undefined;
347
-
348
- // We can hardcode this to 0 to instruct paginatedEventQuery to make a single request for the same block number.
349
- const maxBlockLookBack = 0;
350
- const [fromBlock, toBlock] = [blockNumber, blockNumber];
351
-
352
- const query = (
353
- await Promise.all([
354
- paginatedEventQuery(
355
- spokePool,
356
- spokePool.filters.FilledRelay(null, null, null, null, null, relayData.originChainId, relayData.depositId),
357
- { fromBlock, toBlock, maxBlockLookBack }
358
- ),
359
- paginatedEventQuery(
360
- spokePool,
361
- spokePool.filters.FilledV3Relay(null, null, null, null, null, relayData.originChainId, relayData.depositId),
362
- { fromBlock, toBlock, maxBlockLookBack }
363
- ),
364
- ])
365
- ).flat();
366
- if (query.length === 0) throw new Error(`Failed to find fill event at block ${blockNumber}`);
367
- const event = query[0];
368
- // In production the chainId returned from the provider matches 1:1 with the actual chainId. Querying the provider
369
- // object saves an RPC query because the chainId is cached by StaticJsonRpcProvider instances. In hre, the SpokePool
370
- // may be configured with a different chainId than what is returned by the provider.
371
- const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
372
- ? (await spokePool.provider.getNetwork()).chainId
373
- : Number(await spokePool.chainId());
374
- const fill = {
375
- ...spreadEventWithBlockNumber(event),
376
- destinationChainId,
377
- messageHash: getMessageHash(event.args.message),
378
- } as FillWithBlock;
379
- return fill;
380
- }
381
-
382
84
  // Determines if the input address (either a bytes32 or bytes20) is the zero address.
383
85
  export function isZeroAddress(address: string): boolean {
384
86
  return address === ZERO_ADDRESS || address === ZERO_BYTES;