carbon_system_program_decoder/instructions/
mod.rs

1use crate::SystemProgramDecoder;
2pub mod advance_nonce_account;
3pub mod allocate;
4pub mod allocate_with_seed;
5pub mod assign;
6pub mod assign_with_seed;
7pub mod authorize_nonce_account;
8pub mod create_account;
9pub mod create_account_with_seed;
10pub mod initialize_nonce_account;
11pub mod transfer;
12pub mod transfer_with_seed;
13pub mod upgrade_nonce_account;
14pub mod withdraw_nonce_account;
15
16#[derive(
17    carbon_core::InstructionType,
18    serde::Serialize,
19    serde::Deserialize,
20    PartialEq,
21    Eq,
22    Debug,
23    Clone,
24    Hash,
25)]
26pub enum SystemProgramInstruction {
27    CreateAccount(create_account::CreateAccount),
28    Assign(assign::Assign),
29    Transfer(transfer::Transfer),
30    CreateAccountWithSeed(create_account_with_seed::CreateAccountWithSeed),
31    AdvanceNonceAccount(advance_nonce_account::AdvanceNonceAccount),
32    WithdrawNonceAccount(withdraw_nonce_account::WithdrawNonceAccount),
33    InitializeNonceAccount(initialize_nonce_account::InitializeNonceAccount),
34    AuthorizeNonceAccount(authorize_nonce_account::AuthorizeNonceAccount),
35    Allocate(allocate::Allocate),
36    AllocateWithSeed(allocate_with_seed::AllocateWithSeed),
37    AssignWithSeed(assign_with_seed::AssignWithSeed),
38    TransferWithSeed(transfer_with_seed::TransferWithSeed),
39    UpgradeNonceAccount(upgrade_nonce_account::UpgradeNonceAccount),
40}
41
42impl carbon_core::instruction::InstructionDecoder<'_> for SystemProgramDecoder {
43    type InstructionType = SystemProgramInstruction;
44
45    fn decode_instruction(
46        &self,
47        instruction: &solana_sdk::instruction::Instruction,
48    ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
49        if !instruction.program_id.eq(&solana_sdk::system_program::id()) {
50            return None;
51        }
52
53        carbon_core::try_decode_instructions!(instruction,
54            SystemProgramInstruction::CreateAccount => create_account::CreateAccount,
55            SystemProgramInstruction::Assign => assign::Assign,
56            SystemProgramInstruction::Transfer => transfer::Transfer,
57            SystemProgramInstruction::CreateAccountWithSeed => create_account_with_seed::CreateAccountWithSeed,
58            SystemProgramInstruction::AdvanceNonceAccount => advance_nonce_account::AdvanceNonceAccount,
59            SystemProgramInstruction::WithdrawNonceAccount => withdraw_nonce_account::WithdrawNonceAccount,
60            SystemProgramInstruction::InitializeNonceAccount => initialize_nonce_account::InitializeNonceAccount,
61            SystemProgramInstruction::AuthorizeNonceAccount => authorize_nonce_account::AuthorizeNonceAccount,
62            SystemProgramInstruction::Allocate => allocate::Allocate,
63            SystemProgramInstruction::AllocateWithSeed => allocate_with_seed::AllocateWithSeed,
64            SystemProgramInstruction::AssignWithSeed => assign_with_seed::AssignWithSeed,
65            SystemProgramInstruction::TransferWithSeed => transfer_with_seed::TransferWithSeed,
66            SystemProgramInstruction::UpgradeNonceAccount => upgrade_nonce_account::UpgradeNonceAccount,
67        )
68    }
69}