Skip to content

Commit

Permalink
Release v0.38.0
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Dec 31, 2024
1 parent 7fbd424 commit 6ccc81a
Show file tree
Hide file tree
Showing 24 changed files with 57 additions and 85 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

### Summary

* Full NIP42 support (SDK)
Full NIP42 support for SDK and relay builder, negentropy support and read/write policy plugins for relay builder,
NIP35 support, better logs and docs, performance improvements, bugs fix and more!

### Breaking changes

Expand All @@ -48,7 +49,7 @@

### Changed

* Bump `async-utility` to 0.3, `async-wsocket` to 0.11 and `atomic-destructor` to 0.3 ([Yuki Kishimoto])
* Bump `async-utility` to 0.3, `async-wsocket` to 0.12 and `atomic-destructor` to 0.3 ([Yuki Kishimoto])
* nostr: remove self-tagging when building events ([Yuki Kishimoto])
* nostr: don't set root tags when the root is null ([Yuki Kishimoto])
* nostr: update `RelayMessage::NegErr` variant ([Yuki Kishimoto])
Expand Down Expand Up @@ -940,7 +941,8 @@ added `nostrdb` storage backend, added NIP32 and completed NIP51 support and mor
[Roland Bewick]: https://github.com/rolznz (nostr:npub1zk6u7mxlflguqteghn8q7xtu47hyerruv6379c36l8lxzzr4x90q0gl6ef)

<!-- Tags -->
[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.37.0...HEAD
[Unreleased]: https://github.com/rust-nostr/nostr/compare/v0.38.0...HEAD
[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
[v0.35.0]: https://github.com/rust-nostr/nostr/compare/v0.34.0...v0.35.0
Expand Down
6 changes: 3 additions & 3 deletions book/snippets/flutter/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ packages:
dependency: "direct main"
description:
path: "."
ref: b6fe16d3aee91c4cda670c4236ad4b28f12433df
resolved-ref: b6fe16d3aee91c4cda670c4236ad4b28f12433df
ref: "v0.38.0"
resolved-ref: "65e9cd225bb16e15633350e573bcc438410fbcb3"
url: "https://github.com/rust-nostr/nostr-sdk-flutter.git"
source: git
version: "0.37.0"
version: "0.38.0"
package_config:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion book/snippets/flutter/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dependencies:
nostr_sdk:
git:
url: https://github.com/rust-nostr/nostr-sdk-flutter.git
ref: b6fe16d3aee91c4cda670c4236ad4b28f12433df
ref: v0.38.0

dev_dependencies:
lints: ^3.0.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.37.0",
"@rust-nostr/nostr-sdk": "0.38.0",
"bip39": "^3.1.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions book/snippets/js/src/hello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ export async function hello() {

// ANCHOR: publish
let builder = EventBuilder.textNote("Hello, rust-nostr!");
let res = await client.sendEventBuilder(builder);
let output = await client.sendEventBuilder(builder);
// ANCHOR_END: publish

// ANCHOR: output
console.log("Event ID:", res.id.toBech32());
console.log("Sent to:", res.output.success);
console.log("Not sent to:", res.output.failed);
console.log("Event ID:", output.id.toBech32());
console.log("Sent to:", output.success);
console.log("Not sent to:", output.failed);
// ANCHOR_END: output
}
// ANCHOR_END: full
2 changes: 1 addition & 1 deletion book/snippets/js/src/nip44.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Keys, PublicKey, nip44Encrypt, nip44Decrypt, NIP44Version} from "@rust-n
export function run() {
let keys = Keys.generate();

let public_key = PublicKey.fromHex("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798");
let public_key = PublicKey.parse("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798");

let ciphertext = nip44Encrypt(keys.secretKey, public_key, "my message", NIP44Version.V2)
console.log("Encrypted: " + ciphertext)
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.37.0" }
nostr = { module = "org.rust-nostr:nostr-sdk", version = "0.38.0" }

[plugins]
androidLibrary = { id = "com.android.library", version.ref = "agp" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ suspend fun hello() {

// ANCHOR: publish
val builder = EventBuilder.textNote("Hello, rust-nostr!")
val res = client.sendEventBuilder(builder)
val output = client.sendEventBuilder(builder)
// ANCHOR_END: publish

// ANCHOR: output
println("Event ID: ${res.id.toBech32()}")
println("Sent to: ${res.output.success}")
println("Not sent to: ${res.output.failed}")
println("Event ID: ${output.id.toBech32()}")
println("Sent to: ${output.success}")
println("Not sent to: ${output.failed}")
// ANCHOR_END: output
}
// ANCHOR_END: full
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ fun restore() {
var keys = Keys.parse("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")

// Parse from hex
var secretKey = SecretKey.fromHex("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e")
keys = Keys(secretKey = secretKey)

// Parse from bech32
secretKey = SecretKey.fromBech32("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")
var secretKey = SecretKey.parse("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e")
keys = Keys(secretKey = secretKey)
}
// ANCHOR_END: restore
Expand Down
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.37.0
nostr-sdk==0.38.0
pyright==1.1.389
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def event_id():
event_id_hex = event_id.to_hex()
print(f" - Hex: {event_id_hex}")
print(f" - Parse: {EventId.parse(event_id_hex)}")
print(f" - From Hex: {EventId.from_hex(event_id_hex)}")
# ANCHOR_END: format-parse-hex

print()
Expand All @@ -30,7 +29,6 @@ def event_id():
event_id_bech32 = event_id.to_bech32()
print(f" - Bech32: {event_id_bech32}")
print(f" - Parse: {EventId.parse(event_id_bech32)}")
print(f" - From Bech32: {EventId.from_bech32(event_id_bech32)}")
# ANCHOR_END: format-parse-bech32

print()
Expand All @@ -40,7 +38,6 @@ def event_id():
event_id_nostr_uri = event_id.to_nostr_uri()
print(f" - Nostr URI: {event_id_nostr_uri}")
print(f" - Parse: {EventId.parse(event_id_nostr_uri)}")
print(f" - From Nostr URI: {EventId.from_nostr_uri(event_id_nostr_uri)}")
# ANCHOR_END: format-parse-nostr-uri

print()
Expand Down
17 changes: 2 additions & 15 deletions book/snippets/python/src/event/kind.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ def kind():

print()
# ANCHOR: kind-representations
print(" Kinds Representing types of Events:")
kind = Kind.from_enum(cast(KindEnum, KindEnum.CUSTOM(1337)))
print(f" - Custom Event Kind: {kind.as_u16()} - {kind.as_enum()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.REPLACEABLE(10420)))
print(f" - Replacable Event Kind: {kind.as_u16()} - {kind.as_enum()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.PARAMETERIZED_REPLACEABLE(30420)))
print(f" - Parameterised Replaceable Event Kind: {kind.as_u16()} - {kind.as_enum()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.EPHEMERAL(21420)))
print(f" - Ephemeral Event Kind: {kind.as_u16()} - {kind.as_enum()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.REGULAR(420)))
print(f" - Regular Event Kind: {kind.as_u16()} - {kind.as_enum()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.JOB_REQUEST(123)))
print(f" - Job Request Event Kind: {kind.as_u16()} - {kind.as_enum()}")
kind = Kind.from_enum(cast(KindEnum, KindEnum.JOB_RESULT(321)))
print(f" - Job Result Event Kind: {kind.as_u16()} - {kind.as_enum()}")
kind = Kind(1337)
print(f"Custom Event Kind: {kind.as_u16()} - {kind.as_enum()}")
# ANCHOR_END: kind-representations
8 changes: 4 additions & 4 deletions book/snippets/python/src/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ async def hello():

# ANCHOR: publish
builder = EventBuilder.text_note("Hello, rust-nostr!")
res = await client.send_event_builder(builder)
output = await client.send_event_builder(builder)
# ANCHOR_END: publish

# ANCHOR: output
print(f"Event ID: {res.id.to_bech32()}")
print(f"Sent to: {res.output.success}")
print(f"Not send to: {res.output.failed}")
print(f"Event ID: {output.id.to_bech32()}")
print(f"Sent to: {output.success}")
print(f"Not send to: {output.failed}")
# ANCHOR_END: output

# ANCHOR_END: full
5 changes: 1 addition & 4 deletions book/snippets/python/src/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ def generate():
def restore():
keys = Keys.parse("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")

secret_key = SecretKey.from_hex("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e")
keys = Keys(secret_key)

secret_key = SecretKey.from_bech32("nsec1j4c6269y9w0q2er2xjw8sv2ehyrtfxq3jwgdlxj6qfn8z4gjsq5qfvfk99")
secret_key = SecretKey.parse("6b911fd37cdf5c81d4c0adb1ab7fa822ed253ab0ad9aa18d77257c88b29b718e")
keys = Keys(secret_key)
# ANCHOR_END: restore

Expand Down
6 changes: 3 additions & 3 deletions book/snippets/python/src/nip21.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def nip21():
# bech32 npub
pk_parse = Nip21.parse(pk_uri)
if pk_parse.as_enum().is_pubkey():
pk_bech32 = PublicKey.from_nostr_uri(pk_uri).to_bech32()
pk_bech32 = PublicKey.parse(pk_uri).to_bech32()
print(f" Public key (bech32): {pk_bech32}")
# ANCHOR_END: npub

Expand All @@ -30,7 +30,7 @@ def nip21():
# bech32 note
note_pasre = Nip21.parse(note_uri)
if note_pasre.as_enum().is_note():
event_bech32 = EventId.from_nostr_uri(note_uri).to_bech32()
event_bech32 = EventId.parse(note_uri).to_bech32()
print(f" Event (bech32): {event_bech32}")
# ANCHOR_END: note

Expand Down Expand Up @@ -80,6 +80,6 @@ def nip21():
# bech32 naddr
coord_parse = Nip21.parse(coord_uri)
if coord_parse.as_enum().is_coord():
coord_bech32 = Coordinate.from_nostr_uri(coord_uri).to_bech32()
coord_bech32 = Coordinate.parse(coord_uri).to_bech32()
print(f" Coordinate (bech32): {coord_bech32}")
# ANCHOR_END: naddr
2 changes: 1 addition & 1 deletion book/snippets/python/src/nip44.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def nip44():
print("\nEncrypting and Decrypting Messages (NIP-44):")
keys = Keys.generate()

pk = PublicKey.from_hex("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")
pk = PublicKey.parse("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")

ciphertext = nip44_encrypt(keys.secret_key(), pk, "my message", Nip44Version.V2)
print(f" Encrypted: {ciphertext}")
Expand Down
5 changes: 3 additions & 2 deletions book/snippets/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ edition = "2021"
members = ["."]

[dependencies]
nostr-sdk = { version = "0.37", features = ["all-nips"] }
nostr-relay-builder = "0.37"
nostr-sdk = { version = "0.38", features = ["all-nips"] }
nostr-relay-builder = "0.38"
nwc = "0.38"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
2 changes: 1 addition & 1 deletion book/snippets/rust/src/nip47.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ANCHOR: full
use nostr_sdk::prelude::*;
use nwc::prelude::*;

pub async fn run() -> Result<()> {
// Parse NWC uri
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.37.0")
.package(url: "https://github.com/rust-nostr/nostr-sdk-swift", from: "0.38.0")
],
targets: [
.executableTarget(
Expand Down
8 changes: 4 additions & 4 deletions book/snippets/swift/NostrSnippets/Sources/Hello.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ func hello() async throws {

// ANCHOR: publish
let builder = EventBuilder.textNote(content: "Hello, rust-nostr!")
let res = try await client.sendEventBuilder(builder: builder)
let output = try await client.sendEventBuilder(builder: builder)
// ANCHOR_END: publish

// ANCHOR: output
print("Event ID: \(try res.id.toBech32())")
print("Sent to: \(res.output.success)")
print("Not sent to: \(res.output.failed)")
print("Event ID: \(try output.id.toBech32())")
print("Sent to: \(output.success)")
print("Not sent to: \(output.failed)")
// ANCHOR_END: output
}
// ANCHOR_END: full
2 changes: 1 addition & 1 deletion book/snippets/swift/NostrSnippets/Sources/Nip44.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import NostrSDK
func nip44() throws {
let keys = Keys.generate()

let publicKey = try PublicKey.fromHex(hex: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")
let publicKey = try PublicKey.parse(publicKey: "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798")

let ciphertext = try nip44Encrypt(secretKey: keys.secretKey(), publicKey: publicKey, content: "my message", version: Nip44Version.v2)
print("Encrypted: \(ciphertext)");
Expand Down
12 changes: 6 additions & 6 deletions book/src/sdk/event/id.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The `EventId` class can be called in order to construct event ids, although this
Upon instantiation the following content are passed to the class instance to generate the event ID: `public_key`, `created_at`, `kind`, `tags` and `content`.

```python,ignore
{{#include ../../../snippets/python/src/event/eventid.py:build-event-id}}
{{#include ../../../snippets/python/src/event/id.py:build-event-id}}
```

Once we have an event id object we are able to format and parse this using a few simple methods.
Expand All @@ -34,19 +34,19 @@ In the event that we want to generalise and simplify this process, across hex/be
For more information/examples on the formatting of Nostr objects please refer to [NIP-19](../nips/19.md) and [NIP-21](../nips/21.md).

```python,ignore
{{#include ../../../snippets/python/src/event/eventid.py:format-parse-hex}}
{{#include ../../../snippets/python/src/event/id.py:format-parse-hex}}
```

```python,ignore
{{#include ../../../snippets/python/src/event/eventid.py:format-parse-bech32}}
{{#include ../../../snippets/python/src/event/id.py:format-parse-bech32}}
```

```python,ignore
{{#include ../../../snippets/python/src/event/eventid.py:format-parse-nostr-uri}}
{{#include ../../../snippets/python/src/event/id.py:format-parse-nostr-uri}}
```

```python,ignore
{{#include ../../../snippets/python/src/event/eventid.py:format-parse-bytes}}
{{#include ../../../snippets/python/src/event/id.py:format-parse-bytes}}
```

</section>
Expand Down Expand Up @@ -97,7 +97,7 @@ TODO
In addition to directly creating/manipulating event ID objects we can also easily access these directly from events, by calling the `id()` method on and instance of the `Event` class, or, verify that the event id (and signature) for an event is valid, by using the `verify()` method.

```python,ignore
{{#include ../../../snippets/python/src/event/eventid.py:access-verify}}
{{#include ../../../snippets/python/src/event/id.py:access-verify}}
```

</section>
Expand Down
10 changes: 1 addition & 9 deletions book/src/sdk/event/kind.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,7 @@ For example, the `text_note()` method can be used to quickly and efficiently cre
```

Occasionally you may want more generic usage of kinds, like if you wanted to create your own custom (or experimental) event type,
or if you want to leverage one of the commonly defined event types (i.e. replaceable, ephemeral, regular etc.).
To do this we can use the `Kind` class along with the `from_enum()` method much as we did in previous examples,
but we can leverage enums representing these types of events e.g. `CUSTOM()` or `REPLACEABLE()` and pass them the specific Kind integer for the new type of event we're creating.

A good example of this may be events termed as "Parameterized Replaceable Lists".
In the [Nostr NIP-01 documentation](https://github.com/nostr-protocol/nips/blob/master/01.md) we see a recommended range for these lists as `30000 <= n < 40000`,
however at the time of writing, only kinds `30000`, `30002`, `30003`, `30004`, `30005`, `30015`, `30030` and `30063` are currently well defined.
Therefore, if we wanted to extend this to say create a new list event of our favourite memes, Kind `30420`,
then we could do this using the `PARAMETERIZED_REPLACEABLE(30420)` enum to define the type of event as in the example below.
or if you want to leverage one of the commonly defined event types (i.e. replaceable, ephemeral, regular, etc.).

```python,ignore
{{#include ../../../snippets/python/src/event/kind.py:kind-representations}}
Expand Down
Loading

0 comments on commit 6ccc81a

Please sign in to comment.