From e186d034e57e22c6a306ac6141e20a2ed96249a9 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Fri, 15 Nov 2024 17:18:30 +0100 Subject: [PATCH] fix: upgrade to nostr sdk development version --- Cargo.lock | 330 +------------------------------------------------ Cargo.toml | 2 +- src/helpers.rs | 4 + src/main.rs | 2 +- src/tasks.rs | 27 ++-- 5 files changed, 23 insertions(+), 342 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6f98fe4..cfd92bf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1189,29 +1189,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" -dependencies = [ - "bytes", - "http", -] - -[[package]] -name = "http-body-util" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" -dependencies = [ - "bytes", - "futures-util", - "http", - "http-body", - "pin-project-lite", -] - [[package]] name = "httparse" version = "1.9.4" @@ -1224,62 +1201,6 @@ version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" -[[package]] -name = "hyper" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http", - "http-body", - "httparse", - "itoa", - "pin-project-lite", - "smallvec", - "tokio", - "want", -] - -[[package]] -name = "hyper-rustls" -version = "0.27.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" -dependencies = [ - "futures-util", - "http", - "hyper", - "hyper-util", - "rustls", - "rustls-pki-types", - "tokio", - "tokio-rustls", - "tower-service", - "webpki-roots", -] - -[[package]] -name = "hyper-util" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" -dependencies = [ - "bytes", - "futures-channel", - "futures-util", - "http", - "http-body", - "hyper", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", -] - [[package]] name = "iana-time-zone" version = "0.1.60" @@ -1355,12 +1276,6 @@ dependencies = [ "logos", ] -[[package]] -name = "ipnet" -version = "2.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" - [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -1465,18 +1380,6 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" -[[package]] -name = "lnurl-pay" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "536e7c782167a2d48346ca0b2677fad19eaef20f19a4ab868e4d5b96ca879def" -dependencies = [ - "bech32", - "reqwest", - "serde", - "serde_json", -] - [[package]] name = "log" version = "0.4.22" @@ -1540,12 +1443,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mime" -version = "0.3.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" - [[package]] name = "minimal-lexical" version = "0.2.1" @@ -1669,10 +1566,8 @@ dependencies = [ [[package]] name = "nostr" version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14ad56c1d9a59f4edc46b17bc64a217b38b99baefddc0080f85ad98a0855336d" +source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb" dependencies = [ - "aes", "async-trait", "base64 0.22.1", "bech32", @@ -1683,26 +1578,20 @@ dependencies = [ "chacha20poly1305", "getrandom 0.2.15", "instant", - "js-sys", "negentropy 0.3.1", "negentropy 0.4.3", "once_cell", - "reqwest", "scrypt", "serde", "serde_json", "unicode-normalization", "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", ] [[package]] name = "nostr-database" version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1859abebf78d7d9e945b20c8faaf710c9db905adeb148035b803ae45792dbebe" +source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb" dependencies = [ "async-trait", "lru", @@ -1715,8 +1604,7 @@ dependencies = [ [[package]] name = "nostr-relay-pool" version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e39cfcb30cab86b30ca9acba89f5ccb25a4142a5dc5fcfbf3edf34b204ddd7c7" +source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb" dependencies = [ "async-utility", "async-wsocket", @@ -1734,33 +1622,18 @@ dependencies = [ [[package]] name = "nostr-sdk" version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4739ed15ff81a0e474d79b38c3eb481ff5f968c1865f38ba46852daf6f6495e" +source = "git+https://github.com/rust-nostr/nostr?rev=829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb#829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb" dependencies = [ "async-utility", "atomic-destructor", - "lnurl-pay", "nostr", "nostr-database", "nostr-relay-pool", - "nostr-zapper", - "nwc", "thiserror", "tokio", "tracing", ] -[[package]] -name = "nostr-zapper" -version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d9709ecf8050bbe4ecf0e5efda2f25b690bb1761fc504e05654621ba9e568a8" -dependencies = [ - "async-trait", - "nostr", - "thiserror", -] - [[package]] name = "num" version = "0.4.3" @@ -1834,21 +1707,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "nwc" -version = "0.36.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b5f98bcaf232b3ec48e018792ca7bc2b90e7520d001a07b8218a9e76a03fda2" -dependencies = [ - "async-trait", - "async-utility", - "nostr", - "nostr-relay-pool", - "nostr-zapper", - "thiserror", - "tracing", -] - [[package]] name = "object" version = "0.36.4" @@ -2049,55 +1907,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "quinn" -version = "0.11.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" -dependencies = [ - "bytes", - "pin-project-lite", - "quinn-proto", - "quinn-udp", - "rustc-hash", - "rustls", - "socket2", - "thiserror", - "tokio", - "tracing", -] - -[[package]] -name = "quinn-proto" -version = "0.11.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" -dependencies = [ - "bytes", - "rand", - "ring", - "rustc-hash", - "rustls", - "slab", - "thiserror", - "tinyvec", - "tracing", -] - -[[package]] -name = "quinn-udp" -version = "0.5.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" -dependencies = [ - "cfg_aliases", - "libc", - "once_cell", - "socket2", - "tracing", - "windows-sys 0.52.0", -] - [[package]] name = "quote" version = "1.0.37" @@ -2204,49 +2013,6 @@ version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" -[[package]] -name = "reqwest" -version = "0.12.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" -dependencies = [ - "base64 0.22.1", - "bytes", - "futures-core", - "futures-util", - "http", - "http-body", - "http-body-util", - "hyper", - "hyper-rustls", - "hyper-util", - "ipnet", - "js-sys", - "log", - "mime", - "once_cell", - "percent-encoding", - "pin-project-lite", - "quinn", - "rustls", - "rustls-pemfile", - "rustls-pki-types", - "serde", - "serde_json", - "serde_urlencoded", - "sync_wrapper", - "tokio", - "tokio-rustls", - "tokio-socks", - "tower-service", - "url", - "wasm-bindgen", - "wasm-bindgen-futures", - "web-sys", - "webpki-roots", - "windows-registry", -] - [[package]] name = "ring" version = "0.17.8" @@ -2280,12 +2046,6 @@ version = "0.1.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f" -[[package]] -name = "rustc-hash" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152" - [[package]] name = "rustix" version = "0.38.35" @@ -2313,16 +2073,6 @@ dependencies = [ "zeroize", ] -[[package]] -name = "rustls-pemfile" -version = "2.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425" -dependencies = [ - "base64 0.22.1", - "rustls-pki-types", -] - [[package]] name = "rustls-pki-types" version = "1.8.0" @@ -2514,18 +2264,6 @@ dependencies = [ "syn", ] -[[package]] -name = "serde_urlencoded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" -dependencies = [ - "form_urlencoded", - "itoa", - "ryu", - "serde", -] - [[package]] name = "sha1" version = "0.10.6" @@ -2632,15 +2370,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" -dependencies = [ - "futures-core", -] - [[package]] name = "tempfile" version = "3.12.0" @@ -2796,12 +2525,6 @@ dependencies = [ "winnow", ] -[[package]] -name = "tower-service" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" - [[package]] name = "tracing" version = "0.1.40" @@ -2833,12 +2556,6 @@ dependencies = [ "once_cell", ] -[[package]] -name = "try-lock" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" - [[package]] name = "tungstenite" version = "0.24.0" @@ -2955,15 +2672,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "want" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" -dependencies = [ - "try-lock", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -3093,36 +2801,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-registry" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" -dependencies = [ - "windows-result", - "windows-strings", - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-result" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" -dependencies = [ - "windows-targets 0.52.6", -] - -[[package]] -name = "windows-strings" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" -dependencies = [ - "windows-result", - "windows-targets 0.52.6", -] - [[package]] name = "windows-sys" version = "0.48.0" diff --git a/Cargo.toml b/Cargo.toml index 9d12d41..abf40d0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,7 +30,7 @@ itertools = "0.12" chrono = "0.4" parse_datetime = "0.5.0" interim = { version = "0.1", features = ["chrono"] } -nostr-sdk = "0.36" # { git = "https://github.com/xeruf/rust-nostr-sdk", rev = "7b556e1e" } +nostr-sdk = { git = "https://github.com/rust-nostr/nostr", rev = "829e8cad6e68f54fb3a8d056d9ce4d1ceeeb84cb" } [dev-dependencies] tokio = { version = "1.41", features = ["rt", "rt-multi-thread", "macros", "io-std"] } diff --git a/src/helpers.rs b/src/helpers.rs index d104f8c..ec66b58 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -7,6 +7,10 @@ use nostr_sdk::Timestamp; pub const CHARACTER_THRESHOLD: usize = 3; +pub fn to_string_or_default(arg: Option) -> String { + arg.map(|arg| arg.to_string()).unwrap_or_default() +} + pub fn some_non_empty(str: &str) -> Option { if str.is_empty() { None } else { Some(str.to_string()) } } diff --git a/src/main.rs b/src/main.rs index 7f3ed7f..edc5ce8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -136,7 +136,7 @@ async fn main() -> Result<()> { let client = ClientBuilder::new() .opts(Options::new() .automatic_authentication(true) - //.notification_channel_size(8192) + .notification_channel_size(8192) ) .signer(keys.clone()) .build(); diff --git a/src/tasks.rs b/src/tasks.rs index c4ebe5e..0698aef 100644 --- a/src/tasks.rs +++ b/src/tasks.rs @@ -7,14 +7,14 @@ use std::str::FromStr; use std::time::Duration; use crate::event_sender::{EventSender, MostrMessage}; -use crate::helpers::{format_timestamp_local, format_timestamp_relative, format_timestamp_relative_to, parse_tracking_stamp, some_non_empty, CHARACTER_THRESHOLD}; +use crate::helpers::{format_timestamp_local, format_timestamp_relative, format_timestamp_relative_to, parse_tracking_stamp, some_non_empty, to_string_or_default, CHARACTER_THRESHOLD}; use crate::kinds::*; use crate::task::{State, Task, TaskState, MARKER_DEPENDS, MARKER_PARENT, MARKER_PROPERTY}; use colored::Colorize; use itertools::Itertools; use log::{debug, error, info, trace, warn}; use nostr_sdk::prelude::Marker; -use nostr_sdk::{Event, EventBuilder, EventId, JsonUtil, Keys, Kind, Metadata, PublicKey, Tag, TagStandard, Timestamp, UncheckedUrl, Url}; +use nostr_sdk::{Alphabet, Event, EventBuilder, EventId, JsonUtil, Keys, Kind, Metadata, PublicKey, SingleLetterTag, Tag, TagKind, TagStandard, Timestamp, UncheckedUrl, Url}; use regex::bytes::Regex; use tokio::sync::mpsc::Sender; use TagStandard::Hashtag; @@ -824,21 +824,20 @@ impl TasksRelay { // Updates pub(crate) fn make_event_tag_from_id(&self, id: EventId, marker: &str) -> Tag { - Tag::from(TagStandard::Event { - event_id: id, - relay_url: self.sender.url.as_ref().map(|url| UncheckedUrl::new(url.as_str())), - marker: Some(Marker::Custom(marker.to_string())), - public_key: self.get_by_id(&id).map(|e| e.event.pubkey), - }) + Tag::custom(TagKind::SingleLetter(SingleLetterTag::lowercase(Alphabet::E)), [ + id.to_string(), + to_string_or_default(self.sender.url.as_ref()), + marker.to_string(), + ]) } pub(crate) fn make_event_tag(&self, event: &Event, marker: &str) -> Tag { - Tag::from(TagStandard::Event { - event_id: event.id, - relay_url: self.sender.url.as_ref().map(|url| UncheckedUrl::new(url.as_str())), - marker: Some(Marker::Custom(marker.to_string())), - public_key: Some(event.pubkey), - }) + Tag::custom(TagKind::SingleLetter(SingleLetterTag::lowercase(Alphabet::E)), [ + event.id.to_string(), + to_string_or_default(self.sender.url.as_ref()), + marker.to_string(), + event.pubkey.to_string(), + ]) } pub(crate) fn parent_tag(&self) -> Option {