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

import {Script, console} from "forge-std/Script.sol";
import {CCIPLogger} from "../contracts/ccip-integration/CCIPLogger.sol";

/**
 * @title DeployCCIPLoggerOnly - Deploy CCIPLogger to Ethereum Mainnet
 * @notice This script deploys ONLY CCIPLogger to Ethereum Mainnet
 * @dev All other contracts (WETH9, WETH10, Bridges) are already deployed on Mainnet
 *
 * NOTE: CCIPLogger may require Hardhat/OpenZeppelin dependencies.
 * If this script fails due to missing dependencies, use the Hardhat script instead:
 *   npm run deploy:logger:mainnet
 */
contract DeployCCIPLoggerOnly is Script {
    uint256 constant MAINNET = 1;

    function run() external {
        uint256 chainId = block.chainid;
        require(chainId == MAINNET, "This script is only for Ethereum Mainnet");

        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
        address deployer = vm.addr(deployerPrivateKey);

        console.log("==========================================");
        console.log("CCIPLogger Deployment - Ethereum Mainnet");
        console.log("==========================================");
        console.log("Chain ID:", chainId);
        console.log("Deployer:", deployer);
        console.log("Deployer Balance:", deployer.balance / 1e18, "ETH");

        // Get CCIP configuration
        address router = vm.envOr("CCIP_ETH_ROUTER", address(0x80226fc0Ee2b096224EeAc085Bb9a8cba1146f7D));
        address authorizedSigner = vm.envOr("AUTHORIZED_SIGNER", address(0));
        uint64 sourceChainSelector = uint64(vm.envOr("CHAIN138_SELECTOR", uint256(0x8a))); // 138

        console.log("\nCCIP Configuration:");
        console.log("  Router:", router);
        console.log("  Authorized Signer:", authorizedSigner);
        console.log("  Source Chain Selector (Chain-138):", sourceChainSelector);

        vm.startBroadcast(deployerPrivateKey);

        CCIPLogger logger = new CCIPLogger(router, authorizedSigner, sourceChainSelector);
        address loggerAddress = address(logger);

        vm.stopBroadcast();

        if (loggerAddress != address(0)) {
            console.log("\n==========================================");
            console.log("OK: CCIPLogger Deployed Successfully");
            console.log("==========================================");
            console.log("Address:", loggerAddress);
            console.log("\nNext Steps:");
            console.log("1. Verify contract on Etherscan");
            console.log("2. Update .env with CCIPLOGGER_MAINNET=", loggerAddress);
            console.log("3. Configure CCIPTxReporter on Chain-138");
        }
    }
}

