Updates for changes upstream in nostr-types

This commit is contained in:
Mike Dilger 2023-03-31 10:37:07 +13:00
parent 7963b18219
commit 9b67dcb1f9
7 changed files with 36 additions and 40 deletions

View File

@ -37,7 +37,7 @@ impl Delegation {
pub fn get_delegator_pubkey_as_bech32_str(&self) -> Option<String> {
self.get_delegator_pubkey()
.map(|pubkey| pubkey.try_as_bech32_string().unwrap_or_default())
.map(|pubkey| pubkey.as_bech32_string())
}
pub fn set(&self, tag_str: &str) -> Result<(), Error> {

View File

@ -172,7 +172,7 @@ impl Signer {
// Test password
let mut pk = epk.decrypt(pass)?;
let output = pk.try_as_bech32_string()?;
let output = pk.as_bech32_string();
// We have to regenerate encrypted private key because it may have fallen from
// medium to weak security. And then we need to save that

View File

@ -483,7 +483,7 @@ fn render_note_inner(
}
}
if ui.button("Copy ID").clicked() {
ui.output_mut(|o| o.copied_text = event.id.try_as_bech32_string().unwrap());
ui.output_mut(|o| o.copied_text = event.id.as_bech32_string());
}
if ui.button("Copy ID as hex").clicked() {
ui.output_mut(|o| o.copied_text = event.id.as_hex_string());
@ -731,7 +731,7 @@ fn render_note_inner(
app.draft.push(' ');
}
app.draft
.push_str(&event.id.try_as_bech32_string().unwrap());
.push_str(&event.id.as_bech32_string());
}
ui.add_space(24.0);

View File

@ -198,7 +198,7 @@ fn real_posting_area(app: &mut GossipUi, ctx: &Context, frame: &mut eframe::Fram
if !app.draft.ends_with(' ') && !app.draft.is_empty() {
app.draft.push(' ');
}
app.draft.push_str(&pair.1.try_as_bech32_string().unwrap());
app.draft.push_str(&pair.1.as_bech32_string());
app.tag_someone = "".to_owned();
}
}

View File

@ -559,10 +559,10 @@ impl GossipUi {
pub fn pubkey_short(pubkeyhex: &PublicKeyHex) -> String {
match PublicKey::try_from_hex_string(pubkeyhex) {
Err(_) => GossipUi::hex_pubkey_short(pubkeyhex),
Ok(pk) => match pk.try_as_bech32_string() {
Err(_) => GossipUi::hex_pubkey_short(pubkeyhex),
Ok(npub) => format!("{}", &npub.get(0..20).unwrap_or("????????????????????")),
},
Ok(pk) => {
let npub = pk.as_bech32_string();
format!("{}", &npub.get(0..20).unwrap_or("????????????????????"))
}
}
}
@ -626,7 +626,7 @@ impl GossipUi {
.on_hover_text("Copy Public Key")
.clicked()
{
ui.output_mut(|o| o.copied_text = person.pubkey.try_as_bech32_string().unwrap());
ui.output_mut(|o| o.copied_text = person.pubkey.as_bech32_string());
}
});
}

View File

@ -71,17 +71,15 @@ fn content(
let mut npub = "Unable to get npub".to_owned();
if let Ok(pk) = PublicKey::try_from_hex_string(&pubkeyhex) {
if let Ok(npubref) = pk.try_as_bech32_string() {
npub = npubref.to_owned();
ui.horizontal_wrapped(|ui| {
ui.label(RichText::new("Public Key: ").strong());
ui.label(npubref);
if ui.button("").on_hover_text("Show as QR code").clicked() {
app.qr_codes.remove("person_qr");
app.person_qr = Some("npub");
}
});
}
npub = pk.as_bech32_string();
ui.horizontal_wrapped(|ui| {
ui.label(RichText::new("Public Key: ").strong());
ui.label(&npub);
if ui.button("").on_hover_text("Show as QR code").clicked() {
app.qr_codes.remove("person_qr");
app.person_qr = Some("npub");
}
});
}
if let Some(name) = person.name() {

View File

@ -181,16 +181,15 @@ fn show_pub_key_detail(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) {
}
});
if let Ok(bech32) = public_key.try_as_bech32_string() {
ui.horizontal_wrapped(|ui| {
ui.label(&format!("Public Key (bech32): {}", bech32));
if ui.add(CopyButton {}).clicked() {
ui.output_mut(|o| o.copied_text = bech32.clone());
}
});
ui.add_space(10.0);
app.render_qr(ui, ctx, "you_npub_qr", &bech32);
}
let bech32 = public_key.as_bech32_string();
ui.horizontal_wrapped(|ui| {
ui.label(&format!("Public Key (bech32): {}", bech32));
if ui.add(CopyButton {}).clicked() {
ui.output_mut(|o| o.copied_text = bech32.clone());
}
});
ui.add_space(10.0);
app.render_qr(ui, ctx, "you_npub_qr", &bech32);
ui.add_space(10.0);
ui.separator();
@ -200,7 +199,7 @@ fn show_pub_key_detail(app: &mut GossipUi, ctx: &Context, ui: &mut Ui) {
ui.heading("N-Profile");
ui.add_space(10.0);
let nprofile = profile.try_as_bech32_string().unwrap();
let nprofile = profile.as_bech32_string();
ui.horizontal_wrapped(|ui| {
ui.label(&format!("Your Profile: {}", &nprofile));
if ui.add(CopyButton {}).clicked() {
@ -428,14 +427,13 @@ fn offer_delete_or_import_pub_key(app: &mut GossipUi, ui: &mut Ui) {
}
});
if let Ok(bech32) = pk.try_as_bech32_string() {
ui.horizontal(|ui| {
ui.label(&format!("Public Key (bech32): {}", bech32));
if ui.add(CopyButton {}).clicked() {
ui.output_mut(|o| o.copied_text = bech32);
}
});
}
let bech32 = pk.as_bech32_string();
ui.horizontal(|ui| {
ui.label(&format!("Public Key (bech32): {}", bech32));
if ui.add(CopyButton {}).clicked() {
ui.output_mut(|o| o.copied_text = bech32);
}
});
if ui.button("Delete this public key").clicked() {
let _ = GLOBALS.to_overlord.send(ToOverlordMessage::DeletePub);