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

import "forge-std/Script.sol";
import {UniversalAssetRegistry} from "../../../contracts/registry/UniversalAssetRegistry.sol";

/**
 * @title GrantUarRegistrarRWA138
 * @notice Grant REGISTRAR_ROLE on UAR to broadcaster (for RegisterRWAIndicesInUAR138).
 * @dev Broadcaster must hold DEFAULT_ADMIN_ROLE on UAR.
 */
contract GrantUarRegistrarRWA138 is Script {
    function run() external {
        uint256 pk = vm.envUint("PRIVATE_KEY");
        address grantee = vm.envOr("UAR_REGISTRAR_GRANTEE", vm.addr(pk));
        address uarAddr = vm.envAddress("UNIVERSAL_ASSET_REGISTRY");

        UniversalAssetRegistry uar = UniversalAssetRegistry(uarAddr);
        bytes32 role = uar.REGISTRAR_ROLE();

        vm.startBroadcast(pk);
        uar.grantRole(role, grantee);
        vm.stopBroadcast();

        console.log("REGISTRAR_ROLE granted to", grantee, "on UAR", uarAddr);
    }
}
