diff --git a/CHANGELOG.md b/CHANGELOG.md index 8caffa701..243dabdad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,10 +25,15 @@ --> -## [Unreleased] +## [v0.37.0] ### Summary +Add support to NIP17 relay list in SDK (when `gossip` option is enabled), add NIP22 and NIP73 support, +fix Swift Package, many performance improvements and bug fixes (mainly related to SDK `disconnect` methods) and more! + +From this release all the rust features are be disabled by default (except `std` feature in `nostr` crate). + ### Breaking changes * Use `RelayUrl` struct instead of `Url` for relay urls ([Yuki Kishimoto]) @@ -40,7 +45,7 @@ * nostr: remove `tags` arg from `EventBuilder::long_form_text_note` ([Yuki Kishimoto]) * nostr: remove `tags` arg from `EventBuilder::job_request` ([Yuki Kishimoto]) * nostr: disable all default features except `std` ([Yuki Kishimoto]) -* nostr: change `Timestamp::to_human_datetime` fingerprint ([Yuki Kishimoto]) +* nostr: change `Timestamp::to_human_datetime` method signature ([Yuki Kishimoto]) * nostr: change `Tag::parse` arg from slice to iterator ([Yuki Kishimoto]) * nostr: change `TagStandard::Relay` variant inner type ([Yuki Kishimoto]) * nostr: remove `UncheckedUrl` struct ([Yuki Kishimoto]) @@ -815,7 +820,8 @@ added `nostrdb` storage backend, added NIP32 and completed NIP51 support and mor [erskingardner]: https://github.com/erskingardner -[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.36.0...HEAD +[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.37.0...HEAD +[v0.37.0]: https://github.com/rust-nostr/nostr/compare/v0.36.0...v0.37.0 [v0.36.0]: https://github.com/rust-nostr/nostr/compare/v0.35.0...v0.36.0 [v0.35.0]: https://github.com/rust-nostr/nostr/compare/v0.34.0...v0.35.0 [v0.34.0]: https://github.com/rust-nostr/nostr/compare/v0.33.0...v0.34.0 diff --git a/book/snippets/js/package.json b/book/snippets/js/package.json index b5cd22656..ba02847ab 100644 --- a/book/snippets/js/package.json +++ b/book/snippets/js/package.json @@ -5,7 +5,7 @@ "type": "module", "license": "MIT", "dependencies": { - "@rust-nostr/nostr-sdk": "0.36.0", + "@rust-nostr/nostr-sdk": "0.37.0", "bip39": "^3.1.0" }, "devDependencies": { diff --git a/book/snippets/js/src/event/builder.ts b/book/snippets/js/src/event/builder.ts index bf77c4b09..167c13da6 100644 --- a/book/snippets/js/src/event/builder.ts +++ b/book/snippets/js/src/event/builder.ts @@ -5,25 +5,27 @@ export function eventBuilder() { // Compose custom event let kind = new Kind(1111); - let customEvent = new EventBuilder(kind, "", []).signWithKeys(keys); + let customEvent = new EventBuilder(kind, "").signWithKeys(keys); // Compose text note - let textnoteEvent = EventBuilder.textNote("Hello", []).signWithKeys(keys); + let textnoteEvent = EventBuilder.textNote("Hello").signWithKeys(keys); // Compose reply to above text note let replyEvent = - EventBuilder.textNote("Reply to hello", [Tag.event(textnoteEvent.id)]) + EventBuilder.textNote("Reply to hello") + .tags([Tag.event(textnoteEvent.id)]) .signWithKeys(keys); // Compose POW event let powEvent = - EventBuilder.textNote("Another reply with POW", [Tag.event(textnoteEvent.id)]) + EventBuilder.textNote("Another reply with POW") + .tags([Tag.event(textnoteEvent.id)]) .pow(20) .signWithKeys(keys); // Compose note with custom timestamp let customTimestamp = - EventBuilder.textNote("Note with custom timestamp", []) + EventBuilder.textNote("Note with custom timestamp") .customCreatedAt(Timestamp.fromSecs(12345678)) .signWithKeys(keys); } diff --git a/book/snippets/js/src/hello.ts b/book/snippets/js/src/hello.ts index 94d5f7853..15a1d80fd 100644 --- a/book/snippets/js/src/hello.ts +++ b/book/snippets/js/src/hello.ts @@ -14,7 +14,7 @@ export async function hello() { // ANCHOR_END: connect // ANCHOR: publish - let builder = EventBuilder.textNote("Hello, rust-nostr!", []); + let builder = EventBuilder.textNote("Hello, rust-nostr!"); let res = await client.sendEventBuilder(builder); // ANCHOR_END: publish diff --git a/book/snippets/js/src/messages/client.ts b/book/snippets/js/src/messages/client.ts index 8eda48611..1873420c8 100644 --- a/book/snippets/js/src/messages/client.ts +++ b/book/snippets/js/src/messages/client.ts @@ -2,7 +2,7 @@ import { ClientMessage, EventBuilder, Filter, Keys } from "@rust-nostr/nostr-sdk export async function run() { const keys = Keys.generate(); - const event = EventBuilder.textNote("TestTextNoTe", []).signWithKeys(keys); + const event = EventBuilder.textNote("TestTextNoTe").signWithKeys(keys); console.log() console.log("Client Messages:"); diff --git a/book/snippets/js/src/messages/filters.ts b/book/snippets/js/src/messages/filters.ts index 9ae7e6241..69461a86d 100644 --- a/book/snippets/js/src/messages/filters.ts +++ b/book/snippets/js/src/messages/filters.ts @@ -9,8 +9,10 @@ export async function run() { const kind1 = new Kind(1); const kind4 = new Kind(4); - const event = EventBuilder.textNote("Hello World!", []).signWithKeys(keys); - const event2 = new EventBuilder(kind0, "Goodbye World!", [Tag.identifier("Identification D Tag")]).signWithKeys(keys2); + const event = EventBuilder.textNote("Hello World!").signWithKeys(keys); + const event2 = new EventBuilder(kind0, "Goodbye World!") + .tags([Tag.identifier("Identification D Tag")]) + .signWithKeys(keys2); console.log(); console.log("Creating Filters:"); diff --git a/book/snippets/js/src/messages/relay.ts b/book/snippets/js/src/messages/relay.ts index 1efe8a5bb..a11c70699 100644 --- a/book/snippets/js/src/messages/relay.ts +++ b/book/snippets/js/src/messages/relay.ts @@ -2,7 +2,7 @@ import { RelayMessage, EventBuilder, Keys } from "@rust-nostr/nostr-sdk"; export async function run() { const keys = Keys.generate(); - const event = EventBuilder.textNote("TestTextNoTe", []).signWithKeys(keys); + const event = EventBuilder.textNote("TestTextNoTe").signWithKeys(keys); console.log("\nRelay Messages:"); diff --git a/book/snippets/js/src/nip19.ts b/book/snippets/js/src/nip19.ts index a023557cb..7c41b3349 100644 --- a/book/snippets/js/src/nip19.ts +++ b/book/snippets/js/src/nip19.ts @@ -15,7 +15,7 @@ export function run() { // ANCHOR_END: nip19-nsec // ANCHOR: nip19-note - let event = EventBuilder.textNote("Hello from Rust Nostr JS Bindings!", []).signWithKeys(keys); + let event = EventBuilder.textNote("Hello from Rust Nostr JS Bindings!").signWithKeys(keys); console.log(` Event : ${event.id.toBech32()}`); // ANCHOR_END: nip19-note diff --git a/book/snippets/js/src/nip21.ts b/book/snippets/js/src/nip21.ts index c3103dda7..d31c95b0b 100644 --- a/book/snippets/js/src/nip21.ts +++ b/book/snippets/js/src/nip21.ts @@ -13,7 +13,7 @@ export function run(){ console.log(); // ANCHOR: note - let event = EventBuilder.textNote("Hello from rust-nostr JS bindings!", []).signWithKeys(keys); + let event = EventBuilder.textNote("Hello from rust-nostr JS bindings!").signWithKeys(keys); let note_uri = event.id.toNostrUri() console.log(` Event (URI): ${note_uri}`); // ANCHOR_END: note diff --git a/book/snippets/js/src/nip47.ts b/book/snippets/js/src/nip47.ts index 014b110f4..9c1f7bac3 100644 --- a/book/snippets/js/src/nip47.ts +++ b/book/snippets/js/src/nip47.ts @@ -1,5 +1,5 @@ // ANCHOR: full -import { NWC, NostrWalletConnectURI, MakeInvoiceRequestParams } from "@rust-nostr/nostr-sdk"; +import { NWC, NostrWalletConnectURI, PayInvoiceRequest, MakeInvoiceRequest } from "@rust-nostr/nostr-sdk"; export async function main() { // Parse NWC uri @@ -17,12 +17,14 @@ export async function main() { console.log("Balance: " + balance + " SAT"); // Pay an invoice - await nwc.payInvoice("lnbc..") + let payInvoiceParams = new PayInvoiceRequest(); + payInvoiceParams.invoice = "lnbc.."; + await nwc.payInvoice(payInvoiceParams); // Make an invoice - let params = new MakeInvoiceRequestParams(); - params.amount = BigInt(100); - const result = await nwc.makeInvoice(params) + let makeInvoiceParams = new MakeInvoiceRequest(); + makeInvoiceParams.amount = BigInt(100); + const result = await nwc.makeInvoice(makeInvoiceParams) console.log("Invoice: " + result.invoice); // Drop client diff --git a/book/snippets/js/src/nip59.ts b/book/snippets/js/src/nip59.ts index ce112fdcb..676b281b9 100644 --- a/book/snippets/js/src/nip59.ts +++ b/book/snippets/js/src/nip59.ts @@ -10,7 +10,7 @@ export async function run() { const bob_signer = NostrSigner.keys(bob_keys); // Compose rumor - const rumor = EventBuilder.textNote("Test", []).build(alice_keys.publicKey) + const rumor = EventBuilder.textNote("Test") // Build gift wrap with sender keys const gw = await EventBuilder.giftWrap(alice_signer, bob_keys.publicKey, rumor) diff --git a/book/snippets/js/src/nip65.ts b/book/snippets/js/src/nip65.ts index 0f47d21df..092c26855 100644 --- a/book/snippets/js/src/nip65.ts +++ b/book/snippets/js/src/nip65.ts @@ -31,9 +31,7 @@ export function run(){ // Build/sign event let kind = new Kind(10002); - let content = ""; - let tags = [tag1, tag2, tag3]; - builder = new EventBuilder(kind, content, tags); + builder = new EventBuilder(kind, "").tags([tag1, tag2, tag3]); event = builder.signWithKeys(keys); // Print event as json diff --git a/book/snippets/kotlin/gradle/libs.versions.toml b/book/snippets/kotlin/gradle/libs.versions.toml index ac63ff076..4c912d0f6 100644 --- a/book/snippets/kotlin/gradle/libs.versions.toml +++ b/book/snippets/kotlin/gradle/libs.versions.toml @@ -3,7 +3,7 @@ agp = "8.1.4" kotlin = "1.9.22" [libraries] -nostr = { module = "org.rust-nostr:nostr-sdk", version = "0.36.0" } +nostr = { module = "org.rust-nostr:nostr-sdk", version = "0.37.0" } [plugins] androidLibrary = { id = "com.android.library", version.ref = "agp" } diff --git a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Event.kt b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Event.kt index ac12dc4e1..577df8ef2 100644 --- a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Event.kt +++ b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Event.kt @@ -19,18 +19,20 @@ fun builder() { val keys = Keys.generate(); // Compose custom event - val customEvent = EventBuilder(Kind(1111u), "", listOf()).signWithKeys(keys); + val customEvent = EventBuilder(kind = Kind(1111u), content = "").signWithKeys(keys); // Compose text note - val textNoteEvent = EventBuilder.textNote("Hello", listOf()).signWithKeys(keys); + val textNoteEvent = EventBuilder.textNote("Hello").signWithKeys(keys); // Compose reply to above text note - val replyEvent = EventBuilder.textNote("Reply to hello", listOf(Tag.event(textNoteEvent.id()))) + val replyEvent = EventBuilder.textNote("Reply to hello") + .tags(listOf(Tag.event(textNoteEvent.id()))) .signWithKeys(keys); // Compose POW event val powEvent = - EventBuilder.textNote("Another reply with POW", listOf(Tag.event(textNoteEvent.id()))) + EventBuilder.textNote("Another reply with POW") + .tags(listOf(Tag.event(textNoteEvent.id()))) .pow(20u) .signWithKeys(keys); println(powEvent.asJson()) 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 d607ddf28..5835cdc4a 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 @@ -5,20 +5,21 @@ import rust.nostr.sdk.* suspend fun hello() { // ANCHOR: client - //val keys = Keys.generate() - //val client = Client(signer = keys) // TODO: uncomment when fixed + val keys = Keys.generate() + val signer = NostrSigner.keys(keys) + val client = Client(signer = signer) // ANCHOR_END: client // ANCHOR: connect - //client.addRelay("wss://relay.damus.io") - //client.connect() + client.addRelay("wss://relay.damus.io") + client.connect() // ANCHOR_END: connect // ANCHOR: publish - //val builder = EventBuilder.textNote("Hello, rust-nostr!", listOf()) - //client.sendEventBuilder(builder) + val builder = EventBuilder.textNote("Hello, rust-nostr!") + client.sendEventBuilder(builder) // ANCHOR_END: publish - + // ANCHOR: output // TODO // ANCHOR_END: output diff --git a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Keys.kt b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Keys.kt index 32cfa4909..2f340a444 100644 --- a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Keys.kt +++ b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/Keys.kt @@ -4,16 +4,16 @@ import rust.nostr.sdk.* // ANCHOR: generate fun generate() { - val keys = Keys.generate(); + val keys = Keys.generate() - val publicKey = keys.publicKey(); - val secretKey = keys.secretKey(); + val publicKey = keys.publicKey() + val secretKey = keys.secretKey() - println("Public key (hex): ${publicKey.toHex()}"); - println("Public key (bech32): ${publicKey.toBech32()}"); + println("Public key (hex): ${publicKey.toHex()}") + println("Public key (bech32): ${publicKey.toBech32()}") - println("Secret key (hex): ${secretKey.toHex()}"); - println("Secret key (bech32): ${secretKey.toHex()}"); + println("Secret key (hex): ${secretKey.toHex()}") + println("Secret key (bech32): ${secretKey.toHex()}") } // ANCHOR_END: generate @@ -34,7 +34,7 @@ fun restore() { fun vanity() { val keys = Keys.vanity(listOf("yuk0"), true, 4u) - println("Public key: ${keys.publicKey().toBech32()}"); - println("Secret key: ${keys.secretKey().toHex()}"); + println("Public key: ${keys.publicKey().toBech32()}") + println("Secret key: ${keys.secretKey().toHex()}") } // ANCHOR_END: vanity diff --git a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/nip47.kt b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/nip47.kt index cb5fa3111..05872fc95 100644 --- a/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/nip47.kt +++ b/book/snippets/kotlin/shared/src/main/kotlin/rust/nostr/snippets/nip47.kt @@ -19,11 +19,12 @@ suspend fun nip47() { println("Balance: $balance SAT") // Pay an invoice - nwc.payInvoice("lnbc..") + val payInvoiceParams = PayInvoiceRequest(invoice = "lnbc...", amount = null, id = null) + nwc.payInvoice(payInvoiceParams) // Make an invoice - val params = MakeInvoiceRequestParams(amount = 100u, description = null, descriptionHash = null, expiry = null) - val result = nwc.makeInvoice(params) + val makeInvoiceParams = MakeInvoiceRequest(amount = 100u, description = null, descriptionHash = null, expiry = null) + val result = nwc.makeInvoice(makeInvoiceParams) println("Invoice: ${result.invoice}") } // ANCHOR_END: full diff --git a/book/snippets/python/requirements.txt b/book/snippets/python/requirements.txt index f954e42d0..bf09d1410 100644 --- a/book/snippets/python/requirements.txt +++ b/book/snippets/python/requirements.txt @@ -1,3 +1,3 @@ mnemonic==0.21 -nostr-sdk==0.36.0 +nostr-sdk==0.37.0 pyright==1.1.389 diff --git a/book/snippets/python/src/event/builder.py b/book/snippets/python/src/event/builder.py index 512cf5634..2813aacfa 100644 --- a/book/snippets/python/src/event/builder.py +++ b/book/snippets/python/src/event/builder.py @@ -5,13 +5,13 @@ def event_builder(): keys = Keys.generate() # Compose custom event - custom_event = EventBuilder(Kind(1111), "", []).sign_with_keys(keys) + custom_event = EventBuilder(Kind(1111), "").sign_with_keys(keys) # Compose text note - textnote_event = EventBuilder.text_note("Hello", []).sign_with_keys(keys) + textnote_event = EventBuilder.text_note("Hello").sign_with_keys(keys) # Compose reply to above text note - reply_event = EventBuilder.text_note("Reply to hello", [Tag.event(textnote_event.id())]).sign_with_keys(keys) + reply_event = EventBuilder.text_note("Reply to hello").tags([Tag.event(textnote_event.id())]).sign_with_keys(keys) # Compose POW event - pow_event = EventBuilder.text_note("Another reply with POW", [Tag.event(textnote_event.id())]).pow(20).sign_with_keys(keys) + pow_event = EventBuilder.text_note("Another reply with POW").tags([Tag.event(textnote_event.id())]).pow(20).sign_with_keys(keys) diff --git a/book/snippets/python/src/event/eventid.py b/book/snippets/python/src/event/eventid.py index 45c9b6f2f..f4b64e8ec 100644 --- a/book/snippets/python/src/event/eventid.py +++ b/book/snippets/python/src/event/eventid.py @@ -56,7 +56,7 @@ def event_id(): # ANCHOR: access-verify # Event ID from Event & Verfiy print(" Event ID from Event & Verify:") - event = EventBuilder.text_note("This is a note", []).sign_with_keys(keys) + event = EventBuilder.text_note("This is a note").sign_with_keys(keys) print(f" - Event ID: {event.id()}") print(f" - Verify the ID & Signature: {event.verify()}") # ANCHOR_END: access-verify diff --git a/book/snippets/python/src/event/kind.py b/book/snippets/python/src/event/kind.py index 1248098b0..17d52a2f0 100644 --- a/book/snippets/python/src/event/kind.py +++ b/book/snippets/python/src/event/kind.py @@ -31,7 +31,7 @@ def kind(): print() # ANCHOR: kind-methods print(" Kind methods EventBuilder:") - event = EventBuilder.text_note("This is a note", []).sign_with_keys(keys) + event = EventBuilder.text_note("This is a note").sign_with_keys(keys) print(f" - Kind text_note(): {event.kind().as_u16()} - {event.kind().as_enum()}") event = EventBuilder.metadata(Metadata()).sign_with_keys(keys) print(f" - Kind metadata(): {event.kind().as_u16()} - {event.kind().as_enum()}") diff --git a/book/snippets/python/src/hello.py b/book/snippets/python/src/hello.py index 841a97ccb..97830fbb5 100644 --- a/book/snippets/python/src/hello.py +++ b/book/snippets/python/src/hello.py @@ -14,7 +14,7 @@ async def hello(): # ANCHOR_END: connect # ANCHOR: publish - builder = EventBuilder.text_note("Hello, rust-nostr!", []) + builder = EventBuilder.text_note("Hello, rust-nostr!") res = await client.send_event_builder(builder) # ANCHOR_END: publish diff --git a/book/snippets/python/src/messages/client.py b/book/snippets/python/src/messages/client.py index dbf5da541..3273a27ae 100644 --- a/book/snippets/python/src/messages/client.py +++ b/book/snippets/python/src/messages/client.py @@ -4,7 +4,7 @@ def client_message(): keys = Keys.generate() - event = EventBuilder.text_note("TestTextNoTe",[]).sign_with_keys(keys) + event = EventBuilder.text_note("TestTextNoTe").sign_with_keys(keys) print() print("Client Messages:") diff --git a/book/snippets/python/src/messages/filters.py b/book/snippets/python/src/messages/filters.py index 3c68409d4..e1408126a 100644 --- a/book/snippets/python/src/messages/filters.py +++ b/book/snippets/python/src/messages/filters.py @@ -6,8 +6,8 @@ def filters(): # Generate keys and Events keys = Keys.generate() keys2 = Keys.generate() - event = EventBuilder.text_note("Hello World!", []).sign_with_keys(keys) - event2 = EventBuilder(Kind(1),"Goodbye World!", [Tag.identifier("Identification D Tag")]).sign_with_keys(keys2) + event = EventBuilder.text_note("Hello World!").sign_with_keys(keys) + event2 = EventBuilder(Kind(1), "Goodbye World!").tags([Tag.identifier("Identification D Tag")]).sign_with_keys(keys2) print() print("Creating Filters:") diff --git a/book/snippets/python/src/messages/relay.py b/book/snippets/python/src/messages/relay.py index 266e59e65..03f56a471 100644 --- a/book/snippets/python/src/messages/relay.py +++ b/book/snippets/python/src/messages/relay.py @@ -5,7 +5,7 @@ def relay_message(): keys = Keys.generate() - event = EventBuilder.text_note("TestTextNoTe",[]).sign_with_keys(keys) + event = EventBuilder.text_note("TestTextNoTe").sign_with_keys(keys) print() print("Relay Messages:") diff --git a/book/snippets/python/src/nip19.py b/book/snippets/python/src/nip19.py index b8327c874..83eb09c4c 100644 --- a/book/snippets/python/src/nip19.py +++ b/book/snippets/python/src/nip19.py @@ -13,7 +13,7 @@ def nip19(): # ANCHOR_END: nip19-nsec # ANCHOR: nip19-note - event = EventBuilder.text_note("Hello from Rust Nostr Python bindings!", []).sign_with_keys(keys) + event = EventBuilder.text_note("Hello from rust-nostr Python bindings!").sign_with_keys(keys) print(f" Event : {event.id().to_bech32()}") # ANCHOR_END: nip19-note diff --git a/book/snippets/python/src/nip21.py b/book/snippets/python/src/nip21.py index 548308ba8..22307e65a 100644 --- a/book/snippets/python/src/nip21.py +++ b/book/snippets/python/src/nip21.py @@ -21,7 +21,7 @@ def nip21(): print() # ANCHOR: note - event = EventBuilder.text_note("Hello from Rust Nostr Python bindings!", []).sign_with_keys(keys) + event = EventBuilder.text_note("Hello from rust-nostr Python bindings!").sign_with_keys(keys) # URI note note_uri = event.id().to_nostr_uri() diff --git a/book/snippets/python/src/nip47.py b/book/snippets/python/src/nip47.py index 66a683314..569a14ab3 100644 --- a/book/snippets/python/src/nip47.py +++ b/book/snippets/python/src/nip47.py @@ -1,5 +1,5 @@ # ANCHOR: full -from nostr_sdk import NostrWalletConnectUri, Nwc, MakeInvoiceRequestParams +from nostr_sdk import NostrWalletConnectUri, Nwc, PayInvoiceRequest, MakeInvoiceRequest async def main(): @@ -18,10 +18,11 @@ async def main(): print(f"Balance: {balance} SAT") # Pay an invoice - await nwc.pay_invoice("lnbc..") + params = PayInvoiceRequest(invoice = "lnbc..", id = None, amount = None) + await nwc.pay_invoice(params) # Make an invoice - params = MakeInvoiceRequestParams(amount=100, description=None, description_hash=None, expiry=None) + params = MakeInvoiceRequest(amount = 100, description = None, description_hash = None, expiry = None) result = await nwc.make_invoice(params) print(f"Invoice: {result.invoice}") diff --git a/book/snippets/python/src/nip59.py b/book/snippets/python/src/nip59.py index 4071ba2e1..ac9c12ef6 100644 --- a/book/snippets/python/src/nip59.py +++ b/book/snippets/python/src/nip59.py @@ -1,25 +1,27 @@ -from nostr_sdk import Keys, EventBuilder, Event, gift_wrap, UnwrappedGift, UnsignedEvent +from nostr_sdk import Keys, EventBuilder, Event, gift_wrap, UnwrappedGift, UnsignedEvent, NostrSigner async def nip59(): print("\nGift Wrapping (NIP-59):") # Sender Keys alice_keys = Keys.parse("5c0c523f52a5b6fad39ed2403092df8cebc36318b39383bca6c00808626fab3a") + alice_signer = NostrSigner.keys(alice_keys) # Receiver Keys bob_keys = Keys.parse("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99") + bob_signer = NostrSigner.keys(bob_keys) # Compose rumor - rumor = EventBuilder.text_note("Test", []).build(alice_keys.public_key()) + rumor = EventBuilder.text_note("Test") # Build gift wrap with sender keys - gw: Event = await gift_wrap(alice_keys, bob_keys.public_key(), rumor, None) + gw: Event = await gift_wrap(alice_signer, bob_keys.public_key(), rumor, None) print(f" Gift Wrap:\n{gw.as_json()}") # Extract rumor from gift wrap with receiver keys print("\n Unwrapped Gift:") - unwrapped_gift = await UnwrappedGift.from_gift_wrap(bob_keys, gw) + unwrapped_gift = await UnwrappedGift.from_gift_wrap(bob_signer, gw) sender = unwrapped_gift.sender() - rumor: UnsignedEvent = unwrapped_gift.rumor() + unwrapped_rumor: UnsignedEvent = unwrapped_gift.rumor() print(f" Sender: {sender.to_bech32()}") - print(f" Rumor: {rumor.as_json()}") + print(f" Rumor: {unwrapped_rumor.as_json()}") diff --git a/book/snippets/python/src/nip65.py b/book/snippets/python/src/nip65.py index fca1524f9..9c8e9dc8b 100644 --- a/book/snippets/python/src/nip65.py +++ b/book/snippets/python/src/nip65.py @@ -32,9 +32,7 @@ def nip65(): # Build/sign event kind = Kind(10002) - content = "" - tags = [tag1,tag2,tag3] - builder = EventBuilder(kind,content,tags) + builder = EventBuilder(kind = kind, content = "").tags([tag1, tag2, tag3]) event = builder.sign_with_keys(keys) # Print event as json diff --git a/book/snippets/python/src/timestamps.py b/book/snippets/python/src/timestamps.py index b065b0d36..b25672746 100644 --- a/book/snippets/python/src/timestamps.py +++ b/book/snippets/python/src/timestamps.py @@ -26,7 +26,7 @@ def timestamps(): print() # ANCHOR: timestamp-created print(" Created at timestamp:") - event = EventBuilder(Kind(1), "This is some event text.", []).custom_created_at(timestamp).sign_with_keys(alice_keys) + event = EventBuilder(Kind(1), "This is some event text.").custom_created_at(timestamp).sign_with_keys(alice_keys) print(f" Created at: {event.created_at().to_human_datetime()}") # ANCHOR_END: timestamp-created diff --git a/book/snippets/rust/Cargo.toml b/book/snippets/rust/Cargo.toml index c3ead803b..90b6cd755 100644 --- a/book/snippets/rust/Cargo.toml +++ b/book/snippets/rust/Cargo.toml @@ -8,6 +8,6 @@ edition = "2021" members = ["."] [dependencies] -nostr-sdk = "0.36" -nostr-relay-builder = "0.36" +nostr-sdk = { version = "0.37", features = ["all-nips"] } +nostr-relay-builder = "0.37" tokio = { version = "1", features = ["rt-multi-thread", "macros"] } diff --git a/book/snippets/rust/src/event/builder.rs b/book/snippets/rust/src/event/builder.rs index 494821a97..006b42c31 100644 --- a/book/snippets/rust/src/event/builder.rs +++ b/book/snippets/rust/src/event/builder.rs @@ -4,18 +4,20 @@ pub fn event() -> Result<()> { let keys = Keys::generate(); // Compose custom event - let custom_event = EventBuilder::new(Kind::Custom(1111), "", []).sign_with_keys(&keys)?; + let custom_event = EventBuilder::new(Kind::Custom(1111), "").sign_with_keys(&keys)?; // Compose text note - let textnote_event = EventBuilder::text_note("Hello", []).sign_with_keys(&keys)?; + let textnote_event = EventBuilder::text_note("Hello").sign_with_keys(&keys)?; // Compose reply to above text note - let reply_event = EventBuilder::text_note("Reply to hello", [Tag::event(textnote_event.id)]) + let reply_event = EventBuilder::text_note("Reply to hello") + .tag(Tag::event(textnote_event.id)) .sign_with_keys(&keys)?; // Compose POW event let pow_event = - EventBuilder::text_note("Another reply with POW", [Tag::event(textnote_event.id)]) + EventBuilder::text_note("Another reply with POW") + .tag(Tag::event(textnote_event.id)) .pow(20) .sign_with_keys(&keys)?; diff --git a/book/snippets/rust/src/hello.rs b/book/snippets/rust/src/hello.rs index 7b64a2dfe..f0e8c74a9 100644 --- a/book/snippets/rust/src/hello.rs +++ b/book/snippets/rust/src/hello.rs @@ -13,7 +13,7 @@ pub async fn hello() -> Result<()> { // ANCHOR_END: connect // ANCHOR: publish - let builder = EventBuilder::text_note("Hello, rust-nostr!", []); + let builder = EventBuilder::text_note("Hello, rust-nostr!"); let output = client.send_event_builder(builder).await?; // ANCHOR_END: publish diff --git a/book/snippets/rust/src/nip01.rs b/book/snippets/rust/src/nip01.rs index 7afe04e80..8e1023007 100644 --- a/book/snippets/rust/src/nip01.rs +++ b/book/snippets/rust/src/nip01.rs @@ -16,7 +16,7 @@ pub fn nip01() -> Result<()> { "lud16": "w3irdrobot@vlt.ge" }"#; // ANCHOR: create-metadata - let event = EventBuilder::new(Kind::Metadata, content, vec![]).sign_with_keys(&keys)?; + let event = EventBuilder::new(Kind::Metadata, content).sign_with_keys(&keys)?; let metadata = Metadata::from_json(&event.content)?; // ANCHOR_END: create-metadata println!("nostr address: {}", metadata.lud16.unwrap()); diff --git a/book/snippets/rust/src/nip17.rs b/book/snippets/rust/src/nip17.rs index 61027b78d..b23d1a8a5 100644 --- a/book/snippets/rust/src/nip17.rs +++ b/book/snippets/rust/src/nip17.rs @@ -29,7 +29,7 @@ pub async fn run() -> Result<()> { let subscription_id = bob_client.subscribe(vec![message_filter], None).await?; // Alice sends private message to Bob - alice_client.send_private_msg(bob_keys.public_key(), "Hello Bob!".to_string(), None).await?; + alice_client.send_private_msg(bob_keys.public_key(), "Hello Bob!", []).await?; println!("Sent private message to Bob"); // Bob receives private message diff --git a/book/snippets/rust/src/nip47.rs b/book/snippets/rust/src/nip47.rs index a6f7b9510..f07766300 100644 --- a/book/snippets/rust/src/nip47.rs +++ b/book/snippets/rust/src/nip47.rs @@ -17,10 +17,11 @@ pub async fn run() -> Result<()> { println!("Balance: {balance} SAT"); // Pay an invoice - nwc.pay_invoice("lnbc..").await?; + let params = PayInvoiceRequest::new("lnbc.."); + nwc.pay_invoice(params).await?; // Make an invoice - let params = MakeInvoiceRequestParams { + let params = MakeInvoiceRequest { amount: 100, description: None, description_hash: None, diff --git a/book/snippets/rust/src/nip59.rs b/book/snippets/rust/src/nip59.rs index 10a3a61be..fe272e2d3 100644 --- a/book/snippets/rust/src/nip59.rs +++ b/book/snippets/rust/src/nip59.rs @@ -9,8 +9,7 @@ pub async fn run() -> Result<()> { let bob_keys = Keys::parse("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")?; // Compose rumor - let rumor: UnsignedEvent = - EventBuilder::text_note("Test", []).build(alice_keys.public_key()); + let rumor: EventBuilder = EventBuilder::text_note("Test"); // Build gift wrap with sender keys let gw: Event = EventBuilder::gift_wrap(&alice_keys, &bob_keys.public_key(), rumor, None).await?; diff --git a/book/snippets/swift/NostrSnippets/Package.swift b/book/snippets/swift/NostrSnippets/Package.swift index 426f66d21..e3c07018e 100644 --- a/book/snippets/swift/NostrSnippets/Package.swift +++ b/book/snippets/swift/NostrSnippets/Package.swift @@ -7,7 +7,7 @@ let package = Package( name: "NostrSnippets", platforms: [.macOS(.v12)], dependencies: [ - .package(url: "https://github.com/rust-nostr/nostr-sdk-swift", from: "0.36.0") + .package(url: "https://github.com/rust-nostr/nostr-sdk-swift", from: "0.37.0") ], targets: [ .executableTarget( diff --git a/book/src/sdk/install.md b/book/src/sdk/install.md index 755ad9e1b..c8b7eec6c 100644 --- a/book/src/sdk/install.md +++ b/book/src/sdk/install.md @@ -9,14 +9,14 @@ Add the `nostr-sdk` dependency in your `Cargo.toml` file: ```toml [dependencies] -nostr-sdk = "0.36" +nostr-sdk = "0.37" ``` Alternatively, you can add it directly from `git` source: ```toml [dependencies] -nostr-sdk = { git = "https://github.com/rust-nostr/nostr", tag = "v0.36.0" } +nostr-sdk = { git = "https://github.com/rust-nostr/nostr", tag = "v0.37.0" } ``` ```admonish info @@ -43,7 +43,7 @@ pip install nostr-sdk Alternatively, you can manually add the dependency in your `requrements.txt`, `setup.py`, etc.: ``` -nostr-sdk==0.36.0 +nostr-sdk==0.37.0 ``` Import the library in your code: @@ -100,7 +100,7 @@ Alternatively, you can manually add the dependency in your `package.json` file: ```json { "dependencies": { - "@rust-nostr/nostr-sdk": "0.36.0" + "@rust-nostr/nostr-sdk": "0.37.0" } } ``` @@ -152,7 +152,7 @@ repositories { } dependencies { - implementation("org.rust-nostr:nostr-sdk:0.36.0") + implementation("org.rust-nostr:nostr-sdk:0.37.0") } ``` @@ -201,7 +201,7 @@ as a package dependency in Xcode. Add the following to the dependencies array in your `Package.swift`: ``` swift -.package(url: "https://github.com/rust-nostr/nostr-sdk-swift.git", from: "0.36.0"), +.package(url: "https://github.com/rust-nostr/nostr-sdk-swift.git", from: "0.37.0"), ``` @@ -215,7 +215,7 @@ Add the following code to your package: nostr_sdk: git: url: https://github.com/rust-nostr/nostr.git - ref: v0.36.0 + ref: v0.37.0 path: bindings/nostr-sdk-flutter ``` diff --git a/contrib/release/ANNOUNCEMENT_TEMPLATE.txt b/contrib/release/ANNOUNCEMENT_TEMPLATE.txt index d8bda9d55..d704293fb 100644 --- a/contrib/release/ANNOUNCEMENT_TEMPLATE.txt +++ b/contrib/release/ANNOUNCEMENT_TEMPLATE.txt @@ -17,4 +17,4 @@ Thanks to all contributors! https://rust-nostr.org https://rust-nostr.org/donate -#rustnostr #nostr #rustlang #programming #rust #python #javascript #kotlin #swift \ No newline at end of file +#rustnostr #nostr #rustlang #programming #rust #python #javascript #kotlin #swift #flutter