@across-protocol/sdk 4.0.0-beta.34 → 4.0.0-beta.4
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 +175 -355
- 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 -5
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +1 -47
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +4 -4
- package/dist/cjs/clients/SpokePoolClient.d.ts +0 -1
- package/dist/cjs/clients/SpokePoolClient.js +1 -10
- package/dist/cjs/clients/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +1 -2
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +1 -11
- package/dist/cjs/clients/mocks/MockSpokePoolClient.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 -2
- package/dist/cjs/utils/AddressUtils.js +1 -19
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/DepositUtils.d.ts +1 -2
- package/dist/cjs/utils/DepositUtils.js +1 -10
- package/dist/cjs/utils/DepositUtils.js.map +1 -1
- package/dist/cjs/utils/EventUtils.js +0 -21
- package/dist/cjs/utils/EventUtils.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.d.ts +0 -1
- package/dist/cjs/utils/SpokeUtils.js +8 -15
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/common.d.ts +0 -1
- package/dist/cjs/utils/common.js +1 -2
- package/dist/cjs/utils/common.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -5
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +257 -459
- 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 -5
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +1 -54
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +4 -4
- package/dist/esm/clients/SpokePoolClient.d.ts +0 -8
- package/dist/esm/clients/SpokePoolClient.js +1 -17
- package/dist/esm/clients/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +1 -2
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +1 -11
- package/dist/esm/clients/mocks/MockSpokePoolClient.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 -2
- package/dist/esm/utils/AddressUtils.js +0 -25
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/DepositUtils.d.ts +1 -2
- package/dist/esm/utils/DepositUtils.js +2 -11
- package/dist/esm/utils/DepositUtils.js.map +1 -1
- package/dist/esm/utils/EventUtils.js +1 -29
- package/dist/esm/utils/EventUtils.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.d.ts +0 -1
- package/dist/esm/utils/SpokeUtils.js +8 -14
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/common.d.ts +0 -1
- package/dist/esm/utils/common.js +0 -1
- package/dist/esm/utils/common.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 -5
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +4 -4
- package/dist/types/clients/SpokePoolClient.d.ts +0 -8
- package/dist/types/clients/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +1 -2
- package/dist/types/clients/mocks/MockSpokePoolClient.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 -2
- 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/EventUtils.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 +0 -1
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/common.d.ts +0 -1
- package/dist/types/utils/common.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/clients/BundleDataClient/BundleDataClient.ts +227 -433
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +8 -0
- package/src/clients/BundleDataClient/utils/FillUtils.ts +2 -66
- package/src/clients/SpokePoolClient.ts +3 -16
- package/src/clients/mocks/MockSpokePoolClient.ts +1 -14
- package/src/constants.ts +3 -3
- package/src/providers/index.ts +0 -1
- package/src/utils/AddressUtils.ts +0 -26
- package/src/utils/DepositUtils.ts +2 -11
- package/src/utils/EventUtils.ts +1 -29
- package/src/utils/NetworkUtils.ts +0 -11
- package/src/utils/SpokeUtils.ts +9 -22
- package/src/utils/common.ts +0 -2
- 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 { Deposit, 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,65 +44,3 @@ export function getRefundInformationFromFill(
|
|
|
46
44
|
repaymentToken,
|
|
47
45
|
};
|
|
48
46
|
}
|
|
49
|
-
|
|
50
|
-
export function getRepaymentChainId(fill: Fill, matchedDeposit: Deposit): number {
|
|
51
|
-
// Lite chain deposits force repayment on origin chain.
|
|
52
|
-
return matchedDeposit.fromLiteChain ? fill.originChainId : fill.repaymentChainId;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function isEvmRepaymentValid(
|
|
56
|
-
fill: Fill,
|
|
57
|
-
repaymentChainId: number,
|
|
58
|
-
possibleRepaymentChainIds: number[] = []
|
|
59
|
-
): boolean {
|
|
60
|
-
// Slow fills don't result in repayments so they're always valid.
|
|
61
|
-
if (isSlowFill(fill)) {
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
// Return undefined if the requested repayment chain ID is not in a passed in set of eligible chains. This can
|
|
65
|
-
// be used by the caller to narrow the chains to those that are not disabled in the config store.
|
|
66
|
-
if (possibleRepaymentChainIds.length > 0 && !possibleRepaymentChainIds.includes(repaymentChainId)) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
return chainIsEvm(repaymentChainId) && isValidEvmAddress(fill.relayer);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Verify that a fill sent to an EVM chain has a 20 byte address. If the fill does not, then attempt
|
|
73
|
-
// to repay the `msg.sender` of the relay transaction. Otherwise, return undefined.
|
|
74
|
-
export async function verifyFillRepayment(
|
|
75
|
-
_fill: FillWithBlock,
|
|
76
|
-
destinationChainProvider: providers.Provider,
|
|
77
|
-
matchedDeposit: DepositWithBlock,
|
|
78
|
-
possibleRepaymentChainIds: number[] = []
|
|
79
|
-
): Promise<FillWithBlock | undefined> {
|
|
80
|
-
const fill = _.cloneDeep(_fill);
|
|
81
|
-
|
|
82
|
-
const repaymentChainId = getRepaymentChainId(fill, matchedDeposit);
|
|
83
|
-
const validEvmRepayment = isEvmRepaymentValid(fill, repaymentChainId, possibleRepaymentChainIds);
|
|
84
|
-
|
|
85
|
-
// Case 1: Repayment chain is EVM and repayment address is valid EVM address.
|
|
86
|
-
if (validEvmRepayment) {
|
|
87
|
-
return fill;
|
|
88
|
-
}
|
|
89
|
-
// Case 2: Repayment chain is EVM but repayment address is not a valid EVM address. Attempt to switch repayment
|
|
90
|
-
// address to msg.sender of relay transaction.
|
|
91
|
-
else if (chainIsEvm(repaymentChainId) && !isValidEvmAddress(fill.relayer)) {
|
|
92
|
-
// TODO: Handle case where fill was sent on non-EVM chain, in which case the following call would fail
|
|
93
|
-
// or return something unexpected. We'd want to return undefined here.
|
|
94
|
-
const fillTransaction = await destinationChainProvider.getTransaction(fill.transactionHash);
|
|
95
|
-
const destinationRelayer = fillTransaction?.from;
|
|
96
|
-
// Repayment chain is still an EVM chain, but the msg.sender is a bytes32 address, so the fill is invalid.
|
|
97
|
-
if (!isDefined(destinationRelayer) || !isValidEvmAddress(destinationRelayer)) {
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
// Otherwise, assume the relayer to be repaid is the msg.sender. We don't need to modify the repayment chain since
|
|
101
|
-
// the getTransaction() call would only succeed if the fill was sent on an EVM chain and therefore the msg.sender
|
|
102
|
-
// is a valid EVM address and the repayment chain is an EVM chain.
|
|
103
|
-
fill.relayer = destinationRelayer;
|
|
104
|
-
return fill;
|
|
105
|
-
}
|
|
106
|
-
// Case 3: Repayment chain is not an EVM chain, must be invalid.
|
|
107
|
-
else {
|
|
108
|
-
return undefined;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
@@ -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
|
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
FillWithBlock,
|
|
14
14
|
SlowFillLeaf,
|
|
15
15
|
SpeedUp,
|
|
16
|
-
TokensBridged,
|
|
17
16
|
} from "../../interfaces";
|
|
18
17
|
import { toBN, toBNWei, getCurrentTime, randomAddress, BigNumber, bnZero, bnOne, bnMax } from "../../utils";
|
|
19
18
|
import { SpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
|
|
@@ -123,6 +122,7 @@ export class MockSpokePoolClient extends SpokePoolClient {
|
|
|
123
122
|
const { blockNumber, transactionIndex } = deposit;
|
|
124
123
|
let { depositId, depositor, destinationChainId, inputToken, inputAmount, outputToken, outputAmount } = deposit;
|
|
125
124
|
depositId ??= this.numberOfDeposits;
|
|
125
|
+
assert(depositId.gte(this.numberOfDeposits), `${depositId.toString()} < ${this.numberOfDeposits}`);
|
|
126
126
|
this.numberOfDeposits = depositId.add(bnOne);
|
|
127
127
|
|
|
128
128
|
destinationChainId ??= random(1, 42161, false);
|
|
@@ -225,19 +225,6 @@ export class MockSpokePoolClient extends SpokePoolClient {
|
|
|
225
225
|
});
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
setTokensBridged(tokensBridged: TokensBridged): Log {
|
|
229
|
-
const event = "TokensBridged";
|
|
230
|
-
const topics = [tokensBridged.chainId, tokensBridged.leafId, tokensBridged.l2TokenAddress];
|
|
231
|
-
const args = { ...tokensBridged };
|
|
232
|
-
|
|
233
|
-
return this.eventManager.generateEvent({
|
|
234
|
-
event,
|
|
235
|
-
address: this.spokePool.address,
|
|
236
|
-
topics: topics.map((topic) => topic.toString()),
|
|
237
|
-
args,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
|
|
241
228
|
requestV3SlowFill(request: SlowFillRequestWithBlock): Log {
|
|
242
229
|
const event = "RequestedV3SlowFill";
|
|
243
230
|
|
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,29 +38,3 @@ export function compareAddressesSimple(addressA?: string, addressB?: string): bo
|
|
|
38
38
|
}
|
|
39
39
|
return addressA.toLowerCase() === addressB.toLowerCase();
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
// Converts an input (assumed to be) bytes32 string into a bytes20 string.
|
|
43
|
-
// If the input is not a bytes32 but is less than type(uint160).max, then this function
|
|
44
|
-
// will still succeed.
|
|
45
|
-
// Throws an error if the string as an unsigned integer is greater than type(uint160).max.
|
|
46
|
-
export function toAddress(hexString: string): string {
|
|
47
|
-
// rawAddress is the address which is not properly checksummed.
|
|
48
|
-
const rawAddress = utils.hexZeroPad(utils.hexStripZeros(hexString), 20);
|
|
49
|
-
return utils.getAddress(rawAddress);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function isValidEvmAddress(address: string): boolean {
|
|
53
|
-
if (utils.isAddress(address)) {
|
|
54
|
-
return true;
|
|
55
|
-
}
|
|
56
|
-
// We may throw an error here if hexZeroPadFails. This will happen if the address to pad is greater than 20 bytes long, indicating
|
|
57
|
-
// that the address had less than 12 leading zero bytes.
|
|
58
|
-
// We may also throw at getAddress if the input cannot be converted into a checksummed EVM address for some reason.
|
|
59
|
-
// For both cases, this indicates that the address cannot be casted as a bytes20 EVM address, so we should return false.
|
|
60
|
-
try {
|
|
61
|
-
const evmAddress = utils.hexZeroPad(utils.hexStripZeros(address), 20);
|
|
62
|
-
return utils.isAddress(utils.getAddress(evmAddress));
|
|
63
|
-
} catch (_e) {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -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
|
}
|
|
@@ -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
|
/**
|
package/src/utils/EventUtils.ts
CHANGED
|
@@ -3,27 +3,11 @@ 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
|
|
6
|
+
import { isDefined, toBN, BigNumberish } from "./";
|
|
7
7
|
|
|
8
8
|
const maxRetries = 3;
|
|
9
9
|
const retrySleepTime = 10;
|
|
10
10
|
|
|
11
|
-
// Event fields which changed from an `address` to `bytes32` after the SVM contract upgrade.
|
|
12
|
-
const knownExtendedAddressFields = [
|
|
13
|
-
// TokensBridged
|
|
14
|
-
"l2TokenAddress",
|
|
15
|
-
// FundsDeposited/FilledRelay/RequestedSlowFill
|
|
16
|
-
"inputToken",
|
|
17
|
-
"outputToken",
|
|
18
|
-
"depositor",
|
|
19
|
-
"recipient",
|
|
20
|
-
"exclusiveRelayer",
|
|
21
|
-
// FilledRelay
|
|
22
|
-
"relayer",
|
|
23
|
-
// RequestedSpeedUpDeposit
|
|
24
|
-
"updatedRecipient",
|
|
25
|
-
];
|
|
26
|
-
|
|
27
11
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
12
|
export function spreadEvent(args: Result | Record<string, unknown>): { [key: string]: any } {
|
|
29
13
|
const keys = Object.keys(args).filter((key: string) => isNaN(+key)); // Extract non-numeric keys.
|
|
@@ -83,18 +67,6 @@ export function spreadEvent(args: Result | Record<string, unknown>): { [key: str
|
|
|
83
67
|
returnedObject.depositId = toBN(returnedObject.depositId as BigNumberish);
|
|
84
68
|
}
|
|
85
69
|
|
|
86
|
-
// Truncate all fields which may be bytes32 into a bytes20 string.
|
|
87
|
-
for (const field of knownExtendedAddressFields) {
|
|
88
|
-
if (isDefined(returnedObject[field])) {
|
|
89
|
-
let address = String(returnedObject[field]);
|
|
90
|
-
try {
|
|
91
|
-
address = toAddress(address);
|
|
92
|
-
// eslint-disable-next-line no-empty
|
|
93
|
-
} catch (_) {}
|
|
94
|
-
returnedObject[field] = address;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
70
|
return returnedObject;
|
|
99
71
|
}
|
|
100
72
|
|
|
@@ -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
|
@@ -5,8 +5,6 @@ import { Deposit, Fill, FillStatus, FillWithBlock, RelayData, SlowFillRequest }
|
|
|
5
5
|
import { SpokePoolClient } from "../clients";
|
|
6
6
|
import { chunk } from "./ArrayUtils";
|
|
7
7
|
import { BigNumber, toBN, bnOne, bnZero } from "./BigNumberUtils";
|
|
8
|
-
import { keccak256 } from "./common";
|
|
9
|
-
import { isMessageEmpty } from "./DepositUtils";
|
|
10
8
|
import { isDefined } from "./TypeGuards";
|
|
11
9
|
import { getNetworkName } from "./NetworkUtils";
|
|
12
10
|
import { paginatedEventQuery, spreadEventWithBlockNumber } from "./EventUtils";
|
|
@@ -211,7 +209,7 @@ export async function getBlockRangeForDepositId(
|
|
|
211
209
|
export async function getDepositIdAtBlock(contract: Contract, blockTag: number): Promise<BigNumber> {
|
|
212
210
|
const _depositIdAtBlock = await contract.numberOfDeposits({ blockTag });
|
|
213
211
|
const depositIdAtBlock = toBN(_depositIdAtBlock);
|
|
214
|
-
// 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.
|
|
215
213
|
if (depositIdAtBlock.lt(bnZero)) {
|
|
216
214
|
throw new Error("Invalid deposit count");
|
|
217
215
|
}
|
|
@@ -225,34 +223,26 @@ export async function getDepositIdAtBlock(contract: Contract, blockTag: number):
|
|
|
225
223
|
* @returns The corresponding RelayData hash.
|
|
226
224
|
*/
|
|
227
225
|
export function getRelayDataHash(relayData: RelayData, destinationChainId: number): string {
|
|
228
|
-
const _relayData = {
|
|
229
|
-
...relayData,
|
|
230
|
-
depositor: ethersUtils.hexZeroPad(relayData.depositor, 32),
|
|
231
|
-
recipient: ethersUtils.hexZeroPad(relayData.recipient, 32),
|
|
232
|
-
inputToken: ethersUtils.hexZeroPad(relayData.inputToken, 32),
|
|
233
|
-
outputToken: ethersUtils.hexZeroPad(relayData.outputToken, 32),
|
|
234
|
-
exclusiveRelayer: ethersUtils.hexZeroPad(relayData.exclusiveRelayer, 32),
|
|
235
|
-
};
|
|
236
226
|
return ethersUtils.keccak256(
|
|
237
227
|
ethersUtils.defaultAbiCoder.encode(
|
|
238
228
|
[
|
|
239
229
|
"tuple(" +
|
|
240
|
-
"
|
|
241
|
-
"
|
|
242
|
-
"
|
|
243
|
-
"
|
|
244
|
-
"
|
|
230
|
+
"address depositor," +
|
|
231
|
+
"address recipient," +
|
|
232
|
+
"address exclusiveRelayer," +
|
|
233
|
+
"address inputToken," +
|
|
234
|
+
"address outputToken," +
|
|
245
235
|
"uint256 inputAmount," +
|
|
246
236
|
"uint256 outputAmount," +
|
|
247
237
|
"uint256 originChainId," +
|
|
248
|
-
"
|
|
238
|
+
"uint32 depositId," +
|
|
249
239
|
"uint32 fillDeadline," +
|
|
250
240
|
"uint32 exclusivityDeadline," +
|
|
251
241
|
"bytes message" +
|
|
252
242
|
")",
|
|
253
243
|
"uint256 destinationChainId",
|
|
254
244
|
],
|
|
255
|
-
[
|
|
245
|
+
[relayData, destinationChainId]
|
|
256
246
|
)
|
|
257
247
|
);
|
|
258
248
|
}
|
|
@@ -422,6 +412,7 @@ export async function findFillEvent(
|
|
|
422
412
|
// In production the chainId returned from the provider matches 1:1 with the actual chainId. Querying the provider
|
|
423
413
|
// object saves an RPC query becasue the chainId is cached by StaticJsonRpcProvider instances. In hre, the SpokePool
|
|
424
414
|
// may be configured with a different chainId than what is returned by the provider.
|
|
415
|
+
// @todo Sub out actual chain IDs w/ CHAIN_IDs constants
|
|
425
416
|
const destinationChainId = Object.values(CHAIN_IDs).includes(relayData.originChainId)
|
|
426
417
|
? (await spokePool.provider.getNetwork()).chainId
|
|
427
418
|
: Number(await spokePool.chainId());
|
|
@@ -436,7 +427,3 @@ export async function findFillEvent(
|
|
|
436
427
|
export function isZeroAddress(address: string): boolean {
|
|
437
428
|
return address === ZERO_ADDRESS || address === ZERO_BYTES;
|
|
438
429
|
}
|
|
439
|
-
|
|
440
|
-
export function getMessageHash(message: string): string {
|
|
441
|
-
return isMessageEmpty(message) ? ZERO_BYTES : keccak256(message);
|
|
442
|
-
}
|
package/src/utils/common.ts
CHANGED
|
@@ -7,8 +7,6 @@ export type Decimalish = string | number | Decimal;
|
|
|
7
7
|
export const AddressZero = ethers.constants.AddressZero;
|
|
8
8
|
export const MAX_BIG_INT = BigNumber.from(Number.MAX_SAFE_INTEGER.toString());
|
|
9
9
|
|
|
10
|
-
export const { keccak256 } = ethers.utils;
|
|
11
|
-
|
|
12
10
|
/**
|
|
13
11
|
* toBNWei.
|
|
14
12
|
*
|
|
@@ -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
|