light_instruction_decoder/programs/
registry.rs

1//! Light Registry program instruction decoder.
2//!
3//! This module provides a macro-derived decoder for the Light Registry program,
4//! which uses 8-byte Anchor discriminators.
5//!
6//! The Registry program manages:
7//! - Protocol configuration
8//! - Forester registration and epochs
9//! - Merkle tree initialization and operations
10//! - Rollover operations
11//! - Compressible config management
12
13// Allow the macro-generated code to reference types from this crate
14extern crate self as light_instruction_decoder;
15
16use light_instruction_decoder_derive::InstructionDecoder;
17
18/// Light Registry program instructions.
19///
20/// The Registry program uses 8-byte Anchor discriminators computed from
21/// sha256("global:<snake_case_instruction_name>").
22#[derive(InstructionDecoder)]
23#[instruction_decoder(
24    program_id = "Lighton6oQpVkeewmo2mcPTQQp7kYHr4fWpAgJyEmDX",
25    program_name = "Light Registry",
26    discriminator_size = 8
27)]
28pub enum RegistryInstruction {
29    // ========================================================================
30    // Protocol Config
31    // ========================================================================
32    /// Initialize the protocol configuration
33    #[instruction_decoder(account_names = ["fee_payer", "authority", "protocol_config_pda", "system_program", "self_program"])]
34    InitializeProtocolConfig { bump: u8 },
35
36    /// Update the protocol configuration
37    #[instruction_decoder(account_names = ["fee_payer", "authority", "protocol_config_pda", "new_authority"])]
38    UpdateProtocolConfig,
39
40    // ========================================================================
41    // Forester Management
42    // ========================================================================
43    /// Register a new forester
44    #[instruction_decoder(account_names = ["fee_payer", "authority", "protocol_config_pda", "forester_pda", "system_program"])]
45    RegisterForester { bump: u8 },
46
47    /// Update a forester PDA
48    #[instruction_decoder(account_names = ["authority", "forester_pda", "new_authority"])]
49    UpdateForesterPda,
50
51    /// Update a forester's weight
52    #[instruction_decoder(account_names = ["authority", "protocol_config_pda", "forester_pda"])]
53    UpdateForesterPdaWeight { new_weight: u64 },
54
55    // ========================================================================
56    // Epoch Management
57    // ========================================================================
58    /// Register a forester for an epoch
59    #[instruction_decoder(account_names = ["fee_payer", "authority", "forester_pda", "forester_epoch_pda", "protocol_config", "epoch_pda", "system_program"])]
60    RegisterForesterEpoch { epoch: u64 },
61
62    /// Finalize forester registration
63    #[instruction_decoder(account_names = ["authority", "forester_epoch_pda", "epoch_pda"])]
64    FinalizeRegistration,
65
66    /// Report work done by forester
67    #[instruction_decoder(account_names = ["authority", "forester_epoch_pda", "epoch_pda"])]
68    ReportWork,
69
70    // ========================================================================
71    // System Program Registration
72    // ========================================================================
73    /// Register a system program
74    #[instruction_decoder(account_names = ["authority", "cpi_authority", "program_to_be_registered", "registered_program_pda", "group_pda", "account_compression_program", "system_program"])]
75    RegisterSystemProgram { bump: u8 },
76
77    /// Deregister a system program
78    #[instruction_decoder(account_names = ["authority", "cpi_authority", "registered_program_pda", "group_pda", "account_compression_program"])]
79    DeregisterSystemProgram { bump: u8 },
80
81    // ========================================================================
82    // Tree Initialization
83    // ========================================================================
84    /// Initialize an address Merkle tree
85    #[instruction_decoder(account_names = ["authority", "merkle_tree", "queue", "registered_program_pda", "cpi_authority", "account_compression_program", "protocol_config_pda", "cpi_context_account", "light_system_program"])]
86    InitializeAddressMerkleTree { bump: u8 },
87
88    /// Initialize a state Merkle tree
89    #[instruction_decoder(account_names = ["authority", "merkle_tree", "queue", "registered_program_pda", "cpi_authority", "account_compression_program", "protocol_config_pda", "cpi_context_account", "light_system_program"])]
90    InitializeStateMerkleTree { bump: u8 },
91
92    /// Initialize a batched state Merkle tree
93    #[instruction_decoder(account_names = ["authority", "merkle_tree", "queue", "registered_program_pda", "cpi_authority", "account_compression_program", "protocol_config_pda", "cpi_context_account", "light_system_program"])]
94    InitializeBatchedStateMerkleTree { bump: u8 },
95
96    /// Initialize a batched address Merkle tree
97    #[instruction_decoder(account_names = ["authority", "merkle_tree", "registered_program_pda", "cpi_authority", "account_compression_program", "protocol_config_pda"])]
98    InitializeBatchedAddressMerkleTree { bump: u8 },
99
100    // ========================================================================
101    // Tree Operations
102    // ========================================================================
103    /// Nullify a leaf in the tree
104    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "log_wrapper", "merkle_tree", "nullifier_queue"])]
105    Nullify { bump: u8 },
106
107    /// Update an address Merkle tree
108    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "log_wrapper", "merkle_tree", "queue"])]
109    UpdateAddressMerkleTree { bump: u8 },
110
111    /// Batch nullify leaves
112    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "log_wrapper", "merkle_tree"])]
113    BatchNullify { bump: u8 },
114
115    /// Batch append to output queue
116    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "log_wrapper", "merkle_tree", "output_queue"])]
117    BatchAppend { bump: u8 },
118
119    /// Batch update an address tree
120    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "log_wrapper", "merkle_tree"])]
121    BatchUpdateAddressTree { bump: u8 },
122
123    // ========================================================================
124    // Rollover Operations
125    // ========================================================================
126    /// Rollover address Merkle tree and queue
127    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "new_merkle_tree", "new_queue", "old_merkle_tree", "old_queue"])]
128    RolloverAddressMerkleTreeAndQueue { bump: u8 },
129
130    /// Rollover state Merkle tree and queue
131    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "new_merkle_tree", "new_queue", "old_merkle_tree", "old_queue", "cpi_context_account", "light_system_program", "protocol_config_pda"])]
132    RolloverStateMerkleTreeAndQueue { bump: u8 },
133
134    /// Rollover batched address Merkle tree
135    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "new_address_merkle_tree", "old_address_merkle_tree"])]
136    RolloverBatchedAddressMerkleTree { bump: u8 },
137
138    /// Rollover batched state Merkle tree
139    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "new_state_merkle_tree", "old_state_merkle_tree", "new_output_queue", "old_output_queue", "cpi_context_account", "registered_program_pda", "cpi_authority", "account_compression_program", "protocol_config_pda", "light_system_program"])]
140    RolloverBatchedStateMerkleTree { bump: u8 },
141
142    // ========================================================================
143    // Migration
144    // ========================================================================
145    /// Migrate state
146    #[instruction_decoder(account_names = ["registered_forester_pda", "authority", "cpi_authority", "registered_program_pda", "account_compression_program", "merkle_tree"])]
147    MigrateState { bump: u8 },
148
149    // ========================================================================
150    // Compressible Config
151    // ========================================================================
152    /// Create a config counter
153    #[instruction_decoder(account_names = ["fee_payer", "authority", "protocol_config_pda", "config_counter", "system_program"])]
154    CreateConfigCounter,
155
156    /// Create a compressible config
157    #[instruction_decoder(account_names = ["fee_payer", "authority", "protocol_config_pda", "config_counter", "compressible_config", "system_program"])]
158    CreateCompressibleConfig,
159
160    /// Update a compressible config
161    #[instruction_decoder(account_names = ["update_authority", "compressible_config", "new_update_authority", "new_withdrawal_authority"])]
162    UpdateCompressibleConfig,
163
164    /// Pause a compressible config (only requires update_authority and compressible_config)
165    #[instruction_decoder(account_names = ["update_authority", "compressible_config"])]
166    PauseCompressibleConfig,
167
168    /// Unpause a compressible config (only requires update_authority and compressible_config)
169    #[instruction_decoder(account_names = ["update_authority", "compressible_config"])]
170    UnpauseCompressibleConfig,
171
172    /// Deprecate a compressible config (only requires update_authority and compressible_config)
173    #[instruction_decoder(account_names = ["update_authority", "compressible_config"])]
174    DeprecateCompressibleConfig,
175
176    // ========================================================================
177    // Token Operations
178    // ========================================================================
179    /// Withdraw from funding pool
180    #[instruction_decoder(account_names = ["fee_payer", "withdrawal_authority", "compressible_config", "rent_sponsor", "compression_authority", "destination", "system_program", "compressed_token_program"])]
181    WithdrawFundingPool { amount: u64 },
182
183    /// Claim compressed tokens
184    #[instruction_decoder(account_names = ["authority", "registered_forester_pda", "rent_sponsor", "compression_authority", "compressible_config", "compressed_token_program"])]
185    Claim,
186
187    /// Compress and close token account
188    #[instruction_decoder(account_names = ["authority", "registered_forester_pda", "compression_authority", "compressible_config"])]
189    CompressAndClose {
190        authority_index: u8,
191        destination_index: u8,
192    },
193}