Accounts

Trait Accounts 

Source
pub trait Accounts<'info>:
    Sized
    + ToAccountMetas
    + ToAccountInfos<'info> {
    // 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, Error>;
}
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, Error>

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.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Create<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Approve<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<ApproveChecked<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Burn<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<CloseAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<FreezeAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeAccount3<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeMint2<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeMint<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<MintTo<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Revoke<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<SetAuthority<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<SyncNative<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<ThawAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Transfer<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<TransferChecked<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<AmountToUiAmount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Approve<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Burn<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<CloseAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<FreezeAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<GetAccountDataSize<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeAccount3<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeImmutableOwner<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeMint2<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeMint<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<InitializeMintCloseAuthority<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<MintTo<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Revoke<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<SetAuthority<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<SyncNative<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<ThawAccount<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<Transfer<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<TransferChecked<'info>, Error>

Source§

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

Source§

fn try_accounts( __program_id: &Pubkey, __accounts: &mut &[AccountInfo<'info>], __ix_data: &[u8], __bumps: &mut BTreeMap<String, u8>, __reallocs: &mut BTreeSet<Pubkey>, ) -> Result<UiAmountToAmount<'info>, Error>

Source§

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

Source§

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

Implementors§

Source§

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

Source§

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

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 triggr::instructions::close_account::CloseAccount<'info>
where 'info: 'info,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<'info> Accounts<'info> for triggr::instructions::exec_task::Transfer<'info>
where 'info: 'info,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<'info> Accounts<'info> for WithdrawFromPayerSPL<'info>
where 'info: '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 TransferWithSeed<'info>
where 'info: 'info,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl<'info, T> Accounts<'info> for Account<'info, T>

Source§

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

Source§

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

Source§

impl<'info, T> Accounts<'info> for InterfaceAccount<'info, T>

Source§

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

Source§

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