Skip to content

Commit 68cd128

Browse files
committed
Remove mod/uni payjoin-ffi distinction
None of our bindings depend on a non-uniffi interface any longer. Remove it to make maintenence less trouble. Generation scripts are altered since the uniffi feature has been removed. Dart integration tests were not kept up to date, so this does that as well. The bdk integration test was only testing the non-uniffi interface. Because this is tested at the terminal bindings, this test has been removed.
1 parent 88e0857 commit 68cd128

26 files changed

Lines changed: 717 additions & 2078 deletions

payjoin-ffi/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ exclude = ["tests"]
88
[features]
99
_test-utils = ["payjoin-test-utils", "tokio", "bitcoind"]
1010
_danger-local-https = ["payjoin/_danger-local-https"]
11-
uniffi = ["uniffi/cli", "bitcoin-ffi/default", "uniffi-dart"]
1211

1312
[lib]
1413
name = "payjoin_ffi"
@@ -35,8 +34,8 @@ serde = { version = "1.0.200", features = ["derive"] }
3534
serde_json = "1.0.128"
3635
thiserror = "1.0.58"
3736
tokio = { version = "1.38.0", features = ["full"], optional = true }
38-
uniffi = { version = "0.29.1", optional = true }
39-
uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "b6186bc", optional = true}
37+
uniffi = { version = "0.29.1" }
38+
uniffi-dart = { git = "https://github.com/Uniffi-Dart/uniffi-dart.git", rev = "b6186bc" }
4039
url = "2.5.0"
4140

4241
[dev-dependencies]

payjoin-ffi/build.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
fn main() {
2-
#[cfg(feature = "uniffi")]
32
uniffi::generate_scaffolding("src/payjoin_ffi.udl").unwrap();
4-
#[cfg(feature = "uniffi")]
53
uniffi_dart::generate_scaffolding("src/payjoin_ffi.udl".into()).unwrap();
64
}

payjoin-ffi/contrib/lint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
# Individual features with no defaults.
5-
features=("uniffi" "_danger-local-https" "_test-utils")
5+
features=("_danger-local-https" "_test-utils")
66

77
for feature in "${features[@]}"; do
88
# Don't duplicate --all-targets clippy. Clippy end-user code, not tests.

payjoin-ffi/dart/scripts/generate_linux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ LINUX_TARGET=x86_64-unknown-linux-gnu
66
echo "Generating payjoin_ffi.dart..."
77
cd ../
88
# This is a test script the actual release should not include the test utils feature
9-
cargo build --profile release --features uniffi,_test-utils
10-
cargo run --profile release --features uniffi,_test-utils --bin uniffi-bindgen -- --library target/release/$LIBNAME --language dart --out-dir dart/lib/
9+
cargo build --profile release --features _test-utils
10+
cargo run --profile release --features _test-utils --bin uniffi-bindgen -- --library target/release/$LIBNAME --language dart --out-dir dart/lib/
1111

1212
echo "Generating native binaries..."
1313
rustup target add $LINUX_TARGET
1414
# This is a test script the actual release should not include the test utils feature
15-
cargo build --profile release-smaller --target $LINUX_TARGET --features uniffi,_test-utils
15+
cargo build --profile release-smaller --target $LINUX_TARGET --features _test-utils
1616

1717
echo "Copying linux payjoin_ffi.so"
1818
cp target/$LINUX_TARGET/release-smaller/$LIBNAME dart/$LIBNAME

payjoin-ffi/dart/scripts/generate_macos.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ LIBNAME=libpayjoin_ffi.dylib
66
echo "Generating payjoin_ffi.dart..."
77
cd ../
88
# This is a test script the actual release should not include the test utils feature
9-
cargo build --features uniffi,_test-utils --profile release
10-
cargo run --features uniffi,_test-utils --profile release --bin uniffi-bindgen -- --library target/release/$LIBNAME --language dart --out-dir dart/lib/
9+
cargo build --features _test-utils --profile release
10+
cargo run --features _test-utils --profile release --bin uniffi-bindgen -- --library target/release/$LIBNAME --language dart --out-dir dart/lib/
1111

1212
echo "Generating native binaries..."
1313
rustup target add aarch64-apple-darwin x86_64-apple-darwin
1414

1515
# This is a test script the actual release should not include the test utils feature
16-
cargo build --profile release-smaller --target aarch64-apple-darwin --features uniffi,_test-utils
16+
cargo build --profile release-smaller --target aarch64-apple-darwin --features _test-utils
1717
echo "Done building aarch64-apple-darwin"
1818

1919
# This is a test script the actual release should not include the test utils feature
20-
cargo build --profile release-smaller --target x86_64-apple-darwin --features uniffi,_test-utils
20+
cargo build --profile release-smaller --target x86_64-apple-darwin --features _test-utils
2121
echo "Done building x86_64-apple-darwin"
2222

2323
echo "Building macos fat library"

payjoin-ffi/python/scripts/generate_linux.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ LINUX_TARGET=x86_64-unknown-linux-gnu
88
echo "Generating payjoin_ffi.py..."
99
cd ../
1010
# This is a test script the actual release should not include the test utils feature
11-
cargo build --profile release --features uniffi,_test-utils
12-
cargo run --profile release --features uniffi,_test-utils --bin uniffi-bindgen generate --library target/release/$LIBNAME --language python --out-dir python/src/payjoin/
11+
cargo build --profile release --features _test-utils
12+
cargo run --profile release --features _test-utils --bin uniffi-bindgen generate --library target/release/$LIBNAME --language python --out-dir python/src/payjoin/
1313

1414
echo "Generating native binaries..."
1515
rustup target add $LINUX_TARGET
1616
# This is a test script the actual release should not include the test utils feature
17-
cargo build --profile release-smaller --target $LINUX_TARGET --features uniffi,_test-utils
17+
cargo build --profile release-smaller --target $LINUX_TARGET --features _test-utils
1818

1919
echo "Copying linux payjoin_ffi.so"
2020
cp target/$LINUX_TARGET/release-smaller/$LIBNAME python/src/payjoin/$LIBNAME

payjoin-ffi/python/scripts/generate_macos.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ LIBNAME=libpayjoin_ffi.dylib
88
echo "Generating payjoin_ffi.py..."
99
cd ../
1010
# This is a test script the actual release should not include the test utils feature
11-
cargo build --features uniffi,_test-utils --profile release
12-
cargo run --features uniffi,_test-utils --profile release --bin uniffi-bindgen generate --library target/release/$LIBNAME --language python --out-dir python/src/payjoin/
11+
cargo build --features _test-utils --profile release
12+
cargo run --features _test-utils --profile release --bin uniffi-bindgen generate --library target/release/$LIBNAME --language python --out-dir python/src/payjoin/
1313

1414
echo "Generating native binaries..."
1515
rustup target add aarch64-apple-darwin x86_64-apple-darwin
1616

1717
# This is a test script the actual release should not include the test utils feature
18-
cargo build --profile release-smaller --target aarch64-apple-darwin --features uniffi,_test-utils
18+
cargo build --profile release-smaller --target aarch64-apple-darwin --features _test-utils
1919
echo "Done building aarch64-apple-darwin"
2020

2121
# This is a test script the actual release should not include the test utils feature
22-
cargo build --profile release-smaller --target x86_64-apple-darwin --features uniffi,_test-utils
22+
cargo build --profile release-smaller --target x86_64-apple-darwin --features _test-utils
2323
echo "Done building x86_64-apple-darwin"
2424

2525
echo "Building macos fat library"

payjoin-ffi/python/test/test_payjoin_integration_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ async def test_integration_v2_to_v2(self):
183183
headers={"Content-Type": request.request.content_type},
184184
content=request.request.body
185185
)
186-
payjoin_proposal.process_res(response.content, request.client_response)
186+
payjoin_proposal.process_response(response.content, request.client_response)
187187

188188
# **********************
189189
# Inside the Sender:

payjoin-ffi/src/bitcoin_ffi.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
use std::sync::Arc;
22

3-
#[cfg(not(feature = "uniffi"))]
4-
pub use bitcoin_ffi::*;
53
use payjoin::bitcoin;
64

7-
#[cfg(feature = "uniffi")]
85
mod uni {
96
pub use bitcoin_ffi::*;
107
}
118

12-
#[cfg(feature = "uniffi")]
139
pub use uni::*;
1410

15-
#[derive(Debug, Clone)]
16-
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
11+
#[derive(Debug, Clone, uniffi::Record)]
1712
pub struct PsbtInput {
1813
pub witness_utxo: Option<TxOut>,
1914
pub redeem_script: Option<Arc<Script>>,
@@ -55,7 +50,7 @@ impl From<PsbtInput> for bitcoin::psbt::Input {
5550
}
5651
}
5752

58-
#[cfg_attr(feature = "uniffi", derive(uniffi::Record))]
53+
#[derive(Debug, Clone, uniffi::Record)]
5954
pub struct Weight {
6055
pub weight_units: u64,
6156
}

payjoin-ffi/src/error.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ use std::error;
33
/// Error arising due to the specific receiver implementation
44
///
55
/// e.g. database errors, network failures, wallet errors
6-
#[derive(Debug, thiserror::Error)]
6+
#[derive(Debug, thiserror::Error, uniffi::Object)]
77
#[error(transparent)]
8-
#[cfg_attr(feature = "uniffi", derive(uniffi::Object))]
98
pub struct ImplementationError(#[from] payjoin::ImplementationError);
109

1110
impl ImplementationError {
@@ -25,19 +24,16 @@ impl From<ImplementationError> for payjoin::ImplementationError {
2524
fn from(value: ImplementationError) -> Self { value.0 }
2625
}
2726

28-
#[derive(Debug, thiserror::Error)]
27+
#[derive(Debug, thiserror::Error, uniffi::Object)]
2928
#[error("Error de/serializing JSON object: {0}")]
30-
#[cfg_attr(feature = "uniffi", derive(uniffi::Object))]
3129
pub struct SerdeJsonError(#[from] serde_json::Error);
3230

33-
#[derive(Debug, thiserror::Error, PartialEq, Eq)]
34-
#[cfg_attr(feature = "uniffi", derive(uniffi::Error))]
31+
#[derive(Debug, thiserror::Error, PartialEq, Eq, uniffi::Error)]
3532
pub enum ForeignError {
3633
#[error("Internal error: {0}")]
3734
InternalError(String),
3835
}
3936

40-
#[cfg(feature = "uniffi")]
4137
impl From<uniffi::UnexpectedUniFFICallbackError> for ForeignError {
4238
fn from(_: uniffi::UnexpectedUniFFICallbackError) -> Self {
4339
Self::InternalError("Unexpected Uniffi callback error".to_string())

0 commit comments

Comments
 (0)