multiversx_sc_scenario/scenario/model/transaction/
tx_query.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use crate::{
    scenario::model::{AddressValue, BytesValue},
    scenario_format::{
        interpret_trait::{InterpretableFrom, InterpreterContext, IntoRaw},
        serde_raw::TxQueryRaw,
    },
};

#[derive(Debug, Default, Clone)]
pub struct TxQuery {
    pub to: AddressValue,
    pub function: String,
    pub arguments: Vec<BytesValue>,
}

impl InterpretableFrom<TxQueryRaw> for TxQuery {
    fn interpret_from(from: TxQueryRaw, context: &InterpreterContext) -> Self {
        TxQuery {
            to: AddressValue::interpret_from(from.to, context),
            function: from.function,
            arguments: from
                .arguments
                .into_iter()
                .map(|t| BytesValue::interpret_from(t, context))
                .collect(),
        }
    }
}

impl IntoRaw<TxQueryRaw> for TxQuery {
    fn into_raw(self) -> TxQueryRaw {
        TxQueryRaw {
            to: self.to.into_raw(),
            function: self.function,
            arguments: self
                .arguments
                .into_iter()
                .map(|arg| arg.into_raw())
                .collect(),
        }
    }
}