|
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("../"); |
3 | 2 |
|
4 | 3 | async function main() {
|
5 | 4 | await loadWasmAsync();
|
6 | 5 |
|
7 | 6 | initLogger(LogLevel.info());
|
8 | 7 |
|
9 | 8 | // App keys
|
10 |
| - let appKeys = Keys.parse("..."); |
| 9 | + let appKeys = Keys.parse("nsec1lxxqxj4z2ru8p7d45m48thlcfaj594fw4jaj8tfp8zpxylh4ahsscs359t"); |
11 | 10 |
|
12 | 11 | // Remote signer (NIP46)
|
13 |
| - let uri = NostrConnectURI.parse("bunker://.."); |
| 12 | + let uri = NostrConnectURI.parse("bunker://..."); |
14 | 13 | 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); |
17 | 16 |
|
18 | 17 | // Compose client and add relays
|
19 | 18 | let client = new Client(signer);
|
20 | 19 | await client.addRelay("wss://relay.damus.io");
|
21 | 20 | await client.addRelay("wss://nos.lol");
|
22 | 21 | await client.addRelay("wss://nostr.oxtr.dev");
|
23 | 22 | 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); |
27 | 29 | }
|
28 | 30 |
|
29 | 31 | main();
|
0 commit comments