Skip to content

Commit

Permalink
sdk: add async-utility dep
Browse files Browse the repository at this point in the history
Remove `gloo-timers` and `wasm-bindgen-futures` deps
  • Loading branch information
yukibtc committed Jun 28, 2023
1 parent 31253b2 commit 63fff7e
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 223 deletions.
5 changes: 2 additions & 3 deletions crates/nostr-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords = ["nostr", "sdk", "rust"]

[features]
default = ["all-nips"]
blocking = ["dep:once_cell", "nostr/blocking"]
blocking = ["dep:once_cell", "async-utility/blocking", "nostr/blocking"]
vanity = ["nostr/vanity"]
all-nips = ["nip04", "nip05", "nip06", "nip11", "nip19", "nip46", "nip47"]
nip03 = ["nostr/nip03"]
Expand All @@ -26,6 +26,7 @@ nip46 = ["nostr/nip46"]
nip47 = ["nostr/nip47"]

[dependencies]
async-utility = "0.1"
log = "0.4"
nostr = { version = "0.22", path = "../nostr", default-features = false }
nostr-sdk-net = { version = "0.22", path = "../nostr-sdk-net" }
Expand All @@ -36,9 +37,7 @@ thiserror = "1.0"
tokio = { version = "1", default-features = false, features = ["rt-multi-thread", "time", "macros", "sync"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
gloo-timers = { version = "0.2", features = ["futures"] }
tokio = { version = "1", default-features = false, features = ["rt", "macros", "sync"] }
wasm-bindgen-futures = "0.4"

[dev-dependencies]
env_logger = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr-sdk/src/client/signer/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use std::sync::Arc;
use std::time::Duration;

use async_utility::time;
use nostr::nips::nip04;
use nostr::nips::nip46::{Message, Request, Response};
use nostr::secp256k1::XOnlyPublicKey;
Expand All @@ -19,7 +20,6 @@ use tokio::sync::Mutex;
use crate::client::blocking::Client as BlockingClient;
use crate::client::{Client, Error};
use crate::relay::RelayPoolNotification;
use crate::util::time;
#[cfg(feature = "blocking")]
use crate::RUNTIME;

Expand Down
4 changes: 1 addition & 3 deletions crates/nostr-sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@
#[cfg(all(target_arch = "wasm32", feature = "blocking"))]
compile_error!("`blocking` feature can't be enabled for WASM targets");

pub use nostr::{self, *};
#[cfg(feature = "blocking")]
use nostr_sdk_net::futures_util::Future;
#[cfg(feature = "blocking")]
use once_cell::sync::Lazy;
#[cfg(feature = "blocking")]
use tokio::runtime::Runtime;

pub use nostr::{self, *};

pub mod client;
pub mod prelude;
pub mod relay;
pub mod util;

#[cfg(feature = "blocking")]
pub use self::client::blocking;
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr-sdk/src/relay/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::Duration;

use async_utility::{thread, time};
#[cfg(feature = "nip11")]
use nostr::nips::nip11::RelayInformationDocument;
use nostr::{ClientMessage, Event, Filter, RelayMessage, SubscriptionId, Timestamp, Url};
Expand All @@ -21,7 +22,6 @@ use tokio::sync::{broadcast, oneshot, Mutex};
pub mod pool;

pub use self::pool::{RelayPoolMessage, RelayPoolNotification};
use crate::util::{thread, time};
#[cfg(feature = "blocking")]
use crate::RUNTIME;

Expand Down
2 changes: 1 addition & 1 deletion crates/nostr-sdk/src/relay/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;

use async_utility::thread;
use nostr::url::Url;
use nostr::{ClientMessage, Event, EventId, Filter, RelayMessage};
use tokio::sync::mpsc::{self, Receiver, Sender};
use tokio::sync::{broadcast, Mutex};

use super::{Error as RelayError, Relay, RelayOptions};
use crate::util::thread;

/// [`RelayPool`] error
#[derive(Debug, thiserror::Error)]
Expand Down
7 changes: 0 additions & 7 deletions crates/nostr-sdk/src/util/mod.rs

This file was deleted.

125 changes: 0 additions & 125 deletions crates/nostr-sdk/src/util/thread/mod.rs

This file was deleted.

40 changes: 0 additions & 40 deletions crates/nostr-sdk/src/util/thread/wasm.rs

This file was deleted.

42 changes: 0 additions & 42 deletions crates/nostr-sdk/src/util/time.rs

This file was deleted.

0 comments on commit 63fff7e

Please sign in to comment.