Skip to main content

carbon_solayer_restaking_program_decoder/instructions/
initialize.rs

1//! This code was AUTOGENERATED using the Codama library.
2use 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 Initialize {}
6
7#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct InitializeInstructionAccounts {
10    pub signer: solana_pubkey::Pubkey,
11    pub solayer_admin: solana_pubkey::Pubkey,
12    pub lst_mint: solana_pubkey::Pubkey,
13    pub lst_vault: solana_pubkey::Pubkey,
14    pub rst_mint: solana_pubkey::Pubkey,
15    pub pool: solana_pubkey::Pubkey,
16    pub associated_token_program: solana_pubkey::Pubkey,
17    pub token_program: solana_pubkey::Pubkey,
18    pub system_program: solana_pubkey::Pubkey,
19    pub remaining: Vec<solana_instruction::AccountMeta>,
20}
21
22impl Initialize {
23    pub fn decode(data: &[u8]) -> Option<Self> {
24        if data.len() < 8 {
25            return None;
26        }
27        let discriminator = &data[0..8];
28        if discriminator != [175, 175, 109, 31, 13, 152, 155, 237] {
29            return None;
30        }
31
32        let mut data_slice = data;
33
34        data_slice = &data_slice[8..];
35
36        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
37    }
38}
39
40impl ArrangeAccounts for Initialize {
41    type ArrangedAccounts = InitializeInstructionAccounts;
42
43    fn arrange_accounts(
44        accounts: &[solana_instruction::AccountMeta],
45    ) -> Option<Self::ArrangedAccounts> {
46        let mut iter = accounts.iter();
47
48        let signer = next_account(&mut iter)?;
49        let solayer_admin = next_account(&mut iter)?;
50        let lst_mint = next_account(&mut iter)?;
51        let lst_vault = next_account(&mut iter)?;
52        let rst_mint = next_account(&mut iter)?;
53        let pool = next_account(&mut iter)?;
54        let associated_token_program = next_account(&mut iter)?;
55        let token_program = next_account(&mut iter)?;
56        let system_program = next_account(&mut iter)?;
57
58        let remaining = iter.as_slice();
59
60        Some(InitializeInstructionAccounts {
61            signer,
62            solayer_admin,
63            lst_mint,
64            lst_vault,
65            rst_mint,
66            pool,
67            associated_token_program,
68            token_program,
69            system_program,
70            remaining: remaining.to_vec(),
71        })
72    }
73}