Skip to content

Commit

Permalink
book: use @rust-nostr/nostr-sdk package instead of `@rust-nostr/nos…
Browse files Browse the repository at this point in the history
…tr` for all docs

Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Oct 30, 2024
1 parent cfd2db9 commit 6678c32
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion book/snippets/nostr/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@rust-nostr/nostr": "0.35.0",
"@rust-nostr/nostr-sdk": "0.35.0",
"bip39": "^3.1.0"
}
}
2 changes: 1 addition & 1 deletion book/snippets/nostr/js/src/event/builder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Keys, loadWasmSync, EventBuilder, Tag, Timestamp, Kind } = require("@rust-nostr/nostr");
const { Keys, loadWasmSync, EventBuilder, Tag, Timestamp, Kind } = require("@rust-nostr/nostr-sdk");

function eventBuilder() {
// Load WASM
Expand Down
4 changes: 2 additions & 2 deletions book/snippets/nostr/js/src/event/json.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadWasmSync, Event } = require("@rust-nostr/nostr");
const { loadWasmSync, Event } = require("@rust-nostr/nostr-sdk");

function eventJson() {
// Load WASM
Expand All @@ -13,4 +13,4 @@ function eventJson() {
console.log(json2);
}

module.exports.eventJson = eventJson;
module.exports.eventJson = eventJson;
2 changes: 1 addition & 1 deletion book/snippets/nostr/js/src/keys.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Keys, SecretKey, PublicKey, loadWasmSync } = require("@rust-nostr/nostr");
const { Keys, SecretKey, loadWasmSync } = require("@rust-nostr/nostr-sdk");

// ANCHOR: generate
function generate() {
Expand Down
6 changes: 3 additions & 3 deletions book/snippets/nostr/js/src/messages/relay.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { RelayMessage, EventBuilder, Keys, loadWasmAsync } = require('@rust-nostr/nostr');
const { RelayMessage, EventBuilder, Keys, loadWasmAsync } = require("@rust-nostr/nostr-sdk");

async function run() {
await loadWasmAsync();
Expand Down Expand Up @@ -50,7 +50,7 @@ async function run() {
// ANCHOR_END: parse-message

console.log();
// ANCHOR: auth-message
// ANCHOR: auth-message
console.log(" Auth Relay Message:");
relayMessage = RelayMessage.auth("I Challenge You To A Duel! (or some other challenge string)");
console.log(` - JSON: ${relayMessage.asJson()}`);
Expand All @@ -64,4 +64,4 @@ async function run() {
// ANCHOR_END: count-message
}

module.exports.run = run;
module.exports.run = run;
6 changes: 3 additions & 3 deletions book/snippets/nostr/js/src/nip01.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadWasmSync, Keys, Metadata, EventBuilder } = require("@rust-nostr/nostr");
const { loadWasmSync, Keys, Metadata, EventBuilder } = require("@rust-nostr/nostr-sdk");

function run() {
// Load WASM
Expand All @@ -25,7 +25,7 @@ function run() {
// Signed event and print details
console.log("Creating Metadata Event:");
let event = builder.toEvent(keys);

console.log(" Event Details:");
console.log(` Author : ${event.author.toBech32()}`);
console.log(` Kind : ${event.kind.valueOf()}`);
Expand Down Expand Up @@ -53,4 +53,4 @@ function run() {
// ANCHOR_END: create-metadata
}

module.exports.run = run;
module.exports.run = run;
2 changes: 1 addition & 1 deletion book/snippets/nostr/js/src/nip05.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadWasmAsync, PublicKey, Metadata, verifyNip05, getNip05Profile } = require("@rust-nostr/nostr");
const { loadWasmAsync, PublicKey, Metadata, verifyNip05, getNip05Profile } = require("@rust-nostr/nostr-sdk");

async function run() {
// Load WASM
Expand Down
4 changes: 2 additions & 2 deletions book/snippets/nostr/js/src/nip06.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadWasmSync, Keys} = require("@rust-nostr/nostr");
const { loadWasmSync, Keys} = require("@rust-nostr/nostr-sdk");
const { generateMnemonic } = require("bip39");

function run() {
Expand Down Expand Up @@ -74,4 +74,4 @@ function run() {
// ANCHOR_END: keys-from-seed-accounts-pass
}

module.exports.run = run;
module.exports.run = run;
2 changes: 1 addition & 1 deletion 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, Coordinate, Kind } = require("@rust-nostr/nostr");
const { loadWasmSync, Keys, EventBuilder, Nip19Profile, Nip19Event, Coordinate, Kind } = require("@rust-nostr/nostr-sdk");

function run() {
// Load WASM
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/nostr/js/src/nip21.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadWasmSync, Keys, EventBuilder, Nip19Profile, Nip19Event, Coordinate} = require("@rust-nostr/nostr");
const { loadWasmSync, Keys, EventBuilder, Nip19Profile, Nip19Event, Coordinate} = require("@rust-nostr/nostr-sdk");

function run(){
// Load WASM
Expand Down
6 changes: 3 additions & 3 deletions book/snippets/nostr/js/src/nip44.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { Keys, PublicKey, nip44Encrypt, nip44Decrypt, NIP44Version, loadWasmSync } = require("@rust-nostr/nostr");
const { Keys, PublicKey, nip44Encrypt, nip44Decrypt, NIP44Version, loadWasmSync } = require("@rust-nostr/nostr-sdk");

function run() {
loadWasmSync();

let keys = Keys.generate();

let public_key = PublicKey.fromHex("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798");

let ciphertext = nip44Encrypt(keys.secretKey, public_key, "my message", NIP44Version.V2)
Expand All @@ -14,4 +14,4 @@ function run() {
console.log("Decrypted: " + plaintext)
}

module.exports.run = run;
module.exports.run = run;
4 changes: 2 additions & 2 deletions book/snippets/nostr/js/src/nip59.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Keys, EventBuilder, UnwrappedGift, loadWasmSync } = require("@rust-nostr/nostr");
const { Keys, EventBuilder, UnwrappedGift, loadWasmSync } = require("@rust-nostr/nostr-sdk");

function run() {
loadWasmSync();
Expand All @@ -22,4 +22,4 @@ function run() {
console.log("Rumor: ", unwrapped_gift.rumor.asJson())
}

module.exports.run = run;
module.exports.run = run;
2 changes: 1 addition & 1 deletion book/snippets/nostr/js/src/nip65.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { loadWasmSync, Keys, EventBuilder, Tag, RelayMetadata, RelayListItem, Kind } = require("@rust-nostr/nostr");
const { loadWasmSync, Keys, EventBuilder, Tag, RelayMetadata, RelayListItem, Kind } = require("@rust-nostr/nostr-sdk");

function run(){
// Load WASM
Expand Down
8 changes: 4 additions & 4 deletions book/src/nostr/02-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ uniffi_set_event_loop(asyncio.get_running_loop())
The `nostr` package is available on the public [npmjs](https://npmjs.com):

```bash
npm i @rust-nostr/nostr
npm i @rust-nostr/nostr-sdk
```

Alternatively, you can manually add the dependency in your `package.json` file:

```json
{
"dependencies": {
"@rust-nostr/nostr": "0.35.0"
"@rust-nostr/nostr-sdk": "0.35.0"
}
}
```
Expand All @@ -112,7 +112,7 @@ This library to work **require** to load the WASM code.
#### Load in **async** context

```javascript,ignore
const { loadWasmAsync } = require("@rust-nostr/nostr");
const { loadWasmAsync } = require("@rust-nostr/nostr-sdk");
async function main() {
// Load WASM
Expand All @@ -127,7 +127,7 @@ main();
#### Load in **sync** context

```javascript,ignore
const { loadWasmSync } = require("@rust-nostr/nostr");
const { loadWasmSync } = require("@rust-nostr/nostr-sdk");
function main() {
// Load WASM
Expand Down

0 comments on commit 6678c32

Please sign in to comment.