@across-protocol/sdk 4.2.2-alpha.0 → 4.2.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/svm/BlockUtils.d.ts +15 -0
- package/dist/cjs/arch/svm/BlockUtils.js +180 -0
- package/dist/cjs/arch/svm/BlockUtils.js.map +1 -0
- package/dist/cjs/arch/svm/index.d.ts +1 -0
- package/dist/cjs/arch/svm/index.js +1 -0
- package/dist/cjs/arch/svm/index.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/BundleDataClient.js +1 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js +2 -1
- package/dist/cjs/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +3 -3
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js +19 -18
- package/dist/cjs/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.d.ts +3 -4
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js +13 -5
- package/dist/cjs/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/cjs/clients/SpokePoolClient/index.d.ts +3 -3
- package/dist/cjs/clients/SpokePoolClient/index.js +5 -5
- package/dist/cjs/clients/index.d.ts +1 -1
- package/dist/cjs/clients/index.js +4 -2
- package/dist/cjs/clients/index.js.map +1 -1
- package/dist/cjs/clients/mocks/MockSpokePoolClient.d.ts +11 -5
- package/dist/cjs/clients/mocks/MockSpokePoolClient.js +35 -18
- 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 +1 -1
- package/dist/cjs/constants.d.ts +1 -1
- package/dist/cjs/constants.js +3 -1
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/gasPriceOracle/adapters/solana.d.ts +2 -2
- package/dist/cjs/gasPriceOracle/oracle.d.ts +3 -2
- package/dist/cjs/gasPriceOracle/oracle.js +1 -3
- package/dist/cjs/gasPriceOracle/oracle.js.map +1 -1
- package/dist/cjs/gasPriceOracle/types.d.ts +2 -0
- package/dist/cjs/gasPriceOracle/types.js +12 -0
- package/dist/cjs/gasPriceOracle/types.js.map +1 -1
- package/dist/cjs/interfaces/SpokePool.d.ts +3 -1
- package/dist/cjs/interfaces/SpokePool.js.map +1 -1
- package/dist/cjs/providers/infura.js +1 -0
- package/dist/cjs/providers/infura.js.map +1 -1
- package/dist/cjs/utils/BlockFinder.d.ts +0 -1
- package/dist/cjs/utils/BlockFinder.js.map +1 -1
- package/dist/cjs/utils/NetworkUtils.d.ts +0 -2
- package/dist/cjs/utils/NetworkUtils.js +18 -26
- package/dist/cjs/utils/NetworkUtils.js.map +1 -1
- package/dist/cjs/utils/TypeGuards.d.ts +3 -0
- package/dist/cjs/utils/TypeGuards.js +6 -1
- package/dist/cjs/utils/TypeGuards.js.map +1 -1
- package/dist/esm/arch/svm/BlockUtils.d.ts +25 -0
- package/dist/esm/arch/svm/BlockUtils.js +207 -0
- package/dist/esm/arch/svm/BlockUtils.js.map +1 -0
- package/dist/esm/arch/svm/index.d.ts +1 -0
- package/dist/esm/arch/svm/index.js +1 -0
- package/dist/esm/arch/svm/index.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/BundleDataClient.js +2 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js +3 -2
- package/dist/esm/clients/SpokePoolClient/EVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +3 -3
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js +19 -18
- package/dist/esm/clients/SpokePoolClient/SVMSpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.d.ts +3 -4
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js +13 -5
- package/dist/esm/clients/SpokePoolClient/SpokePoolClient.js.map +1 -1
- package/dist/esm/clients/SpokePoolClient/index.d.ts +3 -3
- package/dist/esm/clients/SpokePoolClient/index.js +4 -4
- package/dist/esm/clients/index.d.ts +1 -1
- package/dist/esm/clients/index.js +1 -1
- package/dist/esm/clients/index.js.map +1 -1
- package/dist/esm/clients/mocks/MockSpokePoolClient.d.ts +11 -5
- package/dist/esm/clients/mocks/MockSpokePoolClient.js +38 -21
- 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 +2 -2
- package/dist/esm/constants.d.ts +1 -1
- package/dist/esm/constants.js +1 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/gasPriceOracle/adapters/solana.d.ts +2 -2
- package/dist/esm/gasPriceOracle/oracle.d.ts +3 -8
- package/dist/esm/gasPriceOracle/oracle.js +3 -6
- package/dist/esm/gasPriceOracle/oracle.js.map +1 -1
- package/dist/esm/gasPriceOracle/types.d.ts +2 -0
- package/dist/esm/gasPriceOracle/types.js +9 -1
- package/dist/esm/gasPriceOracle/types.js.map +1 -1
- package/dist/esm/interfaces/SpokePool.d.ts +3 -1
- package/dist/esm/interfaces/SpokePool.js.map +1 -1
- package/dist/esm/providers/infura.js +1 -0
- package/dist/esm/providers/infura.js.map +1 -1
- package/dist/esm/utils/BlockFinder.d.ts +0 -1
- package/dist/esm/utils/BlockFinder.js.map +1 -1
- package/dist/esm/utils/NetworkUtils.d.ts +0 -12
- package/dist/esm/utils/NetworkUtils.js +5 -19
- package/dist/esm/utils/NetworkUtils.js.map +1 -1
- package/dist/esm/utils/TypeGuards.d.ts +3 -0
- package/dist/esm/utils/TypeGuards.js +4 -0
- package/dist/esm/utils/TypeGuards.js.map +1 -1
- package/dist/types/arch/svm/BlockUtils.d.ts +26 -0
- package/dist/types/arch/svm/BlockUtils.d.ts.map +1 -0
- package/dist/types/arch/svm/index.d.ts +1 -0
- package/dist/types/arch/svm/index.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/EVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts +3 -3
- package/dist/types/clients/SpokePoolClient/SVMSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts +3 -4
- package/dist/types/clients/SpokePoolClient/SpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/SpokePoolClient/index.d.ts +3 -3
- package/dist/types/clients/index.d.ts +1 -1
- package/dist/types/clients/index.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts +11 -5
- package/dist/types/clients/mocks/MockSpokePoolClient.d.ts.map +1 -1
- package/dist/types/clients/mocks/MockSvmSpokePoolClient.d.ts +2 -2
- package/dist/types/constants.d.ts +1 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/adapters/solana.d.ts +2 -2
- package/dist/types/gasPriceOracle/adapters/solana.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/oracle.d.ts +3 -8
- package/dist/types/gasPriceOracle/oracle.d.ts.map +1 -1
- package/dist/types/gasPriceOracle/types.d.ts +2 -0
- package/dist/types/gasPriceOracle/types.d.ts.map +1 -1
- package/dist/types/interfaces/SpokePool.d.ts +3 -1
- package/dist/types/interfaces/SpokePool.d.ts.map +1 -1
- package/dist/types/providers/infura.d.ts.map +1 -1
- package/dist/types/utils/BlockFinder.d.ts +0 -1
- package/dist/types/utils/BlockFinder.d.ts.map +1 -1
- package/dist/types/utils/NetworkUtils.d.ts +0 -12
- package/dist/types/utils/NetworkUtils.d.ts.map +1 -1
- package/dist/types/utils/TypeGuards.d.ts +3 -0
- package/dist/types/utils/TypeGuards.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/arch/svm/BlockUtils.ts +166 -0
- package/src/arch/svm/index.ts +1 -0
- package/src/clients/BundleDataClient/BundleDataClient.ts +2 -2
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +3 -1
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +6 -4
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +18 -8
- package/src/clients/SpokePoolClient/index.ts +4 -4
- package/src/clients/index.ts +8 -1
- package/src/clients/mocks/MockSpokePoolClient.ts +66 -36
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +2 -2
- package/src/constants.ts +2 -0
- package/src/gasPriceOracle/adapters/solana.ts +2 -2
- package/src/gasPriceOracle/oracle.ts +16 -5
- package/src/gasPriceOracle/types.ts +11 -1
- package/src/interfaces/SpokePool.ts +4 -1
- package/src/providers/infura.ts +1 -0
- package/src/utils/BlockFinder.ts +0 -1
- package/src/utils/NetworkUtils.ts +13 -21
- package/src/utils/TypeGuards.ts +7 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { EVMSpokePoolClient } from "./EVMSpokePoolClient";
|
|
2
|
-
import {
|
|
2
|
+
import { SVMSpokePoolClient } from "./SVMSpokePoolClient";
|
|
3
3
|
import { SpokePoolClient } from "./SpokePoolClient";
|
|
4
4
|
|
|
5
5
|
export { EVMSpokePoolClient } from "./EVMSpokePoolClient";
|
|
6
6
|
export { SpokePoolClient, SpokePoolUpdate } from "./SpokePoolClient";
|
|
7
|
-
export {
|
|
7
|
+
export { SVMSpokePoolClient } from "./SVMSpokePoolClient";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Checks if a SpokePoolClient is an EVMSpokePoolClient.
|
|
@@ -20,6 +20,6 @@ export function isEVMSpokePoolClient(spokePoolClient: SpokePoolClient): spokePoo
|
|
|
20
20
|
* @param spokePoolClient The SpokePoolClient to check.
|
|
21
21
|
* @returns True if the SpokePoolClient is an SVMSpokePoolClient, false otherwise.
|
|
22
22
|
*/
|
|
23
|
-
export function
|
|
24
|
-
return spokePoolClient instanceof
|
|
23
|
+
export function isSVMSpokePoolClient(spokePoolClient: SpokePoolClient): spokePoolClient is SVMSpokePoolClient {
|
|
24
|
+
return spokePoolClient instanceof SVMSpokePoolClient;
|
|
25
25
|
}
|
package/src/clients/index.ts
CHANGED
|
@@ -6,6 +6,13 @@ export {
|
|
|
6
6
|
} from "./AcrossConfigStoreClient";
|
|
7
7
|
export { UpdateFailureReason } from "./BaseAbstractClient";
|
|
8
8
|
export { HubPoolClient, LpFeeRequest } from "./HubPoolClient";
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
SpokePoolClient,
|
|
11
|
+
SpokePoolUpdate,
|
|
12
|
+
EVMSpokePoolClient,
|
|
13
|
+
SVMSpokePoolClient,
|
|
14
|
+
isEVMSpokePoolClient,
|
|
15
|
+
isSVMSpokePoolClient,
|
|
16
|
+
} from "./SpokePoolClient";
|
|
10
17
|
export * as BundleDataClient from "./BundleDataClient";
|
|
11
18
|
export * as mocks from "./mocks";
|
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
BigNumber,
|
|
26
26
|
bnZero,
|
|
27
27
|
bnOne,
|
|
28
|
+
toAddress,
|
|
28
29
|
toBytes32,
|
|
29
30
|
spreadEventWithBlockNumber,
|
|
30
31
|
} from "../../utils";
|
|
@@ -84,7 +85,6 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
84
85
|
lastDepositId = _depositIds[i];
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
|
-
|
|
88
88
|
_getDepositIdAtBlock(blockTag: number): Promise<BigNumber> {
|
|
89
89
|
return Promise.resolve(this.depositIdAtBlock[blockTag]);
|
|
90
90
|
}
|
|
@@ -129,6 +129,10 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
129
129
|
return this._deposit("FundsDeposited", deposit);
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
depositV3(deposit: Omit<Deposit, "messageHash"> & Partial<SortableEvent>): Log {
|
|
133
|
+
return this._deposit("V3FundsDeposited", deposit);
|
|
134
|
+
}
|
|
135
|
+
|
|
132
136
|
protected _deposit(event: string, deposit: Omit<Deposit, "messageHash"> & Partial<SortableEvent>): Log {
|
|
133
137
|
const { blockNumber, txnIndex } = deposit;
|
|
134
138
|
let { depositId, destinationChainId, inputAmount, outputAmount } = deposit;
|
|
@@ -136,11 +140,12 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
136
140
|
this.numberOfDeposits = depositId.add(bnOne);
|
|
137
141
|
|
|
138
142
|
destinationChainId ??= random(1, 42161, false);
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
const
|
|
143
|
+
const addressModifier = event === "FundsDeposited" ? toBytes32 : toAddress;
|
|
144
|
+
const depositor = addressModifier(deposit.depositor ?? randomAddress());
|
|
145
|
+
const recipient = addressModifier(deposit.recipient ?? depositor);
|
|
146
|
+
const inputToken = addressModifier(deposit.inputToken ?? randomAddress());
|
|
147
|
+
const outputToken = addressModifier(deposit.outputToken ?? inputToken);
|
|
148
|
+
const exclusiveRelayer = addressModifier(deposit.exclusiveRelayer ?? ZERO_ADDRESS);
|
|
144
149
|
|
|
145
150
|
inputAmount ??= toBNWei(random(1, 1000, false));
|
|
146
151
|
outputAmount ??= inputAmount.mul(toBN("0.95"));
|
|
@@ -175,13 +180,17 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
175
180
|
});
|
|
176
181
|
}
|
|
177
182
|
|
|
178
|
-
|
|
183
|
+
fillV3Relay(fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>): Log {
|
|
184
|
+
return this._fillRelay("FilledV3Relay", fill);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
fillRelay(fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>): Log {
|
|
179
188
|
return this._fillRelay("FilledRelay", fill);
|
|
180
189
|
}
|
|
181
190
|
|
|
182
191
|
protected _fillRelay(
|
|
183
192
|
event: string,
|
|
184
|
-
fill: Omit<Fill, "messageHash"> & { message
|
|
193
|
+
fill: Omit<Fill, "messageHash"> & { message: string } & Partial<SortableEvent>
|
|
185
194
|
): Log {
|
|
186
195
|
const { blockNumber, txnIndex } = fill;
|
|
187
196
|
let { originChainId, depositId, inputAmount, outputAmount, fillDeadline } = fill;
|
|
@@ -191,14 +200,15 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
191
200
|
outputAmount ??= inputAmount;
|
|
192
201
|
fillDeadline ??= getCurrentTime() + 60;
|
|
193
202
|
|
|
194
|
-
const
|
|
195
|
-
const
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
const
|
|
203
|
+
const addressModifier = event === "FilledRelay" ? toBytes32 : toAddress;
|
|
204
|
+
const depositor = addressModifier(fill.depositor ?? randomAddress());
|
|
205
|
+
const recipient = addressModifier(fill.recipient ?? depositor);
|
|
206
|
+
const inputToken = addressModifier(fill.inputToken ?? randomAddress());
|
|
207
|
+
const outputToken = addressModifier(fill.outputToken ?? ZERO_ADDRESS);
|
|
208
|
+
const exclusiveRelayer = addressModifier(fill.exclusiveRelayer ?? ZERO_ADDRESS);
|
|
209
|
+
const relayer = addressModifier(fill.relayer ?? randomAddress());
|
|
200
210
|
|
|
201
|
-
const topics = [originChainId, depositId, relayer];
|
|
211
|
+
const topics = [originChainId, depositId, relayer]; // @todo verify
|
|
202
212
|
const message = fill.message ?? EMPTY_MESSAGE;
|
|
203
213
|
const updatedMessage = fill.relayExecutionInfo?.updatedMessage ?? message;
|
|
204
214
|
|
|
@@ -229,14 +239,25 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
229
239
|
},
|
|
230
240
|
};
|
|
231
241
|
|
|
232
|
-
const args =
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
242
|
+
const args =
|
|
243
|
+
event === "FilledRelay"
|
|
244
|
+
? {
|
|
245
|
+
..._args,
|
|
246
|
+
messageHash: getMessageHash(message),
|
|
247
|
+
relayExecutionInfo: {
|
|
248
|
+
...relayExecutionInfo,
|
|
249
|
+
updatedMessageHash: getMessageHash(updatedMessage),
|
|
250
|
+
},
|
|
251
|
+
}
|
|
252
|
+
: {
|
|
253
|
+
// FilledV3Relay
|
|
254
|
+
..._args,
|
|
255
|
+
message,
|
|
256
|
+
relayExecutionInfo: {
|
|
257
|
+
...relayExecutionInfo,
|
|
258
|
+
updatedMessage,
|
|
259
|
+
},
|
|
260
|
+
};
|
|
240
261
|
|
|
241
262
|
return this.eventManager.generateEvent({
|
|
242
263
|
event,
|
|
@@ -248,12 +269,17 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
248
269
|
});
|
|
249
270
|
}
|
|
250
271
|
|
|
272
|
+
speedUpV3Deposit(speedUp: SpeedUp): Log {
|
|
273
|
+
return this._speedUpDeposit("RequestedSpeedUpV3Deposit", speedUp);
|
|
274
|
+
}
|
|
275
|
+
|
|
251
276
|
speedUpDeposit(speedUp: SpeedUp): Log {
|
|
252
277
|
return this._speedUpDeposit("RequestedSpeedUpDeposit", speedUp);
|
|
253
278
|
}
|
|
254
279
|
|
|
255
280
|
protected _speedUpDeposit(event: string, speedUp: SpeedUp): Log {
|
|
256
|
-
const
|
|
281
|
+
const addressModifier = event === "RequestedSpeedUpDeposit" ? toBytes32 : toAddress;
|
|
282
|
+
const depositor = addressModifier(speedUp.depositor);
|
|
257
283
|
const topics = [speedUp.depositId, depositor];
|
|
258
284
|
const args = { ...speedUp };
|
|
259
285
|
|
|
@@ -264,7 +290,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
264
290
|
args: {
|
|
265
291
|
...args,
|
|
266
292
|
depositor,
|
|
267
|
-
updatedRecipient:
|
|
293
|
+
updatedRecipient: addressModifier(speedUp.updatedRecipient),
|
|
268
294
|
},
|
|
269
295
|
});
|
|
270
296
|
}
|
|
@@ -282,19 +308,24 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
282
308
|
});
|
|
283
309
|
}
|
|
284
310
|
|
|
285
|
-
|
|
311
|
+
requestV3SlowFill(request: Omit<SlowFillRequest, "messageHash"> & Partial<SortableEvent>): Log {
|
|
312
|
+
return this._requestSlowFill("RequestedV3SlowFill", request);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
requestSlowFill(request: Omit<SlowFillRequest, "messageHash"> & Partial<SortableEvent>): Log {
|
|
286
316
|
return this._requestSlowFill("RequestedSlowFill", request);
|
|
287
317
|
}
|
|
288
318
|
|
|
289
319
|
protected _requestSlowFill(
|
|
290
320
|
event: string,
|
|
291
|
-
request: Omit<SlowFillRequest, "
|
|
321
|
+
request: Omit<SlowFillRequest, "messageHash"> & Partial<SortableEvent>
|
|
292
322
|
): Log {
|
|
293
323
|
const { originChainId, depositId } = request;
|
|
294
324
|
const topics = [originChainId, depositId];
|
|
295
325
|
const args = { ...request };
|
|
296
326
|
|
|
297
|
-
const
|
|
327
|
+
const addressModifier = event === "RequestedSlowFill" ? toBytes32 : toAddress;
|
|
328
|
+
const depositor = addressModifier(args.depositor ?? randomAddress());
|
|
298
329
|
|
|
299
330
|
return this.eventManager.generateEvent({
|
|
300
331
|
event,
|
|
@@ -302,21 +333,20 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
302
333
|
topics: topics.map((topic) => topic.toString()),
|
|
303
334
|
args: {
|
|
304
335
|
...args,
|
|
305
|
-
destinationChainId: this.chainId,
|
|
306
336
|
depositor,
|
|
307
|
-
recipient:
|
|
308
|
-
inputToken:
|
|
309
|
-
outputToken:
|
|
310
|
-
exclusiveRelayer:
|
|
337
|
+
recipient: addressModifier(args.recipient ?? depositor),
|
|
338
|
+
inputToken: addressModifier(args.inputToken ?? randomAddress()),
|
|
339
|
+
outputToken: addressModifier(args.outputToken ?? ZERO_ADDRESS),
|
|
340
|
+
exclusiveRelayer: addressModifier(args.exclusiveRelayer ?? ZERO_ADDRESS),
|
|
311
341
|
},
|
|
312
342
|
blockNumber: request.blockNumber,
|
|
313
343
|
transactionIndex: request.txnIndex,
|
|
314
344
|
});
|
|
315
345
|
}
|
|
316
346
|
|
|
317
|
-
// This is a simple wrapper around
|
|
347
|
+
// This is a simple wrapper around fillV3Relay().
|
|
318
348
|
// rootBundleId and proof are discarded here - we have no interest in verifying that.
|
|
319
|
-
|
|
349
|
+
executeV3SlowRelayLeaf(leaf: Omit<SlowFillLeaf, "messageHash">): Log {
|
|
320
350
|
const fill = {
|
|
321
351
|
...leaf.relayData,
|
|
322
352
|
destinationChainId: this.chainId,
|
|
@@ -331,7 +361,7 @@ export class MockSpokePoolClient extends EVMSpokePoolClient {
|
|
|
331
361
|
},
|
|
332
362
|
};
|
|
333
363
|
|
|
334
|
-
return this.
|
|
364
|
+
return this.fillV3Relay(fill);
|
|
335
365
|
}
|
|
336
366
|
|
|
337
367
|
executeRelayerRefundLeaf(refund: RelayerRefundExecution & Partial<SortableEvent>): Log {
|
|
@@ -3,7 +3,7 @@ import { SvmSpokeClient } from "@across-protocol/contracts";
|
|
|
3
3
|
import { Address } from "@solana/kit";
|
|
4
4
|
import { DepositWithBlock, RelayerRefundExecution, SortableEvent, SlowFillLeaf, Log } from "../../interfaces";
|
|
5
5
|
import { getCurrentTime, bnZero, MakeOptional, EventSearchConfig } from "../../utils";
|
|
6
|
-
import { SpokePoolUpdate,
|
|
6
|
+
import { SpokePoolUpdate, SVMSpokePoolClient } from "../SpokePoolClient";
|
|
7
7
|
import { HubPoolClient } from "../HubPoolClient";
|
|
8
8
|
import { EventOverrides } from "./MockEvents";
|
|
9
9
|
import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
@@ -12,7 +12,7 @@ import { EventWithData, SvmCpiEventsClient, SVMEventNames, unwrapEventData } fro
|
|
|
12
12
|
|
|
13
13
|
// This class replaces internal SpokePoolClient functionality, enabling
|
|
14
14
|
// the user to bypass on-chain queries and inject events directly.
|
|
15
|
-
export class MockSvmSpokePoolClient extends
|
|
15
|
+
export class MockSvmSpokePoolClient extends SVMSpokePoolClient {
|
|
16
16
|
public mockEventsClient: MockSvmCpiEventsClient;
|
|
17
17
|
private destinationTokenForChainOverride: Record<number, string> = {};
|
|
18
18
|
|
package/src/constants.ts
CHANGED
|
@@ -2,10 +2,12 @@ import { constants as ethersConstants } from "ethers";
|
|
|
2
2
|
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
|
+
CCTP_NO_DOMAIN,
|
|
5
6
|
ChainFamily,
|
|
6
7
|
CHAIN_IDs,
|
|
7
8
|
MAINNET_CHAIN_IDs,
|
|
8
9
|
PUBLIC_NETWORKS,
|
|
10
|
+
PRODUCTION_NETWORKS,
|
|
9
11
|
TESTNET_CHAIN_IDs,
|
|
10
12
|
TOKEN_SYMBOLS_MAP,
|
|
11
13
|
TOKEN_EQUIVALENCE_REMAPPING,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SVMProvider } from "../../arch/svm";
|
|
2
2
|
import { toBN, dedupArray, parseUnits } from "../../utils";
|
|
3
|
-
import {
|
|
3
|
+
import { SvmGasPriceEstimate } from "../types";
|
|
4
4
|
import { GasPriceEstimateOptions } from "../oracle";
|
|
5
5
|
import { CompilableTransactionMessage, TransactionMessageBytesBase64, compileTransaction } from "@solana/kit";
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ import { CompilableTransactionMessage, TransactionMessageBytesBase64, compileTra
|
|
|
8
8
|
* @notice Returns result of getFeeForMessage and getRecentPrioritizationFees RPC calls.
|
|
9
9
|
* @returns GasPriceEstimate
|
|
10
10
|
*/
|
|
11
|
-
export async function messageFee(provider: SVMProvider, opts: GasPriceEstimateOptions): Promise<
|
|
11
|
+
export async function messageFee(provider: SVMProvider, opts: GasPriceEstimateOptions): Promise<SvmGasPriceEstimate> {
|
|
12
12
|
const { unsignedTx: _unsignedTx } = opts;
|
|
13
13
|
|
|
14
14
|
// Cast the opaque unsignedTx type to a solana-kit CompilableTransactionMessage.
|
|
@@ -2,9 +2,9 @@ import assert from "assert";
|
|
|
2
2
|
import { Transport } from "viem";
|
|
3
3
|
import { providers } from "ethers";
|
|
4
4
|
import { CHAIN_IDs } from "../constants";
|
|
5
|
-
import { BigNumber, chainIsOPStack, fixedPointAdjustment, toBNWei } from "../utils";
|
|
5
|
+
import { BigNumber, chainIsOPStack, fixedPointAdjustment, isEvmProvider, toBNWei } from "../utils";
|
|
6
6
|
import { SVMProvider as SolanaProvider } from "../arch/svm";
|
|
7
|
-
import { GasPriceEstimate } from "./types";
|
|
7
|
+
import { EvmGasPriceEstimate, GasPriceEstimate, SvmGasPriceEstimate } from "./types";
|
|
8
8
|
import { getPublicClient } from "./util";
|
|
9
9
|
import * as arbitrum from "./adapters/arbitrum";
|
|
10
10
|
import * as ethereum from "./adapters/ethereum";
|
|
@@ -34,10 +34,22 @@ const GAS_PRICE_ESTIMATE_DEFAULTS = {
|
|
|
34
34
|
// Chains that use the Viem gas price oracle.
|
|
35
35
|
const VIEM_CHAINS = [CHAIN_IDs.LINEA];
|
|
36
36
|
|
|
37
|
+
// Overload For EVM providers
|
|
38
|
+
export async function getGasPriceEstimate(
|
|
39
|
+
provider: providers.Provider,
|
|
40
|
+
opts?: Partial<GasPriceEstimateOptions>
|
|
41
|
+
): Promise<EvmGasPriceEstimate>;
|
|
42
|
+
|
|
43
|
+
// Overload For SVM providers
|
|
44
|
+
export async function getGasPriceEstimate(
|
|
45
|
+
provider: SolanaProvider,
|
|
46
|
+
opts?: Partial<GasPriceEstimateOptions>
|
|
47
|
+
): Promise<SvmGasPriceEstimate>;
|
|
48
|
+
|
|
37
49
|
/**
|
|
38
50
|
* Provide an estimate for the current gas price for a particular chain.
|
|
39
51
|
* @param provider A valid ethers provider.
|
|
40
|
-
* @param {
|
|
52
|
+
* @param {GasPriceEstimateOptions} opts optional parameters.
|
|
41
53
|
* @returns An object of type GasPriceEstimate.
|
|
42
54
|
*/
|
|
43
55
|
export async function getGasPriceEstimate(
|
|
@@ -56,7 +68,7 @@ export async function getGasPriceEstimate(
|
|
|
56
68
|
);
|
|
57
69
|
|
|
58
70
|
// Exit here if we need to estimate on Solana.
|
|
59
|
-
if (!(provider
|
|
71
|
+
if (!isEvmProvider(provider)) {
|
|
60
72
|
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
61
73
|
...GAS_PRICE_ESTIMATE_DEFAULTS,
|
|
62
74
|
baseFeeMultiplier,
|
|
@@ -68,7 +80,6 @@ export async function getGasPriceEstimate(
|
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
// Cast the provider to an ethers provider, which should be given to the oracle when querying an EVM network.
|
|
71
|
-
provider = provider as providers.Provider;
|
|
72
83
|
const chainId = opts.chainId ?? (await provider.getNetwork()).chainId;
|
|
73
84
|
const optsWithDefaults: GasPriceEstimateOptions = {
|
|
74
85
|
...GAS_PRICE_ESTIMATE_DEFAULTS,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Chain, type Transport, PublicClient, FeeValuesEIP1559 } from "viem";
|
|
2
|
-
import { BigNumber } from "../utils";
|
|
2
|
+
import { BigNumber, isDefined } from "../utils";
|
|
3
3
|
|
|
4
4
|
export type InternalGasPriceEstimate = FeeValuesEIP1559;
|
|
5
5
|
export type GasPriceEstimate = EvmGasPriceEstimate | SvmGasPriceEstimate;
|
|
@@ -17,3 +17,13 @@ export type SvmGasPriceEstimate = {
|
|
|
17
17
|
export interface GasPriceFeed {
|
|
18
18
|
(provider: PublicClient<Transport, Chain>, chainId: number): Promise<InternalGasPriceEstimate>;
|
|
19
19
|
}
|
|
20
|
+
|
|
21
|
+
export function isEVMGasPrice(gasPrice: GasPriceEstimate): gasPrice is EvmGasPriceEstimate {
|
|
22
|
+
const { maxFeePerGas, maxPriorityFeePerGas } = gasPrice as EvmGasPriceEstimate;
|
|
23
|
+
return isDefined(maxFeePerGas) && isDefined(maxPriorityFeePerGas);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function isSVMGasPrice(gasPrice: GasPriceEstimate): gasPrice is SvmGasPriceEstimate {
|
|
27
|
+
const { baseFee, microLamportsPerComputeUnit } = gasPrice as SvmGasPriceEstimate;
|
|
28
|
+
return isDefined(baseFee) && isDefined(microLamportsPerComputeUnit);
|
|
29
|
+
}
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { SortableEvent } from "./Common";
|
|
2
|
+
import { FilledV3RelayEvent, V3FundsDepositedEvent } from "../typechain";
|
|
2
3
|
import { SpokePoolClient } from "../clients";
|
|
3
4
|
import { BigNumber } from "../utils";
|
|
4
5
|
import { RelayerRefundLeaf } from "./HubPool";
|
|
5
6
|
|
|
7
|
+
export type { FilledV3RelayEvent, V3FundsDepositedEvent };
|
|
8
|
+
|
|
6
9
|
export interface RelayData {
|
|
7
10
|
originChainId: number;
|
|
8
11
|
depositor: string;
|
|
@@ -90,7 +93,7 @@ export interface SpeedUp {
|
|
|
90
93
|
|
|
91
94
|
export interface SpeedUpWithBlock extends SpeedUp, SortableEvent {}
|
|
92
95
|
|
|
93
|
-
export interface SlowFillRequest extends
|
|
96
|
+
export interface SlowFillRequest extends RelayData {
|
|
94
97
|
messageHash: string;
|
|
95
98
|
destinationChainId: number;
|
|
96
99
|
}
|
package/src/providers/infura.ts
CHANGED
|
@@ -6,6 +6,7 @@ const MAINNET_CHAIN_IDs = Object.values(_MAINNET_CHAIN_IDs);
|
|
|
6
6
|
// Chain-specific overrides for when the endpoint name does not match the canonical chain name.
|
|
7
7
|
const endpoints: { [chainId: string]: string } = {
|
|
8
8
|
[CHAIN_IDs.ARBITRUM]: "arbitrum",
|
|
9
|
+
[CHAIN_IDs.BSC]: "bsc",
|
|
9
10
|
};
|
|
10
11
|
|
|
11
12
|
export function getURL(chainId: number, apiKey: string, transport: RPCTransport): string {
|
package/src/utils/BlockFinder.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
CCTP_NO_DOMAIN,
|
|
3
|
+
ChainFamily,
|
|
4
|
+
CHAIN_IDs,
|
|
5
|
+
MAINNET_CHAIN_IDs,
|
|
6
|
+
PRODUCTION_NETWORKS,
|
|
7
|
+
PUBLIC_NETWORKS,
|
|
8
|
+
TESTNET_CHAIN_IDs,
|
|
9
|
+
} from "../constants";
|
|
3
10
|
|
|
4
11
|
export const hreNetworks: Record<number, string> = {
|
|
5
12
|
666: "Hardhat1",
|
|
@@ -89,24 +96,6 @@ export function chainIsArbitrum(chainId: number): boolean {
|
|
|
89
96
|
return [CHAIN_IDs.ARBITRUM, CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
|
|
90
97
|
}
|
|
91
98
|
|
|
92
|
-
/**
|
|
93
|
-
* Determines whether a chain ID is an Aleph0 implementation
|
|
94
|
-
* @param chainId Chain ID to evaluate
|
|
95
|
-
* @returns True if chainId is an Aleph0 chain, otherwise false.
|
|
96
|
-
*/
|
|
97
|
-
export function chainIsAlephZero(chainId: number): boolean {
|
|
98
|
-
return [CHAIN_IDs.ALEPH_ZERO].includes(chainId);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Determines whether a chain ID is a Lens implementation
|
|
103
|
-
* @param chainId Chain ID to evaluate
|
|
104
|
-
* @returns True if chainId is a Lens chain, otherwise false.
|
|
105
|
-
*/
|
|
106
|
-
export function chainIsLens(chainId: number): boolean {
|
|
107
|
-
return [CHAIN_IDs.LENS_SEPOLIA].includes(chainId);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
99
|
/**
|
|
111
100
|
* Determines whether a chain ID is a Linea implementation.
|
|
112
101
|
* @param chainId Chain ID to evaluate.
|
|
@@ -159,7 +148,10 @@ export function chainIsSvm(chainId: number): boolean {
|
|
|
159
148
|
* @returns True if chainId is a CCTP-bridging enabled chain, otherwise false.
|
|
160
149
|
*/
|
|
161
150
|
export function chainIsCCTPEnabled(chainId: number): boolean {
|
|
162
|
-
|
|
151
|
+
// Add chainIds to cctpExceptions to administratively disable CCTP on a chain.
|
|
152
|
+
// This is useful if constants has been updated to specify a CCTP domain in advance of it being activated.
|
|
153
|
+
const cctpExceptions: number[] = [];
|
|
154
|
+
return PRODUCTION_NETWORKS[chainId]?.cctpDomain !== CCTP_NO_DOMAIN && !cctpExceptions.includes(chainId);
|
|
163
155
|
}
|
|
164
156
|
|
|
165
157
|
/**
|
package/src/utils/TypeGuards.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { providers } from "ethers";
|
|
2
|
+
import { SVMProvider } from "../arch/svm/types";
|
|
3
|
+
|
|
1
4
|
export function isPromiseFulfilled<T>(
|
|
2
5
|
promiseSettledResult: PromiseSettledResult<T>
|
|
3
6
|
): promiseSettledResult is PromiseFulfilledResult<T> {
|
|
@@ -13,3 +16,7 @@ export function isPromiseRejected<T>(
|
|
|
13
16
|
export function isDefined<T>(input: T | null | undefined): input is T {
|
|
14
17
|
return input !== null && input !== undefined;
|
|
15
18
|
}
|
|
19
|
+
|
|
20
|
+
export function isEvmProvider(provider: providers.Provider | SVMProvider): provider is providers.Provider {
|
|
21
|
+
return provider instanceof providers.Provider;
|
|
22
|
+
}
|