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        carbon_core::try_decode_instructions!(instruction,
50            SystemProgramInstruction::CreateAccount => create_account::CreateAccount,
51            SystemProgramInstruction::Assign => assign::Assign,
52            SystemProgramInstruction::Transfer => transfer::Transfer,
53            SystemProgramInstruction::CreateAccountWithSeed => create_account_with_seed::CreateAccountWithSeed,
54            SystemProgramInstruction::AdvanceNonceAccount => advance_nonce_account::AdvanceNonceAccount,
55            SystemProgramInstruction::WithdrawNonceAccount => withdraw_nonce_account::WithdrawNonceAccount,
56            SystemProgramInstruction::InitializeNonceAccount => initialize_nonce_account::InitializeNonceAccount,
57            SystemProgramInstruction::AuthorizeNonceAccount => authorize_nonce_account::AuthorizeNonceAccount,
58            SystemProgramInstruction::Allocate => allocate::Allocate,
59            SystemProgramInstruction::AllocateWithSeed => allocate_with_seed::AllocateWithSeed,
60            SystemProgramInstruction::AssignWithSeed => assign_with_seed::AssignWithSeed,
61            SystemProgramInstruction::TransferWithSeed => transfer_with_seed::TransferWithSeed,
62            SystemProgramInstruction::UpgradeNonceAccount => upgrade_nonce_account::UpgradeNonceAccount,
63        )
64    }
65}