gpl_core/
events.rs

1use crate::state::{Namespace, ReactionType};
2use anchor_lang::prelude::*;
3
4// TODO: Explicitly add the signer to all events
5// This would be useful to quickly find out who owns the current user account. Perhaps this can be
6// looked up? Let's see how this works out.
7
8// This event is emitted whenever a new user is created.
9#[event]
10pub struct UserNew {
11    pub user: Pubkey,
12    pub random_hash: [u8; 32],
13    pub authority: Pubkey,
14    pub timestamp: i64,
15}
16
17// This event is emitted whenever the user's authority is changed.
18#[event]
19pub struct UserAuthorityChanged {
20    pub user: Pubkey,
21    pub new_authority: Pubkey,
22    pub old_authority: Pubkey,
23    pub timestamp: i64,
24}
25
26// This event is emitted whenever the user's account is deleted.
27#[event]
28pub struct UserDeleted {
29    pub user: Pubkey,
30    pub authority: Pubkey,
31    pub timestamp: i64,
32}
33
34// This event is emitted whenever a new profile is created.
35#[event]
36pub struct ProfileNew {
37    pub profile: Pubkey,
38    pub user: Pubkey,
39    pub namespace: Namespace,
40    pub timestamp: i64,
41}
42
43// This event is emitted whenever a profile is deleted.
44#[event]
45pub struct ProfileDeleted {
46    pub profile: Pubkey,
47    pub user: Pubkey,
48    pub namespace: Namespace,
49    pub timestamp: i64,
50}
51
52// This event is emitted whenever a new post is created.
53#[event]
54pub struct PostNew {
55    pub post: Pubkey,
56    pub profile: Pubkey,
57    pub user: Pubkey,
58    pub random_hash: [u8; 32],
59    pub metadata_uri: String,
60    pub timestamp: i64,
61}
62
63// This event is emitted whenever a post is updated.
64#[event]
65pub struct PostUpdated {
66    pub post: Pubkey,
67    pub profile: Pubkey,
68    pub user: Pubkey,
69    pub metadata_uri: String,
70    pub timestamp: i64,
71}
72
73// This event is emitted whenever a post is deleted.
74#[event]
75pub struct PostDeleted {
76    pub post: Pubkey,
77    pub profile: Pubkey,
78    pub user: Pubkey,
79    pub timestamp: i64,
80}
81
82// This event is emitted whenever a new comment is created.
83#[event]
84pub struct PostCommentNew {
85    pub post: Pubkey,
86    pub profile: Pubkey,
87    pub user: Pubkey,
88    pub random_hash: [u8; 32],
89    pub metadata_uri: String,
90    pub reply_to: Pubkey,
91    pub timestamp: i64,
92}
93
94// This event is emitted whenever a new connection is created.
95#[event]
96pub struct ConnectionNew {
97    pub connection: Pubkey,
98    pub user: Pubkey,
99    pub from_profile: Pubkey,
100    pub to_profile: Pubkey,
101    pub timestamp: i64,
102}
103
104// This event is emitted whenever a connection is deleted.
105#[event]
106pub struct ConnectionDeleted {
107    pub connection: Pubkey,
108    pub user: Pubkey,
109    pub from_profile: Pubkey,
110    pub to_profile: Pubkey,
111    pub timestamp: i64,
112}
113
114// This event is emitted whenever a new reaction is created.
115#[event]
116pub struct ReactionNew {
117    pub reaction: Pubkey,
118    pub reaction_type: ReactionType,
119    pub user: Pubkey,
120    pub from_profile: Pubkey,
121    pub to_post: Pubkey,
122    pub timestamp: i64,
123}
124
125// This event is emitted whenever a reaction is deleted.
126#[event]
127pub struct ReactionDeleted {
128    pub reaction: Pubkey,
129    pub reaction_type: ReactionType,
130    pub user: Pubkey,
131    pub from_profile: Pubkey,
132    pub to_post: Pubkey,
133    pub timestamp: i64,
134}
135
136// This event is emitted whenever a new profile metadata is created.
137#[event]
138pub struct ProfileMetadataNew {
139    pub profile_metadata: Pubkey,
140    pub profile: Pubkey,
141    pub user: Pubkey,
142    pub metadata_uri: String,
143    pub timestamp: i64,
144}
145
146// This event is emitted whenever a profile metadata is updated.
147#[event]
148pub struct ProfileMetadataUpdated {
149    pub profile_metadata: Pubkey,
150    pub profile: Pubkey,
151    pub user: Pubkey,
152    pub metadata_uri: String,
153    pub timestamp: i64,
154}
155
156// This event is emitted whenever a profile metadata is deleted.
157#[event]
158pub struct ProfileMetadataDeleted {
159    pub profile_metadata: Pubkey,
160    pub profile: Pubkey,
161    pub user: Pubkey,
162    pub timestamp: i64,
163}