@across-protocol/sdk 4.2.2 → 4.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/arch/svm/BlockUtils.d.ts +2 -2
- package/dist/cjs/arch/svm/BlockUtils.js +3 -4
- package/dist/cjs/arch/svm/BlockUtils.js.map +1 -1
- package/dist/cjs/arch/svm/eventsClient.js +2 -2
- package/dist/cjs/arch/svm/eventsClient.js.map +1 -1
- package/dist/cjs/arch/svm/utils.js +4 -0
- package/dist/cjs/arch/svm/utils.js.map +1 -1
- package/dist/cjs/clients/BundleDataClient/utils/SuperstructUtils.d.ts +22 -22
- package/dist/cjs/clients/index.d.ts +1 -1
- package/dist/cjs/clients/index.js +3 -1
- package/dist/cjs/clients/index.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/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 +2 -2
- package/dist/esm/arch/svm/BlockUtils.js +4 -5
- package/dist/esm/arch/svm/BlockUtils.js.map +1 -1
- package/dist/esm/arch/svm/eventsClient.js +2 -2
- package/dist/esm/arch/svm/eventsClient.js.map +1 -1
- package/dist/esm/arch/svm/utils.js +4 -0
- package/dist/esm/arch/svm/utils.js.map +1 -1
- package/dist/esm/clients/BundleDataClient/utils/SuperstructUtils.d.ts +22 -22
- 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/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/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 +2 -2
- package/dist/types/arch/svm/BlockUtils.d.ts.map +1 -1
- package/dist/types/arch/svm/eventsClient.d.ts.map +1 -1
- package/dist/types/arch/svm/utils.d.ts.map +1 -1
- package/dist/types/clients/BundleDataClient/utils/SuperstructUtils.d.ts +22 -22
- package/dist/types/clients/index.d.ts +1 -1
- package/dist/types/clients/index.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/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 +8 -13
- package/src/arch/svm/eventsClient.ts +3 -13
- package/src/arch/svm/utils.ts +4 -0
- package/src/clients/index.ts +8 -1
- package/src/gasPriceOracle/adapters/solana.ts +2 -2
- package/src/gasPriceOracle/oracle.ts +16 -5
- package/src/gasPriceOracle/types.ts +11 -1
- package/src/utils/TypeGuards.ts +7 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/clients/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,wBAAwB,EACxB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EACL,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,gBAAgB,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { SVMProvider } from "../../arch/svm";
|
|
2
|
-
import {
|
|
2
|
+
import { SvmGasPriceEstimate } from "../types";
|
|
3
3
|
import { GasPriceEstimateOptions } from "../oracle";
|
|
4
4
|
/**
|
|
5
5
|
* @notice Returns result of getFeeForMessage and getRecentPrioritizationFees RPC calls.
|
|
6
6
|
* @returns GasPriceEstimate
|
|
7
7
|
*/
|
|
8
|
-
export declare function messageFee(provider: SVMProvider, opts: GasPriceEstimateOptions): Promise<
|
|
8
|
+
export declare function messageFee(provider: SVMProvider, opts: GasPriceEstimateOptions): Promise<SvmGasPriceEstimate>;
|
|
9
9
|
//# sourceMappingURL=solana.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"solana.d.ts","sourceRoot":"","sources":["../../../../src/gasPriceOracle/adapters/solana.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAC;AAGpD;;;GAGG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAoCnH"}
|
|
@@ -2,7 +2,7 @@ import { Transport } from "viem";
|
|
|
2
2
|
import { providers } from "ethers";
|
|
3
3
|
import { BigNumber } from "../utils";
|
|
4
4
|
import { SVMProvider as SolanaProvider } from "../arch/svm";
|
|
5
|
-
import { GasPriceEstimate } from "./types";
|
|
5
|
+
import { EvmGasPriceEstimate, GasPriceEstimate, SvmGasPriceEstimate } from "./types";
|
|
6
6
|
export interface GasPriceEstimateOptions {
|
|
7
7
|
baseFeeMultiplier: BigNumber;
|
|
8
8
|
priorityFeeMultiplier: BigNumber;
|
|
@@ -11,13 +11,8 @@ export interface GasPriceEstimateOptions {
|
|
|
11
11
|
unsignedTx?: unknown;
|
|
12
12
|
transport?: Transport;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* @param provider A valid ethers provider.
|
|
17
|
-
* @param {opts} GasPriceEstimateOptions optional parameters.
|
|
18
|
-
* @returns An object of type GasPriceEstimate.
|
|
19
|
-
*/
|
|
20
|
-
export declare function getGasPriceEstimate(provider: providers.Provider | SolanaProvider, opts?: Partial<GasPriceEstimateOptions>): Promise<GasPriceEstimate>;
|
|
14
|
+
export declare function getGasPriceEstimate(provider: providers.Provider, opts?: Partial<GasPriceEstimateOptions>): Promise<EvmGasPriceEstimate>;
|
|
15
|
+
export declare function getGasPriceEstimate(provider: SolanaProvider, opts?: Partial<GasPriceEstimateOptions>): Promise<SvmGasPriceEstimate>;
|
|
21
16
|
/**
|
|
22
17
|
* Provide an estimate for the current gas price for a particular chain.
|
|
23
18
|
* @param providerOrChainId A valid ethers provider or a chain ID.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"oracle.d.ts","sourceRoot":"","sources":["../../../src/gasPriceOracle/oracle.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEnC,OAAO,EAAE,SAAS,EAAgE,MAAM,UAAU,CAAC;AACnG,OAAO,EAAE,WAAW,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAQrF,MAAM,WAAW,uBAAuB;IAEtC,iBAAiB,EAAE,SAAS,CAAC;IAE7B,qBAAqB,EAAE,SAAS,CAAC;IAEjC,cAAc,EAAE,OAAO,CAAC;IAExB,OAAO,EAAE,MAAM,CAAC;IAEhB,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,SAAS,CAAC,EAAE,SAAS,CAAC;CACvB;AAUD,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAC5B,IAAI,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAAC;AAGhC,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,cAAc,EACxB,IAAI,CAAC,EAAE,OAAO,CAAC,uBAAuB,CAAC,GACtC,OAAO,CAAC,mBAAmB,CAAC,CAAC;AA0FhC;;;;;;GAMG;AACH,wBAAsB,wBAAwB,CAC5C,iBAAiB,EAAE,SAAS,CAAC,QAAQ,GAAG,MAAM,EAC9C,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,gBAAgB,CAAC,CA2B3B"}
|
|
@@ -13,4 +13,6 @@ export type SvmGasPriceEstimate = {
|
|
|
13
13
|
export interface GasPriceFeed {
|
|
14
14
|
(provider: PublicClient<Transport, Chain>, chainId: number): Promise<InternalGasPriceEstimate>;
|
|
15
15
|
}
|
|
16
|
+
export declare function isEVMGasPrice(gasPrice: GasPriceEstimate): gasPrice is EvmGasPriceEstimate;
|
|
17
|
+
export declare function isSVMGasPrice(gasPrice: GasPriceEstimate): gasPrice is SvmGasPriceEstimate;
|
|
16
18
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/gasPriceOracle/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAClF,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/gasPriceOracle/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC;AAClF,OAAO,EAAE,SAAS,EAAa,MAAM,UAAU,CAAC;AAEhD,MAAM,MAAM,wBAAwB,GAAG,gBAAgB,CAAC;AACxD,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAEzE,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,EAAE,SAAS,CAAC;IACxB,oBAAoB,EAAE,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,SAAS,CAAC;IACnB,2BAA2B,EAAE,SAAS,CAAC;CACxC,CAAC;AAEF,MAAM,WAAW,YAAY;IAC3B,CAAC,QAAQ,EAAE,YAAY,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CAChG;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,gBAAgB,GAAG,QAAQ,IAAI,mBAAmB,CAGzF;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,gBAAgB,GAAG,QAAQ,IAAI,mBAAmB,CAGzF"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { providers } from "ethers";
|
|
2
|
+
import { SVMProvider } from "../arch/svm/types";
|
|
1
3
|
export declare function isPromiseFulfilled<T>(promiseSettledResult: PromiseSettledResult<T>): promiseSettledResult is PromiseFulfilledResult<T>;
|
|
2
4
|
export declare function isPromiseRejected<T>(promiseSettledResult: PromiseSettledResult<T>): promiseSettledResult is PromiseRejectedResult;
|
|
3
5
|
export declare function isDefined<T>(input: T | null | undefined): input is T;
|
|
6
|
+
export declare function isEvmProvider(provider: providers.Provider | SVMProvider): provider is providers.Provider;
|
|
4
7
|
//# sourceMappingURL=TypeGuards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeGuards.d.ts","sourceRoot":"","sources":["../../../src/utils/TypeGuards.ts"],"names":[],"mappings":"AAAA,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC5C,oBAAoB,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC5C,oBAAoB,IAAI,qBAAqB,CAE/C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAEpE"}
|
|
1
|
+
{"version":3,"file":"TypeGuards.d.ts","sourceRoot":"","sources":["../../../src/utils/TypeGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC5C,oBAAoB,IAAI,sBAAsB,CAAC,CAAC,CAAC,CAEnD;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,oBAAoB,EAAE,oBAAoB,CAAC,CAAC,CAAC,GAC5C,oBAAoB,IAAI,qBAAqB,CAE/C;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,IAAI,CAAC,CAEpE;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,GAAG,WAAW,GAAG,QAAQ,IAAI,SAAS,CAAC,QAAQ,CAExG"}
|
package/package.json
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import assert from "assert";
|
|
2
2
|
import { clamp, sortedIndexBy } from "lodash";
|
|
3
|
-
import {
|
|
4
|
-
BlockFinder,
|
|
5
|
-
type Block,
|
|
6
|
-
type BlockFinderOpts as Opts,
|
|
7
|
-
type BlockTimeAverage,
|
|
8
|
-
type BlockFinderHints,
|
|
9
|
-
} from "../../utils/BlockFinder";
|
|
3
|
+
import { BlockFinder, type Block, type BlockTimeAverage, type BlockFinderHints } from "../../utils/BlockFinder";
|
|
10
4
|
import { isDefined } from "../../utils/TypeGuards";
|
|
11
5
|
import { getCurrentTime } from "../../utils/TimeUtils";
|
|
12
6
|
import { CHAIN_IDs } from "../../constants";
|
|
@@ -24,17 +18,18 @@ const averageBlockTimes: { [chainId: number]: BlockTimeAverage } = {
|
|
|
24
18
|
* @dev Solana slots are all defined to be ~400ms away from each other += a small deviation, so we can hardcode this.
|
|
25
19
|
* @returns Average number of seconds per slot
|
|
26
20
|
*/
|
|
27
|
-
export function averageBlockTime(
|
|
28
|
-
_provider: SVMProvider,
|
|
29
|
-
_opts: Opts = {}
|
|
30
|
-
): Pick<BlockTimeAverage, "average" | "blockRange"> {
|
|
21
|
+
export function averageBlockTime(): Pick<BlockTimeAverage, "average" | "blockRange"> {
|
|
31
22
|
// @todo This may need to be expanded to work without assuming that chainId = CHAIN_IDs.SOLANA.
|
|
32
23
|
return averageBlockTimes[CHAIN_IDs.SOLANA];
|
|
33
24
|
}
|
|
34
25
|
|
|
35
|
-
async function estimateBlocksElapsed(
|
|
26
|
+
async function estimateBlocksElapsed(
|
|
27
|
+
seconds: number,
|
|
28
|
+
cushionPercentage = 0.0,
|
|
29
|
+
_provider: SVMProvider
|
|
30
|
+
): Promise<number> {
|
|
36
31
|
const cushionMultiplier = cushionPercentage + 1.0;
|
|
37
|
-
const { average } = await averageBlockTime(
|
|
32
|
+
const { average } = await averageBlockTime();
|
|
38
33
|
return Math.floor((seconds * cushionMultiplier) / average);
|
|
39
34
|
}
|
|
40
35
|
|
|
@@ -13,13 +13,9 @@ import {
|
|
|
13
13
|
import { bs58, chainIsSvm, getMessageHash } from "../../utils";
|
|
14
14
|
import { EventName, EventWithData, SVMProvider } from "./types";
|
|
15
15
|
import { decodeEvent, isDevnet } from "./utils";
|
|
16
|
-
import { DepositWithTime, FillWithTime } from "../../interfaces";
|
|
16
|
+
import { Deposit, DepositWithTime, Fill, FillWithTime } from "../../interfaces";
|
|
17
17
|
import { unwrapEventData } from "./";
|
|
18
18
|
import assert from "assert";
|
|
19
|
-
import {
|
|
20
|
-
FundsDepositedEventObject,
|
|
21
|
-
FilledRelayEventObject,
|
|
22
|
-
} from "@across-protocol/contracts/dist/typechain/contracts/SpokePool";
|
|
23
19
|
|
|
24
20
|
// Utility type to extract the return type for the JSON encoding overload. We only care about the overload where the
|
|
25
21
|
// configuration parameter (C) has the optional property 'encoding' set to 'json'.
|
|
@@ -264,7 +260,7 @@ export class SvmCpiEventsClient {
|
|
|
264
260
|
return events.map((event) => {
|
|
265
261
|
const unwrappedEventArgs = unwrapEventData(event as Record<string, unknown>, ["depositId"]) as Record<
|
|
266
262
|
"data",
|
|
267
|
-
|
|
263
|
+
Deposit
|
|
268
264
|
>;
|
|
269
265
|
|
|
270
266
|
return {
|
|
@@ -276,7 +272,6 @@ export class SvmCpiEventsClient {
|
|
|
276
272
|
txnIndex: 0,
|
|
277
273
|
txnRef: txSignature,
|
|
278
274
|
logIndex: 0,
|
|
279
|
-
destinationChainId: unwrappedEventArgs.data.destinationChainId.toNumber(),
|
|
280
275
|
} satisfies DepositEventFromSignature;
|
|
281
276
|
});
|
|
282
277
|
}
|
|
@@ -314,10 +309,7 @@ export class SvmCpiEventsClient {
|
|
|
314
309
|
}
|
|
315
310
|
|
|
316
311
|
return fillEvents.map((event) => {
|
|
317
|
-
const unwrappedEventData = unwrapEventData(event as Record<string, unknown>) as Record<
|
|
318
|
-
"data",
|
|
319
|
-
FilledRelayEventObject
|
|
320
|
-
>;
|
|
312
|
+
const unwrappedEventData = unwrapEventData(event as Record<string, unknown>) as Record<"data", Fill>;
|
|
321
313
|
return {
|
|
322
314
|
...unwrappedEventData.data,
|
|
323
315
|
fillTimestamp: Number(txDetails.blockTime),
|
|
@@ -326,8 +318,6 @@ export class SvmCpiEventsClient {
|
|
|
326
318
|
txnIndex: 0,
|
|
327
319
|
logIndex: 0,
|
|
328
320
|
destinationChainId,
|
|
329
|
-
repaymentChainId: unwrappedEventData.data.repaymentChainId.toNumber(),
|
|
330
|
-
originChainId: unwrappedEventData.data.originChainId.toNumber(),
|
|
331
321
|
} satisfies FillEventFromSignature;
|
|
332
322
|
});
|
|
333
323
|
}
|
package/src/arch/svm/utils.ts
CHANGED
|
@@ -107,6 +107,10 @@ export function unwrapEventData(
|
|
|
107
107
|
}
|
|
108
108
|
// Handle BigInt
|
|
109
109
|
if (typeof data === "bigint") {
|
|
110
|
+
const bigIntKeysAsNumber = ["originChainId", "destinationChainId", "repaymentChainId", "chainId"];
|
|
111
|
+
if (currentKey && bigIntKeysAsNumber.includes(currentKey)) {
|
|
112
|
+
return Number(data);
|
|
113
|
+
}
|
|
110
114
|
return BigNumber.from(data);
|
|
111
115
|
}
|
|
112
116
|
// Handle Uint8Array and byte arrays
|
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";
|
|
@@ -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
|
+
}
|
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
|
+
}
|