chore(swift-sdk): remove unused code in the swift-sdk and example app#3463
chore(swift-sdk): remove unused code in the swift-sdk and example app#3463
Conversation
📝 WalkthroughWalkthroughThis 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 Changes
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
91ee92a to
f218b47
Compare
|
✅ Review complete (commit e5b5275) |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift (1)
55-56: Consider a temporary compatibility shim for theNetwork→DashSDKNetworkpublic 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
📒 Files selected for processing (90)
packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Identity.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swiftpackages/swift-sdk/Sources/SwiftDashSDK/SDK.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.mdpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swiftpackages/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
f218b47 to
af6e647
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift (1)
36-39:⚠️ Potential issue | 🟠 MajorInitialization remains re-entrant and can duplicate background sync work.
Line 38callsunifiedState.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 anisInitializingguard 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
📒 Files selected for processing (90)
packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Identity.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swiftpackages/swift-sdk/Sources/SwiftDashSDK/SDK.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.mdpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swiftpackages/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
af6e647 to
e5b5275
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift (1)
36-39:⚠️ Potential issue | 🟠 Major
.taskstill allows repeated initialization (previously flagged).At Line 36,
await unifiedState.initialize()is unconditional. Since.taskcan re-run, initialization side effects may execute multiple times unlessinitialize()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/SwiftExampleAppExpected verification result: if
initialize()lacks anisInitializing/isInitializedearly-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. SinceDashSDKNetworkis FFI-generated and lacks named enum cases, define a module-level constant (e.g.,let defaultNetwork = DashSDKNetwork(rawValue: 1)) or use the existingAppNetwork.testnet.sdkNetworkproperty. 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 redundantimport DashSDKFFIon line 2.The
@_exported import DashSDKFFIon 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
📒 Files selected for processing (90)
packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVClient.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/DataContractParser.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/CoreWalletManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Core/Wallet/WalletStorage.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDataContract.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPDocument.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swiftpackages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPStateTransition.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/PlatformQueryExtensions.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/Signer.swiftpackages/swift-sdk/Sources/SwiftDashSDK/FFI/StateTransitionExtensions.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Helpers/TestKeyGenerator.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Identity.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/AccountCollection.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Address.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BLSAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/EdDSAAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyDerivation.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWalletTypes.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedAccountCollection.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedPlatformAccount.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/ManagedWallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Mnemonic.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Transaction.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/Wallet.swiftpackages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/WalletManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/IdentityModel.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/Network.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Models/TokenAction.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentToken.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Models/PersistentTokenHistoryEvent.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Persistence/Types/TokenTypes.swiftpackages/swift-sdk/Sources/SwiftDashSDK/SDK.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Security/KeychainManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Services/DataManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swiftpackages/swift-sdk/Sources/SwiftDashSDK/SwiftDashSDK.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/ErrorHandling.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/PrivateKeyUtils.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/StateManagement.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Utils/Validation.swiftpackages/swift-sdk/Sources/SwiftDashSDK/Wallet/WalletModels.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.mdpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/IdentityBalanceExample.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SDK/SDKExtensions.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Services/KeychainManager.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/UnifiedAppState.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/TestKeyGenerator.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Version.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/ViewModels/BaseViewModel.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentFieldsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentTypeDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DocumentsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/EmptyStateView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/IdentitiesView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/LocalDataContractsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokensView.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ErrorHandlingTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/KeyManagerTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/StateManagementTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/ValidationTests.swiftpackages/swift-sdk/SwiftExampleApp/SwiftExampleAppTests/WalletTests/KeyDerivationTests.swiftpackages/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
|
✅ 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:
|
thepastaclaw
left a comment
There was a problem hiding this comment.
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.
Removed a bunch of dead and redundant code in the codebase following a couple of rules:
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
New Features
Tests