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::InvokeLightSystemProgram;
Modules§
Macros§
- derive_
light_ cpi_ signer - Derives cpi signer and bump to invoke the light system program at compile time. Derives a complete Light Protocol CPI configuration at compile time
Structs§
- CpiAccounts
Config - Contains program id, derived cpi signer, and bump,
- CpiSigner
- Contains program id, derived cpi signer, and bump, 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