diff --git a/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt b/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt index 51252c819c..8b4136e90f 100644 --- a/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt +++ b/app/src/main/java/com/tangem/tap/domain/RatesRepository.kt @@ -20,21 +20,18 @@ class RatesRepository { val throttledResult = coinsList.filter { throttler.isStillThrottled(it) }.map { Pair(it, throttler.geValue(it)) } - if (throttledResult.isNotEmpty()) { - return handleFiatRatesResult(throttledResult.toMap()) - } val currenciesToUpdate = coinsList.filter { !throttler.isStillThrottled(it) } val coinIds = currenciesToUpdate.mapNotNull { it.coinId }.distinct() - if (coinIds.isEmpty()) return EMPTY_RESULT + if (coinIds.isEmpty()) return handleFiatRatesResult(throttledResult.toMap()) return when (val result = tangemTechService.rates(currencyId, coinIds)) { is Result.Success -> { val ratesResultList: Map> = result.data.rates.mapValues { Result.Success(it.value.toBigDecimal()) } - val updatedCurrencies = mutableMapOf?>() - currenciesToUpdate.forEach { currency -> + val updatedCurrencies = throttledResult.toMap().toMutableMap() + coinsList.forEach { currency -> ratesResultList[currency.coinId]?.let { updatedCurrencies[currency] = it throttler.updateThrottlingTo(currency) @@ -65,13 +62,6 @@ class RatesRepository { fun clear() { throttler.clear() } - - companion object { - val EMPTY_RESULT = Result.Success(Pair( - mutableMapOf(), - mutableMapOf() - )) - } } typealias RatesResult = Pair, MutableMap> diff --git a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt index 2339b0a219..d737ac736b 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/ui/WalletDetailsFragment.kt @@ -157,8 +157,15 @@ class WalletDetailsFragment : Fragment(R.layout.fragment_wallet_details), walletCurrenciesManager.update(selectedUserWallet, blockchainNetwork) } else { store.dispatch( - WalletAction.LoadWallet(blockchainNetwork), + WalletAction.LoadWallet( + blockchain = BlockchainNetwork( + selectedWallet.currency.blockchain, + selectedWallet.currency.derivationPath, + emptyList(), + ), + ), ) + store.dispatch(WalletAction.LoadFiatRate(coinsList = listOf(selectedWallet.currency))) } } } diff --git a/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt b/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt index b11840f128..0fde777794 100644 --- a/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt +++ b/domain/src/main/java/com/tangem/domain/common/extensions/Blockchain.kt @@ -44,8 +44,7 @@ fun Blockchain.Companion.fromNetworkId(networkId: String): Blockchain? { "polkadot" -> Blockchain.Polkadot "polkadot/test" -> Blockchain.PolkadotTestnet "kusama" -> Blockchain.Kusama - // "optimistic-ethereum" -> Blockchain.Optimism - "optimistic-ethereum" -> null //TODO: Optimism is disabled until next release + "optimistic-ethereum" -> Blockchain.Optimism "optimistic-ethereum/test" -> Blockchain.OptimismTestnet "dash" -> Blockchain.Dash "sxdai" -> Blockchain.SaltPay @@ -144,6 +143,5 @@ fun Blockchain.isSupportedInApp(): Boolean { } private val excludedBlockchains = listOf( - Blockchain.Optimism, // TODO: remove when fee calculation is fixed Blockchain.SaltPay, ) \ No newline at end of file