Skip to main content

carbon_pumpfun_decoder/instructions/
create.rs

1//! This code was AUTOGENERATED using the Codama library.
2use {
3    carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
4    solana_pubkey::Pubkey,
5};
6/// Creates a new coin and bonding curve.
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
9pub struct Create {
10    pub name: String,
11    pub symbol: String,
12    pub uri: String,
13    pub creator: Pubkey,
14}
15
16#[derive(Debug, Clone, PartialEq)]
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18pub struct CreateInstructionAccounts {
19    pub mint: solana_pubkey::Pubkey,
20    pub mint_authority: solana_pubkey::Pubkey,
21    pub bonding_curve: solana_pubkey::Pubkey,
22    pub associated_bonding_curve: solana_pubkey::Pubkey,
23    pub global: solana_pubkey::Pubkey,
24    pub mpl_token_metadata: solana_pubkey::Pubkey,
25    pub metadata: solana_pubkey::Pubkey,
26    pub user: solana_pubkey::Pubkey,
27    pub system_program: solana_pubkey::Pubkey,
28    pub token_program: solana_pubkey::Pubkey,
29    pub associated_token_program: solana_pubkey::Pubkey,
30    pub rent: solana_pubkey::Pubkey,
31    pub event_authority: solana_pubkey::Pubkey,
32    pub program: solana_pubkey::Pubkey,
33    pub remaining: Vec<solana_instruction::AccountMeta>,
34}
35
36impl Create {
37    pub fn decode(data: &[u8]) -> Option<Self> {
38        if data.len() < 8 {
39            return None;
40        }
41        let discriminator = &data[0..8];
42        if discriminator != [24, 30, 200, 40, 5, 28, 7, 119] {
43            return None;
44        }
45
46        let mut data_slice = data;
47
48        data_slice = &data_slice[8..];
49
50        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
51    }
52}
53
54impl ArrangeAccounts for Create {
55    type ArrangedAccounts = CreateInstructionAccounts;
56
57    fn arrange_accounts(
58        accounts: &[solana_instruction::AccountMeta],
59    ) -> Option<Self::ArrangedAccounts> {
60        let mut iter = accounts.iter();
61
62        let mint = next_account(&mut iter)?;
63        let mint_authority = next_account(&mut iter)?;
64        let bonding_curve = next_account(&mut iter)?;
65        let associated_bonding_curve = next_account(&mut iter)?;
66        let global = next_account(&mut iter)?;
67        let mpl_token_metadata = next_account(&mut iter)?;
68        let metadata = next_account(&mut iter)?;
69        let user = next_account(&mut iter)?;
70        let system_program = next_account(&mut iter)?;
71        let token_program = next_account(&mut iter)?;
72        let associated_token_program = next_account(&mut iter)?;
73        let rent = next_account(&mut iter)?;
74        let event_authority = next_account(&mut iter)?;
75        let program = next_account(&mut iter)?;
76
77        let remaining = iter.as_slice();
78
79        Some(CreateInstructionAccounts {
80            mint,
81            mint_authority,
82            bonding_curve,
83            associated_bonding_curve,
84            global,
85            mpl_token_metadata,
86            metadata,
87            user,
88            system_program,
89            token_program,
90            associated_token_program,
91            rent,
92            event_authority,
93            program,
94            remaining: remaining.to_vec(),
95        })
96    }
97}