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 crate::types::TcompEvent;
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 TcompNoop {
    pub event: TcompEvent,
}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct TcompNoopInstructionAccounts {
    pub tcomp_signer: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl TcompNoop {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != &[106, 162, 10, 226, 132, 68, 223, 21] {
            return None;
        }

        let data_slice = data;

        let data_slice = &data_slice[8..];

        Self::deserialize(data_slice)
    }
}

impl ArrangeAccounts for TcompNoop {
    type ArrangedAccounts = TcompNoopInstructionAccounts;

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

        let tcomp_signer = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(TcompNoopInstructionAccounts {
            tcomp_signer,
            remaining: remaining.to_vec(),
        })
    }
}