@across-protocol/sdk 4.0.0-beta.2 → 4.0.0-beta.20

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 (102) hide show
  1. package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +5 -4
  2. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +320 -179
  3. package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  4. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.d.ts +1 -2
  5. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +1 -2
  6. package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  7. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
  8. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +33 -1
  9. package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  10. package/dist/cjs/clients/SpokePoolClient.d.ts +1 -0
  11. package/dist/cjs/clients/SpokePoolClient.js +13 -4
  12. package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
  13. package/dist/cjs/constants.d.ts +1 -0
  14. package/dist/cjs/constants.js +2 -1
  15. package/dist/cjs/constants.js.map +1 -1
  16. package/dist/cjs/providers/index.d.ts +1 -0
  17. package/dist/cjs/providers/index.js +2 -0
  18. package/dist/cjs/providers/index.js.map +1 -1
  19. package/dist/cjs/providers/mockProvider.d.ts +19 -0
  20. package/dist/cjs/providers/mockProvider.js +70 -0
  21. package/dist/cjs/providers/mockProvider.js.map +1 -0
  22. package/dist/cjs/utils/AddressUtils.d.ts +1 -0
  23. package/dist/cjs/utils/AddressUtils.js +14 -1
  24. package/dist/cjs/utils/AddressUtils.js.map +1 -1
  25. package/dist/cjs/utils/CachingUtils.js +1 -1
  26. package/dist/cjs/utils/CachingUtils.js.map +1 -1
  27. package/dist/cjs/utils/DepositUtils.d.ts +2 -1
  28. package/dist/cjs/utils/DepositUtils.js +12 -3
  29. package/dist/cjs/utils/DepositUtils.js.map +1 -1
  30. package/dist/cjs/utils/NetworkUtils.d.ts +1 -0
  31. package/dist/cjs/utils/NetworkUtils.js +6 -1
  32. package/dist/cjs/utils/NetworkUtils.js.map +1 -1
  33. package/dist/cjs/utils/SpokeUtils.js +3 -3
  34. package/dist/cjs/utils/SpokeUtils.js.map +1 -1
  35. package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +5 -4
  36. package/dist/esm/clients/BundleDataClient/BundleDataClient.js +382 -218
  37. package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
  38. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.d.ts +1 -2
  39. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +2 -3
  40. package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
  41. package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
  42. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +42 -1
  43. package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
  44. package/dist/esm/clients/SpokePoolClient.d.ts +8 -0
  45. package/dist/esm/clients/SpokePoolClient.js +20 -4
  46. package/dist/esm/clients/SpokePoolClient.js.map +1 -1
  47. package/dist/esm/constants.d.ts +1 -0
  48. package/dist/esm/constants.js +2 -1
  49. package/dist/esm/constants.js.map +1 -1
  50. package/dist/esm/providers/index.d.ts +1 -0
  51. package/dist/esm/providers/index.js +2 -0
  52. package/dist/esm/providers/index.js.map +1 -1
  53. package/dist/esm/providers/mockProvider.d.ts +23 -0
  54. package/dist/esm/providers/mockProvider.js +73 -0
  55. package/dist/esm/providers/mockProvider.js.map +1 -0
  56. package/dist/esm/utils/AddressUtils.d.ts +1 -0
  57. package/dist/esm/utils/AddressUtils.js +16 -0
  58. package/dist/esm/utils/AddressUtils.js.map +1 -1
  59. package/dist/esm/utils/CachingUtils.js +1 -1
  60. package/dist/esm/utils/CachingUtils.js.map +1 -1
  61. package/dist/esm/utils/DepositUtils.d.ts +2 -1
  62. package/dist/esm/utils/DepositUtils.js +12 -3
  63. package/dist/esm/utils/DepositUtils.js.map +1 -1
  64. package/dist/esm/utils/NetworkUtils.d.ts +6 -0
  65. package/dist/esm/utils/NetworkUtils.js +10 -0
  66. package/dist/esm/utils/NetworkUtils.js.map +1 -1
  67. package/dist/esm/utils/SpokeUtils.js +4 -4
  68. package/dist/esm/utils/SpokeUtils.js.map +1 -1
  69. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +5 -4
  70. package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
  71. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts +1 -2
  72. package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
  73. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
  74. package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
  75. package/dist/types/clients/SpokePoolClient.d.ts +8 -0
  76. package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
  77. package/dist/types/constants.d.ts +1 -0
  78. package/dist/types/constants.d.ts.map +1 -1
  79. package/dist/types/providers/index.d.ts +1 -0
  80. package/dist/types/providers/index.d.ts.map +1 -1
  81. package/dist/types/providers/mockProvider.d.ts +24 -0
  82. package/dist/types/providers/mockProvider.d.ts.map +1 -0
  83. package/dist/types/utils/AddressUtils.d.ts +1 -0
  84. package/dist/types/utils/AddressUtils.d.ts.map +1 -1
  85. package/dist/types/utils/DepositUtils.d.ts +2 -1
  86. package/dist/types/utils/DepositUtils.d.ts.map +1 -1
  87. package/dist/types/utils/NetworkUtils.d.ts +6 -0
  88. package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
  89. package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
  90. package/package.json +1 -1
  91. package/src/clients/BundleDataClient/BundleDataClient.ts +383 -217
  92. package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +0 -8
  93. package/src/clients/BundleDataClient/utils/FillUtils.ts +47 -2
  94. package/src/clients/SpokePoolClient.ts +19 -6
  95. package/src/constants.ts +3 -1
  96. package/src/providers/index.ts +1 -0
  97. package/src/providers/mockProvider.ts +77 -0
  98. package/src/utils/AddressUtils.ts +16 -0
  99. package/src/utils/CachingUtils.ts +1 -1
  100. package/src/utils/DepositUtils.ts +12 -3
  101. package/src/utils/NetworkUtils.ts +11 -0
  102. package/src/utils/SpokeUtils.ts +6 -5
@@ -14,7 +14,6 @@ import {
14
14
  import {
15
15
  bnZero,
16
16
  AnyObject,
17
- groupObjectCountsByTwoProps,
18
17
  fixedPointAdjustment,
19
18
  count2DDictionaryValues,
20
19
  count3DDictionaryValues,
@@ -26,7 +25,6 @@ import {
26
25
  updateRunningBalance,
27
26
  updateRunningBalanceForDeposit,
28
27
  } from "./PoolRebalanceUtils";
29
- import { V3FillWithBlock } from "./shims";
30
28
  import { AcrossConfigStoreClient } from "../../AcrossConfigStoreClient";
31
29
  import { HubPoolClient } from "../../HubPoolClient";
32
30
  import { buildPoolRebalanceLeafTree } from "./MerkleTreeUtils";
@@ -83,7 +81,6 @@ export function getRefundsFromBundle(
83
81
  export function prettyPrintV3SpokePoolEvents(
84
82
  bundleDepositsV3: BundleDepositsV3,
85
83
  bundleFillsV3: BundleFillsV3,
86
- bundleInvalidFillsV3: V3FillWithBlock[],
87
84
  bundleSlowFillsV3: BundleSlowFills,
88
85
  expiredDepositsToRefundV3: ExpiredDepositsToRefundV3,
89
86
  unexecutableSlowFills: BundleExcessSlowFills
@@ -94,11 +91,6 @@ export function prettyPrintV3SpokePoolEvents(
94
91
  bundleSlowFillsV3: count2DDictionaryValues(bundleSlowFillsV3),
95
92
  expiredDepositsToRefundV3: count2DDictionaryValues(expiredDepositsToRefundV3),
96
93
  unexecutableSlowFills: count2DDictionaryValues(unexecutableSlowFills),
97
- allInvalidFillsInRangeByDestinationChainAndRelayer: groupObjectCountsByTwoProps(
98
- bundleInvalidFillsV3,
99
- "destinationChainId",
100
- (fill) => `${fill.relayer}`
101
- ),
102
94
  };
103
95
  }
104
96
 
@@ -1,5 +1,7 @@
1
- import { Fill } from "../../../interfaces";
2
- import { getBlockRangeForChain, isSlowFill } from "../../../utils";
1
+ import _ from "lodash";
2
+ import { providers } from "ethers";
3
+ import { DepositWithBlock, Fill, FillWithBlock } from "../../../interfaces";
4
+ import { getBlockRangeForChain, isSlowFill, chainIsEvm, isValidEvmAddress, isDefined } from "../../../utils";
3
5
  import { HubPoolClient } from "../../HubPoolClient";
4
6
 
5
7
  export function getRefundInformationFromFill(
@@ -44,3 +46,46 @@ export function getRefundInformationFromFill(
44
46
  repaymentToken,
45
47
  };
46
48
  }
49
+
50
+ // Verify that a fill sent to an EVM chain has a 20 byte address. If the fill does not, then attempt
51
+ // to repay the `msg.sender` of the relay transaction. Otherwise, return undefined.
52
+ export async function verifyFillRepayment(
53
+ fill: FillWithBlock,
54
+ destinationChainProvider: providers.Provider,
55
+ matchedDeposit: DepositWithBlock,
56
+ possibleRepaymentChainIds: number[]
57
+ ): Promise<FillWithBlock | undefined> {
58
+ // Slow fills don't result in repayments so they're always valid.
59
+ if (isSlowFill(fill)) {
60
+ return fill;
61
+ }
62
+ // Lite chain deposits force repayment on origin chain.
63
+ const repaymentChainId = matchedDeposit.fromLiteChain ? fill.originChainId : fill.repaymentChainId;
64
+ // Return undefined if the requested repayment chain ID is not recognized by the hub pool.
65
+ if (!possibleRepaymentChainIds.includes(repaymentChainId)) {
66
+ return undefined;
67
+ }
68
+ const updatedFill = _.cloneDeep(fill);
69
+
70
+ // If the fill requests repayment on a chain where the repayment address is not valid, attempt to find a valid
71
+ // repayment address, otherwise return undefined.
72
+
73
+ // Case 1: repayment chain is an EVM chain but repayment address is not a valid EVM address.
74
+ if (chainIsEvm(repaymentChainId) && !isValidEvmAddress(updatedFill.relayer)) {
75
+ // TODO: Handle case where fill was sent on non-EVM chain, in which case the following call would fail
76
+ // or return something unexpected. We'd want to return undefined here.
77
+ const fillTransaction = await destinationChainProvider.getTransaction(updatedFill.transactionHash);
78
+ const destinationRelayer = fillTransaction?.from;
79
+ // Repayment chain is still an EVM chain, but the msg.sender is a bytes32 address, so the fill is invalid.
80
+ if (!isDefined(destinationRelayer) || !isValidEvmAddress(destinationRelayer)) {
81
+ return undefined;
82
+ }
83
+ // Otherwise, assume the relayer to be repaid is the msg.sender. We don't need to modify the repayment chain since
84
+ // the getTransaction() call would only succeed if the fill was sent on an EVM chain and therefore the msg.sender
85
+ // is a valid EVM address and the repayment chain is an EVM chain.
86
+ updatedFill.relayer = destinationRelayer;
87
+ }
88
+
89
+ // Case 2: TODO repayment chain is an SVM chain and repayment address is not a valid SVM address.
90
+ return updatedFill;
91
+ }
@@ -135,6 +135,18 @@ export class SpokePoolClient extends BaseAbstractClient {
135
135
  return Object.values(this.depositHashes).filter((deposit) => deposit.destinationChainId === destinationChainId);
136
136
  }
137
137
 
138
+ /**
139
+ * Retrieves a list of duplicate deposits matching the given deposit's deposit hash.
140
+ * @notice A duplicate is considered any deposit sent after the original deposit with the same deposit hash.
141
+ * @param deposit The deposit to find duplicates for.
142
+ * @returns A list of duplicate deposits. Does NOT include the original deposit
143
+ * unless the original deposit is a duplicate.
144
+ */
145
+ public getDuplicateDeposits(deposit: DepositWithBlock): DepositWithBlock[] {
146
+ const depositHash = this.getDepositHash(deposit);
147
+ return this.duplicateDepositHashes[depositHash] ?? [];
148
+ }
149
+
138
150
  /**
139
151
  * Returns a list of all deposits including any duplicate ones. Designed only to be used in use cases where
140
152
  * all deposits are required, regardless of duplicates. For example, the Dataworker can use this to refund
@@ -144,9 +156,10 @@ export class SpokePoolClient extends BaseAbstractClient {
144
156
  */
145
157
  public getDepositsForDestinationChainWithDuplicates(destinationChainId: number): DepositWithBlock[] {
146
158
  const deposits = this.getDepositsForDestinationChain(destinationChainId);
147
- const duplicateDeposits = Object.values(this.duplicateDepositHashes).filter(
148
- (deposits) => deposits.length > 0 && deposits[0].destinationChainId === destinationChainId
149
- );
159
+ const duplicateDeposits = deposits.reduce((acc, deposit) => {
160
+ const duplicates = this.getDuplicateDeposits(deposit);
161
+ return acc.concat(duplicates);
162
+ }, [] as DepositWithBlock[]);
150
163
  return sortEventsAscendingInPlace(deposits.concat(duplicateDeposits.flat()));
151
164
  }
152
165
 
@@ -331,7 +344,7 @@ export class SpokePoolClient extends BaseAbstractClient {
331
344
 
332
345
  this.logger.debug({
333
346
  at: "SpokePoolClient::getDepositForFill",
334
- message: `Rejected fill for ${getNetworkName(fill.originChainId)} deposit ${fill.depositId}.`,
347
+ message: `Rejected fill for ${getNetworkName(fill.originChainId)} deposit ${fill.depositId.toString()}.`,
335
348
  reason: match.reason,
336
349
  deposit,
337
350
  fill,
@@ -415,7 +428,7 @@ export class SpokePoolClient extends BaseAbstractClient {
415
428
  * @note This hash takes the form of: `${depositId}-${originChainId}`.
416
429
  */
417
430
  public getDepositHash(event: { depositId: BigNumber; originChainId: number }): string {
418
- return `${event.depositId}-${event.originChainId}`;
431
+ return `${event.depositId.toString()}-${event.originChainId}`;
419
432
  }
420
433
 
421
434
  /**
@@ -833,7 +846,7 @@ export class SpokePoolClient extends BaseAbstractClient {
833
846
  const srcChain = getNetworkName(this.chainId);
834
847
  const dstChain = getNetworkName(destinationChainId);
835
848
  throw new Error(
836
- `Could not find deposit ${depositId} for ${dstChain} fill` +
849
+ `Could not find deposit ${depositId.toString()} for ${dstChain} fill` +
837
850
  ` between ${srcChain} blocks [${searchBounds.low}, ${searchBounds.high}]`
838
851
  );
839
852
  }
package/src/constants.ts CHANGED
@@ -26,9 +26,11 @@ export const SECONDS_PER_YEAR = 31557600; // 365.25 days per year.
26
26
  */
27
27
  export const HUBPOOL_CHAIN_ID = 1;
28
28
 
29
- // List of versions where certain UMIP features were deprecated
29
+ // List of versions where certain UMIP features were deprecated or activated
30
30
  export const TRANSFER_THRESHOLD_MAX_CONFIG_STORE_VERSION = 1;
31
31
 
32
+ export const PRE_FILL_MIN_CONFIG_STORE_VERSION = 5;
33
+
32
34
  // A hardcoded identifier used, by default, to tag all Arweave records.
33
35
  export const ARWEAVE_TAG_APP_NAME = "across-protocol";
34
36
 
@@ -5,3 +5,4 @@ export * from "./speedProvider";
5
5
  export * from "./constants";
6
6
  export * from "./types";
7
7
  export * from "./utils";
8
+ export * as mocks from "./mockProvider";
@@ -0,0 +1,77 @@
1
+ import { BigNumber, providers } from "ethers";
2
+ import { Block, BlockTag, FeeData, TransactionResponse } from "@ethersproject/abstract-provider";
3
+ import { bnZero } from "../utils/BigNumberUtils";
4
+
5
+ /**
6
+ * @notice Class used to test GasPriceOracle which makes ethers provider calls to the following implemented
7
+ * methods.
8
+ */
9
+ export class MockedProvider extends providers.StaticJsonRpcProvider {
10
+ private transactions: { [hash: string]: TransactionResponse } = {};
11
+
12
+ constructor(
13
+ readonly stdLastBaseFeePerGas: BigNumber,
14
+ readonly stdMaxPriorityFeePerGas: BigNumber,
15
+ readonly defaultChainId = 1
16
+ ) {
17
+ super(undefined, defaultChainId);
18
+ }
19
+
20
+ getBlock(_blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block> {
21
+ const mockBlock: Block = {
22
+ transactions: [],
23
+ hash: "0x",
24
+ parentHash: "0x",
25
+ number: 0,
26
+ nonce: "0",
27
+ difficulty: 0,
28
+ _difficulty: bnZero,
29
+ timestamp: 0,
30
+ gasLimit: bnZero,
31
+ gasUsed: bnZero,
32
+ baseFeePerGas: this.stdLastBaseFeePerGas,
33
+ miner: "0x",
34
+ extraData: "0x",
35
+ };
36
+ return Promise.resolve(mockBlock);
37
+ }
38
+
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ send(method: string, _params: Array<any>): Promise<any> {
41
+ switch (method) {
42
+ case "eth_maxPriorityFeePerGas":
43
+ return Promise.resolve(this.stdMaxPriorityFeePerGas);
44
+ default:
45
+ throw new Error(`MockedProvider#Unimplemented method: ${method}`);
46
+ }
47
+ }
48
+
49
+ getFeeData(): Promise<FeeData> {
50
+ return Promise.resolve({
51
+ lastBaseFeePerGas: this.stdLastBaseFeePerGas,
52
+ maxPriorityFeePerGas: this.stdMaxPriorityFeePerGas,
53
+ // Following fields unused in GasPrice oracle
54
+ maxFeePerGas: null,
55
+ gasPrice: null,
56
+ });
57
+ }
58
+
59
+ getTransaction(hash: string): Promise<TransactionResponse> {
60
+ return Promise.resolve(this.transactions[hash]);
61
+ }
62
+
63
+ getGasPrice(): Promise<BigNumber> {
64
+ return Promise.resolve(this.stdLastBaseFeePerGas.add(this.stdMaxPriorityFeePerGas));
65
+ }
66
+
67
+ getNetwork(): Promise<{ chainId: number; name: string }> {
68
+ return Promise.resolve({
69
+ name: "mocknetwork",
70
+ chainId: this.defaultChainId,
71
+ });
72
+ }
73
+
74
+ _setTransaction(hash: string, transaction: TransactionResponse) {
75
+ this.transactions[hash] = transaction;
76
+ }
77
+ }
@@ -38,3 +38,19 @@ export function compareAddressesSimple(addressA?: string, addressB?: string): bo
38
38
  }
39
39
  return addressA.toLowerCase() === addressB.toLowerCase();
40
40
  }
41
+
42
+ export function isValidEvmAddress(address: string): boolean {
43
+ if (utils.isAddress(address)) {
44
+ return true;
45
+ }
46
+ // We may throw an error here if hexZeroPadFails. This will happen if the address to pad is greater than 20 bytes long, indicating
47
+ // that the address had less than 12 leading zero bytes.
48
+ // We may also throw at getAddress if the input cannot be converted into a checksummed EVM address for some reason.
49
+ // For both cases, this indicates that the address cannot be casted as a bytes20 EVM address, so we should return false.
50
+ try {
51
+ const evmAddress = utils.hexZeroPad(utils.hexStripZeros(address), 20);
52
+ return utils.isAddress(utils.getAddress(evmAddress));
53
+ } catch (_e) {
54
+ return false;
55
+ }
56
+ }
@@ -52,5 +52,5 @@ export async function setDepositInCache(
52
52
  */
53
53
  export function getDepositKey(bridgeEvent: Deposit | Fill | SlowFillRequest): string {
54
54
  const relayHash = getRelayHashFromEvent(bridgeEvent);
55
- return `deposit_${bridgeEvent.originChainId}_${bridgeEvent.depositId}_${relayHash}`;
55
+ return `deposit_${bridgeEvent.originChainId}_${bridgeEvent.depositId.toString()}_${relayHash}`;
56
56
  }
@@ -5,6 +5,7 @@ import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, SlowFillReq
5
5
  import { getNetworkName } from "./NetworkUtils";
6
6
  import { getDepositInCache, getDepositKey, setDepositInCache } from "./CachingUtils";
7
7
  import { validateFillForDeposit } from "./FlowUtils";
8
+ import { isUnsafeDepositId } from "./SpokeUtils";
8
9
  import { getCurrentTime } from "./TimeUtils";
9
10
  import { isDefined } from "./TypeGuards";
10
11
  import { isDepositFormedCorrectly } from "./ValidatorUtils";
@@ -17,6 +18,7 @@ export enum InvalidFill {
17
18
  DepositIdInvalid = 0, // Deposit ID seems invalid for origin SpokePool
18
19
  DepositIdNotFound, // Deposit ID not found (bad RPC data?)
19
20
  FillMismatch, // Fill does not match deposit parameters for deposit ID.
21
+ DepositIdOutOfRange, // Fill is for a deterministic deposit.
20
22
  }
21
23
 
22
24
  export type DepositSearchResult =
@@ -40,6 +42,13 @@ export async function queryHistoricalDepositForFill(
40
42
  fill: Fill | SlowFillRequest,
41
43
  cache?: CachingMechanismInterface
42
44
  ): Promise<DepositSearchResult> {
45
+ if (isUnsafeDepositId(fill.depositId)) {
46
+ return {
47
+ found: false,
48
+ code: InvalidFill.DepositIdOutOfRange,
49
+ reason: `Cannot find historical deposit for fill with unsafe deposit ID ${fill.depositId}.`,
50
+ };
51
+ }
43
52
  if (fill.originChainId !== spokePoolClient.chainId) {
44
53
  throw new Error(`OriginChainId mismatch (${fill.originChainId} != ${spokePoolClient.chainId})`);
45
54
  }
@@ -56,7 +65,7 @@ export async function queryHistoricalDepositForFill(
56
65
  return {
57
66
  found: false,
58
67
  code: InvalidFill.DepositIdInvalid,
59
- reason: `Deposit ID ${depositId} is outside of SpokePool bounds [${lowId},${highId}].`,
68
+ reason: `Deposit ID ${depositId.toString()} is outside of SpokePool bounds [${lowId},${highId}].`,
60
69
  };
61
70
  }
62
71
 
@@ -73,14 +82,14 @@ export async function queryHistoricalDepositForFill(
73
82
  return {
74
83
  found: false,
75
84
  code: InvalidFill.FillMismatch,
76
- reason: `Fill for ${originChain} deposit ID ${depositId} is invalid (${match.reason}).`,
85
+ reason: `Fill for ${originChain} deposit ID ${depositId.toString()} is invalid (${match.reason}).`,
77
86
  };
78
87
  }
79
88
 
80
89
  return {
81
90
  found: false,
82
91
  code: InvalidFill.DepositIdNotFound,
83
- reason: `${originChain} deposit ID ${depositId} not found in SpokePoolClient event buffer.`,
92
+ reason: `${originChain} deposit ID ${depositId.toString()} not found in SpokePoolClient event buffer.`,
84
93
  };
85
94
  }
86
95
 
@@ -123,6 +123,17 @@ export function chainIsL1(chainId: number): boolean {
123
123
  return [CHAIN_IDs.MAINNET, CHAIN_IDs.SEPOLIA].includes(chainId);
124
124
  }
125
125
 
126
+ /**
127
+ * Determines whether a chain ID runs on an EVM-like execution layer.
128
+ * @param chainId Chain ID to evaluate.
129
+ * @returns True if chain corresponding to chainId has an EVM-like execution layer.
130
+ */
131
+ export function chainIsEvm(chainId: number): boolean {
132
+ chainId;
133
+ // TODO: Fix when we support non-EVM chains.
134
+ return true;
135
+ }
136
+
126
137
  /**
127
138
  * Determines whether a chain ID has the capacity for having its USDC bridged via CCTP.
128
139
  * @param chainId Chain ID to evaluate.
@@ -154,7 +154,7 @@ export async function getBlockRangeForDepositId(
154
154
  // // targetId = 2 <- pass (does not trigger this error)
155
155
  // // targetId = 3 <- pass (does not trigger this error)
156
156
  throw new Error(
157
- `Target depositId is less than the initial low block (${targetDepositId} > ${lowestDepositIdInRange})`
157
+ `Target depositId is less than the initial low block (${targetDepositId.toString()} > ${lowestDepositIdInRange})`
158
158
  );
159
159
  }
160
160
 
@@ -209,7 +209,7 @@ export async function getBlockRangeForDepositId(
209
209
  export async function getDepositIdAtBlock(contract: Contract, blockTag: number): Promise<BigNumber> {
210
210
  const _depositIdAtBlock = await contract.numberOfDeposits({ blockTag });
211
211
  const depositIdAtBlock = toBN(_depositIdAtBlock);
212
- // Sanity check to ensure that the deposit ID is an integer and is greater than or equal to zero.
212
+ // Sanity check to ensure that the deposit ID is greater than or equal to zero.
213
213
  if (depositIdAtBlock.lt(bnZero)) {
214
214
  throw new Error("Invalid deposit count");
215
215
  }
@@ -281,7 +281,9 @@ export async function relayFillStatus(
281
281
 
282
282
  if (![FillStatus.Unfilled, FillStatus.RequestedSlowFill, FillStatus.Filled].includes(fillStatus)) {
283
283
  const { originChainId, depositId } = relayData;
284
- throw new Error(`relayFillStatus: Unexpected fillStatus for ${originChainId} deposit ${depositId} (${fillStatus})`);
284
+ throw new Error(
285
+ `relayFillStatus: Unexpected fillStatus for ${originChainId} deposit ${depositId.toString()} (${fillStatus})`
286
+ );
285
287
  }
286
288
 
287
289
  return fillStatus;
@@ -345,7 +347,6 @@ export async function findFillBlock(
345
347
  // In production the chainId returned from the provider matches 1:1 with the actual chainId. Querying the provider
346
348
  // object saves an RPC query becasue the chainId is cached by StaticJsonRpcProvider instances. In hre, the SpokePool
347
349
  // may be configured with a different chainId than what is returned by the provider.
348
- // @todo Sub out actual chain IDs w/ CHAIN_IDs constants
349
350
  const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
350
351
  ? (await provider.getNetwork()).chainId
351
352
  : Number(await spokePool.chainId());
@@ -370,7 +371,7 @@ export async function findFillBlock(
370
371
  if (initialFillStatus === FillStatus.Filled) {
371
372
  const { depositId, originChainId } = relayData;
372
373
  const [srcChain, dstChain] = [getNetworkName(originChainId), getNetworkName(destinationChainId)];
373
- throw new Error(`${srcChain} deposit ${depositId} filled on ${dstChain} before block ${lowBlockNumber}`);
374
+ throw new Error(`${srcChain} deposit ${depositId.toString()} filled on ${dstChain} before block ${lowBlockNumber}`);
374
375
  }
375
376
 
376
377
  // Find the leftmost block where filledAmount equals the deposit amount.