feat: add zap setup screen
This commit is contained in:
@@ -103,6 +103,7 @@ fn main() {
|
||||
nostr::metadata::get_settings,
|
||||
nostr::metadata::get_nwc_status,
|
||||
nostr::metadata::set_nwc,
|
||||
nostr::metadata::nwc_status,
|
||||
nostr::metadata::zap_profile,
|
||||
nostr::metadata::zap_event,
|
||||
nostr::event::get_event,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use crate::Nostr;
|
||||
use keyring::Entry;
|
||||
use nostr_sdk::prelude::*;
|
||||
use std::{str::FromStr, time::Duration};
|
||||
use tauri::State;
|
||||
@@ -285,18 +286,30 @@ pub async fn get_nwc_status(state: State<'_, Nostr>) -> Result<bool, ()> {
|
||||
pub async fn set_nwc(uri: &str, state: State<'_, Nostr>) -> Result<bool, String> {
|
||||
let client = &state.client;
|
||||
|
||||
if let Ok(uri) = NostrWalletConnectURI::from_str(&uri) {
|
||||
if let Ok(nwc) = NWC::new(uri).await {
|
||||
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);
|
||||
let _ = client.set_zapper(nwc);
|
||||
|
||||
Ok(true)
|
||||
} else {
|
||||
Ok(false)
|
||||
Err("URI is not valid".into())
|
||||
}
|
||||
} else {
|
||||
Err("Set NWC failed".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn nwc_status(state: State<'_, Nostr>) -> Result<bool, bool> {
|
||||
let client = &state.client;
|
||||
match client.zapper().await {
|
||||
Ok(_) => Ok(true),
|
||||
Err(_) => Err(false),
|
||||
}
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn zap_profile(
|
||||
id: &str,
|
||||
|
||||
Reference in New Issue
Block a user