diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt
index 9f5d8aecb2..1abdf861b9 100644
--- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt
+++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/TradeCryptoMiddleware.kt
@@ -5,7 +5,6 @@ import com.tangem.blockchain.common.Blockchain
import com.tangem.common.routing.AppRoute
import com.tangem.common.routing.AppRouter
import com.tangem.core.analytics.Analytics
-import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.domain.tokens.legacy.TradeCryptoAction
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.NetworkAddress
@@ -48,11 +47,6 @@ object TradeCryptoMiddleware {
is TradeCryptoAction.FinishSelling -> openReceiptUrl(action.transactionId)
is TradeCryptoAction.Buy -> proceedBuyAction(state, action)
is TradeCryptoAction.Sell -> proceedSellAction(action)
- is TradeCryptoAction.Stake -> openStaking(
- userWalletId = action.userWalletId,
- cryptoCurrencyId = action.cryptoCurrencyId,
- yield = action.yield,
- )
is TradeCryptoAction.SendToken -> handleNewSendToken(action = action)
is TradeCryptoAction.SendCoin -> handleNewSendCoin(action = action)
}
@@ -140,18 +134,6 @@ object TradeCryptoMiddleware {
)?.let { store.dispatchOpenUrl(it) }
}
- private fun openStaking(userWalletId: UserWalletId, cryptoCurrencyId: CryptoCurrency.ID, yield: Yield) {
- store.dispatchNavigationAction {
- push(
- AppRoute.Staking(
- userWalletId = userWalletId,
- cryptoCurrencyId = cryptoCurrencyId,
- yield = yield,
- ),
- )
- }
- }
-
private fun handleNewSendToken(action: TradeCryptoAction.SendToken) {
handleNewSend(
userWalletId = action.userWallet.walletId,
diff --git a/common/ui/src/main/java/com/tangem/common/ui/tokens/TokenActionsUtils.kt b/common/ui/src/main/java/com/tangem/common/ui/tokens/TokenActionsUtils.kt
new file mode 100644
index 0000000000..d33e9330f1
--- /dev/null
+++ b/common/ui/src/main/java/com/tangem/common/ui/tokens/TokenActionsUtils.kt
@@ -0,0 +1,69 @@
+package com.tangem.common.ui.tokens
+
+import com.tangem.common.ui.R
+import com.tangem.core.ui.extensions.TextReference
+import com.tangem.core.ui.extensions.resourceReference
+import com.tangem.core.ui.extensions.wrappedList
+import com.tangem.domain.tokens.model.ScenarioUnavailabilityReason
+
+fun ScenarioUnavailabilityReason.getUnavailabilityReasonText(): TextReference {
+ return when (val unavailabilityReason = this) {
+ is ScenarioUnavailabilityReason.StakingUnavailable -> {
+ resourceReference(
+ id = R.string.token_button_unavailability_reason_staking_unavailable,
+ formatArgs = wrappedList(unavailabilityReason.cryptoCurrencyName),
+ )
+ }
+ is ScenarioUnavailabilityReason.PendingTransaction -> {
+ when (unavailabilityReason.withdrawalScenario) {
+ ScenarioUnavailabilityReason.WithdrawalScenario.SEND -> resourceReference(
+ id = R.string.token_button_unavailability_reason_pending_transaction_send,
+ formatArgs = wrappedList(unavailabilityReason.networkName),
+ )
+ ScenarioUnavailabilityReason.WithdrawalScenario.SELL -> resourceReference(
+ id = R.string.token_button_unavailability_reason_pending_transaction_sell,
+ formatArgs = wrappedList(unavailabilityReason.networkName),
+ )
+ }
+ }
+ is ScenarioUnavailabilityReason.EmptyBalance -> {
+ when (unavailabilityReason.withdrawalScenario) {
+ ScenarioUnavailabilityReason.WithdrawalScenario.SEND -> resourceReference(
+ id = R.string.token_button_unavailability_reason_empty_balance_send,
+ )
+ ScenarioUnavailabilityReason.WithdrawalScenario.SELL -> resourceReference(
+ id = R.string.token_button_unavailability_reason_empty_balance_sell,
+ )
+ }
+ }
+ is ScenarioUnavailabilityReason.BuyUnavailable -> {
+ resourceReference(
+ id = R.string.token_button_unavailability_reason_buy_unavailable,
+ formatArgs = wrappedList(unavailabilityReason.cryptoCurrencyName),
+ )
+ }
+ is ScenarioUnavailabilityReason.NotExchangeable -> {
+ resourceReference(
+ id = R.string.token_button_unavailability_reason_not_exchangeable,
+ formatArgs = wrappedList(unavailabilityReason.cryptoCurrencyName),
+ )
+ }
+ is ScenarioUnavailabilityReason.NotSupportedBySellService -> {
+ resourceReference(
+ id = R.string.token_button_unavailability_reason_sell_unavailable,
+ formatArgs = wrappedList(unavailabilityReason.cryptoCurrencyName),
+ )
+ }
+ ScenarioUnavailabilityReason.Unreachable -> {
+ resourceReference(
+ id = R.string.token_button_unavailability_generic_description,
+ )
+ }
+ ScenarioUnavailabilityReason.UnassociatedAsset -> resourceReference(
+ id = R.string.warning_receive_blocked_hedera_token_association_required_message,
+ )
+ ScenarioUnavailabilityReason.None -> {
+ throw IllegalArgumentException("The unavailability reason must be other than None")
+ }
+ }
+}
\ No newline at end of file
diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfig.kt b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfig.kt
index 0bb0162ccc..d2eb1f9935 100644
--- a/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfig.kt
+++ b/core/ui/src/main/java/com/tangem/core/ui/components/bottomsheets/TangemBottomSheetConfig.kt
@@ -11,4 +11,9 @@ data class TangemBottomSheetConfig(
val isShow: Boolean,
val onDismissRequest: () -> Unit,
val content: TangemBottomSheetConfigContent,
-)
\ No newline at end of file
+) {
+
+ companion object {
+ val Empty = TangemBottomSheetConfig(false, {}, TangemBottomSheetConfigContent.Empty)
+ }
+}
\ No newline at end of file
diff --git a/core/ui/src/main/java/com/tangem/core/ui/components/token/TokenItem.kt b/core/ui/src/main/java/com/tangem/core/ui/components/token/TokenItem.kt
index 436f507958..0a519a13e1 100644
--- a/core/ui/src/main/java/com/tangem/core/ui/components/token/TokenItem.kt
+++ b/core/ui/src/main/java/com/tangem/core/ui/components/token/TokenItem.kt
@@ -2,6 +2,7 @@ package com.tangem.core.ui.components.token
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.combinedClickable
+import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
@@ -47,12 +48,18 @@ private enum class LayoutId {
* >Figma Component
*/
@Composable
-fun TokenItem(state: TokenItemState, isBalanceHidden: Boolean, modifier: Modifier = Modifier) {
+fun TokenItem(
+ state: TokenItemState,
+ isBalanceHidden: Boolean,
+ modifier: Modifier = Modifier,
+ itemPaddingValues: PaddingValues = PaddingValues(horizontal = TangemTheme.dimens.spacing12),
+) {
TokenItem(
state = state,
isBalanceHidden = isBalanceHidden,
modifier = modifier,
reorderableTokenListState = null,
+ itemPaddingValues = itemPaddingValues,
)
}
@@ -63,6 +70,7 @@ fun TokenItem(state: TokenItemState, isBalanceHidden: Boolean, modifier: Modifie
* @param isBalanceHidden flag that shows/hides balance
* @param reorderableTokenListState reorderable token list state
* @param modifier modifier
+ * @param itemPaddingValues padding values
*
* @see Figma Component
@@ -73,12 +81,15 @@ fun TokenItem(
isBalanceHidden: Boolean,
reorderableTokenListState: ReorderableLazyListState?,
modifier: Modifier = Modifier,
+ itemPaddingValues: PaddingValues = PaddingValues(horizontal = TangemTheme.dimens.spacing12),
) {
val betweenRowsMargin = TangemTheme.dimens.spacing2
CustomContainer(
state = state,
- modifier = modifier.tokenClickable(state = state),
+ modifier = modifier
+ .tokenClickable(state = state)
+ .padding(itemPaddingValues),
) {
CurrencyIcon(
state = state.iconState,
@@ -163,10 +174,7 @@ private fun CustomContainer(state: TokenItemState, modifier: Modifier = Modifier
Layout(content = content, modifier = modifier) { measurables, constraints ->
val layoutWidth = constraints.maxWidth
- val horizontalPadding = with(density) { dimens.size12.roundToPx() }
val verticalPadding = with(density) { dimens.size15.roundToPx() }
- val layoutWidthWithoutPaddings = layoutWidth - 2 * horizontalPadding
-
val titleMinWidth = (layoutWidth * TITLE_MIN_WIDTH_COEFFICIENT).toInt()
val priceChangeMinWidth = (layoutWidth * PRICE_MIN_WIDTH_COEFFICIENT).toInt()
@@ -202,35 +210,35 @@ private fun CustomContainer(state: TokenItemState, modifier: Modifier = Modifier
-> {
fiatAmount = measurables.measureFiatAmount(
state = state,
- maxWidth = layoutWidthWithoutPaddings - icon.width - titleMinWidth,
+ maxWidth = layoutWidth - icon.width - titleMinWidth,
defaultConstraints = constraints,
)
cryptoAmount = measurables.measureCryptoAmount(
state = state,
- maxWidth = layoutWidthWithoutPaddings - icon.width - priceChangeMinWidth,
+ maxWidth = layoutWidth - icon.width - priceChangeMinWidth,
defaultConstraints = constraints,
)
- firstRowRemainingFreeSpace = layoutWidthWithoutPaddings - icon.width - fiatAmount.width
- secondRowRemainingFreeSpace = layoutWidthWithoutPaddings - icon.width - cryptoAmount.width
+ firstRowRemainingFreeSpace = layoutWidth - icon.width - fiatAmount.width
+ secondRowRemainingFreeSpace = layoutWidth - icon.width - cryptoAmount.width
}
is TokenItemState.Draggable -> {
cryptoAmount = measurables.measureCryptoAmount(
state = state,
- maxWidth = layoutWidthWithoutPaddings - icon.width - nonFiatContent.width,
+ maxWidth = layoutWidth - icon.width - nonFiatContent.width,
defaultConstraints = constraints,
)
- firstRowRemainingFreeSpace = layoutWidthWithoutPaddings - icon.width - nonFiatContent.width
+ firstRowRemainingFreeSpace = layoutWidth - icon.width - nonFiatContent.width
}
is TokenItemState.NoAddress,
is TokenItemState.Unreachable,
-> {
- firstRowRemainingFreeSpace = layoutWidthWithoutPaddings - icon.width - nonFiatContent.width
+ firstRowRemainingFreeSpace = layoutWidth - icon.width - nonFiatContent.width
if (state.subtitleState != null) {
- secondRowRemainingFreeSpace = layoutWidthWithoutPaddings - icon.width - nonFiatContent.width
+ secondRowRemainingFreeSpace = layoutWidth - icon.width - nonFiatContent.width
}
}
}
@@ -262,10 +270,10 @@ private fun CustomContainer(state: TokenItemState, modifier: Modifier = Modifier
)
layout(width = constraints.maxWidth, height = layoutHeight) {
- icon.placeRelative(x = horizontalPadding, y = (layoutHeight - icon.height).div(other = 2))
+ icon.placeRelative(x = 0, y = (layoutHeight - icon.height).div(other = 2))
title.placeRelative(
- x = horizontalPadding + icon.width,
+ x = icon.width,
y = when (state) {
is TokenItemState.NoAddress,
is TokenItemState.Unreachable,
@@ -280,23 +288,23 @@ private fun CustomContainer(state: TokenItemState, modifier: Modifier = Modifier
},
)
- fiatAmount?.placeRelative(x = layoutWidth - fiatAmount.width - horizontalPadding, y = verticalPadding)
+ fiatAmount?.placeRelative(x = layoutWidth - fiatAmount.width, y = verticalPadding)
priceChange?.placeRelative(
- x = horizontalPadding + icon.width,
+ x = icon.width,
y = layoutHeight - priceChange.height - verticalPadding,
)
cryptoAmount?.placeRelative(
x = when (state) {
- is TokenItemState.Draggable -> horizontalPadding + icon.width
- else -> layoutWidth - cryptoAmount.width - horizontalPadding
+ is TokenItemState.Draggable -> icon.width
+ else -> layoutWidth - cryptoAmount.width
},
y = layoutHeight - cryptoAmount.height - verticalPadding,
)
nonFiatContent.placeRelative(
- x = layoutWidth - nonFiatContent.width - horizontalPadding,
+ x = layoutWidth - nonFiatContent.width,
y = (layoutHeight - nonFiatContent.height).div(other = 2),
)
}
diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/ScenarioUnavailabilityReason.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/ScenarioUnavailabilityReason.kt
similarity index 100%
rename from domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/ScenarioUnavailabilityReason.kt
rename to domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/ScenarioUnavailabilityReason.kt
diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt
index c83af879ba..99ec404379 100644
--- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt
+++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCryptoCurrencyActionsUseCase.kt
@@ -130,11 +130,24 @@ class GetCryptoCurrencyActionsUseCase(
// staking
if (stakingFeatureToggles.isStakingEnabled) {
if (isStakingAvailable(cryptoCurrency)) {
- activeList.add(TokenActionsState.ActionState.Stake(ScenarioUnavailabilityReason.None))
+ val yield = kotlin.runCatching {
+ stakingRepository.getYield(
+ cryptoCurrencyId = cryptoCurrency.id,
+ symbol = cryptoCurrency.symbol,
+ )
+ }.getOrNull()
+
+ activeList.add(
+ TokenActionsState.ActionState.Stake(
+ unavailabilityReason = ScenarioUnavailabilityReason.None,
+ yield = yield,
+ ),
+ )
} else {
disabledList.add(
TokenActionsState.ActionState.Stake(
unavailabilityReason = ScenarioUnavailabilityReason.StakingUnavailable(cryptoCurrency.name),
+ yield = null,
),
)
}
@@ -254,7 +267,7 @@ class GetCryptoCurrencyActionsUseCase(
actionsList.add(TokenActionsState.ActionState.Receive(scenario))
}
if (stakingFeatureToggles.isStakingEnabled) {
- actionsList.add(TokenActionsState.ActionState.Stake(ScenarioUnavailabilityReason.Unreachable))
+ actionsList.add(TokenActionsState.ActionState.Stake(ScenarioUnavailabilityReason.Unreachable, null))
}
actionsList.add(TokenActionsState.ActionState.HideToken(ScenarioUnavailabilityReason.None))
diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt
index 706493a6ea..b32c7a091f 100644
--- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt
+++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/legacy/TradeCryptoAction.kt
@@ -1,10 +1,8 @@
package com.tangem.domain.tokens.legacy
-import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.wallets.models.UserWallet
-import com.tangem.domain.wallets.models.UserWalletId
import org.rekotlin.Action
import java.math.BigDecimal
@@ -24,6 +22,7 @@ sealed class TradeCryptoAction : Action {
val appCurrencyCode: String,
) : TradeCryptoAction()
+ @Deprecated("Use AppRoute instead")
data class SendToken(
val userWallet: UserWallet,
val tokenCurrency: CryptoCurrency.Token,
@@ -33,6 +32,7 @@ sealed class TradeCryptoAction : Action {
val transactionInfo: TransactionInfo? = null,
) : TradeCryptoAction()
+ @Deprecated("Use AppRoute instead")
data class SendCoin(
val userWallet: UserWallet,
val coinStatus: CryptoCurrencyStatus,
@@ -40,12 +40,6 @@ sealed class TradeCryptoAction : Action {
val transactionInfo: TransactionInfo? = null,
) : TradeCryptoAction()
- data class Stake(
- val userWalletId: UserWalletId,
- val cryptoCurrencyId: CryptoCurrency.ID,
- val yield: Yield,
- ) : TradeCryptoAction()
-
data class TransactionInfo(
val transactionId: String,
val destinationAddress: String,
diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenActionsState.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenActionsState.kt
index a3dbea0959..c6db8e28e2 100644
--- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenActionsState.kt
+++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/model/TokenActionsState.kt
@@ -1,5 +1,6 @@
package com.tangem.domain.tokens.model
+import com.tangem.domain.staking.model.stakekit.Yield
import com.tangem.domain.wallets.models.UserWalletId
data class TokenActionsState(
@@ -20,7 +21,10 @@ data class TokenActionsState(
data class Receive(override val unavailabilityReason: ScenarioUnavailabilityReason) : ActionState()
- data class Stake(override val unavailabilityReason: ScenarioUnavailabilityReason) : ActionState()
+ data class Stake(
+ override val unavailabilityReason: ScenarioUnavailabilityReason,
+ val yield: Yield?,
+ ) : ActionState()
data class Swap(override val unavailabilityReason: ScenarioUnavailabilityReason) : ActionState()
diff --git a/features/markets/impl/build.gradle.kts b/features/markets/impl/build.gradle.kts
index 3fc641b0da..8cccec2563 100644
--- a/features/markets/impl/build.gradle.kts
+++ b/features/markets/impl/build.gradle.kts
@@ -29,6 +29,13 @@ dependencies {
implementation(projects.domain.wallets)
implementation(projects.domain.wallets.models)
+ // FIXME [REDACTED_TASK_KEY]
+ // Remove the "Buy" and "Sell" actions from the redux middleware.
+ // Instead, create some kind of interface for such cases.
+ /* Redux -_- */
+ implementation(projects.domain.legacy)
+ implementation(deps.reKotlin)
+
/* Compose */
implementation(deps.compose.coil)
implementation(deps.compose.foundation)
diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt
index e899cfeb23..83b17519eb 100644
--- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt
+++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt
@@ -346,9 +346,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
chartDataProducer.runTransaction {
updateLook {
- it.copy(
- type = getChartTypeByPercent(percent),
- )
+ it.copy(type = percent.percentChangeType().toChartType())
}
}
}
@@ -356,13 +354,12 @@ internal class MarketsTokenDetailsModel @Inject constructor(
private suspend fun updateQuotes(newQuotes: TokenQuotes) {
quotesStateUpdater.updateQuotes(newQuotes)
- val percent = newQuotes.getPercentByInterval(interval = state.value.selectedInterval)
+ val percent = newQuotes
+ .getPercentByInterval(interval = state.value.selectedInterval)
chartDataProducer.runTransaction {
updateLook {
- it.copy(
- type = getChartTypeByPercent(percent),
- )
+ it.copy(type = percent.percentChangeType().toChartType())
}
}
}
@@ -430,7 +427,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
chartDataProducer.runTransaction {
updateLook {
it.copy(
- type = getChartTypeByPercent(percent),
+ type = percent.percentChangeType().toChartType(),
)
}
}
@@ -477,7 +474,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
launch {
while (true) {
delay(timeMillis)
- // Update quotes only when content visible on the screen
+ // Update quotes only when content is visible on the screen
isVisibleOnScreen.first { it }
loadQuotes()
diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt
index c4cf1f6e3f..d2f2869872 100644
--- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt
+++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/formatter/Formatters.kt
@@ -87,15 +87,4 @@ internal fun PriceChangeType.toChartType(): MarketChartLook.Type {
PriceChangeType.DOWN -> MarketChartLook.Type.Falling
PriceChangeType.NEUTRAL -> MarketChartLook.Type.Neutral
}
-}
-
-@Suppress("MagicNumber")
-internal fun getChartTypeByPercent(percent: BigDecimal?): MarketChartLook.Type {
- val scaled = percent?.setScale(4, RoundingMode.HALF_UP)
- return when {
- scaled == null -> return MarketChartLook.Type.Neutral
- scaled > BigDecimal.ZERO -> MarketChartLook.Type.Growing
- scaled < BigDecimal.ZERO -> MarketChartLook.Type.Falling
- else -> MarketChartLook.Type.Neutral
- }
}
\ No newline at end of file
diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioData.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioData.kt
index 8ac05a4e90..ece4a0a217 100644
--- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioData.kt
+++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioData.kt
@@ -4,6 +4,7 @@ import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.core.lce.Lce
import com.tangem.domain.tokens.error.TokenListError
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
+import com.tangem.domain.tokens.model.TokenActionsState
import com.tangem.domain.tokens.model.TotalFiatBalance
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
@@ -11,7 +12,7 @@ import com.tangem.domain.wallets.models.UserWalletId
/**
* Portfolio data. Combined data from all flows that required to setup portfolio
*
- * @property walletsWithCurrencyStatuses wallets with crypto currency statuses
+ * @property walletsWithCurrencies wallets with crypto currency statuses
* @property appCurrency app currency
* @property isBalanceHidden flag that indicates if balance should be hidden
* @property walletsWithBalance wallets with total balance
@@ -19,8 +20,14 @@ import com.tangem.domain.wallets.models.UserWalletId
[REDACTED_AUTHOR]
*/
internal data class PortfolioData(
- val walletsWithCurrencyStatuses: Map>,
+ val walletsWithCurrencies: Map>,
val appCurrency: AppCurrency,
val isBalanceHidden: Boolean,
val walletsWithBalance: Map>,
-)
\ No newline at end of file
+) {
+ data class CryptoCurrencyData(
+ val userWallet: UserWallet,
+ val status: CryptoCurrencyStatus,
+ val actions: List,
+ )
+}
\ No newline at end of file
diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt
index e2e08f4b70..0685abffb7 100644
--- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt
+++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/portfolio/impl/loader/PortfolioDataLoader.kt
@@ -6,9 +6,9 @@ import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
import com.tangem.domain.core.lce.Lce
import com.tangem.domain.tokens.GetAllWalletsCryptoCurrencyStatusesUseCase
+import com.tangem.domain.tokens.GetCryptoCurrencyActionsUseCase
import com.tangem.domain.tokens.GetWalletTotalBalanceUseCase
import com.tangem.domain.tokens.error.TokenListError
-import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.domain.tokens.model.TotalFiatBalance
import com.tangem.domain.wallets.models.UserWallet
import com.tangem.domain.wallets.models.UserWalletId
@@ -32,18 +32,19 @@ internal class PortfolioDataLoader @Inject constructor(
private val getSelectedAppCurrencyUseCase: GetSelectedAppCurrencyUseCase,
private val getBalanceHidingSettingsUseCase: GetBalanceHidingSettingsUseCase,
private val getWalletTotalBalanceUseCase: GetWalletTotalBalanceUseCase,
+ private val getCryptoCurrencyActionsUseCase: GetCryptoCurrencyActionsUseCase,
) {
/** Load data by [currencyRawId] */
@OptIn(ExperimentalCoroutinesApi::class)
fun load(currencyRawId: String): Flow {
return combine(
- flow = getAllWalletsCryptoCurrencyStatusesFlow(currencyRawId = currencyRawId),
+ flow = getAllWalletsCryptoCurrenciesData(currencyRawId = currencyRawId),
flow2 = getSelectedAppCurrencyFlow(),
flow3 = getBalanceHidingSettingsFlow(),
- ) { walletsWithCurrencyStatuses, appCurrency, isBalanceHidden ->
+ ) { walletsWithCurrencies, appCurrency, isBalanceHidden ->
PortfolioData(
- walletsWithCurrencyStatuses = walletsWithCurrencyStatuses,
+ walletsWithCurrencies = walletsWithCurrencies,
appCurrency = appCurrency,
isBalanceHidden = isBalanceHidden,
walletsWithBalance = emptyMap(),
@@ -52,15 +53,16 @@ internal class PortfolioDataLoader @Inject constructor(
// setup balances for wallets from walletsWithCurrencyStatuses
.flatMapLatest { portfolioData ->
getWalletsWithTotalBalanceFlow(
- ids = portfolioData.walletsWithCurrencyStatuses.keys.map(UserWallet::walletId),
+ ids = portfolioData.walletsWithCurrencies.keys.map(UserWallet::walletId),
)
.map { portfolioData.copy(walletsWithBalance = it) }
}
}
- private fun getAllWalletsCryptoCurrencyStatusesFlow(
+ @OptIn(ExperimentalCoroutinesApi::class)
+ private fun getAllWalletsCryptoCurrenciesData(
currencyRawId: String,
- ): Flow