Skip to content

Commit bab29f3

Browse files
committed
Refactor config for CCT Foundry
1 parent 5032e19 commit bab29f3

30 files changed

+104
-85
lines changed

ccip/cct/foundry/README.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ forge script script/AcceptAdminRole.s.sol --rpc-url $RPC_URL --private-key $PRIV
116116

117117
The script pulls the token address from a previously deployed token in a JSON file located in the `script/output/` folder. The `TokenAdminRegistry` address is fetched from the `HelperConfig.s.sol` file.
118118

119-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
119+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
120120
- **TokenAdminRegistry Address**: The `TokenAdminRegistry` address is retrieved based on the network settings in `HelperConfig.s.sol`.
121121

122122
### Examples
@@ -197,9 +197,9 @@ forge script script/ApplyChainUpdates.s.sol --rpc-url $RPC_URL --private-key $PR
197197

198198
The script pulls the pool and token addresses from previously deployed pool and token JSON files located in the `script/output/` folder. The cross-chain configuration (e.g., chain selector) is fetched from the `HelperConfig.s.sol` file.
199199

200-
- **Deployed Local Pool Address**: The pool address is read from the output file corresponding to the current chain (e.g., `deployedTokenPool_avalancheFuji.json`).
201-
- **Deployed Remote Pool Address**: The remote pool address is read from the JSON file corresponding to the remote chain (e.g., `deployedTokenPool_arbitrumSepolia.json`).
202-
- **Deployed Remote Token Address**: The remote token address is read from the JSON file corresponding to the remote chain (e.g., `deployedToken_arbitrumSepolia.json`).
200+
- **Deployed Local Pool Address**: The pool address is read from the output file corresponding to the current chain (e.g., `deployedTokenPool_avalanche_fuji.json`).
201+
- **Deployed Remote Pool Address**: The remote pool address is read from the JSON file corresponding to the remote chain (e.g., `deployedTokenPool_arbitrum_one_sepolia.json`).
202+
- **Deployed Remote Token Address**: The remote token address is read from the JSON file corresponding to the remote chain (e.g., `deployedToken_arbitrum_one_sepolia.json`).
203203
- **Remote Chain Selector**: The chain selector for the remote chain is fetched based on the network configuration in `HelperConfig.s.sol`.
204204
- **Rate Limiter Configuration**: The script allows configuring rate limiting for both inbound and outbound transfers. By default, rate limiting is disabled in this script.
205205

@@ -239,7 +239,7 @@ forge script script/ClaimAdmin.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_K
239239

240240
The script pulls the token and admin details from the `config.json` file and the deployed token address from a JSON file located in the `script/output/` folder.
241241

242-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
242+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
243243
- **Admin Address**: The admin address is read from the `config.json` file (`ccipAdminAddress` field).
244244

245245
### Examples
@@ -278,7 +278,7 @@ forge script script/DeployBurnMintTokenPool.s.sol --rpc-url $RPC_URL --private-k
278278

279279
The script pulls the token address from a previously deployed token in a JSON file located in the `script/output/` folder. The network configuration (router and RMN proxy addresses) is also fetched from the `HelperConfig.s.sol` file.
280280

281-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
281+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
282282
- **Router and RMN Proxy**: The router and RMN proxy addresses are retrieved based on the network settings in `HelperConfig.s.sol`.
283283

284284
### Examples
@@ -317,7 +317,7 @@ forge script script/DeployLockReleaseTokenPool.s.sol --rpc-url $RPC_URL --privat
317317

318318
The script pulls the token address from a previously deployed token in a JSON file located in the `script/output/` folder. The network configuration (router and RMN proxy addresses) is fetched from the `HelperConfig.s.sol` file.
319319

320-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
320+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
321321
- **Router and RMN Proxy**: The router and RMN proxy addresses are retrieved based on the network settings in `HelperConfig.s.sol`.
322322

323323
### Examples
@@ -527,7 +527,7 @@ forge script script/MintTokens.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_K
527527

528528
The script pulls the token address from a previously deployed token in a JSON file located in the `script/output/` folder. The mint amount is specified in the `config.json` file.
529529

530-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
530+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
531531
- **Mint Amount**: The amount of tokens to mint is read from the `config.json` file (`tokenAmountToMint` field).
532532

533533
### Examples
@@ -611,8 +611,8 @@ forge script script/SetPool.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY
611611

612612
The script pulls the token and pool addresses from previously deployed token and pool JSON files located in the `script/output/` folder. The `TokenAdminRegistry` address is retrieved from the `HelperConfig.s.sol` file.
613613

614-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
615-
- **Deployed Pool Address**: The pool address is read from the output file corresponding to the current chain (e.g., `deployedTokenPool_avalancheFuji.json`).
614+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
615+
- **Deployed Pool Address**: The pool address is read from the output file corresponding to the current chain (e.g., `deployedTokenPool_avalanche_fuji.json`).
616616
- **TokenAdminRegistry Address**: The `TokenAdminRegistry` address is retrieved based on the network settings in `HelperConfig.s.sol`.
617617

618618
### Examples
@@ -736,7 +736,7 @@ forge script script/TransferTokens.s.sol --rpc-url $RPC_URL --private-key $PRIVA
736736

737737
The script pulls the token address, transfer amount, and fee type from the `config.json` file. It also reads the destination chain information from the same file.
738738

739-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
739+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
740740
- **Transfer Amount**: The amount of tokens to transfer is read from `config.json` (`tokenAmountToTransfer` field).
741741
- **Fee Type**: The fee type is specified in the `config.json` file as either `"native"` (e.g., ETH, AVAX) or `"link"` (to pay fees in LINK tokens).
742742
- **Destination Chain**: The destination chain ID is determined based on the current chain ID and the `remoteChains` field in `config.json`.

ccip/cct/foundry/script/AcceptAdminRole.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {TokenAdminRegistry} from "@chainlink/contracts-ccip/contracts/tokenAdmin
99
contract AcceptAdminRole is Script {
1010
function run() external {
1111
// Get the chain name based on the current chain ID
12-
string memory chainName = HelperUtils.getChainName(block.chainid);
12+
string memory chainName = getChain(block.chainid).chainAlias;
1313

1414
// Construct the path to the deployed token JSON file
1515
string memory root = vm.projectRoot();

ccip/cct/foundry/script/AddRemotePool.s.sol

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22
pragma solidity 0.8.24;
33

44
import {Script, console} from "forge-std/Script.sol";
5-
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
65
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
76
import {TokenPool} from "@chainlink/contracts-ccip/contracts/pools/TokenPool.sol";
87

98
contract AddRemotePool is Script {
109
function run(address poolAddress, uint256 remoteChainId, address remotePoolAddress) external {
1110
HelperConfig helperConfig = new HelperConfig();
1211
HelperConfig.NetworkConfig memory remoteNetworkConfig =
13-
HelperUtils.getNetworkConfig(helperConfig, remoteChainId);
12+
helperConfig.getNetworkConfig(remoteChainId);
1413

1514
// Validate that configurations exist
1615
require(remoteNetworkConfig.chainSelector != 0, "Remote network configuration not found");

ccip/cct/foundry/script/ApplyChainUpdates.s.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {RateLimiter} from "@chainlink/contracts-ccip/contracts/libraries/RateLim
1010
contract ApplyChainUpdates is Script {
1111
function run() external {
1212
// Get the current chain name based on the chain ID
13-
string memory chainName = HelperUtils.getChainName(block.chainid);
13+
string memory chainName = getChain(block.chainid).chainAlias;
1414

1515
// Construct paths to the configuration and local pool JSON files
1616
string memory root = vm.projectRoot();
@@ -23,7 +23,7 @@ contract ApplyChainUpdates is Script {
2323
);
2424

2525
// Get the remote chain name based on the remoteChainId
26-
string memory remoteChainName = HelperUtils.getChainName(remoteChainId);
26+
string memory remoteChainName = getChain(remoteChainId).chainAlias;
2727
string memory remotePoolPath =
2828
string.concat(root, "/script/output/deployedTokenPool_", remoteChainName, ".json");
2929
string memory remoteTokenPath = string.concat(root, "/script/output/deployedToken_", remoteChainName, ".json");
@@ -43,7 +43,7 @@ contract ApplyChainUpdates is Script {
4343
// Fetch the remote network configuration to get the chain selector
4444
HelperConfig helperConfig = new HelperConfig();
4545
HelperConfig.NetworkConfig memory remoteNetworkConfig =
46-
HelperUtils.getNetworkConfig(helperConfig, remoteChainId);
46+
helperConfig.getNetworkConfig(remoteChainId);
4747

4848
uint64 remoteChainSelector = remoteNetworkConfig.chainSelector;
4949

ccip/cct/foundry/script/ClaimAdmin.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {BurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/Bu
1212
contract ClaimAdmin is Script {
1313
function run() external {
1414
// Get the chain name based on the current chain ID
15-
string memory chainName = HelperUtils.getChainName(block.chainid);
15+
string memory chainName = getChain(block.chainid).chainAlias;
1616

1717
// Define paths to the necessary JSON files
1818
string memory root = vm.projectRoot();

ccip/cct/foundry/script/DeployBurnMintTokenPool.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {IBurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/I
1111
contract DeployBurnMintTokenPool is Script {
1212
function run() external {
1313
// Get the chain name based on the current chain ID
14-
string memory chainName = HelperUtils.getChainName(block.chainid);
14+
string memory chainName = getChain(block.chainid).chainAlias;
1515

1616
// Construct the path to the deployed token JSON file
1717
string memory root = vm.projectRoot();

ccip/cct/foundry/script/DeployLockReleaseTokenPool.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {IERC20} from "@openzeppelin/[email protected]/token/ERC20/IERC20.sol";
1010
contract DeployLockReleaseTokenPool is Script {
1111
function run() external {
1212
// Get the chain name based on the current chain ID
13-
string memory chainName = HelperUtils.getChainName(block.chainid);
13+
string memory chainName = getChain(block.chainid).chainAlias;
1414

1515
// Construct the path to the deployed token JSON file
1616
string memory root = vm.projectRoot();

ccip/cct/foundry/script/DeployToken.s.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {BurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/Bu
88
contract DeployToken is Script {
99
function run() external {
1010
// Get the chain name based on the current chain ID
11-
string memory chainName = HelperUtils.getChainName(block.chainid);
11+
string memory chainName = getChain(block.chainid).chainAlias;
1212

1313
// Define the path to the config.json file
1414
string memory root = vm.projectRoot();

ccip/cct/foundry/script/GetCurrentRateLimits.s.sol

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pragma solidity 0.8.24;
33

44
import {Script, console} from "forge-std/Script.sol";
55
import {HelperConfig} from "./HelperConfig.s.sol";
6-
import {HelperUtils} from "./utils/HelperUtils.s.sol";
76

87
library RateLimiter {
98
struct State {
@@ -32,9 +31,9 @@ contract GetCurrentRateLimits is Script {
3231
// Instantiate HelperConfig
3332
HelperConfig helperConfig = new HelperConfig();
3433

35-
// Retrieve the remote network configuration using HelperUtils
34+
// Retrieve the remote network configuration using HelperConfig
3635
HelperConfig.NetworkConfig memory remoteNetworkConfig =
37-
HelperUtils.getNetworkConfig(helperConfig, remoteChainId);
36+
helperConfig.getNetworkConfig(remoteChainId);
3837

3938
// Ensure that configurations exist
4039
require(remoteNetworkConfig.chainSelector != 0, "Remote network configuration not found");

ccip/cct/foundry/script/HelperConfig.s.sol

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,18 @@ contract HelperConfig is Script {
2626
activeNetworkConfig = getAvalancheFujiConfig();
2727
} else if (block.chainid == 84532) {
2828
activeNetworkConfig = getBaseSepoliaConfig();
29+
} else if (block.chainid == 11155420) {
30+
activeNetworkConfig = getOptimismSepoliaConfig();
31+
} else {
32+
revert("Unsupported network");
2933
}
3034
}
3135

32-
function getEthereumSepoliaConfig() public pure returns (NetworkConfig memory) {
36+
function getEthereumSepoliaConfig()
37+
public
38+
pure
39+
returns (NetworkConfig memory)
40+
{
3341
NetworkConfig memory ethereumSepoliaConfig = NetworkConfig({
3442
chainSelector: 16015286601757825753,
3543
router: 0x0BF3dE8c5D3e8A2B34D2BEeB17ABfCeBaf363A59,
@@ -57,7 +65,11 @@ contract HelperConfig is Script {
5765
return arbitrumSepoliaConfig;
5866
}
5967

60-
function getAvalancheFujiConfig() public pure returns (NetworkConfig memory) {
68+
function getAvalancheFujiConfig()
69+
public
70+
pure
71+
returns (NetworkConfig memory)
72+
{
6173
NetworkConfig memory avalancheFujiConfig = NetworkConfig({
6274
chainSelector: 14767482510784806043,
6375
router: 0xF694E193200268f9a4868e4Aa017A0118C9a8177,
@@ -84,4 +96,42 @@ contract HelperConfig is Script {
8496
});
8597
return baseSepoliaConfig;
8698
}
99+
100+
function getOptimismSepoliaConfig()
101+
public
102+
pure
103+
returns (NetworkConfig memory)
104+
{
105+
NetworkConfig memory optimismSepoliaConfig = NetworkConfig({
106+
chainSelector: 5224473277236331295,
107+
router: 0x114A20A10b43D4115e5aeef7345a1A71d2a60C57,
108+
rmnProxy: 0xb40A3109075965cc09E93719e33E748abf680dAe,
109+
tokenAdminRegistry: 0x1d702b1FA12F347f0921C722f9D9166F00DEB67A,
110+
registryModuleOwnerCustom: 0x49c4ba01dc6F5090f9df43Ab8F79449Db91A0CBB,
111+
link: 0xE4aB69C077896252FAFBD49EFD26B5D171A32410,
112+
confirmations: 2,
113+
nativeCurrencySymbol: "ETH"
114+
});
115+
return optimismSepoliaConfig;
116+
}
117+
118+
function getNetworkConfig(uint256 chainId)
119+
public
120+
pure
121+
returns (NetworkConfig memory)
122+
{
123+
if (chainId == 43113) {
124+
return getAvalancheFujiConfig();
125+
} else if (chainId == 11155111) {
126+
return getEthereumSepoliaConfig();
127+
} else if (chainId == 421614) {
128+
return getArbitrumSepolia();
129+
} else if (chainId == 84532) {
130+
return getBaseSepoliaConfig();
131+
} else if (chainId == 11155420) {
132+
return getOptimismSepoliaConfig();
133+
} else {
134+
revert("Unsupported chain ID");
135+
}
136+
}
87137
}

0 commit comments

Comments
 (0)