Skip to content

feat: add concrete SpvClient UniFFI object#13

Closed
xdustinface wants to merge 3 commits into
v0.42-devfrom
claude/issue-7-20260313-1135
Closed

feat: add concrete SpvClient UniFFI object#13
xdustinface wants to merge 3 commits into
v0.42-devfrom
claude/issue-7-20260313-1135

Conversation

@xdustinface
Copy link
Copy Markdown
Owner

Implements the concrete SpvClient UniFFI wrapper for DashSpvClient.

Closes #7

  • uniffi::Enum on MempoolStrategy, uniffi::Record on ClientConfig
  • custom_type! mappings for SocketAddr and PathBuf
  • max_mempool_transactions changed from usize to u64 (UniFFI compat)
  • SpvClient UniFFI object with lifecycle (new, start, stop) and state queries

- Add `#[cfg_attr(feature = "uniffi", derive(uniffi::Enum))]` to `MempoolStrategy`
- Add `#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]` to `ClientConfig`
- Change `max_mempool_transactions: usize` → `u64` for UniFFI compatibility
- Add `custom_type!` mappings for `SocketAddr` and `PathBuf` in bridge module
- Make `DashSpvClient::start()` public (was `pub(super)`)
- Implement `SpvClient` UniFFI object wrapping the concrete type
  `DashSpvClient<WalletManager<ManagedWalletInfo>, PeerNetworkManager, DiskStorageManager>`
- Export: `new()`, `start()`, `stop()`, `shutdown()`, `is_running()`,
  `tip_height()`, `tip_hash()`, `peer_count()`, `sync_progress()`, `is_syncing()`
- Add `SpvClientError` uniffi::Error enum mapped from `SpvError`
- Unit tests for construction and state queries

Closes #7

Co-authored-by: Kevin Rombach <xdustinface@users.noreply.github.com>
@xdustinface
Copy link
Copy Markdown
Owner Author

@claude CI is failing with a compilation error in bridge/mod.rs line 105: type mismatch in map_err(SpvError::Network). The PeerNetworkManager::new error type may not match what SpvError::Network expects. Also run cargo fmt before committing — pre-commit checks are also failing with formatting issues. Fix the compilation error first, then format.

@claude
Copy link
Copy Markdown

claude Bot commented Mar 13, 2026

Claude finished @xdustinface's task in 5m 5s —— View job


Fixing CI compilation error and formatting

  • Gather context
  • Read bridge/mod.rs to understand the type mismatch
  • Fix compilation error (map_err(SpvError::Network) type mismatch)
  • Apply formatting fix (collapse SocketAddr try_lift closure to single line)
  • Commit and push changes

Root cause

PeerNetworkManager::new is declared in manager.rs as:

use crate::error::{NetworkError, NetworkResult, SpvError as Error};
// ...
pub async fn new(config: &ClientConfig) -> Result<Self, Error>

It returns Result<_, SpvError>already the top-level error type. The original code then called .map_err(SpvError::Network), but SpvError::Network is a variant constructor fn(NetworkError) -> SpvError, expecting a NetworkError argument, not a SpvError. Hence the type mismatch.

Changes made (30554bb)

Compilation fix (bridge/mod.rs):

  • PeerNetworkManager::new: drop the erroneous map_err(SpvError::Network) and convert directly with .map_err(SpvClientError::from).
  • DiskStorageManager::new: replace the two-step conversion through SpvError::from (ambiguous across many From impls) with an explicit inline closure |e| SpvClientError::Storage { message: e.to_string() }.

Formatting fix:

  • Collapse the SocketAddr try_lift closure to a single line (85 chars, within the project's max_width = 100 rustfmt setting).

Note: I was unable to run cargo fmt directly due to tool approval restrictions. If further formatting issues surface in CI, please run cargo fmt locally and push the result (or approve the cargo fmt tool in Claude's settings).
| Branch

- `PeerNetworkManager::new` returns `Result<_, SpvError>` (it aliases
  `SpvError` as `Error` in manager.rs), so the original
  `map_err(SpvError::Network)` was wrong — that variant constructor
  expects a `NetworkError`, not the `SpvError` already returned.
  Fix: use `.map_err(SpvClientError::from)` directly.

- `DiskStorageManager::new` returns `StorageResult` (`StorageError`);
  replace the two-step conversion via `SpvError::from` (ambiguous with
  many `From` impls) with an explicit inline closure.

- Collapse the `SocketAddr` `try_lift` closure to a single line (85 chars)
  per the project's `max_width = 100` rustfmt setting.

Co-authored-by: Kevin Rombach <xdustinface@users.noreply.github.com>
@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 68.75000% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 65.91%. Comparing base (f80f96c) to head (30554bb).

Files with missing lines Patch % Lines
dash-spv/src/bridge/mod.rs 68.42% 24 Missing ⚠️
dash-spv/src/client/mempool.rs 0.00% 1 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev      #13      +/-   ##
=============================================
+ Coverage      65.89%   65.91%   +0.01%     
=============================================
  Files            312      312              
  Lines          64607    64683      +76     
=============================================
+ Hits           42573    42636      +63     
- Misses         22034    22047      +13     
Flag Coverage Δ
core 75.02% <ø> (ø)
ffi 36.60% <ø> (ø)
rpc 19.92% <ø> (ø)
spv 81.11% <68.75%> (+0.01%) ⬆️
wallet 65.68% <ø> (ø)
Files with missing lines Coverage Δ
dash-spv/src/client/config.rs 92.45% <100.00%> (ø)
dash-spv/src/client/lifecycle.rs 63.46% <100.00%> (ø)
dash-spv/src/client/mempool.rs 57.57% <0.00%> (ø)
dash-spv/src/bridge/mod.rs 75.22% <68.42%> (-15.68%) ⬇️

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

@xdustinface
Copy link
Copy Markdown
Owner Author

@claude The pre-commit checks are still failing on all 3 platforms due to formatting issues. Please run cargo fmt --all and push.

@claude
Copy link
Copy Markdown

claude Bot commented Mar 13, 2026

Claude finished @xdustinface's task in 32s —— View job


Fixing formatting issues

  • Gather context
  • Run cargo fmt --all
  • Commit and push changes

Blocked: cargo fmt requires tool approval

I attempted to run cargo fmt --all but it requires explicit approval in your Claude Code permissions settings.

Options to unblock:

  1. Approve the tool — In your Claude Code settings, add cargo (or cargo fmt) to the allowed tools list, then re-trigger with @claude.

  2. Run locally and push — Run the following commands locally:

    cargo fmt --all
    git add -A
    git commit -m "style: apply cargo fmt --all"
    git push

This is the same limitation noted in my previous comment. The formatting fix must be applied either via approved tool execution or manually.

Branch

@xdustinface xdustinface force-pushed the claude/issue-7-20260313-1135 branch from 88aa976 to 033ee86 Compare March 13, 2026 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add concrete SpvClient UniFFI object for DashSpvClient

2 participants