From 3b988fb13e0ea39c13dad116bd63333ea5d2bc36 Mon Sep 17 00:00:00 2001 From: Yuki Kishimoto Date: Mon, 16 Dec 2024 12:35:05 +0100 Subject: [PATCH] sdk: add `Connection::embedded_tor_with_path` Fix UniFFI checksum mismatch issue. Closes https://github.com/mozilla/uniffi-rs/issues/2321 Signed-off-by: Yuki Kishimoto --- CHANGELOG.md | 2 ++ Cargo.lock | 2 +- Cargo.toml | 2 +- bindings/nostr-sdk-ffi/src/client/options.rs | 17 +++++++---------- crates/nostr-sdk/src/client/options.rs | 12 +++++++----- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 114130ab8..77b0dc114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,6 +71,7 @@ * database: add `SaveEventStatus` enum ([Yuki Kishimoto]) * pool: add `ReceiverStream` ([Yuki Kishimoto]) * sdk: automatically resend event after NIP-42 authentication ([Yuki Kishimoto]) +* sdk: add `Connection::embedded_tor_with_path` ([Yuki Kishimoto]) * relay-builder: add NIP42 support ([Yuki Kishimoto]) * relay-builder: add negentropy support ([Yuki Kishimoto]) * relay-builder: add read/write policy plugins ([v0l]) @@ -81,6 +82,7 @@ * sdk: fix NIP42 authentication for auto-closing REQ ([Yuki Kishimoto]) * sdk: fix min POW is not updated to already existing relays ([Yuki Kishimoto]) * bindings: allow passing empty string as relay url without return an error ([Yuki Kishimoto]) +* ffi: fix UniFFI checksum mismatch issue ([Yuki Kishimoto]) * flutter: fix `default` is reserved in dart ([J. Azad EMERY]) ### Removed diff --git a/Cargo.lock b/Cargo.lock index e97223a9f..73e06bda7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -337,7 +337,7 @@ dependencies = [ [[package]] name = "async-wsocket" version = "0.11.0" -source = "git+https://github.com/yukibtc/async-wsocket?rev=27f606af6b2028634022a97b5e56c332dfe3f611#27f606af6b2028634022a97b5e56c332dfe3f611" +source = "git+https://github.com/yukibtc/async-wsocket?rev=259c0bc372e7d60d94827b484178bf995afdcbe6#259c0bc372e7d60d94827b484178bf995afdcbe6" dependencies = [ "arti-client", "async-utility", diff --git a/Cargo.toml b/Cargo.toml index 45d5a8f4d..8a1d4cd4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ rust-version = "1.70.0" async-trait = "0.1" async-utility = "0.3" #async-wsocket = "0.11" -async-wsocket = { git = "https://github.com/yukibtc/async-wsocket", rev = "27f606af6b2028634022a97b5e56c332dfe3f611" } +async-wsocket = { git = "https://github.com/yukibtc/async-wsocket", rev = "259c0bc372e7d60d94827b484178bf995afdcbe6" } atomic-destructor = { version = "0.3", default-features = false } js-sys = "0.3" negentropy = { version = "0.4", default-features = false } diff --git a/bindings/nostr-sdk-ffi/src/client/options.rs b/bindings/nostr-sdk-ffi/src/client/options.rs index 33e496471..7721e8e2d 100644 --- a/bindings/nostr-sdk-ffi/src/client/options.rs +++ b/bindings/nostr-sdk-ffi/src/client/options.rs @@ -174,26 +174,23 @@ impl Connection { builder.inner = builder.inner.proxy(addr); Ok(builder) } -} -#[cfg(all(not(target_os = "android"), not(target_os = "ios")))] -#[uniffi::export] -impl Connection { /// Use embedded tor client + /// + /// This not work on `android` and/or `ios` targets. + /// Use [`Connection::embedded_tor_with_path`] instead. pub fn embedded_tor(&self) -> Self { let mut builder = self.clone(); builder.inner = builder.inner.embedded_tor(); builder } -} -#[cfg(any(target_os = "android", target_os = "ios"))] -#[uniffi::export] -impl Connection { /// Use embedded tor client - pub fn embedded_tor(&self, data_path: String) -> Self { + /// + /// Specify a path where to store data + pub fn embedded_tor_with_path(&self, data_path: String) -> Self { let mut builder = self.clone(); - builder.inner = builder.inner.embedded_tor(data_path); + builder.inner = builder.inner.embedded_tor_with_path(data_path); builder } } diff --git a/crates/nostr-sdk/src/client/options.rs b/crates/nostr-sdk/src/client/options.rs index 718a46e10..df5d33678 100644 --- a/crates/nostr-sdk/src/client/options.rs +++ b/crates/nostr-sdk/src/client/options.rs @@ -6,7 +6,7 @@ #[cfg(not(target_arch = "wasm32"))] use std::net::SocketAddr; -#[cfg(all(feature = "tor", any(target_os = "android", target_os = "ios")))] +#[cfg(feature = "tor")] use std::path::Path; use std::time::Duration; @@ -238,20 +238,22 @@ impl Connection { /// Use embedded tor client #[inline] - #[cfg(all(feature = "tor", not(target_os = "android"), not(target_os = "ios")))] + #[cfg(feature = "tor")] pub fn embedded_tor(mut self) -> Self { self.mode = ConnectionMode::tor(); self } /// Use embedded tor client + /// + /// Specify a path where to store data #[inline] - #[cfg(all(feature = "tor", any(target_os = "android", target_os = "ios")))] - pub fn embedded_tor

(mut self, path: P) -> Self + #[cfg(feature = "tor")] + pub fn embedded_tor_with_path

(mut self, path: P) -> Self where P: AsRef, { - self.mode = ConnectionMode::tor(path.as_ref().to_path_buf()); + self.mode = ConnectionMode::tor_with_path(path); self } }