gmsol_callback/states.rs
1use anchor_lang::prelude::*;
2
3/// The expected program ID of the caller.
4pub const CALLER_PROGRAM_ID: Pubkey = pubkey!("Gmso1uvJnLbawvw7yezdfCDcPydwW2s2iqG3w6MDucLo");
5
6/// Maximum length of the prefix.
7#[constant]
8pub const MAX_PREFIX_LEN: u8 = 32;
9
10/// The seed for [`Config`] account.
11#[constant]
12pub const CONFIG_SEED: &[u8] = b"config";
13
14/// The seed for [`ActionStats`] account.
15#[constant]
16pub const ACTION_STATS_SEED: &[u8] = b"action_stats";
17
18/// Config account.
19#[account]
20#[derive(InitSpace)]
21#[cfg_attr(feature = "debug", derive(Debug))]
22pub struct Config {
23 /// Prefix.
24 #[max_len(MAX_PREFIX_LEN)]
25 pub prefix: String,
26 /// Total number of calls.
27 pub calls: u64,
28}
29
30/// Account that tracks lifecycle statistics of actions known to the program.
31#[account]
32#[derive(InitSpace)]
33#[cfg_attr(feature = "debug", derive(Debug))]
34pub struct ActionStats {
35 /// Whether the account has been initialized.
36 pub initialized: bool,
37 /// Bump seed used to derive the PDA for this account.
38 pub bump: u8,
39 /// The action kind.
40 pub action_kind: u8,
41 /// The owner.
42 pub owner: Pubkey,
43 /// Total number of actions that have ever been created.
44 pub total_created: u64,
45 /// Updated times.
46 pub update_count: u64,
47 /// Total number of actions that have been executed.
48 pub total_executed: u64,
49 /// Total number of actions that have been closed.
50 pub total_closed: u64,
51 /// Timestamp of the last created action.
52 pub last_created_at: i64,
53 /// Timestamp of the last created action.
54 pub last_updated_at: i64,
55 /// Timestamp of the last executed action.
56 pub last_executed_at: i64,
57 /// Timestamp of the last closed action.
58 pub last_closed_at: i64,
59}