hapi_core/state/
reporter.rs

1use anchor_lang::prelude::*;
2
3#[account]
4#[derive(Default)]
5pub struct Reporter {
6    /// Community account, which this reporter belongs to
7    pub community: Pubkey,
8
9    /// Seed bump for PDA
10    pub bump: u8,
11
12    /// If this is true, reporter can't interact with the contract
13    pub is_frozen: bool,
14
15    /// Reporter account status
16    pub status: ReporterStatus,
17
18    /// Reporter's type
19    pub role: ReporterRole,
20
21    /// Reporter's wallet account
22    pub pubkey: Pubkey,
23
24    /// Short reporter description
25    pub name: [u8; 32],
26
27    /// Current deposited stake
28    pub stake: u64,
29
30    /// Reporter can unstake at this epoch (0 if unstaking hasn't been requested)
31    pub unlock_epoch: u64,
32}
33
34#[account(zero_copy)]
35#[derive(Default, Debug)]
36pub struct ReporterReward {
37    /// Reporter account to keep reward counter for
38    pub reporter: Pubkey,
39
40    /// Network that has the reward associated with
41    pub network: Pubkey,
42
43    /// Seed bump for PDA
44    pub bump: u8,
45
46    /// Number of unclaimed address report rewards
47    pub address_tracer_counter: u64,
48
49    /// Number of unclaimed address confirmation rewards
50    pub address_confirmation_counter: u64,
51
52    /// Number of unclaimed asset report rewards
53    pub asset_tracer_counter: u64,
54
55    /// Number of unclaimed asset confirmation rewards
56    pub asset_confirmation_counter: u64,
57}
58
59#[derive(Clone, PartialEq, AnchorDeserialize, AnchorSerialize)]
60pub enum ReporterStatus {
61    /// Reporter is not active, but can activate after staking
62    Inactive,
63
64    /// Reporter is active and can report
65    Active,
66
67    /// Reporter has requested unstaking and can't report
68    Unstaking,
69}
70
71impl Default for ReporterStatus {
72    fn default() -> Self {
73        ReporterStatus::Inactive
74    }
75}
76
77#[derive(Clone, PartialEq, AnchorDeserialize, AnchorSerialize)]
78pub enum ReporterRole {
79    /// Validator - can validate addresses
80    Validator = 0,
81
82    /// Tracer - can report and validate addresses
83    Tracer = 1,
84
85    /// Publisher - can report cases and addresses
86    Publisher = 2,
87
88    /// Authority - can report and modify cases and addresses
89    Authority = 3,
90
91    /// Appraiser - can update replication price
92    Appraiser = 4,
93}
94
95impl Default for ReporterRole {
96    fn default() -> Self {
97        ReporterRole::Validator
98    }
99}