Skip to content

Commit 15a0c46

Browse files
Improve development guides (#809)
* Improve development guides * Apply suggestions from code review Co-authored-by: Erdem Yerebasmaz <[email protected]> * Add Firefox prerequisites --------- Co-authored-by: Erdem Yerebasmaz <[email protected]>
1 parent 0918330 commit 15a0c46

File tree

15 files changed

+127
-80
lines changed

15 files changed

+127
-80
lines changed

.github/workflows/main.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ jobs:
5959
run: cargo clippy -- -D warnings
6060

6161
clippy-wasm:
62-
name: Cargo Clippy WASM
62+
name: Cargo Clippy Wasm
6363
runs-on: ubuntu-latest
6464
steps:
6565
- uses: actions/checkout@v4
6666

67-
- name: Install WASM target
67+
- name: Install Wasm target
6868
run: rustup target add wasm32-unknown-unknown
6969

7070
- uses: Swatinem/rust-cache@v2
@@ -126,12 +126,12 @@ jobs:
126126
fi
127127
128128
build-wasm:
129-
name: Cargo Build WASM
129+
name: Cargo Build Wasm
130130
runs-on: ubuntu-latest
131131
steps:
132132
- uses: actions/checkout@v4
133133

134-
- name: Install WASM target
134+
- name: Install Wasm target
135135
run: rustup target add wasm32-unknown-unknown
136136

137137
- uses: Swatinem/rust-cache@v2
@@ -278,12 +278,12 @@ jobs:
278278
run: cargo test --no-default-features --features uniffi-25
279279

280280
test-wasm:
281-
name: Test WASM
281+
name: Test Wasm
282282
runs-on: ubuntu-latest
283283
steps:
284284
- uses: actions/checkout@v4
285285

286-
- name: Install WASM target
286+
- name: Install Wasm target
287287
run: rustup target add wasm32-unknown-unknown
288288

289289
- name: Install wasm-pack
@@ -304,7 +304,7 @@ jobs:
304304
- name: Setup emsdk
305305
uses: mymindstorm/setup-emsdk@v14
306306

307-
- name: Test WASM
307+
- name: Test Wasm
308308
run: make wasm-test
309309

310310
notification-plugin:

CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ __*[lib/core](lib/core)*__
3636

3737
__*[lib/wasm](lib/wasm)*__
3838
* [model.rs](lib/wasm/src/model.rs) - Update the structs/enums exported.
39-
* [lib.rs](lib/wasm/src/lib.rs) - Update the Rust interface for the WASM bindings.
39+
* [lib.rs](lib/wasm/src/lib.rs) - Update the Rust interface for the Wasm bindings.
4040

41-
After making these changes the [Dart](packages/dart), [Flutter](packages/flutter) and [React Native](packages/react-native) bindings code also need to be regenerated and included in your pull request. You can regenerate these from the project root using `make codegen`. Please see the prerequisites for [Flutter](lib/bindings/langs/flutter/README.md), [React Native](packages/react-native/DEVELOPING.md) and [WASM](lib/wasm/DEVELOPING.md) if this is your first time generating code.
41+
After making these changes the [Dart](packages/dart), [Flutter](packages/flutter) and [React Native](packages/react-native) bindings code also need to be regenerated and included in your pull request. You can regenerate these from the project root using `make codegen`. Please see the prerequisites for [Flutter](lib/bindings/langs/flutter/README.md), [React Native](packages/react-native/DEVELOPMENT.md) and [Wasm](lib/wasm/DEVELOPMENT.md) if this is your first time generating code.
4242

4343
#### Testing
4444
Please adequately test your code using the existing tests and write additional tests for new features. You can run the tests from the project root using `make test`. You can also make use of the [CLI](cli) to test changes while developing your feature.

DEVELOPMENT.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
## Setup
1+
# Development guide
2+
Please see the development guides for each crate/package:
3+
4+
### Crates
5+
* [SDK Bindings](lib/bindings/DEVELOPMENT.md)
6+
* [SDK Core](lib/core/DEVELOPMENT.md)
7+
* [SDK Wasm](lib/wasm/DEVELOPMENT.md)
8+
9+
### Packages
10+
* [React Native](packages/react-native/DEVELOPMENT.md)
11+
12+
## Automatic format & syntax checking
213
To configure automatic code formatting and syntax checking for this repository, you can run the following command once:
314
```bash
415
git config --local core.hooksPath .githooks/

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
all: fmt codegen clippy
22

3+
init:
4+
make -C ./lib/bindings init
5+
make -C ./lib/core init
6+
make -C ./lib/wasm init
7+
38
fmt:
49
cd lib && cargo fmt
510
cd cli && cargo fmt

lib/bindings/DEVELOPMENT.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Development guide - Bindings crate
2+
This crate is responsible for building UniFFI bindings.
3+
4+
## Prerequisites
5+
To build you need to first install:
6+
- [Protobuf](https://protobuf.dev/installation/)
7+
```bash
8+
brew install protobuf
9+
```
10+
11+
Set the ANDROID_NDK_HOME env variable to your Android NDK directory:
12+
```bash
13+
export ANDROID_NDK_HOME=<your android ndk directory>
14+
```
15+
16+
On first usage you will need to run:
17+
```bash
18+
make init
19+
```
20+
21+
## Building
22+
To build bindings for individual languages please see the available [Makefile tasks](lib/bindings/makefile). Otherwise to build all bindings run:
23+
```bash
24+
make all
25+
```
26+
27+
## Testing
28+
```bash
29+
make test
30+
```

lib/bindings/README.md

-5
This file was deleted.

lib/core/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ecies = { version = "0.2.7", default-features = false, features = ["pure"] }
6161
semver = "1.0.23"
6262
lazy_static = "1.5.0"
6363

64-
# Non-WASM dependencies
64+
# Non-Wasm dependencies
6565
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
6666
electrum-client = { version = "0.21.0", default-features = false, features = [
6767
"use-rustls-ring",
@@ -74,7 +74,7 @@ tokio-stream = { version = "0.1.14", features = ["sync"] }
7474
tonic = { version = "^0.8", features = ["tls", "tls-webpki-roots"] }
7575
uuid = { version = "1.8.0", features = ["v4"] }
7676

77-
# WASM dependencies
77+
# Wasm dependencies
7878
[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dependencies]
7979
console_log = "1"
8080
lwk_wollet = { version = "0.9.0", default-features = false, features = [
@@ -92,11 +92,11 @@ tonic = { version = "0.12", default-features = false, features = [
9292
sdk-common = { workspace = true, features = ["test-utils"] }
9393
paste = "1.0.15"
9494

95-
# Non-WASM dev dependencies
95+
# Non-Wasm dev dependencies
9696
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dev-dependencies]
9797
tempdir = "0.3.7"
9898

99-
# WASM dev dependencies
99+
# Wasm dev dependencies
100100
[target.'cfg(all(target_family = "wasm", target_os = "unknown"))'.dev-dependencies]
101101
wasm-bindgen-test = "0.3.33"
102102
rand = "0.8"

lib/core/DEVELOPMENT.md

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Development guide - Core crate
2+
3+
## Prerequisites
4+
To compile the Core crate you will first need to install:
5+
- [Protobuf](https://protobuf.dev/installation/)
6+
- [Emscripten](https://emscripten.org/docs/getting_started/downloads.html) for compiling to Wasm
7+
- [Firefox](https://mozilla.org/firefox/download/) for testing Wasm
8+
9+
```bash
10+
brew install protobuf emscripten
11+
```
12+
13+
On first usage you will need to run:
14+
```bash
15+
make init
16+
```
17+
18+
## Testing
19+
To test all targets run:
20+
```bash
21+
make test
22+
```
23+
This comprises the following make tasks:
24+
```bash
25+
make cargo-test wasm-test
26+
```

lib/core/README.md

-23
This file was deleted.

lib/core/src/sdk.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ impl LiquidSdkBuilder {
189189
None => {
190190
#[cfg(all(target_family = "wasm", target_os = "unknown"))]
191191
return Err(anyhow!(
192-
"Must provide a WASM-compatible persister on WASM builds"
192+
"Must provide a Wasm-compatible persister on Wasm builds"
193193
));
194194
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
195195
Arc::new(Persister::new_using_fs(

lib/wasm/DEVELOPING.md

-33
This file was deleted.

lib/wasm/DEVELOPMENT.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Development guide - Wasm crate
2+
This crate is responsible for building Wasm specific bindings.
3+
4+
## Prerequisites
5+
To build some dependencies you need to first install
6+
- [Protobuf](https://protobuf.dev/installation/)
7+
- [Emscripten](https://emscripten.org/docs/getting_started/downloads.html) for compiling to Wasm
8+
- [Firefox](https://mozilla.org/firefox/download/) for testing Wasm
9+
10+
```bash
11+
brew install protobuf emscripten
12+
```
13+
14+
On first usage you will need to run:
15+
```bash
16+
make init
17+
```
18+
19+
## Building
20+
```bash
21+
make pack
22+
```
23+
24+
This will generate the following artifacts:
25+
26+
- `pkg/package.json`
27+
- `pkg/breez_sdk_liquid_wasm_bg.wasm`
28+
- `pkg/breez_sdk_liquid_wasm_bg.d.wasm`
29+
- `pkg/breez_sdk_liquid_wasm.d.ts`
30+
- `pkg/breez_sdk_liquid_wasm.js`
31+
32+
## Testing
33+
```bash
34+
make test
35+
```

lib/wasm/Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ endif
66

77
init:
88
cargo install wasm-pack
9+
rustup target add wasm32-unknown-unknown
910

1011
clippy:
1112
$(CLANG_PREFIX) cargo clippy --target=wasm32-unknown-unknown -- -D warnings

packages/react-native/DEVELOPING.md packages/react-native/DEVELOPMENT.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Setting up a development environment
1+
# Development guide - React Native package
22

33
The Breez Liquid SDK React Native plugin consumes the underlying Breez Liquid SDK from the following sources:
44

@@ -12,8 +12,8 @@ All the following commands can be run in the `packages/react-native` directory.
1212

1313
## Prerequisites
1414

15-
Set the ANDROID_NDK_HOME env variable to your SDK home directory:
16-
```
15+
Set the ANDROID_NDK_HOME env variable to your Android NDK directory:
16+
```bash
1717
export ANDROID_NDK_HOME=<your android ndk directory>
1818
```
1919

packages/react-native/example/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ yarn ios
4444

4545
## Development
4646

47-
To develop the Breez Liquid SDK alongside the React Native module and example app, please read [DEVELOPING.md](../DEVELOPING.md) for details on how to setup your development environment.
47+
To develop the Breez Liquid SDK alongside the React Native module and example app, please read [DEVELOPMENT.md](../DEVELOPMENT.md) for details on how to setup your development environment.

0 commit comments

Comments
 (0)