From d64a58389b55591bc43acf19d25d669307b4cb31 Mon Sep 17 00:00:00 2001 From: Konstantin Ullrich Date: Mon, 11 Aug 2025 19:21:07 +0200 Subject: [PATCH] feat: add currency override support in fiat conversion service (#2445) --- lib/core/fiat_conversion_service.dart | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/core/fiat_conversion_service.dart b/lib/core/fiat_conversion_service.dart index 669e38128..af6a3192c 100644 --- a/lib/core/fiat_conversion_service.dart +++ b/lib/core/fiat_conversion_service.dart @@ -48,11 +48,19 @@ Future _fetchPrice(String crypto, String fiat, bool torOnly) async { } } +/// Override specific [CryptoCurrency] to fix its price to the price of another +/// e.g. nDEPS should have the same price as DEPS, but only DEPS is tracked +CryptoCurrency _overrideCryptoCurrency(CryptoCurrency crypto) { + if (crypto.title == CryptoCurrency.ndeps.title) + return CryptoCurrency.deps; + return crypto; +} + class FiatConversionService { static Future fetchPrice({ required CryptoCurrency crypto, required FiatCurrency fiat, required bool torOnly, }) async => - await _fetchPrice(crypto.toString(), fiat.toString(), torOnly); + await _fetchPrice(_overrideCryptoCurrency(crypto).toString(), fiat.toString(), torOnly); }