Updated on 2026-08-14

This commit is contained in:
Tangem 2026-01-28 16:19:36 +04:00
parent 749260cdef
commit ed7a658e86
2 changed files with 22 additions and 5 deletions

View file

@ -8,6 +8,7 @@ import com.tangem.domain.models.account.AccountId
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.tokens.GetCryptoCurrencyActionsUseCase
import com.tangem.domain.tokens.model.TokenActionsState
import com.tangem.domain.yield.supply.models.YieldSupplyAvailability
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.emitAll
@ -29,7 +30,11 @@ class GetCryptoCurrencyActionsUseCaseV2(
) {
@OptIn(ExperimentalCoroutinesApi::class)
operator fun invoke(accountId: AccountId, currency: CryptoCurrency): Flow<TokenActionsState> {
operator fun invoke(
accountId: AccountId,
currency: CryptoCurrency,
yieldSupplyAvailability: YieldSupplyAvailability = YieldSupplyAvailability.Unavailable,
): Flow<TokenActionsState> {
return singleAccountStatusListSupplier(
params = SingleAccountStatusListProducer.Params(userWalletId = accountId.userWalletId),
)
@ -44,6 +49,7 @@ class GetCryptoCurrencyActionsUseCaseV2(
val actionsFlow = getCryptoCurrencyActionsUseCase(
userWallet = userWallet,
cryptoCurrencyStatus = accountCurrencyStatus.status,
yieldSupplyAvailability = yieldSupplyAvailability,
)
emitAll(actionsFlow)

View file

@ -1,5 +1,6 @@
package com.tangem.features.markets.portfolio.impl.model
import arrow.core.getOrElse
import com.tangem.blockchainsdk.compatibility.getTokenIdIfL2Network
import com.tangem.common.ui.account.AccountTitleUM
import com.tangem.common.ui.account.toUM
@ -24,6 +25,8 @@ import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.models.wallet.isMultiCurrency
import com.tangem.domain.tokens.model.TokenActionsState
import com.tangem.domain.wallets.usecase.GetUserWalletUseCase
import com.tangem.domain.yield.supply.models.YieldSupplyAvailability
import com.tangem.domain.yield.supply.usecase.YieldSupplyGetAvailabilityUseCase
import com.tangem.features.markets.portfolio.impl.loader.PortfolioData
import com.tangem.features.markets.portfolio.impl.ui.state.MyPortfolioUM
import com.tangem.features.markets.portfolio.impl.ui.state.MyPortfolioUM.Tokens.AddButtonState
@ -48,6 +51,7 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor(
private val allAccountSupplier: MultiAccountStatusListSupplier,
private val getCryptoCurrencyActionsUseCase: GetCryptoCurrencyActionsUseCaseV2,
private val getUserWalletUseCase: GetUserWalletUseCase,
private val yieldSupplyGetAvailabilityUseCase: YieldSupplyGetAvailabilityUseCase,
isAccountsModeEnabledUseCase: IsAccountsModeEnabledUseCase,
@Assisted private val scope: CoroutineScope,
@Assisted private val token: TokenMarketParams,
@ -113,10 +117,17 @@ internal class NewMarketsPortfolioDelegate @AssistedInject constructor(
private fun contentFlow(portfolio: PortfoliosWithThisCurrency): Flow<MyPortfolioUM.Content> {
fun Portfolio.actionsFoAccountCurrencies(): List<Flow<Pair<CryptoCurrency, TokenActionsState>>> =
accountsWithAdded.map { account ->
fun CryptoCurrencyStatus.actionsFlow() = getCryptoCurrencyActionsUseCase(
accountId = account.accountStatus.account.accountId,
currency = this.currency,
).map { actionsState -> actionsState.cryptoCurrencyStatus.currency to actionsState }
fun CryptoCurrencyStatus.actionsFlow(): Flow<Pair<CryptoCurrency, TokenActionsState>> = flow {
val yieldSupplyAvailability = yieldSupplyGetAvailabilityUseCase(this@actionsFlow.currency)
.getOrElse { YieldSupplyAvailability.Unavailable }
emitAll(
getCryptoCurrencyActionsUseCase(
accountId = account.accountStatus.account.accountId,
currency = this@actionsFlow.currency,
yieldSupplyAvailability = yieldSupplyAvailability,
).map { actionsState -> actionsState.cryptoCurrencyStatus.currency to actionsState },
)
}
account.addedCurrency.map { it.actionsFlow() }
}.flatten()