From 82c51f6ac88fd3662a0f91a0cf19a717986e3470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Florkiewicz?= Date: Tue, 3 Dec 2024 11:26:22 +0100 Subject: [PATCH] fix(celestia-grpc-macros): Fix standalone build for celestia-grpc-macros, add CI (#470) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MikoĊ‚aj Florkiewicz Co-authored-by: Yiannis Marangos --- .github/workflows/ci.yml | 3 +++ grpc/grpc-macros/Cargo.toml | 8 +++++++- grpc/grpc-macros/README.md | 26 ++++++++++++++++++++++++++ grpc/grpc-macros/src/lib.rs | 26 +------------------------- 4 files changed, 37 insertions(+), 26 deletions(-) create mode 100644 grpc/grpc-macros/README.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58316918..4b58e09f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,9 @@ jobs: - name: Run clippy for native run: cargo clippy --all --all-targets -- -D warnings + - name: Run clippy for celestia-grpc-macros + run: cargo clippy -p celestia-grpc-macros --all-targets -- -D warnings + - name: Run clippy for wasm32 run: cargo clippy --all --all-targets --target=wasm32-unknown-unknown -- -D warnings diff --git a/grpc/grpc-macros/Cargo.toml b/grpc/grpc-macros/Cargo.toml index 31318038..2c94b255 100644 --- a/grpc/grpc-macros/Cargo.toml +++ b/grpc/grpc-macros/Cargo.toml @@ -2,10 +2,16 @@ name = "celestia-grpc-macros" version = "0.1.0" edition = "2021" +license = "Apache-2.0" +description = "Helper crate for grpc_method macro for creating gRPC client, used by celestia-grpc" +authors = ["Eiger "] +homepage = "https://www.eiger.co" +repository = "https://github.com/eigerco/lumina" +readme = "README.md" [dependencies] quote = "1.0.37" -syn = "2.0.87" +syn = { version = "2.0.87", features = ["full", "extra-traits"] } proc-macro2 = "1.0.89" [lib] diff --git a/grpc/grpc-macros/README.md b/grpc/grpc-macros/README.md new file mode 100644 index 00000000..a49ed2bc --- /dev/null +++ b/grpc/grpc-macros/README.md @@ -0,0 +1,26 @@ +Helper crate for grpc_method macro for creating a tonic gRPC client, used by [celestia-grpc](https://docs.rs/celestia-grpc/latest/celestia_grpc/). + +# Example + +```rust,ignore +use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient; +use tonic::service::Interceptor; +use tonic::transport::Channel; + +pub struct GrpcClient +where + I: Interceptor, +{ + grpc_channel: Channel, + auth_interceptor: I, +} + +impl GrpcClient +where + I: Interceptor + Clone, +{ + /// Get auth params + #[grpc_method(AuthQueryClient::params)] + async fn get_auth_params(&mut self) -> Result; +} +``` diff --git a/grpc/grpc-macros/src/lib.rs b/grpc/grpc-macros/src/lib.rs index f2656f2e..1f648dfa 100644 --- a/grpc/grpc-macros/src/lib.rs +++ b/grpc/grpc-macros/src/lib.rs @@ -1,28 +1,4 @@ -//! Helper crate for grpc_method macro for creating gRPC methods -//! -//! # Example -//! ```rust,ignore -//! use celestia_proto::cosmos::auth::v1beta1::query_client::QueryClient; -//! # use tonic::service::Interceptor; -//! # use tonic::transport::Channel; -//! # -//! # pub struct GrpcClient -//! # where -//! # I: Interceptor, -//! # { -//! # grpc_channel: Channel, -//! # auth_interceptor: I, -//! # } -//! -//! impl GrpcClient -//! where -//! I: Interceptor + Clone, -//! { -//! /// Get auth params -//! #[grpc_method(AuthQueryClient::params)] -//! async fn get_auth_params(&mut self) -> Result; -//! } -//! ``` +#![doc = include_str!("../README.md")] extern crate proc_macro;