Expand description
Utilities to build instructions for programs with compressed accounts.
§Overview
This module provides types and utilities for building Solana instructions that work with compressed accounts. The main workflow involves:
|- 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- Indices of address tree and queue accounts.PackedStateTreeInfo- Indices of state tree and queue accounts.PackedAccounts- Packs accounts and creates indices for instruction building (client-side).SystemAccountMetaConfig- Configures which Light system program accounts to add toPackedAccounts.ValidityProof- Proves that new addresses don’t exist yet, and compressed account state exists.CompressedAccountMeta- Metadata for compressed accounts.
§Compressed Account Metas
Instruction data types to pass compressed account metadata into instructions.
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, 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-
Packedstructs: Contain pubkeys (Pubkey) for use in the client, and are returned by RPC methods. PackedAccounts: Manages account deduplication and index assignment to createPacked*structs.
Modules§
Structs§
- Address
Tree Info - Compressed
Proof - Merkle
Context - Packed
Accounts - Packs accounts and creates indices for instruction building (client-side).
- Packed
Address Tree Info - Packed address tree info for instruction data. Contains indices to address tree accounts and root index.
- Packed
Merkle Context - Packed
State Tree Info - System
Account Meta Config - Configuration for Light system program accounts when building instructions.
- System
Account Pubkeys - Validity
Proof
Traits§
- Account
Metas Vec - Packed
Address Tree Info Ext - Extension trait for PackedAddressTreeInfo SDK-specific methods. Since PackedAddressTreeInfo is defined in light-compressed-account, we use an extension trait to add methods that depend on SDK types.
Functions§
- get_
light_ system_ account_ metas - InvokeSystemCpi v1.
- get_
light_ system_ account_ metas_ v2 - Can be used in client to add system account metas.
- pack_
address_ tree_ info - Returns a
PackedAddressTreeInfoand fills upremaining_accountsbased on the givenmerkle_context. Packs Merkle tree account first. Packs queue account second. - pack_
address_ tree_ infos - Returns an iterator of
PackedAddressTreeInfoand fills upremaining_accountsbased on the givenmerkle_contexts. - pack_
merkle_ context Deprecated - pack_
merkle_ contexts Deprecated - unpack_
address_ tree_ info - unpack_
address_ tree_ infos