// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import "forge-std/Script.sol";
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";
import "../../contracts/registry/ChainRegistry.sol";

contract DeployChainRegistry is Script {
    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address admin = vm.addr(pk);

        vm.startBroadcast(pk);

        ChainRegistry impl = new ChainRegistry();
        bytes memory initData = abi.encodeCall(ChainRegistry.initialize, (admin));
        ERC1967Proxy proxy = new ERC1967Proxy(address(impl), initData);
        address proxyAddr = address(proxy);

        vm.stopBroadcast();

        console.log("CHAIN_REGISTRY_ADDRESS_138=", proxyAddr);
    }
}
