Skip to content

Commit

Permalink
Release v0.32.0
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Jun 7, 2024
1 parent 042c6a8 commit 60cb27f
Show file tree
Hide file tree
Showing 17 changed files with 81 additions and 65 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
<!-- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), -->
<!-- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -->

## [Unreleased]
## [v0.32.0]

### Summary

Added `async`/`future` support to Python, Kotlin and Swift, added automatic authentication to relays (NIP-42, can be deactivated in client options),
improvements to relay limits, many bug fixes (relays not auto reconnect, wrong query order for SQLite,
tokio panic when using SQLite database in bindings) and more!

Note for kotlin devs: from this release the packages will be published at `org.rust-nostr` instead of `io.github.rust-nostr`.

### Changed

* Bump `atomic-destructor` to `v0.2` ([Yuki Kishimoto])
Expand Down Expand Up @@ -246,6 +252,7 @@ added `nostrdb` storage backend, added NIP32 and completed NIP51 support and mor
[RydalWater]: https://github.com/RydalWater

<!-- Tags -->
[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.31.0...HEAD
[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.32.0...HEAD
[v0.32.0]: https://github.com/rust-nostr/nostr/compare/v0.31.0...v0.32.0
[v0.31.0]: https://github.com/rust-nostr/nostr/compare/v0.30.0...v0.31.0
[v0.30.0]: https://github.com/rust-nostr/nostr/compare/v0.29.0...v0.30.0
2 changes: 1 addition & 1 deletion book/snippets/nostr-sdk/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ edition = "2021"
members = ["."]

[dependencies]
nostr-sdk = "0.31"
nostr-sdk = "0.32"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
2 changes: 1 addition & 1 deletion book/snippets/nostr/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
"@rust-nostr/nostr": "0.14.0"
"@rust-nostr/nostr": "0.32.0"
}
}
2 changes: 1 addition & 1 deletion book/snippets/nostr/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 = "io.github.rust-nostr:nostr", version = "0.12.0" }
nostr = { module = "org.rust-nostr:nostr", version = "0.32.1" }

[plugins]
androidLibrary = { id = "com.android.library", version.ref = "agp" }
Expand Down
10 changes: 6 additions & 4 deletions book/snippets/nostr/python/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env python

import asyncio

from src.keys import generate, restore, vanity
from src.event.json import event_json
from src.event.builder import event_builder
Expand All @@ -13,20 +15,20 @@
from src.nip65 import nip65


def main():
async def main():
generate()
restore()
vanity()
event_json()
event_builder()
nip01()
nip05()
await nip05()
nip06()
nip19()
nip21()
nip44()
nip59()
nip65()


main()
if __name__ == '__main__':
asyncio.run(main())
2 changes: 1 addition & 1 deletion book/snippets/nostr/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
nostr-protocol==0.12.0
nostr-protocol==0.32.1
mnemonic==0.21
19 changes: 6 additions & 13 deletions book/snippets/nostr/python/src/nip05.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from nostr_protocol import Keys, Metadata, EventBuilder, PublicKey, verify_nip05, get_nip05_profile


def nip05():
async def nip05():
# ANCHOR: set-metadata
# Create metadata object with name and NIP05
metadata = Metadata() \
Expand All @@ -16,24 +16,17 @@ def nip05():
nip_05 = "[email protected]"
public_key = PublicKey.parse("npub1drvpzev3syqt0kjrls50050uzf25gehpz9vgdw08hvex7e0vgfeq0eseet")
proxy = None
try:
verify_nip05(public_key, nip_05, proxy)
if await verify_nip05(public_key, nip_05, proxy):
print(f" '{nip_05}' verified, for {public_key.to_bech32()}")
except Exception as e:
print(f" Unable to verify NIP-05, for {public_key.to_bech32()}: {e}")
else:
print(f" Unable to verify NIP-05, for {public_key.to_bech32()}")
# ANCHOR_END: verify-nip05

# TODO: replace above code with the following one (due to changes to NIP-05 verify func)
# if verify_nip05(public_key, nip_05, proxy):
# print(f" '{nip_05}' verified, for {public_key.to_bech32()}")
# else:
# print(f" Unable to verify NIP-05, for {public_key.to_bech32()}")

print()

# ANCHOR: nip05-profile
print("Profile NIP-05:")
nip_05 = "[email protected]"
profile = get_nip05_profile(nip_05)
nip_05 = "[email protected]"
profile = await get_nip05_profile(nip_05)
print(f" {nip_05} Profile: {profile.to_bech32()}")
# ANCHOR_END: nip05-profile
4 changes: 2 additions & 2 deletions book/snippets/nostr/python/src/nip06.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def nip06():

# Use Seed Phrase and account to multiple Nostr keys
for account in range(0,6):
nsec = Keys.from_mnemonic_with_account(words,passphrase,account).secret_key().to_bech32()
nsec = Keys.from_mnemonic(words, passphrase, account).secret_key().to_bech32()
print(f" Account #{account} bech32: {nsec}")
# ANCHOR_END: keys-from-seed-accounts

Expand All @@ -61,6 +61,6 @@ def nip06():

# Use Seed Phrase and account to multiple Nostr keys
for account in range(0,6):
nsec = Keys.from_mnemonic_with_account(words,passphrase,account).secret_key().to_bech32()
nsec = Keys.from_mnemonic(words, passphrase, account).secret_key().to_bech32()
print(f" Account #{account} bech32: {nsec}")
# ANCHOR_END: keys-from-seed-accounts-pass
2 changes: 1 addition & 1 deletion book/snippets/nostr/python/src/nip19.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def nip19():
print()
# ANCHOR: nip19-nevent-encode
# Create NIP-19 event including author and relays data
nevent = Nip19Event(event.id(),keys.public_key(),relays)
nevent = Nip19Event(event.id(), keys.public_key(), kind=None, relays=relays)
print(f" Event (encoded): {nevent.to_bech32()}")
# ANCHOR_END: nip19-nevent-encode

Expand Down
2 changes: 1 addition & 1 deletion book/snippets/nostr/python/src/nip21.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def nip21():

# ANCHOR: nevent
relays = ["wss://relay.damus.io"]
nevent = Nip19Event(event.id(), keys.public_key(), relays)
nevent = Nip19Event(event.id(), keys.public_key(), kind=None, relays=relays)

# URI nevent
nevent_uri = nevent.to_nostr_uri()
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/nostr/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ edition = "2021"
members = ["."]

[dependencies]
nostr = "0.31"
nostr = "0.32"
2 changes: 1 addition & 1 deletion book/snippets/nostr/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(.v13)],
dependencies: [
.package(url: "https://github.com/rust-nostr/nostr-swift", from:"0.12.0")
.package(url: "https://github.com/rust-nostr/nostr-swift", from:"0.32.1")
],
targets: [
.executableTarget(
Expand Down
12 changes: 6 additions & 6 deletions book/src/nostr-sdk/02-installation.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.31"
nostr-sdk = "0.32"
```

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

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

```admonish info
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.12.1
nostr-sdk==0.32.1
```

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.14.1"
"@rust-nostr/nostr-sdk": "0.32.0"
}
}
```
Expand Down Expand Up @@ -152,7 +152,7 @@ repositories {
}

dependencies {
implementation("io.github.rust-nostr:nostr-sdk:0.12.1")
implementation("org.rust-nostr:nostr-sdk:0.32.1")
}
```

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

</section>
Expand Down
41 changes: 27 additions & 14 deletions book/src/nostr/02-installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ Add the `nostr` dependency in your `Cargo.toml` file:

```toml,ignore
[dependencies]
nostr = "0.31"
nostr = "0.32"
```

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

```toml,ignore
[dependencies]
nostr = { git = "https://github.com/rust-nostr/nostr", tag = "v0.31.0" }
nostr = { git = "https://github.com/rust-nostr/nostr", tag = "v0.32.0" }
```

```admonish info
Expand All @@ -43,7 +43,7 @@ pip install nostr-protocol
Alternatively, you can manually add the dependency in your `requrements.txt`, `setup.py`, etc.:

```
nostr-protocol==0.12.1
nostr-protocol==0.32.1
```

Import the library in your code:
Expand All @@ -52,24 +52,37 @@ Import the library in your code:
from nostr_protocol import *
```

### Support matrix
## Support matrix

The wheels are distributed for the following python `versions` and `platforms`.
If your `version`/`platform` is not currently supported, you can compile the wheel by your self following [these instructions](https://github.com/rust-nostr/nostr/blob/master/bindings/nostr-ffi/README.md#python).

#### Python version
### Python version

| 3.8 | 3.9 | 3.10 | 3.11 | 3.12 | 3.13 |
| --- | --- | ---- | ---- | ---- | ---- |
|||||||

#### Platform support
### Platform support

| OS | i686 | x64 | aarch64 | arm |
| ---------- | ---- | --- | ------- | --- |
| Linux |||||
| macOS |||||
| Windows |||||
| OS | x64 | aarch64 | arm | i686 |
| ---------- | --- | ------- | --- |------|
| Linux |||||
| macOS |||||
| Windows |||||

## Known issues

### No running event loop

If you receive `no running event loop` error at runtime, add the following line to your code:

```python
import asyncio
from nostr_sdk import uniffi_set_event_loop

uniffi_set_event_loop(asyncio.get_running_loop())
```

</section>

Expand All @@ -87,7 +100,7 @@ Alternatively, you can manually add the dependency in your `package.json` file:
```json
{
"dependencies": {
"@rust-nostr/nostr": "0.14.1"
"@rust-nostr/nostr": "0.32.0"
}
}
```
Expand Down Expand Up @@ -139,7 +152,7 @@ repositories {
}
dependencies {
implementation("io.github.rust-nostr:nostr:0.12.1")
implementation("org.rust-nostr:nostr:0.32.1")
}
```

Expand Down Expand Up @@ -188,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-swift.git", from: "0.12.1"),
.package(url: "https://github.com/rust-nostr/nostr-swift.git", from: "0.32.1"),
```

Import the library in your code:
Expand Down
13 changes: 9 additions & 4 deletions book/src/nostr/06-nip06.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
## NIP-06

In accordance with the [Bitcoin Improvement Proposal 0039 (BIP-39)](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) we can derive Nostr keys using seed phrases as a source of entropy. This is handled by the [FromMnemonic](https://docs.rs/nostr/latest/nostr/nips/nip06/trait.FromMnemonic.html) Trait and its associated methods.
In accordance with the [Bitcoin Improvement Proposal 0039 (BIP-39)](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki) we can derive Nostr keys using seed phrases as a source of entropy.
This is handled by the [FromMnemonic](https://docs.rs/nostr/latest/nostr/nips/nip06/trait.FromMnemonic.html) Trait and its associated methods.

The default functionality is to generate a single key-pair at the derivation path `0`. However, it is also possible to perform more advanced derivations by incrementing the `account`, enabling generation of many sets of keys from a single seed. More granular derivation path control (over `account`, `type` and `index`) exists within the `from_mnemonic_advanced` method.
The default functionality is to generate a single key-pair at the derivation path `0`.
However, it is also possible to perform more advanced derivations by incrementing the `account`,
enabling generation of many sets of keys from a single seed.

For more examples of key generation please refer back to the [Keys section](03-keys.md) of this book.

Expand Down Expand Up @@ -34,13 +37,15 @@ As well as deriving basic keys from a 24 word seed we can also use seed phrases
{{#include ../../snippets/nostr/python/src/nip06.py:keys-from-seed12}}
```

Advanced key derivation functionality (for accounts) can be accessed by the `from_mnemonic_with_account()` method. To do this we use the `account` argument which accepts an integer to specify the derivation path.
Advanced key derivation functionality (for accounts) can be accessed by the `from_mnemonic()` method.
To do this we use the `account` argument which accepts an integer to specify the derivation path.

```python,ignore
{{#include ../../snippets/nostr/python/src/nip06.py:keys-from-seed-accounts}}
```

This final example utilizes the same seed as for the previous example, but also includes a `passphrase`. It illustrates the effect of inclusion of a passphrase on the key derivation.
This final example utilizes the same seed as for the previous example, but also includes a `passphrase`.
It illustrates the effect of inclusion of a passphrase on the key derivation.

```python,ignore
{{#include ../../snippets/nostr/python/src/nip06.py:keys-from-seed-accounts-pass}}
Expand Down
12 changes: 4 additions & 8 deletions contrib/release/ANNOUNCEMENT_TEMPLATE.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
## rust-nostr release is out! 🦀

### Versions

* Rust: <VERSION_TO_REPLACE>
* JavaScript: <VERSION_TO_REPLACE>
* Python, Kotlin and Swift: <VERSION_TO_REPLACE>
## rust-nostr v<VERSION_TO_REPLACE> is out! 🦀

### Summary

Expand All @@ -14,7 +8,9 @@ Full changelog: https://rust-nostr.org/changelog

### Contributors

Thanks to <CONTRIBUTORS_TO_REPLACE> for contributing!
Thanks to all contributors!

<LIST_OF_CONTRIBUTORS_TO_REPLACE>

### Links

Expand Down
Loading

0 comments on commit 60cb27f

Please sign in to comment.