diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt index 7b43c6221f..cd41c82702 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetFeePaidCryptoCurrencyStatusSyncUseCase.kt @@ -3,7 +3,6 @@ package com.tangem.domain.tokens import arrow.core.Either import arrow.core.raise.either import com.tangem.domain.tokens.error.TokenListError -import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.FeePaidCurrency import com.tangem.domain.tokens.operations.CurrenciesStatusesOperations @@ -35,17 +34,13 @@ class GetFeePaidCryptoCurrencyStatusSyncUseCase( return either { when (feePaidCurrency) { - FeePaidCurrency.Coin -> getCryptoCurrencyStatus(operations, cryptoCurrency.id) + FeePaidCurrency.Coin -> + operations + .getNetworkCoinSync(cryptoCurrency.network.id, cryptoCurrency.network.derivationPath) + .getOrNull() FeePaidCurrency.SameCurrency -> cryptoCurrencyStatus - is FeePaidCurrency.Token -> getCryptoCurrencyStatus(operations, feePaidCurrency.tokenId) + is FeePaidCurrency.Token -> operations.getCurrencyStatusSync(feePaidCurrency.tokenId).getOrNull() } } } - - private suspend fun getCryptoCurrencyStatus( - operations: CurrenciesStatusesOperations, - cryptoCurrencyId: CryptoCurrency.ID, - ): CryptoCurrencyStatus? { - return operations.getCurrencyStatusSync(cryptoCurrencyId).getOrNull() - } } \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt index 92d6969de0..fac9f7fc95 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/operations/CurrenciesStatusesOperations.kt @@ -109,6 +109,18 @@ internal class CurrenciesStatusesOperations( } } + suspend fun getNetworkCoinSync( + networkId: Network.ID, + derivationPath: Network.DerivationPath, + ): Either { + val currency = recover( + block = { getNetworkCoin(networkId, derivationPath) }, + recover = { return it.left() }, + ) + + return getCurrencyStatusSync(currency.id) + } + suspend fun getPrimaryCurrencyStatusSync(): Either = either { val currency = catch( block = { currenciesRepository.getSingleCurrencyWalletPrimaryCurrency(userWalletId) },