Updated on 2026-08-14
This commit is contained in:
parent
faa58cf142
commit
ea8c9079b7
24 changed files with 311 additions and 69 deletions
|
|
@ -0,0 +1,18 @@
|
|||
package com.tangem.domain.staking
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.staking.model.stakekit.StakingError
|
||||
import com.tangem.domain.staking.repositories.StakingErrorResolver
|
||||
import com.tangem.domain.staking.repositories.StakingRepository
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
|
||||
class IsApproveNeededUseCase(
|
||||
private val stakingRepository: StakingRepository,
|
||||
private val stakingErrorResolver: StakingErrorResolver,
|
||||
) {
|
||||
operator fun invoke(cryptoCurrency: CryptoCurrency): Either<StakingError, Boolean> {
|
||||
return Either
|
||||
.catch { stakingRepository.isApproveNeeded(cryptoCurrency) }
|
||||
.mapLeft { stakingErrorResolver.resolve(it) }
|
||||
}
|
||||
}
|
||||
|
|
@ -15,9 +15,10 @@ import com.tangem.domain.tokens.model.Network
|
|||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
@Suppress("TooManyFunctions")
|
||||
interface StakingRepository {
|
||||
|
||||
fun isStakingSupported(currencyId: String): Boolean
|
||||
fun isStakingSupported(integrationKey: String): Boolean
|
||||
|
||||
suspend fun fetchEnabledYields(refresh: Boolean)
|
||||
|
||||
|
|
@ -75,4 +76,7 @@ interface StakingRepository {
|
|||
|
||||
/** Returns whether additional staking is possible if there is already active staking */
|
||||
fun isStakeMoreAvailable(networkId: Network.ID): Boolean
|
||||
|
||||
/** Returns whether approve is needed before staking */
|
||||
fun isApproveNeeded(cryptoCurrency: CryptoCurrency): Boolean
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue