mirror of
https://github.com/aljazceru/notedeck.git
synced 2025-12-18 17:14:21 +01:00
accounts: make fallback pk non optional
Note: this commit alone is *incorrect* and will cause crashes. It is part of a greater plan to upgrade accounts. It was done this way to break commits to smaller, more digestable chunks Signed-off-by: kernelkind <kernelkind@gmail.com>
This commit is contained in:
@@ -20,11 +20,15 @@ pub struct Accounts {
|
||||
account_data: BTreeMap<[u8; 32], AccountData>,
|
||||
relay_defaults: RelayDefaults,
|
||||
needs_relay_config: bool,
|
||||
fallback: Option<Pubkey>,
|
||||
fallback: Pubkey,
|
||||
}
|
||||
|
||||
impl Accounts {
|
||||
pub fn new(key_store: Option<AccountStorage>, forced_relays: Vec<String>) -> Self {
|
||||
pub fn new(
|
||||
key_store: Option<AccountStorage>,
|
||||
forced_relays: Vec<String>,
|
||||
fallback: Pubkey,
|
||||
) -> Self {
|
||||
let accounts = match &key_store {
|
||||
Some(keystore) => match keystore.get_accounts() {
|
||||
Ok(k) => k,
|
||||
@@ -53,7 +57,7 @@ impl Accounts {
|
||||
account_data,
|
||||
relay_defaults,
|
||||
needs_relay_config: true,
|
||||
fallback: None,
|
||||
fallback,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +86,7 @@ impl Accounts {
|
||||
}
|
||||
|
||||
pub fn with_fallback(&mut self, fallback: Pubkey) {
|
||||
self.fallback = Some(fallback);
|
||||
self.fallback = fallback;
|
||||
}
|
||||
|
||||
pub fn remove_account(&mut self, index: usize) {
|
||||
@@ -359,11 +363,9 @@ impl Accounts {
|
||||
}
|
||||
|
||||
fn handle_no_accounts(&mut self, unknown_ids: &mut UnknownIds, ndb: &Ndb, txn: &Transaction) {
|
||||
if let Some(fallback) = self.fallback {
|
||||
self.add_account(Keypair::new(fallback, None))
|
||||
.process_action(unknown_ids, ndb, txn);
|
||||
self.select_account(self.num_accounts() - 1);
|
||||
}
|
||||
self.add_account(Keypair::new(self.fallback, None))
|
||||
.process_action(unknown_ids, ndb, txn);
|
||||
self.select_account(self.num_accounts() - 1);
|
||||
}
|
||||
|
||||
fn poll_for_updates(&mut self, ndb: &Ndb) -> bool {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::account::FALLBACK_PUBKEY;
|
||||
use crate::persist::{AppSizeHandler, ZoomHandler};
|
||||
use crate::wallet::GlobalWallet;
|
||||
use crate::zaps::Zaps;
|
||||
@@ -176,7 +177,7 @@ impl Notedeck {
|
||||
None
|
||||
};
|
||||
|
||||
let mut accounts = Accounts::new(keystore, parsed_args.relays.clone());
|
||||
let mut accounts = Accounts::new(keystore, parsed_args.relays.clone(), FALLBACK_PUBKEY());
|
||||
|
||||
let num_keys = parsed_args.keys.len();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user