diff --git a/core/res/src/main/res/values/strings.xml b/core/res/src/main/res/values/strings.xml
index 5fc80e50c7..03805641a9 100644
--- a/core/res/src/main/res/values/strings.xml
+++ b/core/res/src/main/res/values/strings.xml
@@ -688,6 +688,7 @@
Your funds will be available for use after the 21-day unbonding period. Reward will be withdrawn along with your unstaking funds.
Your funds will be available for use after the %s unbonding period.
You can now withdraw your funds, it will be available to use immediately
+ Staking in the Tron network with a new validator will automatically transfer all previously staked funds to this validator
Preparing
Ready to withdraw
Rebond
diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/StakingNotification.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/StakingNotification.kt
index 3f8be15c42..65968aeafa 100644
--- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/StakingNotification.kt
+++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/StakingNotification.kt
@@ -90,5 +90,10 @@ internal object StakingNotification {
title = title,
subtitle = text,
)
+
+ data object TronRevote : StakingNotification.Info(
+ title = resourceReference(R.string.staking_revote),
+ subtitle = resourceReference(R.string.staking_notifications_revote_tron_text),
+ )
}
}
\ No newline at end of file
diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/AddStakingNotificationsTransformer.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/AddStakingNotificationsTransformer.kt
index 6f68eb4cc8..7132cb9280 100644
--- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/AddStakingNotificationsTransformer.kt
+++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/AddStakingNotificationsTransformer.kt
@@ -15,7 +15,9 @@ import com.tangem.core.ui.extensions.pluralReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.domain.appcurrency.model.AppCurrency
+import com.tangem.domain.staking.model.stakekit.BalanceType
import com.tangem.domain.staking.model.stakekit.Yield
+import com.tangem.domain.staking.model.stakekit.YieldBalance
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
import com.tangem.domain.staking.model.stakekit.action.StakingActionType
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
@@ -30,6 +32,7 @@ import com.tangem.features.staking.impl.presentation.state.StakingUiState
import com.tangem.features.staking.impl.presentation.state.utils.checkAndCalculateSubtractedAmount
import com.tangem.features.staking.impl.presentation.state.utils.checkFeeCoverage
import com.tangem.lib.crypto.BlockchainUtils
+import com.tangem.lib.crypto.BlockchainUtils.isTron
import com.tangem.utils.Provider
import com.tangem.utils.extensions.orZero
import com.tangem.utils.transformer.Transformer
@@ -203,86 +206,73 @@ internal class AddStakingNotificationsTransformer(
private fun MutableList.addInfoNotifications(prevState: StakingUiState) {
when (prevState.actionType) {
- StakingActionCommonType.EXIT -> {
- add(
- StakingNotification.Info.Unstake(
- cooldownPeriodDays = yield.metadata.cooldownPeriod.days,
- ),
- )
- }
- StakingActionCommonType.ENTER -> {
- add(
- StakingNotification.Info.EarnRewards(
- subtitleText = resourceReference(
- id = getEarnRewardsPeriod(yield.metadata.rewardSchedule),
- formatArgs = wrappedList(yield.token.name),
- ),
- ),
- )
- }
- else -> {
- val confirmationState = prevState.confirmationState as? StakingStates.ConfirmationState.Data
- val pendingActionType = confirmationState?.pendingAction?.type
- val (titleReference, textReference) = when (pendingActionType) {
- StakingActionType.CLAIM_REWARDS -> {
- resourceReference(R.string.common_claim) to
- resourceReference(R.string.staking_notification_claim_rewards_text)
- }
- StakingActionType.RESTAKE_REWARDS -> {
- resourceReference(R.string.staking_restake) to
- resourceReference(R.string.staking_notification_restake_rewards_text)
- }
- StakingActionType.WITHDRAW -> {
- resourceReference(R.string.staking_withdraw) to
- resourceReference(R.string.staking_notification_withdraw_text)
- }
- StakingActionType.UNLOCK_LOCKED -> {
- val cooldownPeriodDays = yield.metadata.cooldownPeriod.days
- resourceReference(R.string.staking_unlocked_locked) to resourceReference(
- R.string.staking_notification_unlock_text,
- wrappedList(
- pluralReference(
- id = R.plurals.common_days,
- count = cooldownPeriodDays,
- formatArgs = wrappedList(cooldownPeriodDays),
- ),
- ),
- )
- }
- else -> null to null
- }
-
- if (titleReference != null && textReference != null) {
- add(
- StakingNotification.Info.PendingAction(
- title = titleReference,
- text = textReference,
- ),
- )
- }
- }
+ StakingActionCommonType.EXIT -> addExitInfoNotifications()
+ StakingActionCommonType.ENTER -> addEnterInfoNotifications()
+ else -> addPendingInfoNotifications(prevState)
}
}
- private fun getEarnRewardsPeriod(rewardSchedule: Yield.Metadata.RewardSchedule): Int {
- return when (rewardSchedule) {
- Yield.Metadata.RewardSchedule.BLOCK,
- Yield.Metadata.RewardSchedule.DAY,
- Yield.Metadata.RewardSchedule.ERA,
- Yield.Metadata.RewardSchedule.EPOCH,
- -> R.string.staking_notification_earn_rewards_text_period_day
+ private fun MutableList.addExitInfoNotifications() {
+ add(
+ StakingNotification.Info.Unstake(
+ cooldownPeriodDays = yield.metadata.cooldownPeriod.days,
+ ),
+ )
+ }
- Yield.Metadata.RewardSchedule.HOUR,
- -> R.string.staking_notification_earn_rewards_text_period_hour
+ private fun MutableList.addEnterInfoNotifications() {
+ val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
+ val isTron = isTron(cryptoCurrencyStatus.currency.network.id.value)
+ val hasStakedBalance = (cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data)?.balance
+ ?.items?.any {
+ it.type == BalanceType.PREPARING ||
+ it.type == BalanceType.STAKED ||
+ it.type == BalanceType.LOCKED
+ } == true
+ if (hasStakedBalance && isTron) {
+ add(StakingNotification.Info.TronRevote)
+ }
+ }
- Yield.Metadata.RewardSchedule.WEEK,
- -> R.string.staking_notification_earn_rewards_text_period_week
+ private fun MutableList.addPendingInfoNotifications(prevState: StakingUiState) {
+ val confirmationState = prevState.confirmationState as? StakingStates.ConfirmationState.Data
+ val pendingActionType = confirmationState?.pendingAction?.type
+ val (titleReference, textReference) = when (pendingActionType) {
+ StakingActionType.CLAIM_REWARDS -> {
+ resourceReference(R.string.common_claim) to
+ resourceReference(R.string.staking_notification_claim_rewards_text)
+ }
+ StakingActionType.RESTAKE_REWARDS -> {
+ resourceReference(R.string.staking_restake) to
+ resourceReference(R.string.staking_notification_restake_rewards_text)
+ }
+ StakingActionType.WITHDRAW -> {
+ resourceReference(R.string.staking_withdraw) to
+ resourceReference(R.string.staking_notification_withdraw_text)
+ }
+ StakingActionType.UNLOCK_LOCKED -> {
+ val cooldownPeriodDays = yield.metadata.cooldownPeriod.days
+ resourceReference(R.string.staking_unlocked_locked) to resourceReference(
+ R.string.staking_notification_unlock_text,
+ wrappedList(
+ pluralReference(
+ id = R.plurals.common_days,
+ count = cooldownPeriodDays,
+ formatArgs = wrappedList(cooldownPeriodDays),
+ ),
+ ),
+ )
+ }
+ else -> null to null
+ }
- Yield.Metadata.RewardSchedule.MONTH,
- -> R.string.staking_notification_earn_rewards_text_period_month
-
- else
- -> R.string.staking_notification_earn_rewards_text_period_day
+ if (titleReference != null && textReference != null) {
+ add(
+ StakingNotification.Info.PendingAction(
+ title = titleReference,
+ text = textReference,
+ ),
+ )
}
}
}
\ No newline at end of file
diff --git a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/utils/RewardScheduleUtils.kt b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/utils/RewardScheduleUtils.kt
index 8bb6550f79..1219166e7b 100644
--- a/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/utils/RewardScheduleUtils.kt
+++ b/features/tokendetails/impl/src/main/kotlin/com/tangem/feature/tokendetails/presentation/tokendetails/state/utils/RewardScheduleUtils.kt
@@ -9,18 +9,18 @@ internal fun Yield.Metadata.RewardSchedule.getStringResourceId(): Int {
Yield.Metadata.RewardSchedule.DAY,
Yield.Metadata.RewardSchedule.ERA,
Yield.Metadata.RewardSchedule.EPOCH,
- -> R.string.staking_notification_earn_rewards_text_period_day
+ -> R.string.staking_notification_earn_rewards_text_daily
Yield.Metadata.RewardSchedule.HOUR,
- -> R.string.staking_notification_earn_rewards_text_period_hour
+ -> R.string.staking_notification_earn_rewards_text_hourly
Yield.Metadata.RewardSchedule.WEEK,
- -> R.string.staking_notification_earn_rewards_text_period_week
+ -> R.string.staking_notification_earn_rewards_text_weekly
Yield.Metadata.RewardSchedule.MONTH,
- -> R.string.staking_notification_earn_rewards_text_period_month
+ -> R.string.staking_notification_earn_rewards_text_monthly
else
- -> R.string.staking_notification_earn_rewards_text_period_day
+ -> R.string.staking_notification_earn_rewards_text_daily
}
}
\ No newline at end of file