carbon_token_2022_decoder/instructions/
initialize_transfer_fee_config.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 transfer fee 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
19/// bytes), 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 InitializeTransferFeeConfig {
24    pub transfer_fee_discriminator: u8,
25    /// Pubkey that may update the fees.
26    pub transfer_fee_config_authority: Option<Pubkey>,
27    /// Withdraw instructions must be signed by this key.
28    pub withdraw_withheld_authority: Option<Pubkey>,
29    /// Amount of transfer collected as fees, expressed as basis points of the transfer amount.
30    pub transfer_fee_basis_points: u16,
31    /// Maximum fee assessed on transfers.
32    pub maximum_fee: u64,
33}
34
35#[derive(Debug, Clone, PartialEq)]
36#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
37pub struct InitializeTransferFeeConfigInstructionAccounts {
38    pub mint: solana_pubkey::Pubkey,
39    pub remaining: Vec<solana_instruction::AccountMeta>,
40}
41
42impl InitializeTransferFeeConfig {
43    pub fn decode(data: &[u8]) -> Option<Self> {
44        if data.len() < 2 {
45            return None;
46        }
47        let discriminator = &data[0..1];
48        if discriminator != [26] {
49            return None;
50        }
51        let transfer_fee_discriminator = data[1];
52        if transfer_fee_discriminator != 0 {
53            return None;
54        }
55
56        let data_slice = data;
57
58        let data_slice = &data_slice[1..];
59
60        Self::deserialize(data_slice)
61    }
62}
63
64impl ArrangeAccounts for InitializeTransferFeeConfig {
65    type ArrangedAccounts = InitializeTransferFeeConfigInstructionAccounts;
66
67    fn arrange_accounts(
68        accounts: &[solana_instruction::AccountMeta],
69    ) -> Option<Self::ArrangedAccounts> {
70        let mut iter = accounts.iter();
71
72        let mint = next_account(&mut iter)?;
73
74        let remaining = iter.as_slice();
75
76        Some(InitializeTransferFeeConfigInstructionAccounts {
77            mint,
78            remaining: remaining.to_vec(),
79        })
80    }
81}