Skip to content

Commit 45b5272

Browse files
feat: build out key-wallet ffi and improve ci (#108)
* key wallet ffi * tests for key-wallet * added tests * more fixes * more fixes * work * clean up * clean up * clean up * more fixes * clean up * fixes * fixes * fixes * a lot of fixes * more work * more work * more work * more work * more work * more work * more work * more work * more work * more work * more work * more work * small improvements * small improvements
1 parent 16d54e7 commit 45b5272

File tree

99 files changed

+19054
-5905
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+19054
-5905
lines changed

.github/strict-checks.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"strict_check_crates": [
3+
"key-wallet",
4+
"key-wallet-manager",
5+
"key-wallet-ffi"
6+
],
7+
"excluded_crates": [
8+
"dash",
9+
"dash-network",
10+
"dash-network-ffi",
11+
"hashes",
12+
"internals",
13+
"fuzz",
14+
"rpc-client",
15+
"rpc-json",
16+
"rpc-integration-test",
17+
"dash-spv",
18+
"dash-spv-ffi",
19+
"test-utils"
20+
],
21+
"comment": "Crates in strict_check_crates will fail CI on any warnings or clippy issues. Add or remove crates as needed."
22+
}

.github/workflows/fuzz.yml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ on:
88
- 'test-ci/**'
99
pull_request:
1010

11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: true
17+
1118
jobs:
1219
fuzz:
1320
if: ${{ !github.event.act }}
@@ -40,19 +47,14 @@ jobs:
4047
- name: Install test dependencies
4148
run: sudo apt-get update -y && sudo apt-get install -y binutils-dev libunwind8-dev libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc libiberty-dev
4249
- uses: actions/checkout@v4
43-
- uses: actions/cache@v4
44-
id: cache-fuzz
50+
- name: Setup Rust toolchain
51+
uses: dtolnay/rust-toolchain@stable
4552
with:
46-
path: |
47-
~/.cargo/bin
48-
fuzz/target
49-
target
50-
key: cache-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
51-
- uses: actions-rs/toolchain@v1
53+
toolchain: 1.89
54+
- name: Cache cargo dependencies
55+
uses: Swatinem/rust-cache@v2
5256
with:
53-
toolchain: 1.85
54-
override: true
55-
profile: minimal
57+
workspaces: "fuzz -> target"
5658
- name: fuzz
5759
run: cd fuzz && ./fuzz.sh "${{ matrix.fuzz_target }}"
5860
- run: echo "${{ matrix.fuzz_target }}" >executed_${{ matrix.fuzz_target }}

.github/workflows/rust.yml

Lines changed: 131 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@ on: [push, pull_request]
22

33
name: Continuous integration
44

5+
permissions:
6+
contents: read
7+
8+
concurrency:
9+
group: ${{ github.workflow }}-${{ github.ref }}
10+
cancel-in-progress: true
11+
512
jobs:
613
Tests:
714
name: Tests
@@ -26,21 +33,130 @@ jobs:
2633
AS_DEPENDENCY: true
2734
DO_NO_STD: false
2835
DO_DOCS: true
29-
- rust: 1.85.0
36+
- rust: 1.89.0
3037
env:
3138
AS_DEPENDENCY: true
3239
steps:
3340
- name: Checkout Crate
3441
uses: actions/checkout@v4
35-
- name: Checkout Toolchain
36-
uses: actions-rs/toolchain@v1
42+
- name: Setup Rust toolchain
43+
uses: dtolnay/rust-toolchain@stable
3744
with:
38-
profile: minimal
3945
toolchain: ${{ matrix.rust }}
40-
override: true
4146
- name: Running test script
4247
env: ${{ matrix.env }}
4348
run: ./contrib/test.sh
49+
50+
workspace-tests:
51+
name: Workspace Tests
52+
runs-on: ubuntu-latest
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
rust: [stable, beta, nightly, 1.89.0]
57+
steps:
58+
- name: Checkout Crate
59+
uses: actions/checkout@v4
60+
- name: Setup Rust toolchain
61+
uses: dtolnay/rust-toolchain@stable
62+
with:
63+
toolchain: ${{ matrix.rust }}
64+
- name: Cache cargo dependencies
65+
uses: Swatinem/rust-cache@v2
66+
- name: Run workspace tests
67+
run: cargo test --workspace --all-features
68+
- name: Run workspace tests (no default features)
69+
run: cargo test --workspace --no-default-features
70+
- name: Build workspace (release mode)
71+
run: cargo build --workspace --release
72+
73+
clippy:
74+
name: Clippy (Non-strict)
75+
runs-on: ubuntu-latest
76+
steps:
77+
- name: Checkout Crate
78+
uses: actions/checkout@v4
79+
- name: Setup Rust toolchain
80+
uses: dtolnay/rust-toolchain@stable
81+
with:
82+
toolchain: stable
83+
components: clippy
84+
- name: Run clippy (excluding strict-checked crates)
85+
run: |
86+
# Auto-discover all workspace crates and exclude strict-checked ones
87+
STRICT_CRATES=("key-wallet" "key-wallet-manager" "key-wallet-ffi")
88+
mapfile -t ALL_CRATES < <(cargo metadata --no-deps --format-version=1 | jq -r '.packages[].name' | sort -u)
89+
for crate in "${ALL_CRATES[@]}"; do
90+
if printf '%s\n' "${STRICT_CRATES[@]}" | grep -qx "$crate"; then
91+
continue
92+
fi
93+
echo "Checking $crate (warnings allowed)..."
94+
cargo clippy -p "$crate" --all-features --all-targets || true
95+
done
96+
97+
strict-checks:
98+
name: Strict Warnings and Clippy Checks
99+
runs-on: ubuntu-latest
100+
steps:
101+
- name: Checkout Crate
102+
uses: actions/checkout@v4
103+
- name: Setup Rust toolchain
104+
uses: dtolnay/rust-toolchain@stable
105+
with:
106+
toolchain: stable
107+
components: clippy
108+
- name: Cache cargo dependencies
109+
uses: Swatinem/rust-cache@v2
110+
111+
# Check key-wallet with strict warnings
112+
- name: Check key-wallet (deny warnings)
113+
env:
114+
RUSTFLAGS: "-D warnings"
115+
run: |
116+
cargo check -p key-wallet --all-features --lib --bins --tests
117+
cargo build -p key-wallet --all-features --lib --bins
118+
cargo test -p key-wallet --all-features --lib --bins
119+
120+
- name: Clippy key-wallet (deny all warnings)
121+
run: cargo clippy -p key-wallet --all-features --lib --bins --tests -- -D warnings
122+
123+
# Check key-wallet-manager with strict warnings
124+
- name: Check key-wallet-manager (deny warnings)
125+
env:
126+
RUSTFLAGS: "-D warnings"
127+
run: |
128+
cargo check -p key-wallet-manager --all-features --lib --bins --tests
129+
cargo build -p key-wallet-manager --all-features --lib --bins
130+
cargo test -p key-wallet-manager --all-features --lib --bins
131+
132+
- name: Clippy key-wallet-manager (deny all warnings)
133+
run: cargo clippy -p key-wallet-manager --all-features --lib --bins --tests -- -D warnings
134+
135+
# Check key-wallet-ffi with strict warnings
136+
- name: Check key-wallet-ffi (deny warnings)
137+
env:
138+
RUSTFLAGS: "-D warnings"
139+
run: |
140+
cargo check -p key-wallet-ffi --all-features --lib --bins --tests
141+
cargo build -p key-wallet-ffi --all-features --lib --bins
142+
cargo test -p key-wallet-ffi --all-features --lib --bins
143+
144+
- name: Clippy key-wallet-ffi (deny all warnings)
145+
run: cargo clippy -p key-wallet-ffi --all-features --lib --bins --tests -- -D warnings
146+
147+
fmt:
148+
name: Format
149+
runs-on: ubuntu-latest
150+
steps:
151+
- name: Checkout Crate
152+
uses: actions/checkout@v4
153+
- name: Setup Rust toolchain
154+
uses: dtolnay/rust-toolchain@stable
155+
with:
156+
toolchain: stable
157+
components: rustfmt
158+
- name: Check formatting
159+
run: cargo fmt --all -- --check
44160

45161
# TODO: need to support compiling rust-x11-hash under s390x
46162
# Cross:
@@ -49,9 +165,9 @@ jobs:
49165
# runs-on: ubuntu-latest
50166
# steps:
51167
# - name: Checkout Crate
52-
# uses: actions/checkout@v2
168+
# uses: actions/checkout@v4
53169
# - name: Checkout Toolchain
54-
# uses: actions-rs/toolchain@v1
170+
# uses: dtolnay/rust-toolchain@stable
55171
# with:
56172
# profile: minimal
57173
# toolchain: stable
@@ -88,7 +204,7 @@ jobs:
88204
# run: cd hashes/embedded && cargo run --target thumbv7m-none-eabi --features=alloc
89205

90206
rpc-tests:
91-
name: Tests
207+
name: RPC Tests
92208
runs-on: ubuntu-latest
93209
strategy:
94210
matrix:
@@ -99,18 +215,16 @@ jobs:
99215
- rust: nightly
100216
env:
101217
RUSTFMTCHK: false
102-
- rust: 1.85.0
218+
- rust: 1.89.0
103219
env:
104220
PIN_VERSIONS: true
105221
steps:
106222
- name: Checkout Crate
107-
uses: actions/checkout@v2
108-
- name: Checkout Toolchain
109-
uses: actions-rs/toolchain@v1
223+
uses: actions/checkout@v4
224+
- name: Setup Rust toolchain
225+
uses: dtolnay/rust-toolchain@stable
110226
with:
111-
profile: minimal
112227
toolchain: ${{ matrix.rust }}
113-
override: true
114228
- name: Running test script
115229
env: ${{ matrix.env }}
116230
run: ./contrib/test.sh
@@ -133,13 +247,11 @@ jobs:
133247
]
134248
steps:
135249
- name: Checkout Crate
136-
uses: actions/checkout@v2
137-
- name: Checkout Toolchain
138-
uses: actions-rs/toolchain@v1
250+
uses: actions/checkout@v4
251+
- name: Setup Rust toolchain
252+
uses: dtolnay/rust-toolchain@stable
139253
with:
140-
profile: minimal
141254
toolchain: ${{ matrix.rust }}
142-
override: true
143255
- name: Running test script
144256
env:
145257
BITCOINVERSION: ${{ matrix.bitcoinversion }}

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ rust-dashcore is a Rust implementation of the Dash cryptocurrency protocol libra
2424

2525
### Network & SPV
2626
- `dash-network/` - Network protocol abstractions
27-
- `dash-network-ffi/` - Network FFI bindings using UniFFI
27+
- `dash-network-ffi/` - C-compatible FFI bindings for network types
2828
- `dash-spv/` - SPV client implementation
2929
- `dash-spv-ffi/` - C-compatible FFI bindings for SPV client
3030

3131
### Wallet & Keys
3232
- `key-wallet/` - HD wallet implementation
33-
- `key-wallet-ffi/` - FFI bindings for wallet functionality
33+
- `key-wallet-ffi/` - C-compatible FFI bindings for wallet functionality
3434

3535
### RPC & Integration
3636
- `rpc-client/` - JSON-RPC client for Dash Core nodes

dash-network-ffi/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,12 @@ readme = "README.md"
1111

1212
[dependencies]
1313
dash-network = { path = "../dash-network", default-features = false }
14-
uniffi = { version = "0.29.3", features = ["cli"] }
1514
thiserror = "2.0.12"
1615

17-
[build-dependencies]
18-
uniffi = { version = "0.29.3", features = ["build"] }
19-
2016
[dev-dependencies]
2117
hex = "0.4"
2218

2319
[lib]
2420
crate-type = ["cdylib", "staticlib"]
2521
name = "dash_network_ffi"
2622

27-
[[bin]]
28-
name = "uniffi-bindgen"
29-
path = "uniffi-bindgen.rs"

dash-network-ffi/README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# dash-network-ffi
22

3-
FFI bindings for the dash-network crate, providing language bindings via UniFFI.
3+
FFI bindings for the dash-network crate, providing C-compatible language bindings.
44

55
## Overview
66

77
This crate provides Foreign Function Interface (FFI) bindings for the `dash-network` types, allowing them to be used from other programming languages like Swift, Python, Kotlin, and Ruby.
88

99
## Features
1010

11-
- UniFFI-based bindings for the Network enum
11+
- C-compatible FFI bindings for the Network enum
1212
- Network information and utilities exposed through FFI
1313
- Support for magic bytes operations
1414
- Core version activation queries
@@ -21,16 +21,6 @@ This crate provides Foreign Function Interface (FFI) bindings for the `dash-netw
2121
cargo build --release
2222
```
2323

24-
### Generating Bindings
25-
26-
To generate bindings for your target language:
27-
28-
```bash
29-
cargo run --bin uniffi-bindgen generate src/dash_network.udl --language swift
30-
cargo run --bin uniffi-bindgen generate src/dash_network.udl --language python
31-
cargo run --bin uniffi-bindgen generate src/dash_network.udl --language kotlin
32-
```
33-
3424
### Example Usage (Swift)
3525

3626
```swift

dash-network-ffi/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
fn main() {
2-
uniffi::generate_scaffolding("src/dash_network.udl").unwrap();
2+
// Build script for dash-network-ffi
3+
// Standard FFI compilation without uniffi
34
}

dash-network-ffi/src/dash_network.udl

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)