multiversx_sc_scenario/scenario/model/step/
into_blockchain_call.rs1#![allow(deprecated)]
2
3use super::{ScCallStep, ScDeployStep, ScQueryStep, TypedScCall, TypedScDeploy, TypedScQuery};
4use crate::{
5 api::StaticApi,
6 multiversx_sc::{
7 codec::TopEncodeMulti,
8 types::{
9 ContractCall, ContractCallNoPayment, ContractCallWithEgld,
10 ContractCallWithEgldOrSingleEsdt, ContractCallWithMultiEsdt, ContractDeploy,
11 },
12 },
13};
14
15#[deprecated(
18 since = "0.42.0",
19 note = "The recommended syntax is a variation of `sc_call` or `sc_deploy` with a scenario step built from the ContractCall."
20)]
21pub trait IntoBlockchainCall {
22 type BlockchainCall;
23
24 #[deprecated(
25 since = "0.42.0",
26 note = "The recommended syntax is a variation of `sc_call` or `sc_deploy` with a scenario step built from the ContractCall."
27 )]
28 fn into_blockchain_call(self) -> Self::BlockchainCall;
29}
30
31macro_rules! impl_into_blockchain_call_cc {
34 ($cc:ident) => {
35 impl<OriginalResult> IntoBlockchainCall for $cc<StaticApi, OriginalResult>
36 where
37 OriginalResult: TopEncodeMulti,
38 {
39 type BlockchainCall = TypedScCall<OriginalResult>;
40
41 fn into_blockchain_call(self) -> Self::BlockchainCall {
42 ScCallStep::new().call(self).into()
43 }
44 }
45 };
46}
47
48impl_into_blockchain_call_cc! {ContractCallNoPayment}
49impl_into_blockchain_call_cc! {ContractCallWithEgld}
50impl_into_blockchain_call_cc! {ContractCallWithEgldOrSingleEsdt}
51impl_into_blockchain_call_cc! {ContractCallWithMultiEsdt}
52
53impl<OriginalResult> IntoBlockchainCall for ContractDeploy<StaticApi, OriginalResult> {
54 type BlockchainCall = TypedScDeploy<OriginalResult>;
55
56 fn into_blockchain_call(self) -> Self::BlockchainCall {
57 ScDeployStep::new().call(self)
58 }
59}
60
61pub trait IntoVMQuery {
63 type VMQuery;
64
65 fn into_vm_query(self) -> Self::VMQuery;
66}
67
68impl<CC> IntoVMQuery for CC
69where
70 CC: ContractCall<StaticApi>,
71{
72 type VMQuery = TypedScQuery<CC::OriginalResult>;
73 fn into_vm_query(self) -> Self::VMQuery {
74 ScQueryStep::default().call(self)
75 }
76}