carbon-system-program-decoder 1.0.0

System Program Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::{SystemProgramDecoder, PROGRAM_ID};

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

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

pub mod advance_nonce_account;
pub mod allocate;
pub mod allocate_with_seed;
pub mod assign;
pub mod assign_with_seed;
pub mod authorize_nonce_account;
pub mod create_account;
pub mod create_account_with_seed;
pub mod initialize_nonce_account;
pub mod transfer_sol;
pub mod transfer_sol_with_seed;
pub mod upgrade_nonce_account;
pub mod withdraw_nonce_account;

pub use self::{
    advance_nonce_account::*, allocate::*, allocate_with_seed::*, assign::*, assign_with_seed::*,
    authorize_nonce_account::*, create_account::*, create_account_with_seed::*,
    initialize_nonce_account::*, transfer_sol::*, transfer_sol_with_seed::*,
    upgrade_nonce_account::*, withdraw_nonce_account::*,
};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum SystemProgramInstruction {
    AdvanceNonceAccount {
        program_id: solana_pubkey::Pubkey,
        data: AdvanceNonceAccount,
        accounts: AdvanceNonceAccountInstructionAccounts,
    },
    Allocate {
        program_id: solana_pubkey::Pubkey,
        data: Allocate,
        accounts: AllocateInstructionAccounts,
    },
    AllocateWithSeed {
        program_id: solana_pubkey::Pubkey,
        data: AllocateWithSeed,
        accounts: AllocateWithSeedInstructionAccounts,
    },
    Assign {
        program_id: solana_pubkey::Pubkey,
        data: Assign,
        accounts: AssignInstructionAccounts,
    },
    AssignWithSeed {
        program_id: solana_pubkey::Pubkey,
        data: AssignWithSeed,
        accounts: AssignWithSeedInstructionAccounts,
    },
    AuthorizeNonceAccount {
        program_id: solana_pubkey::Pubkey,
        data: AuthorizeNonceAccount,
        accounts: AuthorizeNonceAccountInstructionAccounts,
    },
    CreateAccount {
        program_id: solana_pubkey::Pubkey,
        data: CreateAccount,
        accounts: CreateAccountInstructionAccounts,
    },
    CreateAccountWithSeed {
        program_id: solana_pubkey::Pubkey,
        data: CreateAccountWithSeed,
        accounts: CreateAccountWithSeedInstructionAccounts,
    },
    InitializeNonceAccount {
        program_id: solana_pubkey::Pubkey,
        data: InitializeNonceAccount,
        accounts: InitializeNonceAccountInstructionAccounts,
    },
    TransferSol {
        program_id: solana_pubkey::Pubkey,
        data: TransferSol,
        accounts: TransferSolInstructionAccounts,
    },
    TransferSolWithSeed {
        program_id: solana_pubkey::Pubkey,
        data: TransferSolWithSeed,
        accounts: TransferSolWithSeedInstructionAccounts,
    },
    UpgradeNonceAccount {
        program_id: solana_pubkey::Pubkey,
        data: UpgradeNonceAccount,
        accounts: UpgradeNonceAccountInstructionAccounts,
    },
    WithdrawNonceAccount {
        program_id: solana_pubkey::Pubkey,
        data: WithdrawNonceAccount,
        accounts: WithdrawNonceAccountInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for SystemProgramDecoder {
    type InstructionType = SystemProgramInstruction;

    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,
            SystemProgramInstruction::AdvanceNonceAccount => AdvanceNonceAccount,
            SystemProgramInstruction::Allocate => Allocate,
            SystemProgramInstruction::AllocateWithSeed => AllocateWithSeed,
            SystemProgramInstruction::Assign => Assign,
            SystemProgramInstruction::AssignWithSeed => AssignWithSeed,
            SystemProgramInstruction::AuthorizeNonceAccount => AuthorizeNonceAccount,
            SystemProgramInstruction::CreateAccount => CreateAccount,
            SystemProgramInstruction::CreateAccountWithSeed => CreateAccountWithSeed,
            SystemProgramInstruction::InitializeNonceAccount => InitializeNonceAccount,
            SystemProgramInstruction::TransferSol => TransferSol,
            SystemProgramInstruction::TransferSolWithSeed => TransferSolWithSeed,
            SystemProgramInstruction::UpgradeNonceAccount => UpgradeNonceAccount,
            SystemProgramInstruction::WithdrawNonceAccount => WithdrawNonceAccount,
        )
    }
}