Skip to content

Commit 4105524

Browse files
refactor config for CCT Foundry (#129)
1 parent 5032e19 commit 4105524

37 files changed

+104
-124
lines changed

ccip/ccip-cla-rate-limits/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Compiler files
22
cache/
33
out/
4+
foundry.lock
45

56
# Ignores development broadcast logs
67
!/broadcast

ccip/cct/foundry/.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
PRIVATE_KEY=
22
RPC_URL_FUJI=
33
RPC_URL_ARBITRUM_SEPOLIA=
4-
ETHERSCAN_API_KEY=
5-
ARBISCAN_API_KEY=
4+
ETHERSCAN_API_KEY=

ccip/cct/foundry/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ node_modules/
33
# Compiler files
44
cache/
55
out/
6+
foundry.lock
67

78
# Ignores all broadcast logs except specific exclusions
89
/broadcast/*/

ccip/cct/foundry/README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ PRIVATE_KEY=<your_private_key>
8383
RPC_URL_FUJI=<your_rpc_url_fuji>
8484
RPC_URL_ARBITRUM_SEPOLIA=<your_rpc_url_arbitrum_sepolia>
8585
ETHERSCAN_API_KEY=<your_etherscan_api_key>
86-
ARBISCAN_API_KEY=<your_arbiscan_api_key>
8786
```
8887

8988
Variables to configure:
@@ -92,7 +91,6 @@ Variables to configure:
9291
- `RPC_URL_FUJI`: The RPC URL for the Fuji testnet. You can get this from the [Alchemy](https://www.alchemy.com/) or [Infura](https://infura.io/) website.
9392
- `RPC_URL_ARBITRUM_SEPOLIA`: The RPC URL for the Arbitrum Sepolia testnet. You can get this from the [Alchemy](https://www.alchemy.com/) or [Infura](https://infura.io/) website.
9493
- `ETHERSCAN_API_KEY`: An API key from Etherscan to verify your contracts. You can obtain one from [Etherscan](https://docs.etherscan.io/getting-started/viewing-api-usage-statistics).
95-
- `ARBISCAN_API_KEY`: An API key from Arbiscan to verify your contracts on Arbitrum. See [this guide](https://docs.arbiscan.io/getting-started/viewing-api-usage-statistics) to get one from Arbiscan.
9694

9795
**Load the environment variables** into the terminal session where you will run the commands:
9896

@@ -116,7 +114,7 @@ forge script script/AcceptAdminRole.s.sol --rpc-url $RPC_URL --private-key $PRIV
116114

117115
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.
118116

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

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

198196
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.
199197

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`).
198+
- **Deployed Local Pool Address**: The pool address is read from the output file corresponding to the current chain (e.g., `deployedTokenPool_avalanche_fuji.json`).
199+
- **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`).
200+
- **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`).
203201
- **Remote Chain Selector**: The chain selector for the remote chain is fetched based on the network configuration in `HelperConfig.s.sol`.
204202
- **Rate Limiter Configuration**: The script allows configuring rate limiting for both inbound and outbound transfers. By default, rate limiting is disabled in this script.
205203

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

240238
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.
241239

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

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

279277
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.
280278

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

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

318316
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.
319317

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

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

528526
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.
529527

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

533531
### Examples
@@ -604,23 +602,23 @@ Sets the pool for a deployed token in the `TokenAdminRegistry` contract. The scr
604602
### Usage
605603

606604
```bash
607-
forge script script/SetPool.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify
605+
forge script script/SetPool.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
608606
```
609607

610608
### Config Parameters
611609

612610
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.
613611

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`).
612+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
613+
- **Deployed Pool Address**: The pool address is read from the output file corresponding to the current chain (e.g., `deployedTokenPool_avalanche_fuji.json`).
616614
- **TokenAdminRegistry Address**: The `TokenAdminRegistry` address is retrieved based on the network settings in `HelperConfig.s.sol`.
617615

618616
### Examples
619617

620618
- Set the pool for a token:
621619

622620
```bash
623-
forge script script/SetPool.s.sol --rpc-url $RPC_URL_FUJI --private-key $PRIVATE_KEY --broadcast --verify
621+
forge script script/SetPool.s.sol --rpc-url $RPC_URL_FUJI --private-key $PRIVATE_KEY --broadcast
624622
```
625623

626624
This will:
@@ -729,14 +727,14 @@ The `TransferTokens` script facilitates cross-chain token transfers using Chainl
729727
### Usage
730728

731729
```bash
732-
forge script script/TransferTokens.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast --verify
730+
forge script script/TransferTokens.s.sol --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast
733731
```
734732

735733
### Config Parameters
736734

737735
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.
738736

739-
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalancheFuji.json`).
737+
- **Deployed Token Address**: The token address is read from the output file corresponding to the current chain (e.g., `deployedToken_avalanche_fuji.json`).
740738
- **Transfer Amount**: The amount of tokens to transfer is read from `config.json` (`tokenAmountToTransfer` field).
741739
- **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).
742740
- **Destination Chain**: The destination chain ID is determined based on the current chain ID and the `remoteChains` field in `config.json`.
@@ -746,7 +744,7 @@ The script pulls the token address, transfer amount, and fee type from the `conf
746744
- Transfer tokens across chains:
747745

748746
```bash
749-
forge script script/TransferTokens.s.sol --rpc-url $RPC_URL_FUJI --private-key $PRIVATE_KEY --broadcast --verify
747+
forge script script/TransferTokens.s.sol --rpc-url $RPC_URL_FUJI --private-key $PRIVATE_KEY --broadcast
750748
```
751749

752750
This will:

ccip/cct/foundry/foundry.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,4 @@ remappings = [
1616

1717
fs_permissions = [{ access = "read-write", path = "./" }]
1818

19-
[etherscan]
20-
avalanche-fuji = { key = "${ETHERSCAN_API_KEY}", chain = 43113, url = "https://api-testnet.snowtrace.io/api" }
21-
arbitrum-sepolia = { key = "${ARBISCAN_API_KEY}", chain = 421613, url = "https://api-sepolia.arbiscan.io/api" }
22-
2319
# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
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();
12-
HelperConfig.NetworkConfig memory remoteNetworkConfig =
13-
HelperUtils.getNetworkConfig(helperConfig, remoteChainId);
11+
HelperConfig.NetworkConfig memory remoteNetworkConfig = helperConfig.getNetworkConfig(remoteChainId);
1412

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

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

Lines changed: 3 additions & 4 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");
@@ -42,8 +42,7 @@ contract ApplyChainUpdates is Script {
4242

4343
// Fetch the remote network configuration to get the chain selector
4444
HelperConfig helperConfig = new HelperConfig();
45-
HelperConfig.NetworkConfig memory remoteNetworkConfig =
46-
HelperUtils.getNetworkConfig(helperConfig, remoteChainId);
45+
HelperConfig.NetworkConfig memory remoteNetworkConfig = helperConfig.getNetworkConfig(remoteChainId);
4746

4847
uint64 remoteChainSelector = remoteNetworkConfig.chainSelector;
4948

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

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ pragma solidity 0.8.24;
44
import {Script, console} from "forge-std/Script.sol";
55
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
66
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
7-
import {RegistryModuleOwnerCustom} from
8-
"@chainlink/contracts-ccip/contracts/tokenAdminRegistry/RegistryModuleOwnerCustom.sol";
7+
import {
8+
RegistryModuleOwnerCustom
9+
} from "@chainlink/contracts-ccip/contracts/tokenAdminRegistry/RegistryModuleOwnerCustom.sol";
910
import {BurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol";
1011

11-
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();
@@ -32,9 +32,9 @@ contract ClaimAdmin is Script {
3232
require(registryModuleOwnerCustom != address(0), "Registry module owner custom is not defined for this network");
3333

3434
vm.startBroadcast();
35-
35+
3636
claimAdminWithCCIPAdmin(tokenAddress, tokenAdmin, registryModuleOwnerCustom);
37-
37+
3838
vm.stopBroadcast();
3939
}
4040

@@ -52,14 +52,11 @@ contract ClaimAdmin is Script {
5252
console.log("Current token admin:", tokenContractCCIPAdmin);
5353

5454
// Ensure the CCIP admin matches the expected token admin address
55-
require(
56-
tokenContractCCIPAdmin == tokenAdmin, "CCIP admin of token doesn't match the token admin address."
57-
);
55+
require(tokenContractCCIPAdmin == tokenAdmin, "CCIP admin of token doesn't match the token admin address.");
5856

5957
// Register the admin via getCCIPAdmin() function
6058
console.log("Claiming admin of the token via getCCIPAdmin() for CCIP admin:", tokenAdmin);
6159
registryContract.registerAdminViaGetCCIPAdmin(tokenAddress);
6260
console.log("Admin claimed successfully for token:", tokenAddress);
6361
}
64-
6562
}

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();

0 commit comments

Comments
 (0)