rln-contract/script/DeploymentConfig.s.sol

52 lines
1.7 KiB
Solidity

//// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.19;
import { Script } from "forge-std/Script.sol";
contract DeploymentConfig is Script {
error DeploymentConfig_InvalidDeployerAddress();
error DeploymentConfig_NoConfigForChain(uint256);
struct NetworkConfig {
address deployer;
}
NetworkConfig public activeNetworkConfig;
address private deployer;
constructor(address _broadcaster) {
if (_broadcaster == address(0)) revert DeploymentConfig_InvalidDeployerAddress();
deployer = _broadcaster;
if (block.chainid == 31_337) {
activeNetworkConfig = getOrCreateAnvilEthConfig();
} else if (block.chainid == 11_155_111) {
activeNetworkConfig = getOrCreateSepoliaEthConfig();
} else if (block.chainid == 1442) {
activeNetworkConfig = getOrCreatePolygonZkevmConfig();
} else {
revert DeploymentConfig_NoConfigForChain(block.chainid);
}
}
function getOrCreateAnvilEthConfig() public view returns (NetworkConfig memory) {
return NetworkConfig({ deployer: deployer });
}
function getOrCreateSepoliaEthConfig() public view returns (NetworkConfig memory) {
return NetworkConfig({ deployer: deployer });
}
function getOrCreatePolygonZkevmConfig() public view returns (NetworkConfig memory) {
return NetworkConfig({ deployer: deployer });
}
// This function is a hack to have it excluded by `forge coverage` until
// https://github.com/foundry-rs/foundry/issues/2988 is fixed.
// See: https://github.com/foundry-rs/foundry/issues/2988#issuecomment-1437784542
// for more info.
// solhint-disable-next-line
function test() public { }
}