-
Notifications
You must be signed in to change notification settings - Fork 183
Expand file tree
/
Copy pathcreate_sub_account_v1.rs
More file actions
77 lines (64 loc) · 2.17 KB
/
create_sub_account_v1.rs
File metadata and controls
77 lines (64 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! This code was AUTOGENERATED using the Codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun Codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!
use carbon_core::account_utils::next_account;
use carbon_core::borsh::{self, BorshDeserialize};
use carbon_core::deserialize::ArrangeAccounts;
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(
Debug,
Clone,
carbon_core::borsh::BorshSerialize,
carbon_core::borsh::BorshDeserialize,
PartialEq,
)]
pub struct CreateSubAccountV1 {}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct CreateSubAccountV1InstructionAccounts {
pub swig: solana_pubkey::Pubkey,
pub payer: solana_pubkey::Pubkey,
pub sub_account: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}
impl CreateSubAccountV1 {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 1 {
return None;
}
let discriminator = &data[0..1];
if discriminator != &[6] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[1..];
if let Ok(decoded) = Self::deserialize(&mut data_slice) {
return Some(decoded);
}
None
}
}
impl ArrangeAccounts for CreateSubAccountV1 {
type ArrangedAccounts = CreateSubAccountV1InstructionAccounts;
fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let swig = next_account(&mut iter)?;
let payer = next_account(&mut iter)?;
let sub_account = next_account(&mut iter)?;
let system_program = next_account(&mut iter)?;
let remaining = iter.as_slice();
Some(CreateSubAccountV1InstructionAccounts {
swig: swig,
payer: payer,
sub_account: sub_account,
system_program: system_program,
remaining: remaining.to_vec(),
})
}
}