Skip to main content

carbon_token_program_decoder/instructions/
initialize_immutable_owner.rs

1//! This code was AUTOGENERATED using the Codama library.
2use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3/// Initialize the Immutable Owner extension for the given token account
4/// Fails if the account has already been initialized, so must be called
5/// before `InitializeAccount`.
6/// No-ops in this version of the program, but is included for compatibility
7/// with the Associated Token Account program.
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
10pub struct InitializeImmutableOwner {}
11
12#[derive(Debug, Clone, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14pub struct InitializeImmutableOwnerInstructionAccounts {
15    pub account: solana_pubkey::Pubkey,
16    pub remaining: Vec<solana_instruction::AccountMeta>,
17}
18
19impl InitializeImmutableOwner {
20    pub fn decode(data: &[u8]) -> Option<Self> {
21        if data.is_empty() {
22            return None;
23        }
24        let discriminator = &data[0..1];
25        if discriminator != [22] {
26            return None;
27        }
28
29        let mut data_slice = data;
30
31        data_slice = &data_slice[1..];
32
33        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
34    }
35}
36
37impl ArrangeAccounts for InitializeImmutableOwner {
38    type ArrangedAccounts = InitializeImmutableOwnerInstructionAccounts;
39
40    fn arrange_accounts(
41        accounts: &[solana_instruction::AccountMeta],
42    ) -> Option<Self::ArrangedAccounts> {
43        let mut iter = accounts.iter();
44
45        let account = next_account(&mut iter)?;
46
47        let remaining = iter.as_slice();
48
49        Some(InitializeImmutableOwnerInstructionAccounts {
50            account,
51            remaining: remaining.to_vec(),
52        })
53    }
54}