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