multiversx_sdk/gateway/
gateway_tx_process_status.rs1use crate::data::transaction::TransactionProcessStatus;
2use anyhow::anyhow;
3
4use super::{GatewayRequest, GatewayRequestType};
5
6pub struct GetTxProcessStatus<'a> {
8 pub hash: &'a str,
9}
10
11impl<'a> GetTxProcessStatus<'a> {
12 pub fn new(hash: &'a str) -> Self {
13 Self { hash }
14 }
15}
16
17impl GatewayRequest for GetTxProcessStatus<'_> {
18 type Payload = ();
19 type DecodedJson = TransactionProcessStatus;
20 type Result = (String, String);
21
22 fn request_type(&self) -> GatewayRequestType {
23 GatewayRequestType::Get
24 }
25
26 fn get_endpoint(&self) -> String {
27 format!("transaction/{}/process-status", self.hash)
28 }
29
30 fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result<Self::Result> {
31 match decoded.data {
32 None => Err(anyhow!("{}", decoded.error)),
33 Some(b) => Ok((b.status, b.reason)),
34 }
35 }
36}