multiversx_sc_scenario/facade/
whitebox_contract.rs

1use multiversx_sc::contract_base::{CallableContract, ContractBase};
2
3use crate::{scenario_model::AddressKey, DebugApi};
4
5/// Wraps a contract that is supposed to be used in whitebox tests.
6///
7/// For this reason it references the concrete SC type explicitly.
8pub struct WhiteboxContract<ContractObj>
9where
10    ContractObj: ContractBase<Api = DebugApi> + CallableContract + 'static,
11{
12    pub address_expr: AddressKey,
13    pub contract_obj_builder: fn() -> ContractObj,
14}
15
16impl<ContractObj> WhiteboxContract<ContractObj>
17where
18    ContractObj: ContractBase<Api = DebugApi> + CallableContract + 'static,
19{
20    pub fn new<A: Into<AddressKey>>(
21        address_expr: A,
22        contract_obj_builder: fn() -> ContractObj,
23    ) -> Self {
24        Self {
25            address_expr: address_expr.into(),
26            contract_obj_builder,
27        }
28    }
29}