carbon_token_2022_decoder/instructions/
remove_token_metadata_key.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;
12
13/// Removes a key-value pair in a token-metadata account.
14///
15/// This only applies to additional fields, and not the base name / symbol /
16/// URI fields.
17///
18/// By the end of the instruction, the metadata account must be properly
19/// resized at the end based on the new size of the TLV entry.
20#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
21#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq)]
22pub struct RemoveTokenMetadataKey {
23    /// If the idempotent flag is set to true, then the instruction will not
24    /// error if the key does not exist
25    pub idempotent: bool,
26    /// Key to remove in the additional metadata portion.
27    pub key: String,
28}
29
30#[derive(Debug, Clone, PartialEq)]
31#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
32pub struct RemoveTokenMetadataKeyInstructionAccounts {
33    pub metadata: solana_pubkey::Pubkey,
34    pub update_authority: solana_pubkey::Pubkey,
35    pub remaining: Vec<solana_instruction::AccountMeta>,
36}
37
38impl RemoveTokenMetadataKey {
39    pub fn decode(data: &[u8]) -> Option<Self> {
40        if data.len() < 8 {
41            return None;
42        }
43        let discriminator = &data[0..8];
44        if discriminator != [234, 18, 32, 56, 89, 141, 37, 181] {
45            return None;
46        }
47
48        let data_slice = data;
49
50        let data_slice = &data_slice[8..];
51
52        Self::deserialize(data_slice)
53    }
54}
55
56impl ArrangeAccounts for RemoveTokenMetadataKey {
57    type ArrangedAccounts = RemoveTokenMetadataKeyInstructionAccounts;
58
59    fn arrange_accounts(
60        accounts: &[solana_instruction::AccountMeta],
61    ) -> Option<Self::ArrangedAccounts> {
62        let mut iter = accounts.iter();
63
64        let metadata = next_account(&mut iter)?;
65        let update_authority = next_account(&mut iter)?;
66
67        let remaining = iter.as_slice();
68
69        Some(RemoveTokenMetadataKeyInstructionAccounts {
70            metadata,
71            update_authority,
72            remaining: remaining.to_vec(),
73        })
74    }
75}