bitbadges_cosmwasm/
query.rs

1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3
4use cosmwasm_std::CustomQuery;
5
6use crate::{AddressList, AnchorData, ApprovalTracker, BadgeCollection, Protocol, UserBalanceStore};
7
8// implement custom query
9impl CustomQuery for BitBadgesQuery {}
10
11
12/// BitBadgesQuery is defines available query datas
13#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
14#[serde(rename_all = "camelCase")]
15pub enum BitBadgesQuery {
16    // #[serde(rename_all = "camelCase")]
17    // QueryProtocol {
18    //   name: String,
19    // },
20
21    // #[serde(rename_all = "camelCase")]
22    // QueryCollectionIdForProtocol {
23    //   name: String,
24    //   address: String,
25    // },
26
27    #[serde(rename_all = "camelCase")]
28    QueryValueAtLocation {
29      location_id: String,
30    },
31
32    #[serde(rename_all = "camelCase")]
33    QueryCollection {
34      collection_id: String,
35    },
36    #[serde(rename_all = "camelCase")]
37    QueryBalance {
38      collection_id: String,
39      address: String,
40    },
41    #[serde(rename_all = "camelCase")]
42    QueryAddressList {
43      list_id: String,
44    },
45    #[serde(rename_all = "camelCase")]
46    QueryApprovalTracker {
47      collection_id: String,
48      approval_id: String,
49      approval_level: String,
50      approver_address: String,
51      amount_tracker_id: String,
52      tracker_type: String,
53      approved_address: String,
54    },
55    #[serde(rename_all = "camelCase")]
56    QueryChallengeTracker {
57      collection_id: String,
58      approval_id: String,
59      approval_level: String,
60      approver_address: String,
61      challenge_tracker_id: String,
62      leaf_index: String,
63    },
64
65}
66
67#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
68pub struct QueryValueAtLocationResponse {
69    pub anchor_data: AnchorData,
70}
71
72
73#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
74pub struct QueryGetProtocolResponse {
75    pub protocol: Protocol,
76}
77
78#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
79pub struct QueryGetCollectionIdForProtocolResponse {
80    pub collection_id: String, //Uint
81}
82
83#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
84pub struct QueryAddressByIdResponse {
85    pub address: String, //cosmos address
86}
87
88#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
89pub struct QueryGetCollectionResponse {
90    pub collection: BadgeCollection,
91}
92
93#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
94pub struct QueryGetBalanceResponse {
95    pub balance: UserBalanceStore,
96}
97#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
98pub struct QueryGetAddressListResponse {
99    pub list: AddressList,
100}
101
102#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
103pub struct QueryGetApprovalTrackerResponse {
104    pub tracker: ApprovalTracker,
105}
106
107#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
108pub struct QueryChallengeTrackerResponse {
109    pub num_used: String, //Uint
110}
111
112
113
114