Skip to content

Commit 71740e1

Browse files
DRadmirclaude
andcommitted
Fix reserved fee info text display for zero amounts in staking
Previously, the reserved fee info text would display even when the input amount was zero. This change adds a check to ensure the info text only appears when the user has entered a non-zero amount that would trigger the reserved fee warning. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent f4c345a commit 71740e1

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Features/Transfer/Sources/ViewModels/AmountSceneViewModel.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ public final class AmountSceneViewModel {
102102
return nil
103103
case .stake, .freeze:
104104
guard reservedForFee > .zero else { return nil }
105-
guard let inputValue = try? formatter.inputNumber(from: amountInputModel.text, decimals: asset.decimals.asInt) else { return nil }
106-
guard inputValue >= availableBalanceForStaking, inputValue <= availableValue else { return nil }
105+
guard let inputValue = try? formatter.inputNumber(from: amountInputModel.text, decimals: asset.decimals.asInt),
106+
!inputValue.isZero, inputValue >= availableBalanceForStaking, inputValue <= availableValue
107+
else { return nil }
107108
return Localized.Transfer.reservedFees(formatter.string(reservedForFee, asset: asset))
108109
}
109110
}

Features/Transfer/Tests/ViewModels/AmountSceneViewModelTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct AmountSceneViewModelTests {
4040

4141
#expect(model.infoText != nil)
4242
#expect(model.amountInputModel.text == "1.99975")
43+
44+
model.amountInputModel.text = .zero
45+
#expect(model.infoText == nil)
4346
}
4447

4548
@Test

0 commit comments

Comments
 (0)