pub struct LightSystemProgramCpi { /* private fields */ }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 addressescompress_lamports()- Compress SOL into compressed accountsdecompress_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_input_compressed_accounts_with_merkle_context()- Manually specify input accountswith_output_compressed_accounts()- Manually specify output accounts
§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)?;Implementations§
Source§impl LightSystemProgramCpi
impl LightSystemProgramCpi
pub fn with_new_addresses( self, new_address_params: &[NewAddressParamsPacked], ) -> Self
pub fn with_input_compressed_accounts_with_merkle_context( self, input_compressed_accounts_with_merkle_context: &[PackedCompressedAccountWithMerkleContext], ) -> Self
pub fn with_output_compressed_accounts( self, output_compressed_accounts: &[OutputCompressedAccountWithPackedContext], ) -> Self
pub fn compress_lamports(self, lamports: u64) -> Self
pub fn decompress_lamports(self, lamports: u64) -> Self
Trait Implementations§
Source§impl Clone for LightSystemProgramCpi
impl Clone for LightSystemProgramCpi
Source§fn clone(&self) -> LightSystemProgramCpi
fn clone(&self) -> LightSystemProgramCpi
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 InstructionDiscriminator for LightSystemProgramCpi
impl InstructionDiscriminator for LightSystemProgramCpi
fn discriminator(&self) -> &'static [u8] ⓘ
Source§impl LightCpiInstruction for LightSystemProgramCpi
impl LightCpiInstruction for LightSystemProgramCpi
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
Auto Trait Implementations§
impl Freeze for LightSystemProgramCpi
impl RefUnwindSafe for LightSystemProgramCpi
impl Send for LightSystemProgramCpi
impl Sync for LightSystemProgramCpi
impl Unpin for LightSystemProgramCpi
impl UnwindSafe for LightSystemProgramCpi
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