carbon_score_decoder/instructions/
process_settle.rs1use carbon_core::CarbonDeserialize;
3use carbon_core::account_utils::next_account;
4use carbon_core::borsh;
5use carbon_core::deserialize::ArrangeAccounts;
6use carbon_core::deserialize::CarbonDeserialize;
7
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq, Eq, Hash)]
10pub struct ProcessSettle {
11 pub staking_bump: u8,
12 pub scorevars_bump: u8,
13 pub scorevars_ship_bump: u8,
14}
15
16#[derive(Debug, Clone, PartialEq)]
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18pub struct ProcessSettleInstructionAccounts {
19 pub player_account: solana_pubkey::Pubkey,
20 pub update_authority_account: solana_pubkey::Pubkey,
21 pub ship_staking_account: solana_pubkey::Pubkey,
22 pub score_vars_ship_account: solana_pubkey::Pubkey,
23 pub score_vars_account: solana_pubkey::Pubkey,
24 pub clock: solana_pubkey::Pubkey,
25 pub ship_mint: solana_pubkey::Pubkey,
26 pub remaining: Vec<solana_instruction::AccountMeta>,
27}
28
29impl ProcessSettle {
30 pub fn decode(data: &[u8]) -> Option<Self> {
31 if data.len() < 8 {
32 return None;
33 }
34 let discriminator = &data[0..8];
35 if discriminator != &[223, 209, 43, 136, 182, 72, 253, 253] {
36 return None;
37 }
38
39 let data_slice = data;
40
41 let data_slice = &data_slice[8..];
42
43 Self::deserialize(data_slice)
44 }
45}
46
47impl ArrangeAccounts for ProcessSettle {
48 type ArrangedAccounts = ProcessSettleInstructionAccounts;
49
50 fn arrange_accounts(
51 accounts: &[solana_instruction::AccountMeta],
52 ) -> Option<Self::ArrangedAccounts> {
53 let mut iter = accounts.iter();
54
55 let player_account = next_account(&mut iter)?;
56 let update_authority_account = next_account(&mut iter)?;
57 let ship_staking_account = next_account(&mut iter)?;
58 let score_vars_ship_account = next_account(&mut iter)?;
59 let score_vars_account = next_account(&mut iter)?;
60 let clock = next_account(&mut iter)?;
61 let ship_mint = next_account(&mut iter)?;
62
63 let remaining = iter.as_slice();
64
65 Some(ProcessSettleInstructionAccounts {
66 player_account,
67 update_authority_account,
68 ship_staking_account,
69 score_vars_ship_account,
70 score_vars_account,
71 clock,
72 ship_mint,
73 remaining: remaining.to_vec(),
74 })
75 }
76}