Skip to content

Commit

Permalink
book: add NIP05 & NIP19 JavaScript examples
Browse files Browse the repository at this point in the history
Removed nrelay example.
  • Loading branch information
RydalWater committed Sep 10, 2024
1 parent 9e6a4c8 commit 5f06a21
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
15 changes: 1 addition & 14 deletions book/snippets/nostr/js/src/nip19.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadWasmSync, Keys, EventBuilder, Nip19Profile, Nip19Event, Nip19Relay} = require("@rust-nostr/nostr");
const { loadWasmSync, Keys, EventBuilder, Nip19Profile, Nip19Event} = require("@rust-nostr/nostr");

function run() {
// Load WASM
Expand Down Expand Up @@ -50,19 +50,6 @@ function run() {
console.log(` Event (decoded): ${decode_nevent.eventId().toBech32()}`);
// ANCHOR_END: nip19-nevent-decode

console.log();
// ANCHOR: nip19-nrelay-encode
// Create NIP-19 relay
let relay = new Nip19Relay("wss://relay.damus.io");
console.log(` Relay (encoded): ${relay.toBech32()}`);
// ANCHOR_END: nip19-nrelay-encode

// ANCHOR: nip19-nrelay-decode
// Decode NIP-19 relay
let decode_relay = Nip19Relay.fromBech32(relay.toBech32());
console.log(` Relay (decoded): ${decode_relay.url()}`);
// ANCHOR_END: nip19-nrelay-decode

}

module.exports.run = run;
10 changes: 0 additions & 10 deletions book/src/nostr/06-nip19.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,16 +116,6 @@ Using the `Nip19Event` class to create a shareable `nevent` that includes author
{{#include ../../snippets/nostr/js/src/nip19.js:nip19-nevent-decode}}
```

In addition to the above objects the `Nip19Relay` class can also be used to create a shareable `nrelay`, however it should be noted that per [NIP-19 documentation](https://github.com/nostr-protocol/nips/blob/master/19.md#shareable-identifiers-with-extra-metadata) this is now depreciated. This is followed by decoding the event object.

```javascript,ignore
{{#include ../../snippets/nostr/js/src/nip19.js:nip19-nrelay-encode}}
```

```javascript,ignore
{{#include ../../snippets/nostr/js/src/nip19.js:nip19-nrelay-decode}}
```

</section>

<div slot="title">Kotlin</div>
Expand Down

0 comments on commit 5f06a21

Please sign in to comment.