multiversx_sc_scenario/facade/expr/
register_code_source.rs

1use multiversx_chain_scenario_format::value_interpreter::interpret_string;
2
3use crate::ScenarioTxEnvData;
4
5/// Used when registering a contract for debugging.
6///
7/// Any type that implements this trait can be passed to the `register_contract` method, and to its variants.
8pub trait RegisterCodeSource {
9    fn into_code(self, env_data: ScenarioTxEnvData) -> Vec<u8>;
10}
11
12impl RegisterCodeSource for &str {
13    fn into_code(self, env_data: ScenarioTxEnvData) -> Vec<u8> {
14        interpret_string(self, &env_data.interpreter_context())
15    }
16}
17
18impl RegisterCodeSource for String {
19    fn into_code(self, env_data: ScenarioTxEnvData) -> Vec<u8> {
20        self.as_str().into_code(env_data)
21    }
22}
23
24impl RegisterCodeSource for &String {
25    fn into_code(self, env_data: ScenarioTxEnvData) -> Vec<u8> {
26        self.as_str().into_code(env_data)
27    }
28}