1use chrono::NaiveDateTime;
2use serde::{Deserialize, Serialize};
3
4#[cfg(feature = "redis")]
5use redis_derive::{FromRedisValue, ToRedisArgs};
6
7#[derive(Serialize, Deserialize, Debug, Clone)]
9pub struct AuthResponse {
10 pub token: String,
11}
12
13#[derive(Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
15pub struct SupplyResponse {
16 pub result: String,
17}
18
19#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Eq)]
21pub struct ChatSendMessageResponse {
22 pub status: String,
23 pub message: String,
24}
25
26#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
27pub struct User {
28 pub authority: String,
29 pub username: String,
30 pub profile_photo_url: Option<String>,
31 pub discord_user: Option<DiscordUser>,
32 pub updated_at: NaiveDateTime,
33 pub risk_score: i64,
34 pub is_banned: bool,
35 pub role: Option<String>,
36}
37
38#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
40#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs))]
41pub struct ChatNotification {
42 pub authority: String,
43 pub username: String,
44 pub text: String,
45 pub id: u64,
46 pub ts: i64,
47 pub profile_photo_url: Option<String>,
48 pub role: Option<String>,
49 pub discord_user_id: Option<String>,
50}
51
52#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
53#[cfg_attr(feature = "redis", derive(FromRedisValue, ToRedisArgs))]
54pub struct DeployNotification {
55 pub id: u64,
56 pub authority: String,
57 pub username: Option<String>,
58 pub profile_photo_url: Option<String>,
59 pub total_squares: u64,
60 pub mask: i64,
61 pub amount: u64,
62 pub round_id: u64,
63 pub ts: i64,
64}
65
66#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
67pub struct ResetNotification {
68 pub block_id: u64,
69}
70
71#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
72pub enum Notification {
73 Chat(ChatNotification),
74 Reset(ResetNotification),
75 Deploy(DeployNotification),
76}
77
78impl Notification {
79 pub fn id(&self) -> String {
80 match self {
81 Notification::Chat(chat) => chat.id.to_string(),
82 Notification::Reset(reset) => reset.block_id.to_string(),
83 Notification::Deploy(deploy) => deploy.id.to_string(),
84 }
85 }
86}
87
88#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
89pub struct DailyRevenue {
90 pub day: String,
91 pub revenue: i64,
92}
93
94#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
97pub struct UsernameValidationResponse {
98 pub valid: bool,
99 pub error: Option<String>,
100}
101
102impl UsernameValidationResponse {
103 pub fn valid() -> Self {
104 Self {
105 valid: true,
106 error: None,
107 }
108 }
109
110 pub fn invalid(error: String) -> Self {
111 Self {
112 valid: false,
113 error: Some(error),
114 }
115 }
116}
117
118#[derive(Serialize, Deserialize, Debug, Clone)]
120pub struct DiscordAuthResponse {
121 pub access_token: String,
122}
123
124#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
125pub struct DiscordUser {
126 pub id: String,
127 pub username: String,
128 pub discriminator: String,
129 #[serde(default, skip_serializing_if = "Option::is_none")]
130 pub global_name: Option<String>,
131 #[serde(default, skip_serializing_if = "Option::is_none")]
132 pub avatar: Option<String>,
133 #[serde(default, skip_serializing_if = "Option::is_none")]
134 pub verified: Option<bool>,
135 #[serde(default, skip_serializing_if = "Option::is_none")]
136 pub email: Option<String>,
137}
138
139#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
140pub struct OreBalance {
141 pub wallet: u64,
142 pub staked: u64,
143 pub unrefined: u64,
144 pub refined: u64,
145 pub lifetime_deployed_sol: u64,
146}
147
148#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
149pub struct LeaderboardEntry {
150 pub authority: String,
151 pub amount: u64,
152 pub username: Option<String>,
153 pub profile_picture_url: Option<String>,
154}
155
156#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
158pub struct DeployHistoryEvent {
159 pub sig: String,
160 pub authority: String,
161 pub signer: String,
162 pub amount: u64,
163 pub mask: i64,
164 pub round_id: i64,
165 pub total_squares: i64,
166 pub ts: i64,
167 pub winning_square: i64,
168 pub top_miner: String,
169 pub rewards_sol: u64,
170 pub rewards_ore: u64,
171 pub total_winnings_sol: u64,
172 pub deployed_winning_square: u64,
173 pub motherlode: u64,
174}