From 06bd46c40c7a865836ec4029c33df92aaa85f84d Mon Sep 17 00:00:00 2001 From: Ryan Date: Mon, 16 Dec 2024 13:31:11 +0300 Subject: [PATCH] test(nostr): add log messages --- src/app.rs | 2 +- src/nostr.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app.rs b/src/app.rs index 33bfe43..f45dc8b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -19,7 +19,7 @@ pub fn App() -> impl IntoView { spawn_local(async move { //initialize nostr client - let nostr_client = NostrClient::new("wss://relay.example.com").await.unwrap(); + let nostr_client = NostrClient::new("wss://relay.damus.io").await.unwrap(); nostr_client.subscribe_to_items(tx.clone()).await.unwrap(); //handle incoming events diff --git a/src/nostr.rs b/src/nostr.rs index 1f6ae26..a28795c 100644 --- a/src/nostr.rs +++ b/src/nostr.rs @@ -40,6 +40,7 @@ impl NostrClient { let client = Client::new(keys.clone()); client.add_relay(relay_url).await?; client.connect().await; + println!("Connected to relay: {}", relay_url); Ok(Self { client, keys }) } @@ -61,17 +62,19 @@ impl NostrClient { ); // Create the event builder - let event_builder = EventBuilder::new(Kind::TextNote, content); - // Build the unsigned event + let event_builder = EventBuilder::new(Kind::TextNote, content.clone()); + // Build the unsigned event let unsigned_event = event_builder.build(self.keys.public_key()); - // Sign the event and handle the error explicitly + // Sign the event and handle the error explicitly let signed_event = match unsigned_event.sign(&self.keys).await { Ok(event) => event, Err(e) => return Err(MyError::from(e)), // Convert the error to the expected type }; // Send the event - self.client.send_event(signed_event).await?; + self.client.send_event(signed_event.clone()).await?; + println!("Event published: {:?}", signed_event); + println!("Publishing content: {}", content); Ok(()) } pub async fn subscribe_to_items( @@ -90,7 +93,7 @@ impl NostrClient { } } }); - + Ok(()) } }