1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//! # Overview
//!
//! This module provides types and utilities for building Solana instructions that work with
//! compressed accounts. The main workflow involves:
//! ```text
//! |- Client
//! | |- Get ValidityProof from RPC.
//! | |- pack accounts with PackedAccounts into PackedAddressTreeInfo and PackedStateTreeInfo.
//! | |- pack CompressedAccountMeta.
//! | |- Build Instruction from packed accounts and CompressedAccountMetas.
//! | |_ Send transaction
//! |
//! |_ Custom Program
//! |- use PackedAddressTreeInfo to create a new address.
//! |- use CompressedAccountMeta to instantiate a LightAccount struct.
//! |
//! |_ Light System Program CPI
//! ```
//! ## Main Types
//!
//! - [`PackedAddressTreeInfo`](crate::instruction::PackedAddressTreeInfo) - Indices of address tree and queue accounts.
//! - [`PackedStateTreeInfo`](crate::instruction::PackedStateTreeInfo) - Indices of state tree and queue accounts.
//! - [`PackedAccounts`](crate::instruction::PackedAccounts) - Packs accounts and creates indices for instruction building (client-side).
//! - [`SystemAccountMetaConfig`](crate::instruction::SystemAccountMetaConfig) - Configures which Light system program accounts to add to [`PackedAccounts`](crate::instruction::PackedAccounts).
//! - [`ValidityProof`](crate::instruction::ValidityProof) - Proves that new addresses don't exist yet, and compressed account state exists.
//! - [`CompressedAccountMeta`](crate::instruction::account_meta::CompressedAccountMeta) - Metadata for compressed accounts.
//!
//! ## Compressed Account Metas
//! Instruction data types to pass compressed account metadata into instructions.
//! [`CompressedAccountMeta`](crate::instruction::account_meta::CompressedAccountMeta) and variations with and without lamports and addresses are used to instantiate LightAccount structs in your program.
//!
//! ## Packed Structs Pattern
//!
//! Structs prefixed with `Packed` (eg [`PackedAddressTreeInfo`](crate::instruction::PackedAddressTreeInfo), [`PackedStateTreeInfo`](crate::instruction::PackedStateTreeInfo)) are instruction data
//! structs that contain account **indices** instead of **pubkeys** to reduce instruction size.
//!
//! - `Packed*` structs: Contain indices (u8) for use in instruction data.
//! - Non-`Packed` structs: Contain pubkeys (Pubkey) for use in the client, and are returned by RPC methods.
//! - [`PackedAccounts`](crate::instruction::PackedAccounts): Manages account deduplication and index assignment to create `Packed*` structs.
// TODO: link to examples
// Re-export instruction types from sdk-types (available on all targets)
// SDK-specific: ValidityProof and CompressedProof
pub use ;
pub use *;
// Re-export pack_accounts utilities (off-chain only, requires std for HashMap)
pub use *;
// SDK-specific: system account helpers (depend on find_cpi_signer_macro!)
pub use *;
// SDK-specific: tree info packing/unpacking
pub use *;
// Newtype wrapper around generic PackedAccounts<AccountMeta> with inherent system account methods
pub use PackedAccounts;