<?php
namespace Bot\Services;

use Bot\Config;

/**
 * Provides read-only access to admin-controlled deposit wallets per network.
 * Addresses are configured via environment variables (ADMIN_WALLET_<NETWORK>)
 * and exposed for sell flows so users know where to send crypto.
 */
class AdminWalletService
{
    /**
     * @var array<string,string>
     */
    private array $wallets;

    public function __construct()
    {
        $config = Config::get();
        $this->wallets = array_change_key_case(
            $config->getValue('admin_wallets', []),
            CASE_UPPER
        );
    }

    public function getAddress(string $network): ?string
    {
        $network = strtoupper($network);
        $address = $this->wallets[$network] ?? '';
        return $address !== '' ? $address : null;
    }

    /**
     * @return array<string,string> map of NETWORK => address
     */
    public function getAvailable(): array
    {
        return array_filter(
            $this->wallets,
            static fn ($address) => $address !== ''
        );
    }
}
