from typing import Dict
from decimal import Decimal
EXCHANGE_RATES: Dict[str, Decimal] = {'VND': Decimal('1.0'), 'USD': Decimal('0.000041'), 'EUR': Decimal('0.000038'), 'GBP': Decimal('0.000033'), 'JPY': Decimal('0.0061'), 'CNY': Decimal('0.00029'), 'KRW': Decimal('0.055'), 'SGD': Decimal('0.000055'), 'THB': Decimal('0.0015'), 'AUD': Decimal('0.000062'), 'CAD': Decimal('0.000056')}
SUPPORTED_CURRENCIES = list(EXCHANGE_RATES.keys())

class CurrencyService:

    @staticmethod
    def get_supported_currencies() -> list:
        return SUPPORTED_CURRENCIES

    @staticmethod
    def convert_amount(amount: float, from_currency: str, to_currency: str) -> float:
        from_currency = from_currency.upper()
        to_currency = to_currency.upper()
        if from_currency == to_currency:
            return amount
        if from_currency not in EXCHANGE_RATES:
            raise ValueError(f'Unsupported source currency: {from_currency}')
        if to_currency not in EXCHANGE_RATES:
            raise ValueError(f'Unsupported target currency: {to_currency}')
        amount_vnd = Decimal(str(amount)) / EXCHANGE_RATES[from_currency]
        converted_amount = amount_vnd * EXCHANGE_RATES[to_currency]
        return float(converted_amount)

    @staticmethod
    def get_exchange_rate(from_currency: str, to_currency: str) -> float:
        from_currency = from_currency.upper()
        to_currency = to_currency.upper()
        if from_currency == to_currency:
            return 1.0
        if from_currency not in EXCHANGE_RATES:
            raise ValueError(f'Unsupported source currency: {from_currency}')
        if to_currency not in EXCHANGE_RATES:
            raise ValueError(f'Unsupported target currency: {to_currency}')
        rate = EXCHANGE_RATES[to_currency] / EXCHANGE_RATES[from_currency]
        return float(rate)

    @staticmethod
    def format_currency_code(currency: str) -> str:
        return currency.upper() if currency else 'VND'
currency_service = CurrencyService()