Updated on 2026-08-14
This commit is contained in:
parent
e2cc040d68
commit
ff3f1a26a5
19 changed files with 420 additions and 121 deletions
|
|
@ -2,7 +2,6 @@ package com.tangem.domain.staking
|
|||
|
||||
import arrow.core.Either
|
||||
import com.tangem.domain.staking.repositories.StakingRepository
|
||||
import com.tangem.domain.tokens.model.NetworkStatus
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
|
||||
class FetchStakingYieldBalanceUseCase(
|
||||
|
|
@ -11,13 +10,13 @@ class FetchStakingYieldBalanceUseCase(
|
|||
|
||||
suspend operator fun invoke(
|
||||
userWalletId: UserWalletId,
|
||||
networkStatus: NetworkStatus,
|
||||
address: String,
|
||||
integrationId: String,
|
||||
refresh: Boolean = false,
|
||||
): Either<Throwable, Unit> = Either.catch {
|
||||
stakingRepository.fetchSingleYieldBalance(
|
||||
userWalletId = userWalletId,
|
||||
networkStatus = networkStatus,
|
||||
address = address,
|
||||
integrationId = integrationId,
|
||||
refresh = refresh,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import arrow.core.right
|
|||
import com.tangem.domain.core.utils.EitherFlow
|
||||
import com.tangem.domain.staking.model.YieldBalance
|
||||
import com.tangem.domain.staking.repositories.StakingRepository
|
||||
import com.tangem.domain.tokens.model.NetworkStatus
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.map
|
||||
|
|
@ -17,14 +16,14 @@ class GetStakingYieldBalanceUseCase(
|
|||
|
||||
operator fun invoke(
|
||||
userWalletId: UserWalletId,
|
||||
networkStatus: NetworkStatus,
|
||||
address: String,
|
||||
integrationId: String,
|
||||
): EitherFlow<Throwable, List<YieldBalance>> {
|
||||
): EitherFlow<Throwable, YieldBalance> {
|
||||
return stakingRepository.getSingleYieldBalanceFlow(
|
||||
userWalletId = userWalletId,
|
||||
networkStatus = networkStatus,
|
||||
address = address,
|
||||
integrationId = integrationId,
|
||||
).map<List<YieldBalance>, Either<Throwable, List<YieldBalance>>> { it.right() }
|
||||
).map<YieldBalance, Either<Throwable, YieldBalance>> { it.right() }
|
||||
.catch { emit(it.left()) }
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ package com.tangem.domain.staking.repositories
|
|||
|
||||
import com.tangem.domain.staking.model.*
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.NetworkStatus
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyAddress
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
|
||||
|
|
@ -23,27 +23,27 @@ interface StakingRepository {
|
|||
|
||||
suspend fun fetchSingleYieldBalance(
|
||||
userWalletId: UserWalletId,
|
||||
networkStatus: NetworkStatus,
|
||||
address: String,
|
||||
integrationId: String,
|
||||
refresh: Boolean = false,
|
||||
)
|
||||
|
||||
fun getSingleYieldBalanceFlow(
|
||||
userWalletId: UserWalletId,
|
||||
networkStatus: NetworkStatus,
|
||||
address: String,
|
||||
integrationId: String,
|
||||
): Flow<List<YieldBalance>>
|
||||
): Flow<YieldBalance>
|
||||
|
||||
suspend fun fetchMultiYieldBalance(
|
||||
userWalletId: UserWalletId,
|
||||
networks: Set<NetworkStatus>,
|
||||
addresses: List<CryptoCurrencyAddress>,
|
||||
integrationId: String,
|
||||
refresh: Boolean = false,
|
||||
)
|
||||
|
||||
fun getMultiYieldBalanceFlow(
|
||||
userWalletId: UserWalletId,
|
||||
networks: Set<NetworkStatus>,
|
||||
addresses: List<CryptoCurrencyAddress>,
|
||||
integrationId: String,
|
||||
): Flow<List<YieldBalanceList>>
|
||||
): Flow<YieldBalanceList>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue