carbon_boop_decoder/instructions/
create_token.rs1use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
5pub struct CreateToken {
6 pub salt: u64,
7 pub name: String,
8 pub symbol: String,
9 pub uri: String,
10}
11
12#[derive(Debug, Clone, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14pub struct CreateTokenInstructionAccounts {
15 pub config: solana_pubkey::Pubkey,
16 pub metadata: solana_pubkey::Pubkey,
17 pub mint: solana_pubkey::Pubkey,
18 pub payer: solana_pubkey::Pubkey,
19 pub rent: solana_pubkey::Pubkey,
20 pub system_program: solana_pubkey::Pubkey,
21 pub token_program: solana_pubkey::Pubkey,
22 pub token_metadata_program: solana_pubkey::Pubkey,
23 pub remaining: Vec<solana_instruction::AccountMeta>,
24}
25
26impl CreateToken {
27 pub fn decode(data: &[u8]) -> Option<Self> {
28 if data.len() < 8 {
29 return None;
30 }
31 let discriminator = &data[0..8];
32 if discriminator != [84, 52, 204, 228, 24, 140, 234, 75] {
33 return None;
34 }
35
36 let mut data_slice = data;
37
38 data_slice = &data_slice[8..];
39
40 borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
41 }
42}
43
44impl ArrangeAccounts for CreateToken {
45 type ArrangedAccounts = CreateTokenInstructionAccounts;
46
47 fn arrange_accounts(
48 accounts: &[solana_instruction::AccountMeta],
49 ) -> Option<Self::ArrangedAccounts> {
50 let mut iter = accounts.iter();
51
52 let config = next_account(&mut iter)?;
53 let metadata = next_account(&mut iter)?;
54 let mint = next_account(&mut iter)?;
55 let payer = next_account(&mut iter)?;
56 let rent = next_account(&mut iter)?;
57 let system_program = next_account(&mut iter)?;
58 let token_program = next_account(&mut iter)?;
59 let token_metadata_program = next_account(&mut iter)?;
60
61 let remaining = iter.as_slice();
62
63 Some(CreateTokenInstructionAccounts {
64 config,
65 metadata,
66 mint,
67 payer,
68 rent,
69 system_program,
70 token_program,
71 token_metadata_program,
72 remaining: remaining.to_vec(),
73 })
74 }
75}