Skip to main content

oil_chat_api/
instruction.rs

1use steel::*;
2
3#[repr(u8)]
4#[derive(Clone, Copy, Debug, Eq, PartialEq, TryFromPrimitive)]
5pub enum ChatInstruction {
6    SendMessage = 0,
7    ReplyToMessage = 1,
8    AddReaction = 2,
9    RemoveReaction = 3,
10}
11
12#[repr(C)]
13#[derive(Clone, Copy, Debug, Pod, Zeroable)]
14pub struct SendMessage {
15    pub message_hash: [u8; 32], // Keccak256 hash of message content
16}
17
18#[repr(C)]
19#[derive(Clone, Copy, Debug, Pod, Zeroable)]
20pub struct ReplyToMessage {
21    pub parent_message_pda: [u8; 32], // Parent message PDA
22    pub message_hash: [u8; 32], // Keccak256 hash of message content
23}
24
25#[repr(C)]
26#[derive(Clone, Copy, Debug, Pod, Zeroable)]
27pub struct AddReaction {
28    pub message_pda: [u8; 32], // Message PDA to react to
29    pub emoji: [u8; 4], // UTF-8 emoji (most fit in 4 bytes)
30}
31
32#[repr(C)]
33#[derive(Clone, Copy, Debug, Pod, Zeroable)]
34pub struct RemoveReaction {
35    pub message_pda: [u8; 32], // Message PDA
36    pub emoji: [u8; 4], // UTF-8 emoji
37}
38
39instruction!(ChatInstruction, SendMessage);
40instruction!(ChatInstruction, ReplyToMessage);
41instruction!(ChatInstruction, AddReaction);
42instruction!(ChatInstruction, RemoveReaction);