Skip to content

Commit

Permalink
Release v0.39.0
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Jan 31, 2025
1 parent ac0d4d3 commit 1349760
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 46 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@
-->

## [Unreleased]
## [v0.39.0] - 2025/01/31

### Summary

Add NIP96 support, add NIP22 helpers, NIP01 adjustments, add `try_connect` and `wait_for_connection` methods for better connection handling,
support for custom WebSocket clients (both in Rust, Python, Kotlin and Swift), new JVM bindings,
huge reduction of UniFFI bindings binaries size, many cleanups, refactoring and performance improvements and more!

### Breaking changes

* Drop zapper support ([Yuki Kishimoto])
Expand Down Expand Up @@ -1072,7 +1076,8 @@ added `nostrdb` storage backend, added NIP32 and completed NIP51 support and mor
[cipres]: https://github.com/PancakesArchitect (nostr:npub1r3cnzta52fee26c83cnes8wvzkch3kud2kll67k402x04mttt26q0wfx0c)

<!-- Tags -->
[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.38.0...HEAD
[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.39.0...HEAD
[v0.39.0]: https://github.com/rust-nostr/nostr/compare/v0.38.0...v0.39.0
[v0.38.0]: https://github.com/rust-nostr/nostr/compare/v0.37.0...v0.38.0
[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
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.38.0",
"@rust-nostr/nostr-sdk": "0.39.0",
"bip39": "^3.1.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions book/snippets/js/src/messages/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function run() {
// Create Request client message
console.log(" Request Client Message:");
let f = new Filter().id(event.id);
clientMessage = ClientMessage.req("ABC123", [f]);
clientMessage = ClientMessage.req("ABC123", f);
console.log(` - JSON: ${clientMessage.asJson()}`);
// ANCHOR_END: req-message

Expand Down Expand Up @@ -55,7 +55,7 @@ function run() {
// Create Count client message (NIP45)
console.log(" Count Client Message:");
f = new Filter().pubkey(keys.publicKey);
clientMessage = ClientMessage.count("ABC123", [f]);
clientMessage = ClientMessage.count("ABC123", f);
console.log(` - JSON: ${clientMessage.asJson()}`);
// ANCHOR_END: count-message

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 @@ -13,7 +13,7 @@ async function run() {
const bob_signer = NostrSigner.keys(bob_keys);

// Compose rumor
const rumor = EventBuilder.textNote("Test")
const rumor = EventBuilder.textNote("Test").build(alice_keys.publicKey)

// Build gift wrap with sender keys
const gw = await EventBuilder.giftWrap(alice_signer, bob_keys.publicKey, rumor)
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.24"

[libraries]
nostr = { module = "org.rust-nostr:nostr-sdk", version = "0.38.3" }
nostr = { module = "org.rust-nostr:nostr-sdk", version = "0.39.0" }

[plugins]
androidLibrary = { id = "com.android.library", version.ref = "agp" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fun restore() {
var keys = Keys.parse("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")

// Parse from hex
var secretKey = SecretKey.parse("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e")
val secretKey = SecretKey.parse("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e")
keys = Keys(secretKey = secretKey)
}
// ANCHOR_END: restore
3 changes: 2 additions & 1 deletion book/snippets/python/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ENV/
__pycache__
venv/
__pycache__
7 changes: 3 additions & 4 deletions book/snippets/python/justfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
venv:
python -m venv ENV || virtualenv ENV
python -m venv venv || virtualenv venv

requirements: venv
. ENV/bin/activate && pip install -r requirements.txt
. venv/bin/activate && pip install -r requirements.txt

test: requirements
export PYRIGHT_PYTHON_FORCE_VERSION=latest && \
. ENV/bin/activate && pyright src
export PYRIGHT_PYTHON_FORCE_VERSION=latest && . venv/bin/activate && pyright src
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.38.0
nostr-sdk==0.39.0
pyright==1.1.389
22 changes: 11 additions & 11 deletions book/snippets/python/src/event/kind.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import cast
from nostr_sdk import Kind, KindEnum, EventBuilder, Keys, Metadata
from nostr_sdk import Kind, KindStandard, EventBuilder, Keys, Metadata


def kind():
Expand All @@ -10,39 +10,39 @@ def kind():
# ANCHOR: kind-int
print(" Kind from integer:")
kind = Kind(1)
print(f" - Kind 1: {kind.as_enum()}")
print(f" - Kind 1: {kind.as_std()}")
kind = Kind(0)
print(f" - Kind 0: {kind.as_enum()}")
print(f" - Kind 0: {kind.as_std()}")
kind = Kind(3)
print(f" - Kind 3: {kind.as_enum()}")
print(f" - Kind 3: {kind.as_std()}")
# ANCHOR_END: kind-int

print()
# ANCHOR: kind-enum
print(" Kind from enum:")
kind = Kind.from_enum(cast(KindEnum, KindEnum.TEXT_NOTE()))
kind = Kind.from_std(KindStandard.TEXT_NOTE)
print(f" - Kind TEXT_NOTE: {kind.as_u16()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.METADATA()))
kind = Kind.from_std(KindStandard.METADATA)
print(f" - Kind METADATA: {kind.as_u16()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.CONTACT_LIST()))
kind = Kind.from_std(KindStandard.CONTACT_LIST)
print(f" - Kind CONTRACT_LIST: {kind.as_u16()}")
# ANCHOR_END: kind-enum

print()
# ANCHOR: kind-methods
print(" Kind methods EventBuilder:")
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()}")
print(f" - Kind text_note(): {event.kind().as_u16()} - {event.kind().as_std()}")
event = EventBuilder.metadata(Metadata()).sign_with_keys(keys)
print(f" - Kind metadata(): {event.kind().as_u16()} - {event.kind().as_enum()}")
print(f" - Kind metadata(): {event.kind().as_u16()} - {event.kind().as_std()}")
event = EventBuilder.contact_list([]).sign_with_keys(keys)
print(f" - Kind contact_list(): {event.kind().as_u16()} - {event.kind().as_enum()}")
print(f" - Kind contact_list(): {event.kind().as_u16()} - {event.kind().as_std()}")
# ANCHOR_END: kind-methods

print()
# ANCHOR: kind-representations
kind = Kind(1337)
print(f"Custom Event Kind: {kind.as_u16()} - {kind.as_enum()}")
print(f"Custom Event Kind: {kind.as_u16()} - {kind.as_std()}")
# ANCHOR_END: kind-representations

print()
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/python/src/event/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def tags():
# Generate keys and events
keys = Keys.generate()
event = EventBuilder.contact_list([Contact(keys.public_key(), "", "")]).sign_with_keys(keys)
event = EventBuilder.contact_list([Contact(public_key=keys.public_key(), relay_url=None, alias=None)]).sign_with_keys(keys)

print()
print("Tags:")
Expand Down
6 changes: 3 additions & 3 deletions book/snippets/python/src/messages/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def client_message():
# Request client message
print(" Request Client Message:")
f = Filter().id(event.id())
message = ClientMessage.req(subscription_id="ABC123", filters=[f])
message = ClientMessage.req(subscription_id="ABC123", filter=f)
print(f" - Request Message: {message.as_enum().is_req()}")
print(f" - JSON: {message.as_json()}")
# ANCHOR_END: req-message
Expand All @@ -43,7 +43,7 @@ def client_message():
message = ClientMessage.from_json('["REQ","ABC123",{"#p":["421a4dd67be773903f805bcb7975b4d3377893e0e09d7563b8972ee41031f551"]}]')
print(f" - ENUM: {message.as_enum()}")
f = Filter().pubkey(keys.public_key())
message = ClientMessage.from_enum(cast(ClientMessageEnum, ClientMessageEnum.REQ("ABC123", filters=[f])))
message = ClientMessage.from_enum(cast(ClientMessageEnum, ClientMessageEnum.REQ("ABC123", filter=f)))
print(f" - JSON: {message.as_json()}")
# ANCHOR_END: parse-message

Expand All @@ -61,7 +61,7 @@ def client_message():
# Count client message (NIP45)
print(" Count Client Message:")
f = Filter().pubkey(keys.public_key())
message = ClientMessage.count(subscription_id="ABC123", filters=[f])
message = ClientMessage.count(subscription_id="ABC123", filter=f)
print(f" - Count Message: {message.as_enum().is_count()}")
print(f" - JSON: {message.as_json()}")
# ANCHOR_END: count-message
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/python/src/nip59.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async def nip59():
bob_signer = NostrSigner.keys(bob_keys)

# Compose rumor
rumor = EventBuilder.text_note("Test")
rumor: UnsignedEvent = EventBuilder.text_note("Test").build(alice_keys.public_key())

# Build gift wrap with sender keys
gw: Event = await gift_wrap(alice_signer, bob_keys.public_key(), rumor, None)
Expand Down
4 changes: 2 additions & 2 deletions book/snippets/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ edition = "2021"
members = ["."]

[dependencies]
nostr-sdk = { version = "0.38", features = ["all-nips"] }
nostr-relay-builder = "0.38"
nostr-sdk = { version = "0.39", features = ["all-nips"] }
nostr-relay-builder = "0.39"
nwc = "0.38"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
2 changes: 1 addition & 1 deletion book/snippets/rust/src/nip17.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn run() -> Result<()> {
.kind(Kind::GiftWrap)
.pubkey(bob_keys.public_key())
.limit(0);
let subscription_id = bob_client.subscribe(vec![message_filter], None).await?;
let subscription_id = bob_client.subscribe(message_filter, None).await?;

// Alice sends private message to Bob
alice_client.send_private_msg(bob_keys.public_key(), "Hello Bob!", []).await?;
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/rust/src/nip59.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub async fn run() -> Result<()> {
let bob_keys = Keys::parse("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")?;

// Compose rumor
let rumor: EventBuilder = EventBuilder::text_note("Test");
let rumor: UnsignedEvent = EventBuilder::text_note("Test").build(alice_keys.public_key);

// Build gift wrap with sender keys
let gw: Event = EventBuilder::gift_wrap(&alice_keys, &bob_keys.public_key(), rumor, None).await?;
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/swift/NostrSnippets/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.38.0")
.package(url: "https://github.com/rust-nostr/nostr-sdk-swift", from: "0.39.0")
],
targets: [
.executableTarget(
Expand Down
6 changes: 3 additions & 3 deletions book/src/sdk/event/kind.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ TODO
<div slot="title">Python</div>
<section>

Working with kinds is facilitated by the `Kind` and `KindEnum` classes.
Working with kinds is facilitated by the `Kind` and `KindStandard` classes.
If you are familiar already with the specific integer value for a given Kind it is as simple as calling an instance of the class `Kind()` and passing the specific number for the Kind you wish to create.

In the example below we've used the common `0`/`1`/`3` Kinds (user metadata, text note and following list, respectively) as an illustration of this.

Once we've created the `Kind` object we can use the `as_enum()` method to present the Kind object as an easy to read `KindEnum` object.
Once we've created the `Kind` object we can use the `as_std()` method to present the Kind object as an easy to read `KindStandard` object.

```python,ignore
{{#include ../../../snippets/python/src/event/kind.py:kind-int}}
```

Alternatively, if you are less familiar with the specific integer values for a Kind we can use the individual Kind classes, in conjunction with the `KindEnum` class, to generate the objects.
Alternatively, if you are less familiar with the specific integer values for a Kind we can use the individual Kind classes, in conjunction with the `KindStandard` class, to generate the objects.
Below we see the `TEXT_NOTE()`, `METADATA()` and `CONTACT_LIST()` enums being passed to an instance of the `Kind` class via the `from_enum()` method.

In order to present these as their integer values we can use the `as_u16()` method.
Expand Down
16 changes: 8 additions & 8 deletions book/src/sdk/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Add the `nostr-sdk` dependency in your `Cargo.toml` file:

```toml
[dependencies]
nostr-sdk = "0.38"
nostr-sdk = "0.39"
```

Alternatively, you can add it directly from `git` source:

```toml
[dependencies]
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", tag = "v0.38.0" }
nostr-sdk = { git = "https://github.com/rust-nostr/nostr", tag = "v0.39.0" }
```

```admonish info
Expand All @@ -25,7 +25,7 @@ To use a specific commit, use `rev` instead of `tag`.

Import the library in your code:

```rust
```rust,ignore
use nostr_sdk::prelude::*;
```

Expand All @@ -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.38.0
nostr-sdk==0.39.0
```

Import the library in your code:
Expand Down Expand Up @@ -100,7 +100,7 @@ Alternatively, you can manually add the dependency in your `package.json` file:
```json
{
"dependencies": {
"@rust-nostr/nostr-sdk": "0.38.0"
"@rust-nostr/nostr-sdk": "0.39.0"
}
}
```
Expand Down Expand Up @@ -154,7 +154,7 @@ repositories {
}

dependencies {
implementation("org.rust-nostr:nostr-sdk:0.38.3")
implementation("org.rust-nostr:nostr-sdk:0.39.0")
}
```

Expand All @@ -166,7 +166,7 @@ repositories {
}

dependencies {
implementation("org.rust-nostr:nostr-sdk-jvm:0.39.0-alpha.1")
implementation("org.rust-nostr:nostr-sdk-jvm:0.39.0")
}
```

Expand Down Expand Up @@ -235,7 +235,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.38.0"),
.package(url: "https://github.com/rust-nostr/nostr-sdk-swift.git", from: "0.39.0"),
```

</section>
Expand Down

0 comments on commit 1349760

Please sign in to comment.