Trait anchor_lang::Accounts

source ·
pub trait Accounts<'info>: ToAccountMetas + ToAccountInfos<'info> + Sized {
    // Required method
    fn try_accounts(
        program_id: &Pubkey,
        accounts: &mut &[AccountInfo<'info>],
        ix_data: &[u8],
        bumps: &mut BTreeMap<String, u8>,
        reallocs: &mut BTreeSet<Pubkey>
    ) -> Result<Self>;
}
Expand description

A data structure of validated accounts that can be deserialized from the input to a Solana program. Implementations of this trait should perform any and all requisite constraint checks on accounts to ensure the accounts maintain any invariants required for the program to run securely. In most cases, it’s recommended to use the Accounts derive macro to implement this trait.

Required Methods§

source

fn try_accounts( program_id: &Pubkey, accounts: &mut &[AccountInfo<'info>], ix_data: &[u8], bumps: &mut BTreeMap<String, u8>, reallocs: &mut BTreeSet<Pubkey> ) -> Result<Self>

Returns the validated accounts struct. What constitutes “valid” is program dependent. However, users of these types should never have to worry about account substitution attacks. For example, if a program expects a Mint account from the SPL token program in a particular field, then it should be impossible for this method to return Ok if any other account type is given–from the SPL token program or elsewhere.

program_id is the currently executing program. accounts is the set of accounts to construct the type from. For every account used, the implementation should mutate the slice, consuming the used entry so that it cannot be used again.

Implementations on Foreign Types§

source§

impl<'info, T: Accounts<'info>> Accounts<'info> for Vec<T>

source§

fn try_accounts( program_id: &Pubkey, accounts: &mut &[AccountInfo<'info>], ix_data: &[u8], bumps: &mut BTreeMap<String, u8>, reallocs: &mut BTreeSet<Pubkey> ) -> Result<Self>

source§

impl<'info, T: Accounts<'info>> Accounts<'info> for Box<T>

source§

fn try_accounts( program_id: &Pubkey, accounts: &mut &[AccountInfo<'info>], ix_data: &[u8], bumps: &mut BTreeMap<String, u8>, reallocs: &mut BTreeSet<Pubkey> ) -> Result<Self>

source§

impl<'info, T: Accounts<'info>> Accounts<'info> for Option<T>

source§

fn try_accounts( program_id: &Pubkey, accounts: &mut &[AccountInfo<'info>], ix_data: &[u8], bumps: &mut BTreeMap<String, u8>, reallocs: &mut BTreeSet<Pubkey> ) -> Result<Self>

Implementors§

source§

impl<'info> Accounts<'info> for Signer<'info>

source§

impl<'info> Accounts<'info> for SystemAccount<'info>

source§

impl<'info> Accounts<'info> for UncheckedAccount<'info>

source§

impl<'info> Accounts<'info> for AccountInfo<'info>

source§

impl<'info> Accounts<'info> for AdvanceNonceAccount<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for Allocate<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for AllocateWithSeed<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for Assign<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for AssignWithSeed<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for AuthorizeNonceAccount<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for CreateAccount<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for CreateAccountWithSeed<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for CreateNonceAccount<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for CreateNonceAccountWithSeed<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for Transfer<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for TransferWithSeed<'info>where 'info: 'info,

source§

impl<'info> Accounts<'info> for WithdrawNonceAccount<'info>where 'info: 'info,

source§

impl<'info, T> Accounts<'info> for Account<'info, T>where T: AccountSerialize + AccountDeserialize + Owner + Clone,

source§

impl<'info, T: Sysvar> Accounts<'info> for Sysvar<'info, T>

source§

impl<'info, T: AccountSerialize + AccountDeserialize + CheckOwner + Clone> Accounts<'info> for InterfaceAccount<'info, T>

source§

impl<'info, T: CheckId> Accounts<'info> for Interface<'info, T>

source§

impl<'info, T: Id> Accounts<'info> for Program<'info, T>

source§

impl<'info, T: ZeroCopy + Owner> Accounts<'info> for AccountLoader<'info, T>