@across-protocol/sdk 4.2.9-alpha.1 → 4.2.9-alpha.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/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/cjs/arch/evm/SpokeUtils.js +22 -5
- package/dist/cjs/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/SpokeUtils.js +14 -11
- package/dist/cjs/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/cjs/arch/svm/utils.d.ts +1 -1
- package/dist/cjs/arch/svm/utils.js +15 -13
- 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 +63 -63
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.js +11 -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 +83 -59
- package/dist/cjs/clients/HubPoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -2
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +55 -49
- 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 +9 -13
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +42 -56
- package/dist/cjs/clients/mocks/MockSpokePoolClient.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 +14 -16
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js +7 -7
- package/dist/cjs/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js +14 -15
- package/dist/cjs/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js +7 -7
- package/dist/cjs/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/cjs/utils/AddressUtils.d.ts +6 -3
- package/dist/cjs/utils/AddressUtils.js +42 -14
- 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 +3 -3
- package/dist/cjs/utils/TokenUtils.js.map +1 -1
- package/dist/esm/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/esm/arch/evm/SpokeUtils.js +23 -6
- package/dist/esm/arch/evm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/SpokeUtils.js +14 -11
- package/dist/esm/arch/svm/SpokeUtils.js.map +1 -1
- package/dist/esm/arch/svm/utils.d.ts +1 -1
- package/dist/esm/arch/svm/utils.js +15 -13
- 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 +4 -3
- 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 +63 -63
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js +12 -9
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.js.map +1 -1
- package/dist/esm/clients/HubPoolClient.d.ts +23 -22
- package/dist/esm/clients/HubPoolClient.js +96 -63
- package/dist/esm/clients/HubPoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -3
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +5 -3
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +57 -50
- 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 +9 -13
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +46 -60
- package/dist/esm/clients/mocks/MockSpokePoolClient.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 +14 -16
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js +8 -8
- package/dist/esm/relayFeeCalculator/chain-queries/baseQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js +15 -16
- package/dist/esm/relayFeeCalculator/chain-queries/svmQuery.js.map +1 -1
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js +8 -8
- package/dist/esm/relayFeeCalculator/relayFeeCalculator.js.map +1 -1
- package/dist/esm/utils/AddressUtils.d.ts +7 -3
- package/dist/esm/utils/AddressUtils.js +52 -19
- 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 +18 -16
- package/dist/esm/utils/TokenUtils.js +3 -3
- package/dist/esm/utils/TokenUtils.js.map +1 -1
- package/dist/types/arch/evm/SpokeUtils.d.ts +5 -2
- package/dist/types/arch/evm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/SpokeUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts +1 -1
- 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 +63 -63
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts.map +1 -1
- package/dist/types/clients/HubPoolClient.d.ts +23 -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 +5 -3
- 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 +9 -13
- package/dist/types/clients/mocks/MockSpokePoolClient.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 +14 -16
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts +6 -6
- package/dist/types/relayFeeCalculator/chain-queries/baseQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts +4 -4
- package/dist/types/relayFeeCalculator/chain-queries/svmQuery.d.ts.map +1 -1
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts +5 -5
- package/dist/types/relayFeeCalculator/relayFeeCalculator.d.ts.map +1 -1
- package/dist/types/utils/AddressUtils.d.ts +7 -3
- 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 +18 -16
- package/dist/types/utils/TokenUtils.d.ts.map +1 -1
- package/package.json +1 -2
- package/src/arch/evm/SpokeUtils.ts +41 -11
- package/src/arch/svm/SpokeUtils.ts +23 -9
- package/src/arch/svm/utils.ts +3 -3
- package/src/clients/AcrossConfigStoreClient/AcrossConfigStoreClient.ts +7 -4
- package/src/clients/BundleDataClient/BundleDataClient.ts +54 -52
- package/src/clients/BundleDataClient/utils/DataworkerUtils.ts +28 -13
- package/src/clients/BundleDataClient/utils/FillUtils.ts +6 -4
- 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 +13 -9
- package/src/clients/HubPoolClient.ts +122 -82
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +7 -1
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +113 -43
- package/src/clients/mocks/MockHubPoolClient.ts +24 -19
- package/src/clients/mocks/MockSpokePoolClient.ts +55 -74
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +12 -3
- package/src/interfaces/HubPool.ts +23 -14
- package/src/interfaces/SpokePool.ts +14 -17
- package/src/relayFeeCalculator/chain-queries/baseQuery.ts +10 -8
- package/src/relayFeeCalculator/chain-queries/svmQuery.ts +16 -21
- package/src/relayFeeCalculator/relayFeeCalculator.ts +20 -12
- package/src/utils/AddressUtils.ts +56 -21
- package/src/utils/SpokeUtils.ts +11 -33
- package/src/utils/TokenUtils.ts +7 -7
|
@@ -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,
|
|
@@ -25,9 +25,11 @@ import {
|
|
|
25
25
|
BigNumber,
|
|
26
26
|
bnZero,
|
|
27
27
|
bnOne,
|
|
28
|
-
toAddress,
|
|
29
28
|
toBytes32,
|
|
30
29
|
spreadEventWithBlockNumber,
|
|
30
|
+
Address,
|
|
31
|
+
toAddressType,
|
|
32
|
+
isDefined,
|
|
31
33
|
} from "../../utils";
|
|
32
34
|
import { EVMSpokePoolClient, SpokePoolUpdate } from "../SpokePoolClient";
|
|
33
35
|
import { HubPoolClient } from "../HubPoolClient";
|
|
@@ -63,8 +65,11 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
63
65
|
this.destinationTokenForChainOverride[chainId] = token;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
getDestinationTokenForDeposit(deposit: DepositWithBlock):
|
|
67
|
-
|
|
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);
|
|
68
73
|
}
|
|
69
74
|
|
|
70
75
|
setLatestBlockNumber(blockNumber: number): void {
|
|
@@ -85,6 +90,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
85
90
|
lastDepositId = _depositIds[i];
|
|
86
91
|
}
|
|
87
92
|
}
|
|
93
|
+
|
|
88
94
|
_getDepositIdAtBlock(blockTag: number): Promise<BigNumber> {
|
|
89
95
|
return Promise.resolve(this.depositIdAtBlock[blockTag]);
|
|
90
96
|
}
|
|
@@ -129,28 +135,26 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
129
135
|
return this._deposit("FundsDeposited", deposit);
|
|
130
136
|
}
|
|
131
137
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
protected _deposit(event: string, deposit: Omit<Deposit, "messageHash"> & Partial<SortableEvent>): Log {
|
|
138
|
+
protected _deposit(
|
|
139
|
+
event: string,
|
|
140
|
+
deposit: Omit<Deposit, "messageHash"> & { message?: string } & Partial<SortableEvent>
|
|
141
|
+
): Log {
|
|
137
142
|
const { blockNumber, txnIndex } = deposit;
|
|
138
143
|
let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
|
|
139
144
|
depositId ??= this.numberOfDeposits;
|
|
140
145
|
this.numberOfDeposits = depositId.add(bnOne);
|
|
141
146
|
|
|
142
147
|
destinationChainId ??= random(1, 42161, false);
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
const
|
|
148
|
-
const exclusiveRelayer = addressModifier(deposit.exclusiveRelayer ?? ZERO_ADDRESS);
|
|
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);
|
|
149
153
|
|
|
150
154
|
inputAmount ??= toBNWei(random(1, 1000, false));
|
|
151
155
|
outputAmount ??= inputAmount.mul(toBN("0.95"));
|
|
152
156
|
|
|
153
|
-
const message = deposit
|
|
157
|
+
const message = deposit.message ?? "0x";
|
|
154
158
|
const topics = [destinationChainId, depositId, depositor];
|
|
155
159
|
const quoteTimestamp = deposit.quoteTimestamp ?? getCurrentTime();
|
|
156
160
|
const args = {
|
|
@@ -180,17 +184,13 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
180
184
|
});
|
|
181
185
|
}
|
|
182
186
|
|
|
183
|
-
|
|
184
|
-
return this._fillRelay("FilledV3Relay", fill);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
fillRelay(fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>): Log {
|
|
187
|
+
fillRelay(fill: Omit<Fill, "messageHash"> & { message?: string } & Partial<SortableEvent>): Log {
|
|
188
188
|
return this._fillRelay("FilledRelay", fill);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
191
|
protected _fillRelay(
|
|
192
192
|
event: string,
|
|
193
|
-
fill: Omit<Fill, "messageHash"> & { message
|
|
193
|
+
fill: Omit<Fill, "messageHash"> & { message?: string } & Partial<SortableEvent>
|
|
194
194
|
): Log {
|
|
195
195
|
const { blockNumber, txnIndex } = fill;
|
|
196
196
|
let { originChainId, depositId, inputAmount, outputAmount, fillDeadline } = fill;
|
|
@@ -200,20 +200,20 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
200
200
|
outputAmount ??= inputAmount;
|
|
201
201
|
fillDeadline ??= getCurrentTime() + 60;
|
|
202
202
|
|
|
203
|
-
const
|
|
204
|
-
const
|
|
205
|
-
const
|
|
206
|
-
const
|
|
207
|
-
const
|
|
208
|
-
const
|
|
209
|
-
const relayer = addressModifier(fill.relayer ?? randomAddress());
|
|
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());
|
|
210
209
|
|
|
211
|
-
const topics = [originChainId, depositId, relayer];
|
|
210
|
+
const topics = [originChainId, depositId, relayer];
|
|
212
211
|
const message = fill.message ?? EMPTY_MESSAGE;
|
|
213
212
|
const updatedMessage = fill.relayExecutionInfo?.updatedMessage ?? message;
|
|
213
|
+
const updatedRecipient = fill.relayExecutionInfo?.updatedRecipient.toBytes32() ?? recipient;
|
|
214
214
|
|
|
215
215
|
const relayExecutionInfo = {
|
|
216
|
-
updatedRecipient
|
|
216
|
+
updatedRecipient,
|
|
217
217
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
218
218
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
219
219
|
};
|
|
@@ -233,31 +233,20 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
233
233
|
depositor,
|
|
234
234
|
recipient,
|
|
235
235
|
relayExecutionInfo: {
|
|
236
|
-
updatedRecipient
|
|
236
|
+
updatedRecipient,
|
|
237
237
|
updatedOutputAmount: fill.relayExecutionInfo?.updatedOutputAmount ?? outputAmount,
|
|
238
238
|
fillType: fill.relayExecutionInfo?.fillType ?? FillType.FastFill,
|
|
239
239
|
},
|
|
240
240
|
};
|
|
241
241
|
|
|
242
|
-
const args =
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
},
|
|
251
|
-
}
|
|
252
|
-
: {
|
|
253
|
-
// FilledV3Relay
|
|
254
|
-
..._args,
|
|
255
|
-
message,
|
|
256
|
-
relayExecutionInfo: {
|
|
257
|
-
...relayExecutionInfo,
|
|
258
|
-
updatedMessage,
|
|
259
|
-
},
|
|
260
|
-
};
|
|
242
|
+
const args = {
|
|
243
|
+
..._args,
|
|
244
|
+
messageHash: getMessageHash(message),
|
|
245
|
+
relayExecutionInfo: {
|
|
246
|
+
...relayExecutionInfo,
|
|
247
|
+
updatedMessageHash: getMessageHash(updatedMessage),
|
|
248
|
+
},
|
|
249
|
+
};
|
|
261
250
|
|
|
262
251
|
return this.eventManager.generateEvent({
|
|
263
252
|
event,
|
|
@@ -269,17 +258,12 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
269
258
|
});
|
|
270
259
|
}
|
|
271
260
|
|
|
272
|
-
speedUpV3Deposit(speedUp: SpeedUp): Log {
|
|
273
|
-
return this._speedUpDeposit("RequestedSpeedUpV3Deposit", speedUp);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
261
|
speedUpDeposit(speedUp: SpeedUp): Log {
|
|
277
262
|
return this._speedUpDeposit("RequestedSpeedUpDeposit", speedUp);
|
|
278
263
|
}
|
|
279
264
|
|
|
280
265
|
protected _speedUpDeposit(event: string, speedUp: SpeedUp): Log {
|
|
281
|
-
const
|
|
282
|
-
const depositor = addressModifier(speedUp.depositor);
|
|
266
|
+
const depositor = speedUp.depositor.toBytes32();
|
|
283
267
|
const topics = [speedUp.depositId, depositor];
|
|
284
268
|
const args = { ...speedUp };
|
|
285
269
|
|
|
@@ -290,7 +274,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
290
274
|
args: {
|
|
291
275
|
...args,
|
|
292
276
|
depositor,
|
|
293
|
-
updatedRecipient:
|
|
277
|
+
updatedRecipient: speedUp.updatedRecipient.toBytes32(),
|
|
294
278
|
},
|
|
295
279
|
});
|
|
296
280
|
}
|
|
@@ -308,24 +292,19 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
308
292
|
});
|
|
309
293
|
}
|
|
310
294
|
|
|
311
|
-
|
|
312
|
-
return this._requestSlowFill("RequestedV3SlowFill", request);
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
requestSlowFill(request: Omit<SlowFillRequest, "messageHash"> & Partial<SortableEvent>): Log {
|
|
295
|
+
requestSlowFill(request: Omit<SlowFillRequest, "destinationChainId"> & Partial<SortableEvent>): Log {
|
|
316
296
|
return this._requestSlowFill("RequestedSlowFill", request);
|
|
317
297
|
}
|
|
318
298
|
|
|
319
299
|
protected _requestSlowFill(
|
|
320
300
|
event: string,
|
|
321
|
-
request: Omit<SlowFillRequest, "
|
|
301
|
+
request: Omit<SlowFillRequest, "destinationChainId"> & Partial<SortableEvent>
|
|
322
302
|
): Log {
|
|
323
303
|
const { originChainId, depositId } = request;
|
|
324
304
|
const topics = [originChainId, depositId];
|
|
325
305
|
const args = { ...request };
|
|
326
306
|
|
|
327
|
-
const
|
|
328
|
-
const depositor = addressModifier(args.depositor ?? randomAddress());
|
|
307
|
+
const depositor = args.depositor.toBytes32() ?? toBytes32(randomAddress());
|
|
329
308
|
|
|
330
309
|
return this.eventManager.generateEvent({
|
|
331
310
|
event,
|
|
@@ -333,24 +312,26 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
333
312
|
topics: topics.map((topic) => topic.toString()),
|
|
334
313
|
args: {
|
|
335
314
|
...args,
|
|
315
|
+
destinationChainId: this.chainId,
|
|
336
316
|
depositor,
|
|
337
|
-
recipient:
|
|
338
|
-
inputToken:
|
|
339
|
-
outputToken:
|
|
340
|
-
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,
|
|
341
322
|
},
|
|
342
323
|
blockNumber: request.blockNumber,
|
|
343
324
|
transactionIndex: request.txnIndex,
|
|
344
325
|
});
|
|
345
326
|
}
|
|
346
327
|
|
|
347
|
-
// This is a simple wrapper around
|
|
328
|
+
// This is a simple wrapper around fillRelay().
|
|
348
329
|
// rootBundleId and proof are discarded here - we have no interest in verifying that.
|
|
349
|
-
|
|
330
|
+
executeSlowRelayLeaf(leaf: Omit<SlowFillLeaf, "messageHash">): Log {
|
|
350
331
|
const fill = {
|
|
351
332
|
...leaf.relayData,
|
|
352
333
|
destinationChainId: this.chainId,
|
|
353
|
-
relayer: ZERO_ADDRESS,
|
|
334
|
+
relayer: toAddressType(ZERO_ADDRESS),
|
|
354
335
|
repaymentChainId: 0,
|
|
355
336
|
relayExecutionInfo: {
|
|
356
337
|
updatedRecipient: leaf.relayData.recipient,
|
|
@@ -361,7 +342,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
361
342
|
},
|
|
362
343
|
};
|
|
363
344
|
|
|
364
|
-
return this.
|
|
345
|
+
return this.fillRelay(fill);
|
|
365
346
|
}
|
|
366
347
|
|
|
367
348
|
executeRelayerRefundLeaf(refund: RelayerRefundExecution & Partial<SortableEvent>): Log {
|
|
@@ -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) : super.getDestinationTokenForDeposit(deposit);
|
|
51
60
|
}
|
|
52
61
|
|
|
53
62
|
setLatestBlockNumber(blockNumber: number): void {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigNumber } from "../utils";
|
|
1
|
+
import { Address, BigNumber, EvmAddress } from "../utils";
|
|
2
2
|
import { SortableEvent } from "./Common";
|
|
3
3
|
|
|
4
4
|
export interface PoolRebalanceLeaf {
|
|
@@ -8,7 +8,7 @@ export interface PoolRebalanceLeaf {
|
|
|
8
8
|
netSendAmounts: BigNumber[];
|
|
9
9
|
runningBalances: BigNumber[];
|
|
10
10
|
leafId: number;
|
|
11
|
-
l1Tokens:
|
|
11
|
+
l1Tokens: EvmAddress[];
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export interface RelayerRefundLeaf {
|
|
@@ -16,8 +16,8 @@ export interface RelayerRefundLeaf {
|
|
|
16
16
|
chainId: number;
|
|
17
17
|
refundAmounts: BigNumber[];
|
|
18
18
|
leafId: number;
|
|
19
|
-
l2TokenAddress:
|
|
20
|
-
refundAddresses:
|
|
19
|
+
l2TokenAddress: Address;
|
|
20
|
+
refundAddresses: Address[];
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface ProposedRootBundle extends SortableEvent {
|
|
@@ -27,7 +27,7 @@ export interface ProposedRootBundle extends SortableEvent {
|
|
|
27
27
|
poolRebalanceRoot: string;
|
|
28
28
|
relayerRefundRoot: string;
|
|
29
29
|
slowRelayRoot: string;
|
|
30
|
-
proposer:
|
|
30
|
+
proposer: EvmAddress;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export type RealizedLpFee = {
|
|
@@ -55,7 +55,7 @@ export interface ExecutedRootBundle extends SortableEvent {
|
|
|
55
55
|
netSendAmounts: BigNumber[];
|
|
56
56
|
runningBalances: BigNumber[];
|
|
57
57
|
leafId: number;
|
|
58
|
-
l1Tokens:
|
|
58
|
+
l1Tokens: EvmAddress[];
|
|
59
59
|
proof: string[];
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -76,8 +76,14 @@ export interface RelayerRefundLeafWithGroup extends RelayerRefundLeaf {
|
|
|
76
76
|
groupIndex: number;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export interface
|
|
80
|
-
address:
|
|
79
|
+
export interface L1TokenInfo {
|
|
80
|
+
address: EvmAddress;
|
|
81
|
+
symbol: string;
|
|
82
|
+
decimals: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface TokenInfo {
|
|
86
|
+
address: Address;
|
|
81
87
|
symbol: string;
|
|
82
88
|
decimals: number;
|
|
83
89
|
}
|
|
@@ -87,27 +93,30 @@ export interface LpToken {
|
|
|
87
93
|
liquidReserves: BigNumber;
|
|
88
94
|
}
|
|
89
95
|
|
|
96
|
+
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
90
97
|
export interface CrossChainContractsSet extends SortableEvent {
|
|
91
98
|
l2ChainId: number;
|
|
92
|
-
spokePool:
|
|
99
|
+
spokePool: Address;
|
|
93
100
|
}
|
|
94
101
|
|
|
102
|
+
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
95
103
|
export interface DestinationTokenWithBlock extends SortableEvent {
|
|
96
|
-
l2Token:
|
|
97
|
-
l1Token:
|
|
104
|
+
l2Token: Address;
|
|
105
|
+
l1Token: EvmAddress;
|
|
98
106
|
}
|
|
99
107
|
|
|
108
|
+
// TODO: I think I don't change string -> Address in the Events. I change right after the event is read
|
|
100
109
|
export interface SetPoolRebalanceRoot extends SortableEvent {
|
|
101
110
|
destinationChainId: number;
|
|
102
|
-
l1Token:
|
|
103
|
-
destinationToken:
|
|
111
|
+
l1Token: EvmAddress;
|
|
112
|
+
destinationToken: Address;
|
|
104
113
|
}
|
|
105
114
|
|
|
106
115
|
export interface PendingRootBundle {
|
|
107
116
|
poolRebalanceRoot: string;
|
|
108
117
|
relayerRefundRoot: string;
|
|
109
118
|
slowRelayRoot: string;
|
|
110
|
-
proposer:
|
|
119
|
+
proposer: EvmAddress;
|
|
111
120
|
unclaimedPoolRebalanceLeafCount: number;
|
|
112
121
|
challengePeriodEndTimestamp: number;
|
|
113
122
|
bundleEvaluationBlockNumbers: number[];
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import { SortableEvent } from "./Common";
|
|
2
|
-
import { FilledV3RelayEvent, V3FundsDepositedEvent } from "../typechain";
|
|
3
2
|
import { SpokePoolClient } from "../clients";
|
|
4
|
-
import { BigNumber } from "../utils";
|
|
3
|
+
import { BigNumber, Address, EvmAddress } from "../utils";
|
|
5
4
|
import { RelayerRefundLeaf } from "./HubPool";
|
|
6
5
|
|
|
7
|
-
export type { FilledV3RelayEvent, V3FundsDepositedEvent };
|
|
8
|
-
|
|
9
6
|
export interface RelayData {
|
|
10
7
|
originChainId: number;
|
|
11
|
-
depositor:
|
|
12
|
-
recipient:
|
|
8
|
+
depositor: Address;
|
|
9
|
+
recipient: Address;
|
|
13
10
|
depositId: BigNumber;
|
|
14
|
-
inputToken:
|
|
11
|
+
inputToken: Address;
|
|
15
12
|
inputAmount: BigNumber;
|
|
16
|
-
outputToken:
|
|
13
|
+
outputToken: Address;
|
|
17
14
|
outputAmount: BigNumber;
|
|
18
15
|
message: string;
|
|
19
16
|
fillDeadline: number;
|
|
20
|
-
exclusiveRelayer:
|
|
17
|
+
exclusiveRelayer: Address;
|
|
21
18
|
exclusivityDeadline: number;
|
|
22
19
|
}
|
|
23
20
|
|
|
@@ -26,7 +23,7 @@ export interface Deposit extends RelayData {
|
|
|
26
23
|
destinationChainId: number;
|
|
27
24
|
quoteTimestamp: number;
|
|
28
25
|
speedUpSignature?: string;
|
|
29
|
-
updatedRecipient?:
|
|
26
|
+
updatedRecipient?: Address;
|
|
30
27
|
updatedOutputAmount?: BigNumber;
|
|
31
28
|
updatedMessage?: string;
|
|
32
29
|
fromLiteChain: boolean;
|
|
@@ -54,7 +51,7 @@ export enum FillType {
|
|
|
54
51
|
}
|
|
55
52
|
|
|
56
53
|
export interface RelayExecutionEventInfo {
|
|
57
|
-
updatedRecipient:
|
|
54
|
+
updatedRecipient: Address;
|
|
58
55
|
updatedOutputAmount: BigNumber;
|
|
59
56
|
updatedMessage?: string;
|
|
60
57
|
updatedMessageHash: string;
|
|
@@ -64,7 +61,7 @@ export interface RelayExecutionEventInfo {
|
|
|
64
61
|
export interface Fill extends Omit<RelayData, "message"> {
|
|
65
62
|
messageHash: string;
|
|
66
63
|
destinationChainId: number;
|
|
67
|
-
relayer:
|
|
64
|
+
relayer: Address;
|
|
68
65
|
repaymentChainId: number;
|
|
69
66
|
relayExecutionInfo: RelayExecutionEventInfo;
|
|
70
67
|
}
|
|
@@ -75,25 +72,25 @@ export interface FillWithTime extends Fill, SortableEvent {
|
|
|
75
72
|
}
|
|
76
73
|
|
|
77
74
|
export interface EnabledDepositRoute {
|
|
78
|
-
originToken:
|
|
75
|
+
originToken: Address;
|
|
79
76
|
destinationChainId: number;
|
|
80
77
|
enabled: boolean;
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
export interface EnabledDepositRouteWithBlock extends EnabledDepositRoute, SortableEvent {}
|
|
84
81
|
export interface SpeedUp {
|
|
85
|
-
depositor:
|
|
82
|
+
depositor: EvmAddress;
|
|
86
83
|
depositorSignature: string;
|
|
87
84
|
depositId: BigNumber;
|
|
88
85
|
originChainId: number;
|
|
89
|
-
updatedRecipient:
|
|
86
|
+
updatedRecipient: Address;
|
|
90
87
|
updatedOutputAmount: BigNumber;
|
|
91
88
|
updatedMessage: string;
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
export interface SpeedUpWithBlock extends SpeedUp, SortableEvent {}
|
|
95
92
|
|
|
96
|
-
export interface SlowFillRequest extends RelayData {
|
|
93
|
+
export interface SlowFillRequest extends Omit<RelayData, "message"> {
|
|
97
94
|
messageHash: string;
|
|
98
95
|
destinationChainId: number;
|
|
99
96
|
}
|
|
@@ -133,7 +130,7 @@ export interface TokensBridged extends SortableEvent {
|
|
|
133
130
|
amountToReturn: BigNumber;
|
|
134
131
|
chainId: number;
|
|
135
132
|
leafId: number;
|
|
136
|
-
l2TokenAddress:
|
|
133
|
+
l2TokenAddress: Address;
|
|
137
134
|
}
|
|
138
135
|
|
|
139
136
|
export interface SpokePoolClientsByChain {
|
|
@@ -15,6 +15,8 @@ import {
|
|
|
15
15
|
bnZero,
|
|
16
16
|
chainIsOPStack,
|
|
17
17
|
fixedPointAdjustment,
|
|
18
|
+
toAddressType,
|
|
19
|
+
Address,
|
|
18
20
|
} from "../../utils";
|
|
19
21
|
import assert from "assert";
|
|
20
22
|
import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
|
|
@@ -72,7 +74,7 @@ export class QueryBase implements QueryInterface {
|
|
|
72
74
|
*/
|
|
73
75
|
async getGasCosts(
|
|
74
76
|
deposit: Omit<Deposit, "messageHash">,
|
|
75
|
-
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
77
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
|
|
76
78
|
options: Partial<{
|
|
77
79
|
gasPrice: BigNumberish;
|
|
78
80
|
gasUnits: BigNumberish;
|
|
@@ -122,7 +124,7 @@ export class QueryBase implements QueryInterface {
|
|
|
122
124
|
*/
|
|
123
125
|
getUnsignedTxFromDeposit(
|
|
124
126
|
deposit: Omit<Deposit, "messageHash">,
|
|
125
|
-
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
127
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
|
|
126
128
|
): Promise<PopulatedTransaction> {
|
|
127
129
|
return populateV3Relay(this.spokePool, deposit, relayer);
|
|
128
130
|
}
|
|
@@ -135,10 +137,10 @@ export class QueryBase implements QueryInterface {
|
|
|
135
137
|
*/
|
|
136
138
|
async getNativeGasCost(
|
|
137
139
|
deposit: Omit<Deposit, "messageHash">,
|
|
138
|
-
relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
140
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
|
|
139
141
|
): Promise<BigNumber> {
|
|
140
142
|
const unsignedTx = await this.getUnsignedTxFromDeposit(deposit, relayer);
|
|
141
|
-
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
143
|
+
const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
|
|
142
144
|
return voidSigner.estimateGas(unsignedTx);
|
|
143
145
|
}
|
|
144
146
|
|
|
@@ -152,7 +154,7 @@ export class QueryBase implements QueryInterface {
|
|
|
152
154
|
*/
|
|
153
155
|
async getOpStackL1DataFee(
|
|
154
156
|
unsignedTx: PopulatedTransaction,
|
|
155
|
-
relayer = getDefaultSimulatedRelayerAddress(unsignedTx.chainId),
|
|
157
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(unsignedTx.chainId), unsignedTx.chainId),
|
|
156
158
|
options: Partial<{
|
|
157
159
|
opStackL2GasUnits: BigNumberish;
|
|
158
160
|
opStackL1DataFeeMultiplier: BigNumber;
|
|
@@ -161,7 +163,7 @@ export class QueryBase implements QueryInterface {
|
|
|
161
163
|
const { opStackL2GasUnits, opStackL1DataFeeMultiplier = toBNWei("1") } = options || {};
|
|
162
164
|
const { chainId } = await this.provider.getNetwork();
|
|
163
165
|
assert(isOptimismL2Provider(this.provider), `Unexpected provider for chain ID ${chainId}.`);
|
|
164
|
-
const voidSigner = new VoidSigner(relayer, this.provider);
|
|
166
|
+
const voidSigner = new VoidSigner(relayer.toEvmAddress(), this.provider);
|
|
165
167
|
const populatedTransaction = await voidSigner.populateTransaction({
|
|
166
168
|
...unsignedTx,
|
|
167
169
|
gasLimit: opStackL2GasUnits, // prevents additional gas estimation call
|
|
@@ -183,7 +185,7 @@ export class QueryBase implements QueryInterface {
|
|
|
183
185
|
*/
|
|
184
186
|
async estimateGas(
|
|
185
187
|
unsignedTx: PopulatedTransaction,
|
|
186
|
-
senderAddress:
|
|
188
|
+
senderAddress: Address,
|
|
187
189
|
provider: providers.Provider | L2Provider<providers.Provider>,
|
|
188
190
|
options: Partial<{
|
|
189
191
|
gasPrice: BigNumberish;
|
|
@@ -204,7 +206,7 @@ export class QueryBase implements QueryInterface {
|
|
|
204
206
|
} = options || {};
|
|
205
207
|
|
|
206
208
|
const { chainId } = await provider.getNetwork();
|
|
207
|
-
const voidSigner = new VoidSigner(senderAddress, provider);
|
|
209
|
+
const voidSigner = new VoidSigner(senderAddress.toEvmAddress(), provider);
|
|
208
210
|
|
|
209
211
|
// Estimate the Gas units required to submit this transaction.
|
|
210
212
|
const queries = [
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
getRelayDataHash,
|
|
26
26
|
toAddressType,
|
|
27
27
|
toBN,
|
|
28
|
+
Address,
|
|
28
29
|
} from "../../utils";
|
|
29
30
|
import { Logger, QueryInterface, getDefaultSimulatedRelayerAddress } from "../relayFeeCalculator";
|
|
30
31
|
import { SymbolMappingType } from "./";
|
|
@@ -74,7 +75,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
74
75
|
*/
|
|
75
76
|
async getGasCosts(
|
|
76
77
|
deposit: Omit<Deposit, "messageHash">,
|
|
77
|
-
_relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
78
|
+
_relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
|
|
78
79
|
options: Partial<{
|
|
79
80
|
gasPrice: BigNumberish;
|
|
80
81
|
gasUnits: BigNumberish;
|
|
@@ -82,8 +83,8 @@ export class SvmQuery implements QueryInterface {
|
|
|
82
83
|
priorityFeeMultiplier: BigNumber;
|
|
83
84
|
}> = {}
|
|
84
85
|
): Promise<TransactionCostEstimate> {
|
|
85
|
-
const relayer = _relayer ?
|
|
86
|
-
const fillRelayTx = await this.getFillRelayTx(deposit, relayer
|
|
86
|
+
const relayer = _relayer ? _relayer.forceSvmAddress() : this.simulatedRelayerAddress;
|
|
87
|
+
const fillRelayTx = await this.getFillRelayTx(deposit, relayer);
|
|
87
88
|
|
|
88
89
|
const [computeUnitsConsumed, _gasPriceEstimate] = await Promise.all([
|
|
89
90
|
toBN(await this.computeUnitEstimator(fillRelayTx)),
|
|
@@ -116,7 +117,7 @@ export class SvmQuery implements QueryInterface {
|
|
|
116
117
|
*/
|
|
117
118
|
async getNativeGasCost(
|
|
118
119
|
deposit: Omit<Deposit, "messageHash">,
|
|
119
|
-
_relayer = getDefaultSimulatedRelayerAddress(deposit.destinationChainId)
|
|
120
|
+
_relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId)
|
|
120
121
|
): Promise<BigNumber> {
|
|
121
122
|
const fillRelayTx = await this.getFillRelayTx(deposit, _relayer);
|
|
122
123
|
return toBN(await this.computeUnitEstimator(fillRelayTx));
|
|
@@ -130,35 +131,29 @@ export class SvmQuery implements QueryInterface {
|
|
|
130
131
|
*/
|
|
131
132
|
async getFillRelayTx(
|
|
132
133
|
deposit: Omit<Deposit, "messageHash">,
|
|
133
|
-
|
|
134
|
+
relayer = toAddressType(getDefaultSimulatedRelayerAddress(deposit.destinationChainId), deposit.destinationChainId),
|
|
134
135
|
repaymentChainId = deposit.destinationChainId,
|
|
135
|
-
repaymentAddress =
|
|
136
|
+
repaymentAddress = toAddressType(
|
|
137
|
+
getDefaultSimulatedRelayerAddress(deposit.destinationChainId),
|
|
138
|
+
deposit.destinationChainId
|
|
139
|
+
)
|
|
136
140
|
) {
|
|
137
|
-
const toSvmAddress = (address:
|
|
138
|
-
const relayer = _relayer ? toAddressType(_relayer).forceSvmAddress() : this.simulatedRelayerAddress;
|
|
141
|
+
const toSvmAddress = (address: Address) => address.toV2Address();
|
|
139
142
|
const state = await getStatePda(this.spokePoolAddress.toV2Address());
|
|
140
143
|
const _relayDataHash = getRelayDataHash(deposit, deposit.destinationChainId);
|
|
141
144
|
const relayDataHash = new Uint8Array(Buffer.from(_relayDataHash.slice(2), "hex"));
|
|
142
145
|
const delegate = await getFillRelayDelegatePda(
|
|
143
146
|
relayDataHash,
|
|
144
147
|
BigInt(repaymentChainId),
|
|
145
|
-
|
|
148
|
+
repaymentAddress.toV2Address(),
|
|
146
149
|
this.spokePoolAddress.toV2Address()
|
|
147
150
|
);
|
|
148
|
-
const mint =
|
|
151
|
+
const mint = deposit.outputToken;
|
|
149
152
|
const mintInfo = await fetchMint(this.provider, mint.toV2Address());
|
|
150
|
-
const recipientAta = await getAssociatedTokenAddress(
|
|
151
|
-
|
|
152
|
-
mint,
|
|
153
|
-
mintInfo.programAddress
|
|
154
|
-
);
|
|
155
|
-
const relayerAta = await getAssociatedTokenAddress(
|
|
156
|
-
SvmAddress.from(relayer.toBase58()),
|
|
157
|
-
mint,
|
|
158
|
-
mintInfo.programAddress
|
|
159
|
-
);
|
|
153
|
+
const recipientAta = await getAssociatedTokenAddress(deposit.recipient, mint, mintInfo.programAddress);
|
|
154
|
+
const relayerAta = await getAssociatedTokenAddress(relayer, mint, mintInfo.programAddress);
|
|
160
155
|
const fillStatus = await getFillStatusPda(this.spokePoolAddress.toV2Address(), deposit, deposit.destinationChainId);
|
|
161
|
-
const eventAuthority = await getEventAuthority();
|
|
156
|
+
const eventAuthority = await getEventAuthority(this.spokePoolAddress.toV2Address());
|
|
162
157
|
|
|
163
158
|
const relayData: SvmSpokeClient.FillRelayInput["relayData"] = {
|
|
164
159
|
depositor: toSvmAddress(deposit.depositor),
|