carbon_score_decoder/instructions/
process_register_ship.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 ProcessRegisterShip {
11 pub scorevars_bump: u8,
12 pub scorevars_ship_bump: u8,
13 pub reward_rate_per_second: u64,
14 pub fuel_max_reserve: u32,
15 pub food_max_reserve: u32,
16 pub arms_max_reserve: u32,
17 pub toolkit_max_reserve: u32,
18 pub milliseconds_to_burn_one_fuel: u32,
19 pub milliseconds_to_burn_one_food: u32,
20 pub milliseconds_to_burn_one_arms: u32,
21 pub milliseconds_to_burn_one_toolkit: u32,
22}
23
24#[derive(Debug, Clone, PartialEq)]
25#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
26pub struct ProcessRegisterShipInstructionAccounts {
27 pub update_authority_account: solana_pubkey::Pubkey,
28 pub score_vars_account: solana_pubkey::Pubkey,
29 pub score_vars_ship_account: solana_pubkey::Pubkey,
30 pub ship_mint: solana_pubkey::Pubkey,
31 pub system_program: solana_pubkey::Pubkey,
32 pub remaining: Vec<solana_instruction::AccountMeta>,
33}
34
35impl ProcessRegisterShip {
36 pub fn decode(data: &[u8]) -> Option<Self> {
37 if data.len() < 8 {
38 return None;
39 }
40 let discriminator = &data[0..8];
41 if discriminator != &[193, 152, 37, 84, 8, 48, 15, 90] {
42 return None;
43 }
44
45 let data_slice = data;
46
47 let data_slice = &data_slice[8..];
48
49 Self::deserialize(data_slice)
50 }
51}
52
53impl ArrangeAccounts for ProcessRegisterShip {
54 type ArrangedAccounts = ProcessRegisterShipInstructionAccounts;
55
56 fn arrange_accounts(
57 accounts: &[solana_instruction::AccountMeta],
58 ) -> Option<Self::ArrangedAccounts> {
59 let mut iter = accounts.iter();
60
61 let update_authority_account = next_account(&mut iter)?;
62 let score_vars_account = next_account(&mut iter)?;
63 let score_vars_ship_account = next_account(&mut iter)?;
64 let ship_mint = next_account(&mut iter)?;
65 let system_program = next_account(&mut iter)?;
66
67 let remaining = iter.as_slice();
68
69 Some(ProcessRegisterShipInstructionAccounts {
70 update_authority_account,
71 score_vars_account,
72 score_vars_ship_account,
73 ship_mint,
74 system_program,
75 remaining: remaining.to_vec(),
76 })
77 }
78}