carbon-sharky-decoder 2.0.0

Sharky Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct CloseEscrowValueMintAtaAdmin {
    pub escrow_bump: u8,
}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CloseEscrowValueMintAtaAdminInstructionAccounts {
    pub loan: solana_pubkey::Pubkey,
    pub lender: solana_pubkey::Pubkey,
    pub escrow: solana_pubkey::Pubkey,
    pub escrow_value_mint_token_account: solana_pubkey::Pubkey,
    pub admin: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub token_program: solana_pubkey::Pubkey,
    pub associated_token_program: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl CloseEscrowValueMintAtaAdmin {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [4, 134, 1, 41, 168, 248, 221, 28] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for CloseEscrowValueMintAtaAdmin {
    type ArrangedAccounts = CloseEscrowValueMintAtaAdminInstructionAccounts;

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

        let loan = next_account(&mut iter)?;
        let lender = next_account(&mut iter)?;
        let escrow = next_account(&mut iter)?;
        let escrow_value_mint_token_account = next_account(&mut iter)?;
        let admin = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;
        let token_program = next_account(&mut iter)?;
        let associated_token_program = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(CloseEscrowValueMintAtaAdminInstructionAccounts {
            loan,
            lender,
            escrow,
            escrow_value_mint_token_account,
            admin,
            system_program,
            token_program,
            associated_token_program,
            remaining: remaining.to_vec(),
        })
    }
}