multiversx_sc_scenario/facade/result_handlers/
with_tx_raw_response.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
use multiversx_sc::{
    codec::TopDecodeMulti,
    types::{RHListItem, RHListItemExec, TxEnv},
};

use crate::scenario_model::TxResponse;

/// Wraps a closure that handles a `TxResponse` object.
pub struct WithRawTxResponse<F>(pub F)
where
    F: FnOnce(&TxResponse);

impl<Env, Original, F> RHListItem<Env, Original> for WithRawTxResponse<F>
where
    Env: TxEnv,
    F: FnOnce(&TxResponse),
{
    type Returns = ();
}

impl<Env, Original, F> RHListItemExec<TxResponse, Env, Original> for WithRawTxResponse<F>
where
    Env: TxEnv,
    Original: TopDecodeMulti,
    F: FnOnce(&TxResponse),
{
    fn item_process_result(self, raw_result: &TxResponse) -> Self::Returns {
        (self.0)(raw_result)
    }
}