From 437281695bd34cab6c57007bc06799f27fdf86a1 Mon Sep 17 00:00:00 2001 From: Justin Kilpatrick Date: Tue, 16 Jul 2024 18:15:22 -0400 Subject: [PATCH] Add historical requests bump for v2.24.2 --- Cargo.toml | 2 +- src/client/mod.rs | 2 +- src/utils.rs | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 51c50ae..7cc0074 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "deep_space" -version = "2.24.1" +version = "2.24.2" authors = ["Justin Kilpatrick ", "MichaƂ Papierski "] repository = "https://github.com/althea-net/deep_space" description = "A highly portable, batteries included, transaction generation and key management library for CosmosSDK blockchains" diff --git a/src/client/mod.rs b/src/client/mod.rs index 61e8554..3fa5c82 100644 --- a/src/client/mod.rs +++ b/src/client/mod.rs @@ -89,7 +89,7 @@ mod tests { #[actix_rt::test] async fn test_endpoints() { env_logger::init(); - let contact = Contact::new("http://gravitychain.io:9090", TIMEOUT, "gravity").unwrap(); + let contact = Contact::new("https://gravitychain.io:9090", TIMEOUT, "gravity").unwrap(); let chain_status = contact.get_chain_status().await.unwrap(); match chain_status { diff --git a/src/utils.rs b/src/utils.rs index 0572124..1875d61 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -9,6 +9,22 @@ use std::fmt::Formatter; use std::fmt::Result as FmtResult; use std::time::Duration; use std::{str, usize}; +use tonic::metadata::AsciiMetadataValue; +use tonic::{IntoRequest, Request}; + +/// Converts a standard GRPC query Request struct into a historical one at the given `past_height` by adding +/// the "x-cosmos-block-height" gRPC metadata to the request +/// `req` should be a standard GRPC request like cosmos_sdk_proto_althea::cosmos::bank::v1beta1::QueryBalancesRequest +/// +/// Returns a Request with the set gRPC metadata +pub fn historical_grpc_query(req: impl IntoRequest, past_height: u64) -> Request { + let mut request = req.into_request(); + request.metadata_mut().insert( + "x-cosmos-block-height", + AsciiMetadataValue::from(past_height), + ); + request +} /// A function that takes a hexadecimal representation of bytes /// back into a stream of bytes.