Skip to main content

carbon_stake_program_decoder/instructions/
authorize_with_seed.rs

1//! This code was AUTOGENERATED using the Codama library.
2use {
3    crate::types::AuthorizeWithSeedParams,
4    carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
5};
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
8pub struct AuthorizeWithSeed {
9    pub arg0: AuthorizeWithSeedParams,
10}
11
12#[derive(Debug, Clone, PartialEq)]
13#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
14pub struct AuthorizeWithSeedInstructionAccounts {
15    pub stake: solana_pubkey::Pubkey,
16    pub base: solana_pubkey::Pubkey,
17    pub clock_sysvar: solana_pubkey::Pubkey,
18    pub lockup_authority: Option<solana_pubkey::Pubkey>,
19    pub remaining: Vec<solana_instruction::AccountMeta>,
20}
21
22impl AuthorizeWithSeed {
23    pub fn decode(data: &[u8]) -> Option<Self> {
24        if data.is_empty() {
25            return None;
26        }
27        let discriminator = &data[0..1];
28        if discriminator != [8] {
29            return None;
30        }
31
32        let mut data_slice = data;
33
34        data_slice = &data_slice[1..];
35
36        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
37    }
38}
39
40impl ArrangeAccounts for AuthorizeWithSeed {
41    type ArrangedAccounts = AuthorizeWithSeedInstructionAccounts;
42
43    fn arrange_accounts(
44        accounts: &[solana_instruction::AccountMeta],
45    ) -> Option<Self::ArrangedAccounts> {
46        let mut iter = accounts.iter();
47
48        let stake = next_account(&mut iter)?;
49        let base = next_account(&mut iter)?;
50        let clock_sysvar = next_account(&mut iter)?;
51        let lockup_authority = next_account(&mut iter);
52
53        let remaining = iter.as_slice();
54
55        Some(AuthorizeWithSeedInstructionAccounts {
56            stake,
57            base,
58            clock_sysvar,
59            lockup_authority,
60            remaining: remaining.to_vec(),
61        })
62    }
63}