multiversx_sc_scenario/scenario/model/transaction/
tx_validator_reward.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
use crate::{
    scenario::model::{AddressValue, BigUintValue},
    scenario_format::{
        interpret_trait::{InterpretableFrom, InterpreterContext, IntoRaw},
        serde_raw::TxValidatorRewardRaw,
    },
};

use super::tx_interpret_util::interpret_egld_value;

#[derive(Debug, Clone)]
pub struct TxValidatorReward {
    pub to: AddressValue,
    pub egld_value: BigUintValue,
}

impl InterpretableFrom<TxValidatorRewardRaw> for TxValidatorReward {
    fn interpret_from(from: TxValidatorRewardRaw, context: &InterpreterContext) -> Self {
        TxValidatorReward {
            to: AddressValue::interpret_from(from.to, context),
            egld_value: interpret_egld_value(from.value, from.egld_value, context),
        }
    }
}

impl IntoRaw<TxValidatorRewardRaw> for TxValidatorReward {
    fn into_raw(self) -> TxValidatorRewardRaw {
        TxValidatorRewardRaw {
            to: self.to.into_raw(),
            value: None,
            egld_value: Some(self.egld_value.into_raw()),
        }
    }
}