From 948fe972eb2bddf187b79f2673a091b6331cfd90 Mon Sep 17 00:00:00 2001 From: DanConwayDev Date: Tue, 1 Apr 2025 14:31:34 +0100 Subject: chore: bump rust-nostr v0.37 ~> v0.40 and fix all of the breaking changes --- src/bin/git_remote_nostr/fetch.rs | 2 +- src/bin/git_remote_nostr/main.rs | 4 ++-- src/bin/git_remote_nostr/push.rs | 17 +++++++++++------ src/bin/ngit/sub_commands/init.rs | 21 +++++++++++++-------- src/bin/ngit/sub_commands/send.rs | 8 +++++++- 5 files changed, 34 insertions(+), 18 deletions(-) (limited to 'src/bin') diff --git a/src/bin/git_remote_nostr/fetch.rs b/src/bin/git_remote_nostr/fetch.rs index 5ee4271..a7210d0 100644 --- a/src/bin/git_remote_nostr/fetch.rs +++ b/src/bin/git_remote_nostr/fetch.rs @@ -115,7 +115,7 @@ pub fn make_commits_for_proposal( author: Some(patch.pubkey), kind: Some(patch.kind), relays: if let Some(relay) = repo_ref.relays.first() { - vec![relay.to_string()] + vec![relay.to_owned()] } else { vec![] }, diff --git a/src/bin/git_remote_nostr/main.rs b/src/bin/git_remote_nostr/main.rs index 44359dd..daa924f 100644 --- a/src/bin/git_remote_nostr/main.rs +++ b/src/bin/git_remote_nostr/main.rs @@ -15,7 +15,7 @@ use anyhow::{Context, Result, bail}; use client::{Connect, consolidate_fetch_reports, get_repo_ref_from_cache}; use git::{RepoActions, nostr_url::NostrUrlDecoded}; use ngit::{client, git, login::existing::load_existing_login}; -use nostr::nips::nip01::Coordinate; +use nostr::nips::nip19::Nip19Coordinate; use utils::read_line; use crate::{client::Client, git::Repo}; @@ -148,7 +148,7 @@ async fn process_args() -> Result> { async fn fetching_with_report_for_helper( git_repo_path: &Path, client: &Client, - trusted_maintainer_coordinate: &Coordinate, + trusted_maintainer_coordinate: &Nip19Coordinate, ) -> Result<()> { let term = console::Term::stderr(); term.write_line("nostr: fetching...")?; diff --git a/src/bin/git_remote_nostr/push.rs b/src/bin/git_remote_nostr/push.rs index c0085bd..15adc13 100644 --- a/src/bin/git_remote_nostr/push.rs +++ b/src/bin/git_remote_nostr/push.rs @@ -32,7 +32,7 @@ use ngit::{ }; use nostr::nips::nip10::Marker; use nostr_sdk::{ - Event, EventBuilder, EventId, Kind, NostrSigner, PublicKey, RelayUrl, Tag, + Event, EventBuilder, EventId, Kind, NostrSigner, PublicKey, RelayUrl, Tag, TagStandard, hashes::sha1::Hash as Sha1Hash, }; use repo_ref::RepoRef; @@ -1312,7 +1312,13 @@ async fn create_merge_status( repo_ref .coordinates() .iter() - .map(|c| Tag::coordinate(c.clone())) + .map(|c| { + Tag::from_standardized(TagStandard::Coordinate { + coordinate: c.coordinate.clone(), + relay_url: c.relays.first().cloned(), + uppercase: false, + }) + }) .collect::>(), vec![ Tag::from_standardized(nostr::TagStandard::Reference( @@ -1358,7 +1364,7 @@ async fn get_proposal_and_revision_root_from_patch( patch.clone() } else { let proposal_or_revision_id = EventId::parse( - if let Some(t) = patch.tags.iter().find(|t| t.is_root()) { + &if let Some(t) = patch.tags.iter().find(|t| t.is_root()) { t.clone() } else if let Some(t) = patch.tags.iter().find(|t| t.is_reply()) { t.clone() @@ -1389,13 +1395,12 @@ async fn get_proposal_and_revision_root_from_patch( { Ok(( EventId::parse( - proposal_or_revision + &proposal_or_revision .tags .iter() .find(|t| t.is_reply()) .unwrap() - .as_slice()[1] - .clone(), + .as_slice()[1], )?, Some(proposal_or_revision.id), )) diff --git a/src/bin/ngit/sub_commands/init.rs b/src/bin/ngit/sub_commands/init.rs index 4aa7ced..3731e3a 100644 --- a/src/bin/ngit/sub_commands/init.rs +++ b/src/bin/ngit/sub_commands/init.rs @@ -11,6 +11,7 @@ use nostr::{ nips::{ nip01::Coordinate, nip05::{self}, + nip19::Nip19Coordinate, }, }; use nostr_sdk::{Kind, RelayUrl}; @@ -437,10 +438,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { // TODO - does this git config item do more harm than good? git_repo.save_git_config_item( "nostr.repo", - &Coordinate { - kind: Kind::GitRepoAnnouncement, - public_key: user_ref.public_key, - identifier: identifier.clone(), + &Nip19Coordinate { + coordinate: Coordinate { + kind: Kind::GitRepoAnnouncement, + public_key: user_ref.public_key, + identifier: identifier.clone(), + }, relays: vec![], } .to_bech32()?, @@ -471,10 +474,12 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs) -> Result<()> { repo_ref.set_nostr_git_url(NostrUrlDecoded { original_string: String::new(), nip05: Some(nip05.clone()), - coordinate: Coordinate { - kind: Kind::GitRepoAnnouncement, - public_key: user_ref.public_key, - identifier: repo_ref.identifier.clone(), + coordinate: Nip19Coordinate { + coordinate: Coordinate { + kind: Kind::GitRepoAnnouncement, + public_key: user_ref.public_key, + identifier: repo_ref.identifier.clone(), + }, relays: if inter.next().is_some() || relays.is_empty() { vec![] } else { diff --git a/src/bin/ngit/sub_commands/send.rs b/src/bin/ngit/sub_commands/send.rs index 7c898bc..9fc00d9 100644 --- a/src/bin/ngit/sub_commands/send.rs +++ b/src/bin/ngit/sub_commands/send.rs @@ -238,7 +238,13 @@ pub async fn launch(cli_args: &Cli, args: &SubCommandArgs, no_fetch: bool) -> Re if root_proposal_id.is_none() { if let Some(event) = events.first() { let event_bech32 = if let Some(relay) = repo_ref.relays.first() { - Nip19Event::new(event.id, vec![relay.to_string()]).to_bech32()? + Nip19Event { + event_id: event.id, + relays: vec![relay.clone()], + author: None, + kind: None, + } + .to_bech32()? } else { event.id.to_bech32()? }; -- cgit v1.2.3