//! This code was AUTOGENERATED using the Codama library.
use solana_pubkey::Pubkey;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct OperationState {
    /// Bump to identify PDA
    pub bump: u8,
    /// Address of the operation owner
    pub operation_owners: [Pubkey; 10],
    /// The mint address of whitelist to emit reward
    #[cfg_attr(feature = "serde", serde(with = "serde_big_array::BigArray"))]
    pub whitelist_mints: [Pubkey; 100],
}

impl OperationState {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [19, 236, 58, 237, 81, 222, 183, 252] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
    }
}
