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