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(
|
private fun getRewardSubtitle(
|
||||||
status: CryptoCurrencyStatus,
|
status: CryptoCurrencyStatus,
|
||||||
stakingRewardAmount: BigDecimal?,
|
stakingRewardAmount: BigDecimal?,
|
||||||
|
|
@ -245,7 +245,7 @@ internal class UpdateStakingNotificationTransformer(
|
||||||
RewardBlockType.CardanoNoRewards -> resourceReference(R.string.staking_cardano_details_rewards_info_text)
|
RewardBlockType.CardanoNoRewards -> resourceReference(R.string.staking_cardano_details_rewards_info_text)
|
||||||
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable,
|
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable,
|
||||||
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable,
|
RewardBlockType.RewardUnavailable.SolanaRewardUnavailable,
|
||||||
-> return null
|
-> rewardRateReference() ?: return null
|
||||||
RewardBlockType.EthereumEarnedRewards -> {
|
RewardBlockType.EthereumEarnedRewards -> {
|
||||||
val cryptoRewardAmount = (stakingBalance as? StakingBalance.Data.P2PEthPool)?.totalRewards
|
val cryptoRewardAmount = (stakingBalance as? StakingBalance.Data.P2PEthPool)?.totalRewards
|
||||||
return EarnBlockUM.SubtitleUM.AccentedText(
|
return EarnBlockUM.SubtitleUM.AccentedText(
|
||||||
|
|
@ -286,7 +286,8 @@ internal class UpdateStakingNotificationTransformer(
|
||||||
}
|
}
|
||||||
|
|
||||||
val isAccent = rewardBlockType == RewardBlockType.Rewards ||
|
val isAccent = rewardBlockType == RewardBlockType.Rewards ||
|
||||||
rewardBlockType == RewardBlockType.RewardsRequirementsError
|
rewardBlockType == RewardBlockType.RewardsRequirementsError ||
|
||||||
|
rewardBlockType is RewardBlockType.RewardUnavailable
|
||||||
|
|
||||||
return EarnBlockUM.SubtitleUM.Text(
|
return EarnBlockUM.SubtitleUM.Text(
|
||||||
text = text,
|
text = text,
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,34 @@ class UpdateStakingNotificationTransformerTest {
|
||||||
assertThat((combined.refs.data.last() as TextReference.Str).value).isNotEqualTo(THREE_STARS)
|
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) {
|
private fun rewardFormatArg(text: TextReference): Any? = when (text) {
|
||||||
is TextReference.Res -> text.formatArgs.data.firstOrNull()
|
is TextReference.Res -> text.formatArgs.data.firstOrNull()
|
||||||
is TextReference.Combined -> (text.refs.data.last() as? TextReference.Str)?.value
|
is TextReference.Combined -> (text.refs.data.last() as? TextReference.Str)?.value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue