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
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use cosmwasm_std::{Addr, CustomQuery};

use crate::hooks::Privilege;
use crate::validator::ValidatorVote;

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
#[serde(rename_all = "snake_case")]
pub enum TgradeQuery {
    /// Returns the current tendermint validator set, along with their voting status from last block
    ValidatorVotes {},
    /// Lists all contracts registered with the given privilege
    /// Returns ListPrivilegedResponse
    ListPrivileged(Privilege),
}

impl CustomQuery for TgradeQuery {}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct ValidatorVoteResponse {
    pub votes: Vec<ValidatorVote>,
}

impl Default for ValidatorVoteResponse {
    fn default() -> Self {
        ValidatorVoteResponse { votes: vec![] }
    }
}

#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
pub struct ListPrivilegedResponse {
    // we can guarantee correctly formatted addresses from the Go runtime, use Addr here
    pub privileged: Vec<Addr>,
}