Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yukibtc committed Feb 6, 2023
1 parent 53c7cf2 commit 8ee2ef1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 17 deletions.
15 changes: 13 additions & 2 deletions crates/nostr-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn main() -> Result<()> {
.picture(Url::parse("https://example.com/avatar.png")?)
.banner(Url::parse("https://example.com/banner.png")?)
.nip05("[email protected]")
.lud16("yuki@stacker.news");
.lud16("yuki@getalby.com");
// Update metadata
client.set_metadata(metadata).await?;
Expand All @@ -80,11 +80,22 @@ async fn main() -> Result<()> {
// Publish a POW text note
client.publish_pow_text_note("My first POW text note from Nostr SDK!", &[], 20).await?;
// Send custom event
let event_id = EventId::from_bech32("note1z3lwphdc7gdf6n0y4vaaa0x7ck778kg638lk0nqv2yd343qda78sf69t6r")?;
let public_key = XOnlyPublicKey::from_bech32("npub14rnkcwkw0q5lnmjye7ffxvy7yxscyjl3u4mrr5qxsks76zctmz3qvuftjz")?;
let event: Event = EventBuilder::new_reaction(event_id, public_key, "🧡").to_event(&my_keys)?;
// Send custom event to all relays
// client.send_event(event).await?;
// Send custom event to a specific previously added relay
client.send_event_to("wss://relay.damus.io", event).await?;
// Handle notifications
loop {
let mut notifications = client.notifications();
while let Ok(notification) = notifications.recv().await {
println!("{:?}", notification);
println!("{notification:?}");
}
}
}
Expand Down
26 changes: 13 additions & 13 deletions crates/nostr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fn main() -> Result<()> {
.picture(Url::parse("https://example.com/avatar.png")?)
.banner(Url::parse("https://example.com/banner.png")?)
.nip05("[email protected]")
.lud16("yuki@stacker.news");
.lud16("yuki@getalby.com");
let event: Event = EventBuilder::set_metadata(metadata)?.to_event(&my_keys)?;
Expand All @@ -69,6 +69,18 @@ fn main() -> Result<()> {

More examples can be found in the [examples](https://github.com/rust-nostr/nostr/tree/master/crates/nostr/examples) directory.

## WASM

This crate supports the `wasm32` targets.

On macOS you need to install `llvm`:

```shell
brew install llvm
LLVM_PATH=$(brew --prefix llvm)
AR="${LLVM_PATH}/bin/llvm-ar" CC="${LLVM_PATH}/bin/clang" cargo build --target wasm32-unknown-unknown
```

## Crate Feature Flags

The following crate feature flags are available:
Expand All @@ -87,18 +99,6 @@ The following crate feature flags are available:
| `nip19` | Yes | Enable NIP-19: bech32-encoded entities |
| `nip26` | Yes | Enable NIP-26: Delegated Event Signing |

## WASM

This crate supports the `wasm32` targets.

On macOS you need to install `llvm`:

```shell
brew install llvm
LLVM_PATH=$(brew --prefix llvm)
AR="${LLVM_PATH}/bin/llvm-ar" CC="${LLVM_PATH}/bin/clang" cargo build --target wasm32-unknown-unknown
```

## Supported NIPs

| Supported | NIP |
Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/examples/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() -> Result<()> {
.picture(Url::parse("https://example.com/avatar.png")?)
.banner(Url::parse("https://example.com/banner.png")?)
.nip05("[email protected]")
.lud16("yuki@stacker.news");
.lud16("yuki@getalby.com");

let event: Event = EventBuilder::set_metadata(metadata)?.to_event(&my_keys)?;

Expand Down
2 changes: 1 addition & 1 deletion crates/nostr/src/event/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl EventBuilder {
/// .about("Description")
/// .picture(Url::parse("https://example.com/avatar.png").unwrap())
/// .nip05("[email protected]")
/// .lud16("yuki@stacker.news");
/// .lud16("yuki@getalby.com");
///
/// let builder = EventBuilder::set_metadata(metadata).unwrap();
/// ```
Expand Down

0 comments on commit 8ee2ef1

Please sign in to comment.