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
54
55
56
use async_trait::async_trait;
use eyre::{Context, Result};
use tonic::transport::Channel;
use crate::cosmrs::proto::cosmos::slashing::v1beta1 as slashing;
use super::{GrpcClient, PageRequest, QueryClient};
pub type SlashingQueryClient = slashing::query_client::QueryClient<Channel>;
#[async_trait]
impl GrpcClient for SlashingQueryClient {
type ClientType = Self;
async fn make_client(endpoint: String) -> Result<Self::ClientType> {
SlashingQueryClient::connect(endpoint)
.await
.wrap_err("Failed to make gRPC connection")
}
}
impl QueryClient {
pub async fn slashing_params(&mut self) -> Result<slashing::QueryParamsResponse> {
let query_client = self.get_grpc_query_client::<SlashingQueryClient>().await?;
let request = slashing::QueryParamsRequest {};
Ok(query_client.params(request).await?.into_inner())
}
pub async fn signing_info(
&mut self,
cons_address: &str,
) -> Result<slashing::QuerySigningInfoResponse> {
let query_client = self.get_grpc_query_client::<SlashingQueryClient>().await?;
let request = slashing::QuerySigningInfoRequest {
cons_address: cons_address.to_string(),
};
Ok(query_client.signing_info(request).await?.into_inner())
}
pub async fn signing_infos(
&mut self,
pagination: Option<PageRequest>,
) -> Result<slashing::QuerySigningInfosResponse> {
let query_client = self.get_grpc_query_client::<SlashingQueryClient>().await?;
let request = slashing::QuerySigningInfosRequest { pagination };
Ok(query_client.signing_infos(request).await?.into_inner())
}
}