Skip to content

Commit 98ffb3d

Browse files
committed
Fix nostr-connect example
Signed-off-by: Yuki Kishimoto <[email protected]>
1 parent c528033 commit 98ffb3d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

examples/nostr-connect.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
1-
const { Keys, Client, NostrSigner, NostrConnect, NostrConnectURI, loadWasmAsync, initLogger, LogLevel, Duration } = require("../");
2-
const {EventBuilder} = require("../pkg/nostr_sdk_js");
1+
const { Keys, Client, NostrSigner, NostrConnect, NostrConnectURI, loadWasmAsync, initLogger, LogLevel, Duration, EventBuilder } = require("../");
32

43
async function main() {
54
await loadWasmAsync();
65

76
initLogger(LogLevel.info());
87

98
// App keys
10-
let appKeys = Keys.parse("...");
9+
let appKeys = Keys.parse("nsec1lxxqxj4z2ru8p7d45m48thlcfaj594fw4jaj8tfp8zpxylh4ahsscs359t");
1110

1211
// Remote signer (NIP46)
13-
let uri = NostrConnectURI.parse("bunker://..");
12+
let uri = NostrConnectURI.parse("bunker://...");
1413
let timeout = Duration.fromSecs(60);
15-
let nip46 = new NostrConnect(uri, appKeys, timeout);
16-
let signer = NostrSigner.nip46(nip46);
14+
let connect = new NostrConnect(uri, appKeys, timeout);
15+
let signer = NostrSigner.nip46(connect);
1716

1817
// Compose client and add relays
1918
let client = new Client(signer);
2019
await client.addRelay("wss://relay.damus.io");
2120
await client.addRelay("wss://nos.lol");
2221
await client.addRelay("wss://nostr.oxtr.dev");
2322
await client.connect();
24-
25-
let builder = EventBuilder.textNote("My first text note from rust-nostr WASM with NIP46 signer!", []);
26-
await client.sendEventBuilder(builder);
23+
24+
let builder = EventBuilder.textNote("Text note from rust-nostr WASM with NIP46 signer!");
25+
let output = await client.sendEventBuilder(builder);
26+
console.log("ID:", output.id.toBech32());
27+
console.log("Sent to:", output.success);
28+
console.log("Failed to send to:", output.failed);
2729
}
2830

2931
main();

0 commit comments

Comments
 (0)