From ba4198eeec10bb93dbaeddfcb6359c35e3d23b17 Mon Sep 17 00:00:00 2001 From: William Casarin Date: Tue, 22 Apr 2025 10:46:51 -0700 Subject: [PATCH] enostr: rename to_bech to npub a bit more clear as to what this is --- crates/enostr/src/keypair.rs | 2 +- crates/enostr/src/pubkey.rs | 2 +- crates/notedeck/src/note/context.rs | 2 +- crates/notedeck_columns/src/post.rs | 2 +- crates/notedeck_columns/src/ui/profile/mod.rs | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/enostr/src/keypair.rs b/crates/enostr/src/keypair.rs index eea07c8..0b7f2c6 100644 --- a/crates/enostr/src/keypair.rs +++ b/crates/enostr/src/keypair.rs @@ -178,7 +178,7 @@ impl TokenSerializable for Pubkey { fn serialize_tokens(&self, writer: &mut tokenator::TokenWriter) { writer.write_token(PUBKEY_TOKEN); - let Some(bech) = self.to_bech() else { + let Some(bech) = self.npub() else { tracing::error!("Could not convert pubkey to bech: {}", self.hex()); return; }; diff --git a/crates/enostr/src/pubkey.rs b/crates/enostr/src/pubkey.rs index 3def384..ae59202 100644 --- a/crates/enostr/src/pubkey.rs +++ b/crates/enostr/src/pubkey.rs @@ -115,7 +115,7 @@ impl Pubkey { } } - pub fn to_bech(&self) -> Option { + pub fn npub(&self) -> Option { bech32::encode::(HRP_NPUB, &self.0).ok() } } diff --git a/crates/notedeck/src/note/context.rs b/crates/notedeck/src/note/context.rs index 8ba3516..a804da5 100644 --- a/crates/notedeck/src/note/context.rs +++ b/crates/notedeck/src/note/context.rs @@ -45,7 +45,7 @@ impl NoteContextSelection { ui.ctx().copy_text(note.content().to_string()); } NoteContextSelection::CopyPubkey => { - if let Some(bech) = Pubkey::new(*note.pubkey()).to_bech() { + if let Some(bech) = Pubkey::new(*note.pubkey()).npub() { ui.ctx().copy_text(bech); } } diff --git a/crates/notedeck_columns/src/post.rs b/crates/notedeck_columns/src/post.rs index b8f1d38..9cfaaf5 100644 --- a/crates/notedeck_columns/src/post.rs +++ b/crates/notedeck_columns/src/post.rs @@ -348,7 +348,7 @@ impl PostBuffer { for (cur_end_ind, mention_ind) in self.mention_ends.iter().rev() { if let Some(info) = self.mentions.get(mention_ind) { if let MentionType::Finalized(pk) = info.mention_type { - if let Some(bech) = pk.to_bech() { + if let Some(bech) = pk.npub() { if let Some(byte_range) = char_indices_to_byte(&out, info.start_index..*cur_end_ind) { diff --git a/crates/notedeck_columns/src/ui/profile/mod.rs b/crates/notedeck_columns/src/ui/profile/mod.rs index 614b51f..2e60498 100644 --- a/crates/notedeck_columns/src/ui/profile/mod.rs +++ b/crates/notedeck_columns/src/ui/profile/mod.rs @@ -152,7 +152,7 @@ impl<'a, 'd> ProfileView<'a, 'd> { ); if ui.add(copy_key_widget(&pfp_rect)).clicked() { - let to_copy = if let Some(bech) = self.pubkey.to_bech() { + let to_copy = if let Some(bech) = self.pubkey.npub() { bech } else { error!("Could not convert Pubkey to bech");