@across-protocol/sdk 4.2.16 → 4.3.0
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/arch/evm/SpokeUtils.d.ts +8 -3
- package/dist/cjs/arch/evm/SpokeUtils.js +26 -11
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.d.ts +8 -2
- package/dist/cjs/arch/svm/SpokeUtils.js +41 -50
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +4 -2
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +3 -3
- package/dist/cjs/arch/svm/utils.js +16 -14
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/cjs/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +60 -56
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js +13 -13
- package/dist/cjs/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js +3 -2
- package/dist/cjs/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/cjs/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js +3 -3
- package/dist/cjs/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +13 -8
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/cjs/clients/HubPoolClient.d.ts +21 -21
- package/dist/cjs/clients/HubPoolClient.js +85 -58
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +65 -45
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js +15 -9
- package/dist/cjs/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +40 -36
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js +6 -4
- package/dist/cjs/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js +2 -2
- package/dist/cjs/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/cjs/interfaces/HubPool.d.ts +19 -14
- package/dist/cjs/interfaces/SpokePool.d.ts +18 -19
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +15 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +24 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +12 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +46 -44
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +10 -10
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +12 -8
- package/dist/cjs/utils/AddressUtils.js +33 -36
- package/dist/cjs/utils/AddressUtils.js.map +1 -1
- package/dist/cjs/utils/SpokeUtils.d.ts +3 -3
- package/dist/cjs/utils/SpokeUtils.js +4 -22
- package/dist/cjs/utils/SpokeUtils.js.map +1 -1
- package/dist/cjs/utils/TokenUtils.d.ts +4 -4
- package/dist/cjs/utils/TokenUtils.js +5 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/esm/arch/evm/SpokeUtils.js +29 -14
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/esm/arch/svm/SpokeUtils.js +42 -55
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +5 -3
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +3 -3
- package/dist/esm/arch/svm/utils.js +17 -15
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js +4 -2
- package/dist/esm/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +61 -57
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js +14 -14
- package/dist/esm/clients/BundleDataClient/utils/DataworkerUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js +7 -7
- package/dist/esm/clients/BundleDataClient/utils/FillUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js +5 -1
- package/dist/esm/clients/BundleDataClient/utils/MerkleTreeUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js +4 -4
- package/dist/esm/clients/BundleDataClient/utils/PoolRebalanceUtils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +20 -10
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +22 -22
- package/dist/esm/clients/HubPoolClient.js +91 -62
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +68 -47
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/esm/clients/mocks/MockHubPoolClient.js +16 -10
- package/dist/esm/clients/mocks/MockHubPoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +42 -38
- package/dist/esm/clients/mocks/MockSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js +7 -5
- package/dist/esm/clients/mocks/MockSvmCpiEventsClient.js.map +1 -1
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js +3 -3
- package/dist/esm/clients/mocks/MockSvmSpokePoolClient.js.map +1 -1
- package/dist/esm/interfaces/HubPool.d.ts +19 -14
- package/dist/esm/interfaces/SpokePool.d.ts +18 -19
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +18 -10
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +29 -20
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js +2 -2
- package/dist/esm/relayFeeCalculator/chain-queries/factory.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +14 -6
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +51 -48
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +9 -9
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +12 -8
- package/dist/esm/utils/AddressUtils.js +36 -38
- package/dist/esm/utils/AddressUtils.js.map +1 -1
- package/dist/esm/utils/SpokeUtils.d.ts +3 -8
- package/dist/esm/utils/SpokeUtils.js +4 -26
- package/dist/esm/utils/SpokeUtils.js.map +1 -1
- package/dist/esm/utils/TokenUtils.d.ts +22 -18
- package/dist/esm/utils/TokenUtils.js +6 -4
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +9 -4
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts +9 -3
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/eventsClient.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +3 -3
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts +3 -3
- package/dist/types/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts +4 -4
- package/dist/types/clients/BundleDataClient/BundleDataClient.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/DataworkerUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts +2 -1
- package/dist/types/clients/BundleDataClient/utils/FillUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/MerkleTreeUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/PoolRebalanceUtils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +71 -71
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +22 -22
- package/dist/types/clients/HubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +2 -2
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts +9 -9
- package/dist/types/clients/mocks/MockHubPoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +5 -3
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts +1 -1
- package/dist/types/clients/mocks/MockSvmCpiEventsClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts.map +1 -1
- package/dist/types/interfaces/HubPool.d.ts +19 -14
- package/dist/types/interfaces/HubPool.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +18 -19
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +18 -10
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/factory.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +14 -6
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +6 -6
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +12 -8
- package/dist/types/utils/AddressUtils.d.ts.map +1 -1
- package/dist/types/utils/SpokeUtils.d.ts +3 -8
- package/dist/types/utils/SpokeUtils.d.ts.map +1 -1
- package/dist/types/utils/TokenUtils.d.ts +22 -18
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +72 -22
- package/src/arch/svm/SpokeUtils.ts +67 -53
- package/src/arch/svm/eventsClient.ts +40 -8
- package/src/arch/svm/utils.ts +6 -6
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +57 -53
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +12 -8
- package/src/clients/BundleDataClient/utils/MerkleTreeUtils.ts +7 -1
- package/src/clients/BundleDataClient/utils/PoolRebalanceUtils.ts +4 -4
- package/src/clients/BundleDataClient/utils/SuperstructUtils.ts +22 -10
- package/src/clients/HubPoolClient.ts +123 -82
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +6 -0
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +121 -35
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +39 -27
- package/src/clients/mocks/MockSvmCpiEventsClient.ts +8 -5
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +20 -14
- package/src/interfaces/SpokePool.ts +19 -19
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +39 -20
- package/src/relayFeeCalculator/chain-queries/factory.ts +2 -2
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +57 -56
- package/src/relayFeeCalculator/relayFeeCalculator.ts +15 -13
- package/src/utils/AddressUtils.ts +39 -51
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +10 -8
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
|
+
import { utils as ethersUtils } from "ethers";
|
|
2
3
|
import {
|
|
3
4
|
AnyObject,
|
|
4
5
|
BigNumber,
|
|
@@ -6,6 +7,7 @@ import {
|
|
|
6
7
|
DefaultLogLevels,
|
|
7
8
|
DepositSearchResult,
|
|
8
9
|
EventSearchConfig,
|
|
10
|
+
EvmAddress,
|
|
9
11
|
MAX_BIG_INT,
|
|
10
12
|
MakeOptional,
|
|
11
13
|
assign,
|
|
@@ -13,16 +15,14 @@ import {
|
|
|
13
15
|
isDefined,
|
|
14
16
|
getMessageHash,
|
|
15
17
|
isSlowFill,
|
|
16
|
-
isValidEvmAddress,
|
|
17
18
|
isZeroAddress,
|
|
18
|
-
toEvmAddress,
|
|
19
19
|
validateFillForDeposit,
|
|
20
|
-
chainIsEvm,
|
|
21
20
|
chainIsProd,
|
|
22
21
|
Address,
|
|
22
|
+
toAddressType,
|
|
23
23
|
} from "../../utils";
|
|
24
24
|
import { duplicateEvent, sortEventsAscendingInPlace } from "../../utils/EventUtils";
|
|
25
|
-
import { ZERO_ADDRESS } from "../../constants";
|
|
25
|
+
import { CHAIN_IDs, ZERO_ADDRESS } from "../../constants";
|
|
26
26
|
import {
|
|
27
27
|
BridgedToHubPoolWithBlock,
|
|
28
28
|
ClaimedRelayerRefundWithBlock,
|
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
SortableEvent,
|
|
40
40
|
SpeedUpWithBlock,
|
|
41
41
|
TokensBridged,
|
|
42
|
+
RelayExecutionEventInfo,
|
|
42
43
|
} from "../../interfaces";
|
|
43
44
|
import { BaseAbstractClient, UpdateFailureReason } from "../BaseAbstractClient";
|
|
44
45
|
import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
@@ -208,8 +209,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
208
209
|
* @param relayer The relayer address.
|
|
209
210
|
* @returns A list of fills.
|
|
210
211
|
*/
|
|
211
|
-
public getFillsForRelayer(relayer:
|
|
212
|
-
return this.getFills().filter((fill) => fill.relayer
|
|
212
|
+
public getFillsForRelayer(relayer: Address): FillWithBlock[] {
|
|
213
|
+
return this.getFills().filter((fill) => fill.relayer.eq(relayer));
|
|
213
214
|
}
|
|
214
215
|
|
|
215
216
|
/**
|
|
@@ -273,8 +274,8 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
273
274
|
const { depositId, depositor } = deposit;
|
|
274
275
|
|
|
275
276
|
// Note: we know depositor cannot be more than 20 bytes since this is guaranteed by contracts.
|
|
276
|
-
|
|
277
|
-
|
|
277
|
+
// Additionally, speed ups can only be done on EVM networks.
|
|
278
|
+
const speedups = this.speedUps[depositor.toEvmAddress()]?.[depositId.toString()];
|
|
278
279
|
if (!isDefined(speedups) || speedups.length === 0) {
|
|
279
280
|
return deposit;
|
|
280
281
|
}
|
|
@@ -403,11 +404,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
403
404
|
// is not a valid EVM chain. In the case where the repayment address is not a valid EVM address, the dataworker
|
|
404
405
|
// might be able to overwrite the repayment address to the msg.sender on the fill txn, but to keep this
|
|
405
406
|
// functioon synchronous, we can't make that decision now. So this function might log some false positives.
|
|
406
|
-
if (
|
|
407
|
-
this.hubPoolClient &&
|
|
408
|
-
!isSlowFill(fill) &&
|
|
409
|
-
(!chainIsEvm(repaymentChainId) || !isValidEvmAddress(fill.relayer))
|
|
410
|
-
) {
|
|
407
|
+
if (this.hubPoolClient && !isSlowFill(fill) && !fill.relayer.isValidOn(repaymentChainId)) {
|
|
411
408
|
groupedFills.unrepayableFills.push(fill);
|
|
412
409
|
}
|
|
413
410
|
// This fill is still valid and means that the deposit cannot be filled on-chain anymore, but it
|
|
@@ -429,7 +426,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
429
426
|
chainId: this.chainId,
|
|
430
427
|
message: "Unrepayable fills found where we need to switch repayment address and or chain",
|
|
431
428
|
deposit,
|
|
432
|
-
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer, x])),
|
|
429
|
+
unrepayableFills: Object.fromEntries(unrepayableFillsForDeposit.map((x) => [x.relayer.toNative(), x])),
|
|
433
430
|
notificationPath: "across-unrepayable-fills",
|
|
434
431
|
});
|
|
435
432
|
}
|
|
@@ -501,14 +498,36 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
501
498
|
const { events: queryResults, currentTime, searchEndBlock } = update;
|
|
502
499
|
|
|
503
500
|
if (eventsToQuery.includes("TokensBridged")) {
|
|
504
|
-
for (const
|
|
505
|
-
|
|
501
|
+
for (const _event of queryResults[eventsToQuery.indexOf("TokensBridged")]) {
|
|
502
|
+
const event = _event as TokensBridged & {
|
|
503
|
+
l2TokenAddress: string;
|
|
504
|
+
};
|
|
505
|
+
this.tokensBridged.push({
|
|
506
|
+
...event,
|
|
507
|
+
l2TokenAddress: toAddressType(event.l2TokenAddress, this.chainId),
|
|
508
|
+
});
|
|
506
509
|
}
|
|
507
510
|
}
|
|
508
511
|
|
|
509
512
|
// Performs the indexing of a deposit-like spoke pool event.
|
|
510
513
|
const queryDepositEvents = async (eventName: string) => {
|
|
511
|
-
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
514
|
+
const depositEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
515
|
+
const event = _event as DepositWithBlock & {
|
|
516
|
+
depositor: string;
|
|
517
|
+
recipient: string;
|
|
518
|
+
inputToken: string;
|
|
519
|
+
outputToken: string;
|
|
520
|
+
exclusiveRelayer: string;
|
|
521
|
+
};
|
|
522
|
+
return {
|
|
523
|
+
...event,
|
|
524
|
+
depositor: toAddressType(event.depositor, this.chainId),
|
|
525
|
+
recipient: toAddressType(event.recipient, event.destinationChainId),
|
|
526
|
+
inputToken: toAddressType(event.inputToken, this.chainId),
|
|
527
|
+
outputToken: toAddressType(event.outputToken, event.destinationChainId),
|
|
528
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, event.destinationChainId),
|
|
529
|
+
} as DepositWithBlock;
|
|
530
|
+
});
|
|
512
531
|
if (depositEvents.length > 0) {
|
|
513
532
|
this.log(
|
|
514
533
|
"debug",
|
|
@@ -565,11 +584,31 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
565
584
|
|
|
566
585
|
// Performs indexing of a "speed up deposit"-like event.
|
|
567
586
|
const querySpeedUpDepositEvents = (eventName: string) => {
|
|
568
|
-
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
587
|
+
const speedUpEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
588
|
+
.map((_event) => {
|
|
589
|
+
const event = _event as SpeedUpWithBlock & { depositor: string; updatedRecipient: string };
|
|
590
|
+
|
|
591
|
+
const invalid = [event.depositor, event.updatedRecipient].some(
|
|
592
|
+
(addr) => !EvmAddress.validate(ethersUtils.arrayify(addr))
|
|
593
|
+
);
|
|
594
|
+
if (invalid) {
|
|
595
|
+
return;
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
return {
|
|
599
|
+
...event,
|
|
600
|
+
depositor: EvmAddress.from(event.depositor),
|
|
601
|
+
updatedRecipient: EvmAddress.from(event.updatedRecipient),
|
|
602
|
+
} as SpeedUpWithBlock;
|
|
603
|
+
})
|
|
604
|
+
.filter(isDefined);
|
|
569
605
|
|
|
570
606
|
for (const event of speedUpEvents) {
|
|
571
|
-
const speedUp = {
|
|
572
|
-
|
|
607
|
+
const speedUp = {
|
|
608
|
+
...event,
|
|
609
|
+
originChainId: this.chainId,
|
|
610
|
+
};
|
|
611
|
+
assign(this.speedUps, [speedUp.depositor.toEvmAddress(), speedUp.depositId.toString()], [speedUp]);
|
|
573
612
|
|
|
574
613
|
// Find deposit hash matching this speed up event and update the deposit data associated with the hash,
|
|
575
614
|
// if the hash+data exists.
|
|
@@ -593,7 +632,23 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
593
632
|
|
|
594
633
|
// Performs indexing of "requested slow fill"-like events.
|
|
595
634
|
const queryRequestedSlowFillEvents = (eventName: string) => {
|
|
596
|
-
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
635
|
+
const slowFillRequests = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
636
|
+
const event = _event as SlowFillRequestWithBlock & {
|
|
637
|
+
depositor: string;
|
|
638
|
+
recipient: string;
|
|
639
|
+
inputToken: string;
|
|
640
|
+
outputToken: string;
|
|
641
|
+
exclusiveRelayer: string;
|
|
642
|
+
};
|
|
643
|
+
return {
|
|
644
|
+
...event,
|
|
645
|
+
depositor: toAddressType(event.depositor, event.originChainId),
|
|
646
|
+
recipient: toAddressType(event.recipient, this.chainId),
|
|
647
|
+
inputToken: toAddressType(event.inputToken, event.originChainId),
|
|
648
|
+
outputToken: toAddressType(event.outputToken, this.chainId),
|
|
649
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
|
|
650
|
+
} as SlowFillRequestWithBlock;
|
|
651
|
+
});
|
|
597
652
|
for (const event of slowFillRequests) {
|
|
598
653
|
const slowFillRequest = {
|
|
599
654
|
...event,
|
|
@@ -620,7 +675,30 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
620
675
|
|
|
621
676
|
// Performs indexing of filled relay-like events.
|
|
622
677
|
const queryFilledRelayEvents = (eventName: string) => {
|
|
623
|
-
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? [])
|
|
678
|
+
const fillEvents = (queryResults[eventsToQuery.indexOf(eventName)] ?? []).map((_event) => {
|
|
679
|
+
const event = _event as FillWithBlock & {
|
|
680
|
+
depositor: string;
|
|
681
|
+
recipient: string;
|
|
682
|
+
inputToken: string;
|
|
683
|
+
outputToken: string;
|
|
684
|
+
exclusiveRelayer: string;
|
|
685
|
+
relayer: string;
|
|
686
|
+
relayExecutionInfo: RelayExecutionEventInfo & { updatedRecipient: string };
|
|
687
|
+
};
|
|
688
|
+
return {
|
|
689
|
+
...event,
|
|
690
|
+
depositor: toAddressType(event.depositor, event.originChainId),
|
|
691
|
+
recipient: toAddressType(event.recipient, this.chainId),
|
|
692
|
+
inputToken: toAddressType(event.inputToken, event.originChainId),
|
|
693
|
+
outputToken: toAddressType(event.outputToken, this.chainId),
|
|
694
|
+
exclusiveRelayer: toAddressType(event.exclusiveRelayer, this.chainId),
|
|
695
|
+
relayer: toAddressType(event.relayer, this.chainId),
|
|
696
|
+
relayExecutionInfo: {
|
|
697
|
+
...event.relayExecutionInfo,
|
|
698
|
+
updatedRecipient: toAddressType(event.relayExecutionInfo.updatedRecipient, this.chainId),
|
|
699
|
+
},
|
|
700
|
+
} as FillWithBlock;
|
|
701
|
+
});
|
|
624
702
|
|
|
625
703
|
if (fillEvents.length > 0) {
|
|
626
704
|
this.log("debug", `Using ${fillEvents.length} newly queried ${eventName} events for chain ${this.chainId}`, {
|
|
@@ -656,8 +734,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
656
734
|
});
|
|
657
735
|
|
|
658
736
|
if (eventsToQuery.includes("EnabledDepositRoute")) {
|
|
659
|
-
const enableDepositsEvents =
|
|
660
|
-
|
|
737
|
+
const enableDepositsEvents = queryResults[
|
|
738
|
+
eventsToQuery.indexOf("EnabledDepositRoute")
|
|
739
|
+
] as EnabledDepositRouteWithBlock[];
|
|
661
740
|
|
|
662
741
|
for (const event of enableDepositsEvents) {
|
|
663
742
|
assign(this.depositRoutes, [event.originToken, event.destinationChainId], event.enabled);
|
|
@@ -665,18 +744,23 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
665
744
|
}
|
|
666
745
|
|
|
667
746
|
if (eventsToQuery.includes("RelayedRootBundle")) {
|
|
668
|
-
const relayedRootBundleEvents =
|
|
669
|
-
|
|
747
|
+
const relayedRootBundleEvents = queryResults[
|
|
748
|
+
eventsToQuery.indexOf("RelayedRootBundle")
|
|
749
|
+
] as RootBundleRelayWithBlock[];
|
|
670
750
|
for (const event of relayedRootBundleEvents) {
|
|
671
751
|
this.rootBundleRelays.push(event);
|
|
672
752
|
}
|
|
673
753
|
}
|
|
674
754
|
|
|
675
755
|
if (eventsToQuery.includes("ExecutedRelayerRefundRoot")) {
|
|
676
|
-
const refundEvents =
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
this.relayerRefundExecutions.push(
|
|
756
|
+
const refundEvents = queryResults[eventsToQuery.indexOf("ExecutedRelayerRefundRoot")];
|
|
757
|
+
for (const _event of refundEvents) {
|
|
758
|
+
const event = _event as { l2TokenAddress: string; refundAddresses: string[] } & RelayerRefundExecutionWithBlock;
|
|
759
|
+
this.relayerRefundExecutions.push({
|
|
760
|
+
...event,
|
|
761
|
+
l2TokenAddress: toAddressType(event.l2TokenAddress, this.chainId),
|
|
762
|
+
refundAddresses: event.refundAddresses.map((addr) => toAddressType(addr, this.chainId)),
|
|
763
|
+
});
|
|
680
764
|
}
|
|
681
765
|
}
|
|
682
766
|
|
|
@@ -743,9 +827,9 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
743
827
|
* @param deposit The deposit to retrieve the destination token for.
|
|
744
828
|
* @returns The destination token.
|
|
745
829
|
*/
|
|
746
|
-
protected getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
830
|
+
protected getDestinationTokenForDeposit(deposit: DepositWithBlock): Address {
|
|
747
831
|
if (!this.canResolveZeroAddressOutputToken(deposit)) {
|
|
748
|
-
return ZERO_ADDRESS;
|
|
832
|
+
return toAddressType(ZERO_ADDRESS, CHAIN_IDs.MAINNET);
|
|
749
833
|
}
|
|
750
834
|
// L1 token should be resolved if we get here:
|
|
751
835
|
const l1Token = this.hubPoolClient!.getL1TokenForL2TokenAtBlock(
|
|
@@ -753,10 +837,12 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
753
837
|
deposit.originChainId,
|
|
754
838
|
deposit.quoteBlockNumber
|
|
755
839
|
)!;
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
840
|
+
const counterpartToken = this.hubPoolClient!.getL2TokenForL1TokenAtBlock(
|
|
841
|
+
l1Token,
|
|
842
|
+
deposit.destinationChainId,
|
|
843
|
+
deposit.quoteBlockNumber
|
|
759
844
|
);
|
|
845
|
+
return counterpartToken ?? toAddressType(ZERO_ADDRESS, CHAIN_IDs.MAINNET);
|
|
760
846
|
}
|
|
761
847
|
|
|
762
848
|
/**
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
2
|
import { Contract } from "ethers";
|
|
3
|
-
import { BigNumber, randomAddress, assign, bnZero } from "../../utils";
|
|
4
|
-
import {
|
|
3
|
+
import { BigNumber, randomAddress, assign, bnZero, toAddressType, EvmAddress, Address, isDefined } from "../../utils";
|
|
4
|
+
import { Log, PendingRootBundle, RealizedLpFee, L1TokenInfo } from "../../interfaces";
|
|
5
5
|
import { AcrossConfigStoreClient as ConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
6
6
|
import { HubPoolClient, HubPoolUpdate, LpFeeRequest } from "../HubPoolClient";
|
|
7
7
|
import { EventManager, EventOverrides, getEventManager } from "./MockEvents";
|
|
8
|
+
import { ZERO_ADDRESS } from "../../constants";
|
|
8
9
|
|
|
9
10
|
const emptyRootBundle: PendingRootBundle = {
|
|
10
11
|
poolRebalanceRoot: "",
|
|
11
12
|
relayerRefundRoot: "",
|
|
12
13
|
slowRelayRoot: "",
|
|
13
|
-
proposer:
|
|
14
|
+
proposer: EvmAddress.from(ZERO_ADDRESS),
|
|
14
15
|
unclaimedPoolRebalanceLeafCount: 0,
|
|
15
16
|
challengePeriodEndTimestamp: 0,
|
|
16
17
|
bundleEvaluationBlockNumbers: [],
|
|
@@ -22,9 +23,9 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
22
23
|
private realizedLpFeePct: BigNumber = bnZero;
|
|
23
24
|
private realizedLpFeePctOverride = false;
|
|
24
25
|
|
|
25
|
-
private l1TokensMock:
|
|
26
|
+
private l1TokensMock: L1TokenInfo[] = []; // L1Tokens and their associated info.
|
|
26
27
|
|
|
27
|
-
private spokePoolTokens: { [l1Token: string]: { [chainId: number]:
|
|
28
|
+
private spokePoolTokens: { [l1Token: string]: { [chainId: number]: Address } } = {};
|
|
28
29
|
|
|
29
30
|
private eventManager: EventManager;
|
|
30
31
|
|
|
@@ -69,7 +70,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
69
70
|
[chainId],
|
|
70
71
|
[
|
|
71
72
|
{
|
|
72
|
-
spokePool: contract,
|
|
73
|
+
spokePool: toAddressType(contract, this.chainId),
|
|
73
74
|
blockNumber: blockNumber,
|
|
74
75
|
transactionIndex: 0,
|
|
75
76
|
logIndex: 0,
|
|
@@ -82,7 +83,7 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
82
83
|
this.latestHeightSearched = blockNumber;
|
|
83
84
|
}
|
|
84
85
|
|
|
85
|
-
addL1Token(l1Token:
|
|
86
|
+
addL1Token(l1Token: L1TokenInfo) {
|
|
86
87
|
this.l1TokensMock.push(l1Token);
|
|
87
88
|
}
|
|
88
89
|
|
|
@@ -92,19 +93,19 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
92
93
|
|
|
93
94
|
setTokenMapping(l1Token: string, chainId: number, l2Token: string) {
|
|
94
95
|
this.spokePoolTokens[l1Token] ??= {};
|
|
95
|
-
this.spokePoolTokens[l1Token][chainId] = l2Token;
|
|
96
|
+
this.spokePoolTokens[l1Token][chainId] = toAddressType(l2Token, chainId);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
|
-
l2TokenEnabledForL1TokenAtBlock(l1Token:
|
|
99
|
-
if (this.spokePoolTokens[l1Token]?.[destinationChainId]) {
|
|
99
|
+
l2TokenEnabledForL1TokenAtBlock(l1Token: EvmAddress, destinationChainId: number, hubBlockNumber: number): boolean {
|
|
100
|
+
if (this.spokePoolTokens[l1Token.toEvmAddress()]?.[destinationChainId]) {
|
|
100
101
|
return true;
|
|
101
102
|
} else {
|
|
102
103
|
return super.l2TokenEnabledForL1TokenAtBlock(l1Token, destinationChainId, hubBlockNumber);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
l2TokenHasPoolRebalanceRoute(l2Token:
|
|
106
|
+
l2TokenHasPoolRebalanceRoute(l2Token: Address, chainId: number, hubPoolBlock: number): boolean {
|
|
106
107
|
const l1Token = Object.keys(this.spokePoolTokens).find(
|
|
107
|
-
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]
|
|
108
|
+
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]?.eq(l2Token)
|
|
108
109
|
);
|
|
109
110
|
if (!l1Token) {
|
|
110
111
|
return super.l2TokenHasPoolRebalanceRoute(l2Token, chainId, hubPoolBlock);
|
|
@@ -115,20 +116,24 @@ export class MockHubPoolClient extends HubPoolClient {
|
|
|
115
116
|
delete this.spokePoolTokens[l1Token]?.[chainId];
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
getL1TokenForL2TokenAtBlock(l2Token:
|
|
119
|
+
getL1TokenForL2TokenAtBlock(l2Token: Address, chainId: number, blockNumber: number): EvmAddress {
|
|
119
120
|
const l1Token = Object.keys(this.spokePoolTokens).find(
|
|
120
|
-
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId]
|
|
121
|
+
(l1Token) => this.spokePoolTokens[l1Token]?.[chainId].eq(l2Token)
|
|
121
122
|
);
|
|
122
|
-
|
|
123
|
+
if (isDefined(l1Token)) {
|
|
124
|
+
return EvmAddress.from(l1Token);
|
|
125
|
+
} else {
|
|
126
|
+
return super.getL1TokenForL2TokenAtBlock(l2Token, chainId, blockNumber);
|
|
127
|
+
}
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
getL2TokenForL1TokenAtBlock(l1Token:
|
|
126
|
-
const l2Token = this.spokePoolTokens[l1Token]?.[chainId];
|
|
130
|
+
getL2TokenForL1TokenAtBlock(l1Token: EvmAddress, chainId: number, blockNumber: number): Address {
|
|
131
|
+
const l2Token = this.spokePoolTokens[l1Token.toEvmAddress()]?.[chainId];
|
|
127
132
|
return l2Token ?? super.getL2TokenForL1TokenAtBlock(l1Token, chainId, blockNumber);
|
|
128
133
|
}
|
|
129
134
|
|
|
130
|
-
getTokenInfoForL1Token(l1Token:
|
|
131
|
-
return this.l1TokensMock.find((token) => token.address
|
|
135
|
+
getTokenInfoForL1Token(l1Token: EvmAddress): L1TokenInfo | undefined {
|
|
136
|
+
return this.l1TokensMock.find((token) => token.address.eq(l1Token));
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
_update(eventNames: string[]): Promise<HubPoolUpdate> {
|
|
@@ -2,7 +2,7 @@ import assert from "assert";
|
|
|
2
2
|
import { Contract } from "ethers";
|
|
3
3
|
import { random } from "lodash";
|
|
4
4
|
import winston from "winston";
|
|
5
|
-
import { EMPTY_MESSAGE, ZERO_ADDRESS } from "../../constants";
|
|
5
|
+
import { EMPTY_MESSAGE, ZERO_ADDRESS, ZERO_BYTES } from "../../constants";
|
|
6
6
|
import {
|
|
7
7
|
Log,
|
|
8
8
|
Deposit,
|
|
@@ -27,6 +27,9 @@ import {
|
|
|
27
27
|
bnOne,
|
|
28
28
|
toBytes32,
|
|
29
29
|
spreadEventWithBlockNumber,
|
|
30
|
+
Address,
|
|
31
|
+
toAddressType,
|
|
32
|
+
isDefined,
|
|
30
33
|
} from "../../utils";
|
|
31
34
|
import { EVMSpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
|
|
32
35
|
import { HubPoolClient } from "../HubPoolClient";
|
|
@@ -62,8 +65,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
62
65
|
this.destinationTokenForChainOverride[chainId] = token;
|
|
63
66
|
}
|
|
64
67
|
|
|
65
|
-
getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
66
|
-
|
|
68
|
+
getDestinationTokenForDeposit(deposit: DepositWithBlock): Address {
|
|
69
|
+
const override = this.destinationTokenForChainOverride[deposit.originChainId];
|
|
70
|
+
return isDefined(override)
|
|
71
|
+
? toAddressType(override, deposit.destinationChainId)
|
|
72
|
+
: super.getDestinationTokenForDeposit(deposit);
|
|
67
73
|
}
|
|
68
74
|
|
|
69
75
|
setLatestBlockNumber(blockNumber: number): void {
|
|
@@ -129,23 +135,26 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
129
135
|
return this._deposit("FundsDeposited", deposit);
|
|
130
136
|
}
|
|
131
137
|
|
|
132
|
-
protected _deposit(
|
|
138
|
+
protected _deposit(
|
|
139
|
+
event: string,
|
|
140
|
+
deposit: Omit<Deposit, "messageHash"> & { message?: string } & Partial<SortableEvent>
|
|
141
|
+
): Log {
|
|
133
142
|
const { blockNumber, txnIndex } = deposit;
|
|
134
143
|
let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
|
|
135
144
|
depositId ??= this.numberOfDeposits;
|
|
136
145
|
this.numberOfDeposits = depositId.add(bnOne);
|
|
137
146
|
|
|
138
147
|
destinationChainId ??= random(1, 42161, false);
|
|
139
|
-
const depositor =
|
|
140
|
-
const recipient =
|
|
141
|
-
const inputToken =
|
|
142
|
-
const outputToken =
|
|
143
|
-
const exclusiveRelayer =
|
|
148
|
+
const depositor = deposit.depositor?.toBytes32() ?? toBytes32(randomAddress());
|
|
149
|
+
const recipient = deposit.recipient?.toBytes32() ?? toBytes32(depositor);
|
|
150
|
+
const inputToken = deposit.inputToken?.toBytes32() ?? toBytes32(randomAddress());
|
|
151
|
+
const outputToken = deposit.outputToken?.toBytes32() ?? inputToken;
|
|
152
|
+
const exclusiveRelayer = deposit.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
|
|
144
153
|
|
|
145
154
|
inputAmount ??= toBNWei(random(1, 1000, false));
|
|
146
155
|
outputAmount ??= inputAmount.mul(toBN("0.95"));
|
|
147
156
|
|
|
148
|
-
const message = deposit
|
|
157
|
+
const message = deposit.message ?? "0x";
|
|
149
158
|
const topics = [destinationChainId, depositId, depositor];
|
|
150
159
|
const quoteTimestamp = deposit.quoteTimestamp ?? getCurrentTime();
|
|
151
160
|
const args = {
|
|
@@ -191,19 +200,20 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
191
200
|
outputAmount ??= inputAmount;
|
|
192
201
|
fillDeadline ??= getCurrentTime() + 60;
|
|
193
202
|
|
|
194
|
-
const depositor =
|
|
195
|
-
const recipient =
|
|
196
|
-
const inputToken =
|
|
197
|
-
const outputToken =
|
|
198
|
-
const exclusiveRelayer =
|
|
199
|
-
const relayer =
|
|
203
|
+
const depositor = fill.depositor?.toBytes32() ?? toBytes32(randomAddress());
|
|
204
|
+
const recipient = fill.recipient?.toBytes32() ?? toBytes32(depositor);
|
|
205
|
+
const inputToken = fill.inputToken?.toBytes32() ?? toBytes32(randomAddress());
|
|
206
|
+
const outputToken = fill.outputToken?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
|
|
207
|
+
const exclusiveRelayer = fill.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS);
|
|
208
|
+
const relayer = fill.relayer?.toBytes32() ?? toBytes32(randomAddress());
|
|
200
209
|
|
|
201
210
|
const topics = [originChainId, depositId, relayer];
|
|
202
211
|
const message = fill.message ?? EMPTY_MESSAGE;
|
|
203
212
|
const updatedMessage = fill.relayExecutionInfo?.updatedMessage ?? message;
|
|
213
|
+
const updatedRecipient = fill.relayExecutionInfo?.updatedRecipient.toBytes32() ?? recipient;
|
|
204
214
|
|
|
205
215
|
const relayExecutionInfo = {
|
|
206
|
-
updatedRecipient
|
|
216
|
+
updatedRecipient,
|
|
207
217
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
208
218
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
209
219
|
};
|
|
@@ -223,7 +233,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
223
233
|
depositor,
|
|
224
234
|
recipient,
|
|
225
235
|
relayExecutionInfo: {
|
|
226
|
-
updatedRecipient
|
|
236
|
+
updatedRecipient,
|
|
227
237
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
228
238
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
229
239
|
},
|
|
@@ -253,7 +263,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
253
263
|
}
|
|
254
264
|
|
|
255
265
|
protected _speedUpDeposit(event: string, speedUp: SpeedUp): Log {
|
|
256
|
-
const depositor =
|
|
266
|
+
const depositor = speedUp.depositor.toBytes32();
|
|
257
267
|
const topics = [speedUp.depositId, depositor];
|
|
258
268
|
const args = { ...speedUp };
|
|
259
269
|
|
|
@@ -264,7 +274,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
264
274
|
args: {
|
|
265
275
|
...args,
|
|
266
276
|
depositor,
|
|
267
|
-
updatedRecipient:
|
|
277
|
+
updatedRecipient: speedUp.updatedRecipient.toBytes32(),
|
|
268
278
|
},
|
|
269
279
|
});
|
|
270
280
|
}
|
|
@@ -294,7 +304,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
294
304
|
const topics = [originChainId, depositId];
|
|
295
305
|
const args = { ...request };
|
|
296
306
|
|
|
297
|
-
const depositor =
|
|
307
|
+
const depositor = args.depositor.toBytes32() ?? toBytes32(randomAddress());
|
|
298
308
|
|
|
299
309
|
return this.eventManager.generateEvent({
|
|
300
310
|
event,
|
|
@@ -304,10 +314,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
304
314
|
...args,
|
|
305
315
|
destinationChainId: this.chainId,
|
|
306
316
|
depositor,
|
|
307
|
-
recipient:
|
|
308
|
-
inputToken:
|
|
309
|
-
outputToken:
|
|
310
|
-
exclusiveRelayer:
|
|
317
|
+
recipient: args.recipient?.toBytes32() ?? depositor,
|
|
318
|
+
inputToken: args.inputToken?.toBytes32() ?? toBytes32(randomAddress()),
|
|
319
|
+
outputToken: args.outputToken?.toBytes32() ?? toBytes32(ZERO_ADDRESS),
|
|
320
|
+
exclusiveRelayer: args.exclusiveRelayer?.toBytes32() ?? toBytes32(ZERO_ADDRESS),
|
|
321
|
+
messageHash: args.messageHash ?? ZERO_BYTES,
|
|
311
322
|
},
|
|
312
323
|
blockNumber: request.blockNumber,
|
|
313
324
|
transactionIndex: request.txnIndex,
|
|
@@ -317,10 +328,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
317
328
|
// This is a simple wrapper around fillRelay().
|
|
318
329
|
// rootBundleId and proof are discarded here - we have no interest in verifying that.
|
|
319
330
|
executeSlowRelayLeaf(leaf: Omit<SlowFillLeaf, "messageHash">): Log {
|
|
331
|
+
const destinationChainId = this.chainId;
|
|
320
332
|
const fill = {
|
|
321
333
|
...leaf.relayData,
|
|
322
|
-
destinationChainId
|
|
323
|
-
relayer: ZERO_ADDRESS,
|
|
334
|
+
destinationChainId,
|
|
335
|
+
relayer: toAddressType(ZERO_ADDRESS, destinationChainId),
|
|
324
336
|
repaymentChainId: 0,
|
|
325
337
|
relayExecutionInfo: {
|
|
326
338
|
updatedRecipient: leaf.relayData.recipient,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
|
+
import { utils as ethersUtils } from "ethers";
|
|
2
3
|
import { createHash } from "crypto";
|
|
3
4
|
import { hexlify, arrayify, hexZeroPad } from "ethers/lib/utils";
|
|
4
5
|
import { random } from "lodash";
|
|
@@ -17,9 +18,11 @@ import {
|
|
|
17
18
|
SVMProvider,
|
|
18
19
|
getRandomSvmAddress,
|
|
19
20
|
} from "../../arch/svm";
|
|
20
|
-
import { bnZero, bnOne, bs58, getCurrentTime, randomAddress, EvmAddress } from "../../utils";
|
|
21
|
+
import { bnZero, bnOne, bs58, getCurrentTime, randomAddress, EvmAddress, SvmAddress } from "../../utils";
|
|
21
22
|
import { FillType } from "../../interfaces";
|
|
22
23
|
|
|
24
|
+
const randomBytes = (n: number) => ethersUtils.hexlify(ethersUtils.randomBytes(n));
|
|
25
|
+
|
|
23
26
|
export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
|
|
24
27
|
private events: Record<EventName, EventWithData[]> = {} as Record<EventName, EventWithData[]>;
|
|
25
28
|
private slotHeight: bigint = BigInt(0);
|
|
@@ -75,9 +78,9 @@ export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
|
|
|
75
78
|
|
|
76
79
|
destinationChainId ??= BigInt(random(1, 42161, false));
|
|
77
80
|
const depositor = deposit.depositor ?? getRandomSvmAddress();
|
|
78
|
-
const recipient = deposit.recipient ??
|
|
81
|
+
const recipient = deposit.recipient ?? SvmAddress.from(randomBytes(32), "base16").toBase58();
|
|
79
82
|
const inputToken = deposit.inputToken ?? getRandomSvmAddress();
|
|
80
|
-
const outputToken = deposit.outputToken ??
|
|
83
|
+
const outputToken = deposit.outputToken ?? SvmAddress.from(randomBytes(32), "base16").toBase58();
|
|
81
84
|
inputAmount ??= BigInt(random(1, 1000, false));
|
|
82
85
|
outputAmount ??= (inputAmount * BigInt(95)) / BigInt(100);
|
|
83
86
|
const message = deposit.message ?? new Uint8Array(32);
|
|
@@ -158,9 +161,9 @@ export class MockSvmCpiEventsClient extends SvmCpiEventsClient {
|
|
|
158
161
|
let { depositId, originChainId } = slowFillRequest;
|
|
159
162
|
depositId ??= Uint8Array.from([random(1, 100_000, false)]);
|
|
160
163
|
originChainId ??= BigInt(random(1, 42161, false));
|
|
161
|
-
const depositor = slowFillRequest.depositor ??
|
|
164
|
+
const depositor = slowFillRequest.depositor ?? SvmAddress.from(randomBytes(32)).toBase58();
|
|
162
165
|
const recipient = slowFillRequest.recipient ?? getRandomSvmAddress();
|
|
163
|
-
const inputToken = slowFillRequest.inputToken ??
|
|
166
|
+
const inputToken = slowFillRequest.inputToken ?? SvmAddress.from(randomBytes(32)).toBase58();
|
|
164
167
|
const outputToken = slowFillRequest.outputToken ?? getRandomSvmAddress();
|
|
165
168
|
|
|
166
169
|
const args = {
|
|
@@ -2,7 +2,15 @@ import winston from "winston";
|
|
|
2
2
|
import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
3
3
|
import { Address } from "@solana/kit";
|
|
4
4
|
import { DepositWithBlock, RelayerRefundExecution, SortableEvent, SlowFillLeaf, Log } from "../../interfaces";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
getCurrentTime,
|
|
7
|
+
bnZero,
|
|
8
|
+
MakeOptional,
|
|
9
|
+
EventSearchConfig,
|
|
10
|
+
Address as SDKAddress,
|
|
11
|
+
toAddressType,
|
|
12
|
+
isDefined,
|
|
13
|
+
} from "../../utils";
|
|
6
14
|
import { SpokePoolUpdate, SVMSpokePoolClient } from "../SpokePoolClient";
|
|
7
15
|
import { HubPoolClient } from "../HubPoolClient";
|
|
8
16
|
import { EventOverrides } from "./MockEvents";
|
|
@@ -46,8 +54,9 @@ export class MockSvmSpokePoolClient extends SVMSpokePoolClient {
|
|
|
46
54
|
this.destinationTokenForChainOverride[chainId] = token;
|
|
47
55
|
}
|
|
48
56
|
|
|
49
|
-
getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
50
|
-
|
|
57
|
+
getDestinationTokenForDeposit(deposit: DepositWithBlock): SDKAddress {
|
|
58
|
+
const override = this.destinationTokenForChainOverride[deposit.originChainId];
|
|
59
|
+
return isDefined(override) ? toAddressType(override, this.chainId) : super.getDestinationTokenForDeposit(deposit);
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
setLatestBlockNumber(blockNumber: number): void {
|