Updated on 2026-08-14

This commit is contained in:
Tangem 2025-06-26 13:22:19 +04:00
parent 73832d3e8e
commit 867d9fd735
9 changed files with 66 additions and 79 deletions

View file

@ -18,6 +18,7 @@ import com.tangem.domain.tokens.GetNetworkCoinStatusUseCase
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.ScenarioUnavailabilityReason
import com.tangem.domain.tokens.repository.CurrenciesRepository
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
import com.tangem.features.onramp.OnrampFeatureToggles
import com.tangem.utils.Provider
@ -55,7 +56,7 @@ internal class DefaultRampManager(
}
override suspend fun availableForSell(
userWalletId: UserWalletId,
userWallet: UserWallet,
status: CryptoCurrencyStatus,
): Either<ScenarioUnavailabilityReason, Unit> {
return either {
@ -68,7 +69,7 @@ internal class DefaultRampManager(
catch = { raise(ScenarioUnavailabilityReason.NotSupportedBySellService(status.currency.name)) },
)
val reason = getSendUnavailabilityReason(userWalletId, status)
val reason = getSendUnavailabilityReason(userWallet = userWallet, cryptoCurrencyStatus = status)
ensure(condition = reason is ScenarioUnavailabilityReason.None) {
when (reason) {
@ -205,14 +206,13 @@ internal class DefaultRampManager(
}
private suspend fun getSendUnavailabilityReason(
userWalletId: UserWalletId,
userWallet: UserWallet,
cryptoCurrencyStatus: CryptoCurrencyStatus,
): ScenarioUnavailabilityReason {
val coinStatus = getNetworkCoinStatusUseCase.invokeSync(
userWalletId = userWalletId,
userWallet = userWallet,
networkId = cryptoCurrencyStatus.currency.network.id,
derivationPath = cryptoCurrencyStatus.currency.network.derivationPath,
isSingleWalletWithTokens = false,
).getOrNull()
return when {