// SPDX-License-Identifier: MIT
pragma solidity 0.8.24;

/// @title LegacyKYAAdapterV3
/// @notice Read-only adapter over the historical Vaultfire KYA (Know Your Agent)
///         address-based registrations. This is EXPLICITLY a legacy adapter and
///         does not claim ERC-8004 semantics. It exists so V3 UIs and indexers
///         can still resolve pre-V3 agents for provenance.
/// @dev No writes. No admin. No slashing. Reads only.
interface ILegacyKYA {
    function isRegistered(address wallet) external view returns (bool);
    function registeredAt(address wallet) external view returns (uint64);
    function agentType(address wallet) external view returns (string memory);
}

contract LegacyKYAAdapterV3 {
    error ZeroAddress();
    error NotRegistered(address wallet);

    ILegacyKYA public immutable legacy;

    constructor(address _legacy) {
        if (_legacy == address(0)) revert ZeroAddress();
        legacy = ILegacyKYA(_legacy);
    }

    /// @notice UI/indexers show this label next to any resolved legacy identity.
    function label() external pure returns (string memory) {
        return "Legacy KYA (pre-V3, address-based, not ERC-8004)";
    }

    function resolve(address wallet) external view returns (bool registered, uint64 since, string memory agentType_) {
        registered = legacy.isRegistered(wallet);
        if (!registered) return (false, 0, "");
        since = legacy.registeredAt(wallet);
        agentType_ = legacy.agentType(wallet);
    }
}
