use core::marker::PhantomData;
use core::ops::{Deref, DerefMut};
use solana_program::account_info::AccountInfo;
use crate::account_data::{AccountData, ProgramId};
pub struct Account<'info, T: AccountData> {
pub info: &'info AccountInfo<'info>,
pub data: T,
}
impl<'info, T: AccountData> Deref for Account<'info, T> {
type Target = T;
fn deref(&self) -> &T { &self.data }
}
impl<'info, T: AccountData> DerefMut for Account<'info, T> {
fn deref_mut(&mut self) -> &mut T { &mut self.data }
}
pub struct Signer<'info> {
pub info: &'info AccountInfo<'info>,
}
pub struct Program<'info, P: ProgramId> {
pub info: &'info AccountInfo<'info>,
_phantom: PhantomData<P>,
}
impl<'info, P: ProgramId> Program<'info, P> {
pub fn new(info: &'info AccountInfo<'info>) -> Self {
Self { info, _phantom: PhantomData }
}
}
pub struct SystemAccount<'info> {
pub info: &'info AccountInfo<'info>,
}
pub struct UncheckedAccount<'info> {
pub info: &'info AccountInfo<'info>,
}