Updated on 2026-08-14
This commit is contained in:
parent
b3dc6938fd
commit
de838113af
2 changed files with 32 additions and 3 deletions
|
|
@ -215,7 +215,7 @@ internal class UpdateStakingNotificationTransformer(
|
|||
)
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@Suppress("LongMethod", "CyclomaticComplexMethod")
|
||||
private fun getRewardSubtitle(
|
||||
status: CryptoCurrencyStatus,
|
||||
stakingRewardAmount: BigDecimal?,
|
||||
|
|
@ -245,7 +245,7 @@ internal class UpdateStakingNotificationTransformer(
|
|||
RewardBlockType.CardanoNoRewards -> resourceReference(R.string.staking_cardano_details_rewards_info_text)
|
||||
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable,
|
||||
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable,
|
||||
-> return null
|
||||
-> rewardRateReference() ?: return null
|
||||
RewardBlockType.EthereumEarnedRewards -> {
|
||||
val cryptoRewardAmount = (stakingBalance as? StakingBalance.Data.P2PEthPool)?.totalRewards
|
||||
return EarnBlockUM.SubtitleUM.AccentedText(
|
||||
|
|
@ -286,7 +286,8 @@ internal class UpdateStakingNotificationTransformer(
|
|||
}
|
||||
|
||||
val isAccent = rewardBlockType == RewardBlockType.Rewards ||
|
||||
rewardBlockType == RewardBlockType.RewardsRequirementsError
|
||||
rewardBlockType == RewardBlockType.RewardsRequirementsError ||
|
||||
rewardBlockType is RewardBlockType.RewardUnavailable
|
||||
|
||||
return EarnBlockUM.SubtitleUM.Text(
|
||||
text = text,
|
||||
|
|
|
|||
|
|
@ -215,6 +215,34 @@ class UpdateStakingNotificationTransformerTest {
|
|||
assertThat((combined.refs.data.last() as TextReference.Str).value).isNotEqualTo(THREE_STARS)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN auto-compound rewards AND rate known WHEN transform THEN subtitle shows rate only`() {
|
||||
// Arrange
|
||||
val status = buildStatus(
|
||||
networkRawId = "solana",
|
||||
symbol = "SOL",
|
||||
isCoin = true,
|
||||
stakingBalance = stakeKitBalance(staked = BigDecimal("100"), rewards = BigDecimal("5")),
|
||||
)
|
||||
val transformer = createTransformer(
|
||||
availability = availableOption(BigDecimal("4.2")),
|
||||
entryInfo = StakingEntryInfo(tokenSymbol = "SOL"),
|
||||
status = status,
|
||||
isBalanceHidden = false,
|
||||
)
|
||||
|
||||
// Act
|
||||
val result = transformer.transform(initialState())
|
||||
|
||||
// Assert
|
||||
val content = result.earnBlockState as EarnBlockUM.Content
|
||||
val subtitle = content.subtitleUM as EarnBlockUM.SubtitleUM.Text
|
||||
val rateLabel = subtitle.text as TextReference.Combined
|
||||
val apyLabel = rateLabel.refs.data.filterIsInstance<TextReference.Res>().first()
|
||||
assertThat(apyLabel.id).isEqualTo(CoreResR.string.staking_details_apy)
|
||||
assertThat(subtitle.tone).isEqualTo(EarnBlockUM.SubtitleUM.Tone.Accent)
|
||||
}
|
||||
|
||||
private fun rewardFormatArg(text: TextReference): Any? = when (text) {
|
||||
is TextReference.Res -> text.formatArgs.data.firstOrNull()
|
||||
is TextReference.Combined -> (text.refs.data.last() as? TextReference.Str)?.value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue