Expand description
Utilities to invoke the light-system-program via cpi.
To create, update, or close compressed accounts, programs need to invoke the light system program via cross program invocation (cpi).
ⓘ
declare_id!("2tzfijPBGbrR5PboyFUFKzfEoLTwdDSHUjANCw929wyt");
pub const LIGHT_CPI_SIGNER: CpiSigner =
derive_light_cpi_signer!("2tzfijPBGbrR5PboyFUFKzfEoLTwdDSHUjANCw929wyt");
let light_cpi_accounts = CpiAccounts::new(
ctx.accounts.fee_payer.as_ref(),
ctx.remaining_accounts,
crate::LIGHT_CPI_SIGNER,
)?;
let (address, address_seed) = derive_address(
&[b"compressed", name.as_bytes()],
&address_tree_info.get_tree_pubkey(&light_cpi_accounts)?,
&crate::ID,
);
let new_address_params = address_tree_info.into_new_address_params_packed(address_seed);
let mut my_compressed_account = LightAccount::<MyCompressedAccount>::new_init(
&crate::ID,
Some(address),
output_tree_index,
);
my_compressed_account.name = name;
LightSystemProgramCpi::new_cpi(crate::LIGHT_CPI_SIGNER, proof)
.with_light_account(my_compressed_account)?
.with_new_addresses(&[new_address_params])
.invoke(light_cpi_accounts)?;Re-exports§
pub use invoke::invoke_light_system_program;pub use invoke::InvokeLightSystemProgram;
Modules§
- invoke
- v1
- V1 CPI for Light system program.
- v2
- V2 CPI for Light system program - optimized for compressed PDAs.
Structs§
- CpiAccounts
Config - CpiSigner
- Configuration struct containing program ID, CPI signer, and bump for Light Protocol
Traits§
- CpiAccounts
Trait - Trait for types that can provide account information for CPI calls
- Light
CpiInstruction - Trait for Light CPI instruction types
- Light
Instruction Data