carbon-tcomp-decoder 0.12.1

Rust decoder for Tensor cNFT Compressed program on Solana
Documentation
//! This code was AUTOGENERATED using the Codama library.
use carbon_core::CarbonDeserialize;
use carbon_core::account_utils::next_account;
use carbon_core::borsh;
use carbon_core::deserialize::ArrangeAccounts;
use carbon_core::deserialize::CarbonDeserialize;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq, Eq, Hash)]
pub struct CloseExpiredBid {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CloseExpiredBidInstructionAccounts {
    pub bid_state: solana_pubkey::Pubkey,
    pub owner: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub tcomp_program: solana_pubkey::Pubkey,
    pub rent_dest: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl CloseExpiredBid {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != &[83, 20, 105, 67, 248, 68, 104, 190] {
            return None;
        }

        let data_slice = data;

        let data_slice = &data_slice[8..];

        Self::deserialize(data_slice)
    }
}

impl ArrangeAccounts for CloseExpiredBid {
    type ArrangedAccounts = CloseExpiredBidInstructionAccounts;

    fn arrange_accounts(
        accounts: &[solana_instruction::AccountMeta],
    ) -> Option<Self::ArrangedAccounts> {
        let mut iter = accounts.iter();

        let bid_state = next_account(&mut iter)?;
        let owner = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;
        let tcomp_program = next_account(&mut iter)?;
        let rent_dest = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(CloseExpiredBidInstructionAccounts {
            bid_state,
            owner,
            system_program,
            tcomp_program,
            rent_dest,
            remaining: remaining.to_vec(),
        })
    }
}