upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorDanConwayDev <DanConwayDev@protonmail.com>2024-11-27 17:28:29 +0000
committerDanConwayDev <DanConwayDev@protonmail.com>2024-11-27 17:28:29 +0000
commite40e96a4364464b4e88d3db7a81485b978b57c07 (patch)
treefc40611f08a55dc5a198eaabe63e436cfa10bcc3 /src/lib
parent75cd323e2481502671aa1f62b28875d95f9863c3 (diff)
feat: only print awaiting signer with nip46
using the backend feature I requested for rust-nostr
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/client.rs27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/lib/client.rs b/src/lib/client.rs
index 051aa3d..70f4b8c 100644
--- a/src/lib/client.rs
+++ b/src/lib/client.rs
@@ -29,7 +29,7 @@ use futures::{
29use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressState, ProgressStyle}; 29use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressState, ProgressStyle};
30#[cfg(test)] 30#[cfg(test)]
31use mockall::*; 31use mockall::*;
32use nostr::{nips::nip01::Coordinate, Event}; 32use nostr::{nips::nip01::Coordinate, signer::SignerBackend, Event};
33use nostr_database::NostrEventsDatabase; 33use nostr_database::NostrEventsDatabase;
34use nostr_lmdb::NostrLMDB; 34use nostr_lmdb::NostrLMDB;
35use nostr_sdk::{ 35use nostr_sdk::{
@@ -663,7 +663,7 @@ pub async fn sign_event(
663 // TODO: Yuki suggested he would add a backend option to NostrSigner so we can 663 // TODO: Yuki suggested he would add a backend option to NostrSigner so we can
664 // identify nip46 signers again and replace the below if statement with: 664 // identify nip46 signers again and replace the below if statement with:
665 // if signer.backend() == nip46 { 665 // if signer.backend() == nip46 {
666 if std::env::var("NGITTEST").is_err() { 666 if signer.backend() == SignerBackend::NostrConnect {
667 let term = console::Term::stderr(); 667 let term = console::Term::stderr();
668 term.write_line("signing event with remote signer...")?; 668 term.write_line("signing event with remote signer...")?;
669 let event = signer 669 let event = signer
@@ -681,14 +681,21 @@ pub async fn sign_event(
681} 681}
682 682
683pub async fn fetch_public_key(signer: &Arc<dyn NostrSigner>) -> Result<nostr::PublicKey> { 683pub async fn fetch_public_key(signer: &Arc<dyn NostrSigner>) -> Result<nostr::PublicKey> {
684 let term = console::Term::stderr(); 684 if signer.backend() == SignerBackend::NostrConnect {
685 term.write_line("fetching npub from remote signer...")?; 685 let term = console::Term::stderr();
686 let public_key = signer 686 term.write_line("fetching npub from remote signer...")?;
687 .get_public_key() 687 let public_key = signer
688 .await 688 .get_public_key()
689 .context("failed to get npub from remote signer")?; 689 .await
690 term.clear_last_lines(1)?; 690 .context("failed to get npub from remote signer")?;
691 Ok(public_key) 691 term.clear_last_lines(1)?;
692 Ok(public_key)
693 } else {
694 signer
695 .get_public_key()
696 .await
697 .context("failed to get public key from local keys")
698 }
692} 699}
693 700
694fn pb_style() -> Result<ProgressStyle> { 701fn pb_style() -> Result<ProgressStyle> {