carbon_token_2022_decoder/instructions/
initialize_permanent_delegate.rs

1//! This code was AUTOGENERATED using the Codama library.
2//! Please DO NOT EDIT THIS FILE, instead use visitors
3//! to add features, then rerun Codama to update it.
4//!
5//! <https://github.com/codama-idl/codama>
6//!
7use carbon_core::account_utils::next_account;
8use carbon_core::borsh;
9use carbon_core::deserialize::ArrangeAccounts;
10use carbon_core::deserialize::CarbonDeserialize;
11use carbon_core::CarbonDeserialize;
12use solana_pubkey::Pubkey;
13
14/// Initialize the permanent delegate on a new mint.
15///
16/// Fails if the mint has already been initialized, so must be called before `InitializeMint`.
17///
18/// The mint must have exactly enough space allocated for the base mint (82 bytes),
19/// plus 83 bytes of padding, 1 byte reserved for the account type,
20/// then space required for this extension, plus any others.
21#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
22#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
23pub struct InitializePermanentDelegate {
24    /// Authority that may sign for `Transfer`s and `Burn`s on any account
25    pub delegate: Pubkey,
26}
27
28#[derive(Debug, Clone, PartialEq)]
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30pub struct InitializePermanentDelegateInstructionAccounts {
31    pub mint: solana_pubkey::Pubkey,
32    pub remaining: Vec<solana_instruction::AccountMeta>,
33}
34
35impl InitializePermanentDelegate {
36    pub fn decode(data: &[u8]) -> Option<Self> {
37        if data.is_empty() {
38            return None;
39        }
40        let discriminator = &data[0..1];
41        if discriminator != [35] {
42            return None;
43        }
44
45        let data_slice = data;
46
47        let data_slice = &data_slice[1..];
48
49        Self::deserialize(data_slice)
50    }
51}
52
53impl ArrangeAccounts for InitializePermanentDelegate {
54    type ArrangedAccounts = InitializePermanentDelegateInstructionAccounts;
55
56    fn arrange_accounts(
57        accounts: &[solana_instruction::AccountMeta],
58    ) -> Option<Self::ArrangedAccounts> {
59        let mut iter = accounts.iter();
60
61        let mint = next_account(&mut iter)?;
62
63        let remaining = iter.as_slice();
64
65        Some(InitializePermanentDelegateInstructionAccounts {
66            mint,
67            remaining: remaining.to_vec(),
68        })
69    }
70}