carbon-stake-program-decoder 1.0.0

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

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

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

pub mod authorize;
pub mod authorize_checked;
pub mod authorize_checked_with_seed;
pub mod authorize_with_seed;
pub mod deactivate;
pub mod deactivate_delinquent;
pub mod delegate_stake;
pub mod get_minimum_delegation;
pub mod initialize;
pub mod initialize_checked;
pub mod merge;
pub mod move_lamports;
pub mod move_stake;
pub mod redelegate;
pub mod set_lockup;
pub mod set_lockup_checked;
pub mod split;
pub mod withdraw;

pub use self::{
    authorize::*, authorize_checked::*, authorize_checked_with_seed::*, authorize_with_seed::*,
    deactivate::*, deactivate_delinquent::*, delegate_stake::*, get_minimum_delegation::*,
    initialize::*, initialize_checked::*, merge::*, move_lamports::*, move_stake::*, redelegate::*,
    set_lockup::*, set_lockup_checked::*, split::*, withdraw::*,
};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum StakeProgramInstruction {
    Authorize {
        program_id: solana_pubkey::Pubkey,
        data: Authorize,
        accounts: AuthorizeInstructionAccounts,
    },
    AuthorizeChecked {
        program_id: solana_pubkey::Pubkey,
        data: AuthorizeChecked,
        accounts: AuthorizeCheckedInstructionAccounts,
    },
    AuthorizeCheckedWithSeed {
        program_id: solana_pubkey::Pubkey,
        data: AuthorizeCheckedWithSeed,
        accounts: AuthorizeCheckedWithSeedInstructionAccounts,
    },
    AuthorizeWithSeed {
        program_id: solana_pubkey::Pubkey,
        data: AuthorizeWithSeed,
        accounts: AuthorizeWithSeedInstructionAccounts,
    },
    Deactivate {
        program_id: solana_pubkey::Pubkey,
        data: Deactivate,
        accounts: DeactivateInstructionAccounts,
    },
    DeactivateDelinquent {
        program_id: solana_pubkey::Pubkey,
        data: DeactivateDelinquent,
        accounts: DeactivateDelinquentInstructionAccounts,
    },
    DelegateStake {
        program_id: solana_pubkey::Pubkey,
        data: DelegateStake,
        accounts: DelegateStakeInstructionAccounts,
    },
    GetMinimumDelegation {
        program_id: solana_pubkey::Pubkey,
        data: GetMinimumDelegation,
        accounts: GetMinimumDelegationInstructionAccounts,
    },
    Initialize {
        program_id: solana_pubkey::Pubkey,
        data: Initialize,
        accounts: InitializeInstructionAccounts,
    },
    InitializeChecked {
        program_id: solana_pubkey::Pubkey,
        data: InitializeChecked,
        accounts: InitializeCheckedInstructionAccounts,
    },
    Merge {
        program_id: solana_pubkey::Pubkey,
        data: Merge,
        accounts: MergeInstructionAccounts,
    },
    MoveLamports {
        program_id: solana_pubkey::Pubkey,
        data: MoveLamports,
        accounts: MoveLamportsInstructionAccounts,
    },
    MoveStake {
        program_id: solana_pubkey::Pubkey,
        data: MoveStake,
        accounts: MoveStakeInstructionAccounts,
    },
    Redelegate {
        program_id: solana_pubkey::Pubkey,
        data: Redelegate,
        accounts: RedelegateInstructionAccounts,
    },
    SetLockup {
        program_id: solana_pubkey::Pubkey,
        data: SetLockup,
        accounts: SetLockupInstructionAccounts,
    },
    SetLockupChecked {
        program_id: solana_pubkey::Pubkey,
        data: SetLockupChecked,
        accounts: SetLockupCheckedInstructionAccounts,
    },
    Split {
        program_id: solana_pubkey::Pubkey,
        data: Split,
        accounts: SplitInstructionAccounts,
    },
    Withdraw {
        program_id: solana_pubkey::Pubkey,
        data: Withdraw,
        accounts: WithdrawInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for StakeProgramDecoder {
    type InstructionType = StakeProgramInstruction;

    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,
            StakeProgramInstruction::Authorize => Authorize,
            StakeProgramInstruction::AuthorizeChecked => AuthorizeChecked,
            StakeProgramInstruction::AuthorizeCheckedWithSeed => AuthorizeCheckedWithSeed,
            StakeProgramInstruction::AuthorizeWithSeed => AuthorizeWithSeed,
            StakeProgramInstruction::Deactivate => Deactivate,
            StakeProgramInstruction::DeactivateDelinquent => DeactivateDelinquent,
            StakeProgramInstruction::DelegateStake => DelegateStake,
            StakeProgramInstruction::GetMinimumDelegation => GetMinimumDelegation,
            StakeProgramInstruction::Initialize => Initialize,
            StakeProgramInstruction::InitializeChecked => InitializeChecked,
            StakeProgramInstruction::Merge => Merge,
            StakeProgramInstruction::MoveLamports => MoveLamports,
            StakeProgramInstruction::MoveStake => MoveStake,
            StakeProgramInstruction::Redelegate => Redelegate,
            StakeProgramInstruction::SetLockup => SetLockup,
            StakeProgramInstruction::SetLockupChecked => SetLockupChecked,
            StakeProgramInstruction::Split => Split,
            StakeProgramInstruction::Withdraw => Withdraw,
        )
    }
}