Skip to main content

carbon_virtuals_decoder/instructions/
initialize.rs

1//! This code was AUTOGENERATED using the Codama library.
2use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3/// # Initialize Pool
4/// This is where Virtuals creates a new mint address and pool and mints the
5/// initial 1,000,000,000 tokens. This enabels Virtuals to premine addresses and
6/// \ sell\\
7/// them to customers without any delays of mining the
8/// address. While this instruction could be permissioned, it is currently
9/// permissionless. As such, we make sure to handle all the necessary checks
10/// such as: address suffix, zero supply, 6 decimals, correct mint authority.
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
13pub struct Initialize {}
14
15#[derive(Debug, Clone, PartialEq)]
16#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
17pub struct InitializeInstructionAccounts {
18    pub payer: solana_pubkey::Pubkey,
19    pub virtuals_mint: solana_pubkey::Pubkey,
20    pub token_mint: solana_pubkey::Pubkey,
21    pub vpool_virtuals_ata: solana_pubkey::Pubkey,
22    pub vpool_token_ata: solana_pubkey::Pubkey,
23    pub vpool: solana_pubkey::Pubkey,
24    pub token_program: solana_pubkey::Pubkey,
25    pub associated_token_program: solana_pubkey::Pubkey,
26    pub system_program: solana_pubkey::Pubkey,
27    pub remaining: Vec<solana_instruction::AccountMeta>,
28}
29
30impl Initialize {
31    pub fn decode(data: &[u8]) -> Option<Self> {
32        if data.len() < 8 {
33            return None;
34        }
35        let discriminator = &data[0..8];
36        if discriminator != [175, 175, 109, 31, 13, 152, 155, 237] {
37            return None;
38        }
39
40        let mut data_slice = data;
41
42        data_slice = &data_slice[8..];
43
44        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
45    }
46}
47
48impl ArrangeAccounts for Initialize {
49    type ArrangedAccounts = InitializeInstructionAccounts;
50
51    fn arrange_accounts(
52        accounts: &[solana_instruction::AccountMeta],
53    ) -> Option<Self::ArrangedAccounts> {
54        let mut iter = accounts.iter();
55
56        let payer = next_account(&mut iter)?;
57        let virtuals_mint = next_account(&mut iter)?;
58        let token_mint = next_account(&mut iter)?;
59        let vpool_virtuals_ata = next_account(&mut iter)?;
60        let vpool_token_ata = next_account(&mut iter)?;
61        let vpool = next_account(&mut iter)?;
62        let token_program = next_account(&mut iter)?;
63        let associated_token_program = next_account(&mut iter)?;
64        let system_program = next_account(&mut iter)?;
65
66        let remaining = iter.as_slice();
67
68        Some(InitializeInstructionAccounts {
69            payer,
70            virtuals_mint,
71            token_mint,
72            vpool_virtuals_ata,
73            vpool_token_ata,
74            vpool,
75            token_program,
76            associated_token_program,
77            system_program,
78            remaining: remaining.to_vec(),
79        })
80    }
81}