1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use crate::v0::context::SharedContext;
use crate::v0::result::HandlerResult;
use jormungandr_lib::interfaces::Value;
use serde::{Deserialize, Serialize};
use snapshot_lib::{Dreps, Fraction, RawSnapshot, SnapshotInfo};
use warp::{Rejection, Reply};

#[tracing::instrument(skip(context))]
pub async fn get_voters_info(
    tag: String,
    voting_key: String,
    context: SharedContext,
) -> Result<impl Reply, Rejection> {
    Ok(HandlerResult(
        super::get_voters_info(tag, voting_key, context).await,
    ))
}

#[tracing::instrument(skip(context))]
pub async fn get_delegator_info(
    tag: String,
    stake_public_key: String,
    context: SharedContext,
) -> Result<impl Reply, Rejection> {
    Ok(HandlerResult(
        super::get_delegator_info(tag, stake_public_key, context).await,
    ))
}

/// Snapshot information update with timestamp.
#[derive(Clone, Debug, /* PartialEq, Eq, */ Deserialize, Serialize)]
pub struct SnapshotInfoInput {
    pub snapshot: Vec<SnapshotInfo>,
    #[serde(deserialize_with = "crate::utils::serde::deserialize_unix_timestamp_from_rfc3339")]
    #[serde(serialize_with = "crate::utils::serde::serialize_unix_timestamp_as_rfc3339")]
    pub update_timestamp: i64,
}

/// Raw Snapshot information update with timestamp.
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct RawSnapshotInput {
    pub snapshot: RawSnapshot,
    #[serde(deserialize_with = "crate::utils::serde::deserialize_unix_timestamp_from_rfc3339")]
    #[serde(serialize_with = "crate::utils::serde::serialize_unix_timestamp_as_rfc3339")]
    pub update_timestamp: i64,
    pub min_stake_threshold: Value,
    #[serde(deserialize_with = "crate::utils::serde::deserialize_fraction_from_string")]
    #[serde(serialize_with = "crate::utils::serde::serialize_fraction_to_string")]
    pub voting_power_cap: Fraction,
    pub direct_voters_group: Option<String>,
    pub representatives_group: Option<String>,
    pub dreps: Option<Dreps>,
}