use anchor_lang::prelude::*;
use anchor_lang::solana_program::borsh0_10::get_instance_packed_len;
use super::*;
#[account]
pub struct ConfigTransaction {
pub multisig: Pubkey,
pub creator: Pubkey,
pub index: u64,
pub bump: u8,
pub actions: Vec<ConfigAction>,
}
impl ConfigTransaction {
pub fn size(actions: &[ConfigAction]) -> usize {
let actions_size: usize = actions
.iter()
.map(|action| get_instance_packed_len(action).unwrap())
.sum();
8 + 32 + 32 + 8 + 1 + 4 + actions_size
}
}
#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub enum ConfigAction {
AddMember { new_member: Member },
RemoveMember { old_member: Pubkey },
ChangeThreshold { new_threshold: u16 },
SetTimeLock { new_time_lock: u32 },
AddSpendingLimit {
create_key: Pubkey,
vault_index: u8,
mint: Pubkey,
amount: u64,
period: Period,
members: Vec<Pubkey>,
destinations: Vec<Pubkey>,
},
RemoveSpendingLimit { spending_limit: Pubkey },
SetRentCollector { new_rent_collector: Option<Pubkey> },
}