Skip to content

Commit

Permalink
Release v0.37.0
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 27, 2024
1 parent d9dde71 commit 47c695f
Show file tree
Hide file tree
Showing 41 changed files with 115 additions and 98 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -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])
Expand Down Expand Up @@ -815,7 +820,8 @@ added `nostrdb` storage backend, added NIP32 and completed NIP51 support and mor
[erskingardner]: https://github.com/erskingardner

<!-- Tags -->
[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
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
12 changes: 7 additions & 5 deletions book/snippets/js/src/event/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion book/snippets/js/src/hello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion book/snippets/js/src/messages/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:");
Expand Down
6 changes: 4 additions & 2 deletions book/snippets/js/src/messages/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:");
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/js/src/messages/relay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:");

Expand Down
2 changes: 1 addition & 1 deletion book/snippets/js/src/nip19.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion book/snippets/js/src/nip21.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions book/snippets/js/src/nip47.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/js/src/nip59.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions book/snippets/js/src/nip65.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/kotlin/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion book/snippets/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
mnemonic==0.21
nostr-sdk==0.36.0
nostr-sdk==0.37.0
pyright==1.1.389
8 changes: 4 additions & 4 deletions book/snippets/python/src/event/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion book/snippets/python/src/event/eventid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion book/snippets/python/src/event/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()}")
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/python/src/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion book/snippets/python/src/messages/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand Down
4 changes: 2 additions & 2 deletions book/snippets/python/src/messages/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/python/src/messages/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:")
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/python/src/nip19.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion book/snippets/python/src/nip21.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading

0 comments on commit 47c695f

Please sign in to comment.