Skip to content

refactor(swift-example-app): remove dead code in SwiftExampleApp (10 audit entries) - #4639

Open
llbartekll wants to merge 10 commits into
v4.2-devfrom
refactor/wallet-dead-code-swift-app
Open

refactor(swift-example-app): remove dead code in SwiftExampleApp (10 audit entries)#4639
llbartekll wants to merge 10 commits into
v4.2-devfrom
refactor/wallet-dead-code-swift-app

Conversation

@llbartekll

@llbartekll llbartekll commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Issue being fixed or feature implemented

Second part of the cleanup following the 2026-09-08 audit (dead-code category). 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 in Sources/SwiftDashSDK/Models/StateTransitionDefinitions.swift that is data for that app.

Independent of #4637 — both branches come off v4.2-dev.

What was done?

Entry What goes
swift-app-035 the seedPhrase field on identityCreate (required, yet executeIdentityCreate never reads it) plus generateTestSeedPhrase() returning the literal "test seed phrase for development only…"; the empty loadExistingDocument / fetchContestedResources TODO arms; fetchDocumentSchema, which wrote a canned template DocumentFieldsView immediately overwrites; masternodeVote from the catalogue (the router sends it to default: notImplemented)
swift-app-036 the wallet PIN — collected, validated, printed to the console, and never passed to createWallet, WalletStorage or the Keychain, under a footer promising "Choose a PIN to secure your wallet"; an alert bound to isPresented: .constant(false)
swift-app-037 the unreachable PINPromptView + derivePrivateKeyWithPIN (nothing ever sets showingPINPrompt = true), unread @State, and SyncProgressRow (marked "(Legacy)" in the source)
swift-app-043 the always-empty "Unassigned" section, the fromPersistent parameter only ever passed nil, DataManagementView with destructive buttons wired to empty closures, hardcoded "1.0.0" in About, and a dead NSPasteboard branch in an iOS-only target
swift-app-051 IdentityBalanceExample.swift, SDKExtensions.swift, Utils/TestKeyGenerator.swift, test_account_collection.swift, AppState.run*Diagnostics (146 lines), readLocalCorePeers
swift-app-056 iOS<17 onChange shims on a target with IPHONEOS_DEPLOYMENT_TARGET = 18.5; extension Character { var isHexDigit } shadowing the stdlib property
swift-app-060 alias/note/hidden on DashPayContactMetaStore, dead since the contactInfo migration; plus an alias read that could never return a value
swift-app-072 PlatformStateTransitionsView (body: StateTransitionsView()); IdentitiesView.swiftIdentityRow.swift
swift-app-076 the "View Private Key" button wired to a method with an empty body
swift-app-094 the contestInfo parameter 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) from EnvLoader.

Where this departs from the audit

  • Correction: the audit stated SwiftExampleApp/Utils/TestKeyGenerator.swift is "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.
  • Out of scope: fullBase58 has four call sites — a redundant alias, not dead code. Same for the DPNS constants duplicated across the app (constant substitution) and the print("DEBUG: …") storms (log silencing). Each needs its own change.
  • Out of scope, needs a decision: swift-app-053 and swift-app-063 (TokensView, TokenSearchView, LocalDataContractsView, ShieldedFundFromAssetLockProgressView) were deliberately dropped — KotlinExampleApp has live equivalents wired into Routes.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 16 destination in CLAUDE.md does not exist on the test machine — builds ran on iPhone 17. CLAUDE.md is worth updating.

swift build is not a meaningful check in this repo: DashSDKFFI.xcframework ships only an ios-arm64-simulator slice, so a macOS-targeted build cannot resolve the module on any branch.

The SwiftExampleAppUITests UI 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:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

🤖 Generated with Claude Code

llbartekll and others added 10 commits September 9, 2026 12:58
… 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>
@github-actions github-actions Bot added this to the v4.2.0 milestone Sep 9, 2026
@coderabbitai

coderabbitai Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 47 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 75052ed7-69c2-4c20-8a23-49bd3db00e14

📥 Commits

Reviewing files that changed from the base of the PR and between 299d662 and 29421fe.

📒 Files selected for processing (29)
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/StateTransitionDefinitions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/AccountDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/CoreContentView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Core/Views/CreateWalletView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/EnvLoader.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContestDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/ContactRequestsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/DashPayContactMeta.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DashPay/SendDashPayPaymentSheet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DiagnosticsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentWithPriceView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentityDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentityRow.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/KeyDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/OptionsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/PlatformStateTransitionsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/RegisterNameView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/StorageModelListViews.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TransitionCategoryView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TransitionDetailView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/WalletMemoryExplorerView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppUITests/SwiftExampleAppUITests.swift
  • packages/swift-sdk/SwiftExampleApp/test_account_collection.swift

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thepastaclaw

thepastaclaw commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

🕓 Queued for automated review — 5th in line, estimated start in ~1.5 h (commit 29421fe)
Estimated review time once started: ~35 min (two-phase automated review; median of recent runs).

  • Request priority review — tick this box and the review moves to the front of the queue.

@llbartekll llbartekll changed the title refactor(swift-example-app): usunięcie martwego kodu w SwiftExampleApp (10 wpisów audytu) refactor(swift-example-app): remove dead code in SwiftExampleApp (10 audit entries) Sep 9, 2026
@llbartekll
llbartekll force-pushed the refactor/wallet-dead-code-swift-app branch from 3da3136 to 29421fe Compare September 9, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants