@across-protocol/sdk 4.0.0-beta.28 → 4.0.0-beta.3
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 +4 -5
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +164 -326
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +1 -3
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +1 -33
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient.d.ts +0 -1
- package/dist/cjs/clients/SpokePoolClient.js +4 -13
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.js +2 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/providers/index.d.ts +0 -1
- package/dist/cjs/providers/index.js +0 -2
- package/dist/cjs/providers/index.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +0 -1
- package/dist/cjs/utils/AddressUtils.js +1 -14
- package/dist/cjs/utils/AddressUtils.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 +1 -2
- package/dist/cjs/utils/DepositUtils.js +4 -13
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.d.ts +0 -1
- package/dist/cjs/utils/NetworkUtils.js +1 -6
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.js +3 -3
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -5
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +188 -394
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +3 -2
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +1 -3
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +1 -42
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient.d.ts +0 -8
- package/dist/esm/clients/SpokePoolClient.js +4 -20
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +2 -2
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/providers/index.d.ts +0 -1
- package/dist/esm/providers/index.js +0 -2
- package/dist/esm/providers/index.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +0 -1
- package/dist/esm/utils/AddressUtils.js +0 -16
- package/dist/esm/utils/AddressUtils.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 +1 -2
- package/dist/esm/utils/DepositUtils.js +5 -14
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.d.ts +0 -6
- package/dist/esm/utils/NetworkUtils.js +0 -10
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.js +4 -4
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -5
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts +2 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +1 -3
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient.d.ts +0 -8
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/providers/index.d.ts +0 -1
- package/dist/types/providers/index.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +0 -1
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/DepositUtils.d.ts +1 -2
- package/dist/types/utils/DepositUtils.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts +0 -6
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +179 -395
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +8 -0
- package/src/clients/BundleDataClient/utils/FillUtils.ts +2 -47
- package/src/clients/SpokePoolClient.ts +6 -19
- package/src/constants.ts +3 -3
- package/src/providers/index.ts +0 -1
- package/src/utils/AddressUtils.ts +0 -16
- package/src/utils/CachingUtils.ts +1 -1
- package/src/utils/DepositUtils.ts +5 -14
- package/src/utils/NetworkUtils.ts +0 -11
- package/src/utils/SpokeUtils.ts +6 -6
- package/dist/cjs/providers/mockProvider.d.ts +0 -19
- package/dist/cjs/providers/mockProvider.js +0 -70
- package/dist/cjs/providers/mockProvider.js.map +0 -1
- package/dist/esm/providers/mockProvider.d.ts +0 -23
- package/dist/esm/providers/mockProvider.js +0 -73
- package/dist/esm/providers/mockProvider.js.map +0 -1
- package/dist/types/providers/mockProvider.d.ts +0 -24
- package/dist/types/providers/mockProvider.d.ts.map +0 -1
- package/src/providers/mockProvider.ts +0 -77
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
bnZero,
|
|
16
16
|
AnyObject,
|
|
17
|
+
groupObjectCountsByTwoProps,
|
|
17
18
|
fixedPointAdjustment,
|
|
18
19
|
count2DDictionaryValues,
|
|
19
20
|
count3DDictionaryValues,
|
|
@@ -25,6 +26,7 @@ import {
|
|
|
25
26
|
updateRunningBalance,
|
|
26
27
|
updateRunningBalanceForDeposit,
|
|
27
28
|
} from "./PoolRebalanceUtils";
|
|
29
|
+
import { V3FillWithBlock } from "./shims";
|
|
28
30
|
import { AcrossConfigStoreClient } from "../../AcrossConfigStoreClient";
|
|
29
31
|
import { HubPoolClient } from "../../HubPoolClient";
|
|
30
32
|
import { buildPoolRebalanceLeafTree } from "./MerkleTreeUtils";
|
|
@@ -81,6 +83,7 @@ export function getRefundsFromBundle(
|
|
|
81
83
|
export function prettyPrintV3SpokePoolEvents(
|
|
82
84
|
bundleDepositsV3: BundleDepositsV3,
|
|
83
85
|
bundleFillsV3: BundleFillsV3,
|
|
86
|
+
bundleInvalidFillsV3: V3FillWithBlock[],
|
|
84
87
|
bundleSlowFillsV3: BundleSlowFills,
|
|
85
88
|
expiredDepositsToRefundV3: ExpiredDepositsToRefundV3,
|
|
86
89
|
unexecutableSlowFills: BundleExcessSlowFills
|
|
@@ -91,6 +94,11 @@ export function prettyPrintV3SpokePoolEvents(
|
|
|
91
94
|
bundleSlowFillsV3: count2DDictionaryValues(bundleSlowFillsV3),
|
|
92
95
|
expiredDepositsToRefundV3: count2DDictionaryValues(expiredDepositsToRefundV3),
|
|
93
96
|
unexecutableSlowFills: count2DDictionaryValues(unexecutableSlowFills),
|
|
97
|
+
allInvalidFillsInRangeByDestinationChainAndRelayer: groupObjectCountsByTwoProps(
|
|
98
|
+
bundleInvalidFillsV3,
|
|
99
|
+
"destinationChainId",
|
|
100
|
+
(fill) => `${fill.relayer}`
|
|
101
|
+
),
|
|
94
102
|
};
|
|
95
103
|
}
|
|
96
104
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { DepositWithBlock, Fill, FillWithBlock } from "../../../interfaces";
|
|
4
|
-
import { getBlockRangeForChain, isSlowFill, chainIsEvm, isValidEvmAddress, isDefined } from "../../../utils";
|
|
1
|
+
import { Fill } from "../../../interfaces";
|
|
2
|
+
import { getBlockRangeForChain, isSlowFill } from "../../../utils";
|
|
5
3
|
import { HubPoolClient } from "../../HubPoolClient";
|
|
6
4
|
|
|
7
5
|
export function getRefundInformationFromFill(
|
|
@@ -46,46 +44,3 @@ export function getRefundInformationFromFill(
|
|
|
46
44
|
repaymentToken,
|
|
47
45
|
};
|
|
48
46
|
}
|
|
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,18 +135,6 @@ 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
|
-
private _getDuplicateDeposits(deposit: DepositWithBlock): DepositWithBlock[] {
|
|
146
|
-
const depositHash = this.getDepositHash(deposit);
|
|
147
|
-
return this.duplicateDepositHashes[depositHash] ?? [];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
138
|
/**
|
|
151
139
|
* Returns a list of all deposits including any duplicate ones. Designed only to be used in use cases where
|
|
152
140
|
* all deposits are required, regardless of duplicates. For example, the Dataworker can use this to refund
|
|
@@ -156,10 +144,9 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
156
144
|
*/
|
|
157
145
|
public getDepositsForDestinationChainWithDuplicates(destinationChainId: number): DepositWithBlock[] {
|
|
158
146
|
const deposits = this.getDepositsForDestinationChain(destinationChainId);
|
|
159
|
-
const duplicateDeposits =
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}, [] as DepositWithBlock[]);
|
|
147
|
+
const duplicateDeposits = Object.values(this.duplicateDepositHashes).filter(
|
|
148
|
+
(deposits) => deposits.length > 0 && deposits[0].destinationChainId === destinationChainId
|
|
149
|
+
);
|
|
163
150
|
return sortEventsAscendingInPlace(deposits.concat(duplicateDeposits.flat()));
|
|
164
151
|
}
|
|
165
152
|
|
|
@@ -344,7 +331,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
344
331
|
|
|
345
332
|
this.logger.debug({
|
|
346
333
|
at: "SpokePoolClient::getDepositForFill",
|
|
347
|
-
message: `Rejected fill for ${getNetworkName(fill.originChainId)} deposit ${fill.depositId
|
|
334
|
+
message: `Rejected fill for ${getNetworkName(fill.originChainId)} deposit ${fill.depositId}.`,
|
|
348
335
|
reason: match.reason,
|
|
349
336
|
deposit,
|
|
350
337
|
fill,
|
|
@@ -428,7 +415,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
428
415
|
* @note This hash takes the form of: `${depositId}-${originChainId}`.
|
|
429
416
|
*/
|
|
430
417
|
public getDepositHash(event: { depositId: BigNumber; originChainId: number }): string {
|
|
431
|
-
return `${event.depositId
|
|
418
|
+
return `${event.depositId}-${event.originChainId}`;
|
|
432
419
|
}
|
|
433
420
|
|
|
434
421
|
/**
|
|
@@ -846,7 +833,7 @@ export class SpokePoolClient extends BaseAbstractClient {
|
|
|
846
833
|
const srcChain = getNetworkName(this.chainId);
|
|
847
834
|
const dstChain = getNetworkName(destinationChainId);
|
|
848
835
|
throw new Error(
|
|
849
|
-
`Could not find deposit ${depositId
|
|
836
|
+
`Could not find deposit ${depositId} for ${dstChain} fill` +
|
|
850
837
|
` between ${srcChain} blocks [${searchBounds.low}, ${searchBounds.high}]`
|
|
851
838
|
);
|
|
852
839
|
}
|
package/src/constants.ts
CHANGED
|
@@ -26,11 +26,9 @@ 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
|
|
30
30
|
export const TRANSFER_THRESHOLD_MAX_CONFIG_STORE_VERSION = 1;
|
|
31
31
|
|
|
32
|
-
export const PRE_FILL_MIN_CONFIG_STORE_VERSION = 5;
|
|
33
|
-
|
|
34
32
|
// A hardcoded identifier used, by default, to tag all Arweave records.
|
|
35
33
|
export const ARWEAVE_TAG_APP_NAME = "across-protocol";
|
|
36
34
|
|
|
@@ -57,6 +55,8 @@ export const DEFAULT_ARWEAVE_STORAGE_ADDRESS = "Z6hjBM8FHu90lYWB8o5jR1dfX92FlV2W
|
|
|
57
55
|
|
|
58
56
|
export const EMPTY_MESSAGE = "0x";
|
|
59
57
|
|
|
58
|
+
export const EMPTY_MESSAGE_HASH = ethersConstants.HashZero;
|
|
59
|
+
|
|
60
60
|
export const BRIDGED_USDC_SYMBOLS = [
|
|
61
61
|
TOKEN_SYMBOLS_MAP["USDC.e"].symbol,
|
|
62
62
|
TOKEN_SYMBOLS_MAP.USDbC.symbol,
|
package/src/providers/index.ts
CHANGED
|
@@ -38,19 +38,3 @@ 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
|
|
55
|
+
return `deposit_${bridgeEvent.originChainId}_${bridgeEvent.depositId}_${relayHash}`;
|
|
56
56
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { SpokePoolClient } from "../clients";
|
|
3
|
-
import { DEFAULT_CACHING_TTL, EMPTY_MESSAGE,
|
|
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";
|
|
9
8
|
import { getCurrentTime } from "./TimeUtils";
|
|
10
9
|
import { isDefined } from "./TypeGuards";
|
|
11
10
|
import { isDepositFormedCorrectly } from "./ValidatorUtils";
|
|
@@ -18,7 +17,6 @@ export enum InvalidFill {
|
|
|
18
17
|
DepositIdInvalid = 0, // Deposit ID seems invalid for origin SpokePool
|
|
19
18
|
DepositIdNotFound, // Deposit ID not found (bad RPC data?)
|
|
20
19
|
FillMismatch, // Fill does not match deposit parameters for deposit ID.
|
|
21
|
-
DepositIdOutOfRange, // Fill is for a deterministic deposit.
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
export type DepositSearchResult =
|
|
@@ -42,13 +40,6 @@ export async function queryHistoricalDepositForFill(
|
|
|
42
40
|
fill: Fill | SlowFillRequest,
|
|
43
41
|
cache?: CachingMechanismInterface
|
|
44
42
|
): 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
|
-
}
|
|
52
43
|
if (fill.originChainId !== spokePoolClient.chainId) {
|
|
53
44
|
throw new Error(`OriginChainId mismatch (${fill.originChainId} != ${spokePoolClient.chainId})`);
|
|
54
45
|
}
|
|
@@ -65,7 +56,7 @@ export async function queryHistoricalDepositForFill(
|
|
|
65
56
|
return {
|
|
66
57
|
found: false,
|
|
67
58
|
code: InvalidFill.DepositIdInvalid,
|
|
68
|
-
reason: `Deposit ID ${depositId
|
|
59
|
+
reason: `Deposit ID ${depositId} is outside of SpokePool bounds [${lowId},${highId}].`,
|
|
69
60
|
};
|
|
70
61
|
}
|
|
71
62
|
|
|
@@ -82,14 +73,14 @@ export async function queryHistoricalDepositForFill(
|
|
|
82
73
|
return {
|
|
83
74
|
found: false,
|
|
84
75
|
code: InvalidFill.FillMismatch,
|
|
85
|
-
reason: `Fill for ${originChain} deposit ID ${depositId
|
|
76
|
+
reason: `Fill for ${originChain} deposit ID ${depositId} is invalid (${match.reason}).`,
|
|
86
77
|
};
|
|
87
78
|
}
|
|
88
79
|
|
|
89
80
|
return {
|
|
90
81
|
found: false,
|
|
91
82
|
code: InvalidFill.DepositIdNotFound,
|
|
92
|
-
reason: `${originChain} deposit ID ${depositId
|
|
83
|
+
reason: `${originChain} deposit ID ${depositId} not found in SpokePoolClient event buffer.`,
|
|
93
84
|
};
|
|
94
85
|
}
|
|
95
86
|
|
|
@@ -160,7 +151,7 @@ export function isMessageEmpty(message = EMPTY_MESSAGE): boolean {
|
|
|
160
151
|
}
|
|
161
152
|
|
|
162
153
|
export function isFillOrSlowFillRequestMessageEmpty(message: string): boolean {
|
|
163
|
-
return isMessageEmpty(message) || message ===
|
|
154
|
+
return isMessageEmpty(message) || message === EMPTY_MESSAGE_HASH;
|
|
164
155
|
}
|
|
165
156
|
|
|
166
157
|
/**
|
|
@@ -123,17 +123,6 @@ 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
|
-
|
|
137
126
|
/**
|
|
138
127
|
* Determines whether a chain ID has the capacity for having its USDC bridged via CCTP.
|
|
139
128
|
* @param chainId Chain ID to evaluate.
|
package/src/utils/SpokeUtils.ts
CHANGED
|
@@ -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
|
|
157
|
+
`Target depositId is less than the initial low block (${targetDepositId} > ${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 greater than or equal to zero.
|
|
212
|
+
// Sanity check to ensure that the deposit ID is an integer and is greater than or equal to zero.
|
|
213
213
|
if (depositIdAtBlock.lt(bnZero)) {
|
|
214
214
|
throw new Error("Invalid deposit count");
|
|
215
215
|
}
|
|
@@ -281,9 +281,7 @@ 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(
|
|
285
|
-
`relayFillStatus: Unexpected fillStatus for ${originChainId} deposit ${depositId.toString()} (${fillStatus})`
|
|
286
|
-
);
|
|
284
|
+
throw new Error(`relayFillStatus: Unexpected fillStatus for ${originChainId} deposit ${depositId} (${fillStatus})`);
|
|
287
285
|
}
|
|
288
286
|
|
|
289
287
|
return fillStatus;
|
|
@@ -347,6 +345,7 @@ export async function findFillBlock(
|
|
|
347
345
|
// In production the chainId returned from the provider matches 1:1 with the actual chainId. Querying the provider
|
|
348
346
|
// object saves an RPC query becasue the chainId is cached by StaticJsonRpcProvider instances. In hre, the SpokePool
|
|
349
347
|
// 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
|
|
350
349
|
const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
|
|
351
350
|
? (await provider.getNetwork()).chainId
|
|
352
351
|
: Number(await spokePool.chainId());
|
|
@@ -371,7 +370,7 @@ export async function findFillBlock(
|
|
|
371
370
|
if (initialFillStatus === FillStatus.Filled) {
|
|
372
371
|
const { depositId, originChainId } = relayData;
|
|
373
372
|
const [srcChain, dstChain] = [getNetworkName(originChainId), getNetworkName(destinationChainId)];
|
|
374
|
-
throw new Error(`${srcChain} deposit ${depositId
|
|
373
|
+
throw new Error(`${srcChain} deposit ${depositId} filled on ${dstChain} before block ${lowBlockNumber}`);
|
|
375
374
|
}
|
|
376
375
|
|
|
377
376
|
// Find the leftmost block where filledAmount equals the deposit amount.
|
|
@@ -412,6 +411,7 @@ export async function findFillEvent(
|
|
|
412
411
|
// In production the chainId returned from the provider matches 1:1 with the actual chainId. Querying the provider
|
|
413
412
|
// object saves an RPC query becasue the chainId is cached by StaticJsonRpcProvider instances. In hre, the SpokePool
|
|
414
413
|
// may be configured with a different chainId than what is returned by the provider.
|
|
414
|
+
// @todo Sub out actual chain IDs w/ CHAIN_IDs constants
|
|
415
415
|
const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
|
|
416
416
|
? (await spokePool.provider.getNetwork()).chainId
|
|
417
417
|
: Number(await spokePool.chainId());
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { BigNumber, providers } from "ethers";
|
|
2
|
-
import { Block, BlockTag, FeeData, TransactionResponse } from "@ethersproject/abstract-provider";
|
|
3
|
-
export declare class MockedProvider extends providers.StaticJsonRpcProvider {
|
|
4
|
-
readonly stdLastBaseFeePerGas: BigNumber;
|
|
5
|
-
readonly stdMaxPriorityFeePerGas: BigNumber;
|
|
6
|
-
readonly defaultChainId: number;
|
|
7
|
-
private transactions;
|
|
8
|
-
constructor(stdLastBaseFeePerGas: BigNumber, stdMaxPriorityFeePerGas: BigNumber, defaultChainId?: number);
|
|
9
|
-
getBlock(_blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
|
|
10
|
-
send(method: string, _params: Array<any>): Promise<any>;
|
|
11
|
-
getFeeData(): Promise<FeeData>;
|
|
12
|
-
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
13
|
-
getGasPrice(): Promise<BigNumber>;
|
|
14
|
-
getNetwork(): Promise<{
|
|
15
|
-
chainId: number;
|
|
16
|
-
name: string;
|
|
17
|
-
}>;
|
|
18
|
-
_setTransaction(hash: string, transaction: TransactionResponse): void;
|
|
19
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MockedProvider = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
var ethers_1 = require("ethers");
|
|
6
|
-
var BigNumberUtils_1 = require("../utils/BigNumberUtils");
|
|
7
|
-
var MockedProvider = (function (_super) {
|
|
8
|
-
tslib_1.__extends(MockedProvider, _super);
|
|
9
|
-
function MockedProvider(stdLastBaseFeePerGas, stdMaxPriorityFeePerGas, defaultChainId) {
|
|
10
|
-
if (defaultChainId === void 0) { defaultChainId = 1; }
|
|
11
|
-
var _this = _super.call(this, undefined, defaultChainId) || this;
|
|
12
|
-
_this.stdLastBaseFeePerGas = stdLastBaseFeePerGas;
|
|
13
|
-
_this.stdMaxPriorityFeePerGas = stdMaxPriorityFeePerGas;
|
|
14
|
-
_this.defaultChainId = defaultChainId;
|
|
15
|
-
_this.transactions = {};
|
|
16
|
-
return _this;
|
|
17
|
-
}
|
|
18
|
-
MockedProvider.prototype.getBlock = function (_blockHashOrBlockTag) {
|
|
19
|
-
var mockBlock = {
|
|
20
|
-
transactions: [],
|
|
21
|
-
hash: "0x",
|
|
22
|
-
parentHash: "0x",
|
|
23
|
-
number: 0,
|
|
24
|
-
nonce: "0",
|
|
25
|
-
difficulty: 0,
|
|
26
|
-
_difficulty: BigNumberUtils_1.bnZero,
|
|
27
|
-
timestamp: 0,
|
|
28
|
-
gasLimit: BigNumberUtils_1.bnZero,
|
|
29
|
-
gasUsed: BigNumberUtils_1.bnZero,
|
|
30
|
-
baseFeePerGas: this.stdLastBaseFeePerGas,
|
|
31
|
-
miner: "0x",
|
|
32
|
-
extraData: "0x",
|
|
33
|
-
};
|
|
34
|
-
return Promise.resolve(mockBlock);
|
|
35
|
-
};
|
|
36
|
-
MockedProvider.prototype.send = function (method, _params) {
|
|
37
|
-
switch (method) {
|
|
38
|
-
case "eth_maxPriorityFeePerGas":
|
|
39
|
-
return Promise.resolve(this.stdMaxPriorityFeePerGas);
|
|
40
|
-
default:
|
|
41
|
-
throw new Error("MockedProvider#Unimplemented method: ".concat(method));
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
MockedProvider.prototype.getFeeData = function () {
|
|
45
|
-
return Promise.resolve({
|
|
46
|
-
lastBaseFeePerGas: this.stdLastBaseFeePerGas,
|
|
47
|
-
maxPriorityFeePerGas: this.stdMaxPriorityFeePerGas,
|
|
48
|
-
maxFeePerGas: null,
|
|
49
|
-
gasPrice: null,
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
MockedProvider.prototype.getTransaction = function (hash) {
|
|
53
|
-
return Promise.resolve(this.transactions[hash]);
|
|
54
|
-
};
|
|
55
|
-
MockedProvider.prototype.getGasPrice = function () {
|
|
56
|
-
return Promise.resolve(this.stdLastBaseFeePerGas.add(this.stdMaxPriorityFeePerGas));
|
|
57
|
-
};
|
|
58
|
-
MockedProvider.prototype.getNetwork = function () {
|
|
59
|
-
return Promise.resolve({
|
|
60
|
-
name: "mocknetwork",
|
|
61
|
-
chainId: this.defaultChainId,
|
|
62
|
-
});
|
|
63
|
-
};
|
|
64
|
-
MockedProvider.prototype._setTransaction = function (hash, transaction) {
|
|
65
|
-
this.transactions[hash] = transaction;
|
|
66
|
-
};
|
|
67
|
-
return MockedProvider;
|
|
68
|
-
}(ethers_1.providers.StaticJsonRpcProvider));
|
|
69
|
-
exports.MockedProvider = MockedProvider;
|
|
70
|
-
//# sourceMappingURL=mockProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockProvider.js","sourceRoot":"","sources":["../../../src/providers/mockProvider.ts"],"names":[],"mappings":";;;;AAAA,iCAA8C;AAE9C,0DAAiD;AAMjD;IAAoC,0CAA+B;IAGjE,wBACW,oBAA+B,EAC/B,uBAAkC,EAClC,cAAkB;QAAlB,+BAAA,EAAA,kBAAkB;QAH7B,YAKE,kBAAM,SAAS,EAAE,cAAc,CAAC,SACjC;QALU,0BAAoB,GAApB,oBAAoB,CAAW;QAC/B,6BAAuB,GAAvB,uBAAuB,CAAW;QAClC,oBAAc,GAAd,cAAc,CAAI;QALrB,kBAAY,GAA4C,EAAE,CAAC;;IAQnE,CAAC;IAED,iCAAQ,GAAR,UAAS,oBAAoE;QAC3E,IAAM,SAAS,GAAU;YACvB,YAAY,EAAE,EAAE;YAChB,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,GAAG;YACV,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,uBAAM;YACnB,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,uBAAM;YAChB,OAAO,EAAE,uBAAM;YACf,aAAa,EAAE,IAAI,CAAC,oBAAoB;YACxC,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;SAChB,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAGD,6BAAI,GAAJ,UAAK,MAAc,EAAE,OAAmB;QACtC,QAAQ,MAAM,EAAE;YACd,KAAK,0BAA0B;gBAC7B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACvD;gBACE,MAAM,IAAI,KAAK,CAAC,+CAAwC,MAAM,CAAE,CAAC,CAAC;SACrE;IACH,CAAC;IAED,mCAAU,GAAV;QACE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,iBAAiB,EAAE,IAAI,CAAC,oBAAoB;YAC5C,oBAAoB,EAAE,IAAI,CAAC,uBAAuB;YAElD,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED,uCAAc,GAAd,UAAe,IAAY;QACzB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,oCAAW,GAAX;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,mCAAU,GAAV;QACE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,IAAI,CAAC,cAAc;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,wCAAe,GAAf,UAAgB,IAAY,EAAE,WAAgC;QAC5D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACxC,CAAC;IACH,qBAAC;AAAD,CAAC,AApED,CAAoC,kBAAS,CAAC,qBAAqB,GAoElE;AApEY,wCAAc"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BigNumber, providers } from "ethers";
|
|
2
|
-
import { Block, BlockTag, FeeData, TransactionResponse } from "@ethersproject/abstract-provider";
|
|
3
|
-
/**
|
|
4
|
-
* @notice Class used to test GasPriceOracle which makes ethers provider calls to the following implemented
|
|
5
|
-
* methods.
|
|
6
|
-
*/
|
|
7
|
-
export declare class MockedProvider extends providers.StaticJsonRpcProvider {
|
|
8
|
-
readonly stdLastBaseFeePerGas: BigNumber;
|
|
9
|
-
readonly stdMaxPriorityFeePerGas: BigNumber;
|
|
10
|
-
readonly defaultChainId: number;
|
|
11
|
-
private transactions;
|
|
12
|
-
constructor(stdLastBaseFeePerGas: BigNumber, stdMaxPriorityFeePerGas: BigNumber, defaultChainId?: number);
|
|
13
|
-
getBlock(_blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
|
|
14
|
-
send(method: string, _params: Array<any>): Promise<any>;
|
|
15
|
-
getFeeData(): Promise<FeeData>;
|
|
16
|
-
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
17
|
-
getGasPrice(): Promise<BigNumber>;
|
|
18
|
-
getNetwork(): Promise<{
|
|
19
|
-
chainId: number;
|
|
20
|
-
name: string;
|
|
21
|
-
}>;
|
|
22
|
-
_setTransaction(hash: string, transaction: TransactionResponse): void;
|
|
23
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { __extends } from "tslib";
|
|
2
|
-
import { providers } from "ethers";
|
|
3
|
-
import { bnZero } from "../utils/BigNumberUtils";
|
|
4
|
-
/**
|
|
5
|
-
* @notice Class used to test GasPriceOracle which makes ethers provider calls to the following implemented
|
|
6
|
-
* methods.
|
|
7
|
-
*/
|
|
8
|
-
var MockedProvider = /** @class */ (function (_super) {
|
|
9
|
-
__extends(MockedProvider, _super);
|
|
10
|
-
function MockedProvider(stdLastBaseFeePerGas, stdMaxPriorityFeePerGas, defaultChainId) {
|
|
11
|
-
if (defaultChainId === void 0) { defaultChainId = 1; }
|
|
12
|
-
var _this = _super.call(this, undefined, defaultChainId) || this;
|
|
13
|
-
_this.stdLastBaseFeePerGas = stdLastBaseFeePerGas;
|
|
14
|
-
_this.stdMaxPriorityFeePerGas = stdMaxPriorityFeePerGas;
|
|
15
|
-
_this.defaultChainId = defaultChainId;
|
|
16
|
-
_this.transactions = {};
|
|
17
|
-
return _this;
|
|
18
|
-
}
|
|
19
|
-
MockedProvider.prototype.getBlock = function (_blockHashOrBlockTag) {
|
|
20
|
-
var mockBlock = {
|
|
21
|
-
transactions: [],
|
|
22
|
-
hash: "0x",
|
|
23
|
-
parentHash: "0x",
|
|
24
|
-
number: 0,
|
|
25
|
-
nonce: "0",
|
|
26
|
-
difficulty: 0,
|
|
27
|
-
_difficulty: bnZero,
|
|
28
|
-
timestamp: 0,
|
|
29
|
-
gasLimit: bnZero,
|
|
30
|
-
gasUsed: bnZero,
|
|
31
|
-
baseFeePerGas: this.stdLastBaseFeePerGas,
|
|
32
|
-
miner: "0x",
|
|
33
|
-
extraData: "0x",
|
|
34
|
-
};
|
|
35
|
-
return Promise.resolve(mockBlock);
|
|
36
|
-
};
|
|
37
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
38
|
-
MockedProvider.prototype.send = function (method, _params) {
|
|
39
|
-
switch (method) {
|
|
40
|
-
case "eth_maxPriorityFeePerGas":
|
|
41
|
-
return Promise.resolve(this.stdMaxPriorityFeePerGas);
|
|
42
|
-
default:
|
|
43
|
-
throw new Error("MockedProvider#Unimplemented method: ".concat(method));
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
MockedProvider.prototype.getFeeData = function () {
|
|
47
|
-
return Promise.resolve({
|
|
48
|
-
lastBaseFeePerGas: this.stdLastBaseFeePerGas,
|
|
49
|
-
maxPriorityFeePerGas: this.stdMaxPriorityFeePerGas,
|
|
50
|
-
// Following fields unused in GasPrice oracle
|
|
51
|
-
maxFeePerGas: null,
|
|
52
|
-
gasPrice: null,
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
MockedProvider.prototype.getTransaction = function (hash) {
|
|
56
|
-
return Promise.resolve(this.transactions[hash]);
|
|
57
|
-
};
|
|
58
|
-
MockedProvider.prototype.getGasPrice = function () {
|
|
59
|
-
return Promise.resolve(this.stdLastBaseFeePerGas.add(this.stdMaxPriorityFeePerGas));
|
|
60
|
-
};
|
|
61
|
-
MockedProvider.prototype.getNetwork = function () {
|
|
62
|
-
return Promise.resolve({
|
|
63
|
-
name: "mocknetwork",
|
|
64
|
-
chainId: this.defaultChainId,
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
MockedProvider.prototype._setTransaction = function (hash, transaction) {
|
|
68
|
-
this.transactions[hash] = transaction;
|
|
69
|
-
};
|
|
70
|
-
return MockedProvider;
|
|
71
|
-
}(providers.StaticJsonRpcProvider));
|
|
72
|
-
export { MockedProvider };
|
|
73
|
-
//# sourceMappingURL=mockProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockProvider.js","sourceRoot":"","sources":["../../../src/providers/mockProvider.ts"],"names":[],"mappings":";AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD;;;GAGG;AACH;IAAoC,kCAA+B;IAGjE,wBACW,oBAA+B,EAC/B,uBAAkC,EAClC,cAAkB;QAAlB,+BAAA,EAAA,kBAAkB;QAH7B,YAKE,kBAAM,SAAS,EAAE,cAAc,CAAC,SACjC;QALU,0BAAoB,GAApB,oBAAoB,CAAW;QAC/B,6BAAuB,GAAvB,uBAAuB,CAAW;QAClC,oBAAc,GAAd,cAAc,CAAI;QALrB,kBAAY,GAA4C,EAAE,CAAC;;IAQnE,CAAC;IAED,iCAAQ,GAAR,UAAS,oBAAoE;QAC3E,IAAM,SAAS,GAAU;YACvB,YAAY,EAAE,EAAE;YAChB,IAAI,EAAE,IAAI;YACV,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,GAAG;YACV,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,MAAM;YACnB,SAAS,EAAE,CAAC;YACZ,QAAQ,EAAE,MAAM;YAChB,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,IAAI,CAAC,oBAAoB;YACxC,KAAK,EAAE,IAAI;YACX,SAAS,EAAE,IAAI;SAChB,CAAC;QACF,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,8DAA8D;IAC9D,6BAAI,GAAJ,UAAK,MAAc,EAAE,OAAmB;QACtC,QAAQ,MAAM,EAAE;YACd,KAAK,0BAA0B;gBAC7B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;YACvD;gBACE,MAAM,IAAI,KAAK,CAAC,+CAAwC,MAAM,CAAE,CAAC,CAAC;SACrE;IACH,CAAC;IAED,mCAAU,GAAV;QACE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,iBAAiB,EAAE,IAAI,CAAC,oBAAoB;YAC5C,oBAAoB,EAAE,IAAI,CAAC,uBAAuB;YAClD,6CAA6C;YAC7C,YAAY,EAAE,IAAI;YAClB,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;IACL,CAAC;IAED,uCAAc,GAAd,UAAe,IAAY;QACzB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,oCAAW,GAAX;QACE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC;IACtF,CAAC;IAED,mCAAU,GAAV;QACE,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,IAAI,EAAE,aAAa;YACnB,OAAO,EAAE,IAAI,CAAC,cAAc;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,wCAAe,GAAf,UAAgB,IAAY,EAAE,WAAgC;QAC5D,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC;IACxC,CAAC;IACH,qBAAC;AAAD,CAAC,AApED,CAAoC,SAAS,CAAC,qBAAqB,GAoElE"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BigNumber, providers } from "ethers";
|
|
2
|
-
import { Block, BlockTag, FeeData, TransactionResponse } from "@ethersproject/abstract-provider";
|
|
3
|
-
/**
|
|
4
|
-
* @notice Class used to test GasPriceOracle which makes ethers provider calls to the following implemented
|
|
5
|
-
* methods.
|
|
6
|
-
*/
|
|
7
|
-
export declare class MockedProvider extends providers.StaticJsonRpcProvider {
|
|
8
|
-
readonly stdLastBaseFeePerGas: BigNumber;
|
|
9
|
-
readonly stdMaxPriorityFeePerGas: BigNumber;
|
|
10
|
-
readonly defaultChainId: number;
|
|
11
|
-
private transactions;
|
|
12
|
-
constructor(stdLastBaseFeePerGas: BigNumber, stdMaxPriorityFeePerGas: BigNumber, defaultChainId?: number);
|
|
13
|
-
getBlock(_blockHashOrBlockTag: BlockTag | string | Promise<BlockTag | string>): Promise<Block>;
|
|
14
|
-
send(method: string, _params: Array<any>): Promise<any>;
|
|
15
|
-
getFeeData(): Promise<FeeData>;
|
|
16
|
-
getTransaction(hash: string): Promise<TransactionResponse>;
|
|
17
|
-
getGasPrice(): Promise<BigNumber>;
|
|
18
|
-
getNetwork(): Promise<{
|
|
19
|
-
chainId: number;
|
|
20
|
-
name: string;
|
|
21
|
-
}>;
|
|
22
|
-
_setTransaction(hash: string, transaction: TransactionResponse): void;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=mockProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mockProvider.d.ts","sourceRoot":"","sources":["../../../src/providers/mockProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAGjG;;;GAGG;AACH,qBAAa,cAAe,SAAQ,SAAS,CAAC,qBAAqB;IAI/D,QAAQ,CAAC,oBAAoB,EAAE,SAAS;IACxC,QAAQ,CAAC,uBAAuB,EAAE,SAAS;IAC3C,QAAQ,CAAC,cAAc;IALzB,OAAO,CAAC,YAAY,CAA+C;gBAGxD,oBAAoB,EAAE,SAAS,EAC/B,uBAAuB,EAAE,SAAS,EAClC,cAAc,SAAI;IAK7B,QAAQ,CAAC,oBAAoB,EAAE,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC;IAoB9F,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IASvD,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAU9B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAI1D,WAAW,IAAI,OAAO,CAAC,SAAS,CAAC;IAIjC,UAAU,IAAI,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAOxD,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB;CAG/D"}
|
|
@@ -1,77 +0,0 @@
|
|
|
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
|
-
}
|