feat: Refactor code to improve error handling and readability

This commit is contained in:
xy
2024-05-09 19:09:55 +09:00
parent c8e1b8b8bd
commit 8c0d03aed0
6 changed files with 21 additions and 24 deletions

View File

@@ -353,7 +353,7 @@ pub async fn get_nstore(key: &str, state: State<'_, Nostr>) -> Result<String, St
pub async fn set_nwc(uri: &str, state: State<'_, Nostr>) -> Result<bool, String> {
let client = &state.client;
if let Ok(nwc_uri) = NostrWalletConnectURI::from_str(&uri) {
if let Ok(nwc_uri) = NostrWalletConnectURI::from_str(uri) {
if let Ok(nwc) = NWC::new(nwc_uri).await {
let keyring = Entry::new("Lume Secret Storage", "NWC").unwrap();
let _ = keyring.set_password(uri);
@@ -431,7 +431,7 @@ pub async fn zap_profile(
if let Some(recipient) = public_key {
let details = ZapDetails::new(ZapType::Public).message(message);
if let Ok(_) = client.zap(recipient, amount, Some(details)).await {
if (client.zap(recipient, amount, Some(details)).await).is_ok() {
Ok(true)
} else {
Err("Zap profile failed".into())
@@ -464,7 +464,7 @@ pub async fn zap_event(
if let Some(recipient) = event_id {
let details = ZapDetails::new(ZapType::Public).message(message);
if let Ok(_) = client.zap(recipient, amount, Some(details)).await {
if (client.zap(recipient, amount, Some(details)).await).is_ok() {
Ok(true)
} else {
Err("Zap event failed".into())