multiversx_sdk/gateway/
gateway_tx_status.rs1use crate::data::transaction::TransactionStatus;
2use anyhow::anyhow;
3
4use super::{GatewayRequest, GatewayRequestType};
5
6pub struct GetTxStatus<'a> {
8 pub hash: &'a str,
9}
10
11impl<'a> GetTxStatus<'a> {
12 pub fn new(hash: &'a str) -> Self {
13 Self { hash }
14 }
15}
16
17impl GatewayRequest for GetTxStatus<'_> {
18 type Payload = ();
19 type DecodedJson = TransactionStatus;
20 type Result = String;
21
22 fn request_type(&self) -> GatewayRequestType {
23 GatewayRequestType::Get
24 }
25
26 fn get_endpoint(&self) -> String {
27 format!("transaction/{}/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),
34 }
35 }
36}