@across-protocol/sdk 4.0.0-beta.0 → 4.0.0-beta.10
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.
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +218 -148
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +33 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +12 -10
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient.d.ts +12 -12
- package/dist/cjs/clients/SpokePoolClient.js +20 -18
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -4
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +6 -6
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +4 -2
- package/dist/cjs/constants.js +5 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/interfaces/SpokePool.d.ts +2 -2
- package/dist/cjs/providers/index.d.ts +1 -0
- package/dist/cjs/providers/index.js +2 -0
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/providers/mockProvider.d.ts +19 -0
- package/dist/cjs/providers/mockProvider.js +70 -0
- package/dist/cjs/providers/mockProvider.js.map +1 -0
- package/dist/cjs/utils/AddressUtils.d.ts +1 -0
- package/dist/cjs/utils/AddressUtils.js +14 -1
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/BigNumberUtils.d.ts +1 -0
- package/dist/cjs/utils/BigNumberUtils.js +5 -1
- package/dist/cjs/utils/BigNumberUtils.js.map +1 -1
- package/dist/cjs/utils/CachingUtils.js +1 -1
- package/dist/cjs/utils/CachingUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +4 -1
- package/dist/cjs/utils/DepositUtils.js +23 -6
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +4 -0
- package/dist/cjs/utils/EventUtils.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.d.ts +1 -0
- package/dist/cjs/utils/NetworkUtils.js +6 -1
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +5 -3
- package/dist/cjs/utils/SpokeUtils.js +18 -11
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/ValidatorUtils.js +1 -1
- package/dist/cjs/utils/ValidatorUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +275 -186
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +42 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +12 -10
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient.d.ts +12 -12
- package/dist/esm/clients/SpokePoolClient.js +21 -19
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -4
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +7 -7
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +4 -2
- package/dist/esm/constants.js +5 -3
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/interfaces/SpokePool.d.ts +2 -2
- package/dist/esm/providers/index.d.ts +1 -0
- package/dist/esm/providers/index.js +2 -0
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/providers/mockProvider.d.ts +23 -0
- package/dist/esm/providers/mockProvider.js +73 -0
- package/dist/esm/providers/mockProvider.js.map +1 -0
- package/dist/esm/utils/AddressUtils.d.ts +1 -0
- package/dist/esm/utils/AddressUtils.js +16 -0
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/BigNumberUtils.d.ts +8 -0
- package/dist/esm/utils/BigNumberUtils.js +10 -0
- package/dist/esm/utils/BigNumberUtils.js.map +1 -1
- package/dist/esm/utils/CachingUtils.js +1 -1
- package/dist/esm/utils/CachingUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +4 -1
- package/dist/esm/utils/DepositUtils.js +21 -6
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +8 -0
- package/dist/esm/utils/EventUtils.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.d.ts +6 -0
- package/dist/esm/utils/NetworkUtils.js +10 -0
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +5 -3
- package/dist/esm/utils/SpokeUtils.js +21 -13
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/ValidatorUtils.js +1 -1
- package/dist/esm/utils/ValidatorUtils.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +3 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +12 -10
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient.d.ts +12 -12
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -4
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +4 -2
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +2 -2
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +1 -0
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/providers/mockProvider.d.ts +24 -0
- package/dist/types/providers/mockProvider.d.ts.map +1 -0
- package/dist/types/utils/AddressUtils.d.ts +1 -0
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/BigNumberUtils.d.ts +8 -0
- package/dist/types/utils/BigNumberUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +4 -1
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/EventUtils.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts +6 -0
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +5 -3
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/clients/BundleDataClient/BundleDataClient.ts +179 -114
- package/src/clients/BundleDataClient/utils/FillUtils.ts +47 -2
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +4 -2
- package/src/clients/SpokePoolClient.ts +30 -26
- package/src/clients/mocks/MockSpokePoolClient.ts +10 -10
- package/src/constants.ts +7 -3
- package/src/interfaces/SpokePool.ts +2 -2
- package/src/providers/index.ts +1 -0
- package/src/providers/mockProvider.ts +77 -0
- package/src/utils/AddressUtils.ts +16 -0
- package/src/utils/BigNumberUtils.ts +11 -0
- package/src/utils/CachingUtils.ts +1 -1
- package/src/utils/DepositUtils.ts +23 -6
- package/src/utils/EventUtils.ts +8 -0
- package/src/utils/NetworkUtils.ts +11 -0
- package/src/utils/SpokeUtils.ts +31 -19
- package/src/utils/ValidatorUtils.ts +1 -1
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
pattern,
|
|
11
11
|
boolean,
|
|
12
12
|
defaulted,
|
|
13
|
+
union,
|
|
13
14
|
type,
|
|
14
15
|
} from "superstruct";
|
|
15
16
|
import { BigNumber } from "../../../utils";
|
|
@@ -17,7 +18,7 @@ import { BigNumber } from "../../../utils";
|
|
|
17
18
|
const PositiveIntegerStringSS = pattern(string(), /\d+/);
|
|
18
19
|
const Web3AddressSS = pattern(string(), /^0x[a-fA-F0-9]{40}$/);
|
|
19
20
|
|
|
20
|
-
const BigNumberType = coerce(instance(BigNumber), string(), (value) => {
|
|
21
|
+
const BigNumberType = coerce(instance(BigNumber), union([string(), number()]), (value) => {
|
|
21
22
|
try {
|
|
22
23
|
// Attempt to convert the string to a BigNumber
|
|
23
24
|
return BigNumber.from(value);
|
|
@@ -41,7 +42,7 @@ const V3RelayDataSS = {
|
|
|
41
42
|
originChainId: number(),
|
|
42
43
|
depositor: string(),
|
|
43
44
|
recipient: string(),
|
|
44
|
-
depositId:
|
|
45
|
+
depositId: BigNumberType,
|
|
45
46
|
message: string(),
|
|
46
47
|
};
|
|
47
48
|
|
|
@@ -91,6 +92,7 @@ const V3FillSS = {
|
|
|
91
92
|
repaymentChainId: number(),
|
|
92
93
|
relayExecutionInfo: V3RelayExecutionEventInfoSS,
|
|
93
94
|
quoteTimestamp: number(),
|
|
95
|
+
messageHash: optional(string()),
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
const V3FillWithBlockSS = {
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
getRelayDataHash,
|
|
13
13
|
isDefined,
|
|
14
14
|
toBN,
|
|
15
|
+
bnOne,
|
|
16
|
+
isUnsafeDepositId,
|
|
15
17
|
} from "../utils";
|
|
16
18
|
import {
|
|
17
19
|
paginatedEventQuery,
|
|
@@ -46,8 +48,8 @@ type SpokePoolUpdateSuccess = {
|
|
|
46
48
|
success: true;
|
|
47
49
|
currentTime: number;
|
|
48
50
|
oldestTime: number;
|
|
49
|
-
firstDepositId:
|
|
50
|
-
latestDepositId:
|
|
51
|
+
firstDepositId: BigNumber;
|
|
52
|
+
latestDepositId: BigNumber;
|
|
51
53
|
events: Log[][];
|
|
52
54
|
searchEndBlock: number;
|
|
53
55
|
};
|
|
@@ -67,7 +69,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
67
69
|
protected depositHashes: { [depositHash: string]: DepositWithBlock } = {};
|
|
68
70
|
protected duplicateDepositHashes: { [depositHash: string]: DepositWithBlock[] } = {};
|
|
69
71
|
protected depositHashesToFills: { [depositHash: string]: FillWithBlock[] } = {};
|
|
70
|
-
protected speedUps: { [depositorAddress: string]: { [depositId:
|
|
72
|
+
protected speedUps: { [depositorAddress: string]: { [depositId: string]: SpeedUpWithBlock[] } } = {};
|
|
71
73
|
protected slowFillRequests: { [relayDataHash: string]: SlowFillRequestWithBlock } = {};
|
|
72
74
|
protected depositRoutes: { [originToken: string]: { [DestinationChainId: number]: boolean } } = {};
|
|
73
75
|
protected tokensBridged: TokensBridged[] = [];
|
|
@@ -75,10 +77,10 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
75
77
|
protected relayerRefundExecutions: RelayerRefundExecutionWithBlock[] = [];
|
|
76
78
|
protected queryableEventNames: string[] = [];
|
|
77
79
|
protected configStoreClient: AcrossConfigStoreClient | undefined;
|
|
78
|
-
public earliestDepositIdQueried =
|
|
79
|
-
public latestDepositIdQueried =
|
|
80
|
-
public firstDepositIdForSpokePool =
|
|
81
|
-
public lastDepositIdForSpokePool =
|
|
80
|
+
public earliestDepositIdQueried = MAX_BIG_INT;
|
|
81
|
+
public latestDepositIdQueried = bnZero;
|
|
82
|
+
public firstDepositIdForSpokePool = MAX_BIG_INT;
|
|
83
|
+
public lastDepositIdForSpokePool = MAX_BIG_INT;
|
|
82
84
|
public fills: { [OriginChainId: number]: FillWithBlock[] } = {};
|
|
83
85
|
|
|
84
86
|
/**
|
|
@@ -248,7 +250,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
248
250
|
*/
|
|
249
251
|
public appendMaxSpeedUpSignatureToDeposit(deposit: DepositWithBlock): DepositWithBlock {
|
|
250
252
|
const { depositId, depositor } = deposit;
|
|
251
|
-
const speedups = this.speedUps[depositor]?.[depositId];
|
|
253
|
+
const speedups = this.speedUps[depositor]?.[depositId.toString()];
|
|
252
254
|
if (!isDefined(speedups) || speedups.length === 0) {
|
|
253
255
|
return deposit;
|
|
254
256
|
}
|
|
@@ -281,7 +283,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
281
283
|
* @param depositId The unique ID of the deposit being queried.
|
|
282
284
|
* @returns The corresponding deposit if found, undefined otherwise.
|
|
283
285
|
*/
|
|
284
|
-
public getDeposit(depositId:
|
|
286
|
+
public getDeposit(depositId: BigNumber): DepositWithBlock | undefined {
|
|
285
287
|
const depositHash = this.getDepositHash({ depositId, originChainId: this.chainId });
|
|
286
288
|
return this.depositHashes[depositHash];
|
|
287
289
|
}
|
|
@@ -311,7 +313,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
311
313
|
* Retrieves speed up requests grouped by depositor and depositId.
|
|
312
314
|
* @returns A mapping of depositor addresses to deposit ids with their corresponding speed up requests.
|
|
313
315
|
*/
|
|
314
|
-
public getSpeedUps(): { [depositorAddress: string]: { [depositId:
|
|
316
|
+
public getSpeedUps(): { [depositorAddress: string]: { [depositId: string]: SpeedUpWithBlock[] } } {
|
|
315
317
|
return this.speedUps;
|
|
316
318
|
}
|
|
317
319
|
|
|
@@ -329,7 +331,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
329
331
|
|
|
330
332
|
this.logger.debug({
|
|
331
333
|
at: "SpokePoolClient::getDepositForFill",
|
|
332
|
-
message: `Rejected fill for ${getNetworkName(fill.originChainId)} deposit ${fill.depositId}.`,
|
|
334
|
+
message: `Rejected fill for ${getNetworkName(fill.originChainId)} deposit ${fill.depositId.toString()}.`,
|
|
333
335
|
reason: match.reason,
|
|
334
336
|
deposit,
|
|
335
337
|
fill,
|
|
@@ -381,7 +383,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
381
383
|
);
|
|
382
384
|
|
|
383
385
|
// Log any invalid deposits with same deposit id but different params.
|
|
384
|
-
const invalidFillsForDeposit = invalidFills.filter((x) => x.depositId
|
|
386
|
+
const invalidFillsForDeposit = invalidFills.filter((x) => x.depositId.eq(deposit.depositId));
|
|
385
387
|
if (invalidFillsForDeposit.length > 0) {
|
|
386
388
|
this.logger.warn({
|
|
387
389
|
at: "SpokePoolClient",
|
|
@@ -412,8 +414,8 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
412
414
|
* @note This hash is used to match deposits and fills together.
|
|
413
415
|
* @note This hash takes the form of: `${depositId}-${originChainId}`.
|
|
414
416
|
*/
|
|
415
|
-
public getDepositHash(event: { depositId:
|
|
416
|
-
return `${event.depositId}-${event.originChainId}`;
|
|
417
|
+
public getDepositHash(event: { depositId: BigNumber; originChainId: number }): string {
|
|
418
|
+
return `${event.depositId.toString()}-${event.originChainId}`;
|
|
417
419
|
}
|
|
418
420
|
|
|
419
421
|
/**
|
|
@@ -421,7 +423,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
421
423
|
* @param blockTag The block number to search for the deposit ID at.
|
|
422
424
|
* @returns The deposit ID.
|
|
423
425
|
*/
|
|
424
|
-
public _getDepositIdAtBlock(blockTag: number): Promise<
|
|
426
|
+
public _getDepositIdAtBlock(blockTag: number): Promise<BigNumber> {
|
|
425
427
|
return getDepositIdAtBlock(this.spokePool as SpokePool, blockTag);
|
|
426
428
|
}
|
|
427
429
|
|
|
@@ -454,10 +456,11 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
454
456
|
*/
|
|
455
457
|
protected async _update(eventsToQuery: string[]): Promise<SpokePoolUpdate> {
|
|
456
458
|
// Find the earliest known depositId. This assumes no deposits were placed in the deployment block.
|
|
457
|
-
let firstDepositId
|
|
458
|
-
if (firstDepositId
|
|
459
|
+
let firstDepositId = this.firstDepositIdForSpokePool;
|
|
460
|
+
if (firstDepositId.eq(MAX_BIG_INT)) {
|
|
459
461
|
firstDepositId = await this.spokePool.numberOfDeposits({ blockTag: this.deploymentBlock });
|
|
460
|
-
|
|
462
|
+
firstDepositId = BigNumber.from(firstDepositId); // Cast input to a big number.
|
|
463
|
+
if (!BigNumber.isBigNumber(firstDepositId) || firstDepositId.lt(bnZero)) {
|
|
461
464
|
throw new Error(`SpokePoolClient::update: Invalid first deposit id (${firstDepositId})`);
|
|
462
465
|
}
|
|
463
466
|
}
|
|
@@ -507,9 +510,10 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
507
510
|
]);
|
|
508
511
|
this.log("debug", `Time to query new events from RPC for ${this.chainId}: ${Date.now() - timerStart} ms`);
|
|
509
512
|
|
|
510
|
-
const [currentTime,
|
|
513
|
+
const [currentTime, _numberOfDeposits] = multicallFunctions.map(
|
|
511
514
|
(fn, idx) => spokePool.interface.decodeFunctionResult(fn, multicallOutput[idx])[0]
|
|
512
515
|
);
|
|
516
|
+
const _latestDepositId = BigNumber.from(_numberOfDeposits).sub(bnOne);
|
|
513
517
|
|
|
514
518
|
if (!BigNumber.isBigNumber(currentTime) || currentTime.lt(this.currentTime)) {
|
|
515
519
|
const errMsg = BigNumber.isBigNumber(currentTime)
|
|
@@ -526,7 +530,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
526
530
|
currentTime: currentTime.toNumber(), // uint32
|
|
527
531
|
oldestTime: oldestTime.toNumber(),
|
|
528
532
|
firstDepositId,
|
|
529
|
-
latestDepositId:
|
|
533
|
+
latestDepositId: _latestDepositId.gt(bnZero) ? _latestDepositId : bnZero,
|
|
530
534
|
searchEndBlock: searchConfig.toBlock,
|
|
531
535
|
events,
|
|
532
536
|
};
|
|
@@ -596,10 +600,10 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
596
600
|
}
|
|
597
601
|
assign(this.depositHashes, [this.getDepositHash(deposit)], deposit);
|
|
598
602
|
|
|
599
|
-
if (deposit.depositId
|
|
603
|
+
if (deposit.depositId.lt(this.earliestDepositIdQueried) && !isUnsafeDepositId(deposit.depositId)) {
|
|
600
604
|
this.earliestDepositIdQueried = deposit.depositId;
|
|
601
605
|
}
|
|
602
|
-
if (deposit.depositId
|
|
606
|
+
if (deposit.depositId.gt(this.latestDepositIdQueried) && !isUnsafeDepositId(deposit.depositId)) {
|
|
603
607
|
this.latestDepositIdQueried = deposit.depositId;
|
|
604
608
|
}
|
|
605
609
|
}
|
|
@@ -611,7 +615,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
611
615
|
|
|
612
616
|
for (const event of speedUpEvents) {
|
|
613
617
|
const speedUp = { ...spreadEventWithBlockNumber(event), originChainId: this.chainId } as SpeedUpWithBlock;
|
|
614
|
-
assign(this.speedUps, [speedUp.depositor, speedUp.depositId], [speedUp]);
|
|
618
|
+
assign(this.speedUps, [speedUp.depositor, speedUp.depositId.toString()], [speedUp]);
|
|
615
619
|
|
|
616
620
|
// Find deposit hash matching this speed up event and update the deposit data associated with the hash,
|
|
617
621
|
// if the hash+data exists.
|
|
@@ -795,7 +799,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
795
799
|
return this.oldestTime;
|
|
796
800
|
}
|
|
797
801
|
|
|
798
|
-
async findDeposit(depositId:
|
|
802
|
+
async findDeposit(depositId: BigNumber, destinationChainId: number): Promise<DepositWithBlock> {
|
|
799
803
|
// Binary search for event search bounds. This way we can get the blocks before and after the deposit with
|
|
800
804
|
// deposit ID = fill.depositId and use those blocks to optimize the search for that deposit.
|
|
801
805
|
// Stop searches after a maximum # of searches to limit number of eth_call requests. Make an
|
|
@@ -824,12 +828,12 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
824
828
|
);
|
|
825
829
|
const tStop = Date.now();
|
|
826
830
|
|
|
827
|
-
const event = query.find(({ args }) => args["depositId"]
|
|
831
|
+
const event = query.find(({ args }) => args["depositId"].eq(depositId));
|
|
828
832
|
if (event === undefined) {
|
|
829
833
|
const srcChain = getNetworkName(this.chainId);
|
|
830
834
|
const dstChain = getNetworkName(destinationChainId);
|
|
831
835
|
throw new Error(
|
|
832
|
-
`Could not find deposit ${depositId} for ${dstChain} fill` +
|
|
836
|
+
`Could not find deposit ${depositId.toString()} for ${dstChain} fill` +
|
|
833
837
|
` between ${srcChain} blocks [${searchBounds.low}, ${searchBounds.high}]`
|
|
834
838
|
);
|
|
835
839
|
}
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
SlowFillLeaf,
|
|
15
15
|
SpeedUp,
|
|
16
16
|
} from "../../interfaces";
|
|
17
|
-
import { toBN, toBNWei, getCurrentTime, randomAddress } from "../../utils";
|
|
17
|
+
import { toBN, toBNWei, getCurrentTime, randomAddress, BigNumber, bnZero, bnOne, bnMax } from "../../utils";
|
|
18
18
|
import { SpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
|
|
19
19
|
import { HubPoolClient } from "../HubPoolClient";
|
|
20
20
|
import { EventManager, EventOverrides, getEventManager } from "./MockEvents";
|
|
@@ -26,8 +26,8 @@ export class MockSpokePoolClient extends SpokePoolClient {
|
|
|
26
26
|
public eventManager: EventManager;
|
|
27
27
|
private destinationTokenForChainOverride: Record<number, string> = {};
|
|
28
28
|
// Allow tester to set the numberOfDeposits() returned by SpokePool at a block height.
|
|
29
|
-
public depositIdAtBlock:
|
|
30
|
-
public numberOfDeposits =
|
|
29
|
+
public depositIdAtBlock: BigNumber[] = [];
|
|
30
|
+
public numberOfDeposits = bnZero;
|
|
31
31
|
|
|
32
32
|
constructor(
|
|
33
33
|
logger: winston.Logger,
|
|
@@ -57,21 +57,21 @@ export class MockSpokePoolClient extends SpokePoolClient {
|
|
|
57
57
|
this.latestBlockSearched = blockNumber;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
setDepositIds(_depositIds:
|
|
60
|
+
setDepositIds(_depositIds: BigNumber[]): void {
|
|
61
61
|
this.depositIdAtBlock = [];
|
|
62
62
|
if (_depositIds.length === 0) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
65
|
let lastDepositId = _depositIds[0];
|
|
66
66
|
for (let i = 0; i < _depositIds.length; i++) {
|
|
67
|
-
if (_depositIds[i]
|
|
67
|
+
if (_depositIds[i].lt(lastDepositId)) {
|
|
68
68
|
throw new Error("deposit ID must be equal to or greater than previous");
|
|
69
69
|
}
|
|
70
70
|
this.depositIdAtBlock[i] = _depositIds[i];
|
|
71
71
|
lastDepositId = _depositIds[i];
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
-
_getDepositIdAtBlock(blockTag: number): Promise<
|
|
74
|
+
_getDepositIdAtBlock(blockTag: number): Promise<BigNumber> {
|
|
75
75
|
return Promise.resolve(this.depositIdAtBlock[blockTag]);
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -96,13 +96,13 @@ export class MockSpokePoolClient extends SpokePoolClient {
|
|
|
96
96
|
// Update latestDepositIdQueried.
|
|
97
97
|
const idx = eventsToQuery.indexOf("V3FundsDeposited");
|
|
98
98
|
const latestDepositId = (events[idx] ?? []).reduce(
|
|
99
|
-
(depositId, event) =>
|
|
99
|
+
(depositId, event) => bnMax(depositId, event.args["depositId"] ?? bnZero),
|
|
100
100
|
this.latestDepositIdQueried
|
|
101
101
|
);
|
|
102
102
|
|
|
103
103
|
return Promise.resolve({
|
|
104
104
|
success: true,
|
|
105
|
-
firstDepositId:
|
|
105
|
+
firstDepositId: bnZero,
|
|
106
106
|
latestDepositId,
|
|
107
107
|
currentTime,
|
|
108
108
|
oldestTime: 0,
|
|
@@ -122,7 +122,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
|
|
|
122
122
|
const { blockNumber, transactionIndex } = deposit;
|
|
123
123
|
let { depositId, depositor, destinationChainId, inputToken, inputAmount, outputToken, outputAmount } = deposit;
|
|
124
124
|
depositId ??= this.numberOfDeposits;
|
|
125
|
-
this.numberOfDeposits = depositId
|
|
125
|
+
this.numberOfDeposits = depositId.add(bnOne);
|
|
126
126
|
|
|
127
127
|
destinationChainId ??= random(1, 42161, false);
|
|
128
128
|
depositor ??= randomAddress();
|
|
@@ -167,7 +167,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
|
|
|
167
167
|
const { blockNumber, transactionIndex } = fill;
|
|
168
168
|
let { originChainId, depositId, inputToken, inputAmount, outputAmount, fillDeadline, relayer } = fill;
|
|
169
169
|
originChainId ??= random(1, 42161, false);
|
|
170
|
-
depositId ??= random(1, 100_000, false);
|
|
170
|
+
depositId ??= BigNumber.from(random(1, 100_000, false));
|
|
171
171
|
inputToken ??= randomAddress();
|
|
172
172
|
inputAmount ??= toBNWei(random(1, 1000, false));
|
|
173
173
|
outputAmount ??= inputAmount;
|
package/src/constants.ts
CHANGED
|
@@ -10,7 +10,7 @@ export {
|
|
|
10
10
|
TOKEN_SYMBOLS_MAP,
|
|
11
11
|
} from "@across-protocol/constants";
|
|
12
12
|
|
|
13
|
-
export const { AddressZero: ZERO_ADDRESS } = ethersConstants;
|
|
13
|
+
export const { AddressZero: ZERO_ADDRESS, HashZero: ZERO_BYTES } = ethersConstants;
|
|
14
14
|
|
|
15
15
|
// 2^96 - 1 is a conservative erc20 max allowance.
|
|
16
16
|
export const MAX_SAFE_ALLOWANCE = "79228162514264337593543950335";
|
|
@@ -26,14 +26,16 @@ 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
|
|
|
35
37
|
// A hardcoded version number used, by default, to tag all Arweave records.
|
|
36
|
-
export const ARWEAVE_TAG_APP_VERSION =
|
|
38
|
+
export const ARWEAVE_TAG_APP_VERSION = 3;
|
|
37
39
|
|
|
38
40
|
/**
|
|
39
41
|
* A default list of chain Ids that the protocol supports. This is outlined
|
|
@@ -55,6 +57,8 @@ export const DEFAULT_ARWEAVE_STORAGE_ADDRESS = "Z6hjBM8FHu90lYWB8o5jR1dfX92FlV2W
|
|
|
55
57
|
|
|
56
58
|
export const EMPTY_MESSAGE = "0x";
|
|
57
59
|
|
|
60
|
+
export const EMPTY_MESSAGE_HASH = ethersConstants.HashZero;
|
|
61
|
+
|
|
58
62
|
export const BRIDGED_USDC_SYMBOLS = [
|
|
59
63
|
TOKEN_SYMBOLS_MAP["USDC.e"].symbol,
|
|
60
64
|
TOKEN_SYMBOLS_MAP.USDbC.symbol,
|
|
@@ -10,7 +10,7 @@ export interface RelayData {
|
|
|
10
10
|
originChainId: number;
|
|
11
11
|
depositor: string;
|
|
12
12
|
recipient: string;
|
|
13
|
-
depositId:
|
|
13
|
+
depositId: BigNumber;
|
|
14
14
|
inputToken: string;
|
|
15
15
|
inputAmount: BigNumber;
|
|
16
16
|
outputToken: string;
|
|
@@ -67,7 +67,7 @@ export interface FillWithBlock extends Fill, SortableEvent {}
|
|
|
67
67
|
export interface SpeedUp {
|
|
68
68
|
depositor: string;
|
|
69
69
|
depositorSignature: string;
|
|
70
|
-
depositId:
|
|
70
|
+
depositId: BigNumber;
|
|
71
71
|
originChainId: number;
|
|
72
72
|
updatedRecipient: string;
|
|
73
73
|
updatedOutputAmount: BigNumber;
|
package/src/providers/index.ts
CHANGED
|
@@ -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
|
+
}
|
|
@@ -62,3 +62,14 @@ export const toBN = (num: BigNumberish, rounding: "floor" | "round" | "ceil" = "
|
|
|
62
62
|
// Otherwise, it is a string int and we can parse it directly.
|
|
63
63
|
return BigNumber.from(num.toString());
|
|
64
64
|
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Compares two BigNumbers and returns the maximum. Order does not matter.
|
|
68
|
+
*
|
|
69
|
+
* @param val The first BigNumber to compare.
|
|
70
|
+
* @param cmp The second BigNumber to compare.
|
|
71
|
+
* @returns The greater of the two BigNumbers.
|
|
72
|
+
*/
|
|
73
|
+
export const bnMax = (val: BigNumber, cmp: BigNumber) => {
|
|
74
|
+
return val.gt(cmp) ? val : cmp;
|
|
75
|
+
};
|
|
@@ -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
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { SpokePoolClient } from "../clients";
|
|
3
|
-
import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE } from "../constants";
|
|
3
|
+
import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE, EMPTY_MESSAGE_HASH } from "../constants";
|
|
4
4
|
import { CachingMechanismInterface, Deposit, DepositWithBlock, Fill, SlowFillRequest } from "../interfaces";
|
|
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
|
}
|
|
@@ -52,16 +61,16 @@ export async function queryHistoricalDepositForFill(
|
|
|
52
61
|
|
|
53
62
|
const { depositId } = fill;
|
|
54
63
|
let { firstDepositIdForSpokePool: lowId, lastDepositIdForSpokePool: highId } = spokePoolClient;
|
|
55
|
-
if (depositId
|
|
64
|
+
if (depositId.lt(lowId) || depositId.gt(highId)) {
|
|
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
|
|
|
63
72
|
({ earliestDepositIdQueried: lowId, latestDepositIdQueried: highId } = spokePoolClient);
|
|
64
|
-
if (depositId
|
|
73
|
+
if (depositId.gte(lowId) && depositId.lte(highId)) {
|
|
65
74
|
const originChain = getNetworkName(fill.originChainId);
|
|
66
75
|
const deposit = spokePoolClient.getDeposit(depositId);
|
|
67
76
|
if (isDefined(deposit)) {
|
|
@@ -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
|
|
|
@@ -137,6 +146,10 @@ export function isZeroValueDeposit(deposit: Pick<Deposit, "inputAmount" | "messa
|
|
|
137
146
|
return deposit.inputAmount.eq(0) && isMessageEmpty(deposit.message);
|
|
138
147
|
}
|
|
139
148
|
|
|
149
|
+
export function isZeroValueFillOrSlowFillRequest(e: Pick<Fill | SlowFillRequest, "inputAmount" | "message">): boolean {
|
|
150
|
+
return e.inputAmount.eq(0) && isFillOrSlowFillRequestMessageEmpty(e.message);
|
|
151
|
+
}
|
|
152
|
+
|
|
140
153
|
/**
|
|
141
154
|
* Determines if a message is empty or not.
|
|
142
155
|
* @param message The message to check.
|
|
@@ -146,6 +159,10 @@ export function isMessageEmpty(message = EMPTY_MESSAGE): boolean {
|
|
|
146
159
|
return message === "" || message === "0x";
|
|
147
160
|
}
|
|
148
161
|
|
|
162
|
+
export function isFillOrSlowFillRequestMessageEmpty(message: string): boolean {
|
|
163
|
+
return isMessageEmpty(message) || message === EMPTY_MESSAGE_HASH;
|
|
164
|
+
}
|
|
165
|
+
|
|
149
166
|
/**
|
|
150
167
|
* Determines if a deposit was updated via a speed-up transaction.
|
|
151
168
|
* @param deposit Deposit to evaluate.
|
package/src/utils/EventUtils.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Result } from "@ethersproject/abi";
|
|
|
3
3
|
import { Contract, Event, EventFilter } from "ethers";
|
|
4
4
|
import { Log, SortableEvent } from "../interfaces";
|
|
5
5
|
import { delay } from "./common";
|
|
6
|
+
import { isDefined, toBN, BigNumberish } from "./";
|
|
6
7
|
|
|
7
8
|
const maxRetries = 3;
|
|
8
9
|
const retrySleepTime = 10;
|
|
@@ -58,6 +59,13 @@ export function spreadEvent(args: Result | Record<string, unknown>): { [key: str
|
|
|
58
59
|
if (returnedObject.rootBundleId) {
|
|
59
60
|
returnedObject.rootBundleId = Number(returnedObject.rootBundleId);
|
|
60
61
|
}
|
|
62
|
+
// If depositId is included in the event, cast it to a BigNumber. Need to check if it is defined since the deposit ID can
|
|
63
|
+
// be 0, which would still make this evaluate as false.
|
|
64
|
+
if (isDefined(returnedObject.depositId)) {
|
|
65
|
+
// Assuming a numeric output, we can safely cast the unknown to BigNumberish since the depositId will either be a uint32 (and therefore a TypeScript `number`),
|
|
66
|
+
// or a uint256 (and therefore an ethers BigNumber).
|
|
67
|
+
returnedObject.depositId = toBN(returnedObject.depositId as BigNumberish);
|
|
68
|
+
}
|
|
61
69
|
|
|
62
70
|
return returnedObject;
|
|
63
71
|
}
|
|
@@ -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.
|