Skip to content

Commit 2dc247e

Browse files
committed
fixed tests/examples
1 parent e33e852 commit 2dc247e

File tree

18 files changed

+139
-47
lines changed

18 files changed

+139
-47
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ members = [
1010
"crates/nostr-sdk",
1111
"crates/nostr-sdk-net",
1212
"crates/nostr-sdk-sqlite",
13-
"crates/ensure_no_std"
13+
"crates/ensure_no_std",
1414
]
15-
default-members = ["crates/*"]
15+
default-members = ["crates/nostr*"]
1616
resolver = "2"
1717

1818
[workspace.package]

crates/nostr-sdk/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ tokio = { version = "1", features = ["full"] }
3333
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
3434
3535
use nostr_sdk::prelude::*;
36+
use nostr_sdk::key::XOnlyPublicKey;
37+
use crate::nostr_sdk::prelude::nip19::FromBech32;
38+
use crate::nostr_sdk::prelude::nip19::ToBech32;
3639
3740
#[tokio::main]
3841
async fn main() -> Result<()> {

crates/nostr-sdk/examples/client-with-opts.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
use std::net::{Ipv4Addr, SocketAddr, SocketAddrV4};
55
use std::time::Duration;
66

7+
use nostr_sdk::key::SecretKey;
8+
use nostr_sdk::nips::nip04::decrypt;
9+
use nostr_sdk::prelude::nip19::FromBech32;
710
use nostr_sdk::prelude::*;
811

912
const BECH32_SK: &str = "nsec1ufnus6pju578ste3v90xd5m2decpuzpql2295m3sknqcjzyys9ls0qlc85";

crates/nostr-sdk/examples/client.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) 2022-2023 Yuki Kishimoto
22
// Distributed under the MIT software license
33

4+
use nostr_sdk::key::SecretKey;
5+
use nostr_sdk::prelude::nip19::FromBech32;
46
use nostr_sdk::prelude::*;
57

68
const BECH32_SK: &str = "nsec1ufnus6pju578ste3v90xd5m2decpuzpql2295m3sknqcjzyys9ls0qlc85";

crates/nostr-sdk/examples/nostr-connect.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33

44
use std::time::Duration;
55

6+
use nostr_sdk::client::RemoteSigner;
7+
use nostr_sdk::key::SecretKey;
8+
use nostr_sdk::key::XOnlyPublicKey;
9+
use nostr_sdk::nips::nip46::NostrConnectMetadata;
10+
use nostr_sdk::nips::nip46::NostrConnectURI;
11+
use nostr_sdk::prelude::nip19::FromBech32;
612
use nostr_sdk::prelude::*;
713

814
const APP_SECRET_KEY: &str = "nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99";

crates/nostr-sdk/src/client/mod.rs

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ impl Client {
125125
/// # Example
126126
/// ```rust,no_run
127127
/// use nostr_sdk::prelude::*;
128+
/// use nostr::Keys;
128129
///
129130
/// let my_keys = Keys::generate();
130131
/// let client = Client::new(&my_keys);
@@ -138,6 +139,7 @@ impl Client {
138139
/// # Example
139140
/// ```rust,no_run
140141
/// use nostr_sdk::prelude::*;
142+
/// use nostr::Keys;
141143
///
142144
/// let my_keys = Keys::generate();
143145
/// let opts = Options::new().wait_for_send(true);
@@ -283,6 +285,7 @@ impl Client {
283285
/// # Example
284286
/// ```rust,no_run
285287
/// use nostr_sdk::prelude::*;
288+
/// use nostr::Keys;
286289
///
287290
/// # #[tokio::main]
288291
/// # async fn main() {
@@ -321,6 +324,7 @@ impl Client {
321324
/// # Example
322325
/// ```rust,no_run
323326
/// use nostr_sdk::prelude::*;
327+
/// use nostr::Keys;
324328
///
325329
/// # #[tokio::main]
326330
/// # async fn main() {
@@ -366,7 +370,7 @@ impl Client {
366370
/// # Example
367371
/// ```rust,no_run
368372
/// use nostr_sdk::prelude::*;
369-
///
373+
/// use nostr::Keys;
370374
/// # #[tokio::main]
371375
/// # async fn main() {
372376
/// # let my_keys = Keys::generate();
@@ -418,6 +422,7 @@ impl Client {
418422
/// # Example
419423
/// ```rust,no_run
420424
/// use nostr_sdk::prelude::*;
425+
/// use nostr::Keys;
421426
///
422427
/// # #[tokio::main]
423428
/// # async fn main() {
@@ -448,6 +453,7 @@ impl Client {
448453
/// # Example
449454
/// ```rust,no_run
450455
/// use nostr_sdk::prelude::*;
456+
/// use nostr::Keys;
451457
///
452458
/// # #[tokio::main]
453459
/// # async fn main() {
@@ -476,7 +482,7 @@ impl Client {
476482
/// # Example
477483
/// ```rust,no_run
478484
/// use nostr_sdk::prelude::*;
479-
///
485+
/// use nostr::Keys;
480486
/// # #[tokio::main]
481487
/// # async fn main() {
482488
/// # let my_keys = Keys::generate();
@@ -493,7 +499,7 @@ impl Client {
493499
/// # Example
494500
/// ```rust,no_run
495501
/// use nostr_sdk::prelude::*;
496-
///
502+
/// use nostr::Keys;
497503
/// # #[tokio::main]
498504
/// # async fn main() {
499505
/// # let my_keys = Keys::generate();
@@ -510,7 +516,7 @@ impl Client {
510516
/// # Example
511517
/// ```rust,no_run
512518
/// use nostr_sdk::prelude::*;
513-
///
519+
/// use nostr::Keys;
514520
/// # #[tokio::main]
515521
/// # async fn main() {
516522
/// # let my_keys = Keys::generate();
@@ -540,7 +546,7 @@ impl Client {
540546
/// use std::time::Duration;
541547
///
542548
/// use nostr_sdk::prelude::*;
543-
///
549+
/// use nostr::Keys;
544550
/// # #[tokio::main]
545551
/// # async fn main() {
546552
/// # let my_keys = Keys::generate();
@@ -671,7 +677,7 @@ impl Client {
671677
/// # Example
672678
/// ```rust,no_run
673679
/// use nostr_sdk::prelude::*;
674-
///
680+
/// use nostr::Keys;
675681
/// # #[tokio::main]
676682
/// # async fn main() {
677683
/// # let my_keys = Keys::generate();
@@ -698,7 +704,7 @@ impl Client {
698704
/// # Example
699705
/// ```rust,no_run
700706
/// use nostr_sdk::prelude::*;
701-
///
707+
/// use nostr::Keys;
702708
/// # #[tokio::main]
703709
/// # async fn main() {
704710
/// # let my_keys = Keys::generate();
@@ -724,7 +730,7 @@ impl Client {
724730
/// # Example
725731
/// ```rust,no_run
726732
/// use nostr_sdk::prelude::*;
727-
///
733+
/// use nostr::Keys;
728734
/// # #[tokio::main]
729735
/// # async fn main() {
730736
/// # let my_keys = Keys::generate();
@@ -789,7 +795,7 @@ impl Client {
789795
/// use std::time::Duration;
790796
///
791797
/// use nostr_sdk::prelude::*;
792-
///
798+
/// use nostr::Keys;
793799
/// # #[tokio::main]
794800
/// # async fn main() {
795801
/// # let my_keys = Keys::generate();
@@ -887,7 +893,9 @@ impl Client {
887893
/// # Example
888894
/// ```rust,no_run
889895
/// use nostr_sdk::prelude::*;
890-
///
896+
/// use nostr_sdk::key::XOnlyPublicKey;
897+
/// use nostr_sdk::prelude::nip19::FromBech32;
898+
/// use nostr::Keys;
891899
/// # #[tokio::main]
892900
/// # async fn main() {
893901
/// # let my_keys = Keys::generate();
@@ -974,7 +982,8 @@ impl Client {
974982
/// use std::str::FromStr;
975983
///
976984
/// use nostr_sdk::prelude::*;
977-
///
985+
/// use nostr_sdk::key::XOnlyPublicKey;
986+
/// use nostr::Keys;
978987
/// # #[tokio::main]
979988
/// # async fn main() {
980989
/// # let my_keys = Keys::generate();
@@ -1008,7 +1017,8 @@ impl Client {
10081017
/// use std::str::FromStr;
10091018
///
10101019
/// use nostr_sdk::prelude::*;
1011-
///
1020+
/// use nostr_sdk::key::XOnlyPublicKey;
1021+
/// use nostr::Keys;
10121022
/// # #[tokio::main]
10131023
/// # async fn main() {
10141024
/// # let my_keys = Keys::generate();
@@ -1042,7 +1052,8 @@ impl Client {
10421052
/// use std::str::FromStr;
10431053
///
10441054
/// use nostr_sdk::prelude::*;
1045-
///
1055+
/// use nostr_sdk::key::XOnlyPublicKey;
1056+
/// use nostr::Keys;
10461057
/// # #[tokio::main]
10471058
/// # async fn main() {
10481059
/// # let my_keys = Keys::generate();

crates/nostr-sdk/src/client/signer/remote.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ impl Client {
6666
/// use std::time::Duration;
6767
///
6868
/// use nostr_sdk::prelude::*;
69+
/// use nostr_sdk::client::RemoteSigner;
6970
///
7071
/// #[tokio::main]
7172
/// async fn main() {
@@ -87,6 +88,8 @@ impl Client {
8788
/// use std::str::FromStr;
8889
///
8990
/// use nostr_sdk::prelude::*;
91+
/// use nostr_sdk::key::XOnlyPublicKey;
92+
/// use nostr_sdk::client::RemoteSigner;
9093
///
9194
/// #[tokio::main]
9295
/// async fn main() {

crates/nostr-sdk/src/prelude.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
pub use nostr::prelude::*;
88

99
// Internal modules
10-
pub use crate::client::*;
11-
pub use crate::relay::*;
10+
pub use crate::client;
11+
pub use crate::relay;
1212
pub use crate::*;

crates/nostr/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ tungstenite = { version = "0.18", features = ["rustls-tls-webpki-roots"]}
2424

2525
```rust,no_run
2626
use nostr::prelude::*;
27+
use nostr::Keys;
28+
use nostr::Event;
29+
use nostr::Metadata;
30+
use nostr::EventBuilder;
31+
use nostr::ClientMessage;
32+
use crate::nostr::nips::nip19::ToBech32;
2733
use tungstenite::{Message as WsMessage};
2834
2935
fn main() -> Result<()> {

crates/nostr/examples/nip13.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33

44
use std::str::FromStr;
55

6+
use nostr::key::SecretKey;
67
use nostr::prelude::*;
8+
use nostr::Event;
9+
use nostr::EventBuilder;
10+
use nostr::Keys;
711

812
const ALICE_SK: &str = "6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e";
913

0 commit comments

Comments
 (0)