carbon_tcomp_decoder/instructions/
edit.rs

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