From 07a6b27eacc9cb80b0858ae8d7042287567ea790 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:28 +0000 Subject: ClientSigner renamed ~> NostrSigner to reflect new name in rust-nostr --- src/client.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/client.rs b/src/client.rs index 539d45a..7eaa322 100644 --- a/src/client.rs +++ b/src/client.rs @@ -19,7 +19,7 @@ use indicatif::{MultiProgress, ProgressBar, ProgressState, ProgressStyle}; #[cfg(test)] use mockall::*; use nostr::Event; -use nostr_sdk::ClientSigner; +use nostr_sdk::NostrSigner; #[allow(clippy::struct_field_names)] pub struct Client { @@ -101,7 +101,7 @@ impl Connect for Client { async fn set_keys(&mut self, keys: &nostr::Keys) { self.client - .set_signer(Some(ClientSigner::Keys(keys.clone()))) + .set_signer(Some(NostrSigner::Keys(keys.clone()))) .await; } @@ -125,7 +125,7 @@ impl Connect for Client { async fn send_event_to(&self, url: &str, event: Event) -> Result { self.client.add_relay(url).await?; self.client.connect_relay(url).await?; - Ok(self.client.send_event_to(url, event).await?) + Ok(self.client.send_event_to(vec![url], event).await?) } async fn get_events( -- cgit v1.2.3 From f7d520e9ccb6084144a3e963516e40a322add0c8 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:31 +0000 Subject: use Sha1Hashin new location it had moved from 'prelude' to 'hashes' --- src/git.rs | 2 +- src/sub_commands/push.rs | 2 +- src/sub_commands/send.rs | 6 ++---- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/git.rs b/src/git.rs index 86b59fb..77c1dcb 100644 --- a/src/git.rs +++ b/src/git.rs @@ -4,7 +4,7 @@ use std::{env::current_dir, path::Path}; use anyhow::{bail, Context, Result}; use git2::{DiffOptions, Oid, Revwalk}; -use nostr::prelude::{sha1::Hash as Sha1Hash, Hash}; +use nostr_sdk::hashes::{sha1::Hash as Sha1Hash, Hash}; use crate::sub_commands::list::{get_commit_id_from_patch, tag_value}; diff --git a/src/sub_commands/push.rs b/src/sub_commands/push.rs index 651b250..bb50ee2 100644 --- a/src/sub_commands/push.rs +++ b/src/sub_commands/push.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Context, Result}; -use nostr::prelude::sha1::Hash as Sha1Hash; +use nostr_sdk::hashes::sha1::Hash as Sha1Hash; #[cfg(not(test))] use crate::client::Client; diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 35c2c81..cc182f1 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -4,10 +4,8 @@ use anyhow::{bail, Context, Result}; use console::Style; use futures::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use nostr::{ - nips::nip19::Nip19, prelude::sha1::Hash as Sha1Hash, EventBuilder, FromBech32, Marker, Tag, - TagKind, UncheckedUrl, -}; +use nostr::{nips::nip19::Nip19, EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl}; +use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use super::list::tag_value; #[cfg(not(test))] -- cgit v1.2.3 From 0d7a8383d7d54e64bb0e1d5f4e06110c1e6a818b Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:34 +0000 Subject: rename from_sk_str -> from_str to reflect new name in rust-nostr --- src/key_handling/encryption.rs | 12 ++++++++---- src/key_handling/users.rs | 6 +++--- src/login.rs | 8 +++++--- test_utils/src/lib.rs | 8 ++++---- 4 files changed, 20 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/key_handling/encryption.rs b/src/key_handling/encryption.rs index 0ef7f69..54002fa 100644 --- a/src/key_handling/encryption.rs +++ b/src/key_handling/encryption.rs @@ -1,3 +1,5 @@ +use std::str::FromStr; + use anyhow::{anyhow, bail, ensure, Context, Result}; use chacha20poly1305::{ aead::{rand_core::RngCore, Aead, AeadCore, KeyInit, OsRng, Payload}, @@ -6,6 +8,7 @@ use chacha20poly1305::{ #[cfg(test)] use mockall::*; use nostr::{prelude::*, Keys}; +use nostr_sdk::bech32::{self, FromBase32, ToBase32}; use rand::{distributions::Alphanumeric, thread_rng, Rng}; use zeroize::Zeroize; @@ -120,10 +123,11 @@ impl EncryptDecrypt for Encryptor { bail!("invalid encrypted key"); } - let key = Keys::from_sk_str( - std::str::from_utf8(&inner_secret).context("inner secret is not [u8]")?, - ) - .context("incorrect password. Key decrypted with password did not produce a valid nsec.")?; + let key = + Keys::from_str(std::str::from_utf8(&inner_secret).context("inner secret is not [u8]")?) + .context( + "incorrect password. Key decrypted with password did not produce a valid nsec.", + )?; inner_secret.zeroize(); diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index 2e88fba..c061cd3 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs @@ -1,4 +1,4 @@ -use std::time::SystemTime; +use std::{str::FromStr, time::SystemTime}; use anyhow::{Context, Result}; use async_trait::async_trait; @@ -59,7 +59,7 @@ impl UserManagement for UserManager { .input(PromptInputParms::default().with_prompt(prompt)) .context("failed to get nsec input from interactor")?, }; - match Keys::from_sk_str(&pk) { + match Keys::from_str(&pk) { Ok(key) => { break key; } @@ -471,7 +471,7 @@ mod tests { .expect_encrypt_key() .once() .withf(|k, p| { - k.eq(&Keys::from_sk_str(TEST_KEY_1_NSEC).unwrap()) && p.eq(TEST_PASSWORD) + k.eq(&Keys::from_str(TEST_KEY_1_NSEC).unwrap()) && p.eq(TEST_PASSWORD) }) .returning(|_, _| Ok(TEST_KEY_1_ENCRYPTED.into())); diff --git a/src/login.rs b/src/login.rs index b0fe230..4cdf3c1 100644 --- a/src/login.rs +++ b/src/login.rs @@ -1,5 +1,7 @@ +use std::str::FromStr; + use anyhow::{bail, Context, Result}; -use nostr::{prelude::FromSkStr, secp256k1::XOnlyPublicKey}; +use nostr::PublicKey; use zeroize::Zeroize; #[cfg(not(test))] @@ -25,7 +27,7 @@ pub async fn launch( // if nsec parameter let key = if let Some(nsec_unwrapped) = nsec { // get key or fail without prompts - let key = nostr::Keys::from_sk_str(nsec_unwrapped).context("invalid nsec parameter")?; + let key = nostr::Keys::from_str(nsec_unwrapped).context("invalid nsec parameter")?; // if password, add user to enable password login in future if password.is_some() { @@ -91,7 +93,7 @@ pub async fn launch( } async fn get_user_details( - public_key: &XOnlyPublicKey, + public_key: &PublicKey, #[cfg(test)] client: &crate::client::MockConnect, #[cfg(not(test))] client: &Client, ) -> Result { diff --git a/test_utils/src/lib.rs b/test_utils/src/lib.rs index a0c67df..ad187be 100644 --- a/test_utils/src/lib.rs +++ b/test_utils/src/lib.rs @@ -1,9 +1,9 @@ -use std::{ffi::OsStr, path::PathBuf}; +use std::{ffi::OsStr, path::PathBuf, str::FromStr}; use anyhow::{bail, ensure, Context, Result}; use dialoguer::theme::{ColorfulTheme, Theme}; use directories::ProjectDirs; -use nostr::{self, prelude::FromSkStr, Kind, Tag}; +use nostr::{self, Kind, Tag}; use once_cell::sync::Lazy; use rexpect::session::{Options, PtySession}; use strip_ansi_escapes::strip_str; @@ -26,7 +26,7 @@ pub static TEST_KEY_1_DISPLAY_NAME: &str = "bob"; pub static TEST_KEY_1_ENCRYPTED: &str = "ncryptsec1qyq607h3cykxc3f2a44u89cdk336fptccn3fm5pf3nmf93d3c86qpunc7r6klwcn6lyszjy72wxwqq9aljg4pm6atvjrds9e248yhv76xfnt464265kgnjsvg8rlg06wg4sp9uljzfpu8zuaztcvfn2j8ggdrg8mldh850cy75efsyqqansert9wqmn4e6khpgvfz7h5le9"; pub static TEST_KEY_1_ENCRYPTED_WEAK: &str = "ncryptsec1qy8ke0tjqnn8wt3w6lnc86c27ry3qrptxctjfcgruryxy0at238kwyjwsswd7z88thysruzw3awlrsxjvw5uptcd7vt70ft9rtkx00m8cgy3khm4hxa5d2gfnc6athnfruy2eyl6pkas8k34jg85z7xjqqadzfzh9rp0fzxqtw0tvxksac3n8yc98uksvuf93e0lcvqy8j6"; pub static TEST_KEY_1_KEYS: Lazy = - Lazy::new(|| nostr::Keys::from_sk_str(TEST_KEY_1_NSEC).unwrap()); + Lazy::new(|| nostr::Keys::from_str(TEST_KEY_1_NSEC).unwrap()); pub fn generate_test_key_1_metadata_event(name: &str) -> nostr::Event { nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) @@ -95,7 +95,7 @@ pub static TEST_KEY_2_NPUB: &str = pub static TEST_KEY_2_DISPLAY_NAME: &str = "carole"; pub static TEST_KEY_2_ENCRYPTED: &str = "...2"; pub static TEST_KEY_2_KEYS: Lazy = - Lazy::new(|| nostr::Keys::from_sk_str(TEST_KEY_2_NSEC).unwrap()); + Lazy::new(|| nostr::Keys::from_str(TEST_KEY_2_NSEC).unwrap()); pub fn generate_test_key_2_metadata_event(name: &str) -> nostr::Event { nostr::event::EventBuilder::metadata(&nostr::Metadata::new().name(name)) -- cgit v1.2.3 From 9a450f2ce740da08843a541d230c43194b934f5f Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:36 +0000 Subject: replace XOnlyPublicKey with wrapper PublicKey to reflect new name in rust-nostr --- src/config.rs | 6 +++--- src/key_handling/users.rs | 12 ++++++------ src/repo_ref.rs | 14 +++++++------- src/sub_commands/init.rs | 10 +++++----- 4 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/config.rs b/src/config.rs index 2370e34..7fca446 100644 --- a/src/config.rs +++ b/src/config.rs @@ -4,7 +4,7 @@ use anyhow::{anyhow, Context, Result}; use directories::ProjectDirs; #[cfg(test)] use mockall::*; -use nostr::{secp256k1::XOnlyPublicKey, ToBech32}; +use nostr::{PublicKey, ToBech32}; use serde::{self, Deserialize, Serialize}; #[derive(Default)] @@ -69,7 +69,7 @@ pub struct MyConfig { #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct UserRef { - pub public_key: XOnlyPublicKey, + pub public_key: PublicKey, pub encrypted_key: String, pub metadata: UserMetadata, pub relays: UserRelays, @@ -77,7 +77,7 @@ pub struct UserRef { } impl UserRef { - pub fn new(public_key: XOnlyPublicKey, encrypted_key: String) -> Self { + pub fn new(public_key: PublicKey, encrypted_key: String) -> Self { Self { public_key, encrypted_key, diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index c061cd3..751c577 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs @@ -32,13 +32,13 @@ pub trait UserManagement { &self, #[cfg(test)] client: &MockConnect, #[cfg(not(test))] client: &Client, - public_key: &XOnlyPublicKey, + public_key: &PublicKey, after: u64, ) -> Result; - fn get_user_from_cache(&self, public_key: &XOnlyPublicKey) -> Result; + fn get_user_from_cache(&self, public_key: &PublicKey) -> Result; fn add_user_to_config( &self, - public_key: XOnlyPublicKey, + public_key: PublicKey, encrypted_secret_key: Option, overwrite: bool, ) -> Result<()>; @@ -99,7 +99,7 @@ impl UserManagement for UserManager { fn add_user_to_config( &self, - public_key: XOnlyPublicKey, + public_key: PublicKey, encrypted_secret_key: Option, overwrite: bool, ) -> Result<()> { @@ -129,7 +129,7 @@ impl UserManagement for UserManager { .context("failed to save application configuration with new user details in") } - fn get_user_from_cache(&self, public_key: &XOnlyPublicKey) -> Result { + fn get_user_from_cache(&self, public_key: &PublicKey) -> Result { let cfg = self .config_manager .load() @@ -148,7 +148,7 @@ impl UserManagement for UserManager { &self, #[cfg(test)] client: &MockConnect, #[cfg(not(test))] client: &Client, - public_key: &XOnlyPublicKey, + public_key: &PublicKey, use_cache_unless_checked_more_than_x_secs_ago: u64, ) -> Result { let cfg = self diff --git a/src/repo_ref.rs b/src/repo_ref.rs index c7b42fa..0a14005 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs @@ -1,7 +1,7 @@ use std::{fs::File, io::BufReader, str::FromStr}; use anyhow::{bail, Context, Result}; -use nostr::{nips::nip19::Nip19, secp256k1::XOnlyPublicKey, FromBech32, Tag, ToBech32}; +use nostr::{nips::nip19::Nip19, FromBech32, PublicKey, Tag, ToBech32}; use serde::{Deserialize, Serialize}; #[cfg(not(test))] @@ -23,7 +23,7 @@ pub struct RepoRef { pub git_server: String, pub web: Vec, pub relays: Vec, - pub maintainers: Vec, + pub maintainers: Vec, // code languages and hashtags } @@ -78,7 +78,7 @@ impl TryFrom for RepoRef { } for pk in maintainers { r.maintainers.push( - nostr_sdk::prelude::XOnlyPublicKey::from_str(&pk) + nostr_sdk::prelude::PublicKey::from_str(&pk) .context(format!("cannot convert entry from maintainers tag {pk} into a valid nostr public key. it should be in hex format")) .context("invalid repository event")?, ); @@ -246,11 +246,11 @@ pub fn get_repo_config_from_yaml(git_repo: &Repo) -> Result { Ok(repo_config_yaml) } -pub fn extract_pks(pk_strings: Vec) -> Result> { - let mut pks: Vec = vec![]; +pub fn extract_pks(pk_strings: Vec) -> Result> { + let mut pks: Vec = vec![]; for s in pk_strings { pks.push( - nostr_sdk::prelude::XOnlyPublicKey::from_bech32(s.clone()) + nostr_sdk::prelude::PublicKey::from_bech32(s.clone()) .context(format!("cannot convert {s} into a valid nostr public key"))?, ); } @@ -259,7 +259,7 @@ pub fn extract_pks(pk_strings: Vec) -> Result> { pub fn save_repo_config_to_yaml( git_repo: &Repo, - maintainers: Vec, + maintainers: Vec, relays: Vec, ) -> Result<()> { let path = git_repo.get_path()?.join("maintainers.yaml"); diff --git a/src/sub_commands/init.rs b/src/sub_commands/init.rs index 4f098c0..56129a6 100644 --- a/src/sub_commands/init.rs +++ b/src/sub_commands/init.rs @@ -1,5 +1,5 @@ use anyhow::{Context, Result}; -use nostr::{secp256k1::XOnlyPublicKey, FromBech32, ToBech32}; +use nostr::{FromBech32, PublicKey, ToBech32}; use super::send::send_events; #[cfg(not(test))] @@ -163,7 +163,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { args.web.clone() }; - let maintainers: Vec = { + let maintainers: Vec = { let mut dont_ask = !args.other_maintainers.is_empty(); let mut maintainers_string = if !args.other_maintainers.is_empty() { [args.other_maintainers.clone()].concat().join(" ") @@ -185,7 +185,7 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { }; // add current user if not present if maintainers.iter().any(|m| { - if let Ok(m_pubkey) = XOnlyPublicKey::from_bech32(m) { + if let Ok(m_pubkey) = PublicKey::from_bech32(m) { user_ref.public_key.eq(&m_pubkey) } else { false @@ -210,9 +210,9 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { .map(std::string::ToString::to_string) .collect(); } - let mut maintainers: Vec = vec![]; + let mut maintainers: Vec = vec![]; for m in maintainers_string.split(' ') { - if let Ok(m_pubkey) = XOnlyPublicKey::from_bech32(m) { + if let Ok(m_pubkey) = PublicKey::from_bech32(m) { maintainers.push(m_pubkey); } else { println!("not a valid set of npubs seperated by a space"); -- cgit v1.2.3 From 49bc478fffc63a3cad0be194c6c45a868e432691 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 15:51:40 +0000 Subject: update tag generation to reflect changes in rust-nostr --- src/key_handling/users.rs | 6 +++++- src/repo_ref.rs | 5 +++-- src/sub_commands/list.rs | 12 +++++++++--- src/sub_commands/send.rs | 31 ++++++++++++++++++++----------- tests/list.rs | 12 +++++++++--- tests/pull.rs | 10 ++++++++-- 6 files changed, 54 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/key_handling/users.rs b/src/key_handling/users.rs index 751c577..1dd75a8 100644 --- a/src/key_handling/users.rs +++ b/src/key_handling/users.rs @@ -249,7 +249,11 @@ impl UserManagement for UserManager { relays: new_relays_event .tags .iter() - .filter(|t| t.kind().eq(&nostr::TagKind::R)) + .filter(|t| { + t.kind().eq(&nostr::TagKind::SingleLetter( + SingleLetterTag::lowercase(Alphabet::R), + )) + }) .map(|t| UserRelayRef { url: t.as_vec()[1].clone(), read: t.as_vec().len() == 2 || t.as_vec()[2].eq("read"), diff --git a/src/repo_ref.rs b/src/repo_ref.rs index 0a14005..2dab79c 100644 --- a/src/repo_ref.rs +++ b/src/repo_ref.rs @@ -200,8 +200,9 @@ pub async fn fetch( nostr::Filter::default().kind(nostr::Kind::Custom(REPO_REF_KIND)); match nip19 { Nip19::Coordinate(c) => { - repo_event_filter = - repo_event_filter.identifier(c.identifier).author(c.pubkey); + repo_event_filter = repo_event_filter + .identifier(c.identifier) + .author(c.public_key); for r in c.relays { relays.push(r); } diff --git a/src/sub_commands/list.rs b/src/sub_commands/list.rs index 2d81164..1a30b9b 100644 --- a/src/sub_commands/list.rs +++ b/src/sub_commands/list.rs @@ -730,9 +730,12 @@ pub async fn find_proposal_events( vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]) .custom_tag( - nostr::Alphabet::A, + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::A), repo_ref .maintainers .iter() @@ -742,7 +745,10 @@ pub async fn find_proposal_events( // events nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]) + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ) .reference(root_commit), ], ) diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index cc182f1..91654d2 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -4,7 +4,10 @@ use anyhow::{bail, Context, Result}; use console::Style; use futures::future::join_all; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use nostr::{nips::nip19::Nip19, EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl}; +use nostr::{ + nips::{nip01::Coordinate, nip19::Nip19}, + EventBuilder, FromBech32, Marker, Tag, TagKind, UncheckedUrl, +}; use nostr_sdk::hashes::sha1::Hash as Sha1Hash; use super::list::tag_value; @@ -539,11 +542,14 @@ pub fn generate_cover_letter_and_patch_events( vec![ // TODO: why not tag all maintainer identifiers? Tag::A { - kind: nostr::Kind::Custom(REPO_REF_KIND), - public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, - identifier: repo_ref.identifier.to_string(), + coordinate: Coordinate { + kind: nostr::Kind::Custom(REPO_REF_KIND), + public_key: *repo_ref.maintainers.first() + .context("repo reference should always have at least one maintainer - the issuer of the repo event") + ?, + identifier: repo_ref.identifier.to_string(), + relays: repo_ref.relays.clone(), + }, relay_url: repo_ref.relays.first().map(nostr::UncheckedUrl::from).clone(), }, Tag::Reference(format!("{root_commit}")), @@ -795,11 +801,14 @@ pub fn generate_patch_event( [ vec![ Tag::A { - kind: nostr::Kind::Custom(REPO_REF_KIND), - public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, - identifier: repo_ref.identifier.to_string(), + coordinate: Coordinate { + kind: nostr::Kind::Custom(REPO_REF_KIND), + public_key: *repo_ref.maintainers.first() + .context("repo reference should always have at least one maintainer - the issuer of the repo event") + ?, + identifier: repo_ref.identifier.to_string(), + relays: repo_ref.relays.clone(), + }, relay_url: relay_hint.clone(), }, Tag::Reference(format!("{root_commit}")), diff --git a/tests/list.rs b/tests/list.rs index 4f55645..ee5e1dc 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -190,7 +190,7 @@ mod cannot_find_repo_event { input.succeeds_with( &Coordinate { kind: nostr::Kind::Custom(REPOSITORY_KIND), - pubkey: TEST_KEY_1_KEYS.public_key(), + public_key: TEST_KEY_1_KEYS.public_key(), identifier: repo_event.identifier().unwrap().to_string(), relays: vec!["ws://localhost:8056".to_string()], } @@ -1621,7 +1621,10 @@ mod when_main_branch_is_uptodate { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; @@ -1748,7 +1751,10 @@ mod when_main_branch_is_uptodate { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; diff --git a/tests/pull.rs b/tests/pull.rs index 50dddbf..853f518 100644 --- a/tests/pull.rs +++ b/tests/pull.rs @@ -746,7 +746,10 @@ mod when_branch_is_checked_out { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; @@ -843,7 +846,10 @@ mod when_branch_is_checked_out { vec![ nostr::Filter::default() .kind(nostr::Kind::Custom(PATCH_KIND)) - .custom_tag(nostr::Alphabet::T, vec!["root"]), + .custom_tag( + nostr::SingleLetterTag::lowercase(nostr::Alphabet::T), + vec!["root"], + ), ], Some(Duration::from_millis(500)), )?; -- cgit v1.2.3 From 761484b6db6100a8b7f81e09f8903232f9f3ffaf Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Fri, 22 Mar 2024 16:02:35 +0000 Subject: refactor: more concise error message to suppress the clippy too_many_lines in function warning --- src/sub_commands/send.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/sub_commands/send.rs b/src/sub_commands/send.rs index 91654d2..d9caf9b 100644 --- a/src/sub_commands/send.rs +++ b/src/sub_commands/send.rs @@ -545,8 +545,7 @@ pub fn generate_cover_letter_and_patch_events( coordinate: Coordinate { kind: nostr::Kind::Custom(REPO_REF_KIND), public_key: *repo_ref.maintainers.first() - .context("repo reference should always have at least one maintainer - the issuer of the repo event") - ?, + .context("repo reference should always have at least one maintainer")?, identifier: repo_ref.identifier.to_string(), relays: repo_ref.relays.clone(), }, -- cgit v1.2.3 From 04a8bce2c58dfb697410ae9bb83ab6abbf95406a Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Mon, 25 Mar 2024 09:47:04 +0000 Subject: fix: relay connection timeout panic upgrade from rust-nostr v0.27 ~> v0.28 introduces this panic presumably get_events attempted to write to the MultiProgress just after it has been removed --- src/client.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/client.rs b/src/client.rs index 7eaa322..e271a9f 100644 --- a/src/client.rs +++ b/src/client.rs @@ -144,7 +144,7 @@ impl Connect for Client { let m = MultiProgress::new(); let pb_style = ProgressStyle::with_template(" {spinner} {prefix} {msg} {timeout_in}")? .with_key("timeout_in", |state: &ProgressState, w: &mut dyn Write| { - if state.elapsed().as_secs() > 3 { + if state.elapsed().as_secs() > 3 && state.elapsed().as_secs() < GET_EVENTS_TIMEOUT { write!( w, "timeout in {:.1}s", -- cgit v1.2.3 From 4171733090d25732029a149cf0976c6b1103d0ea Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Thu, 28 Mar 2024 08:30:57 +0000 Subject: refactor: allow pedantic clippy warning large_futures rust-nostr author suggested this might be a false positive https://github.com/rust-nostr/nostr/pull/375#issuecomment-2022245832 --- src/client.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/client.rs b/src/client.rs index e271a9f..2dbd238 100644 --- a/src/client.rs +++ b/src/client.rs @@ -124,6 +124,7 @@ impl Connect for Client { async fn send_event_to(&self, url: &str, event: Event) -> Result { self.client.add_relay(url).await?; + #[allow(clippy::large_futures)] self.client.connect_relay(url).await?; Ok(self.client.send_event_to(vec![url], event).await?) } @@ -200,6 +201,7 @@ impl Connect for Client { } else { None }; + #[allow(clippy::large_futures)] match get_events_of(relay, filters, &pb).await { Err(error) => { if let Some(pb) = pb { @@ -246,6 +248,7 @@ async fn get_events_of( pb: &Option, ) -> Result> { if !relay.is_connected().await { + #[allow(clippy::large_futures)] relay.connect(None).await; } -- cgit v1.2.3