mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-19 09:34:19 +01:00
@@ -1,11 +1,11 @@
|
||||
use enostr::Keypair;
|
||||
use tokenator::{ParseError, TokenParser, TokenSerializable};
|
||||
|
||||
use crate::Wallet;
|
||||
use crate::wallet::ZapWallet;
|
||||
|
||||
pub struct UserAccount {
|
||||
pub key: Keypair,
|
||||
pub wallet: Option<Wallet>,
|
||||
pub wallet: Option<ZapWallet>,
|
||||
}
|
||||
|
||||
impl UserAccount {
|
||||
@@ -13,7 +13,7 @@ impl UserAccount {
|
||||
Self { key, wallet: None }
|
||||
}
|
||||
|
||||
pub fn with_wallet(mut self, wallet: Wallet) -> Self {
|
||||
pub fn with_wallet(mut self, wallet: ZapWallet) -> Self {
|
||||
self.wallet = Some(wallet);
|
||||
self
|
||||
}
|
||||
@@ -21,7 +21,7 @@ impl UserAccount {
|
||||
|
||||
enum UserAccountRoute {
|
||||
Key(Keypair),
|
||||
Wallet(Wallet),
|
||||
Wallet(ZapWallet),
|
||||
}
|
||||
|
||||
impl TokenSerializable for UserAccount {
|
||||
@@ -36,7 +36,7 @@ impl TokenSerializable for UserAccount {
|
||||
parser,
|
||||
&[
|
||||
|p| Ok(UserAccountRoute::Key(Keypair::parse_from_tokens(p)?)),
|
||||
|p| Ok(UserAccountRoute::Wallet(Wallet::parse_from_tokens(p)?)),
|
||||
|p| Ok(UserAccountRoute::Wallet(ZapWallet::parse_from_tokens(p)?)),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -90,8 +90,8 @@ mod tests {
|
||||
#[test]
|
||||
fn test_user_account_serialize_deserialize() {
|
||||
let kp = FullKeypair::generate();
|
||||
let acc =
|
||||
UserAccount::new(kp.to_keypair()).with_wallet(Wallet::new(URI.to_owned()).unwrap());
|
||||
let acc = UserAccount::new(kp.to_keypair())
|
||||
.with_wallet(Wallet::new(URI.to_owned()).unwrap().into());
|
||||
|
||||
let mut writer = TokenWriter::new("\t");
|
||||
acc.serialize_tokens(&mut writer);
|
||||
@@ -111,6 +111,6 @@ mod tests {
|
||||
panic!();
|
||||
};
|
||||
|
||||
assert_eq!(wallet.uri, URI);
|
||||
assert_eq!(wallet.wallet.uri, URI);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ pub fn get_wallet_for_mut<'a>(
|
||||
accounts: &'a mut Accounts,
|
||||
global_wallet: &'a mut GlobalWallet,
|
||||
account_pk: &'a [u8; 32],
|
||||
) -> Option<&'a mut Wallet> {
|
||||
) -> Option<&'a mut ZapWallet> {
|
||||
let cur_acc = accounts.get_account_mut_optimized(account_pk)?;
|
||||
|
||||
if let Some(wallet) = &mut cur_acc.wallet {
|
||||
@@ -137,7 +137,7 @@ impl TokenSerializable for Wallet {
|
||||
}
|
||||
|
||||
pub struct GlobalWallet {
|
||||
pub wallet: Option<Wallet>,
|
||||
pub wallet: Option<ZapWallet>,
|
||||
pub ui_state: WalletUIState,
|
||||
wallet_handler: TokenHandler,
|
||||
}
|
||||
@@ -172,8 +172,8 @@ impl GlobalWallet {
|
||||
}
|
||||
}
|
||||
|
||||
fn construct_global_wallet(wallet_handler: &TokenHandler) -> Option<Wallet> {
|
||||
let Ok(res) = wallet_handler.load::<Wallet>("\t") else {
|
||||
fn construct_global_wallet(wallet_handler: &TokenHandler) -> Option<ZapWallet> {
|
||||
let Ok(res) = wallet_handler.load::<ZapWallet>("\t") else {
|
||||
return None;
|
||||
};
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ fn process_event(
|
||||
});
|
||||
};
|
||||
|
||||
let promise = wallet.pay_invoice(&invoice);
|
||||
let promise = wallet.wallet.pay_invoice(&invoice);
|
||||
|
||||
let ctx = SendingNWCInvoiceContext {
|
||||
request_noteid: req_noteid,
|
||||
|
||||
@@ -546,7 +546,7 @@ fn render_nav_body(
|
||||
if let Some(cur_acc) = ctx.accounts.get_selected_account_mut() {
|
||||
if let Some(wallet) = &mut cur_acc.wallet {
|
||||
break 's WalletState::Wallet {
|
||||
wallet,
|
||||
wallet: &mut wallet.wallet,
|
||||
can_create_local_wallet: false,
|
||||
};
|
||||
}
|
||||
@@ -560,7 +560,7 @@ fn render_nav_body(
|
||||
};
|
||||
|
||||
WalletState::Wallet {
|
||||
wallet,
|
||||
wallet: &mut wallet.wallet,
|
||||
can_create_local_wallet: true,
|
||||
}
|
||||
}
|
||||
@@ -579,7 +579,7 @@ fn render_nav_body(
|
||||
};
|
||||
|
||||
WalletState::Wallet {
|
||||
wallet,
|
||||
wallet: &mut wallet.wallet,
|
||||
can_create_local_wallet: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ impl WalletAction {
|
||||
};
|
||||
|
||||
accounts.update_current_account(move |acc| {
|
||||
acc.wallet = Some(wallet);
|
||||
acc.wallet = Some(wallet.into());
|
||||
});
|
||||
} else {
|
||||
if global_wallet.wallet.is_some() {
|
||||
@@ -60,7 +60,7 @@ impl WalletAction {
|
||||
return;
|
||||
};
|
||||
|
||||
global_wallet.wallet = Some(wallet);
|
||||
global_wallet.wallet = Some(wallet.into());
|
||||
global_wallet.save_wallet();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user