diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:28:29 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2024-11-27 17:28:29 +0000 |
| commit | e40e96a4364464b4e88d3db7a81485b978b57c07 (patch) | |
| tree | fc40611f08a55dc5a198eaabe63e436cfa10bcc3 | |
| parent | 75cd323e2481502671aa1f62b28875d95f9863c3 (diff) | |
feat: only print awaiting signer with nip46
using the backend feature I requested for rust-nostr
| -rw-r--r-- | src/lib/client.rs | 27 |
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::{ | |||
| 29 | use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressState, ProgressStyle}; | 29 | use indicatif::{MultiProgress, ProgressBar, ProgressDrawTarget, ProgressState, ProgressStyle}; |
| 30 | #[cfg(test)] | 30 | #[cfg(test)] |
| 31 | use mockall::*; | 31 | use mockall::*; |
| 32 | use nostr::{nips::nip01::Coordinate, Event}; | 32 | use nostr::{nips::nip01::Coordinate, signer::SignerBackend, Event}; |
| 33 | use nostr_database::NostrEventsDatabase; | 33 | use nostr_database::NostrEventsDatabase; |
| 34 | use nostr_lmdb::NostrLMDB; | 34 | use nostr_lmdb::NostrLMDB; |
| 35 | use nostr_sdk::{ | 35 | use 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 | ||
| 683 | pub async fn fetch_public_key(signer: &Arc<dyn NostrSigner>) -> Result<nostr::PublicKey> { | 683 | pub 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 | ||
| 694 | fn pb_style() -> Result<ProgressStyle> { | 701 | fn pb_style() -> Result<ProgressStyle> { |