#[cfg(feature = "pinocchio")]
pub type AccountView = pinocchio::AccountView;
#[cfg(feature = "pinocchio")]
pub type AccountInfo = AccountView;
#[cfg(all(not(feature = "pinocchio"), feature = "anchor"))]
pub type AccountInfo<'a> = anchor_lang::prelude::AccountInfo<'a>;
#[cfg(all(not(feature = "pinocchio"), not(feature = "anchor")))]
pub type AccountInfo<'a> = crate::solana_program::account_info::AccountInfo<'a>;
#[cfg(feature = "pinocchio")]
pub trait AsAccountInfo<'a> {
fn as_account_info(&self) -> &AccountInfo;
}
#[cfg(feature = "pinocchio")]
pub trait AsAccountInfoMut<'a>: AsAccountInfo<'a> {
fn as_account_info_mut(&mut self) -> &mut AccountInfo;
}
#[cfg(not(feature = "pinocchio"))]
pub trait AsAccountInfo<'a> {
fn as_account_info(&self) -> &AccountInfo<'a>;
}
#[cfg(feature = "pinocchio")]
impl<'a> AsAccountInfo<'a> for AccountInfo {
#[inline(always)]
fn as_account_info(&self) -> &AccountInfo {
self
}
}
#[cfg(feature = "pinocchio")]
impl<'a> AsAccountInfoMut<'a> for AccountInfo {
#[inline(always)]
fn as_account_info_mut(&mut self) -> &mut AccountInfo {
self
}
}
#[cfg(not(feature = "pinocchio"))]
impl<'a> AsAccountInfo<'a> for AccountInfo<'a> {
#[inline(always)]
fn as_account_info(&self) -> &AccountInfo<'a> {
self
}
}
#[cfg(feature = "pinocchio")]
impl<'a> AsAccountInfo<'a> for &AccountInfo {
#[inline(always)]
fn as_account_info(&self) -> &AccountInfo {
self
}
}
#[cfg(feature = "pinocchio")]
impl<'a> AsAccountInfo<'a> for &mut AccountInfo {
#[inline(always)]
fn as_account_info(&self) -> &AccountInfo {
self
}
}
#[cfg(feature = "pinocchio")]
impl<'a> AsAccountInfoMut<'a> for &mut AccountInfo {
#[inline(always)]
fn as_account_info_mut(&mut self) -> &mut AccountInfo {
self
}
}
#[cfg(not(feature = "pinocchio"))]
impl<'a> AsAccountInfo<'a> for &AccountInfo<'a> {
#[inline(always)]
fn as_account_info(&self) -> &AccountInfo<'a> {
self
}
}
#[cfg(feature = "pinocchio")]
#[macro_export]
macro_rules! get_account_key {
($account:expr) => {
$account.address()
};
}
#[cfg(not(feature = "pinocchio"))]
#[macro_export]
macro_rules! get_account_key {
($account:expr) => {
$account.key
};
}
#[cfg(feature = "pinocchio")]
#[macro_export]
macro_rules! borrow_account_data {
($account:expr) => {
unsafe { $account.borrow_unchecked() }
};
}
#[cfg(not(feature = "pinocchio"))]
#[macro_export]
macro_rules! borrow_account_data {
($account:expr) => {
$account.data.borrow()
};
}
#[cfg(feature = "pinocchio")]
#[macro_export]
macro_rules! borrow_mut_account_data {
($account:expr) => {
unsafe { $account.borrow_unchecked_mut() }
};
}
#[cfg(not(feature = "pinocchio"))]
#[macro_export]
macro_rules! borrow_mut_account_data {
($account:expr) => {
$account.data.borrow_mut()
};
}