Skip to content

Commit

Permalink
fixed tests/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
OverOrion committed Apr 21, 2023
1 parent e33e852 commit 2dc247e
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 47 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ members = [
"crates/nostr-sdk",
"crates/nostr-sdk-net",
"crates/nostr-sdk-sqlite",
"crates/ensure_no_std"
"crates/ensure_no_std",
]
default-members = ["crates/*"]
default-members = ["crates/nostr*"]
resolver = "2"

[workspace.package]
Expand Down
3 changes: 3 additions & 0 deletions crates/nostr-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ tokio = { version = "1", features = ["full"] }
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
use nostr_sdk::prelude::*;
use nostr_sdk::key::XOnlyPublicKey;
use crate::nostr_sdk::prelude::nip19::FromBech32;
use crate::nostr_sdk::prelude::nip19::ToBech32;
#[tokio::main]
async fn main() -> Result<()> {
Expand Down
3 changes: 3 additions & 0 deletions crates/nostr-sdk/examples/client-with-opts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
use std::time::Duration;

use nostr_sdk::key::SecretKey;
use nostr_sdk::nips::nip04::decrypt;
use nostr_sdk::prelude::nip19::FromBech32;
use nostr_sdk::prelude::*;

const BECH32_SK: &str = "nsec1ufnus6pju578ste3v90xd5m2decpuzpql2295m3sknqcjzyys9ls0qlc85";
Expand Down
2 changes: 2 additions & 0 deletions crates/nostr-sdk/examples/client.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) 2022-2023 Yuki Kishimoto
// Distributed under the MIT software license

use nostr_sdk::key::SecretKey;
use nostr_sdk::prelude::nip19::FromBech32;
use nostr_sdk::prelude::*;

const BECH32_SK: &str = "nsec1ufnus6pju578ste3v90xd5m2decpuzpql2295m3sknqcjzyys9ls0qlc85";
Expand Down
6 changes: 6 additions & 0 deletions crates/nostr-sdk/examples/nostr-connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

use std::time::Duration;

use nostr_sdk::client::RemoteSigner;
use nostr_sdk::key::SecretKey;
use nostr_sdk::key::XOnlyPublicKey;
use nostr_sdk::nips::nip46::NostrConnectMetadata;
use nostr_sdk::nips::nip46::NostrConnectURI;
use nostr_sdk::prelude::nip19::FromBech32;
use nostr_sdk::prelude::*;

const APP_SECRET_KEY: &str = "nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99";
Expand Down
37 changes: 24 additions & 13 deletions crates/nostr-sdk/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
/// use nostr::Keys;
///
/// let my_keys = Keys::generate();
/// let client = Client::new(&my_keys);
Expand All @@ -138,6 +139,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
/// use nostr::Keys;
///
/// let my_keys = Keys::generate();
/// let opts = Options::new().wait_for_send(true);
Expand Down Expand Up @@ -283,6 +285,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
/// use nostr::Keys;
///
/// # #[tokio::main]
/// # async fn main() {
Expand Down Expand Up @@ -321,6 +324,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
/// use nostr::Keys;
///
/// # #[tokio::main]
/// # async fn main() {
Expand Down Expand Up @@ -366,7 +370,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -418,6 +422,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
/// use nostr::Keys;
///
/// # #[tokio::main]
/// # async fn main() {
Expand Down Expand Up @@ -448,6 +453,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
/// use nostr::Keys;
///
/// # #[tokio::main]
/// # async fn main() {
Expand Down Expand Up @@ -476,7 +482,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -493,7 +499,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -510,7 +516,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -540,7 +546,7 @@ impl Client {
/// use std::time::Duration;
///
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -671,7 +677,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -698,7 +704,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand All @@ -724,7 +730,7 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -789,7 +795,7 @@ impl Client {
/// use std::time::Duration;
///
/// use nostr_sdk::prelude::*;
///
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -887,7 +893,9 @@ impl Client {
/// # Example
/// ```rust,no_run
/// use nostr_sdk::prelude::*;
///
/// use nostr_sdk::key::XOnlyPublicKey;
/// use nostr_sdk::prelude::nip19::FromBech32;
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -974,7 +982,8 @@ impl Client {
/// use std::str::FromStr;
///
/// use nostr_sdk::prelude::*;
///
/// use nostr_sdk::key::XOnlyPublicKey;
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -1008,7 +1017,8 @@ impl Client {
/// use std::str::FromStr;
///
/// use nostr_sdk::prelude::*;
///
/// use nostr_sdk::key::XOnlyPublicKey;
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down Expand Up @@ -1042,7 +1052,8 @@ impl Client {
/// use std::str::FromStr;
///
/// use nostr_sdk::prelude::*;
///
/// use nostr_sdk::key::XOnlyPublicKey;
/// use nostr::Keys;
/// # #[tokio::main]
/// # async fn main() {
/// # let my_keys = Keys::generate();
Expand Down
3 changes: 3 additions & 0 deletions crates/nostr-sdk/src/client/signer/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl Client {
/// use std::time::Duration;
///
/// use nostr_sdk::prelude::*;
/// use nostr_sdk::client::RemoteSigner;
///
/// #[tokio::main]
/// async fn main() {
Expand All @@ -87,6 +88,8 @@ impl Client {
/// use std::str::FromStr;
///
/// use nostr_sdk::prelude::*;
/// use nostr_sdk::key::XOnlyPublicKey;
/// use nostr_sdk::client::RemoteSigner;
///
/// #[tokio::main]
/// async fn main() {
Expand Down
4 changes: 2 additions & 2 deletions crates/nostr-sdk/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
pub use nostr::prelude::*;

// Internal modules
pub use crate::client::*;
pub use crate::relay::*;
pub use crate::client;
pub use crate::relay;
pub use crate::*;
6 changes: 6 additions & 0 deletions crates/nostr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ tungstenite = { version = "0.18", features = ["rustls-tls-webpki-roots"]}

```rust,no_run
use nostr::prelude::*;
use nostr::Keys;
use nostr::Event;
use nostr::Metadata;
use nostr::EventBuilder;
use nostr::ClientMessage;
use crate::nostr::nips::nip19::ToBech32;
use tungstenite::{Message as WsMessage};
fn main() -> Result<()> {
Expand Down
4 changes: 4 additions & 0 deletions crates/nostr/examples/nip13.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@

use std::str::FromStr;

use nostr::key::SecretKey;
use nostr::prelude::*;
use nostr::Event;
use nostr::EventBuilder;
use nostr::Keys;

const ALICE_SK: &str = "6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e";

Expand Down
3 changes: 3 additions & 0 deletions crates/nostr/examples/nip19.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

use std::str::FromStr;

use nostr::key::XOnlyPublicKey;
use nostr::nips::nip19::ToBech32;
use nostr::prelude::*;
use nostr::Profile;

fn main() -> Result<()> {
env_logger::init();
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/examples/nip65.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use nostr::nips::nip65;
use nostr::prelude::FromBech32;
use nostr::prelude::nip19::FromBech32;
use nostr::secp256k1::XOnlyPublicKey;
use nostr::{ClientMessage, Filter, Kind, RelayMessage, Result, SubscriptionId};
use tungstenite::{connect, Message as WsMessage};
Expand Down
Loading

0 comments on commit 2dc247e

Please sign in to comment.