carbon_points_decoder/instructions/
decrement_level.rs

1//! This code was AUTOGENERATED using the Codama library.
2use crate::types::DecrementLevelInput;
3use carbon_core::CarbonDeserialize;
4use carbon_core::account_utils::next_account;
5use carbon_core::borsh;
6use carbon_core::deserialize::ArrangeAccounts;
7use carbon_core::deserialize::CarbonDeserialize;
8
9#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
10#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq, Eq, Hash)]
11pub struct DecrementLevel {
12    pub input: DecrementLevelInput,
13}
14
15#[derive(Debug, Clone, PartialEq)]
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17pub struct DecrementLevelInstructionAccounts {
18    pub category: solana_pubkey::Pubkey,
19    pub user_points_account: solana_pubkey::Pubkey,
20    pub points_modifier_account: solana_pubkey::Pubkey,
21    pub remaining: Vec<solana_instruction::AccountMeta>,
22}
23
24impl DecrementLevel {
25    pub fn decode(data: &[u8]) -> Option<Self> {
26        if data.len() < 8 {
27            return None;
28        }
29        let discriminator = &data[0..8];
30        if discriminator != &[128, 240, 93, 203, 228, 14, 101, 154] {
31            return None;
32        }
33
34        let data_slice = data;
35
36        let data_slice = &data_slice[8..];
37
38        Self::deserialize(data_slice)
39    }
40}
41
42impl ArrangeAccounts for DecrementLevel {
43    type ArrangedAccounts = DecrementLevelInstructionAccounts;
44
45    fn arrange_accounts(
46        accounts: &[solana_instruction::AccountMeta],
47    ) -> Option<Self::ArrangedAccounts> {
48        let mut iter = accounts.iter();
49
50        let category = next_account(&mut iter)?;
51        let user_points_account = next_account(&mut iter)?;
52        let points_modifier_account = next_account(&mut iter)?;
53
54        let remaining = iter.as_slice();
55
56        Some(DecrementLevelInstructionAccounts {
57            category,
58            user_points_account,
59            points_modifier_account,
60            remaining: remaining.to_vec(),
61        })
62    }
63}