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/lib/git_events.rs | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) (limited to 'src/lib/git_events.rs') diff --git a/src/lib/git_events.rs b/src/lib/git_events.rs index 559155a..2b3df42 100644 --- a/src/lib/git_events.rs +++ b/src/lib/git_events.rs @@ -3,7 +3,7 @@ use std::{str::FromStr, sync::Arc}; use anyhow::{Context, Result, bail}; use nostr::nips::{nip01::Coordinate, nip10::Marker, nip19::Nip19}; use nostr_sdk::{ - Event, EventBuilder, EventId, FromBech32, Kind, NostrSigner, PublicKey, RelayUrl, Tag, TagKind, + Event, EventBuilder, EventId, FromBech32, Kind, NostrSigner, PublicKey, Tag, TagKind, TagStandard, hashes::sha1::Hash as Sha1Hash, }; @@ -115,11 +115,14 @@ pub async fn generate_patch_event( .maintainers .iter() .map(|m| { - Tag::coordinate(Coordinate { - kind: nostr::Kind::GitRepoAnnouncement, - public_key: *m, - identifier: repo_ref.identifier.to_string(), - relays: repo_ref.relays.clone(), + Tag::from_standardized(TagStandard::Coordinate { + coordinate: Coordinate { + kind: nostr::Kind::GitRepoAnnouncement, + public_key: *m, + identifier: repo_ref.identifier.to_string(), + }, + relay_url: repo_ref.relays.first().cloned(), + uppercase: false, }) }) .collect::>(), @@ -257,12 +260,12 @@ pub fn event_tag_from_nip19_or_hex( PromptInputParms::default().with_prompt(format!("{reference_name} reference")), )?; } - if let Ok(nip19) = Nip19::from_bech32(bech32.clone()) { + if let Ok(nip19) = Nip19::from_bech32(&bech32) { match nip19 { Nip19::Event(n) => { break Ok(Tag::from_standardized(nostr_sdk::TagStandard::Event { event_id: n.event_id, - relay_url: n.relays.first().and_then(|url| RelayUrl::parse(url).ok()), + relay_url: n.relays.first().cloned(), marker: Some(marker), public_key: None, uppercase: false, @@ -278,7 +281,11 @@ pub fn event_tag_from_nip19_or_hex( })); } Nip19::Coordinate(coordinate) => { - break Ok(Tag::coordinate(coordinate)); + break Ok(Tag::from_standardized(TagStandard::Coordinate { + coordinate: coordinate.coordinate, + relay_url: coordinate.relays.first().cloned(), + uppercase: false, + })); } Nip19::Profile(profile) => { if allow_npub_reference { @@ -338,12 +345,17 @@ pub async fn generate_cover_letter_and_patch_events( )) .tags( [ - repo_ref.maintainers.iter().map(|m| Tag::coordinate(Coordinate { - kind: nostr::Kind::GitRepoAnnouncement, - public_key: *m, - identifier: repo_ref.identifier.to_string(), - relays: repo_ref.relays.clone(), - })).collect::>(), + repo_ref.maintainers.iter().map(|m| + Tag::from_standardized(TagStandard::Coordinate { + coordinate: Coordinate { + kind: nostr::Kind::GitRepoAnnouncement, + public_key: *m, + identifier: repo_ref.identifier.to_string(), + }, + relay_url: repo_ref.relays.first().cloned(), + uppercase: false, + }) + ).collect::>(), vec![ Tag::from_standardized(TagStandard::Reference(format!("{root_commit}"))), Tag::hashtag("cover-letter"), -- cgit v1.2.3