Skip to content

Commit 8e3a8bb

Browse files
authored
improve(NetworkUtils): Use constants CCTP information (#959)
1 parent a879f66 commit 8e3a8bb

File tree

2 files changed

+15
-21
lines changed

2 files changed

+15
-21
lines changed

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import { constants as ethersConstants } from "ethers";
22
import { CHAIN_IDs, TOKEN_SYMBOLS_MAP } from "@across-protocol/constants";
33

44
export {
5+
CCTP_NO_DOMAIN,
56
ChainFamily,
67
CHAIN_IDs,
78
MAINNET_CHAIN_IDs,
89
PUBLIC_NETWORKS,
10+
PRODUCTION_NETWORKS,
911
TESTNET_CHAIN_IDs,
1012
TOKEN_SYMBOLS_MAP,
1113
TOKEN_EQUIVALENCE_REMAPPING,

src/utils/NetworkUtils.ts

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import { CCTP_NO_DOMAIN } from "@across-protocol/constants";
2-
import { ChainFamily, CHAIN_IDs, MAINNET_CHAIN_IDs, PUBLIC_NETWORKS, TESTNET_CHAIN_IDs } from "../constants";
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";
310

411
export const hreNetworks: Record<number, string> = {
512
666: "Hardhat1",
@@ -89,24 +96,6 @@ export function chainIsArbitrum(chainId: number): boolean {
8996
return [CHAIN_IDs.ARBITRUM, CHAIN_IDs.ARBITRUM_SEPOLIA].includes(chainId);
9097
}
9198

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-
11099
/**
111100
* Determines whether a chain ID is a Linea implementation.
112101
* @param chainId Chain ID to evaluate.
@@ -159,7 +148,10 @@ export function chainIsSvm(chainId: number): boolean {
159148
* @returns True if chainId is a CCTP-bridging enabled chain, otherwise false.
160149
*/
161150
export function chainIsCCTPEnabled(chainId: number): boolean {
162-
return PUBLIC_NETWORKS?.[chainId]?.cctpDomain !== CCTP_NO_DOMAIN;
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);
163155
}
164156

165157
/**

0 commit comments

Comments
 (0)