tg3/
query.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use crate::msg::Vote;
5
6#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
7#[serde(rename_all = "snake_case")]
8pub enum Tg3QueryMsg {
9    /// Returns the threshold rules that would be used for a new proposal that was
10    /// opened right now. The threshold rules do not change often, but the `total_points`
11    /// in the response may easily differ from that used in previously opened proposals.
12    /// Returns ThresholdResponse.
13    Threshold {},
14    /// Returns details of the proposal state. Returns ProposalResponse.
15    Proposal { proposal_id: u64 },
16    /// Iterate over details of all proposals from oldest to newest. Returns ProposalListResponse
17    ListProposals {
18        start_after: Option<u64>,
19        limit: Option<u32>,
20    },
21    /// Iterate reverse over details of all proposals, this is useful to easily query
22    /// only the most recent proposals (to get updates). Returns ProposalListResponse
23    ReverseProposals {
24        start_before: Option<u64>,
25        limit: Option<u32>,
26    },
27    /// Query the vote made by the given voter on `proposal_id`. This should
28    /// return an error if there is no such proposal. It will return a None value
29    /// if the proposal exists but the voter did not vote. Returns VoteResponse
30    Vote { proposal_id: u64, voter: String },
31    /// Iterate (with pagination) over all votes for this proposal. The ordering is arbitrary,
32    /// unlikely to be sorted by address. But ordering is consistent and pagination from the end
33    /// of each page will cover all votes for the proposal. Returns VoteListResponse
34    ListVotes {
35        proposal_id: u64,
36        start_after: Option<String>,
37        limit: Option<u32>,
38    },
39    /// Voter extension: Returns VoterResponse
40    Voter { address: String },
41    /// ListVoters extension: Returns VoterListResponse
42    ListVoters {
43        start_after: Option<String>,
44        limit: Option<u32>,
45    },
46}
47
48#[derive(Serialize, Deserialize, Clone, Copy, PartialEq, Eq, JsonSchema, Debug)]
49#[serde(rename_all = "lowercase")]
50#[repr(u8)]
51pub enum Status {
52    /// proposal was created, but voting has not yet begun for whatever reason
53    Pending = 1,
54    /// you can vote on this
55    Open = 2,
56    /// voting is over and it did not pass
57    Rejected = 3,
58    /// voting is over and it did pass, but has not yet executed
59    Passed = 4,
60    /// voting is over it passed, and the proposal was executed
61    Executed = 5,
62}
63
64#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
65pub struct VoteListResponse {
66    pub votes: Vec<VoteInfo>,
67}
68
69/// Returns the vote (opinion as well as points counted) as well as
70/// the address of the voter who submitted it
71#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
72pub struct VoteInfo {
73    pub proposal_id: u64,
74    pub voter: String,
75    pub vote: Vote,
76    pub points: u64,
77}
78
79#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
80pub struct VoteResponse {
81    pub vote: Option<VoteInfo>,
82}
83
84#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
85pub struct VoterResponse {
86    pub points: Option<u64>,
87}
88
89#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
90pub struct VoterListResponse {
91    pub voters: Vec<VoterDetail>,
92}
93
94#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
95pub struct VoterDetail {
96    pub addr: String,
97    pub points: u64,
98}