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