coal_api/state/
tool.rs

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
use bytemuck::{Pod, Zeroable};
use solana_program::pubkey::Pubkey;

use crate::utils::{impl_account_from_bytes, impl_to_bytes, Discriminator};

use super::AccountDiscriminator;

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct Tool {
    /// The tool authority.
    pub authority: Pubkey,

    /// Miner authorized to use the tool.
    pub miner: Pubkey,

    /// The equipped tool.
    pub asset: Pubkey,

    /// The remaining durability of the tool.
    pub durability: u64,

    /// The multiplier of the tool.
    pub multiplier: u64,
}

impl Discriminator for Tool {
    fn discriminator() -> u8 {
        AccountDiscriminator::Tool.into()
    }
}

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable)]
pub struct WoodTool {
    /// The tool authority.
    pub authority: Pubkey,

    /// Miner authorized to use the tool.
    pub miner: Pubkey,

    /// The equipped tool.
    pub asset: Pubkey,

    /// The remaining durability of the tool.
    pub durability: u64,

    /// The multiplier of the tool.
    pub multiplier: u64,
}

impl Discriminator for WoodTool {
    fn discriminator() -> u8 {
        AccountDiscriminator::WoodTool.into()
    }
}

impl_to_bytes!(Tool);
impl_account_from_bytes!(Tool);
impl_to_bytes!(WoodTool);
impl_account_from_bytes!(WoodTool);