Skip to content

Commit

Permalink
Add mint parameter requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jkilpatr committed Nov 21, 2024
1 parent 79e6f0a commit 633560c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deep_space"
version = "2.27.1"
version = "2.27.2"
authors = ["Justin Kilpatrick <[email protected]>", "Michał Papierski <[email protected]>"]
repository = "https://github.com/althea-net/deep_space"
description = "A highly portable, batteries included, transaction generation and key management library for CosmosSDK blockchains"
Expand Down
33 changes: 32 additions & 1 deletion src/client/mint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ use crate::error::CosmosGrpcError;
use crate::Contact;
use cosmos_sdk_proto::cosmos::mint::v1beta1::query_client::QueryClient as MintQueryClient;
use cosmos_sdk_proto::cosmos::mint::v1beta1::{
QueryAnnualProvisionsRequest, QueryInflationRequest,
Params as MintParms, QueryAnnualProvisionsRequest, QueryInflationRequest,
QueryParamsRequest as QueryMintParamsRequest,
};
use tokio::time::timeout;

Expand All @@ -13,6 +14,36 @@ use tokio::time::timeout;
const DEC_MANTISSA: f64 = 1_000_000_000_000_000_000.0;

impl Contact {
/// Returns the mint denom, or the native token on the chain
pub async fn get_mint_denom(&self) -> Result<String, CosmosGrpcError> {
let mut grpc = timeout(
self.get_timeout(),
MintQueryClient::connect(self.url.clone()),
)
.await??;

let res = timeout(self.get_timeout(), grpc.params(QueryMintParamsRequest {}))
.await??
.into_inner();

Ok(res.params.unwrap().mint_denom)
}

/// Returns the mint module parameters
pub async fn get_mint_params(&self) -> Result<MintParms, CosmosGrpcError> {
let mut grpc = timeout(
self.get_timeout(),
MintQueryClient::connect(self.url.clone()),
)
.await??;

let res = timeout(self.get_timeout(), grpc.params(QueryMintParamsRequest {}))
.await??
.into_inner();

Ok(res.params.unwrap())
}

/// Returns the inflation rate for the chain, in decimal format
pub async fn get_inflation(&self) -> Result<f64, CosmosGrpcError> {
let mut grpc = timeout(
Expand Down

0 comments on commit 633560c

Please sign in to comment.