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

import {Script, console} from "forge-std/Script.sol";
import {Chain138MainnetCheckpoint} from "../../contracts/mainnet-checkpoint/Chain138MainnetCheckpoint.sol";
import {CheckpointHubConfig} from "../../contracts/mainnet-checkpoint/libraries/CheckpointHubConfig.sol";
import {CheckpointConfigScript} from "./CheckpointConfigLib.s.sol";

/// @notice Apply granular hub config from env (post-deploy). Run predeploy gate first.
contract ConfigureCheckpointHub is CheckpointConfigScript {
    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address proxy = vm.envAddress("CHAIN138_MAINNET_CHECKPOINT_PROXY");
        Chain138MainnetCheckpoint hub = Chain138MainnetCheckpoint(proxy);
        CheckpointHubConfig.HubConfig memory cfg = hubConfigFromEnv();

        vm.startBroadcast(pk);
        hub.applyConfig(cfg);
        vm.stopBroadcast();

        CheckpointHubConfig.HubConfig memory onChain = hub.getFullConfig();
        console.log("batchSize", onChain.batchSize);
        console.log("maxBatchWaitSeconds", onChain.maxBatchWaitSeconds);
        console.log("allowCCIPIngress", onChain.allowCCIPIngress);
    }
}
