Updated on 2026-08-14
This commit is contained in:
parent
93f74f5aff
commit
91b78deb4a
2 changed files with 24 additions and 1 deletions
|
|
@ -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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ internal class WalletDeepLinksHandler @Inject constructor(
|
|||
}
|
||||
|
||||
private suspend fun onSellCurrencyDeepLink(userWallet: UserWallet, data: SellCurrencyDeepLink.Data) {
|
||||
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet.walletId, data.currencyId).getOrNull()
|
||||
val cryptoCurrency = getCryptoCurrencyUseCase(userWallet, data.currencyId).getOrNull()
|
||||
|
||||
if (cryptoCurrency == null) {
|
||||
Timber.e("onSellCurrencyDeepLink cryptoCurrency is null")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue