Updated on 2026-08-14

This commit is contained in:
Tangem 2025-01-28 21:36:11 +05:00
parent 93f74f5aff
commit 91b78deb4a
2 changed files with 24 additions and 1 deletions

View file

@ -7,12 +7,35 @@ import arrow.core.raise.either
import com.tangem.domain.tokens.error.CurrencyStatusError
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.repository.CurrenciesRepository
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
class GetCryptoCurrencyUseCase(
private val currenciesRepository: CurrenciesRepository,
) {
/**
* Returns specific cryptocurrency for a given user wallet.
*
* !!! Important Use only [CryptoCurrency.ID.value] as cryptoCurrencyId
*
* @param userWallet The user's wallet.
* @param cryptoCurrencyId The ID of the cryptocurrency.
* @return An [Either] representing success (Right) or an error (Left) in fetching the status.
*/
suspend operator fun invoke(
userWallet: UserWallet,
cryptoCurrencyId: String,
): Either<CurrencyStatusError, CryptoCurrency> {
return either {
if (userWallet.isMultiCurrency) {
getCurrency(userWallet.walletId, cryptoCurrencyId)
} else {
getPrimaryCurrency(userWallet.walletId)
}
}
}
/**
* Returns specific cryptocurrency for a given user wallet.
*