Skip to content

chore(swift-sdk): remove unused code in the swift-sdk and example app#3463

Draft
ZocoLini wants to merge 1 commit intov3.1-devfrom
chore/remove-unused
Draft

chore(swift-sdk): remove unused code in the swift-sdk and example app#3463
ZocoLini wants to merge 1 commit intov3.1-devfrom
chore/remove-unused

Conversation

@ZocoLini
Copy link
Copy Markdown
Collaborator

@ZocoLini ZocoLini commented Apr 8, 2026

Removed a bunch of dead and redundant code in the codebase following a couple of rules:

  • If something its only being tested it gets removed
  • if something can be removed and the app still compiles it gets removed
  • if something is being used in a unused field and by removing the unused field one of the previous conditions mets it gets removed

There is a lot more stuff that is dead code or unnecessary but honestly, I don't want to continue iterating over the codebase right now and, in most of the cases, stuff is being used in unused fields and requires to much time to verify

Summary by CodeRabbit

  • Refactor

    • Removed many wallet/key-management and key-derivation features (including biometric/PIN flows), KeyWallet entry points, and related wallet APIs.
    • Removed token actions, token search, token history, and many token-related models/UI.
    • Removed document creation/management, local data-contract workflows, DPP state-transition/types, identity conversion helpers, unified state manager, and several persistence models.
    • Switched some view modules to use the core SDK module.
  • New Features

    • Added a reusable Empty State view component.
  • Tests

    • Removed related unit tests for wallet derivation, key validation, state management, error formatting, and transaction building.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 8, 2026

📝 Walkthrough

Walkthrough

This PR substantially reduces the Swift SDK surface: it deletes many KeyWallet, DPP, persistence, state-management, error/validation utilities, and example-app UI/adapter files; narrows network types to DashSDKNetwork; and removes numerous helper/test utilities. No equivalent replacements are introduced.

Changes

Cohort / File(s) Summary
Network / SDK bootstrap
packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift, packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift, packages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swift
Changed stored/parameter types from Network typealias to concrete DashSDKNetwork; DashSDKFFI re-export added; removed some public typealiases (Network, ErrorCode, SDKConfig).
KeyWallet & Wallet subsystem (large removal)
packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/... (e.g. Wallet.swift, WalletManager.swift, KeyDerivation.swift, ManagedWallet.swift, KeyWallet.swift, Mnemonic.swift, Transaction.swift, Address.swift, ManagedAccountCollection.swift, ManagedPlatformAccount.swift, AccountCollection.swift, BLSAccount.swift, EdDSAAccount.swift, BIP38.swift, KeyWalletTypes.swift)
Removed majority of wallet APIs: wallet lifecycle/initializers, account/managed wallet wrappers, key-derivation, mnemonic/transaction/address helpers, summaries and related types.
Key management, signer & test helpers removed
packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift, packages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift, packages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swift, packages/swift-sdk/SwiftExampleApp/.../Utils/TestKeyGenerator.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
Deleted convenience key finders, validation helpers, deterministic test key generation, and TestSigner mock.
Seed / biometric / keychain APIs reduced
packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swift, packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swift, packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift, packages/swift-sdk/SwiftExampleApp/.../Services/KeychainManager.swift
Removed seed decrypt/change-PIN/biometric enable/unlock APIs and several keychain methods and error type; left a smaller keychain surface and removed app-specific keychain singleton.
DPP models & state-transition removed
packages/swift-sdk/Sources/SwiftDashSDK/DPP/... (e.g. DPPStateTransition.swift, DPPDocument.swift, DPPDataContract.swift, DPPIdentity.swift)
Deleted DPP state-transition types, document/data-contract schema types, partial identity and related factory/extension APIs.
Data contract parsing & persistence container changes
packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swift, packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift, packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
Removed heavy DataContractParser and DashModelContainer; ModelContainerHelper.createContainer() now omits PersistentTokenHistoryEvent from schema.
Persistence models & token-related types removed
packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/..., packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift (e.g. PersistentTokenHistoryEvent.swift, PersistentToken.swift, token enums)
Removed token history model and relationship, token control-rule APIs, and token/event enums and helpers.
State, error, validation & utility APIs removed
packages/swift-sdk/Sources/SwiftDashSDK/Utils/... (e.g. ErrorHandling.swift, StateManagement.swift, PrivateKeyUtils.swift, Validation.swift)
Removed retryability flag and related error-formatting/recovery APIs, ErrorBuilder/Aggregator, multiple generic state/result abstractions, key-size validators, and combined address/identity validator helpers.
FFI convenience extensions trimmed
packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift, packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
Removed convenience FFI methods (tokenTransfer, topUpIdentity) and a private SendablePtr helper; core FFI signatures left intact.
Services / DataManager API removals
packages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swift
Removed numerous SwiftData-backed fetch/mutate operations for identities, documents, contracts/tokens, token balances, sync bookkeeping and bulk-clear logic.
Example App — backward-compat typealiases, converters, and SwiftData bindings removed
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/*, .../Models/SwiftData/*, Persistent* converters
Deleted many app-level typealiases that re-exported SDK types and conversion helpers between app models and SDK persistent models (contracts, documents, identities, tokens, indexes, etc.).
Example App — UI screens removed or simplified
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/* (notable removals: TokensView.swift, DocumentsView.swift, LocalDataContractsView.swift, IdentitiesView.swift, TokenSearchView.swift; additions: EmptyStateView.swift; import changes across several views)
Removed multiple full-featured screens and associated components; added a small EmptyStateView and updated several view imports to SwiftDashSDK.
Example App — state & initialization simplified
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift, UnifiedAppState.swift, AppState.swift
Removed unified state manager usage/reset path and test signer property; simplified app initialization task.
Tests reduced
packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/...
Removed many unit tests tied to removed features (error handling/retryability, state-management types, key-size validation, validation tests, key-derivation/transaction tests, and others).

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

🐰 I nibble through the code tonight,

Shelves of helpers trimmed just right,
Tokens, keys, and views set free,
A quieter tree for you and me. 🥕

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/remove-unused

@github-actions github-actions bot added this to the v3.1.0 milestone Apr 8, 2026
@ZocoLini ZocoLini changed the title Chore/remove unused chore(swift-sdk): remove unused code in the swift-sdk and example app Apr 8, 2026
@ZocoLini ZocoLini force-pushed the chore/remove-unused branch from 91ee92a to f218b47 Compare April 8, 2026 23:15
@ZocoLini ZocoLini marked this pull request as ready for review April 8, 2026 23:17
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 8, 2026

✅ Review complete (commit e5b5275)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift (1)

55-56: Consider a temporary compatibility shim for the NetworkDashSDKNetwork public API change.

This is source-breaking for SDK consumers that still reference Network. A deprecated compatibility alias for one release would reduce upgrade friction.

Also applies to: 156-156

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift` around lines 55 - 56, Add
a temporary deprecated compatibility shim so existing consumers using Network
keep working: declare a public typealias with deprecation pointing to the new
type (e.g. add `@available(*, deprecated, renamed: "DashSDKNetwork") public
typealias Network = DashSDKNetwork`) in SDK.swift near the DashSDKNetwork
declaration and add the same alias if Network is referenced elsewhere (the other
occurrence around the second mention at line 156); this preserves source
compatibility for one release while guiding users to migrate to DashSDKNetwork.
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift (1)

4-27: Clean, reusable empty-state component!

The implementation is well-structured and follows SwiftUI best practices. The component provides good flexibility through its parameters while maintaining consistent styling.

Optional: Consider adding a preview provider for development convenience.

Adding a preview would make it easier to iterate on the design in Xcode.

📱 Optional: Add preview provider
`#Preview` {
    EmptyStateView(
        systemImage: "doc.plaintext",
        title: "No Items",
        message: "There are no items to display at this time"
    )
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift`
around lines 4 - 27, Add a SwiftUI preview for the EmptyStateView so it's
viewable in Xcode: create a preview provider (e.g., EmptyStateView_Previews
conforming to PreviewProvider or use the `#Preview` block) that returns
EmptyStateView with example values for systemImage, title, and message (for
example "doc.plaintext", "No Items", "There are no items to display at this
time") so you can iterate on the design during development.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift`:
- Around line 36-39: Add a re-entrancy guard around calls to
unifiedState.initialize() invoked from the .task block and protect the Retry
button path by making UnifiedAppState.initialize() idempotent: introduce a
boolean flag (e.g., isInitializing / isInitialized) and short-circuit early if
initialization is in progress or already completed, set/reset the flag
appropriately around the async work, and ensure any errors clear the in-progress
flag so subsequent retries work; update references to unifiedState.initialize()
(the .task invocation and any Retry button handlers) to rely on the built-in
guard rather than duplicating checks.

In
`@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift`:
- Line 2: Add the missing SwiftData import so SwiftData APIs used in
DataContractDetailsView compile: add "import SwiftData" alongside the existing
"import SwiftDashSDK" at the top of the file; this will allow the
`@Environment`(\.modelContext) property and the modelContext.save() call in
DataContractDetailsView to resolve correctly.

---

Nitpick comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift`:
- Around line 55-56: Add a temporary deprecated compatibility shim so existing
consumers using Network keep working: declare a public typealias with
deprecation pointing to the new type (e.g. add `@available(*, deprecated,
renamed: "DashSDKNetwork") public typealias Network = DashSDKNetwork`) in
SDK.swift near the DashSDKNetwork declaration and add the same alias if Network
is referenced elsewhere (the other occurrence around the second mention at line
156); this preserves source compatibility for one release while guiding users to
migrate to DashSDKNetwork.

In
`@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift`:
- Around line 4-27: Add a SwiftUI preview for the EmptyStateView so it's
viewable in Xcode: create a preview provider (e.g., EmptyStateView_Previews
conforming to PreviewProvider or use the `#Preview` block) that returns
EmptyStateView with example values for systemImage, title, and message (for
example "doc.plaintext", "No Items", "There are no items to display at this
time") so you can iterate on the design during development.
🪄 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: 241a5d97-568a-4a47-ac54-46df2538c9b3

📥 Commits

Reviewing files that changed from the base of the PR and between 11d80f5 and f218b47.

📒 Files selected for processing (90)
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/TransactionTests.swift
💤 Files with no reviewable changes (81)
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/TransactionTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swift

@ZocoLini ZocoLini force-pushed the chore/remove-unused branch from f218b47 to af6e647 Compare April 9, 2026 01:15
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift (1)

36-39: ⚠️ Potential issue | 🟠 Major

Initialization remains re-entrant and can duplicate background sync work.

Line 38 calls unifiedState.initialize() unconditionally from .task. UnifiedAppState.initialize() (packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift, Lines 71-101) starts periodic sync jobs, and Retry (packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ContentView.swift, Lines 39-43) can invoke it again.

Suggested mitigation in this file
                 .task {
+                    guard !unifiedState.isInitialized else { return }
                     SDKLogger.log("🚀 SwiftExampleApp: Starting initialization...", minimumLevel: .medium)
                     await unifiedState.initialize()
                     SDKLogger.log("🚀 SwiftExampleApp: Initialization complete", minimumLevel: .medium)
                 }

Also make UnifiedAppState.initialize() idempotent with an isInitializing guard so lifecycle/task retries cannot overlap.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift`
around lines 36 - 39, The .task in SwiftExampleAppApp.swift currently calls
unifiedState.initialize() unconditionally which allows re-entrant initialization
and duplicate background sync; update the .task call to first check a
readiness/initialized flag on unifiedState (or a new isInitialized property) and
only call unifiedState.initialize() when not already initialized, and
concurrently make UnifiedAppState.initialize() idempotent by adding an internal
isInitializing/isInitialized guard: on entry return early if isInitializing or
isInitialized, set isInitializing true while performing setup, set isInitialized
true and isInitializing false on completion (and handle errors to reset
isInitializing), and ensure any other callers like Retry in ContentView.swift
consult the same isInitialized/isInitializing state instead of calling
initialize() unconditionally.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift`:
- Line 7: The init?(handle:) currently discards the passed
UnsafeMutablePointer<IdentityHandle> causing leaks and warnings; fix by adding a
stored property (e.g., private var handle:
UnsafeMutablePointer<IdentityHandle>?) on the Identity type, assign the incoming
handle in init?(handle:) (returning nil if handle is nil/invalid), and implement
deinit to call the appropriate FFI release function for IdentityHandle (e.g.,
identity_handle_free or IdentityHandle_release) and nil out the stored pointer
to ensure proper ownership transfer and avoid leaks.

---

Duplicate comments:
In `@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift`:
- Around line 36-39: The .task in SwiftExampleAppApp.swift currently calls
unifiedState.initialize() unconditionally which allows re-entrant initialization
and duplicate background sync; update the .task call to first check a
readiness/initialized flag on unifiedState (or a new isInitialized property) and
only call unifiedState.initialize() when not already initialized, and
concurrently make UnifiedAppState.initialize() idempotent by adding an internal
isInitializing/isInitialized guard: on entry return early if isInitializing or
isInitialized, set isInitializing true while performing setup, set isInitialized
true and isInitializing false on completion (and handle errors to reset
isInitializing), and ensure any other callers like Retry in ContentView.swift
consult the same isInitialized/isInitializing state instead of calling
initialize() unconditionally.
🪄 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: b9956e68-e9c1-4f75-85d5-5e896a50068d

📥 Commits

Reviewing files that changed from the base of the PR and between f218b47 and af6e647.

📒 Files selected for processing (90)
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/TransactionTests.swift
💤 Files with no reviewable changes (81)
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.md
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/TransactionTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swift
✅ Files skipped from review due to trivial changes (5)
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift

Comment thread packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift
@ZocoLini ZocoLini force-pushed the chore/remove-unused branch from af6e647 to e5b5275 Compare April 9, 2026 01:28
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift (1)

36-39: ⚠️ Potential issue | 🟠 Major

.task still allows repeated initialization (previously flagged).

At Line 36, await unifiedState.initialize() is unconditional. Since .task can re-run, initialization side effects may execute multiple times unless initialize() is explicitly re-entrancy-safe.

Suggested mitigation in this file
                 .task {
+                    guard !unifiedState.isInitialized else { return }
                     SDKLogger.log("🚀 SwiftExampleApp: Starting initialization...", minimumLevel: .medium)
                     await unifiedState.initialize()
                     SDKLogger.log("🚀 SwiftExampleApp: Initialization complete", minimumLevel: .medium)
                 }
#!/bin/bash
set -euo pipefail

echo "== Verify initialize() guards in UnifiedAppState =="
rg -n -C4 'func initialize\(\)|isInitialized|isInitializing' \
  packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift

echo
echo "== Verify initialize() call sites from SwiftUI task/retry paths =="
rg -n -C3 '\.task\s*\{|await unifiedState\.initialize\(\)|initialize\(\)' \
  packages/swift-sdk/SwiftExampleApp/SwiftExampleApp

Expected verification result: if initialize() lacks an isInitializing/isInitialized early-return guard and call sites are unconditional, the re-entrancy risk is confirmed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift`
around lines 36 - 39, The .task block currently calls await
unifiedState.initialize() unconditionally which can run multiple times; make
initialize() re-entrancy-safe by adding an early-return guard (e.g.,
isInitializing/isInitialized flags) inside UnifiedAppState.initialize() to
prevent concurrent or repeated work, or alternatively check a public
isInitialized property before calling initialize() from the .task; update the
UnifiedAppState methods (initialize, any async setup helpers) to set
isInitializing at start, set isInitialized on success, and short-circuit if
already initializing/initialized to ensure idempotence.
🧹 Nitpick comments (2)
packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift (2)

57-57: Centralize the default network constant to avoid coupling to FFI raw values.

Line 57 hard-codes DashSDKNetwork(rawValue: 1) for testnet. Since DashSDKNetwork is FFI-generated and lacks named enum cases, define a module-level constant (e.g., let defaultNetwork = DashSDKNetwork(rawValue: 1)) or use the existing AppNetwork.testnet.sdkNetwork property. This eliminates duplication—the same pattern appears in SPVClient.swift and other locations.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift` at line 57, Replace the
hard-coded DashSDKNetwork(rawValue: 1) used to initialize the SDK.network
property with a single centralized constant or existing helper instead of
repeating the FFI raw value; e.g., introduce a module-level constant
(defaultNetwork) of type DashSDKNetwork and use it to set public private(set)
var network, or reference the existing AppNetwork.testnet.sdkNetwork where
available so SPVClient.swift and other files share the same canonical default.

4-4: Remove the redundant import DashSDKFFI on line 2.

The @_exported import DashSDKFFI on line 4 already imports the module into this file and re-exports it to consumers; the plain import on line 2 is redundant and should be removed.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift` at line 4, Remove the
redundant plain import of DashSDKFFI and keep only the re-exported import;
specifically delete the regular "import DashSDKFFI" line and retain the
"@_exported import DashSDKFFI" statement in SDK.swift so the module is imported
and re-exported exactly once.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift`:
- Around line 36-39: The .task block currently calls await
unifiedState.initialize() unconditionally which can run multiple times; make
initialize() re-entrancy-safe by adding an early-return guard (e.g.,
isInitializing/isInitialized flags) inside UnifiedAppState.initialize() to
prevent concurrent or repeated work, or alternatively check a public
isInitialized property before calling initialize() from the .task; update the
UnifiedAppState methods (initialize, any async setup helpers) to set
isInitializing at start, set isInitialized on success, and short-circuit if
already initializing/initialized to ensure idempotence.

---

Nitpick comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift`:
- Line 57: Replace the hard-coded DashSDKNetwork(rawValue: 1) used to initialize
the SDK.network property with a single centralized constant or existing helper
instead of repeating the FFI raw value; e.g., introduce a module-level constant
(defaultNetwork) of type DashSDKNetwork and use it to set public private(set)
var network, or reference the existing AppNetwork.testnet.sdkNetwork where
available so SPVClient.swift and other files share the same canonical default.
- Line 4: Remove the redundant plain import of DashSDKFFI and keep only the
re-exported import; specifically delete the regular "import DashSDKFFI" line and
retain the "@_exported import DashSDKFFI" statement in SDK.swift so the module
is imported and re-exported exactly once.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4b0c9723-098e-4170-a31f-d6e20222a8e5

📥 Commits

Reviewing files that changed from the base of the PR and between af6e647 and e5b5275.

📒 Files selected for processing (90)
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/TransactionTests.swift
💤 Files with no reviewable changes (81)
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.md
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/TransactionTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swift
✅ Files skipped from review due to trivial changes (4)
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swift
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swift

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

✅ DashSDKFFI.xcframework built for this PR.

SwiftPM (host the zip at a stable URL, then use):

.binaryTarget(
  name: "DashSDKFFI",
  url: "https://your.cdn.example/DashSDKFFI.xcframework.zip",
  checksum: "da5bc8c5f24bf393a3bd633cc2ff73e2ed2ec0a36803939e1c43e54f954c4f43"
)

Xcode manual integration:

  • Download 'DashSDKFFI.xcframework' artifact from the run link above.
  • Drag it into your app target (Frameworks, Libraries & Embedded Content) and set Embed & Sign.
  • If using the Swift wrapper package, point its binaryTarget to the xcframework location or add the package and place the xcframework at the expected path.

Copy link
Copy Markdown
Collaborator

@thepastaclaw thepastaclaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This cleanup removes a lot of genuinely dead Swift code, but it also deletes still-live SDK surface without updating the package's own remaining consumers. The current branch leaves two in-repo test targets uncompilable: Tests/SwiftDashSDKTests/KeyWallet/WalletSerializationTests.swift still uses the standalone WalletManager API that this PR removed, and SwiftTests/Tests/SwiftDashSDKTests/PlatformWalletTypesTests.swift still relies on the public Network alias that disappeared with SwiftDashSDK.swift. I also verified one lower-severity regression in the example app: deleting its Keychain wrapper changes the service name used to look up stored private keys, so existing app data becomes inaccessible after upgrade. A louder FFI lifetime warning from one agent was dropped because the implicated WalletService.swift code is not part of this diff.

Reviewed commit: e5b5275

🔴 2 blocking | 🟡 1 suggestion(s)

1 additional finding

🟡 suggestion: Hard-coding the shared Keychain service strands the example app's previously stored keys

packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift (lines 33-44)

After this change KeychainManager.shared is always backed by the SDK default service name com.dash.sdk.keys. The deleted packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift wrapper was the only thing keeping the example app on its legacy service name com.dash.swiftexampleapp.keys, and the remaining views still resolve KeychainManager.shared from the app code (KeysListView.swift:104,353, KeyDetailView.swift:16,171,193). That means users who already had private keys stored by earlier versions of the example app will suddenly stop seeing them after this upgrade, because the keys remain in the Keychain under the old service name that nothing queries anymore. Even if this is only sample-app code, that behavioral change deserves either a migration path or retention of the legacy wrapper.

🤖 Prompt for all review comments with AI agents
These findings are from an automated code review. Verify each finding against the current code and only fix it if needed.

In `packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swift`:
- [BLOCKING] lines 5-12: Removing the standalone `WalletManager` API leaves the package's own KeyWallet tests uncompilable
  This branch deletes the public `WalletManager` entry points that the remaining `packages/swift-sdk/Tests/SwiftDashSDKTests/KeyWallet/WalletSerializationTests.swift` target still uses. After the change, the only initializer left on `WalletManager` is `internal init(handle:)`, so calls like `let manager = try WalletManager()` at lines 8, 29, 52, 71, 82, 101, 108, 134, and 154 can no longer compile. The same test file also still calls `addWalletAndSerialize(..., network: ...)` (lines 14-21, 57-64, 87-94, 146-149), `getWalletIds()` (lines 38-39, 162), and `getReceiveAddress(..., network: ...)` (lines 45-46, 77), but the current `WalletManager` implementation has already removed those signatures. If this API is intentionally being retired, the tests and any documented migration path need to be updated in the same PR; otherwise the package is left in a self-inconsistent state.

In `packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift`:
- [BLOCKING] lines 1-4: Deleting `SwiftDashSDK.swift` removes public aliases that the remaining SwiftTests target still imports
  The deleted `Sources/SwiftDashSDK/SwiftDashSDK.swift` file was the public compatibility shim that re-exported `Network = DashSDKNetwork`, `ErrorCode = DashSDKErrorCode`, and `SDKConfig = DashSDKConfig`. This PR removes that file and switches `SDK.swift` over to the raw FFI types instead, but `packages/swift-sdk/SwiftTests/Tests/SwiftDashSDKTests/PlatformWalletTypesTests.swift` still references `Network.mainnet/testnet/devnet/local` at lines 9-12. So the branch is not just making a theoretical external API break: it leaves an in-repo test target uncompilable unless you either keep the aliases or update the target in the same change. Because this PR is presented as dead-code cleanup rather than an intentional Swift SDK breaking change, the compatibility shim should not disappear silently.

In `packages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swift`:
- [SUGGESTION] lines 33-44: Hard-coding the shared Keychain service strands the example app's previously stored keys
  After this change `KeychainManager.shared` is always backed by the SDK default service name `com.dash.sdk.keys`. The deleted `packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swift` wrapper was the only thing keeping the example app on its legacy service name `com.dash.swiftexampleapp.keys`, and the remaining views still resolve `KeychainManager.shared` from the app code (`KeysListView.swift:104,353`, `KeyDetailView.swift:16,171,193`). That means users who already had private keys stored by earlier versions of the example app will suddenly stop seeing them after this upgrade, because the keys remain in the Keychain under the old service name that nothing queries anymore. Even if this is only sample-app code, that behavioral change deserves either a migration path or retention of the legacy wrapper.

Comment thread packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
@ZocoLini ZocoLini marked this pull request as draft April 9, 2026 18:07
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