diff --git a/book/snippets/js/src/hello.ts b/book/snippets/js/src/hello.ts index 15a1d80fd..36f785d15 100644 --- a/book/snippets/js/src/hello.ts +++ b/book/snippets/js/src/hello.ts @@ -20,8 +20,8 @@ export async function hello() { // ANCHOR: output console.log("Event ID:", res.id.toBech32()); - console.log("Successfully sent to:", res.output.success); - console.log("Failed to sent to:", res.output.failed); + console.log("Sent to:", res.output.success); + console.log("Not sent to:", res.output.failed); // ANCHOR_END: output } // ANCHOR_END: full diff --git a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Hello.kt b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Hello.kt index 5835cdc4a..c87fb2c5f 100644 --- a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Hello.kt +++ b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Hello.kt @@ -17,11 +17,13 @@ suspend fun hello() { // ANCHOR: publish val builder = EventBuilder.textNote("Hello, rust-nostr!") - client.sendEventBuilder(builder) + val res = client.sendEventBuilder(builder) // ANCHOR_END: publish // ANCHOR: output - // TODO + println("Event ID: ${res.id.toBech32()}") + println("Sent to: ${res.output.success}") + println("Not sent to: ${res.output.failed}") // ANCHOR_END: output } // ANCHOR_END: full diff --git a/book/snippets/python/src/hello.py b/book/snippets/python/src/hello.py index 97830fbb5..feee17e8b 100644 --- a/book/snippets/python/src/hello.py +++ b/book/snippets/python/src/hello.py @@ -20,8 +20,8 @@ async def hello(): # ANCHOR: output print(f"Event ID: {res.id.to_bech32()}") - print(f"Successfully sent to: {res.output.success}") - print(f"Failed to send to: {res.output.failed}") + print(f"Sent to: {res.output.success}") + print(f"Not send to: {res.output.failed}") # ANCHOR_END: output # ANCHOR_END: full diff --git a/book/snippets/swift/NostrSnippets/Sources/Hello.swift b/book/snippets/swift/NostrSnippets/Sources/Hello.swift new file mode 100644 index 000000000..a67d56a23 --- /dev/null +++ b/book/snippets/swift/NostrSnippets/Sources/Hello.swift @@ -0,0 +1,28 @@ +// ANCHOR: full +import Foundation +import NostrSDK + +func hello() async throws { + // ANCHOR: client + let keys = Keys.generate() + let signer = NostrSigner.keys(keys: keys) + let client = Client(signer: signer) + // ANCHOR_END: client + + // ANCHOR: connect + try await client.addRelay(url: "wss://relay.damus.io") + await client.connect() + // ANCHOR_END: connect + + // ANCHOR: publish + let builder = EventBuilder.textNote(content: "Hello, rust-nostr!") + let output = try await client.sendEventBuilder(builder: builder) + // ANCHOR_END: publish + + // ANCHOR: output + print("Event ID: \(try output.id.toBech32())") + print("Sent to: \(output.success)") + print("Not sent to: \(output.failed)") + // ANCHOR_END: output +} +// ANCHOR_END: full diff --git a/book/src/sdk/hello.md b/book/src/sdk/hello.md index a679e388e..c7b22fb29 100644 --- a/book/src/sdk/hello.md +++ b/book/src/sdk/hello.md @@ -46,7 +46,9 @@ The first step is to generate random keys needed for the client and construct th