carbon-bubblegum-decoder 2.0.0

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

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

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

pub mod burn;
pub mod cancel_redeem;
pub mod create_tree;
pub mod decompress_v1;
pub mod delegate;
pub mod mint_to_collection_v1;
pub mod mint_v1;
pub mod redeem;
pub mod set_and_verify_collection;
pub mod set_decompressible_state;
pub mod set_tree_delegate;
pub mod transfer;
pub mod unverify_collection;
pub mod unverify_creator;
pub mod update_metadata;
pub mod verify_collection;
pub mod verify_creator;

pub use self::{
    burn::*, cancel_redeem::*, create_tree::*, decompress_v1::*, delegate::*,
    mint_to_collection_v1::*, mint_v1::*, redeem::*, set_and_verify_collection::*,
    set_decompressible_state::*, set_tree_delegate::*, transfer::*, unverify_collection::*,
    unverify_creator::*, update_metadata::*, verify_collection::*, verify_creator::*,
};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum BubblegumInstruction {
    Burn {
        program_id: solana_pubkey::Pubkey,
        data: Burn,
        accounts: BurnInstructionAccounts,
    },
    CancelRedeem {
        program_id: solana_pubkey::Pubkey,
        data: CancelRedeem,
        accounts: CancelRedeemInstructionAccounts,
    },
    CreateTree {
        program_id: solana_pubkey::Pubkey,
        data: CreateTree,
        accounts: CreateTreeInstructionAccounts,
    },
    DecompressV1 {
        program_id: solana_pubkey::Pubkey,
        data: DecompressV1,
        accounts: DecompressV1InstructionAccounts,
    },
    Delegate {
        program_id: solana_pubkey::Pubkey,
        data: Delegate,
        accounts: DelegateInstructionAccounts,
    },
    MintToCollectionV1 {
        program_id: solana_pubkey::Pubkey,
        data: MintToCollectionV1,
        accounts: MintToCollectionV1InstructionAccounts,
    },
    MintV1 {
        program_id: solana_pubkey::Pubkey,
        data: MintV1,
        accounts: MintV1InstructionAccounts,
    },
    Redeem {
        program_id: solana_pubkey::Pubkey,
        data: Redeem,
        accounts: RedeemInstructionAccounts,
    },
    SetAndVerifyCollection {
        program_id: solana_pubkey::Pubkey,
        data: SetAndVerifyCollection,
        accounts: SetAndVerifyCollectionInstructionAccounts,
    },
    SetDecompressibleState {
        program_id: solana_pubkey::Pubkey,
        data: SetDecompressibleState,
        accounts: SetDecompressibleStateInstructionAccounts,
    },
    SetTreeDelegate {
        program_id: solana_pubkey::Pubkey,
        data: SetTreeDelegate,
        accounts: SetTreeDelegateInstructionAccounts,
    },
    Transfer {
        program_id: solana_pubkey::Pubkey,
        data: Transfer,
        accounts: TransferInstructionAccounts,
    },
    UnverifyCollection {
        program_id: solana_pubkey::Pubkey,
        data: UnverifyCollection,
        accounts: UnverifyCollectionInstructionAccounts,
    },
    UnverifyCreator {
        program_id: solana_pubkey::Pubkey,
        data: UnverifyCreator,
        accounts: UnverifyCreatorInstructionAccounts,
    },
    UpdateMetadata {
        program_id: solana_pubkey::Pubkey,
        data: UpdateMetadata,
        accounts: UpdateMetadataInstructionAccounts,
    },
    VerifyCollection {
        program_id: solana_pubkey::Pubkey,
        data: VerifyCollection,
        accounts: VerifyCollectionInstructionAccounts,
    },
    VerifyCreator {
        program_id: solana_pubkey::Pubkey,
        data: VerifyCreator,
        accounts: VerifyCreatorInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for BubblegumDecoder {
    type InstructionType = BubblegumInstruction;

    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,
            BubblegumInstruction::Burn => Burn,
            BubblegumInstruction::CancelRedeem => CancelRedeem,
            BubblegumInstruction::CreateTree => CreateTree,
            BubblegumInstruction::DecompressV1 => DecompressV1,
            BubblegumInstruction::Delegate => Delegate,
            BubblegumInstruction::MintToCollectionV1 => MintToCollectionV1,
            BubblegumInstruction::MintV1 => MintV1,
            BubblegumInstruction::Redeem => Redeem,
            BubblegumInstruction::SetAndVerifyCollection => SetAndVerifyCollection,
            BubblegumInstruction::SetDecompressibleState => SetDecompressibleState,
            BubblegumInstruction::SetTreeDelegate => SetTreeDelegate,
            BubblegumInstruction::Transfer => Transfer,
            BubblegumInstruction::UnverifyCollection => UnverifyCollection,
            BubblegumInstruction::UnverifyCreator => UnverifyCreator,
            BubblegumInstruction::UpdateMetadata => UpdateMetadata,
            BubblegumInstruction::VerifyCollection => VerifyCollection,
            BubblegumInstruction::VerifyCreator => VerifyCreator,
        )
    }
}