carbon_name_service_decoder/instructions/
mod.rs1use crate::PROGRAM_ID;
2
3use super::NameDecoder;
4pub mod create;
5pub mod delete;
6pub mod realloc;
7pub mod transfer;
8pub mod update;
9
10#[derive(
11 carbon_core::InstructionType,
12 serde::Serialize,
13 serde::Deserialize,
14 PartialEq,
15 Eq,
16 Debug,
17 Clone,
18 Hash,
19)]
20pub enum NameInstruction {
21 Create(create::Create),
22 Update(update::Update),
23 Transfer(transfer::Transfer),
24 Delete(delete::Delete),
25 Realloc(realloc::Realloc),
26}
27
28impl carbon_core::instruction::InstructionDecoder<'_> for NameDecoder {
29 type InstructionType = NameInstruction;
30
31 fn decode_instruction(
32 &self,
33 instruction: &solana_instruction::Instruction,
34 ) -> Option<carbon_core::instruction::DecodedInstruction<Self::InstructionType>> {
35 if !instruction.program_id.eq(&PROGRAM_ID) {
36 return None;
37 }
38
39 carbon_core::try_decode_instructions!(instruction,
40 NameInstruction::Create => create::Create,
41 NameInstruction::Update => update::Update,
42 NameInstruction::Transfer => transfer::Transfer,
43 NameInstruction::Delete => delete::Delete,
44 NameInstruction::Realloc => realloc::Realloc,
45 )
46 }
47}