eq_sdk/
lib.rs

1pub use eq_common::eqs::inclusion_client::InclusionClient;
2pub use eq_common::eqs::{
3    get_keccak_inclusion_response, GetKeccakInclusionRequest, GetKeccakInclusionResponse,
4};
5use tonic::transport::Channel;
6use tonic::Status as TonicStatus;
7
8pub mod types;
9pub use types::BlobId;
10
11#[derive(Debug)]
12pub struct EqClient {
13    grpc_channel: Channel,
14}
15
16impl EqClient {
17    pub fn new(grpc_channel: Channel) -> Self {
18        Self { grpc_channel }
19    }
20    pub fn get_keccak_inclusion<'a>(
21        &'a self,
22        request: &'a BlobId,
23    ) -> impl std::future::Future<Output = Result<GetKeccakInclusionResponse, TonicStatus>> + Send + 'a
24    where
25        Self: Sync,
26    {
27        async {
28            let request = GetKeccakInclusionRequest {
29                commitment: request.commitment.hash().to_vec(),
30                namespace: request
31                    .namespace
32                    .id_v0()
33                    .ok_or(TonicStatus::invalid_argument("Namespace invalid"))?
34                    .to_vec(),
35                height: request.height.into(),
36            };
37            let mut client = InclusionClient::new(self.grpc_channel.clone());
38            match client.get_keccak_inclusion(request).await {
39                Ok(response) => Ok(response.into_inner()),
40                Err(e) => Err(e),
41            }
42        }
43    }
44}