Skip to content

chore(swift-sdk): define missing spv client event OnTransactionStatusChanged#3487

Open
ZocoLini wants to merge 1 commit intov3.1-devfrom
chore/missing-event
Open

chore(swift-sdk): define missing spv client event OnTransactionStatusChanged#3487
ZocoLini wants to merge 1 commit intov3.1-devfrom
chore/missing-event

Conversation

@ZocoLini
Copy link
Copy Markdown
Collaborator

@ZocoLini ZocoLini commented Apr 13, 2026

In this PR I am implementing a missing wrapper for the OnTransactionStatusChanged event in the SPVClient that was missing after PR #3414

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have added "!" to the title and described breaking changes in the corresponding section if my code contains any
  • I have made corresponding changes to the documentation if needed

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

Summary by CodeRabbit

  • New Features
    • Added transaction status monitoring to wallet event handling, enabling the SDK to detect and respond to transaction status updates.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 13, 2026

📝 Walkthrough

Walkthrough

The changes introduce a new transaction status change event callback to the Swift SDK's SPV wallet event handling system, extending the protocol with onTransactionStatusChanged, implementing FFI-C bridging, and providing concrete implementations across the wallet service layer.

Changes

Cohort / File(s) Summary
SPV Event Handler Protocol & FFI Bridge
packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVEventHandler.swift
Added protocol requirement onTransactionStatusChanged to SPVWalletEventsHandler; implemented C-callback onSpvTransactionStatusChangedCallbackC for FFI data conversion and handler invocation; wired FFI function pointer; added no-op stub to DummySPVWalletEventsHandler.
Wallet Service Event Handler
packages/swift-sdk/Sources/SwiftDashSDK/Core/Services/WalletService.swift
Added empty implementation of onTransactionStatusChanged to WalletService.SPVWalletEventsHandlerImpl to satisfy protocol conformance.

Sequence Diagram

sequenceDiagram
    participant FFI as FFI Layer
    participant Callback as C Callback Handler
    participant Handler as SPVWalletEventsHandler
    participant Service as WalletService Impl
    
    FFI->>Callback: onSpvTransactionStatusChangedCallbackC(walletIdPtr, txIdPtr, status, userData)
    Callback->>Callback: Resolve handler from userData
    Callback->>Callback: Validate walletIdPtr
    Callback->>Callback: Convert txIdPtr (32 bytes) to Data
    Callback->>Callback: Convert status to TransactionContext
    Callback->>Handler: onTransactionStatusChanged(walletId, txId, status)
    Handler->>Service: onTransactionStatusChanged(walletId, txId, status)
    Service-->>Handler: (completes)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 A rabbit hops through transaction flows,
Where status changes gently rose,
From C to Swift, the data flows,
Event handlers now bestow,
What wallets need to know! 🌟

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'define missing spv client event OnTransactionStatusChanged' directly and clearly describes the main change—adding the missing OnTransactionStatusChanged event wrapper to the SPV client.

✏️ 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 chore/missing-event

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 13, 2026
@ZocoLini ZocoLini marked this pull request as ready for review April 13, 2026 22:40
@thepastaclaw
Copy link
Copy Markdown
Collaborator

thepastaclaw commented Apr 13, 2026

Review Gate

Commit: 0ed861a2

  • Debounce: 546m ago (need 30m)

  • CI checks: build failure: PR title

  • CodeRabbit review: comment found

  • Off-peak hours: off-peak (12:42 AM PT Tuesday)

  • Run review now (check to override)

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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/Core/SPV/SPVEventHandler.swift`:
- Around line 547-569: The callback onSpvTransactionStatusChangedCallbackC
currently converts a nil txIdPtr into empty Data and still calls
handler.onTransactionStatusChanged, so guard txIdPtr before converting and
dispatching; inside onSpvTransactionStatusChangedCallbackC (which uses
rawPtrIntoSpvWalletEventsHandler, bytePtrIntoData and TransactionContext(ffi:)),
add a guard let txIdPtr else { assertionFailure("TransactionStatusChanged txId
pointer is nil"); return } before calling bytePtrIntoData and only call
handler.onTransactionStatusChanged(walletId, txId, status) when txId is valid.
🪄 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: 78c89766-cabf-4683-8651-593253ca5eb5

📥 Commits

Reviewing files that changed from the base of the PR and between c061bd4 and 0ed861a.

📒 Files selected for processing (2)
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/SPV/SPVEventHandler.swift
  • packages/swift-sdk/Sources/SwiftDashSDK/Core/Services/WalletService.swift

@github-actions
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: "588b895d6b2ca64d4b5ded9704c6516c16c383406528dddf978b964e907feb89"
)

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.

@ZocoLini ZocoLini changed the title define missing spv client event OnTransactionStatusChanged chore(swift-sdk): define missing spv client event OnTransactionStatusChanged Apr 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants