diff --git a/framework/snippets/src/interactor_tx.rs b/framework/snippets/src/interactor_tx.rs index 1075cc533f..0521300977 100644 --- a/framework/snippets/src/interactor_tx.rs +++ b/framework/snippets/src/interactor_tx.rs @@ -16,9 +16,3 @@ pub use interactor_exec_step::InteractorExecStep; pub use interactor_prepare_async::InteractorPrepareAsync; pub use interactor_query_env::InteractorEnvQuery; pub use interactor_query_step::InteractorQueryStep; - -#[deprecated(since = "0.50.2", note = "Renamed to InteractorExecEnv")] -pub type InteractorExecEnv<'a> = InteractorEnvExec<'a>; - -#[deprecated(since = "0.50.2", note = "Renamed to InteractorEnvQuery")] -pub type InteractorQueryEnv<'a> = InteractorEnvQuery<'a>; diff --git a/framework/snippets/src/interactor_tx/interactor_exec_call.rs b/framework/snippets/src/interactor_tx/interactor_exec_call.rs index e7c593c774..eadd122ed2 100644 --- a/framework/snippets/src/interactor_tx/interactor_exec_call.rs +++ b/framework/snippets/src/interactor_tx/interactor_exec_call.rs @@ -17,17 +17,18 @@ use crate::InteractorBase; use super::{InteractorEnvExec, InteractorExecStep, InteractorPrepareAsync}; -impl<'w, From, To, Payment, Gas, RH> InteractorPrepareAsync - for Tx, From, To, Payment, Gas, FunctionCall, RH> +impl<'w, GatewayProxy, From, To, Payment, Gas, RH> InteractorPrepareAsync + for Tx, From, To, Payment, Gas, FunctionCall, RH> where - From: TxFromSpecified>, - To: TxToSpecified>, - Payment: TxPayment>, - Gas: TxGas>, - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + From: TxFromSpecified>, + To: TxToSpecified>, + Payment: TxPayment>, + Gas: TxGas>, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { - type Exec = InteractorExecStep<'w, ScCallStep, RH>; + type Exec = InteractorExecStep<'w, GatewayProxy, ScCallStep, RH>; fn prepare_async(self) -> Self::Exec { InteractorExecStep { @@ -36,9 +37,10 @@ where } } -impl<'w, RH> InteractorExecStep<'w, ScCallStep, RH> +impl<'w, GatewayProxy, RH> InteractorExecStep<'w, GatewayProxy, ScCallStep, RH> where - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { pub async fn run(mut self) -> ::Unpacked { diff --git a/framework/snippets/src/interactor_tx/interactor_exec_deploy.rs b/framework/snippets/src/interactor_tx/interactor_exec_deploy.rs index a7872cdcec..142325e73a 100644 --- a/framework/snippets/src/interactor_tx/interactor_exec_deploy.rs +++ b/framework/snippets/src/interactor_tx/interactor_exec_deploy.rs @@ -16,25 +16,26 @@ use crate::InteractorBase; use super::{InteractorEnvExec, InteractorExecStep, InteractorPrepareAsync}; -impl<'w, From, Payment, Gas, CodeValue, RH> InteractorPrepareAsync +impl<'w, GatewayProxy, From, Payment, Gas, CodeValue, RH> InteractorPrepareAsync for Tx< - InteractorEnvExec<'w>, + InteractorEnvExec<'w, GatewayProxy>, From, (), Payment, Gas, - DeployCall, Code>, + DeployCall, Code>, RH, > where - From: TxFromSpecified>, - Payment: TxPayment>, - Gas: TxGas>, - CodeValue: TxCodeValue>, - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + From: TxFromSpecified>, + Payment: TxPayment>, + Gas: TxGas>, + CodeValue: TxCodeValue>, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { - type Exec = InteractorExecStep<'w, ScDeployStep, RH>; + type Exec = InteractorExecStep<'w, GatewayProxy, ScDeployStep, RH>; fn prepare_async(self) -> Self::Exec { InteractorExecStep { @@ -43,9 +44,10 @@ where } } -impl<'w, RH> InteractorExecStep<'w, ScDeployStep, RH> +impl<'w, GatewayProxy, RH> InteractorExecStep<'w, GatewayProxy, ScDeployStep, RH> where - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { pub async fn run(mut self) -> ::Unpacked { diff --git a/framework/snippets/src/interactor_tx/interactor_exec_env.rs b/framework/snippets/src/interactor_tx/interactor_exec_env.rs index e1148b8e82..c7987d28e6 100644 --- a/framework/snippets/src/interactor_tx/interactor_exec_env.rs +++ b/framework/snippets/src/interactor_tx/interactor_exec_env.rs @@ -7,12 +7,14 @@ use multiversx_sc_scenario::{ ScenarioTxEnv, ScenarioTxEnvData, }; use multiversx_sdk::gateway::GatewayAsyncService; -use multiversx_sdk_http::GatewayHttpProxy; use crate::InteractorBase; -impl InteractorBase { - pub fn tx(&mut self) -> TxBaseWithEnv> { +impl InteractorBase +where + GatewayProxy: GatewayAsyncService, +{ + pub fn tx(&mut self) -> TxBaseWithEnv> { let data = self.new_env_data(); let env = InteractorEnvExec { world: self, data }; Tx::new_with_env(env) @@ -20,12 +22,18 @@ impl InteractorBase { } /// Environment for executing transactions. -pub struct InteractorEnvExec<'w> { - pub world: &'w mut InteractorBase, +pub struct InteractorEnvExec<'w, GatewayProxy> +where + GatewayProxy: GatewayAsyncService, +{ + pub world: &'w mut InteractorBase, pub data: ScenarioTxEnvData, } -impl<'w> TxEnv for InteractorEnvExec<'w> { +impl<'w, GatewayProxy> TxEnv for InteractorEnvExec<'w, GatewayProxy> +where + GatewayProxy: GatewayAsyncService, +{ type Api = StaticApi; type RHExpect = TxExpect; @@ -43,13 +51,19 @@ impl<'w> TxEnv for InteractorEnvExec<'w> { } } -impl<'w> ScenarioTxEnv for InteractorEnvExec<'w> { +impl<'w, GatewayProxy> ScenarioTxEnv for InteractorEnvExec<'w, GatewayProxy> +where + GatewayProxy: GatewayAsyncService, +{ fn env_data(&self) -> &ScenarioTxEnvData { &self.data } } -impl<'w> TxEnvWithTxHash for InteractorEnvExec<'w> { +impl<'w, GatewayProxy> TxEnvWithTxHash for InteractorEnvExec<'w, GatewayProxy> +where + GatewayProxy: GatewayAsyncService, +{ fn set_tx_hash(&mut self, tx_hash: H256) { self.data.set_tx_hash(tx_hash); } diff --git a/framework/snippets/src/interactor_tx/interactor_exec_step.rs b/framework/snippets/src/interactor_tx/interactor_exec_step.rs index 1d4eabf54d..0ef9666bf8 100644 --- a/framework/snippets/src/interactor_tx/interactor_exec_step.rs +++ b/framework/snippets/src/interactor_tx/interactor_exec_step.rs @@ -3,13 +3,15 @@ use multiversx_sc_scenario::{ scenario::tx_to_step::StepWrapper, scenario_model::TxResponse, }; +use multiversx_sdk::gateway::GatewayAsyncService; use super::InteractorEnvExec; -pub struct InteractorExecStep<'w, Step, RH> +pub struct InteractorExecStep<'w, GatewayProxy, Step, RH> where - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { - pub(crate) step_wrapper: StepWrapper, Step, RH>, + pub(crate) step_wrapper: StepWrapper, Step, RH>, } diff --git a/framework/snippets/src/interactor_tx/interactor_exec_transf.rs b/framework/snippets/src/interactor_tx/interactor_exec_transf.rs index 3ec04c0b05..bef6fb8032 100644 --- a/framework/snippets/src/interactor_tx/interactor_exec_transf.rs +++ b/framework/snippets/src/interactor_tx/interactor_exec_transf.rs @@ -3,18 +3,20 @@ use multiversx_sc_scenario::{ scenario::tx_to_step::TxToStep, scenario_model::TransferStep, }; +use multiversx_sdk::gateway::GatewayAsyncService; use super::{InteractorEnvExec, InteractorExecStep, InteractorPrepareAsync}; -impl<'w, From, To, Payment, Gas> InteractorPrepareAsync - for Tx, From, To, Payment, Gas, (), ()> +impl<'w, GatewayProxy, From, To, Payment, Gas> InteractorPrepareAsync + for Tx, From, To, Payment, Gas, (), ()> where - From: TxFromSpecified>, - To: TxToSpecified>, - Payment: TxPayment>, - Gas: TxGas>, + GatewayProxy: GatewayAsyncService, + From: TxFromSpecified>, + To: TxToSpecified>, + Payment: TxPayment>, + Gas: TxGas>, { - type Exec = InteractorExecStep<'w, TransferStep, ()>; + type Exec = InteractorExecStep<'w, GatewayProxy, TransferStep, ()>; fn prepare_async(self) -> Self::Exec { InteractorExecStep { @@ -23,7 +25,10 @@ where } } -impl<'w> InteractorExecStep<'w, TransferStep, ()> { +impl<'w, GatewayProxy> InteractorExecStep<'w, GatewayProxy, TransferStep, ()> +where + GatewayProxy: GatewayAsyncService, +{ pub async fn run(self) { self.step_wrapper .env diff --git a/framework/snippets/src/interactor_tx/interactor_exec_upgrade.rs b/framework/snippets/src/interactor_tx/interactor_exec_upgrade.rs index 0f4bb6882e..a99b5e3131 100644 --- a/framework/snippets/src/interactor_tx/interactor_exec_upgrade.rs +++ b/framework/snippets/src/interactor_tx/interactor_exec_upgrade.rs @@ -11,30 +11,32 @@ use multiversx_sc_scenario::{ scenario_model::{ScDeployStep, TxResponse}, ScenarioTxEnvData, }; +use multiversx_sdk::gateway::GatewayAsyncService; use crate::InteractorBase; use super::{InteractorEnvExec, InteractorExecStep, InteractorPrepareAsync}; -impl<'w, From, To, Gas, CodeValue, RH> InteractorPrepareAsync +impl<'w, GatewayProxy, From, To, Gas, CodeValue, RH> InteractorPrepareAsync for Tx< - InteractorEnvExec<'w>, + InteractorEnvExec<'w, GatewayProxy>, From, To, NotPayable, Gas, - UpgradeCall, Code>, + UpgradeCall, Code>, RH, > where - From: TxFromSpecified>, - To: TxToSpecified>, - Gas: TxGas>, - CodeValue: TxCodeValue>, - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + From: TxFromSpecified>, + To: TxToSpecified>, + Gas: TxGas>, + CodeValue: TxCodeValue>, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { - type Exec = InteractorExecStep<'w, ScCallStep, RH>; + type Exec = InteractorExecStep<'w, GatewayProxy, ScCallStep, RH>; fn prepare_async(self) -> Self::Exec { InteractorExecStep { @@ -43,27 +45,29 @@ where } } -impl<'w, From, To, Gas, RH, CodeValue> TxToStep, RH> +impl<'w, GatewayProxy, From, To, Gas, RH, CodeValue> + TxToStep, RH> for Tx< - InteractorEnvExec<'w>, + InteractorEnvExec<'w, GatewayProxy>, From, To, NotPayable, Gas, - UpgradeCall, Code>, + UpgradeCall, Code>, RH, > where - From: TxFromSpecified>, - To: TxToSpecified>, - Gas: TxGas>, - CodeValue: TxCodeValue>, - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + From: TxFromSpecified>, + To: TxToSpecified>, + Gas: TxGas>, + CodeValue: TxCodeValue>, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { type Step = ScCallStep; - fn tx_to_step(self) -> StepWrapper, Self::Step, RH> { + fn tx_to_step(self) -> StepWrapper, Self::Step, RH> { let mut step = tx_to_sc_call_upgrade_step(&self.env, self.from, self.to, self.gas, self.data); step.expect = Some(self.result_handler.list_tx_expect()); @@ -76,18 +80,19 @@ where } } -pub fn tx_to_sc_call_upgrade_step<'a, 'w: 'a, From, To, Gas, CodeValue>( - env: &'a InteractorEnvExec<'w>, +pub fn tx_to_sc_call_upgrade_step<'a, 'w: 'a, GatewayProxy, From, To, Gas, CodeValue>( + env: &'a InteractorEnvExec<'w, GatewayProxy>, from: From, to: To, gas: Gas, - data: UpgradeCall, Code>, + data: UpgradeCall, Code>, ) -> ScCallStep where - From: TxFromSpecified>, - To: TxToSpecified>, - Gas: TxGas>, - CodeValue: TxCodeValue>, + GatewayProxy: GatewayAsyncService, + From: TxFromSpecified>, + To: TxToSpecified>, + Gas: TxGas>, + CodeValue: TxCodeValue>, { let mut step = ScCallStep::new() .from(address_annotated(env, &from)) diff --git a/framework/snippets/src/interactor_tx/interactor_query_call.rs b/framework/snippets/src/interactor_tx/interactor_query_call.rs index df84ad0acc..6491a1e34d 100644 --- a/framework/snippets/src/interactor_tx/interactor_query_call.rs +++ b/framework/snippets/src/interactor_tx/interactor_query_call.rs @@ -14,15 +14,16 @@ use crate::InteractorBase; use super::{InteractorEnvQuery, InteractorPrepareAsync, InteractorQueryStep}; -impl<'w, To, Payment, RH> InteractorPrepareAsync - for Tx, (), To, Payment, (), FunctionCall, RH> +impl<'w, GatewayProxy, To, Payment, RH> InteractorPrepareAsync + for Tx, (), To, Payment, (), FunctionCall, RH> where - To: TxToSpecified>, - Payment: TxNoPayment>, - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + To: TxToSpecified>, + Payment: TxNoPayment>, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { - type Exec = InteractorQueryStep<'w, RH>; + type Exec = InteractorQueryStep<'w, GatewayProxy, RH>; fn prepare_async(self) -> Self::Exec { InteractorQueryStep { @@ -31,9 +32,10 @@ where } } -impl<'w, RH> InteractorQueryStep<'w, RH> +impl<'w, GatewayProxy, RH> InteractorQueryStep<'w, GatewayProxy, RH> where - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { pub async fn run(mut self) -> ::Unpacked { diff --git a/framework/snippets/src/interactor_tx/interactor_query_env.rs b/framework/snippets/src/interactor_tx/interactor_query_env.rs index 42c9bb5f8f..25d0b5e822 100644 --- a/framework/snippets/src/interactor_tx/interactor_query_env.rs +++ b/framework/snippets/src/interactor_tx/interactor_query_env.rs @@ -5,24 +5,32 @@ use multiversx_sc_scenario::{ ScenarioTxEnv, ScenarioTxEnvData, }; use multiversx_sdk::gateway::GatewayAsyncService; -use multiversx_sdk_http::GatewayHttpProxy; use crate::InteractorBase; -impl InteractorBase { - pub fn query(&mut self) -> TxBaseWithEnv> { +impl InteractorBase +where + GatewayProxy: GatewayAsyncService, +{ + pub fn query(&mut self) -> TxBaseWithEnv> { let data = self.new_env_data(); let env = InteractorEnvQuery { world: self, data }; Tx::new_with_env(env) } } -pub struct InteractorEnvQuery<'w> { - pub world: &'w mut InteractorBase, +pub struct InteractorEnvQuery<'w, GatewayProxy> +where + GatewayProxy: GatewayAsyncService, +{ + pub world: &'w mut InteractorBase, pub data: ScenarioTxEnvData, } -impl<'w> TxEnv for InteractorEnvQuery<'w> { +impl<'w, GatewayProxy> TxEnv for InteractorEnvQuery<'w, GatewayProxy> +where + GatewayProxy: GatewayAsyncService, +{ type Api = StaticApi; type RHExpect = TxExpect; @@ -40,7 +48,10 @@ impl<'w> TxEnv for InteractorEnvQuery<'w> { } } -impl<'w> ScenarioTxEnv for InteractorEnvQuery<'w> { +impl<'w, GatewayProxy> ScenarioTxEnv for InteractorEnvQuery<'w, GatewayProxy> +where + GatewayProxy: GatewayAsyncService, +{ fn env_data(&self) -> &ScenarioTxEnvData { &self.data } diff --git a/framework/snippets/src/interactor_tx/interactor_query_step.rs b/framework/snippets/src/interactor_tx/interactor_query_step.rs index bbb7a0996b..ae4645ff3a 100644 --- a/framework/snippets/src/interactor_tx/interactor_query_step.rs +++ b/framework/snippets/src/interactor_tx/interactor_query_step.rs @@ -3,13 +3,15 @@ use multiversx_sc_scenario::{ scenario::tx_to_step::StepWrapper, scenario_model::{ScQueryStep, TxResponse}, }; +use multiversx_sdk::gateway::GatewayAsyncService; use super::InteractorEnvQuery; -pub struct InteractorQueryStep<'w, RH> +pub struct InteractorQueryStep<'w, GatewayProxy, RH> where - RH: RHListExec>, + GatewayProxy: GatewayAsyncService, + RH: RHListExec>, RH::ListReturns: NestedTupleFlatten, { - pub(crate) step_wrapper: StepWrapper, ScQueryStep, RH>, + pub(crate) step_wrapper: StepWrapper, ScQueryStep, RH>, } diff --git a/framework/snippets/src/multi/homogenous_tx_buffer.rs b/framework/snippets/src/multi/homogenous_tx_buffer.rs index b9afa69e1b..4ee43ab81a 100644 --- a/framework/snippets/src/multi/homogenous_tx_buffer.rs +++ b/framework/snippets/src/multi/homogenous_tx_buffer.rs @@ -7,21 +7,29 @@ use multiversx_sc_scenario::{ scenario_model::TxResponse, ScenarioTxEnvData, }; -use multiversx_sdk_http::GatewayHttpProxy; +use multiversx_sdk::gateway::GatewayAsyncService; use crate::{InteractorBase, InteractorEnvExec, InteractorStep, StepBuffer}; -pub struct HomogenousTxBuffer<'w, Step, RH> { - env: InteractorEnvExec<'w>, +pub struct HomogenousTxBuffer<'w, GatewayProxy, Step, RH> +where + GatewayProxy: GatewayAsyncService, +{ + env: InteractorEnvExec<'w, GatewayProxy>, steps: Vec>, } -impl InteractorBase { +impl InteractorBase +where + GatewayProxy: GatewayAsyncService, +{ /// Creates a buffer that can hold multiple transactions, and then execute them all at once. /// /// This buffer holds transactions of the same type (call/deploy) and with identical result handler types. /// Therefore, after execution, all results will have the same type. - pub fn homogenous_call_buffer(&mut self) -> HomogenousTxBuffer<'_, Step, RH> { + pub fn homogenous_call_buffer( + &mut self, + ) -> HomogenousTxBuffer<'_, GatewayProxy, Step, RH> { let data = self.new_env_data(); let env = InteractorEnvExec { world: self, data }; HomogenousTxBuffer { @@ -31,8 +39,9 @@ impl InteractorBase { } } -impl<'w, Step, RH> HomogenousTxBuffer<'w, Step, RH> +impl<'w, GatewayProxy, Step, RH> HomogenousTxBuffer<'w, GatewayProxy, Step, RH> where + GatewayProxy: GatewayAsyncService, Step: InteractorStep, RH: RHListExec, RH::ListReturns: NestedTupleFlatten,