Skip to content

Commit ccd1d50

Browse files
committed
Cleanup stage files
1 parent da4066d commit ccd1d50

14 files changed

Lines changed: 66 additions & 6203 deletions

File tree

bindings/wasm-sdk/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ WASM checks are wired into CI in `.github/workflows/test.yaml`:
5454

5555
- [ERROR_CONTRACT.md](ERROR_CONTRACT.md)
5656
- [SDK_WASM_ENDPOINT_MATRIX.md](SDK_WASM_ENDPOINT_MATRIX.md)
57-
- WIP planning/reference docs moved to `bindings/wasm-sdk/.local_wip/`
5857

5958
## Related
6059

src/sdk/README.md

Lines changed: 32 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,116 +1,50 @@
1-
# SDK WASM Notes
1+
# SDK Module Notes
22

3-
This document tracks the wasm-facing SDK boundary and the refactor work that moved wasm APIs into `src/sdk`.
3+
This document describes the current `src/sdk` structure after wasm-port cleanup.
44

5-
## What Changed
5+
## Active modules
66

7-
1. WASM bindings were moved to SDK scope:
8-
- from `src/wasm_bindings.rs`
9-
- to `src/sdk/wasm_bindings.rs`
10-
2. WASM SDK boundary lives in `src/sdk/wasm.rs`.
11-
3. On wasm targets, library export now points `pub mod sdk;` to `src/sdk/wasm.rs` through `src/lib.rs`.
12-
4. UniFFI/native runtime modules are gated out for wasm builds.
13-
14-
## Major SDK Refactors (Engine / Disk / Core)
15-
16-
The wasm work was preceded by a larger SDK restructuring so runtime-dependent logic and SDK-facing contracts are separated.
17-
18-
1. Engine abstraction introduced (`src/sdk/engine.rs`)
19-
- Added a dedicated `SdkEngine` trait containing SDK operations (init/unlock, node/network info, channel/payment/rgb/swap APIs, and mutating operations).
20-
- This decouples API surface from concrete runtime wiring and enables different engine implementations per target/runtime.
21-
- Outcome: wasm can keep a boundary engine/state model while native keeps full runtime behavior.
22-
2. Disk/storage logic moved into SDK namespace (`src/sdk/disk.rs`)
23-
- Filesystem persistence and recovery helpers were moved under SDK scope:
24-
- channel-peer map persistence
25-
- LDK graph/scorer/payment storage reads
26-
- swap/channel id persistence helpers
27-
- Outcome: stateful runtime storage concerns are isolated from wasm boundary and can be replaced with wasm-safe adapters later.
28-
3. Core shared types/constants extracted for SDK (`src/sdk/core_types.rs`)
29-
- Shared protocol and runtime constants/status enums (`FEE_RATE`, `HTLCStatus`, `SwapStatus`, `UnlockRequest`, etc.) are now local to SDK internals.
30-
- Outcome: wasm and native paths can share API contracts while diverging in execution/runtime backend.
31-
4. Native runtime modules duplicated/scoped at SDK level
32-
- Native runtime-heavy modules now exist in `src/sdk/*` (`args`, `bitcoind`, `error`, `ldk`, `rgb`, `swap`, `utils`) instead of coupling directly to root module layout.
33-
- `src/sdk/mod.rs` gates most of these under `feature = "native-sdk-engine"`.
34-
- Outcome: SDK evolution can happen in one module tree, and wasm-facing code can be ported incrementally without pulling native internals.
35-
5. Cargo feature and target separation
36-
- `native-sdk-engine` feature marks native engine path.
37-
- `cfg(target_arch = "wasm32")` compiles only wasm-safe dependencies and modules.
38-
- Outcome: clear compile-time boundary between native full node runtime and wasm SDK boundary.
39-
40-
## Module Mapping (Root -> SDK)
41-
42-
| Previous root module | SDK-level module | Status |
43-
| --- | --- | --- |
44-
| `src/args.rs` | `src/sdk/args.rs` | extracted for native-sdk path |
45-
| `src/bitcoind.rs` | `src/sdk/bitcoind.rs` | extracted for native-sdk path |
46-
| `src/core_types.rs` | `src/sdk/core_types.rs` | extracted/shared contract constants |
47-
| `src/disk.rs` | `src/sdk/disk.rs` | extracted for SDK runtime persistence |
48-
| `src/error.rs` | `src/sdk/error.rs` | extracted for SDK runtime errors |
49-
| `src/ldk.rs` | `src/sdk/ldk.rs` | extracted for SDK native runtime |
50-
| `src/rgb.rs` | `src/sdk/rgb.rs` | extracted for SDK native runtime |
51-
| `src/swap.rs` | `src/sdk/swap.rs` | extracted for SDK native runtime |
52-
| `src/utils.rs` | `src/sdk/utils.rs` | extracted/shared SDK helpers |
53-
| `src/wasm_bindings.rs` | `src/sdk/wasm_bindings.rs` | moved to SDK wasm boundary |
54-
| n/a (new) | `src/sdk/engine.rs` | new abstraction for runtime backends |
55-
| n/a (new) | `src/sdk/wasm.rs` | new wasm boundary module |
56-
57-
## Module Layout
58-
59-
- `src/lib.rs`
60-
- native-only modules are behind `#[cfg(not(target_arch = "wasm32"))]`
61-
- wasm SDK module is exposed with:
62-
- `#[cfg(target_arch = "wasm32")]`
63-
- `#[path = "sdk/wasm.rs"]`
64-
- `pub mod sdk;`
7+
- `src/sdk/mod.rs`
8+
- Native SDK implementation used on non-wasm targets.
9+
- Mirrors core route behavior for SDK consumers.
6510
- `src/sdk/wasm.rs`
66-
- wasm-safe SDK data types
67-
- state container (`WasmSdkState`, `WasmSdkStateConfig`)
68-
- async wasm API surface (`init`, `network_info`, `list_channels`, `list_peers`, `node_info`, `estimate_fee`, `list_transactions`, `runtime_capabilities`, `get_channel_id`, `address`, `healthcheck`, `sdk_info`)
69-
- exports wasm JS bridge module:
70-
- `pub mod wasm_bindings;`
11+
- Wasm boundary module used when `target_arch = "wasm32"`.
12+
- Defines wasm SDK state/types and async wasm-facing API surface.
7113
- `src/sdk/wasm_bindings.rs`
72-
- `wasm-bindgen` bridge for JS consumers
73-
- `sdk_init(...)` constructor
74-
- JSON-returning methods (`*Json`)
75-
- typed `JsValue` methods (`*Value`) using `serde-wasm-bindgen`
14+
- `wasm-bindgen` bridge for JS-facing calls (`*Value` / `*Json`).
15+
16+
## Target wiring
7617

77-
## Runtime Model
18+
`src/lib.rs` selects SDK module by target:
7819

79-
Current wasm SDK layer is an explicit boundary module:
20+
- non-wasm: `mod sdk;` -> `src/sdk/mod.rs`
21+
- wasm: `#[path = "sdk/wasm.rs"] pub mod sdk;`
8022

81-
- It is read-only and deterministic.
82-
- It does not start native LDK/RGB background services on wasm.
83-
- It provides stable API/shape for frontend integration while runtime-backed operations are ported incrementally.
23+
This means native and wasm SDK entrypoints are separated at compile time.
8424

85-
In other words, the major refactor split the project into:
25+
## Removed staged files
8626

87-
- SDK contracts + engine boundary (`src/sdk/engine.rs` and SDK types)
88-
- native runtime implementation modules (`src/sdk/ldk.rs`, `src/sdk/rgb.rs`, `src/sdk/disk.rs`, etc.)
89-
- wasm boundary implementation (`src/sdk/wasm.rs` + `src/sdk/wasm_bindings.rs`)
27+
The previous staged duplication modules were removed because they were not
28+
connected to the active module graph:
9029

91-
`WasmSdkStateConfig` lets callers inject network, height, fee-rate hint, channels, and peers so integration tests and UI demos can run against predictable state.
30+
- `src/sdk/args.rs`
31+
- `src/sdk/bitcoind.rs`
32+
- `src/sdk/core_types.rs`
33+
- `src/sdk/disk.rs`
34+
- `src/sdk/engine.rs`
35+
- `src/sdk/error.rs`
36+
- `src/sdk/ldk.rs`
37+
- `src/sdk/rgb.rs`
38+
- `src/sdk/swap.rs`
39+
- `src/sdk/utils.rs`
9240

93-
## Validation Commands
41+
## Validation commands
9442

9543
Run from repository root:
9644

9745
```bash
46+
cargo check
9847
cargo check --target wasm32-unknown-unknown --lib
99-
cargo test --target wasm32-unknown-unknown --lib --no-run
100-
cargo test --target wasm32-unknown-unknown --tests --no-run
101-
cargo check --features "uniffi,native-sdk-engine" --lib
48+
cargo check --manifest-path bindings/wasm-sdk/Cargo.toml
49+
cargo check --manifest-path bindings/wasm-sdk/Cargo.toml --target wasm32-unknown-unknown
10250
```
103-
104-
## Dependency and Build Updates
105-
106-
- `Cargo.toml` includes wasm target support deps:
107-
- `wasm-bindgen`
108-
- `serde-wasm-bindgen`
109-
- `getrandom` with `js` feature
110-
- Explicit `[[bin]]` test handling is configured so wasm `--tests --no-run` is not blocked by native-only bin harness assumptions.
111-
112-
## Next Porting Steps
113-
114-
1. Replace placeholder wasm engine behavior with real async runtime adapters where browser-compatible.
115-
2. Separate read-only and mutating API groups in wasm exports.
116-
3. Add wasm integration tests from JS side (e.g. Node + browser harness) for API-level contract checks.

src/sdk/args.rs

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

0 commit comments

Comments
 (0)