refactor(send): move route fee estimation out of the SwiftUI view layer - #1061
refactor(send): move route fee estimation out of the SwiftUI view layer#1061QuantumExplorer wants to merge 1 commit into
Conversation
SendConfirmSheet computed its Network fee row inside the View — calling PlatformWalletManager.estimateShieldedFee (FFI) per route and deriving the Core → Shielded lock total with CoreToShieldedAmountPolicy — which the SwiftUI-first guardrails ban from View structs. Flagged by CodeRabbit on PR #1057, where it was out of scope (the pattern predates that PR). SendViewModel now owns both computations (confirmNetworkFeeCredits, confirmTotalDuffs), reusing its existing shieldedFeeKind(for:) route mapping and platformTransferFeeReserveCredits constant instead of the sheet's duplicated switch and bare 100_000_000 literal. The sheet receives the two values as stored properties and only formats them. Estimates and displayed strings are unchanged route by route. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 21 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🕓 Ready for review — 8 ahead in queue (commit 2722b29) |
Issue being fixed or feature implemented
CodeRabbit flagged on #1057 that
SendConfirmSheet.networkFeeCreditscallsPlatformWalletManager.estimateShieldedFee(FFI) and performs per-route fee calculations inside a SwiftUIView— a pattern the repo's SwiftUI-first guardrails ban fromViewstructs. The pattern predates #1057 (that PR only added the.platformToShieldedcase following the existing convention), so the refactor was declined there as out of scope and split into this PR.What was done?
SendViewModelnow owns both confirm-sheet computations:confirmNetworkFeeCredits— the per-route fee switch. The pool-spending routes reuse the existingshieldedFeeKind(for:)mapping instead of duplicatedestimateShieldedFeecalls,.platformToPlatformreuses the existingplatformTransferFeeReserveCreditsconstant instead of a bare100_000_000literal,.platformToCorereadswithdrawalPreflight?.estimatedFeedirectly, and.platformToShieldedkeeps feat(wallet): pay external shielded addresses from the Platform balance #1057's flat 2-action estimate.confirmTotalDuffs— the Total row's Core → Shielded lock-value derivation (CoreToShieldedAmountPolicyis FFI-backed too, so leaving it would have kept an FFI call in the view).SendConfirmSheetreceives the two values as storedletproperties and only formats them.SendScreen.swiftis now free ofPlatformWalletManager/CoreToShieldedAmountPolicyreferences.—fallbacks. Update timing is unchanged — the sheet's parameters were already re-evaluated through the observed view model (the same mechanism as the existingwithdrawalFeeCreditsparameter).How Has This Been Tested?
Clean
dashpayscheme simulator build (-sdk iphonesimulator, arm64) on top of currentdevelop(includes #1057). Pure code motion with no rendering change, verified by diff review of each route's estimator against the previous switch. The unit-test target is broken pre-existing on this branch lineage, so no new tests were added.Breaking Changes
None.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code