carbon_points_decoder/instructions/
create_point_category.rs1use crate::types::CreatePointCategoryInput;
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 CreatePointCategory {
12 pub input: CreatePointCategoryInput,
13}
14
15#[derive(Debug, Clone, PartialEq)]
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17pub struct CreatePointCategoryInstructionAccounts {
18 pub profile: solana_pubkey::Pubkey,
19 pub funder: solana_pubkey::Pubkey,
20 pub category: solana_pubkey::Pubkey,
21 pub system_program: solana_pubkey::Pubkey,
22 pub remaining: Vec<solana_instruction::AccountMeta>,
23}
24
25impl CreatePointCategory {
26 pub fn decode(data: &[u8]) -> Option<Self> {
27 if data.len() < 8 {
28 return None;
29 }
30 let discriminator = &data[0..8];
31 if discriminator != &[160, 233, 223, 48, 62, 107, 71, 176] {
32 return None;
33 }
34
35 let data_slice = data;
36
37 let data_slice = &data_slice[8..];
38
39 Self::deserialize(data_slice)
40 }
41}
42
43impl ArrangeAccounts for CreatePointCategory {
44 type ArrangedAccounts = CreatePointCategoryInstructionAccounts;
45
46 fn arrange_accounts(
47 accounts: &[solana_instruction::AccountMeta],
48 ) -> Option<Self::ArrangedAccounts> {
49 let mut iter = accounts.iter();
50
51 let profile = next_account(&mut iter)?;
52 let funder = next_account(&mut iter)?;
53 let category = next_account(&mut iter)?;
54 let system_program = next_account(&mut iter)?;
55
56 let remaining = iter.as_slice();
57
58 Some(CreatePointCategoryInstructionAccounts {
59 profile,
60 funder,
61 category,
62 system_program,
63 remaining: remaining.to_vec(),
64 })
65 }
66}