pub struct LightSystemProgramCpi {Show 13 fields
pub mode: u8,
pub bump: u8,
pub invoking_program_id: Pubkey,
pub compress_or_decompress_lamports: u64,
pub is_compress: bool,
pub with_cpi_context: bool,
pub with_transaction_hash: bool,
pub cpi_context: CompressedCpiContext,
pub proof: Option<CompressedProof>,
pub new_address_params: Vec<NewAddressParamsAssignedPacked>,
pub account_infos: Vec<CompressedAccountInfo>,
pub read_only_addresses: Vec<PackedReadOnlyAddress>,
pub read_only_accounts: Vec<PackedReadOnlyCompressedAccount>,
}Expand description
Light system program CPI instruction data builder.
Use this builder to construct instructions for compressed account operations: creating, updating, closing accounts, and compressing/decompressing SOL.
§Builder Methods
§Common Methods
with_light_account()- Add a compressed account (handles output hashing, and type conversion to instruction data).with_new_addresses()- Create new compressed account addresses.with_read_only_addresses()- Validate that addresses don’t exist without creating them.with_read_only_accounts()- Validate that compressed account state exists without updating it.compress_lamports()- Compress SOL into compressed accounts.decompress_lamports()- Decompress SOL from compressed accounts.
Note: An instruction can either compress or decompress lamports, not both.
§Advanced Methods
For fine-grained control, use these low-level methods instead of with_light_account():
with_account_infos()- Manually specify CompressedAccountInfos.
§Examples
§Create a compressed account with an address
LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, proof)
.with_new_addresses(&[new_address_params])
.with_light_account(account)?
.invoke(cpi_accounts)?;§Update a compressed account
LightSystemProgramCpi::new_cpi(LIGHT_CPI_SIGNER, proof)
.with_light_account(account)?
.invoke(cpi_accounts)?;Fields§
§mode: u80 V1 instruction accounts. 1 Optimized V2 instruction accounts.
bump: u8§invoking_program_id: Pubkey§compress_or_decompress_lamports: u64If compress_or_decompress_lamports > 0 -> expect sol_pool_pda
is_compress: bool-> expect account decompression_recipient
with_cpi_context: bool§with_transaction_hash: bool§cpi_context: CompressedCpiContext§proof: Option<CompressedProof>§new_address_params: Vec<NewAddressParamsAssignedPacked>§account_infos: Vec<CompressedAccountInfo>§read_only_addresses: Vec<PackedReadOnlyAddress>§read_only_accounts: Vec<PackedReadOnlyCompressedAccount>Implementations§
Source§impl InstructionDataInvokeCpiWithAccountInfo
impl InstructionDataInvokeCpiWithAccountInfo
pub fn new( invoking_program_id: Pubkey, bump: u8, proof: Option<CompressedProof>, ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn mode_v1(self) -> InstructionDataInvokeCpiWithAccountInfo
pub fn write_to_cpi_context_set(self) -> InstructionDataInvokeCpiWithAccountInfo
pub fn write_to_cpi_context_first( self, ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn execute_with_cpi_context(self) -> InstructionDataInvokeCpiWithAccountInfo
pub fn with_cpi_context( self, cpi_context: CompressedCpiContext, ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn with_with_transaction_hash( self, with_transaction_hash: bool, ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn compress_lamports( self, lamports: u64, ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn decompress_lamports( self, lamports: u64, ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn with_new_addresses( self, new_address_params: &[NewAddressParamsAssignedPacked], ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn with_account_infos( self, account_infos: &[CompressedAccountInfo], ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn with_read_only_addresses( self, read_only_addresses: &[PackedReadOnlyAddress], ) -> InstructionDataInvokeCpiWithAccountInfo
pub fn with_read_only_accounts( self, read_only_accounts: &[PackedReadOnlyCompressedAccount], ) -> InstructionDataInvokeCpiWithAccountInfo
Trait Implementations§
Source§impl BorshDeserialize for InstructionDataInvokeCpiWithAccountInfowhere
u8: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
bool: BorshDeserialize,
CompressedCpiContext: BorshDeserialize,
Option<CompressedProof>: BorshDeserialize,
Vec<NewAddressParamsAssignedPacked>: BorshDeserialize,
Vec<CompressedAccountInfo>: BorshDeserialize,
Vec<PackedReadOnlyAddress>: BorshDeserialize,
Vec<PackedReadOnlyCompressedAccount>: BorshDeserialize,
impl BorshDeserialize for InstructionDataInvokeCpiWithAccountInfowhere
u8: BorshDeserialize,
Pubkey: BorshDeserialize,
u64: BorshDeserialize,
bool: BorshDeserialize,
CompressedCpiContext: BorshDeserialize,
Option<CompressedProof>: BorshDeserialize,
Vec<NewAddressParamsAssignedPacked>: BorshDeserialize,
Vec<CompressedAccountInfo>: BorshDeserialize,
Vec<PackedReadOnlyAddress>: BorshDeserialize,
Vec<PackedReadOnlyCompressedAccount>: BorshDeserialize,
fn deserialize_reader<R>(
reader: &mut R,
) -> Result<InstructionDataInvokeCpiWithAccountInfo, Error>where
R: Read,
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for InstructionDataInvokeCpiWithAccountInfowhere
u8: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
bool: BorshSerialize,
CompressedCpiContext: BorshSerialize,
Option<CompressedProof>: BorshSerialize,
Vec<NewAddressParamsAssignedPacked>: BorshSerialize,
Vec<CompressedAccountInfo>: BorshSerialize,
Vec<PackedReadOnlyAddress>: BorshSerialize,
Vec<PackedReadOnlyCompressedAccount>: BorshSerialize,
impl BorshSerialize for InstructionDataInvokeCpiWithAccountInfowhere
u8: BorshSerialize,
Pubkey: BorshSerialize,
u64: BorshSerialize,
bool: BorshSerialize,
CompressedCpiContext: BorshSerialize,
Option<CompressedProof>: BorshSerialize,
Vec<NewAddressParamsAssignedPacked>: BorshSerialize,
Vec<CompressedAccountInfo>: BorshSerialize,
Vec<PackedReadOnlyAddress>: BorshSerialize,
Vec<PackedReadOnlyCompressedAccount>: BorshSerialize,
Source§impl Clone for InstructionDataInvokeCpiWithAccountInfo
impl Clone for InstructionDataInvokeCpiWithAccountInfo
Source§fn clone(&self) -> InstructionDataInvokeCpiWithAccountInfo
fn clone(&self) -> InstructionDataInvokeCpiWithAccountInfo
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Default for InstructionDataInvokeCpiWithAccountInfo
impl Default for InstructionDataInvokeCpiWithAccountInfo
Source§fn default() -> InstructionDataInvokeCpiWithAccountInfo
fn default() -> InstructionDataInvokeCpiWithAccountInfo
Returns the “default value” for a type. Read more
Source§impl InstructionDiscriminator for InstructionDataInvokeCpiWithAccountInfo
impl InstructionDiscriminator for InstructionDataInvokeCpiWithAccountInfo
fn discriminator(&self) -> &'static [u8] ⓘ
Source§impl LightCpiInstruction for InstructionDataInvokeCpiWithAccountInfo
impl LightCpiInstruction for InstructionDataInvokeCpiWithAccountInfo
Source§fn new_cpi(cpi_signer: CpiSigner, proof: ValidityProof) -> Self
fn new_cpi(cpi_signer: CpiSigner, proof: ValidityProof) -> Self
Creates a new CPI instruction builder with a validity proof. Read more
Source§fn with_light_account<A>(
self,
account: LightAccount<A>,
) -> Result<Self, ProgramError>
fn with_light_account<A>( self, account: LightAccount<A>, ) -> Result<Self, ProgramError>
Adds a compressed account to the instruction (using SHA256 hashing). Read more
Source§impl PartialEq for InstructionDataInvokeCpiWithAccountInfo
impl PartialEq for InstructionDataInvokeCpiWithAccountInfo
Source§fn eq(&self, other: &InstructionDataInvokeCpiWithAccountInfo) -> bool
fn eq(&self, other: &InstructionDataInvokeCpiWithAccountInfo) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl<'a> ZeroCopyAt<'a> for InstructionDataInvokeCpiWithAccountInfo
impl<'a> ZeroCopyAt<'a> for InstructionDataInvokeCpiWithAccountInfo
type ZeroCopyAt = ZInstructionDataInvokeCpiWithAccountInfo<'a>
fn zero_copy_at( bytes: &'a [u8], ) -> Result<(<InstructionDataInvokeCpiWithAccountInfo as ZeroCopyAt<'a>>::ZeroCopyAt, &'a [u8]), ZeroCopyError>
impl StructuralPartialEq for InstructionDataInvokeCpiWithAccountInfo
Auto Trait Implementations§
impl Freeze for InstructionDataInvokeCpiWithAccountInfo
impl RefUnwindSafe for InstructionDataInvokeCpiWithAccountInfo
impl Send for InstructionDataInvokeCpiWithAccountInfo
impl Sync for InstructionDataInvokeCpiWithAccountInfo
impl Unpin for InstructionDataInvokeCpiWithAccountInfo
impl UnwindSafe for InstructionDataInvokeCpiWithAccountInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more