mpl_token_auth_rules/state/
frequency.rs

1use borsh::{BorshDeserialize, BorshSerialize};
2use shank::ShankAccount;
3
4use super::{Key, SolanaAccount};
5
6#[derive(BorshSerialize, BorshDeserialize, PartialEq, Eq, Debug, Clone, ShankAccount)]
7/// An account containing frequency state.
8pub struct FrequencyAccount {
9    /// The `Key` for this account which identifies it as a Frequency account.
10    pub key: Key,
11    /// The last time the frequency counter was updated.
12    pub last_update: i64,
13    /// The period which must transpire before the rule will succeed again.
14    pub period: i64,
15}
16
17impl FrequencyAccount {
18    /// Create a new `FrequencyAccount`.
19    pub fn new(last_update: i64, period: i64) -> Self {
20        Self {
21            key: Key::Frequency,
22            last_update,
23            period,
24        }
25    }
26}
27
28impl SolanaAccount for FrequencyAccount {
29    fn key() -> Key {
30        Key::Frequency
31    }
32}