From ff57df6cf84f78463cf61afcaf3ea94266d8d508 Mon Sep 17 00:00:00 2001 From: benthecarman Date: Wed, 24 Jan 2024 11:40:59 +0000 Subject: [PATCH] Make nostr-sdk signing events public --- crates/nostr-sdk/src/client/mod.rs | 7 ++++--- crates/nostr-sdk/src/client/zapper.rs | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/nostr-sdk/src/client/mod.rs b/crates/nostr-sdk/src/client/mod.rs index f7ed744d6..1a57c18da 100644 --- a/crates/nostr-sdk/src/client/mod.rs +++ b/crates/nostr-sdk/src/client/mod.rs @@ -717,7 +717,8 @@ impl Client { Ok(self.pool.send_event_to(url, event, opts).await?) } - async fn internal_sign_event_builder(&self, builder: EventBuilder) -> Result { + /// Signs the [`EventBuilder`] into an [`Event`] using the [`ClientSigner`] + pub async fn sign_event_builder(&self, builder: EventBuilder) -> Result { match self.signer().await? { ClientSigner::Keys(keys) => { let difficulty: u8 = self.opts.get_difficulty(); @@ -770,7 +771,7 @@ impl Client { /// /// Rise an error if the [`ClientSigner`] is not set. pub async fn send_event_builder(&self, builder: EventBuilder) -> Result { - let event: Event = self.internal_sign_event_builder(builder).await?; + let event: Event = self.sign_event_builder(builder).await?; self.send_event(event).await } @@ -786,7 +787,7 @@ impl Client { U: TryIntoUrl, pool::Error: From<::Err>, { - let event: Event = self.internal_sign_event_builder(builder).await?; + let event: Event = self.sign_event_builder(builder).await?; self.send_event_to(url, event).await } diff --git a/crates/nostr-sdk/src/client/zapper.rs b/crates/nostr-sdk/src/client/zapper.rs index 283a94634..8df0d1159 100644 --- a/crates/nostr-sdk/src/client/zapper.rs +++ b/crates/nostr-sdk/src/client/zapper.rs @@ -316,7 +316,7 @@ impl Client { match details.r#type { ZapType::Public => { let builder = EventBuilder::public_zap_request(data); - Some(self.internal_sign_event_builder(builder).await?.as_json()) + Some(self.sign_event_builder(builder).await?.as_json()) } ZapType::Private => None, ZapType::Anonymous => Some(nip57::anonymous_zap_request(data)?.as_json()),