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

import "forge-std/Script.sol";
import {IDiamondCut} from "@gru/interfaces/IDiamondCut.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";

/**
 * @notice Add OZ AccessControl admin selectors to existing M00MainnetBridgeFacet on live hub.
 */
contract UpgradeM00DiamondAcl138 is Script {
    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address diamond = vm.envAddress("M00_DIAMOND_HUB");
        address bridgeFacet = vm.envAddress("M00_MAINNET_BRIDGE_FACET");

        bytes4[] memory sels = new bytes4[](3);
        sels[0] = IAccessControl.grantRole.selector;
        sels[1] = IAccessControl.revokeRole.selector;
        sels[2] = IAccessControl.hasRole.selector;

        IDiamondCut.FacetCut[] memory cut = new IDiamondCut.FacetCut[](1);
        cut[0] = IDiamondCut.FacetCut({
            facetAddress: bridgeFacet,
            action: IDiamondCut.FacetCutAction.Add,
            functionSelectors: sels
        });

        vm.startBroadcast(pk);
        IDiamondCut(diamond).diamondCut(cut, address(0), "");
        vm.stopBroadcast();
    }
}
