Skip to content

refactor(swift-sdk): lean down stale app and SDK layers - #3539

Merged
QuantumExplorer merged 9 commits into
v3.1-devfrom
codex/swift-sdk-lean-wave1
Apr 27, 2026
Merged

QuantumExplorer merged 9 commits into
v3.1-devfrom
codex/swift-sdk-lean-wave1

Conversation

@llbartekll

@llbartekll llbartekll commented Apr 25, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • remove SwiftExampleApp shim/re-export model layers and dead app state
  • remove broken placeholder Swift SDK fetch stubs
  • consolidate identity-key public types into DPP model files without renaming symbols
  • delete stale Swift SDK markdown/report artifacts and placeholder BIP38 references

Validation

  • source searches pass for removed symbols and stale files
  • xcodebuild reaches the known existing platform-wallet FFI link failure; touched Swift files compile before link

Notes

  • no JS changes
  • persistence schema shape is intentionally unchanged
  • StateTransitionExtensions cleanup and PersistentDataContract storage dedup are intentionally left for later waves

Summary by CodeRabbit

  • New Features

    • Added richer identity/public-key models and core DPP type aliases; persistence schema expanded to include address model.
  • Breaking Changes

    • Removed several legacy wrapper types and backward-compatible aliases used by the example app.
    • Removed SDK contract and identity lookup APIs and the unified state manager.
    • BIP38 docs/stubs and many app shims removed.
  • Documentation

    • Multiple Swift SDK implementation, migration, and test verification guides removed.

@coderabbitai

coderabbitai Bot commented Apr 25, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2ad9bf75-2b31-4532-aefd-796ee71faac2

📥 Commits

Reviewing files that changed from the base of the PR and between bc6018e and 51a1c12.

📒 Files selected for processing (5)
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Utils/ContractDownloader.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swift
✅ Files skipped from review due to trivial changes (1)
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenDetailsView.swift
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractsView.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift

📝 Walkthrough

Walkthrough

Removes many Swift SDK and example-app compatibility shims and documentation, deletes several wrapper types and a state manager, adds DPP identity/key types and a SwiftData model entry, and updates example app wiring and view imports.

Changes

Cohort / File(s) Summary
Documentation deletions
packages/swift-sdk/IDENTITY_API_FIXES_SUMMARY.md, packages/swift-sdk/IMPLEMENTATION_SUMMARY.md, packages/swift-sdk/TEST_FIX_SUMMARY.md, packages/swift-sdk/TEST_VERIFICATION.md, packages/swift-sdk/WALLET_IMPLEMENTATION_SUMMARY.md, packages/swift-sdk/ios_to_dash_api_mapping.md
Removed multiple implementation, mapping, test verification, and wallet guidance documents.
New DPP identity types
packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift, packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPTypes.swift
Adds KeyType, KeyPurpose, SecurityLevel, IdentityPublicKey, ContractBounds, and public typealiases (KeyID, BinaryData, TimestampMillis, Identifier).
Removed identity wrappers & legacy types
packages/swift-sdk/Sources/SwiftDashSDK/IdentityTypes.swift, packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift, packages/swift-sdk/Sources/SwiftDashSDK/DataContract.swift
Deletes legacy Identity, DataContract wrappers and prior identity-type definitions/typealiases; removes duplicate/placeholder implementations.
SDK API surface changes
packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
Removes contracts property and async lookup APIs (getIdentity, getDataContract) and deletes Contracts helper type.
State & model helpers removed
packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift, packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift
Deletes ModelContainerHelper factory and the UnifiedStateManager observable plus its asset/transfer model types and APIs.
KeyWallet docs/placeholder removed
packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift, packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift, packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/README.md
Removes BIP38 placeholder file, related README/docs, and a commented re-export stub.
Persistence schema update
packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
Adds PersistentCoreAddress.self to DashModelContainer.modelTypes (expands SwiftData schema).
Example app: removed compatibility shims (many)
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/..., packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/...
Deletes numerous app-level typealias shims and re-exports for DPP and SwiftData models (Persistent*/DPP* aliases), plus app-side keychain helper extensions on PersistentPublicKey.
Example app state & wiring
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift, packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/SwiftExampleAppApp.swift
Removes persisted dataContracts, local flags, and loadPersistedData(); replaces ModelContainerHelper.createContainer() with DashModelContainer.create() and removes unifiedStateManager injection.
Views: fetch flow & imports
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractsView.swift, .../DataContractDetailsView.swift, .../DocumentFieldsView.swift, .../DocumentTypeDetailsView.swift, .../TokenDetailsView.swift, .../TokenSearchView.swift
Refactors ContractsView.fetchContract() to use defer, sdk.dataContractGet(), validation, duplicate prevention and persistence; adds SwiftDashSDK imports to multiple view files.
App model container helper removed
packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
Deletes app-level ModelContainer factory and re-exported migration/schema aliases.
Misc
.gitignore
Adds ignores for packages/swift-sdk/build/ and .claude/settings.local.json.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FetchContractView
    participant SDK as SwiftDashSDK
    participant ModelContext
    participant Parser as DataContractParser

    User->>FetchContractView: tap Fetch
    FetchContractView->>SDK: dataContractGet(trimmedId)
    SDK-->>FetchContractView: Data (contractBytes)
    FetchContractView->>FetchContractView: validate id, check duplicates
    alt not duplicate
        FetchContractView->>ModelContext: insert PersistentDataContract(contractBytes)
        ModelContext-->>FetchContractView: saved
        FetchContractView->>Parser: parseDataContract(contractBytes)
        Parser-->>ModelContext: parsed documents/metadata -> save
        FetchContractView-->>User: success (dismiss)
    else duplicate / invalid id
        FetchContractView-->>User: error (show)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I hopped through code with twitchy feet,

Old wrappers shed, new keys to meet,
Docs trimmed back, the schema grown,
Views now call the SDK they've known,
A burrow tidied, fresh and neat. 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 38.46% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'refactor(swift-sdk): lean down stale app and SDK layers' is fully related to the main changes in the pull request, which comprehensively remove obsolete code, stale documentation, and broken placeholder implementations from both the Swift SDK and example app layers.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 codex/swift-sdk-lean-wave1

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added this to the v3.1.0 milestone Apr 25, 2026
@llbartekll
llbartekll marked this pull request as ready for review April 25, 2026 17:00
@thepastaclaw

thepastaclaw commented Apr 25, 2026 •

Copy link
Copy Markdown
Collaborator

Review Gate

Commit: 51a1c121

  • ✅ Debounce: 190m ago (need 30m)

  • ✅ CI checks: builds passed, 0/2 tests passed

  • ✅ CodeRabbit review: comment found

  • ⏳ Off-peak hours: peak window (5am-11am PT) — currently 06:24 AM PT Monday

  • Run review now (check to override)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift (2)

117-122: Minor: isDisabled evaluates current time on every access.

Date().timeIntervalSince1970 * 1000 is recomputed for every read of isDisabled, and the Double → UInt64 conversion silently truncates sub-millisecond precision. Functionally fine, but if this is hot-pathed (e.g. inside SwiftUI bodies), prefer accepting an explicit now: TimestampMillis parameter on a method (isDisabled(at:)) so callers control the clock and tests stay deterministic.

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

In `@packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift` around lines
117 - 122, The isDisabled computed property currently samples Date() on every
access and truncates sub-millisecond precision; replace this hot-path property
with a deterministic method isDisabled(at: TimestampMillis) that takes an
explicit now parameter (using the existing TimestampMillis type) and implement
the existing isDisabled to call isDisabled(at:
TimestampMillis(Date().timeIntervalSince1970 * 1000)) if you want to keep the
convenience property; update callers/tests to pass a controlled TimestampMillis
to isDisabled(at:) for deterministic behavior and avoid repeated Date() sampling
in hot paths.

51-61: Consider conforming to CustomStringConvertible (or rename) for the description properties.

KeyPurpose (lines 51-61), SecurityLevel (lines 86-93), and ContractBounds (lines 151-158) each expose a public description: String but do not conform to CustomStringConvertible. In Swift this is a known foot-gun: String(describing: value), "\(value)", and print(value) will fall back to the reflection-based default and silently bypass these custom strings. Either conform to the protocol so the helper is actually picked up, or rename to e.g. summary / humanReadable to avoid shadowing the standard semantics.

♻️ Example fix for `ContractBounds`
-public enum ContractBounds: Codable, Equatable, Sendable {
+public enum ContractBounds: Codable, Equatable, Sendable, CustomStringConvertible {
     case singleContract(id: Identifier)
     case singleContractDocumentType(id: Identifier, documentTypeName: String)

Apply the analogous change to KeyPurpose and SecurityLevel.

Also applies to: 86-93, 151-158

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

In `@packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift` around lines
51 - 61, The enums KeyPurpose, SecurityLevel, and ContractBounds expose public
description properties but don't conform to CustomStringConvertible; update each
enum declaration to adopt CustomStringConvertible (e.g., "enum KeyPurpose:
CustomStringConvertible") so their existing public var description: String
implementations are actually used by String(describing:) / print, or
alternatively rename the property (e.g., summary or humanReadable) if you
intentionally don't want the protocol; ensure the signature remains public and
remove any conflicting members so the compiler accepts the protocol conformance
for KeyPurpose, SecurityLevel, and ContractBounds.
🤖 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/DPP/DPPIdentity.swift`:
- Around line 151-158: In DPPIdentity.swift update the description computed
property for the enum cases singleContract and singleContractDocumentType to
call the established Data method name: replace id.toBase58() with
id.toBase58String() so the switch arms in var description use the same
toBase58String() convention used elsewhere (e.g., lines ~181/215 and other call
sites).

In
`@packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift`:
- Line 24: The change adds PersistentCoreAddress.self to
DashModelContainer.modelTypes which mutates DashSchemaV1 in place; either
document that this is an intentional lightweight SwiftData migration or create
an explicit new schema/version and migration stage. Fix by adding a clear
comment on DashSchemaV1 (or DashMigrationPlan) stating that adding
PersistentCoreAddress is additive and safe for lightweight migration, or
alternatively add a new DashSchemaV2 with version (1,0,1) or (1,1,0), register
DashSchemaV2 in DashMigrationPlan.schemas and add
MigrationStage.lightweight(fromVersion: .init(1,0,0), toVersion: .init(1,0,1))
to DashMigrationPlan so the upgrade is explicit and deterministic; reference
PersistentCoreAddress, DashModelContainer.modelTypes, DashSchemaV1/DashSchemaV2,
DashMigrationPlan, and MigrationStage.lightweight when making the change.

In
`@packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractsView.swift`:
- Around line 258-266: In fetchContract(), don't route success through
appState.showError or discard the returned contract: instead either call a new
success UI (add and use appState.showInfo if you prefer a separate success
surface) or persist the fetched value into the model container so the
`@Query`(PersistentDataContract) updates; specifically, replace the discarded call
to sdk.dataContractGet(id:) by capturing the returned dictionary, map it into a
PersistentDataContract instance, and insert it into the ModelContainer (or call
the existing contract persister) before closing the sheet, and change the
success notification to use a non-error method (e.g., appState.showInfo) or a
neutral UI path instead of appState.showError.

---

Nitpick comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift`:
- Around line 117-122: The isDisabled computed property currently samples Date()
on every access and truncates sub-millisecond precision; replace this hot-path
property with a deterministic method isDisabled(at: TimestampMillis) that takes
an explicit now parameter (using the existing TimestampMillis type) and
implement the existing isDisabled to call isDisabled(at:
TimestampMillis(Date().timeIntervalSince1970 * 1000)) if you want to keep the
convenience property; update callers/tests to pass a controlled TimestampMillis
to isDisabled(at:) for deterministic behavior and avoid repeated Date() sampling
in hot paths.
- Around line 51-61: The enums KeyPurpose, SecurityLevel, and ContractBounds
expose public description properties but don't conform to
CustomStringConvertible; update each enum declaration to adopt
CustomStringConvertible (e.g., "enum KeyPurpose: CustomStringConvertible") so
their existing public var description: String implementations are actually used
by String(describing:) / print, or alternatively rename the property (e.g.,
summary or humanReadable) if you intentionally don't want the protocol; ensure
the signature remains public and remove any conflicting members so the compiler
accepts the protocol conformance for KeyPurpose, SecurityLevel, and
ContractBounds.
🪄 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: da534d62-a8f3-4d32-b2b9-b8a95008f21d

📥 Commits

Reviewing files that changed from the base of the PR and between 2b3486a and 1703d19.

📒 Files selected for processing (44)
  • packages/swift-sdk/IDENTITY_API_FIXES_SUMMARY.md
  • packages/swift-sdk/IMPLEMENTATION_SUMMARY.md
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/IdentityTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/README.md
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.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/SwiftExampleAppApp.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/ContractsView.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/TokenDetailsView.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/TokenSearchView.swift
  • packages/swift-sdk/SwiftTests/TEST_FIX_SUMMARY.md
  • packages/swift-sdk/TEST_VERIFICATION.md
  • packages/swift-sdk/WALLET_IMPLEMENTATION_SUMMARY.md
  • packages/swift-sdk/ios_to_dash_api_mapping.md
💤 Files with no reviewable changes (33)
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/BIP38.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIdentity.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenBalance.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentKeyword.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/README.md
  • packages/swift-sdk/IMPLEMENTATION_SUMMARY.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentIndex.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDataContract.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/KeyWallet/KeyWallet.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Identity.swift
  • packages/swift-sdk/TEST_VERIFICATION.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocumentType.swift
  • packages/swift-sdk/WALLET_IMPLEMENTATION_SUMMARY.md
  • packages/swift-sdk/IDENTITY_API_FIXES_SUMMARY.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentTokenHistoryEvent.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Identity.swift
  • packages/swift-sdk/SwiftTests/TEST_FIX_SUMMARY.md
  • packages/swift-sdk/ios_to_dash_api_mapping.md
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DPPCoreTypes.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentDocument.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/DataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/DataContract.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/StateTransition.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/DPP/Document.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentProperty.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/ModelContainer+App.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentToken.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/SDK.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Models/SwiftData/PersistentPublicKey.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/IdentityTypes.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Shared/UnifiedStateManager.swift

@llbartekll
llbartekll marked this pull request as draft April 25, 2026 17:54
@llbartekll
llbartekll marked this pull request as ready for review April 27, 2026 07:04

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 (1)
packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift (1)

117-122: Minor: isDisabled is time-dependent and non-deterministic.

isDisabled returns different results across calls depending on wall-clock time, which is fine for UI but can surprise tests, caching, or Equatable-based diffing on parent structures. Two small considerations:

  1. If callers compare IdentityPublicKey instances, isDisabled is excluded from Equatable (it's a computed property), so that's safe — just worth being aware of.
  2. Consider exposing isDisabled(at: Date = Date()) so tests can inject a clock without freezing time globally.

Not blocking.

♻️ Optional refactor
-    /// Check if the key is currently disabled
-    public var isDisabled: Bool {
-        guard let disabledAt = disabledAt else { return false }
-        let currentTime = TimestampMillis(Date().timeIntervalSince1970 * 1000)
-        return disabledAt <= currentTime
-    }
+    /// Check if the key is disabled relative to the provided instant (defaults to now).
+    public func isDisabled(at date: Date = Date()) -> Bool {
+        guard let disabledAt = disabledAt else { return false }
+        return disabledAt <= TimestampMillis(date.timeIntervalSince1970 * 1000)
+    }
+
+    /// Convenience: disabled relative to the current wall clock.
+    public var isDisabled: Bool { isDisabled(at: Date()) }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift` around lines
117 - 122, The computed property isDisabled is time-dependent and
non-deterministic; add a new API isDisabled(at timestamp: Date = Date()) -> Bool
that takes an injectable clock and implement the existing public var isDisabled
to call isDisabled(at: Date()), then update any internal uses to call the new
method when a specific time is needed to enable deterministic tests; reference
the existing property isDisabled and the stored property disabledAt when
implementing the check so disabledAt <=
TimestampMillis(timestamp.timeIntervalSince1970 * 1000) is used inside
isDisabled(at:).
🤖 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/DPP/DPPIdentity.swift`:
- Around line 71-103: The Comparable ordering is inverted (lower rawValue ==
stricter level) which is surprising; add a brief doc comment on the
SecurityLevel enum that explains "Comparable uses protocol/rawValue ordering:
lower rawValue = stricter security", and add one or two clearly named helpers to
make call-sites readable — e.g. add func meetsOrExceeds(_ required:
SecurityLevel) -> Bool { return self.rawValue <= required.rawValue } and/or func
isLessSecure(than other: SecurityLevel) -> Bool { return self.rawValue >
other.rawValue } (keep the existing Comparable implementation and ffiValue
as-is). Ensure the new helpers are public and documented so callers can use
key.securityLevel.meetsOrExceeds(requiredLevel) instead of relying on raw '<'
semantics.
- Around line 147-168: ContractBounds' synthesized Codable doesn't match Rust's
externally-tagged serde format; implement custom encode(to:) and init(from:) for
enum ContractBounds so it serializes as {"type":"singleContract", "id":...} and
{"type":"singleContractDocumentType", "id":..., "documentType":...} (note the
inner key must be "documentType" for the second case), using the existing cases
singleContract(id:), singleContractDocumentType(id:documentTypeName:), and the
contractId/description helpers for reference; ensure the "type" field uses
camelCase names ("singleContract" and "singleContractDocumentType") and decode
accordingly, throwing decoding errors for unknown types or missing fields.

---

Nitpick comments:
In `@packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift`:
- Around line 117-122: The computed property isDisabled is time-dependent and
non-deterministic; add a new API isDisabled(at timestamp: Date = Date()) -> Bool
that takes an injectable clock and implement the existing public var isDisabled
to call isDisabled(at: Date()), then update any internal uses to call the new
method when a specific time is needed to enable deterministic tests; reference
the existing property isDisabled and the stored property disabledAt when
implementing the check so disabledAt <=
TimestampMillis(timestamp.timeIntervalSince1970 * 1000) is used inside
isDisabled(at:).
🪄 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: 0dce8d44-44d1-4143-ad1f-afea75b4a04a

📥 Commits

Reviewing files that changed from the base of the PR and between 1703d19 and bc6018e.

📒 Files selected for processing (5)
  • .gitignore
  • packages/swift-sdk/Sources/SwiftDashSDK/DPP/DPPIdentity.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Persistence/DashModelContainer.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
💤 Files with no reviewable changes (1)
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/AppState.swift
✅ Files skipped from review due to trivial changes (2)
  • packages/swift-sdk/SwiftExampleApp/SwiftExampleApp/Views/DataContractDetailsView.swift
  • .gitignore

@github-actions

github-actions Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

✅ 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: "0fde9e97b3cd44d766b39cb2ebaf3324df63b1770e67295473ecdce3326274e2"
)

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.

…ean-wave1

# Conflicts:
#	packages/swift-sdk/Sources/SwiftDashSDK/Core/Utils/ModelContainerHelper.swift
@QuantumExplorer
QuantumExplorer merged commit bb0f59f into v3.1-dev Apr 27, 2026
35 checks passed
@QuantumExplorer
QuantumExplorer deleted the codex/swift-sdk-lean-wave1 branch April 27, 2026 13:30
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.

3 participants