Skip to main content

made_client/
execution_receipts.rs

1use made_proto::v1::{
2    ExecutionReceipt, GetExecutionReceiptRequest, InspectExecutionRecoveryRequest,
3    InspectExecutionRecoveryResponse,
4};
5
6use crate::{MadeClient, MadeClientError};
7
8impl MadeClient {
9    pub async fn get_execution_receipt(
10        &self,
11        operation_id: impl Into<String>,
12    ) -> Result<ExecutionReceipt, MadeClientError> {
13        let response = self
14            .rpc()
15            .get_execution_receipt(Self::request(
16                &self.context(),
17                "/underpass.made.v1.MadeService/GetExecutionReceipt",
18                GetExecutionReceiptRequest {
19                    operation_id: operation_id.into(),
20                },
21            ))
22            .await
23            .map_err(MadeClientError::from_status)?
24            .into_inner();
25        response.receipt.ok_or_else(|| {
26            MadeClientError::ProtocolViolation(
27                "get execution receipt response has no receipt".to_owned(),
28            )
29        })
30    }
31
32    pub async fn inspect_execution_recovery(
33        &self,
34        after: Option<String>,
35        limit: u32,
36    ) -> Result<InspectExecutionRecoveryResponse, MadeClientError> {
37        self.rpc()
38            .inspect_execution_recovery(Self::request(
39                &self.context(),
40                "/underpass.made.v1.MadeService/InspectExecutionRecovery",
41                InspectExecutionRecoveryRequest { after, limit },
42            ))
43            .await
44            .map(tonic::Response::into_inner)
45            .map_err(MadeClientError::from_status)
46    }
47}