instruction_decoder

Attribute Macro instruction_decoder 

Source
#[instruction_decoder]
Expand description

Attribute macro for generating InstructionDecoder from Anchor program modules.

This macro extracts function names from the program module and generates an InstructionDecoder implementation automatically.

§Usage

use light_instruction_decoder_derive::instruction_decoder;

#[instruction_decoder]
#[program]
pub mod my_program {
    pub fn create_record(ctx: Context<CreateRecord>) -> Result<()> { ... }
    pub fn update_record(ctx: Context<UpdateRecord>) -> Result<()> { ... }
}

This generates a MyProgramInstructionDecoder struct that implements InstructionDecoder. The program_id can also be omitted if declare_id! is used inside the module.