@across-protocol/sdk 4.2.1 → 4.2.2
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 +181 -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 +1 -0
- 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 +2 -1
- 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 +2 -2
- 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/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/esm/arch/svm/BlockUtils.d.ts +25 -0
- package/dist/esm/arch/svm/BlockUtils.js +208 -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 +2 -1
- 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 +2 -1
- 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/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/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/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 +2 -1
- 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/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/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/package.json +1 -1
- package/src/arch/svm/BlockUtils.ts +171 -0
- package/src/arch/svm/index.ts +1 -0
- package/src/clients/BundleDataClient/BundleDataClient.ts +2 -2
- package/src/clients/SpokePoolClient/EVMSpokePoolClient.ts +2 -0
- package/src/clients/SpokePoolClient/SVMSpokePoolClient.ts +6 -4
- package/src/clients/SpokePoolClient/SpokePoolClient.ts +2 -0
- package/src/clients/SpokePoolClient/index.ts +4 -4
- package/src/clients/index.ts +1 -1
- package/src/clients/mocks/MockSvmSpokePoolClient.ts +2 -2
- package/src/constants.ts +2 -0
- package/src/providers/infura.ts +1 -0
- package/src/utils/BlockFinder.ts +0 -1
- package/src/utils/NetworkUtils.ts +13 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import winston from "winston";
|
|
2
|
-
import { AnyObject, BigNumber, DefaultLogLevels, DepositSearchResult, EventSearchConfig, MakeOptional } from "../../utils";
|
|
2
|
+
import { AnyObject, BigNumber, DefaultLogLevels, DepositSearchResult, EventSearchConfig, MakeOptional, Address } from "../../utils";
|
|
3
3
|
import { Deposit, DepositWithBlock, Fill, FillStatus, FillWithBlock, RelayData, RelayerRefundExecutionWithBlock, RootBundleRelayWithBlock, SlowFillRequestWithBlock, SortableEvent, SpeedUpWithBlock, TokensBridged } from "../../interfaces";
|
|
4
4
|
import { BaseAbstractClient, UpdateFailureReason } from "../BaseAbstractClient";
|
|
5
5
|
import { AcrossConfigStoreClient } from "../AcrossConfigStoreClient";
|
|
@@ -53,6 +53,7 @@ export declare abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
53
53
|
protected relayerRefundExecutions: RelayerRefundExecutionWithBlock[];
|
|
54
54
|
protected configStoreClient: AcrossConfigStoreClient | undefined;
|
|
55
55
|
protected invalidFills: Set<string>;
|
|
56
|
+
spokePoolAddress: Address | undefined;
|
|
56
57
|
fills: {
|
|
57
58
|
[OriginChainId: number]: FillWithBlock[];
|
|
58
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpokePoolClient.d.ts","sourceRoot":"","sources":["../../../../src/clients/SpokePoolClient/SpokePoolClient.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EACL,SAAS,EACT,SAAS,EAET,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EAEjB,YAAY,
|
|
1
|
+
{"version":3,"file":"SpokePoolClient.d.ts","sourceRoot":"","sources":["../../../../src/clients/SpokePoolClient/SpokePoolClient.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EACL,SAAS,EACT,SAAS,EAET,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EAEjB,YAAY,EAYZ,OAAO,EACR,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,OAAO,EACP,gBAAgB,EAEhB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,SAAS,EACT,+BAA+B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;;;;OAKG;IACH,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IAE7E;;;;;;;;;;;;OAYG;aACa,yBAAyB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEhG;;;;OAIG;aACa,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAEvE;;;OAGG;aACa,SAAS,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAE/D;;;;;OAKG;aACa,WAAW,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAE/E;;;;;OAKG;aACa,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAE7F;;;;;OAKG;aACa,eAAe,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,UAAU,GAAG,SAAS,CAAC,EAAE,CAAC;CAChH"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EVMSpokePoolClient } from "./EVMSpokePoolClient";
|
|
2
|
-
import {
|
|
2
|
+
import { SVMSpokePoolClient } from "./SVMSpokePoolClient";
|
|
3
3
|
import { SpokePoolClient } from "./SpokePoolClient";
|
|
4
4
|
export { EVMSpokePoolClient } from "./EVMSpokePoolClient";
|
|
5
5
|
export { SpokePoolClient, SpokePoolUpdate } from "./SpokePoolClient";
|
|
6
|
-
export {
|
|
6
|
+
export { SVMSpokePoolClient } from "./SVMSpokePoolClient";
|
|
7
7
|
/**
|
|
8
8
|
* Checks if a SpokePoolClient is an EVMSpokePoolClient.
|
|
9
9
|
* @param spokePoolClient The SpokePoolClient to check.
|
|
@@ -15,5 +15,5 @@ export declare function isEVMSpokePoolClient(spokePoolClient: SpokePoolClient):
|
|
|
15
15
|
* @param spokePoolClient The SpokePoolClient to check.
|
|
16
16
|
* @returns True if the SpokePoolClient is an SVMSpokePoolClient, false otherwise.
|
|
17
17
|
*/
|
|
18
|
-
export declare function
|
|
18
|
+
export declare function isSVMSpokePoolClient(spokePoolClient: SpokePoolClient): spokePoolClient is SVMSpokePoolClient;
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { DEFAULT_CONFIG_STORE_VERSION, GLOBAL_CONFIG_STORE_KEYS, AcrossConfigStoreClient, ConfigStoreUpdate, } from "./AcrossConfigStoreClient";
|
|
2
2
|
export { UpdateFailureReason } from "./BaseAbstractClient";
|
|
3
3
|
export { HubPoolClient, LpFeeRequest } from "./HubPoolClient";
|
|
4
|
-
export { SpokePoolClient, SpokePoolUpdate, EVMSpokePoolClient,
|
|
4
|
+
export { SpokePoolClient, SpokePoolUpdate, EVMSpokePoolClient, SVMSpokePoolClient } from "./SpokePoolClient";
|
|
5
5
|
export * as BundleDataClient from "./BundleDataClient";
|
|
6
6
|
export * as mocks from "./mocks";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -3,13 +3,13 @@ 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 { 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";
|
|
10
10
|
import { MockSvmCpiEventsClient } from "./MockSvmCpiEventsClient";
|
|
11
11
|
import { EventWithData } from "../../arch/svm";
|
|
12
|
-
export declare class MockSvmSpokePoolClient extends
|
|
12
|
+
export declare class MockSvmSpokePoolClient extends SVMSpokePoolClient {
|
|
13
13
|
mockEventsClient: MockSvmCpiEventsClient;
|
|
14
14
|
private destinationTokenForChainOverride;
|
|
15
15
|
constructor(logger: winston.Logger, chainId: number, programId?: Address<"JAZWcGrpSWNPTBj8QtJ9UyQqhJCDhG9GJkDeMf5NQBiq">, deploymentBlock?: number, eventSearchConfig?: MakeOptional<EventSearchConfig, "to">, opts?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ChainFamily, CHAIN_IDs, MAINNET_CHAIN_IDs, PUBLIC_NETWORKS, TESTNET_CHAIN_IDs, TOKEN_SYMBOLS_MAP, TOKEN_EQUIVALENCE_REMAPPING, } from "@across-protocol/constants";
|
|
1
|
+
export { CCTP_NO_DOMAIN, ChainFamily, CHAIN_IDs, MAINNET_CHAIN_IDs, PUBLIC_NETWORKS, PRODUCTION_NETWORKS, TESTNET_CHAIN_IDs, TOKEN_SYMBOLS_MAP, TOKEN_EQUIVALENCE_REMAPPING, } from "@across-protocol/constants";
|
|
2
2
|
export declare const ZERO_ADDRESS: string, ZERO_BYTES: string;
|
|
3
3
|
export declare const MAX_SAFE_ALLOWANCE = "79228162514264337593543950335";
|
|
4
4
|
export declare const MAX_SAFE_DEPOSIT_ID = "4294967295";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AAEpC,eAAO,MAAqB,YAAY,UAAY,UAAU,QAAoB,CAAC;AAGnF,eAAO,MAAM,kBAAkB,kCAAkC,CAAC;AAIlE,eAAO,MAAM,mBAAmB,eAAe,CAAC;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oBAAoB,oBAAoB,CAAC;AAOtD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,UAA2B,CAAC;AAE1E,eAAO,MAAM,mBAAmB,QAAuB,CAAC;AACxD,eAAO,MAAM,wBAAwB,QAAU,CAAC;AAEhD,eAAO,MAAM,iCAAiC,+CAA+C,CAAC;AAC9F,eAAO,MAAM,qCAAqC,iDAAiD,CAAC;AACpG,eAAO,MAAM,sCAAsC,+CAA+C,CAAC;AAEnG,eAAO,MAAM,+BAA+B,gDAAgD,CAAC;AAE7F,eAAO,MAAM,aAAa,OAAO,CAAC;AAClC,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,eAAO,MAAM,oBAAoB,UAKhC,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAY/B,CAAC;AAEF,eAAO,MAAM,iBAAiB;;CAO7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"infura.d.ts","sourceRoot":"","sources":["../../../src/providers/infura.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"infura.d.ts","sourceRoot":"","sources":["../../../src/providers/infura.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAUvC,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,YAAY,GAAG,MAAM,CAYvF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockFinder.d.ts","sourceRoot":"","sources":["../../../src/utils/BlockFinder.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,
|
|
1
|
+
{"version":3,"file":"BlockFinder.d.ts","sourceRoot":"","sources":["../../../src/utils/BlockFinder.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,8BAAsB,WAAW,CAAC,MAAM,SAAS,KAAK;IACpD,QAAQ,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,CAAC;CACpG"}
|
|
@@ -53,18 +53,6 @@ export declare function chainIsOrbit(chainId: number): boolean;
|
|
|
53
53
|
* @returns True if chainId is an Arbitrum chain, otherwise false.
|
|
54
54
|
*/
|
|
55
55
|
export declare function chainIsArbitrum(chainId: number): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Determines whether a chain ID is an Aleph0 implementation
|
|
58
|
-
* @param chainId Chain ID to evaluate
|
|
59
|
-
* @returns True if chainId is an Aleph0 chain, otherwise false.
|
|
60
|
-
*/
|
|
61
|
-
export declare function chainIsAlephZero(chainId: number): boolean;
|
|
62
|
-
/**
|
|
63
|
-
* Determines whether a chain ID is a Lens implementation
|
|
64
|
-
* @param chainId Chain ID to evaluate
|
|
65
|
-
* @returns True if chainId is a Lens chain, otherwise false.
|
|
66
|
-
*/
|
|
67
|
-
export declare function chainIsLens(chainId: number): boolean;
|
|
68
56
|
/**
|
|
69
57
|
* Determines whether a chain ID is a Linea implementation.
|
|
70
58
|
* @param chainId Chain ID to evaluate.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetworkUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/NetworkUtils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NetworkUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/NetworkUtils.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAI9C,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAGjE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAErE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEvD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAErD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAElD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGnD;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEnD;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAK3D;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAExE;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAMpD"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import assert from "assert";
|
|
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";
|
|
10
|
+
import { isDefined } from "../../utils/TypeGuards";
|
|
11
|
+
import { getCurrentTime } from "../../utils/TimeUtils";
|
|
12
|
+
import { CHAIN_IDs } from "../../constants";
|
|
13
|
+
import { SVMProvider } from "./";
|
|
14
|
+
|
|
15
|
+
interface SVMBlock extends Block {}
|
|
16
|
+
|
|
17
|
+
const now = getCurrentTime();
|
|
18
|
+
const averageBlockTimes: { [chainId: number]: BlockTimeAverage } = {
|
|
19
|
+
[CHAIN_IDs.SOLANA]: { average: 0.4, timestamp: now, blockRange: 1 },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* @description Compute the average slot time over a slot range.
|
|
24
|
+
* @dev Solana slots are all defined to be ~400ms away from each other += a small deviation, so we can hardcode this.
|
|
25
|
+
* @returns Average number of seconds per slot
|
|
26
|
+
*/
|
|
27
|
+
export function averageBlockTime(
|
|
28
|
+
_provider: SVMProvider,
|
|
29
|
+
_opts: Opts = {}
|
|
30
|
+
): Pick<BlockTimeAverage, "average" | "blockRange"> {
|
|
31
|
+
// @todo This may need to be expanded to work without assuming that chainId = CHAIN_IDs.SOLANA.
|
|
32
|
+
return averageBlockTimes[CHAIN_IDs.SOLANA];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async function estimateBlocksElapsed(seconds: number, cushionPercentage = 0.0, provider: SVMProvider): Promise<number> {
|
|
36
|
+
const cushionMultiplier = cushionPercentage + 1.0;
|
|
37
|
+
const { average } = await averageBlockTime(provider);
|
|
38
|
+
return Math.floor((seconds * cushionMultiplier) / average);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export class SVMBlockFinder extends BlockFinder<SVMBlock> {
|
|
42
|
+
constructor(
|
|
43
|
+
private readonly provider: SVMProvider,
|
|
44
|
+
private readonly blocks: SVMBlock[] = []
|
|
45
|
+
) {
|
|
46
|
+
super();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @notice Gets the latest slot whose timestamp is <= the provided timestamp.
|
|
51
|
+
* @param number Timestamp timestamp to search.
|
|
52
|
+
* @param hints Optional low and high slot to bound the search space.
|
|
53
|
+
*/
|
|
54
|
+
public async getBlockForTimestamp(timestamp: number | string, hints: BlockFinderHints = {}): Promise<SVMBlock> {
|
|
55
|
+
timestamp = Number(timestamp);
|
|
56
|
+
assert(timestamp !== undefined && timestamp !== null, "timestamp must be provided");
|
|
57
|
+
// If the last slot we have stored is too early, grab the latest slot.
|
|
58
|
+
if (this.blocks.length === 0 || this.blocks[this.blocks.length - 1].timestamp < timestamp) {
|
|
59
|
+
const block = await this.getLatestBlock();
|
|
60
|
+
if (timestamp >= block.timestamp) return block;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Prime the BlockFinder cache with any supplied hints.
|
|
64
|
+
// If the hint is accurate, then this will bypass the subsequent estimation.
|
|
65
|
+
await Promise.all(
|
|
66
|
+
Object.values(hints)
|
|
67
|
+
.filter(isDefined)
|
|
68
|
+
.map((blockNumber) => this.getBlock(blockNumber))
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
// Check the first slot. If it's greater than our timestamp, we need to find an earlier slot.
|
|
72
|
+
if (this.blocks[0].timestamp > timestamp) {
|
|
73
|
+
const initialBlock = this.blocks[0];
|
|
74
|
+
// We use a 2x cushion to reduce the number of iterations in the following loop and increase the chance
|
|
75
|
+
// that the first slot we find sets a floor for the target timestamp. The loop converges on the correct slot
|
|
76
|
+
// slower than the following incremental search performed by `findBlock`, so we want to minimize the number of
|
|
77
|
+
// loop iterations in favor of searching more slots over the `findBlock` search.
|
|
78
|
+
const cushion = 1;
|
|
79
|
+
const incrementDistance = Math.max(
|
|
80
|
+
// Ensure the increment slot distance is _at least_ a single slot to prevent an infinite loop.
|
|
81
|
+
await estimateBlocksElapsed(initialBlock.timestamp - timestamp, cushion, this.provider),
|
|
82
|
+
1
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
// Search backwards by a constant increment until we find a slot before the timestamp or hit slot 0.
|
|
86
|
+
for (let multiplier = 1; ; multiplier++) {
|
|
87
|
+
const distance = multiplier * incrementDistance;
|
|
88
|
+
const blockNumber = Math.max(0, initialBlock.number - distance);
|
|
89
|
+
const block = await this.getBlock(blockNumber);
|
|
90
|
+
if (block.timestamp <= timestamp) break; // Found an earlier block.
|
|
91
|
+
assert(blockNumber > 0, "timestamp is before block 0");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Find the index where the slot would be inserted and use that as the end slot (since it is >= the timestamp).
|
|
96
|
+
const index = sortedIndexBy(this.blocks, { timestamp } as Block, "timestamp");
|
|
97
|
+
return this.findBlock(this.blocks[index - 1], this.blocks[index], timestamp);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Grabs the most recent slot and caches it.
|
|
101
|
+
private async getLatestBlock(): Promise<SVMBlock> {
|
|
102
|
+
const latestSlot = await this.provider.getSlot().send();
|
|
103
|
+
const estimatedSlotTime = await this.provider.getBlockTime(latestSlot).send();
|
|
104
|
+
|
|
105
|
+
// Cast the return type to an SVMBlock.
|
|
106
|
+
const block: SVMBlock = {
|
|
107
|
+
timestamp: Number(estimatedSlotTime),
|
|
108
|
+
number: Number(latestSlot),
|
|
109
|
+
};
|
|
110
|
+
const index = sortedIndexBy(this.blocks, block, "number");
|
|
111
|
+
if (this.blocks[index]?.number !== block.number) this.blocks.splice(index, 0, block);
|
|
112
|
+
return this.blocks[index];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Grabs the slot for a particular number and caches it.
|
|
116
|
+
private async getBlock(number: number): Promise<SVMBlock> {
|
|
117
|
+
let index = sortedIndexBy(this.blocks, { number } as Block, "number");
|
|
118
|
+
if (this.blocks[index]?.number === number) return this.blocks[index]; // Return early if block already exists.
|
|
119
|
+
|
|
120
|
+
const estimatedSlotTime = await this.provider.getBlockTime(BigInt(number)).send();
|
|
121
|
+
// Cast the return type to an SVMBlock.
|
|
122
|
+
const block: SVMBlock = {
|
|
123
|
+
timestamp: Number(estimatedSlotTime),
|
|
124
|
+
number,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Recompute the index after the async call since the state of this.blocks could have changed!
|
|
128
|
+
index = sortedIndexBy(this.blocks, { number } as Block, "number");
|
|
129
|
+
|
|
130
|
+
// Rerun this check to avoid duplicate insertion.
|
|
131
|
+
if (this.blocks[index]?.number === number) return this.blocks[index];
|
|
132
|
+
this.blocks.splice(index, 0, block); // A simple insert at index.
|
|
133
|
+
return block;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Return the latest slot, between startSlot and endSlot, whose timestamp is <= timestamp.
|
|
137
|
+
// Effectively, this is an interpolation search algorithm to minimize slot requests.
|
|
138
|
+
// Note: startSlot and endSlot _must_ be different slots.
|
|
139
|
+
private async findBlock(_startSlot: SVMBlock, _endSlot: SVMBlock, timestamp: number): Promise<SVMBlock> {
|
|
140
|
+
const [startBlock, endBlock] = [_startSlot, _endSlot];
|
|
141
|
+
// In the case of equality, the endBlock is expected to be passed as the one whose timestamp === the requested
|
|
142
|
+
// timestamp.
|
|
143
|
+
if (endBlock.timestamp === timestamp) return endBlock;
|
|
144
|
+
|
|
145
|
+
// If there's no equality, but the blocks are adjacent, return the startBlock, since we want the returned slot's
|
|
146
|
+
// timestamp to be <= the requested timestamp.
|
|
147
|
+
if (endBlock.number === startBlock.number + 1) return startBlock;
|
|
148
|
+
|
|
149
|
+
assert(endBlock.number !== startBlock.number, "startBlock cannot equal endBlock");
|
|
150
|
+
assert(
|
|
151
|
+
timestamp < endBlock.timestamp && timestamp > startBlock.timestamp,
|
|
152
|
+
"timestamp not in between start and end blocks"
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// Interpolating the timestamp we're searching for to slot numbers.
|
|
156
|
+
const totalTimeDifference = endBlock.timestamp - startBlock.timestamp;
|
|
157
|
+
const totalBlockDistance = endBlock.number - startBlock.number;
|
|
158
|
+
const blockPercentile = (timestamp - startBlock.timestamp) / totalTimeDifference;
|
|
159
|
+
const estimatedBlock = startBlock.number + Math.round(blockPercentile * totalBlockDistance);
|
|
160
|
+
|
|
161
|
+
// Clamp ensures the estimated slot is strictly greater than the start slot and strictly less than the end slot.
|
|
162
|
+
const newBlock = await this.getBlock(clamp(estimatedBlock, startBlock.number + 1, endBlock.number - 1));
|
|
163
|
+
|
|
164
|
+
// Depending on whether the new slot is below or above the timestamp, narrow the search space accordingly.
|
|
165
|
+
if (newBlock.timestamp < timestamp) {
|
|
166
|
+
return this.findBlock(newBlock, endBlock, timestamp);
|
|
167
|
+
} else {
|
|
168
|
+
return this.findBlock(startBlock, newBlock, timestamp);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
package/src/arch/svm/index.ts
CHANGED
|
@@ -57,7 +57,7 @@ import {
|
|
|
57
57
|
V3FillWithBlock,
|
|
58
58
|
verifyFillRepayment,
|
|
59
59
|
} from "./utils";
|
|
60
|
-
import { isEVMSpokePoolClient,
|
|
60
|
+
import { isEVMSpokePoolClient, isSVMSpokePoolClient } from "../SpokePoolClient";
|
|
61
61
|
|
|
62
62
|
// max(uint256) - 1
|
|
63
63
|
export const INFINITE_FILL_DEADLINE = bnUint32Max;
|
|
@@ -1617,7 +1617,7 @@ export class BundleDataClient {
|
|
|
1617
1617
|
deposit: DepositWithBlock,
|
|
1618
1618
|
spokePoolClient: SpokePoolClient
|
|
1619
1619
|
): Promise<FillWithBlock | undefined> {
|
|
1620
|
-
if (
|
|
1620
|
+
if (isSVMSpokePoolClient(spokePoolClient)) {
|
|
1621
1621
|
return await findSvmFillEvent(
|
|
1622
1622
|
deposit,
|
|
1623
1623
|
spokePoolClient.chainId,
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
isZeroAddress,
|
|
17
17
|
MakeOptional,
|
|
18
18
|
toBN,
|
|
19
|
+
EvmAddress,
|
|
19
20
|
} from "../../utils";
|
|
20
21
|
import {
|
|
21
22
|
EventSearchConfig,
|
|
@@ -42,6 +43,7 @@ export class EVMSpokePoolClient extends SpokePoolClient {
|
|
|
42
43
|
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 }
|
|
43
44
|
) {
|
|
44
45
|
super(logger, hubPoolClient, chainId, deploymentBlock, eventSearchConfig);
|
|
46
|
+
this.spokePoolAddress = EvmAddress.from(spokePool.address);
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
public override relayFillStatus(relayData: RelayData, atHeight?: number): Promise<FillStatus> {
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
isZeroAddress,
|
|
21
21
|
MakeOptional,
|
|
22
22
|
sortEventsAscendingInPlace,
|
|
23
|
+
SvmAddress,
|
|
23
24
|
} from "../../utils";
|
|
24
25
|
import { isUpdateFailureReason } from "../BaseAbstractClient";
|
|
25
26
|
import { HubPoolClient } from "../HubPoolClient";
|
|
@@ -29,7 +30,7 @@ import { knownEventNames, SpokePoolClient, SpokePoolUpdate } from "./SpokePoolCl
|
|
|
29
30
|
* SvmSpokePoolClient is a client for the SVM SpokePool program. It extends the base SpokePoolClient
|
|
30
31
|
* and implements the abstract methods required for interacting with an SVM Spoke Pool.
|
|
31
32
|
*/
|
|
32
|
-
export class
|
|
33
|
+
export class SVMSpokePoolClient extends SpokePoolClient {
|
|
33
34
|
/**
|
|
34
35
|
* Protected constructor. Use the async create() method to instantiate.
|
|
35
36
|
*/
|
|
@@ -45,6 +46,7 @@ export class SvmSpokePoolClient extends SpokePoolClient {
|
|
|
45
46
|
) {
|
|
46
47
|
// Convert deploymentSlot to number for base class, might need refinement
|
|
47
48
|
super(logger, hubPoolClient, chainId, Number(deploymentSlot), eventSearchConfig);
|
|
49
|
+
this.spokePoolAddress = SvmAddress.from(programId.toString());
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
/**
|
|
@@ -57,11 +59,11 @@ export class SvmSpokePoolClient extends SpokePoolClient {
|
|
|
57
59
|
deploymentSlot: bigint,
|
|
58
60
|
eventSearchConfig: MakeOptional<EventSearchConfig, "to"> = { from: 0, maxLookBack: 0 }, // Provide default
|
|
59
61
|
rpc: Rpc<SolanaRpcApiFromTransport<RpcTransport>>
|
|
60
|
-
): Promise<
|
|
62
|
+
): Promise<SVMSpokePoolClient> {
|
|
61
63
|
const svmEventsClient = await SvmCpiEventsClient.create(rpc);
|
|
62
64
|
const programId = svmEventsClient.getProgramAddress();
|
|
63
65
|
const statePda = await getStatePda(programId);
|
|
64
|
-
return new
|
|
66
|
+
return new SVMSpokePoolClient(
|
|
65
67
|
logger,
|
|
66
68
|
hubPoolClient,
|
|
67
69
|
chainId,
|
|
@@ -86,7 +88,7 @@ export class SvmSpokePoolClient extends SpokePoolClient {
|
|
|
86
88
|
) {
|
|
87
89
|
const programId = eventClient.getProgramAddress();
|
|
88
90
|
const statePda = await getStatePda(programId);
|
|
89
|
-
return new
|
|
91
|
+
return new SVMSpokePoolClient(
|
|
90
92
|
logger,
|
|
91
93
|
hubPoolClient,
|
|
92
94
|
chainId,
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
validateFillForDeposit,
|
|
20
20
|
chainIsEvm,
|
|
21
21
|
chainIsProd,
|
|
22
|
+
Address,
|
|
22
23
|
} from "../../utils";
|
|
23
24
|
import { duplicateEvent, sortEventsAscendingInPlace } from "../../utils/EventUtils";
|
|
24
25
|
import { ZERO_ADDRESS } from "../../constants";
|
|
@@ -86,6 +87,7 @@ export abstract class SpokePoolClient extends BaseAbstractClient {
|
|
|
86
87
|
protected relayerRefundExecutions: RelayerRefundExecutionWithBlock[] = [];
|
|
87
88
|
protected configStoreClient: AcrossConfigStoreClient | undefined;
|
|
88
89
|
protected invalidFills: Set<string> = new Set();
|
|
90
|
+
public spokePoolAddress: Address | undefined;
|
|
89
91
|
public fills: { [OriginChainId: number]: FillWithBlock[] } = {};
|
|
90
92
|
|
|
91
93
|
/**
|
|
@@ -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,6 @@ export {
|
|
|
6
6
|
} from "./AcrossConfigStoreClient";
|
|
7
7
|
export { UpdateFailureReason } from "./BaseAbstractClient";
|
|
8
8
|
export { HubPoolClient, LpFeeRequest } from "./HubPoolClient";
|
|
9
|
-
export { SpokePoolClient, SpokePoolUpdate, EVMSpokePoolClient,
|
|
9
|
+
export { SpokePoolClient, SpokePoolUpdate, EVMSpokePoolClient, SVMSpokePoolClient } from "./SpokePoolClient";
|
|
10
10
|
export * as BundleDataClient from "./BundleDataClient";
|
|
11
11
|
export * as mocks from "./mocks";
|
|
@@ -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,
|
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
|
/**
|