Repository navigation
feat(dashpay): make username voting real - #923
Conversation
|
Warning Review limit reached
Next review available in: 3 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (11)
📝 WalkthroughWalkthroughThe PR replaces legacy username-request voting with Platform contest services, wallet-derived masternode voting, weighted vote casting, and SwiftUI contest screens. It removes obsolete persistence, UIKit voting screens, resources, and project references. ChangesPlatform voting migration
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Menu → Voting was a self-contained mock: it made zero SDK and zero network calls, validated masternode voting keys against three hardcoded strings (`VotingViewModel.validKeys`), fabricated the "masternode IP address" it showed the user (`"182.151.12.\(count)"`), and recorded "votes" as integer arithmetic on a local SQLite row. The only writer to `username_requests` was `addMockRequest()`, wired to a tap gesture on the screen's title label and shipped in release — the production writer was removed in 97398f7, so on a real install the list was permanently empty. Section headers dated contests at `createdAt + 14 days`, which is wrong by roughly two weeks on testnet, where contests run 90 minutes. Everything needed to do this properly already existed and was unused. Now: - **Browse real contests.** `ContestedNamesService` lists every open DPNS contest from Platform with its contenders, vote tallies, and the authoritative deadline. No estimated dates: an unknown end time renders as "Deadline unknown" rather than a guess. - **Vote with the wallet's own nodes.** `MasternodeVoterRegistry` joins the on-chain masternode aggregation (`PlatformWalletManager.masternodes(for:)`) against the wallet's derived `ProviderVotingKeys` pool, so a node is offered only when this wallet actually holds the key Platform checks the signature against. No key is ever pasted or stored — `EnterVotingKeyViewController` is gone. - **Real broadcast.** `MasternodeVoteCaster` pre-flights that the poll is open, gates on `AuthenticationGate` (reused, not copied) before deriving key material, then calls `SDK.castContestedResourceVote` per node. Nodes are cast serially because the SDK fetches an identity nonce per voter identity and concurrent votes from one node would race. - **Honest reporting.** One node failing never abandons the rest; the result sheet says "3 of 4 masternodes voted" and shows Platform's own error for each failure ("already voted", "too many vote changes") verbatim. - **Honest capability.** Evonodes are shown as 4 votes and masternodes as 1, matching drive-abci's server-side weighting. A wallet with no votable node browses fine and says so — the vote controls are disabled, not faked. Search normalizes homographs before matching, since Platform stores "alice" as "a11ce" and a raw substring match finds nothing. Rebuilt in SwiftUI + ViewModel per CLAUDE.md; the storyboard/UIKit stack is deleted, including its app-wide `extension UITableView { override var intrinsicContentSize / contentSize }`, which affected every table view in the dashpay target. Also removed as unreachable dead code: `username_requests` and its DAO, the `RequestDetailsViewController` screen and its only trigger (reached solely via a `JoinDashPayState.voting` branch keyed on `UsernamePrefs.requestedUsernameId`, which nothing in the repo assigns), and `VotingConstants.maxVotes`, whose comment described it as a vote cap when Platform's 5 is a limit on vote *changes* per masternode per contest. `MasternodeKeyUsage.indexByAddress(family:targets:)` is promoted out of `MasternodesScreen`'s private copy so the ownership labels and the voting registry share one address→key-index join. Requires dashpay/platform "feat(swift-sdk): typed DPNS contested-name browsing for voters". Co-Authored-By: Claude Opus 5 <[email protected]>
2908795 to
420ab7a
Compare
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (1)
DashWallet.xcodeproj/project.pbxproj (1)
6027-6028: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsolidate the duplicate "SwiftDashSDK" groups.
This change adds two new groups both named "SwiftDashSDK" (
64CE06816C51B58845E767AAand59B3BC2E57C568600BDD78F5) as children of theInfrastructuregroup. An existing "SwiftDashSDK" group (7E31813A79237F4E037063AA) already exists as a sibling in the sameInfrastructuregroup and holds the other SwiftDashSDK sources. Each new group has its own "Voting" subgroup: one holdsMasternodeVoterRegistry.swiftandContestedNamesService.swift, the other holdsMasternodeVoteCaster.swift.This creates three sibling groups with the identical name "SwiftDashSDK" in the Xcode navigator, and it splits three closely related voting files across two separate subgroups. Move all three files into a single "Voting" subgroup inside the existing
7E31813A79237F4E037063AA"SwiftDashSDK" group, and remove the two new duplicate groups.♻️ Proposed group consolidation
- 64CE06816C51B58845E767AA /* SwiftDashSDK */ = { - isa = PBXGroup; - children = ( - 2A85F872C9D04B3BF9C2FFF3 /* Voting */, - ); - path = SwiftDashSDK; - sourceTree = "<group>"; - }; - 2A85F872C9D04B3BF9C2FFF3 /* Voting */ = { - isa = PBXGroup; - children = ( - 15D89828EC913714251D0B58 /* MasternodeVoterRegistry.swift */, - FC1426BD13E794C788646055 /* ContestedNamesService.swift */, - ); - path = Voting; - sourceTree = "<group>"; - }; - 59B3BC2E57C568600BDD78F5 /* SwiftDashSDK */ = { - isa = PBXGroup; - children = ( - F1884BF21637694C37C972D4 /* Voting */, - ); - path = SwiftDashSDK; - sourceTree = "<group>"; - }; - F1884BF21637694C37C972D4 /* Voting */ = { - isa = PBXGroup; - children = ( - 23AEFB2398EDA01C69E5A8F1 /* MasternodeVoteCaster.swift */, - ); - path = Voting; - sourceTree = "<group>"; - };Then add a single "Voting" subgroup (containing all three files) as a child of the existing
7E31813A79237F4E037063AA /* SwiftDashSDK */group, and remove59B3BC2E57C568600BDD78F5and64CE06816C51B58845E767AAfrom theInfrastructuregroup's children list.Also applies to: 8552-8584
🤖 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.xcodeproj/project.pbxproj` around lines 6027 - 6028, Consolidate the duplicate SwiftDashSDK groups in the Xcode project: move MasternodeVoterRegistry.swift, ContestedNamesService.swift, and MasternodeVoteCaster.swift into one Voting subgroup under the existing 7E31813A79237F4E037063AA SwiftDashSDK group, then remove the 59B3BC2E57C568600BDD78F5 and 64CE06816C51B58845E767AA groups and their Infrastructure child references.
🤖 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.xcodeproj/project.pbxproj`:
- Around line 1899-1904: Update the dashwallet target’s Xcode project
configuration to include all six voting files—MainMenuViewController.swift,
UsernameVotingScreen.swift, VotingViewModel, and the three voting services—in
both PBXBuildFile declarations and the target’s Sources build phase. Ensure each
file is compiled by dashwallet without changing unrelated target settings.
In `@DashWallet/en.lproj/Localizable.strings`:
- Around line 4724-4772: Convert the Localizable.strings file from UTF-8 to
UTF-16LE while preserving all existing localization keys and values. Use
BartyCrouch or Xcode-aware localization tooling to perform the update, then
verify the saved file retains UTF-16LE encoding.
In `@DashWallet/Sources/UI/DashPay/Voting/CastVoteSheet.swift`:
- Line 32: Format the dismiss environment property in CastVoteSheet so the
`@Environment`(\.dismiss) wrapper and its declaration each occupy separate lines,
satisfying the SwiftLint attributes rule while preserving the existing behavior.
In `@DashWallet/Sources/UI/DashPay/Voting/VotingViewModel.swift`:
- Around line 155-168: Update refreshContest(normalizedLabel:) so a resolved
state removes the matching contest from contests instead of updating it; also
remove the contest when voteState returns nil for an item previously in the
active list. Ensure the detail screen observes that removal and dismisses or
disables voting, preserving the active-contest-only contract.
In `@DashWallet/Sources/UI/Menu/Main/MainMenuViewController.swift`:
- Around line 490-493: Update showVoting() to push a dedicated thin
hosting-controller wrapper for UsernameVotingScreen instead of a bare
UIHostingController. Make the wrapper conform to the navigation display protocol
required by BaseNavigationController.willShow, while preserving the existing
bottom-bar and push behavior.
---
Nitpick comments:
In `@DashWallet.xcodeproj/project.pbxproj`:
- Around line 6027-6028: Consolidate the duplicate SwiftDashSDK groups in the
Xcode project: move MasternodeVoterRegistry.swift, ContestedNamesService.swift,
and MasternodeVoteCaster.swift into one Voting subgroup under the existing
7E31813A79237F4E037063AA SwiftDashSDK group, then remove the
59B3BC2E57C568600BDD78F5 and 64CE06816C51B58845E767AA groups and their
Infrastructure child references.
🪄 Autofix
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 Plus
Run ID: b8d49a25-c0a4-4153-91db-ebb9ed018b8a
📒 Files selected for processing (38)
DashWallet.xcodeproj/project.pbxprojDashWallet/Sources/Application/App.swiftDashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/ContestedNamesService.swiftDashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swiftDashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoterRegistry.swiftDashWallet/Sources/Models/Voting/DAO/UsernameRequestsDAO.swiftDashWallet/Sources/Models/Voting/MasternodeKey.swiftDashWallet/Sources/Models/Voting/UsernameRequest.swiftDashWallet/Sources/Models/Voting/VotingConstants.swiftDashWallet/Sources/Models/Voting/VotingFiltersModel.swiftDashWallet/Sources/Models/Voting/VotingPrefs.swiftDashWallet/Sources/UI/DashPay/Setup/CreateUsername/CreateUsernameViewModel.swiftDashWallet/Sources/UI/DashPay/Setup/CreateUsername/JoinDashPayViewModel.swiftDashWallet/Sources/UI/DashPay/Usernames/IconAttributedText.swiftDashWallet/Sources/UI/DashPay/Usernames/RequestDetailsViewController.swiftDashWallet/Sources/UI/DashPay/Usernames/UsernameRequests.storyboardDashWallet/Sources/UI/DashPay/Voting/CastVoteSheet.swiftDashWallet/Sources/UI/DashPay/Voting/CastVoteViewController.swiftDashWallet/Sources/UI/DashPay/Voting/Cells/GroupedRequestCell.swiftDashWallet/Sources/UI/DashPay/Voting/Cells/MasternodeIPCell.swiftDashWallet/Sources/UI/DashPay/Voting/Cells/UsernameRequestCell.swiftDashWallet/Sources/UI/DashPay/Voting/Cells/VoteButton.swiftDashWallet/Sources/UI/DashPay/Voting/Cells/VotingFilterItemSelectableCell.swiftDashWallet/Sources/UI/DashPay/Voting/ContestDetailScreen.swiftDashWallet/Sources/UI/DashPay/Voting/EnterVotingKeyViewController.swiftDashWallet/Sources/UI/DashPay/Voting/QuickVoteViewController.swiftDashWallet/Sources/UI/DashPay/Voting/UsernameRequestDetailsViewController.swiftDashWallet/Sources/UI/DashPay/Voting/UsernameVoting.storyboardDashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swiftDashWallet/Sources/UI/DashPay/Voting/UsernameVotingViewController.swiftDashWallet/Sources/UI/DashPay/Voting/VotingFiltersViewController.swiftDashWallet/Sources/UI/DashPay/Voting/VotingHeaderView.swiftDashWallet/Sources/UI/DashPay/Voting/VotingHeaderView.xibDashWallet/Sources/UI/DashPay/Voting/VotingViewModel.swiftDashWallet/Sources/UI/Menu/Main/MainMenuViewController.swiftDashWallet/Sources/UI/Menu/Tools/Masternode Keys/Overview/Model/WalletKeysOverviewModel.swiftDashWallet/Sources/UI/Menu/Tools/MasternodesScreen.swiftDashWallet/en.lproj/Localizable.strings
💤 Files with no reviewable changes (24)
- DashWallet/Sources/UI/DashPay/Voting/Cells/MasternodeIPCell.swift
- DashWallet/Sources/Models/Voting/MasternodeKey.swift
- DashWallet/Sources/Application/App.swift
- DashWallet/Sources/Models/Voting/VotingConstants.swift
- DashWallet/Sources/UI/DashPay/Usernames/RequestDetailsViewController.swift
- DashWallet/Sources/UI/DashPay/Voting/UsernameVoting.storyboard
- DashWallet/Sources/UI/DashPay/Voting/VotingHeaderView.swift
- DashWallet/Sources/UI/DashPay/Usernames/IconAttributedText.swift
- DashWallet/Sources/UI/DashPay/Voting/Cells/UsernameRequestCell.swift
- DashWallet/Sources/UI/DashPay/Voting/CastVoteViewController.swift
- DashWallet/Sources/Models/Voting/VotingFiltersModel.swift
- DashWallet/Sources/Models/Voting/DAO/UsernameRequestsDAO.swift
- DashWallet/Sources/UI/DashPay/Usernames/UsernameRequests.storyboard
- DashWallet/Sources/UI/DashPay/Voting/Cells/VotingFilterItemSelectableCell.swift
- DashWallet/Sources/UI/DashPay/Voting/Cells/GroupedRequestCell.swift
- DashWallet/Sources/UI/DashPay/Voting/QuickVoteViewController.swift
- DashWallet/Sources/UI/DashPay/Setup/CreateUsername/CreateUsernameViewModel.swift
- DashWallet/Sources/UI/DashPay/Voting/UsernameVotingViewController.swift
- DashWallet/Sources/Models/Voting/UsernameRequest.swift
- DashWallet/Sources/UI/DashPay/Voting/EnterVotingKeyViewController.swift
- DashWallet/Sources/UI/DashPay/Voting/UsernameRequestDetailsViewController.swift
- DashWallet/Sources/UI/DashPay/Voting/Cells/VoteButton.swift
- DashWallet/Sources/UI/DashPay/Voting/VotingHeaderView.xib
- DashWallet/Sources/UI/DashPay/Voting/VotingFiltersViewController.swift
Follows the SDK change making `dpnsNormalizeLabel(_:)` throw: homograph normalization is protocol behavior owned by Rust, so the app no longer accepts a locally-guessed spelling. `ContestedNamesService.normalizedLabel(for:)` now returns `String?`. The search filter needs the SDK handle, and so does the contest list it filters — a non-empty list means the handle is up, so a `nil` here only happens when there is nothing to filter. In that case the list is left unfiltered rather than matched against a substitute spelling that could hide real rows. Co-Authored-By: Claude Opus 5 <[email protected]>
Review follow-up on #923. **Resolved contests leave the active list.** `refreshContest` updated a contest's tallies but kept it in `contests` even when Platform reported it settled, so the list could offer a Vote button whose only possible outcome was the caster's closed-poll rejection. `contests` is the *open* contest list, so a resolved contest — or one Platform no longer holds contenders for — is now removed and recorded in `closedLabels`. A detail screen already open on that contest swaps its vote controls for a "voting has closed" notice rather than showing a stale snapshot with live-looking buttons. The nil case is now distinguished from the error case: a *successful* query returning no contenders means the poll was pruned, while a thrown query taught us nothing and leaves the cached row untouched. Previously `try?` collapsed both, which would have let a network blip evict a live contest. **`dashwallet` target membership.** The `dashwallet` target's Debug configuration defines `DASHPAY` (`SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG PIGGYCARDS_ENABLED DASHPAY"`, plus `-DDASHPAY`), and `MainMenuViewController` is a member of both targets, so its `#if DASHPAY showVoting()` compiles there and references `UsernameVotingScreen`. The seven voting files are now in both Sources phases, matching every dependency they touch (`MasternodeProviderKeyDeriver`, `MasternodeKeyUsage`, `AuthenticationGate`, `SwiftDashSDKHost`), all of which were already dual-target. The legacy storyboard stack this replaces was dashpay-only, so that build was already broken this way. **Project structure.** Consolidated the three sibling `SwiftDashSDK` groups the file had grown into one, with a single `Voting` subgroup holding all three services instead of splitting them across two same-named groups. **SwiftLint.** `@Environment(\.dismiss)` moved to its own line — `attributes` is an opt-in rule enabled in `.swiftlint.yml`, and it fires on attributes carrying arguments. Co-Authored-By: Claude Opus 5 <[email protected]>
Audit of what this PR removed turned up one genuine regression and one capability that had not been carried over. **Regression: the DashPay row stopped navigating.** I had removed `RequestDetailsViewController` on the basis that its only entry point — `handleJoinDashPayTap(state: .voting)` — was unreachable. That was wrong. `.voting` is set from `DWContestedNameStatusService.pendingLabel` (`JoinDashPayViewModel:33`), which is live: the registration coordinator writes it on every contested submission. Only the *other* two states in that method (`.approved` / `.blocked`) were dead, because they came from the DAO branch keyed on `UsernamePrefs.requestedUsernameId`, which nothing in the repo assigns. So a user with a name out for vote tapped the row and got nothing. Rather than restore the old screen, which displayed a real voting deadline beside three fields that never populated (`currentUsernameRequest` was always nil) and a "Cancel Request" button that cancelled nothing, `UsernameRequestStatusScreen` shows what the new service can actually answer: the deadline, plus the live contest — every contender with their tally, our own row marked "You", who is currently leading, and the lock/abstain counts. The status line distinguishes voting-in-progress, you-are-ahead, lock-is-ahead, won, went-to-someone-else, locked, and not-yet-indexed. This is the user-facing contest view `DWContestedNameStatusService` documents as future work. "Cancel Request" is deliberately not reimplemented: a submitted contested DPNS name cannot be withdrawn on Platform, and clearing the local bookmark would only make the app lose track of a live contest. **Bulk voting, replacing "Quick Voting".** The old screen offered "Vote for All" across filtered usernames. Multi-select now lives on the contest list (overflow menu → "Vote on several"), with a bottom bar showing the count and the combined weight, and a sheet that applies one choice with the chosen nodes. `MasternodeVoteCaster.castBulk` authenticates once for the whole run and reports per contest; a contest that closed since the list was fetched comes back as a failed row instead of aborting the batch. Only Abstain and Lock are offered in bulk. Approving names a specific contender, and the legacy "whoever submitted first" rule is not reproducible: contender submission time lives inside the serialized `domain` document that the FFI returns as opaque hex. Guessing an order would be worse than scoping the bulk action to the two choices that generalize honestly. Verified: the remaining deletions really were unreachable — `IconAttributedText` had no referent outside the deleted storyboard, and `requestedUsernameId` is never assigned anywhere at the merge base. Co-Authored-By: Claude Opus 5 <[email protected]>
There was a problem hiding this comment.
Actionable comments posted: 5
🧹 Nitpick comments (2)
DashWallet/Sources/UI/DashPay/Voting/ContestDetailScreen.swift (1)
165-168: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
shortIdentityis duplicated.The same truncation logic exists in
ContestantStatusRow.shortIdentityinDashWallet/Sources/UI/DashPay/Usernames/UsernameRequestStatusScreen.swiftat lines 259-262. Extract one helper, for example an extension onDPNSContenderor a shared formatting function, and use it in both rows.🤖 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/DashPay/Voting/ContestDetailScreen.swift` around lines 165 - 168, The shortIdentity truncation logic is duplicated between the current row and ContestantStatusRow.shortIdentity. Extract the shared formatting into one reusable DPNSContender extension or formatting helper, then update both shortIdentity properties to use it while preserving the existing 16-character threshold and prefix/suffix output.DashWallet/Sources/UI/DashPay/Voting/BulkVoteSheet.swift (1)
102-104: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReplace
NavigationViewwithNavigationStack. The project targets iOS 17.0 or later, andNavigationViewis deprecated from iOS 16.🤖 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/DashPay/Voting/BulkVoteSheet.swift` around lines 102 - 104, Update the navigation container in the body property of BulkVoteSheet from NavigationView to NavigationStack, preserving the existing Group content and navigation behavior.
🤖 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/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swift`:
- Around line 213-214: Update the voting log in MasternodeVoteCaster to avoid
String(describing: choice), which exposes the identity ID publicly. Add or reuse
a non-identifying VoteChoice descriptor such as logDescription that reports only
the choice kind, and use it in the logger call while keeping the existing node
and label logging unchanged.
- Around line 271-281: Update the contest-open check in the vote-casting loop
around contests.contestIsOpen to distinguish thrown query errors from a valid
false result. Report the underlying network/query failure with a retryable error
message when the check fails, and continue using CastError.contestClosed(label)
only when contestIsOpen successfully returns false.
In `@DashWallet/Sources/UI/DashPay/Usernames/UsernameRequestStatusScreen.swift`:
- Around line 88-93: Update the guard handling
ContestedNamesService.normalizedLabel(for:) in UsernameRequestStatusScreen so
its nil result does not always report a connectivity/syncing error. Distinguish
the missing-SDK case from normalization failure, either by exposing separate
service outcomes or by using a distinct user-facing message for labels that
cannot be normalized.
In `@DashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swift`:
- Around line 180-199: Add pluralization rules in the localization strings
dictionary for every count-based key used by the voting UI, while preserving the
existing format specifiers. In UsernameVotingScreen.swift (lines 180-199), cover
“%d evonodes”, “%d masternodes”, “%u votes per contest — evonodes count as 4,
masternodes as 1”, plus the “%d requests” and “%u votes” strings near lines 218
and 228; in BulkVoteSheet.swift (lines 36-43), cover “%d selected”, “%u votes in
total”, “%u votes”, “Vote on %d usernames”, and “%d of %d usernames voted on”
near lines 184, 204, and 241.
In `@DashWallet/Sources/UI/Menu/Tools/Masternode`
Keys/Overview/Model/WalletKeysOverviewModel.swift:
- Around line 162-173: The indexByAddress flow must not derive a complete match
from the derivation wallet’s five-entry fallback pool. Require a complete live
pool before iterating highestAddressIndex, or return an explicit incomplete
result when it is unavailable, and ensure votableNodes() does not silently
undercount deeper voting indexes.
---
Nitpick comments:
In `@DashWallet/Sources/UI/DashPay/Voting/BulkVoteSheet.swift`:
- Around line 102-104: Update the navigation container in the body property of
BulkVoteSheet from NavigationView to NavigationStack, preserving the existing
Group content and navigation behavior.
In `@DashWallet/Sources/UI/DashPay/Voting/ContestDetailScreen.swift`:
- Around line 165-168: The shortIdentity truncation logic is duplicated between
the current row and ContestantStatusRow.shortIdentity. Extract the shared
formatting into one reusable DPNSContender extension or formatting helper, then
update both shortIdentity properties to use it while preserving the existing
16-character threshold and prefix/suffix output.
🪄 Autofix
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 Plus
Run ID: 8f85c942-d9de-4532-abd3-3c66edb58219
📒 Files selected for processing (12)
DashWallet.xcodeproj/project.pbxprojDashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/ContestedNamesService.swiftDashWallet/Sources/Infrastructure/SwiftDashSDK/Voting/MasternodeVoteCaster.swiftDashWallet/Sources/UI/DashPay/Usernames/UsernameRequestStatusScreen.swiftDashWallet/Sources/UI/DashPay/Voting/BulkVoteSheet.swiftDashWallet/Sources/UI/DashPay/Voting/CastVoteSheet.swiftDashWallet/Sources/UI/DashPay/Voting/ContestDetailScreen.swiftDashWallet/Sources/UI/DashPay/Voting/UsernameVotingScreen.swiftDashWallet/Sources/UI/DashPay/Voting/VotingViewModel.swiftDashWallet/Sources/UI/Menu/Main/MainMenuViewController.swiftDashWallet/Sources/UI/Menu/Tools/Masternode Keys/Overview/Model/WalletKeysOverviewModel.swiftDashWallet/en.lproj/Localizable.strings
🚧 Files skipped from review as they are similar to previous changes (3)
- DashWallet/Sources/UI/DashPay/Voting/CastVoteSheet.swift
- DashWallet/en.lproj/Localizable.strings
- DashWallet/Sources/UI/DashPay/Voting/VotingViewModel.swift
**Never log a contender identity id.** The cast log line interpolated `String(describing: choice)` at `.public`, which expands `.towards` to include the base58 identity — writing a specific voter node's choice of candidate into the device log in clear text. `VoteChoice.logDescription` emits the kind only. **A failed open-check no longer reads as "closed".** `castBulk` mapped any thrown `contestIsOpen` error to `false` via `try?`, so a network blip told the user "voting has already closed" for a live contest. The two are now distinguished, same as `refreshContest` already does. **A degraded key pool no longer silently undercounts voting power.** `MasternodeProviderKeyDeriver` falls back to the derivation wallet's pool when the live one can't be read, and that pool is only gap-limit deep. Enumerating it — which the owner/voting address join does — can therefore miss a masternode whose voting key sits at a deeper index, so `votableNodes()` could omit a node the user can really vote with, with no explanation. The deriver now exposes `poolIsLive`, `MasternodeKeyUsage.resolveAddressIndexes` passes it through, and the registry returns a `Resolution` flagging the case where the pool was degraded *and* an active registration went unmatched. The voting header shows a caution when that happens instead of presenting a short list as the full picture. **Normalization failure is no longer reported as a connectivity problem.** `normalizedLabel(for:)` returned `nil` both when the SDK was absent and when Rust refused the label; the status screen called both "Platform is not connected yet — wait for syncing". `requireNormalizedLabel` throws the two cases separately. **Plurals.** Every count string in the voting flow was a fixed English phrase, so any count of 1 rendered "1 evonodes" / "1 votes" / "Vote on 1 usernames". Added `en.lproj/Localizable.stringsdict` rules for all 12, including the three two-number strings via positional specifiers, and removed the now-superseded entries from `Localizable.strings` so the two files cannot disagree. Also: extracted the duplicated identity truncation into `DPNSContender.shortIdentityId`, shared by the contest-detail and request-status rows; and renamed a local `masternodes` binding to `regularNodes` so this PR does not add a new SwiftLint `inclusive_language` warning. Co-Authored-By: Claude Opus 5 <[email protected]>
develop does not compile: #923 and #924 collided after both merged green independently. #923 replaced UsernameVotingViewController with the SwiftUI UsernameVotingScreen and updated the showVoting() that lived in MainMenuViewController when that PR was written. #924 had since moved the Voting entry point into GovernanceMenuScreen, which #923 never saw. On the merged tip the live entry point (Governance) still called the deleted controller — a hard build error — while the updated copy in MainMenuViewController was orphaned, since #924 removed its caller. Points Governance at UsernameVotingScreen (exactly what #923 wrote, in the location that is actually reachable) and deletes the dead copy. Co-authored-by: Claude Fable 5 <[email protected]>
The problem
Menu → Voting (DASHPAY builds, on by default) was a self-contained mock. It made zero SDK calls and zero network calls.
username_requestswasaddMockRequest(), wired to a tap gesture on the screen's title label and shipped in release. The production writer was deleted in97398f7ca, so on a real install the list was permanently empty and the Quick Voting button permanently hidden.createdAt + 14 days— wrong by ~2 weeks on testnet, where contests run 90 minutes.Meanwhile every piece needed to do this properly already existed and was unused:
SDK.castContestedResourceVote,PlatformWalletManager.masternodes(for:), and the wallet's ownProviderVotingKeysderivation.What this does
Modeled on Dash Evo Tool's DPNS contested-names screen (
src/backend_task/contested_names/*).Browse real contests.
ContestedNamesServicelists every open DPNS contest from Platform with contenders, tallies and the authoritative deadline. Nothing is estimated — an unknown end time renders "Deadline unknown", not a guess.Vote with the wallet's own nodes.
MasternodeVoterRegistryjoins the on-chain masternode aggregation against the wallet's derived voting-key pool, so a node is offered only when this wallet actually holds the key Platform will check the signature against. Filtered to active, non-revoked registrations. No key is ever pasted or stored —EnterVotingKeyViewControlleris gone.Real broadcast.
MasternodeVoteCasterpre-flights that the poll is open (turning a ~70 s opaque retry into an instant, actionable error), gates onAuthenticationGatebefore deriving key material, then callsSDK.castContestedResourceVoteper node. Serial per node: the SDK fetches an identity nonce per voter identity, so concurrent votes from one node would race.Honest reporting. One node failing never abandons the rest — the result sheet reads "3 of 4 masternodes voted" and shows Platform's own message per failure (
already voted,too many vote changes) verbatim.Honest capability. Evonodes count as 4 votes and masternodes as 1, matching drive-abci's server-side weighting (
MasternodeType::Evo => 4). A wallet with no votable node browses fine and says so; the vote controls are disabled, not faked.Search normalizes homographs before matching — Platform stores
aliceasa11ce, so a raw substring match finds nothing. (Dash Evo Tool's own filter missesi; this one doesn't.)Removed
Rebuilt in SwiftUI + ViewModel per⚠️ This is the one change that can regress unrelated screens — please smoke the Tx list, menus and Explore.
CLAUDE.md. The storyboard/UIKit stack is deleted — including its app-wideextension UITableView { override var intrinsicContentSize / contentSize }(UsernameVotingViewController.swift:324), which affected every table view in thedashpaytarget.Also removed as unreachable dead code:
username_requests, its DAO, andUsernameRequest/MasternodeKey/VotingFiltersModelRequestDetailsViewController+UsernameRequests.storyboardand its only trigger — reached solely via aJoinDashPayState.votingbranch keyed onUsernamePrefs.requestedUsernameId, which nothing in the repo ever assignsVotingConstants.maxVotes, whose comment called it a vote cap when Platform's 5 is a limit on vote changes per masternode per contestVoteButton.swift(never referenced),kVotingPanelClosed, the title-tap mock generator, and the strayprint(dto)/print("VOTING: votesLeft:")MasternodeKeyUsage.indexByAddress(family:targets:)is promoted out ofMasternodesScreen's private copy so the ownership labels and the voting registry share one address→key-index join instead of two.Depends on
dashpay/platform#4328 — the typed DPNS contest read layer. ✅ Merged (
96af88d2b8onv4.2-dev), so this is no longer blocking. Verified: with the local../platformcheckout moved to mergedv4.2-dev, thedashpayscheme builds clean and the SDK's 19DPNSContestDecoderTestspass.Testing
Clean
dashpaybuild (ARCHS=arm64, iOS Simulator); installs and launches on the QA-iPhone16 simulator. The unit-test target is broken on this branch (pre-existing), so the remaining verification is a testnet smoke — testnet's 90-minute contests make a full lifecycle observable in one sitting:proTxHashbyte orientation here —PlatformMasternode.proTxHashis raw wire bytes andMasternodesScreenreverses it only for display; a wrong orientation surfaces immediately asMasternodeNotFoundError.MasternodeVoteAlreadyPresentErroris surfaced verbatim, not swallowed.Logs:
xcrun simctl spawn <udid> log show --last 15m --predicate 'eventMessage CONTAINS "VOTING ::"'Not in this PR
Past contests, a My-usernames tab, bulk voting and scheduled votes were scoped in the plan and are follow-ups; this PR is the browse + cast core. Worth knowing for the Past tab: Platform prunes resolved polls from the contested tree, so past contests can only ever be local history — Dash Evo Tool has the same constraint.
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Improvements