refactor(swift-example-app): remove dead code in SwiftExampleApp (10 audit entries) - #4639
refactor(swift-example-app): remove dead code in SwiftExampleApp (10 audit entries)#4639llbartekll wants to merge 10 commits into
Conversation
… and validated but never used
`walletPin` / `confirmPin` gated `canCreateWallet` and a 4-6 digit guard, and
were echoed by `print("PIN length: …")` — and that was the whole of it. The PIN
never reached `createWallet`, `WalletStorage` or the Keychain, while the section
footer promised "Choose a PIN to secure your wallet". In a QA app the team uses
to validate wallet flows, that is misleading security UX.
From the same file: the `.alert("Wallet Created", isPresented: .constant(false))`
could never present (unchanged since 872383b).
The `SwiftExampleAppUITests` UI test no longer fills the removed fields, and the
`secureTextField` helper has no users left.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…nd legacy SyncProgressRow
`showingPINPrompt = true` appears nowhere in the app, so the
`.sheet(isPresented: $showingPINPrompt) { PINPromptView(…) }` and the 44-line
`PINPromptView` are unreachable. `derivePrivateKeyWithPIN()` is a stub that only
sets a "not yet available" message.
Going with them: the unread `@State` vars `showingPrivateKey`,
`privateKeyToShow`, `pinInput` and `copiedText` (AccountDetailView), plus
`copiedText` in `ProofDetailView`.
`struct SyncProgressRow` — marked "(Legacy)" in the source itself — has no
reference outside its own definition.
About 150 lines of unreachable UI out of the app's two largest view files.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ppState and SwiftExampleAppApp Everything below was grep-verified as unreferenced: - `SDK/IdentityBalanceExample.swift` — a print-based tutorial compiled into the app; `exampleFetchBalances` / `exampleWithSecp256k1` appear only at their own definitions. - `SDK/SDKExtensions.swift` — `typealias Signer = SwiftDashSDK.Signer` with no users (only `KeychainSigner` is referenced). - `Utils/TestKeyGenerator.swift` — byte-identical to `Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift`. Correction to the audit: it claimed the Utils copy "is the copy that is used" — grep shows NEITHER copy has a reference. The SDK twin goes separately. - `test_account_collection.swift` — a `#!/usr/bin/env swift` script that prints a paragraph describing a past change and "Test completed successfully". - `AppState.runStartupDiagnostics` / `runSimpleDiagnostic` — private and never invoked (146 lines). - `SwiftExampleAppApp.readLocalCorePeers` — private and uncalled; `CoreSpvLauncher.peerOverride` re-implements it. `EnvLoader` also loses its hardcoded developer home directories (`/Users/quantum`, `/Users/samuelw`); the current user's path stays. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- `PublicKeyStorageListView.orphanKeys` and the "Unassigned" section: `scopedKeys` already drops every key with `identity == nil`, so the collection is always empty — its own doc comment said as much — and the section could never render. - `walletDisplayLabel(_:fromPersistent:)`: the parameter was only ever passed `nil`. - `DataManagementView` and the "Manage Local Data" row: three destructive buttons with empty closures (`// Clear identities`) and a "Clear All Data" confirmation whose action is `// Implement clear all data`. Non-functional controls in a QA app mislead testers. - The About section hardcoded "SDK Version 1.0.0" / "App Version 1.0.0" while `exportLogs`, a few dozen lines away, already reads the real version from `Bundle.main`. One row with the real version remains. - `DiagnosticsView`: an `#else NSPasteboard` branch in a file that imports UIKit, in an iOS-only target. `fullBase58` from the same audit entry is KEPT — it has four call sites, making it a redundant alias rather than dead code; collapsing it is a separate task. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…file to match its contents `PlatformStateTransitionsView`'s body was `StateTransitionsView()` and it had one caller (OptionsView), which now points straight at `StateTransitionsView`. (The NavigationLink edit itself rode along with the previous commit, together with the rest of the OptionsView changes.) `IdentitiesView.swift` opened with "The IdentitiesView that used to live here was a legacy duplicate … Only IdentityRow stays" — the file is now `IdentityRow.swift`, and the comment describing that past move is gone. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ed to an empty stub `Button(action: viewPrivateKey)` called a private method with an empty body — two comments and nothing else. A visible control that does nothing. While here, `hasPrivateKey` stops printing to the console on every evaluation of that computed property. The mismatch between `KeyDetailView.hasPrivateKey` (legacy Keychain scheme only) and `KeysListView.hasPrivateKey` (both schemes) is KEPT — that is a behaviour bug rather than dead code, and fixing it needs a shared helper on the SDK side. Reported separately. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…om ContestDetailView `let contestInfo: [String: Any]` was documented as "Kept for call-site compatibility but unused — the view reads everything off `voteState`". A parameter that exists only to avoid editing one call site is the definition of a vestigial shim. Its sole caller (IdentityDetailView) built it from `contestedDpnsInfo[name] as? [String: Any] ?? [:]`. The duplicated DPNS constants from the same audit entry (the contract literal appears 11 times across the app) are KEPT — collapsing them onto the SDK's `DPNSVotePoll` is constant substitution, not dead-code removal. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…b-shadowing extension
`DocumentIdChangeHandler` and `UsernameChangeHandler` branched on
`#available(iOS 17.0, *)` while project.pbxproj sets
IPHONEOS_DEPLOYMENT_TARGET = 18.5 and every other view calls the two-argument
`onChange` directly. Both call sites move to `.onChange(of:)` inline; the dead
modifiers go.
`extension Character { var isHexDigit }` shadowed the standard library property
of the same name — it could drift from stdlib semantics while adding nothing.
The `print("DEBUG: …")` storms from this entry are KEPT — silencing logs needs
its own change (a single `Log.debug` behind `#if DEBUG`) and is not dead-code
removal.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ashPayContactMetaStore After the `contactInfo` migration, alias, note and the hidden flag live on `PersistentDashpayContactRequest` rows written through `setDashPayContactInfo`. The UserDefaults store was left with a dead half: `setAlias`, `setNote`, `setHidden`, `note` and `isHidden` have no call site at all. The one read, `contactMeta.alias(...)` in `ContactRequestsView.displayName`, could never return a value — nothing wrote that key — while looking like a real display-name precedence rule. It now passes `alias: nil`. The store is reduced to `dpnsHint`/`setDpnsHint` (the DPNS hint captured when a contact is added, which has no `contactInfo` counterpart), and its header describes what it actually does instead of announcing a migration that already happened. `DashPayContact.note` / `.isHidden` were only ever set to their defaults by the single constructor and never read — they go along with the hand-written `init` (the memberwise one suffices). The `ContactLocalFieldEditor` doc claimed it writes to `DashPayContactMetaStore`; in fact its `onSave` calls `saveContactInfo`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…stubs from the generic transition builder
The `identityCreate` definition required a `seedPhrase` field
(`required: true`) plus a "Generate New Seed" button. The handler
`generateTestSeedPhrase()` returned the literal "test seed phrase for
development only do not use in production ever please", and
`executeIdentityCreate` never reads `formInputs["seedPhrase"]` — it calls
`sdk.identityCreate()`. A QA tester had to type a fake seed to enable a button
whose result ignores it.
Also from the same action switch:
- `case "loadExistingDocument"` and `case "fetchContestedResources"` — empty
TODO arms,
- `fetchDocumentSchema` — a TODO writing a canned `{ "message": … }` template
into `documentFields`, which `DocumentFieldsView` immediately overwrites.
`TransitionCategoryView` stops advertising `masternodeVote`, since
`executeStateTransition` routes it to `default: notImplemented`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 47 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: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (29)
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 |
|
🕓 Queued for automated review — 5th in line, estimated start in ~1.5 h (commit 29421fe)
|
3da3136 to
29421fe
Compare
Issue being fixed or feature implemented
Second part of the cleanup following the 2026-09-08 audit (
dead-codecategory). Scope: swift-app, Effort S, Risk low — 10 entries, one commit per entry.Changes are confined to
SwiftExampleApp(the QA app), plus one form-definitions table inSources/SwiftDashSDK/Models/StateTransitionDefinitions.swiftthat is data for that app.Independent of #4637 — both branches come off
v4.2-dev.What was done?
seedPhrasefield onidentityCreate(required, yetexecuteIdentityCreatenever reads it) plusgenerateTestSeedPhrase()returning the literal "test seed phrase for development only…"; the emptyloadExistingDocument/fetchContestedResourcesTODO arms;fetchDocumentSchema, which wrote a canned templateDocumentFieldsViewimmediately overwrites;masternodeVotefrom the catalogue (the router sends it todefault: notImplemented)createWallet,WalletStorageor the Keychain, under a footer promising "Choose a PIN to secure your wallet"; an alert bound toisPresented: .constant(false)PINPromptView+derivePrivateKeyWithPIN(nothing ever setsshowingPINPrompt = true), unread@State, andSyncProgressRow(marked "(Legacy)" in the source)fromPersistentparameter only ever passednil,DataManagementViewwith destructive buttons wired to empty closures, hardcoded "1.0.0" in About, and a deadNSPasteboardbranch in an iOS-only targetIdentityBalanceExample.swift,SDKExtensions.swift,Utils/TestKeyGenerator.swift,test_account_collection.swift,AppState.run*Diagnostics(146 lines),readLocalCorePeersonChangeshims on a target withIPHONEOS_DEPLOYMENT_TARGET = 18.5;extension Character { var isHexDigit }shadowing the stdlib propertyalias/note/hiddenonDashPayContactMetaStore, dead since thecontactInfomigration; plus an alias read that could never return a valuePlatformStateTransitionsView(body:StateTransitionsView());IdentitiesView.swift→IdentityRow.swiftcontestInfoparameter documented as "Kept for call-site compatibility but unused"Total: 29 files, 865 deletions, 35 insertions.
Also drops the hardcoded developer home directories (
/Users/quantum,/Users/samuelw) fromEnvLoader.Where this departs from the audit
SwiftExampleApp/Utils/TestKeyGenerator.swiftis "the copy that is used". Grep shows neither of the two copies has a reference. Both go (the SDK twin in the follow-up PR), but the stated rationale was wrong.fullBase58has four call sites — a redundant alias, not dead code. Same for the DPNS constants duplicated across the app (constant substitution) and theprint("DEBUG: …")storms (log silencing). Each needs its own change.swift-app-053andswift-app-063(TokensView, TokenSearchView, LocalDataContractsView, ShieldedFundFromAssetLockProgressView) were deliberately dropped —KotlinExampleApphas live equivalents wired intoRoutes.kt, which makes these look like unwired Swift screens rather than dead code.How Has This Been Tested?
xcodebuild -scheme SwiftDashSDK -sdk iphonesimulator✅xcodebuild -project SwiftExampleApp.xcodeproj -scheme SwiftExampleApp -sdk iphonesimulator✅Note: the
iPhone 16destination inCLAUDE.mddoes not exist on the test machine — builds ran oniPhone 17.CLAUDE.mdis worth updating.swift buildis not a meaningful check in this repo:DashSDKFFI.xcframeworkships only anios-arm64-simulatorslice, so a macOS-targeted build cannot resolve the module on any branch.The
SwiftExampleAppUITestsUI test no longer fills the removed PIN fields.Breaking Changes
None. Example-app changes only; the single SDK file touched is a form-definitions table used solely by that app.
Checklist:
For repository code-owners and collaborators only
🤖 Generated with Claude Code