Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codespellrc
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: put this commit before the offending commit so that no intermediate commits fail ci

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[codespell]
skip = .git,target,Cargo.toml,Cargo.lock,Cargo-minimal.lock,Cargo-recent.lock
skip = .git,target,Cargo.toml,Cargo.lock,Cargo-minimal.lock,Cargo-recent.lock,package-lock.json
ignore-words-list = crate,ser,ot
50 changes: 50 additions & 0 deletions .github/workflows/javascript.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Test JavaScript
on:
pull_request:
paths:
- payjoin-ffi/**
env:
# Override the value from the rust-toolchain file
# This is necessary because even though the correct toolchain
# is explicitly specified for the rust-toolchain action,
# rustup honors the rust-toolchain file over the default
RUSTUP_TOOLCHAIN: 1.85

jobs:
build-js-and-test:
name: "Build and test javascript"
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: payjoin-ffi/javascript
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Rust 1.85.0
uses: dtolnay/[email protected]

- name: "Use cache"
uses: Swatinem/rust-cache@v2

- name: Install Node
uses: actions/setup-node@v6

- name: Install llvm
if: matrix.os == 'macos-latest'
run: brew install llvm

- name: Install wasm-bindgen
run: cargo install wasm-bindgen-cli

- name: "Install dependencies"
run: npm ci
Comment on lines +43 to +44
Copy link
Contributor

Choose a reason for hiding this comment

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

@thebrandonlucas is npm the thing to use or is there another javascript package manager we should be using? Bun?

TBF, it seems like js package managers is a rotating fashion choice and I think npm is lindy and fine.


- name: Generate bindings and binaries
run: bash ./scripts/generate_bindings.sh

- name: Run tests
run: npm test
2 changes: 2 additions & 0 deletions Cargo-minimal.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,7 @@ dependencies = [
"tokio",
"tracing",
"url",
"web-time",
]

[[package]]
Expand Down Expand Up @@ -2469,6 +2470,7 @@ dependencies = [
"bdk",
"bitcoin-ffi",
"bitcoin-ohttp",
"getrandom 0.2.15",
"hex",
"lazy_static",
"payjoin",
Expand Down
2 changes: 2 additions & 0 deletions Cargo-recent.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2397,6 +2397,7 @@ dependencies = [
"tokio",
"tracing",
"url",
"web-time",
]

[[package]]
Expand Down Expand Up @@ -2469,6 +2470,7 @@ dependencies = [
"bdk",
"bitcoin-ffi",
"bitcoin-ohttp",
"getrandom 0.2.15",
"hex",
"lazy_static",
"payjoin",
Expand Down
13 changes: 9 additions & 4 deletions payjoin-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ license = "MIT OR Apache-2.0"
exclude = ["tests"]

[features]
_test-utils = ["payjoin-test-utils", "tokio"]
default = ["io"]
dart = ["dep:uniffi-dart"]
io = ["payjoin/io"]
_test-utils = ["payjoin-test-utils", "tokio", "io"]
_manual-tls = ["payjoin/_manual-tls"]
wasm_js = ["getrandom/js"]

[lib]
name = "payjoin_ffi"
Expand All @@ -19,22 +23,23 @@ path = "uniffi-bindgen.rs"

[build-dependencies]
uniffi = { version = "0.29.4", features = ["build", "cli"] }
uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "04f0007", features = ["build"] }
uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "04f0007", features = ["build"], optional = true }

[dependencies]
base64 = "0.22.1"
bitcoin-ffi = { git = "https://github.com/benalleng/bitcoin-ffi.git", rev = "8e3a23b" }
getrandom = "0.2"
hex = "0.4.3"
lazy_static = "1.5.0"
ohttp = { package = "bitcoin-ohttp", version = "0.6.0" }
payjoin = { version = "1.0.0-rc.1", features = ["v1", "v2", "io"] }
payjoin = { version = "1.0.0-rc.1", features = ["v1", "v2"] }
payjoin-test-utils = { version = "0.0.1", optional = true }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.142"
thiserror = "2.0.14"
tokio = { version = "1.47.1", features = ["full"], optional = true }
uniffi = { version = "0.29.4" }
uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "04f0007" }
uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "04f0007", optional = true }
url = "2.5.4"

[dev-dependencies]
Expand Down
3 changes: 2 additions & 1 deletion payjoin-ffi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ The directories below include instructions for using, building, and publishing t
|----------|-----------------------|-------------------|------------------------------------|
| Python | linux, macOS | [payjoin-ffi/python](python) | [payjoin](https://pypi.org/project/payjoin/) |
| Dart | linux, macOS | [payjoin-ffi/dart](dart) | N/A |
| JavaScript | linux, macOS | [payjoin-ffi/javascript](javascript) | N/A |

## Minimum Supported Rust Version (MSRV)

This library should compile with any combination of features with Rust 1.78.0.
This library should compile with any combination of features with Rust 1.85.0.

## References

Expand Down
1 change: 1 addition & 0 deletions payjoin-ffi/build.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
fn main() {
uniffi::generate_scaffolding("src/payjoin_ffi.udl").unwrap();
#[cfg(feature = "dart")]
uniffi_dart::generate_scaffolding("src/payjoin_ffi.udl".into()).unwrap();
}
4 changes: 2 additions & 2 deletions payjoin-ffi/dart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Follow these steps to clone the repository and run the tests.
git clone https://github.com/payjoin/rust-payjoin.git
cd rust-payjoin/payjoin-ffi/dart

# Generate the bindings (use the script appropriate for your platform)
bash ./scripts/generate_<platform>.sh
# Generate the bindings
bash ./scripts/generate_bindings.sh

# Run all tests
dart test
Expand Down
10 changes: 5 additions & 5 deletions payjoin-ffi/dart/scripts/generate_bindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ fi

cd ../
echo "Generating payjoin dart..."
cargo build --features _test-utils --profile dev
cargo run --features _test-utils --profile dev --bin uniffi-bindgen -- --library ../target/debug/$LIBNAME --language dart --out-dir dart/lib/
cargo build --features dart,_test-utils --profile dev
cargo run --features dart,_test-utils --profile dev --bin uniffi-bindgen -- --library ../target/debug/$LIBNAME --language dart --out-dir dart/lib/

if [[ "$OS" == "Darwin" ]]; then
echo "Generating native binaries..."
rustup target add aarch64-apple-darwin x86_64-apple-darwin
# This is a test script the actual release should not include the test utils feature
cargo build --profile dev --target aarch64-apple-darwin --features _test-utils &
cargo build --profile dev --target x86_64-apple-darwin --features _test-utils &
cargo build --profile dev --target aarch64-apple-darwin --features dart,_test-utils &
cargo build --profile dev --target x86_64-apple-darwin --features dart,_test-utils &
wait

echo "Building macos fat library"
Expand All @@ -38,7 +38,7 @@ else
echo "Generating native binaries..."
rustup target add x86_64-unknown-linux-gnu
# This is a test script the actual release should not include the test utils feature
cargo build --profile dev --target x86_64-unknown-linux-gnu --features _test-utils
cargo build --profile dev --target x86_64-unknown-linux-gnu --features dart,_test-utils

echo "Copying payjoin_ffi binary"
cp ../target/x86_64-unknown-linux-gnu/debug/$LIBNAME dart/$LIBNAME
Expand Down
11 changes: 11 additions & 0 deletions payjoin-ffi/javascript/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Build outputs
dist/
node_modules/

# Generated by uniffi-bindgen-react-native
rust_modules/
src/generated/

# Generated by napi-rs (test-utils)
test-utils/*.node
test-utils/index.d.ts
3 changes: 3 additions & 0 deletions payjoin-ffi/javascript/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
tabWidth: 4
}
26 changes: 26 additions & 0 deletions payjoin-ffi/javascript/README.md
Copy link
Contributor

Choose a reason for hiding this comment

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

The new README under javascript/ still opens with “Payjoin Dart Bindings”

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good catch, thanks!

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Payjoin JavaScript Bindings

Welcome to the JavaScript language bindings for the [Payjoin Dev Kit](https://payjoindevkit.org/)!

## Running Tests

Follow these steps to clone the repository and run the tests.
This assumes you already have Rust and Node.js installed.


```shell
git clone https://github.com/payjoin/rust-payjoin.git
cd rust-payjoin/payjoin-ffi/javascript

# Install dependencies
cargo install wasm-bindgen-cli
npm install
# (macOS only - secp256k1-sys requires a WASM-capable C compiler)
brew install llvm

# Generate the bindings
bash ./scripts/generate_bindings.sh

# Run all tests
npm test
```
Loading
Loading