tg_utils/
jailing.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::Duration;
5
6#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
7#[serde(rename_all = "snake_case")]
8pub enum JailMsg {
9    /// Jails validator. Can be executed only by the admin.
10    Jail {
11        /// Operator which should be jailed
12        operator: String,
13        /// Duration for how long validator is jailed
14        duration: JailingDuration,
15    },
16    /// Unjails validator. Admin can unjail anyone anytime, others can unjail only themselves and
17    /// only if the jail period passed.
18    Unjail {
19        /// Address to unjail. Optional, as if not provided it is assumed to be the sender of the
20        /// message (for convenience when unjailing self after the jail period).
21        operator: Option<String>,
22    },
23}
24
25#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
26#[serde(rename_all = "snake_case")]
27pub enum JailingDuration {
28    Duration(Duration),
29    Forever {},
30}
31
32impl From<Duration> for JailingDuration {
33    fn from(dur: Duration) -> Self {
34        Self::Duration(dur)
35    }
36}