use cosmwasm_std::{Binary, CosmosMsg, Deps, QueryRequest, StdResult};
use prost_types::Timestamp as TimestampGen;
use serde::de::DeserializeOwned;
pub fn make_stargate_query<Req, Res>(deps: Deps, path: &str, req: Req) -> StdResult<Res>
where
Req: prost::Message,
Res: DeserializeOwned,
{
deps.querier.query(&QueryRequest::Stargate {
path: path.to_string(),
data: req.encode_to_vec().into(),
})
}
pub fn create_stargate_msg<Req: prost::Message, T>(path: &str, req: Req) -> CosmosMsg<T> {
CosmosMsg::Stargate::<T> {
type_url: path.to_string(),
value: Binary::from(req.encode_to_vec()),
}
}
pub(crate) fn proto_timestamp_from_i64(timestamp: i64) -> TimestampGen {
TimestampGen {
seconds: timestamp,
nanos: 0,
}
}