Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/AcceptAdminRole.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ pragma solidity 0.8.24;
import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {TokenAdminRegistry} from "@chainlink/contracts-ccip/contracts/tokenAdminRegistry/TokenAdminRegistry.sol";

contract AcceptAdminRole is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the chain name based on the current chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Construct the path to the deployed token JSON file
string memory root = vm.projectRoot();
Expand Down
6 changes: 4 additions & 2 deletions ccip/cct/foundry/script/ApplyChainUpdates.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ pragma solidity 0.8.24;
import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {TokenPool} from "@chainlink/contracts-ccip/contracts/pools/TokenPool.sol";
import {RateLimiter} from "@chainlink/contracts-ccip/contracts/libraries/RateLimiter.sol";

contract ApplyChainUpdates is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the current chain name based on the chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

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

// Get the remote chain name based on the remoteChainId
string memory remoteChainName = getChain(remoteChainId).chainAlias;
string memory remoteChainName = resolver.getChainNameSafe(remoteChainId);
string memory remotePoolPath =
string.concat(root, "/script/output/deployedTokenPool_", remoteChainName, ".json");
string memory remoteTokenPath = string.concat(root, "/script/output/deployedToken_", remoteChainName, ".json");
Expand Down
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/ClaimAdmin.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ pragma solidity 0.8.24;
import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {
RegistryModuleOwnerCustom
} from "@chainlink/contracts-ccip/contracts/tokenAdminRegistry/RegistryModuleOwnerCustom.sol";
import {BurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol";

contract ClaimAdmin is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the chain name based on the current chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Define paths to the necessary JSON files
string memory root = vm.projectRoot();
Expand Down
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/DeployBurnMintTokenPool.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ pragma solidity 0.8.24;
import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {BurnMintTokenPool} from "@chainlink/contracts-ccip/contracts/pools/BurnMintTokenPool.sol";
import {BurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol";
import {IBurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/IBurnMintERC20.sol";

contract DeployBurnMintTokenPool is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the chain name based on the current chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Construct the path to the deployed token JSON file
string memory root = vm.projectRoot();
Expand Down
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/DeployLockReleaseTokenPool.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ pragma solidity 0.8.24;
import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {LockReleaseTokenPool} from "@chainlink/contracts-ccip/contracts/pools/LockReleaseTokenPool.sol";
import {IERC20} from "@openzeppelin/contracts@4.8.3/token/ERC20/IERC20.sol";

contract DeployLockReleaseTokenPool is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the chain name based on the current chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Construct the path to the deployed token JSON file
string memory root = vm.projectRoot();
Expand Down
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/DeployToken.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ pragma solidity 0.8.24;

import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {BurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol";

contract DeployToken is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the chain name based on the current chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Define the path to the config.json file
string memory root = vm.projectRoot();
Expand Down
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/MintTokens.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ pragma solidity 0.8.24;

import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {BurnMintERC20} from "@chainlink/contracts/src/v0.8/shared/token/ERC20/BurnMintERC20.sol";

contract MintTokens is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the current chain name based on the chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Construct paths to the configuration and token JSON files
string memory root = vm.projectRoot();
Expand Down
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/SetPool.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ pragma solidity 0.8.24;
import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {TokenAdminRegistry} from "@chainlink/contracts-ccip/contracts/tokenAdminRegistry/TokenAdminRegistry.sol";

// Script contract to set the token pool in the TokenAdminRegistry
contract SetPool is Script {
function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the chain name based on the current chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Construct paths to the JSON files containing deployed token and pool addresses
string memory root = vm.projectRoot();
Expand Down
4 changes: 3 additions & 1 deletion ccip/cct/foundry/script/TransferTokens.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.24;
import {Script, console} from "forge-std/Script.sol";
import {HelperUtils} from "./utils/HelperUtils.s.sol"; // Utility functions for JSON parsing and chain info
import {HelperConfig} from "./HelperConfig.s.sol"; // Network configuration helper
import {ChainNameResolver} from "./utils/ChainNameResolver.s.sol"; // Chain name resolution utility
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IRouterClient} from "@chainlink/contracts-ccip/contracts/interfaces/IRouterClient.sol";
import {Client} from "@chainlink/contracts-ccip/contracts/libraries/Client.sol";
Expand All @@ -15,8 +16,9 @@ contract TransferTokens is Script {
}

function run() external {
ChainNameResolver resolver = new ChainNameResolver();
// Get the chain name based on the current chain ID
string memory chainName = getChain(block.chainid).chainAlias;
string memory chainName = resolver.getChainNameSafe(block.chainid);

// Construct paths to the configuration and token JSON files
string memory root = vm.projectRoot();
Expand Down
28 changes: 28 additions & 0 deletions ccip/cct/foundry/script/utils/ChainNameResolver.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

import {Script} from "forge-std/Script.sol";

/**
* @title ChainNameResolver
* @notice Provides safe access to StdChains functionality without constructor dependencies
* @dev This contract acts as a resolver,
* and can be used independently to get chain information for any chain,
* with graceful fallback.
*/
contract ChainNameResolver is Script {
/// @dev External function to call getChain (needed for try/catch)
function getChainAlias(uint256 chainId) external returns (string memory) {
return getChain(chainId).chainAlias;
}

/// @dev Safely get chain alias with fallback to "custom_network" if not found in StdChains
function getChainNameSafe(uint256 chainId) public returns (string memory) {
try this.getChainAlias(chainId) returns (string memory chainAlias) {
return chainAlias;
} catch {
// Fallback to "custom_network" for chains not in StdChains
return "custom_network";
}
}
}
Loading