carbon_memo_program_decoder/instructions/
mod.rs

1use {crate::MemoProgramDecoder, carbon_core::instruction::DecodedInstruction};
2
3#[derive(
4    carbon_core::InstructionType,
5    serde::Serialize,
6    serde::Deserialize,
7    PartialEq,
8    Eq,
9    Debug,
10    Clone,
11    Hash,
12)]
13pub enum MemoProgramInstruction {
14    Memo(Vec<u8>),
15}
16
17impl carbon_core::instruction::InstructionDecoder<'_> for MemoProgramDecoder {
18    type InstructionType = MemoProgramInstruction;
19
20    fn decode_instruction(
21        &self,
22        instruction: &solana_sdk::instruction::Instruction,
23    ) -> Option<DecodedInstruction<Self::InstructionType>> {
24        if !instruction.program_id.eq(&spl_memo::ID) {
25            return None;
26        }
27
28        Some(DecodedInstruction {
29            data: MemoProgramInstruction::Memo(instruction.data.clone()),
30            program_id: instruction.program_id,
31            accounts: instruction.accounts.clone(),
32        })
33    }
34}