Skip to main content

carbon_system_program_decoder/instructions/
assign_with_seed.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#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
8pub struct AssignWithSeed {
9    pub base: Pubkey,
10    pub seed: String,
11    pub program_address: Pubkey,
12}
13
14#[derive(Debug, Clone, PartialEq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16pub struct AssignWithSeedInstructionAccounts {
17    pub account: solana_pubkey::Pubkey,
18    pub base_account: solana_pubkey::Pubkey,
19    pub remaining: Vec<solana_instruction::AccountMeta>,
20}
21
22impl AssignWithSeed {
23    pub fn decode(data: &[u8]) -> Option<Self> {
24        if data.len() < 4 {
25            return None;
26        }
27        let discriminator = &data[0..4];
28        if discriminator != [10, 0, 0, 0] {
29            return None;
30        }
31
32        let mut data_slice = data;
33
34        data_slice = &data_slice[4..];
35
36        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
37    }
38}
39
40impl ArrangeAccounts for AssignWithSeed {
41    type ArrangedAccounts = AssignWithSeedInstructionAccounts;
42
43    fn arrange_accounts(
44        accounts: &[solana_instruction::AccountMeta],
45    ) -> Option<Self::ArrangedAccounts> {
46        let mut iter = accounts.iter();
47
48        let account = next_account(&mut iter)?;
49        let base_account = next_account(&mut iter)?;
50
51        let remaining = iter.as_slice();
52
53        Some(AssignWithSeedInstructionAccounts {
54            account,
55            base_account,
56            remaining: remaining.to_vec(),
57        })
58    }
59}