deps: Upgrade to nostr@0.43.0

Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
Awiteb
2025-08-03 13:29:26 +00:00
parent 8bb4cf0da4
commit 1d83e445a4
7 changed files with 241 additions and 234 deletions

View File

@@ -35,6 +35,7 @@ use clap::Parser;
use clap_verbosity_flag::Verbosity;
use nostr::key::Keys;
use nostr::key::SecretKey;
use nostr_keyring::KeyringError;
use nostr_keyring::NostrKeyring;
use types::RelayOrSet;
@@ -96,7 +97,7 @@ impl Cli {
match keyring.get(Self::N34_KEY_PAIR_ENTRY) {
Ok(keys) => Ok(keys),
Err(nostr_keyring::Error::Keyring(keyring::Error::NoEntry)) => {
Err(nostr_keyring::Error::Keyring(KeyringError::NoEntry)) => {
let new_keys = Keys::generate();
keyring.set(Self::N34_KEY_PAIR_ENTRY, &new_keys)?;
Ok(new_keys)

View File

@@ -19,8 +19,8 @@ use std::str::FromStr;
use nostr::{
event::{EventId, Kind},
nips::{
self,
nip01::Coordinate,
nip05::{Nip05Address, Nip05Profile},
nip19::{self, FromBech32, Nip19Coordinate},
},
types::RelayUrl,
@@ -194,19 +194,25 @@ impl FromStr for NostrEvent {
fn parse_nip5_repo(nip5: &str, repo_id: &str) -> Result<NaddrOrSet, String> {
let (username, domain) = nip5.split_once("@").unwrap_or(("_", nip5));
let nip5_profile = tokio::task::block_in_place(|| {
let nip5_address =
Nip05Address::parse(&format!("{username}@{domain}")).map_err(|err| err.to_string())?;
let nip5_json = tokio::task::block_in_place(|| {
Handle::current().block_on(async {
nips::nip05::profile(format!("{username}@{domain}"), None)
reqwest::get(nip5_address.url().as_str())
.await
.map_err(|err| err.to_string())?
.text()
.await
.map_err(|err| err.to_string())
})
})?;
Ok(NaddrOrSet::Naddr(
Nip19Coordinate::new(
Coordinate::new(Kind::GitRepoAnnouncement, nip5_profile.public_key).identifier(repo_id),
nip5_profile.relays,
)
.expect("The relays is `RelayUrl`"),
))
let nip5_profile =
Nip05Profile::from_raw_json(&nip5_address, &nip5_json).map_err(|err| err.to_string())?;
Ok(NaddrOrSet::Naddr(Nip19Coordinate::new(
Coordinate::new(Kind::GitRepoAnnouncement, nip5_profile.public_key).identifier(repo_id),
nip5_profile.relays,
)))
}

View File

@@ -28,6 +28,7 @@ use nostr::{
parser::Token,
types::{RelayUrl, Url},
};
use nostr_keyring::KeyringError;
use crate::cli::issue::ISSUE_ALT_PREFIX;
use crate::cli::patch::{REVISION_ROOT_HASHTAG_CONTENT, ROOT_HASHTAG_CONTENT};
@@ -307,6 +308,6 @@ impl nostr_keyring::Error {
/// Checks if the error indicates a missing keyring entry.
#[inline]
pub fn is_keyring_no_entry(&self) -> bool {
matches!(self, nostr_keyring::Error::Keyring(keyring::Error::NoEntry))
matches!(self, nostr_keyring::Error::Keyring(KeyringError::NoEntry))
}
}

View File

@@ -151,9 +151,8 @@ pub fn repo_naddr(
) -> N34Result<String> {
Nip19Coordinate::new(
Coordinate::new(Kind::GitRepoAnnouncement, pubk).identifier(repo_id),
dedup(relays.iter().cloned()).iter().take(3),
dedup(relays.iter().cloned()).into_iter().take(3),
)
.expect("Valid relays")
.to_bech32()
.map_err(N34Error::from)
}