extend ZapAction

going to need amounts for configurable zaps

Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
kernelkind
2025-04-16 16:13:18 -04:00
parent 0adaafd523
commit 5bddf83655
6 changed files with 35 additions and 11 deletions

View File

@@ -66,7 +66,9 @@ pub use user_account::UserAccount;
pub use wallet::{
get_wallet_for_mut, GlobalWallet, Wallet, WalletError, WalletState, WalletType, WalletUIState,
};
pub use zaps::{AnyZapState, NoteZapTarget, NoteZapTargetOwned, ZapTarget, ZappingError};
pub use zaps::{
AnyZapState, NoteZapTarget, NoteZapTargetOwned, ZapTarget, ZapTargetOwned, ZappingError,
};
// export libs
pub use enostr;

View File

@@ -28,6 +28,12 @@ pub enum NoteAction {
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum ZapAction {
Send(NoteZapTargetOwned),
Send(ZapTargetAmount),
ClearError(NoteZapTargetOwned),
}
#[derive(Debug, Eq, PartialEq, Clone)]
pub struct ZapTargetAmount {
pub target: NoteZapTargetOwned,
pub specified_msats: Option<u64>, // if None use default amount
}

View File

@@ -1,7 +1,7 @@
mod action;
mod context;
pub use action::{NoteAction, ZapAction};
pub use action::{NoteAction, ZapAction, ZapTargetAmount};
pub use context::{BroadcastContext, ContextSelection, NoteContextSelection};
use crate::{notecache::NoteCache, zaps::Zaps, Images};

View File

@@ -606,6 +606,17 @@ impl From<&ZapTarget<'_>> for ZapTargetOwned {
}
}
impl<'a> From<&'a ZapTargetOwned> for ZapTarget<'a> {
fn from(value: &'a ZapTargetOwned) -> Self {
match value {
ZapTargetOwned::Profile(pubkey) => ZapTarget::Profile(pubkey.bytes()),
ZapTargetOwned::Note(note_zap_target_owned) => {
ZapTarget::Note(note_zap_target_owned.into())
}
}
}
}
impl From<&ZapKey<'_>> for ZapKeyOwned {
fn from(value: &ZapKey) -> Self {
Self {