light_sdk/cpi/mod.rs
1//!
2//!
3//! To create, update, or close compressed accounts,
4//! programs need to invoke the light system program via cross program invocation (cpi).
5//!
6//! ```ignore
7//! declare_id!("2tzfijPBGbrR5PboyFUFKzfEoLTwdDSHUjANCw929wyt");
8//! pub const LIGHT_CPI_SIGNER: CpiSigner =
9//! derive_light_cpi_signer!("2tzfijPBGbrR5PboyFUFKzfEoLTwdDSHUjANCw929wyt");
10//!
11//! let light_cpi_accounts = CpiAccounts::new(
12//! ctx.accounts.fee_payer.as_ref(),
13//! ctx.remaining_accounts,
14//! crate::LIGHT_CPI_SIGNER,
15//! )?;
16//!
17//! let (address, address_seed) = derive_address(
18//! &[b"compressed", name.as_bytes()],
19//! &address_tree_info.get_tree_pubkey(&light_cpi_accounts)?,
20//! &crate::ID,
21//! );
22//! let new_address_params = address_tree_info.into_new_address_params_packed(address_seed);
23//!
24//! let mut my_compressed_account = LightAccount::<MyCompressedAccount>::new_init(
25//! &crate::ID,
26//! Some(address),
27//! output_tree_index,
28//! );
29//!
30//! my_compressed_account.name = name;
31//!
32//! LightSystemProgramCpi::new_cpi(crate::LIGHT_CPI_SIGNER, proof)
33//! .with_light_account(my_compressed_account)?
34//! .with_new_addresses(&[new_address_params])
35//! .invoke(light_cpi_accounts)?;
36//! ```
37
38mod account;
39mod instruction;
40pub mod invoke;
41
42pub mod v1;
43#[cfg(feature = "v2")]
44pub mod v2;
45
46pub use account::*;
47pub use instruction::*;
48pub use invoke::InvokeLightSystemProgram;
49pub use light_compressed_account::instruction_data::traits::LightInstructionData;
50/// Derives cpi signer and bump to invoke the light system program at compile time.
51pub use light_macros::derive_light_cpi_signer;
52/// Contains program id, derived cpi signer, and bump,
53pub use light_sdk_types::{cpi_accounts::CpiAccountsConfig, CpiSigner};