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

import {Script, console} from "forge-std/Script.sol";
import {CCIPRelayRouter} from "../contracts/relay/CCIPRelayRouter.sol";
import {CCIPRelayBridgeLINK} from "../contracts/relay/CCIPRelayBridgeLINK.sol";

/// @notice Deploy CCIPRelayBridgeLINK on destination chain and authorize on existing CCIPRelayRouter.
/// Env: PRIVATE_KEY, LINK_TOKEN_MAINNET (or DEST_LINK_ADDRESS), CCIP_RELAY_ROUTER_MAINNET
contract DeployCCIPRelayBridgeLINK is Script {
    function run() external {
        uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
        address link = vm.envAddress("LINK_TOKEN_MAINNET");
        address relayRouter = vm.envAddress("CCIP_RELAY_ROUTER_MAINNET");

        vm.startBroadcast(deployerPrivateKey);

        CCIPRelayBridgeLINK linkBridge = new CCIPRelayBridgeLINK(link, relayRouter);
        console.log("CCIPRelayBridgeLINK:", address(linkBridge));

        CCIPRelayRouter(relayRouter).authorizeBridge(address(linkBridge));
        console.log("Authorized on CCIPRelayRouter:", relayRouter);

        vm.stopBroadcast();
    }
}
