coal_api/state/
tool.rs

1use bytemuck::{Pod, Zeroable};
2use solana_program::pubkey::Pubkey;
3
4use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};
5
6use super::AccountDiscriminator;
7
8#[repr(C)]
9#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
10pub struct Tool {
11    /// The tool authority.
12    pub authority: Pubkey,
13
14    /// Miner authorized to use the tool.
15    pub miner: Pubkey,
16
17    /// The equipped tool.
18    pub asset: Pubkey,
19
20    /// The remaining durability of the tool.
21    pub durability: u64,
22
23    /// The multiplier of the tool.
24    pub multiplier: u64,
25}
26
27impl Discriminator for Tool {
28    fn discriminator() -> u8 {
29        AccountDiscriminator::Tool.into()
30    }
31}
32
33#[repr(C)]
34#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
35pub struct WoodTool {
36    /// The tool authority.
37    pub authority: Pubkey,
38
39    /// Miner authorized to use the tool.
40    pub miner: Pubkey,
41
42    /// The equipped tool.
43    pub asset: Pubkey,
44
45    /// The remaining durability of the tool.
46    pub durability: u64,
47
48    /// The multiplier of the tool.
49    pub multiplier: u64,
50}
51
52impl Discriminator for WoodTool {
53    fn discriminator() -> u8 {
54        AccountDiscriminator::WoodTool.into()
55    }
56}
57
58impl_to_bytes!(Tool);
59impl_account_from_bytes!(Tool);
60impl_to_bytes!(WoodTool);
61impl_account_from_bytes!(WoodTool);