Repository navigation
fix(wallet): live balance refresh and withhold the Dash DEX shortcut - #806
Conversation
The published balance was refreshed only by refreshBalanceBridge() on SPV start and on sync-progress ticks. Once the chain is fully synced the client sits in steady state with no progress ticks, so an incoming payment (e.g. the testnet faucet) updated the transaction list — which reloads on NSManagedObjectContextDidSave — but not the balance, until the next foreground/restart re-ran the bridge. Subscribe the balance bridge to the same NSManagedObjectContextDidSave signal (Rust's persister writes PersistentTransaction rows on a detected/instant-locked tx), throttled 1s to coalesce the sync-time save storm. Reuses the existing refreshBalanceBridge(); cancelled in performStop.
Dash DEX has two entry points; the release merge gated only the Buy & Sell portal card (showsSwapKit = false) and left the .dashDEX shortcut reachable, which routes to the SwapKit swap flow built on frozen DashSync. - Remove .dashDEX from customizableActions so it can't be added to the bar. - Degrade an already-saved .dashDEX shortcut to .spend (same pattern as getTestDash/switchWallet); the saved raw value is untouched, so it returns if DEX is restored. The enum case + icon/title are kept for persisted-config raw-value stability.
📝 WalkthroughWalkthroughSPV balance refreshes are triggered by managed-object-context save notifications with throttling and stop-time cleanup. Home shortcut configuration excludes Dash DEX and converts saved Dash DEX shortcuts to spend during restoration. ChangesWallet and shortcut behavior
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@DashWallet/Sources/UI/Home/Views/HomeViewModel.swift`:
- Around line 884-889: Update the restored shortcut handling around the
.dashDEX-to-.spend mapping so it checks whether a .spend shortcut already exists
before applying the fallback. Preserve the saved configuration when the fallback
would create a duplicate, and ensure the final restored list remains unique
without changing the saved configuration.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d6a91cdd-b032-4376-9c79-7b0b4dac12dd
📒 Files selected for processing (3)
DashWallet/Sources/Infrastructure/SwiftDashSDK/SwiftDashSDKSPVCoordinator.swiftDashWallet/Sources/UI/Home/Views/HomeViewModel.swiftDashWallet/Sources/UI/Home/Views/Shortcuts/Models/ShortcutAction.swift
| // Dash DEX is withheld for the migration release (frozen-DashSync | ||
| // swap path); a saved DEX shortcut degrades to Spend. The saved | ||
| // config is untouched, so it returns if DEX is restored. | ||
| if type == .dashDEX { | ||
| type = .spend | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Avoid duplicate Spend shortcuts during DEX restoration.
If a saved configuration contains both .spend and .dashDEX, this mapping produces two .spend actions. Since the item count remains valid, the duplicate list is accepted and one distinct shortcut is lost. Use a uniqueness-aware fallback before accepting the restored configuration.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@DashWallet/Sources/UI/Home/Views/HomeViewModel.swift` around lines 884 - 889,
Update the restored shortcut handling around the .dashDEX-to-.spend mapping so
it checks whether a .spend shortcut already exists before applying the fallback.
Preserve the saved configuration when the fallback would create a duplicate, and
ensure the final restored list remains unique without changing the saved
configuration.
Issue being fixed or feature implemented
Two related post-merge fixes on
swift-sdk-integration:What was done?
Balance refresh (
d3a27f0) — Device logs show the SDK emitsTransactionDetected/TransactionInstantLockedwallet events with the new balance, and Rust's persister writesPersistentTransactionrows →NSManagedObjectContextDidSave. The home tx list already reloads on that signal, but the balance was refreshed only byrefreshBalanceBridge()on SPV start and on sync-progress ticks — which stop once the chain is fully synced (steady state). So an incoming payment while synced never updated the balance. Fix: subscribe the balance bridge to the sameNSManagedObjectContextDidSavesignal (throttled 1s to coalesce the sync-time save storm), reusing the existingrefreshBalanceBridge(); cancelled inperformStop.Dash DEX shortcut (
aacb286) — The release merge gated only the Buy & Sell portal card (showsSwapKit = false) and left the.dashDEXshortcut reachable. Removed.dashDEXfromcustomizableActions(can't be added to the bar) and degrade an already-saved.dashDEXshortcut to.spend(same pattern asgetTestDash/switchWallet). The enum case + icon/title are kept so persisted-config raw values stay stable and DEX returns if restored.How Has This Been Tested?
dashwallet-dashpayscheme builds clean on the iOS Simulator (ARCHS=arm64).NSManagedObjectContextDidSavesignal it hooks demonstrably fires live (the tx list updated to 3 txs in the same logs where the balance stayed stale).Breaking Changes
None. Dash DEX remains withheld (now consistently); no API or data changes.
Checklist:
For repository code-owners and collaborators only
Summary by CodeRabbit
Bug Fixes
Changes