Skip to content

Commit

Permalink
feat: add configs for other chains
Browse files Browse the repository at this point in the history
  • Loading branch information
rhlsthrm committed Feb 6, 2024
1 parent 7350007 commit 18bd671
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
4 changes: 4 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ runs = 1000
mainnet = "${MAINNET_RPC}"
arbitrum = "${ARBITRUM_RPC}"
optimism = "${OPTIMISM_RPC}"
bsc = "${BSC_RPC}"
polygon = "${POLYGON_RPC}"
base = "${BASE_RPC}"
sepolia = "${SEPOLIA_RPC}"
arb_sepolia = "${ARB_SEPOLIA_RPC}"
Expand All @@ -44,3 +46,5 @@ mainnet = { key = "${ETHERSCAN_API_KEY_MAINNET}" }
arbitrum = { key = "${ETHERSCAN_API_KEY_ARB}" }
optimism = { key = "${ETHERSCAN_API_KEY_OPTIMISM}" }
base = { key = "${ETHERSCAN_API_KEY_BASE}" }
bsc = { key = "${ETHERSCAN_API_KEY_BSC}" }
polygon = { key = "${ETHERSCAN_API_KEY_POLYGON}" }
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
"deploy:arbitrum": "bash -c 'source .env && forge script Deploy --rpc-url arbitrum --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key arbitrum'",
"deploy:optimism": "bash -c 'source .env && forge script Deploy --rpc-url optimism --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key optimism'",
"deploy:base": "bash -c 'source .env && forge script Deploy --rpc-url base --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key base'",
"deploy:polygon": "bash -c 'source .env && forge script Deploy --rpc-url polygon --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key polygon'",
"deploy:bsc": "bash -c 'source .env && forge script Deploy --rpc-url bsc --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key bsc'",
"configure:arbitrum": "bash -c 'source .env && forge script ConfigureArbitrum --rpc-url arbitrum --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key arbitrum'",
"configure:optimism": "bash -c 'source .env && forge script ConfigureOptimism --rpc-url optimism --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key optimism'",
"configure:base": "bash -c 'source .env && forge script ConfigureBase --rpc-url base --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key base'",
"configure:polygon": "bash -c 'source .env && forge script ConfigurePolygon --gas-estimate-multiplier 500 --rpc-url polygon --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key polygon'",
"configure:bsc": "bash -c 'source .env && forge script ConfigureBsc --rpc-url bsc --broadcast --private-key $MAINNET_DEPLOYER_PK --verify --etherscan-api-key bsc'",
"lint:check": "yarn lint:sol-tests && yarn lint:sol-logic && forge fmt --check",
"lint:fix": "sort-package-json && forge fmt && yarn lint:sol-tests --fix && yarn lint:sol-logic --fix",
"lint:sol-logic": "solhint -c .solhint.json 'solidity/contracts/**/*.sol' 'solidity/interfaces/**/*.sol'",
Expand Down
40 changes: 36 additions & 4 deletions solidity/scripts/Configure.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ abstract contract Configure is Script, Config {

constructor() Config() {
bridges[10] = CCIPxERC20Bridge(payable(0x0337c7b958aC69A9e35b1Be47D96b8e058f9222a)); // optimism
bridges[56] = CCIPxERC20Bridge(payable(0x840854c007c1E5F64074350beECa088F8a8e48BF)); // bsc
bridges[137] = CCIPxERC20Bridge(payable(0xB2e04651aC165CB6D2b8B0442ab25231DEf15b51)); // polygon
bridges[8453] = CCIPxERC20Bridge(payable(0x083178fBB5d6dd6521fe778BcfC32BF898678fAe)); // base
bridges[42_161] = CCIPxERC20Bridge(payable(0x0337c7b958aC69A9e35b1Be47D96b8e058f9222a)); // arbitrum

Expand All @@ -30,7 +32,9 @@ abstract contract Configure is Script, Config {
XERC20(xerc20s[block.chainid]).setLimits(address(bridge), 1_000_000_000 ether, 1_000_000_000 ether);
require(address(bridge) != address(0), 'bridge not deployed');
for (uint256 i = 0; i < _otherChainIds.length; i++) {
if (bridge.bridgesByChain(bridge.chainIdToChainSelector(_otherChainIds[i])) == bridges[_otherChainIds[i]]) {
if (
bridge.bridgesByChain(bridge.chainIdToChainSelector(_otherChainIds[i])) == address(bridges[_otherChainIds[i]])
) {
continue;
}
bridge.addBridgeForChain(bridge.chainIdToChainSelector(_otherChainIds[i]), address(bridges[_otherChainIds[i]]));
Expand All @@ -56,27 +60,55 @@ contract ConfigureArbSepolia is Configure {

contract ConfigureBase is Configure {
function run() external {
uint32[] memory _otherChainIds = new uint32[](2);
uint32[] memory _otherChainIds = new uint32[](4);
_otherChainIds[0] = 10;
_otherChainIds[1] = 42_161;
_otherChainIds[2] = 137;
_otherChainIds[3] = 56;
_configure(_otherChainIds);
}
}

contract ConfigureArbitrum is Configure {
function run() external {
uint32[] memory _otherChainIds = new uint32[](2);
uint32[] memory _otherChainIds = new uint32[](4);
_otherChainIds[0] = 8453;
_otherChainIds[1] = 10;
_otherChainIds[2] = 137;
_otherChainIds[3] = 56;
_configure(_otherChainIds);
}
}

contract ConfigureOptimism is Configure {
function run() external {
uint32[] memory _otherChainIds = new uint32[](2);
uint32[] memory _otherChainIds = new uint32[](4);
_otherChainIds[0] = 8453;
_otherChainIds[1] = 42_161;
_otherChainIds[2] = 137;
_otherChainIds[3] = 56;
_configure(_otherChainIds);
}
}

contract ConfigureBsc is Configure {
function run() external {
uint32[] memory _otherChainIds = new uint32[](4);
_otherChainIds[0] = 8453;
_otherChainIds[1] = 137;
_otherChainIds[2] = 10;
_otherChainIds[3] = 42_161;
_configure(_otherChainIds);
}
}

contract ConfigurePolygon is Configure {
function run() external {
uint32[] memory _otherChainIds = new uint32[](4);
_otherChainIds[0] = 8453;
_otherChainIds[1] = 10;
_otherChainIds[2] = 42_161;
_otherChainIds[3] = 56;
_configure(_otherChainIds);
}
}

0 comments on commit 18bd671

Please sign in to comment.