carbon_stake_program_decoder/instructions/
mod.rs

1use crate::PROGRAM_ID;
2
3use super::StakeProgramDecoder;
4pub mod authorize;
5pub mod authorize_checked;
6pub mod authorize_checked_with_seed;
7pub mod authorize_with_seed;
8pub mod deactivate;
9pub mod deactivate_delinquent;
10pub mod delegate_stake;
11pub mod get_minimum_delegation;
12pub mod initialize;
13pub mod initialize_checked;
14pub mod merge;
15pub mod set_lockup;
16pub mod set_lockup_checked;
17pub mod split;
18pub mod withdraw;
19
20#[derive(
21    carbon_core::InstructionType,
22    serde::Serialize,
23    serde::Deserialize,
24    PartialEq,
25    Eq,
26    Debug,
27    Clone,
28    Hash,
29)]
30pub enum StakeProgramInstruction {
31    Initialize(initialize::Initialize),
32    Authorize(authorize::Authorize),
33    DelegateStake(delegate_stake::DelegateStake),
34    Split(split::Split),
35    Withdraw(withdraw::Withdraw),
36    Deactivate(deactivate::Deactivate),
37    SetLockup(set_lockup::SetLockup),
38    Merge(merge::Merge),
39    AuthorizeWithSeed(authorize_with_seed::AuthorizeWithSeed),
40    InitializeChecked(initialize_checked::InitializeChecked),
41    AuthorizeChecked(authorize_checked::AuthorizeChecked),
42    AuthorizeCheckedWithSeed(authorize_checked_with_seed::AuthorizeCheckedWithSeed),
43    SetLockupChecked(set_lockup_checked::SetLockupChecked),
44    GetMinimumDelegation(get_minimum_delegation::GetMinimumDelegation),
45    DeactivateDelinquent(deactivate_delinquent::DeactivateDelinquent),
46}
47
48impl carbon_core::instruction::InstructionDecoder<'_> for StakeProgramDecoder {
49    type InstructionType = StakeProgramInstruction;
50
51    fn decode_instruction(
52        &self,
53        instruction: &solana_instruction::Instruction,
54    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
55        if !instruction.program_id.eq(&PROGRAM_ID) {
56            return None;
57        }
58
59        carbon_core::try_decode_instructions!(instruction,
60            StakeProgramInstruction::Initialize => initialize::Initialize,
61            StakeProgramInstruction::Authorize => authorize::Authorize,
62            StakeProgramInstruction::DelegateStake => delegate_stake::DelegateStake,
63            StakeProgramInstruction::Split => split::Split,
64            StakeProgramInstruction::Withdraw => withdraw::Withdraw,
65            StakeProgramInstruction::Deactivate => deactivate::Deactivate,
66            StakeProgramInstruction::SetLockup => set_lockup::SetLockup,
67            StakeProgramInstruction::Merge => merge::Merge,
68            StakeProgramInstruction::AuthorizeWithSeed => authorize_with_seed::AuthorizeWithSeed,
69            StakeProgramInstruction::InitializeChecked => initialize_checked::InitializeChecked,
70            StakeProgramInstruction::AuthorizeChecked => authorize_checked::AuthorizeChecked,
71            StakeProgramInstruction::AuthorizeCheckedWithSeed => authorize_checked_with_seed::AuthorizeCheckedWithSeed,
72            StakeProgramInstruction::SetLockupChecked => set_lockup_checked::SetLockupChecked,
73            StakeProgramInstruction::GetMinimumDelegation => get_minimum_delegation::GetMinimumDelegation,
74            StakeProgramInstruction::DeactivateDelinquent => deactivate_delinquent::DeactivateDelinquent,
75        )
76    }
77}