pub struct PackedAccounts(pub PackedAccounts<AccountMeta>);Expand description
Packs accounts and creates indices for instruction building (client-side).
Wraps the generic PackedAccounts<AccountMeta> from sdk-types with
Solana-specific system account helpers as inherent methods.
Tuple Fields§
§0: PackedAccounts<AccountMeta>Implementations§
Source§impl PackedAccounts
impl PackedAccounts
Sourcepub fn new_with_system_accounts(config: SystemAccountMetaConfig) -> Result<Self>
pub fn new_with_system_accounts(config: SystemAccountMetaConfig) -> Result<Self>
Creates a new PackedAccounts with v1 system accounts pre-configured.
Use with cpi::v1::CpiAccounts on the program side.
Sourcepub fn add_system_accounts(
&mut self,
config: SystemAccountMetaConfig,
) -> Result<()>
pub fn add_system_accounts( &mut self, config: SystemAccountMetaConfig, ) -> Result<()>
Adds v1 Light system program accounts to the account list.
Use with cpi::v1::CpiAccounts on the program side.
This adds all the accounts required by the Light system program for v1 operations, including the CPI authority, registered programs, account compression program, and Noop program.
Sourcepub fn add_system_accounts_v2(
&mut self,
config: SystemAccountMetaConfig,
) -> Result<()>
pub fn add_system_accounts_v2( &mut self, config: SystemAccountMetaConfig, ) -> Result<()>
Adds v2 Light system program accounts to the account list.
Use with cpi::v2::CpiAccounts on the program side.
This adds all the accounts required by the Light system program for v2 operations. V2 uses a different account layout optimized for batched state trees.
Methods from Deref<Target = PackedAccounts<AccountMeta>>§
pub fn system_accounts_set(&self) -> bool
pub fn add_pre_accounts_signer( &mut self, pubkey: <AM as AccountMetaTrait>::Pubkey, )
pub fn add_pre_accounts_signer_mut( &mut self, pubkey: <AM as AccountMetaTrait>::Pubkey, )
pub fn add_pre_accounts_meta(&mut self, account_meta: AM)
pub fn add_pre_accounts_metas(&mut self, account_metas: &[AM])
pub fn add_system_accounts_raw(&mut self, system_accounts: Vec<AM>)
Sourcepub fn insert_or_get(&mut self, pubkey: <AM as AccountMetaTrait>::Pubkey) -> u8
pub fn insert_or_get(&mut self, pubkey: <AM as AccountMetaTrait>::Pubkey) -> u8
Returns the index of the provided pubkey in the collection.
If the provided pubkey is not a part of the collection, it gets
inserted with a next_index.
If the provided pubkey already exists in the collection, its already
existing index is returned.
pub fn insert_or_get_read_only( &mut self, pubkey: <AM as AccountMetaTrait>::Pubkey, ) -> u8
pub fn insert_or_get_config( &mut self, pubkey: <AM as AccountMetaTrait>::Pubkey, is_signer: bool, is_writable: bool, ) -> u8
Sourcepub fn to_account_metas(&self) -> (Vec<AM>, usize, usize)
pub fn to_account_metas(&self) -> (Vec<AM>, usize, usize)
Converts the collection of accounts to a vector of account metas, which can be used as remaining accounts in instructions or CPI calls.
§Returns
A tuple of (account_metas, system_accounts_offset, packed_accounts_offset):
account_metas: All accounts concatenated in order:[pre_accounts][system_accounts][packed_accounts]system_accounts_offset: Index where system accounts start (= pre_accounts.len())packed_accounts_offset: Index where packed accounts start (= pre_accounts.len() + system_accounts.len())