gmsol_store/events/
shift.rs

1use anchor_lang::prelude::*;
2use borsh::BorshSerialize;
3
4use gmsol_utils::InitSpace;
5
6use crate::states::common::action::ActionState;
7
8use super::Event;
9
10/// Shift removed event.
11#[event]
12#[cfg_attr(feature = "debug", derive(Debug))]
13#[derive(Clone, InitSpace)]
14pub struct ShiftRemoved {
15    /// Action id.
16    pub id: u64,
17    /// Timestamp.
18    pub ts: i64,
19    /// Slot.
20    pub slot: u64,
21    /// Store.
22    pub store: Pubkey,
23    /// Shift.
24    pub shift: Pubkey,
25    /// Market token.
26    pub market_token: Pubkey,
27    /// Owner.
28    pub owner: Pubkey,
29    /// Final state.
30    pub state: ActionState,
31    /// Reason.
32    #[max_len(32)]
33    pub reason: String,
34}
35
36impl ShiftRemoved {
37    pub(crate) fn new(
38        id: u64,
39        store: Pubkey,
40        shift: Pubkey,
41        market_token: Pubkey,
42        owner: Pubkey,
43        state: ActionState,
44        reason: impl ToString,
45    ) -> Result<Self> {
46        let clock = Clock::get()?;
47        Ok(Self {
48            id,
49            ts: clock.unix_timestamp,
50            slot: clock.slot,
51            store,
52            shift,
53            market_token,
54            owner,
55            state,
56            reason: reason.to_string(),
57        })
58    }
59}
60
61impl InitSpace for ShiftRemoved {
62    const INIT_SPACE: usize = <Self as Space>::INIT_SPACE;
63}
64
65impl Event for ShiftRemoved {}