Skip to content

Commit

Permalink
Merge pull request #2 from Philipp-Sc/main
Browse files Browse the repository at this point in the history
Merge upstream cosmos-rust
  • Loading branch information
Philipp-Sc authored Jul 27, 2022
2 parents 753f8d3 + 5935473 commit 06ab6b8
Show file tree
Hide file tree
Showing 52 changed files with 8,405 additions and 778 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cosmos-sdk-proto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- 1.57.0 # MSRV
- stable
target:
- x86_64-unknown-linux-gnu
Expand All @@ -43,7 +43,7 @@ jobs:
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- 1.57.0 # MSRV
- stable
steps:
- uses: actions/checkout@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cosmrs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- 1.57.0 # MSRV
- stable
target:
- x86_64-unknown-linux-gnu
Expand All @@ -44,7 +44,7 @@ jobs:
strategy:
matrix:
rust:
- 1.56.0 # MSRV
- 1.57.0 # MSRV
- stable
steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rebuild-protos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0 # MSRV
toolchain: 1.57.0 # MSRV
components: rustfmt
override: true
profile: minimal
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0 # MSRV
toolchain: 1.57.0 # MSRV
components: rustfmt
override: true
profile: minimal
Expand All @@ -35,7 +35,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.56.0 # MSRV
toolchain: 1.57.0 # MSRV
components: clippy
override: true
profile: minimal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ all other crates, simply make the required edits in [main.rs](proto-build/main.r

## Minimum Supported Rust Version

Rust **1.56**
Rust **1.57**

[//]: # "crates"

Expand Down
12 changes: 12 additions & 0 deletions cosmos-sdk-proto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.13.0 (2022-07-25)
### Added
- gRPC server definitions ([#249])
- Protobuf traits originally from `cosmrs` ([#255])

### Changed
- Bump `tendermint-proto` to v0.23.8 ([#253])

[#249]: https://github.com/cosmos/cosmos-rust/pull/249
[#253]: https://github.com/cosmos/cosmos-rust/pull/253
[#255]: https://github.com/cosmos/cosmos-rust/pull/255

## 0.12.3 (2022-06-09)
### Added
- Additional `cosmwasm` protos ([#240], [#244])
Expand Down
4 changes: 2 additions & 2 deletions cosmos-sdk-proto/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cosmos-sdk-proto"
version = "0.12.3"
version = "0.13.0"
authors = [
"Justin Kilpatrick <justin@althea.net>",
"Greg Szabo <greg@informal.systems>",
Expand All @@ -18,7 +18,7 @@ rust-version = "1.56"
[dependencies]
prost = "0.10"
prost-types = "0.10"
tendermint-proto = "=0.23.7"
tendermint-proto = "=0.23.8"

# Optional dependencies
tonic = { version = "0.7", optional = true, default-features = false, features = ["codegen", "prost"] }
Expand Down
5 changes: 5 additions & 0 deletions cosmos-sdk-proto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#![forbid(unsafe_code)]
#![warn(trivial_casts, trivial_numeric_casts, unused_import_braces)]

pub mod traits;
mod type_urls;

pub use prost;
pub use prost_types::Any;
pub use tendermint_proto as tendermint;

/// The version (commit hash) of the Cosmos SDK used when generating this library.
Expand Down
228 changes: 228 additions & 0 deletions cosmos-sdk-proto/src/prost/cosmos-sdk/cosmos.auth.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,234 @@ pub mod query_client {
}
}
}
/// Generated server implementations.
#[cfg(feature = "grpc")]
#[cfg_attr(docsrs, doc(cfg(feature = "grpc")))]
pub mod query_server {
#![allow(unused_variables, dead_code, missing_docs, clippy::let_unit_value)]
use tonic::codegen::*;
///Generated trait containing gRPC methods that should be implemented for use with QueryServer.
#[async_trait]
pub trait Query: Send + Sync + 'static {
/// Accounts returns all the existing accounts
///
/// Since: cosmos-sdk 0.43
async fn accounts(
&self,
request: tonic::Request<super::QueryAccountsRequest>,
) -> Result<tonic::Response<super::QueryAccountsResponse>, tonic::Status>;
/// Account returns account details based on address.
async fn account(
&self,
request: tonic::Request<super::QueryAccountRequest>,
) -> Result<tonic::Response<super::QueryAccountResponse>, tonic::Status>;
/// Params queries all parameters.
async fn params(
&self,
request: tonic::Request<super::QueryParamsRequest>,
) -> Result<tonic::Response<super::QueryParamsResponse>, tonic::Status>;
}
/// Query defines the gRPC querier service.
#[derive(Debug)]
pub struct QueryServer<T: Query> {
inner: _Inner<T>,
accept_compression_encodings: (),
send_compression_encodings: (),
}
struct _Inner<T>(Arc<T>);
impl<T: Query> QueryServer<T> {
pub fn new(inner: T) -> Self {
Self::from_arc(Arc::new(inner))
}
pub fn from_arc(inner: Arc<T>) -> Self {
let inner = _Inner(inner);
Self {
inner,
accept_compression_encodings: Default::default(),
send_compression_encodings: Default::default(),
}
}
pub fn with_interceptor<F>(
inner: T,
interceptor: F,
) -> InterceptedService<Self, F>
where
F: tonic::service::Interceptor,
{
InterceptedService::new(Self::new(inner), interceptor)
}
}
impl<T, B> tonic::codegen::Service<http::Request<B>> for QueryServer<T>
where
T: Query,
B: Body + Send + 'static,
B::Error: Into<StdError> + Send + 'static,
{
type Response = http::Response<tonic::body::BoxBody>;
type Error = std::convert::Infallible;
type Future = BoxFuture<Self::Response, Self::Error>;
fn poll_ready(
&mut self,
_cx: &mut Context<'_>,
) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
let inner = self.inner.clone();
match req.uri().path() {
"/cosmos.auth.v1beta1.Query/Accounts" => {
#[allow(non_camel_case_types)]
struct AccountsSvc<T: Query>(pub Arc<T>);
impl<
T: Query,
> tonic::server::UnaryService<super::QueryAccountsRequest>
for AccountsSvc<T> {
type Response = super::QueryAccountsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::QueryAccountsRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).accounts(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = AccountsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/cosmos.auth.v1beta1.Query/Account" => {
#[allow(non_camel_case_types)]
struct AccountSvc<T: Query>(pub Arc<T>);
impl<
T: Query,
> tonic::server::UnaryService<super::QueryAccountRequest>
for AccountSvc<T> {
type Response = super::QueryAccountResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::QueryAccountRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).account(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = AccountSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
"/cosmos.auth.v1beta1.Query/Params" => {
#[allow(non_camel_case_types)]
struct ParamsSvc<T: Query>(pub Arc<T>);
impl<T: Query> tonic::server::UnaryService<super::QueryParamsRequest>
for ParamsSvc<T> {
type Response = super::QueryParamsResponse;
type Future = BoxFuture<
tonic::Response<Self::Response>,
tonic::Status,
>;
fn call(
&mut self,
request: tonic::Request<super::QueryParamsRequest>,
) -> Self::Future {
let inner = self.0.clone();
let fut = async move { (*inner).params(request).await };
Box::pin(fut)
}
}
let accept_compression_encodings = self.accept_compression_encodings;
let send_compression_encodings = self.send_compression_encodings;
let inner = self.inner.clone();
let fut = async move {
let inner = inner.0;
let method = ParamsSvc(inner);
let codec = tonic::codec::ProstCodec::default();
let mut grpc = tonic::server::Grpc::new(codec)
.apply_compression_config(
accept_compression_encodings,
send_compression_encodings,
);
let res = grpc.unary(method, req).await;
Ok(res)
};
Box::pin(fut)
}
_ => {
Box::pin(async move {
Ok(
http::Response::builder()
.status(200)
.header("grpc-status", "12")
.header("content-type", "application/grpc")
.body(empty_body())
.unwrap(),
)
})
}
}
}
}
impl<T: Query> Clone for QueryServer<T> {
fn clone(&self) -> Self {
let inner = self.inner.clone();
Self {
inner,
accept_compression_encodings: self.accept_compression_encodings,
send_compression_encodings: self.send_compression_encodings,
}
}
}
impl<T: Query> Clone for _Inner<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T: std::fmt::Debug> std::fmt::Debug for _Inner<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.0)
}
}
#[cfg(feature = "grpc-transport")]
#[cfg_attr(docsrs, doc(cfg(feature = "grpc-transport")))]
impl<T: Query> tonic::transport::NamedService for QueryServer<T> {
const NAME: &'static str = "cosmos.auth.v1beta1.Query";
}
}
/// GenesisState defines the auth module's genesis state.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenesisState {
Expand Down
Loading

0 comments on commit 06ab6b8

Please sign in to comment.