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    Initialize = 4,
11}
12
13#[repr(C)]
14#[derive(Clone, Copy, Debug, Pod, Zeroable)]
15pub struct Initialize {
16    // No fields needed - just creates Config account with next_message_id = 0
17}
18
19#[repr(C)]
20#[derive(Clone, Copy, Debug, Pod, Zeroable)]
21pub struct SendMessage {
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 ReplyToMessage {
28    pub parent_message_pda: [u8; 32], // Parent message PDA
29    pub message_hash: [u8; 32], // Keccak256 hash of message content
30}
31
32#[repr(C)]
33#[derive(Clone, Copy, Debug, Pod, Zeroable)]
34pub struct AddReaction {
35    pub message_pda: [u8; 32], // Message PDA to react to
36    pub emoji: [u8; 4], // UTF-8 emoji (most fit in 4 bytes)
37}
38
39#[repr(C)]
40#[derive(Clone, Copy, Debug, Pod, Zeroable)]
41pub struct RemoveReaction {
42    pub message_pda: [u8; 32], // Message PDA
43    pub emoji: [u8; 4], // UTF-8 emoji
44}
45
46instruction!(ChatInstruction, Initialize);
47instruction!(ChatInstruction, SendMessage);
48instruction!(ChatInstruction, ReplyToMessage);
49instruction!(ChatInstruction, AddReaction);
50instruction!(ChatInstruction, RemoveReaction);