multiversx_sdk/gateway/
gateway_tx_cost.rs1use crate::data::transaction::{ResponseTxCost, Transaction, TxCostResponseData};
2use anyhow::anyhow;
3
4use super::{GatewayRequest, GatewayRequestType, COST_TRANSACTION_ENDPOINT};
5
6pub struct GetTxCost<'a>(pub &'a Transaction);
10
11impl GatewayRequest for GetTxCost<'_> {
12 type Payload = Transaction;
13 type DecodedJson = ResponseTxCost;
14 type Result = TxCostResponseData;
15
16 fn request_type(&self) -> GatewayRequestType {
17 GatewayRequestType::Post
18 }
19
20 fn get_payload(&self) -> Option<&Self::Payload> {
21 Some(self.0)
22 }
23
24 fn get_endpoint(&self) -> String {
25 COST_TRANSACTION_ENDPOINT.to_owned()
26 }
27
28 fn process_json(&self, decoded: Self::DecodedJson) -> anyhow::Result<Self::Result> {
29 match decoded.data {
30 None => Err(anyhow!("{}", decoded.error)),
31 Some(b) => Ok(b),
32 }
33 }
34}