Skip to main content

oil_chat_api/state/
reaction.rs

1use serde::{Deserialize, Serialize};
2use steel::*;
3use crate::state::reaction_pda;
4use super::ChatAccount;
5
6#[repr(C)]
7#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
8pub struct Reaction {
9    pub message_pda: Pubkey, // 32 bytes - Message this reaction is for
10    pub authority: Pubkey, // 32 bytes - User who reacted
11    pub emoji: [u8; 4], // 4 bytes - UTF-8 emoji (most fit in 4 bytes)
12    pub _padding: u32, // 4 bytes explicit padding for u64 alignment
13    pub created_at: u64, // 8 bytes - Unix timestamp
14}
15
16impl Reaction {
17    pub fn pda(&self) -> (Pubkey, u8) {
18        reaction_pda(self.message_pda, self.authority, &self.emoji)
19    }
20}
21
22account!(ChatAccount, Reaction);