carbon-associated-token-account-decoder 1.0.0

Associated Token Account program decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::{AssociatedTokenAccountDecoder, PROGRAM_ID};

#[cfg(feature = "postgres")]
pub mod postgres;

#[cfg(feature = "graphql")]
pub mod graphql;

pub mod create;
pub mod create_idempotent;
pub mod recover_nested;

pub use self::{create::*, create_idempotent::*, recover_nested::*};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum AssociatedTokenAccountInstruction {
    Create {
        program_id: solana_pubkey::Pubkey,
        data: Create,
        accounts: CreateInstructionAccounts,
    },
    CreateIdempotent {
        program_id: solana_pubkey::Pubkey,
        data: CreateIdempotent,
        accounts: CreateIdempotentInstructionAccounts,
    },
    RecoverNested {
        program_id: solana_pubkey::Pubkey,
        data: RecoverNested,
        accounts: RecoverNestedInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for AssociatedTokenAccountDecoder {
    type InstructionType = AssociatedTokenAccountInstruction;

    fn decode_instruction(
        &self,
        instruction: &solana_instruction::Instruction,
    ) -> Option<Self::InstructionType> {
        if instruction.program_id != PROGRAM_ID {
            return None;
        }

        carbon_core::try_decode_instructions!(
            instruction,
            PROGRAM_ID,
            AssociatedTokenAccountInstruction::Create => Create,
            AssociatedTokenAccountInstruction::CreateIdempotent => CreateIdempotent,
            AssociatedTokenAccountInstruction::RecoverNested => RecoverNested,
        )
    }
}