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

import "./UniversalAssetRegistry.sol";

/**
 * @title GRUAssetRegistryFacet
 * @notice ERC-2535 Diamond facet adapter: delegates to UniversalAssetRegistry so M00 Diamond exposes GRU/c* asset registry.
 * @dev Attach to M00 Diamond; set registry via setRegistry. All c* registered via registerGRUCompliantAsset are then queryable via this facet.
 */
contract GRUAssetRegistryFacet {
    UniversalAssetRegistry public registry;

    event RegistrySet(address indexed registry);

    /// @notice One-time set of UniversalAssetRegistry delegate. Callable once (diamond cut init or standalone deploy).
    function setRegistry(address _registry) external {
        require(address(registry) == address(0), "RegistryAlreadySet");
        require(_registry != address(0), "Zero registry");
        registry = UniversalAssetRegistry(_registry);
        emit RegistrySet(_registry);
    }

    function getAsset(address token) external view returns (UniversalAssetRegistry.UniversalAsset memory) {
        return registry.getAsset(token);
    }

    function getAssetType(address token) external view returns (UniversalAssetRegistry.AssetType) {
        return registry.getAssetType(token);
    }

    function getAssetsByType(UniversalAssetRegistry.AssetType assetType) external view returns (address[] memory) {
        return registry.getAssetsByType(assetType);
    }

    function isAssetActive(address token) external view returns (bool) {
        return registry.isAssetActive(token);
    }
}
