From 9c55bf8af1b260260a916c7b5a6c415990c03ccd Mon Sep 17 00:00:00 2001
From: Awiteb
Date: Wed, 6 Aug 2025 08:13:07 +0000
Subject: [PATCH] chore: use the existing signer to get the pubkey instead of a
new one
Signed-off-by: Awiteb
---
src/cli/commands/issue/new.rs | 2 +-
src/cli/commands/mod.rs | 15 +--------------
src/cli/commands/patch/send.rs | 2 +-
src/cli/commands/reply.rs | 3 +--
src/cli/commands/repo/announce.rs | 2 +-
src/cli/common_commands.rs | 12 ++++++------
src/nostr_utils/mod.rs | 10 ++++++++++
7 files changed, 21 insertions(+), 25 deletions(-)
diff --git a/src/cli/commands/issue/new.rs b/src/cli/commands/issue/new.rs
index bcaf097..fcffd37 100644
--- a/src/cli/commands/issue/new.rs
+++ b/src/cli/commands/issue/new.rs
@@ -102,7 +102,7 @@ impl CommandRunner for NewArgs {
)?)?;
let relays = options.relays.clone().flat_relays(&options.config.sets)?;
let client = NostrClient::init(&options, &relays).await;
- let user_pubk = options.pubkey().await?;
+ let user_pubk = client.pubkey().await?;
let coordinates = naddrs.clone().into_coordinates();
client.add_relays(&naddrs.extract_relays()).await;
let repos = client.fetch_repos(coordinates.as_slice()).await?;
diff --git a/src/cli/commands/mod.rs b/src/cli/commands/mod.rs
index ea94134..3fe8b26 100644
--- a/src/cli/commands/mod.rs
+++ b/src/cli/commands/mod.rs
@@ -32,7 +32,7 @@ use std::sync::Arc;
use std::time::Duration;
use clap::{Args, Parser};
-use nostr::key::{Keys, PublicKey, SecretKey};
+use nostr::key::{Keys, SecretKey};
use nostr::nips::nip46::NostrConnectURI;
use nostr::signer::{IntoNostrSigner, NostrSigner};
use nostr_connect::client::NostrConnect;
@@ -124,19 +124,6 @@ pub enum Commands {
impl CliOptions {
- /// Gets the public key of the user.
- pub async fn pubkey(&self) -> N34Result {
- let Some(signer) = self.signer().await? else {
- unreachable!(
- "This method should only be called when a signer is required. If this panic \
- occurs, it indicates a bug where the command failed to properly require a signer \
- (which is the default behavior)"
- )
- };
-
- signer.get_public_key().await.map_err(N34Error::SignerError)
- }
-
/// Returns the signer
pub async fn signer(&self) -> N34Result