Skip to content

Commit

Permalink
unified syntax - interactor env rename
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed May 20, 2024
1 parent fa616d3 commit 1e30e7d
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 50 deletions.
10 changes: 8 additions & 2 deletions framework/snippets/src/interactor_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ mod interactor_query_call;
mod interactor_query_env;
mod interactor_query_step;

pub use interactor_exec_env::InteractorExecEnv;
pub use interactor_exec_env::InteractorEnvExec;
pub use interactor_exec_step::InteractorExecStep;
pub use interactor_prepare_async::InteractorPrepareAsync;
pub use interactor_query_env::InteractorQueryEnv;
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>;
16 changes: 8 additions & 8 deletions framework/snippets/src/interactor_tx/interactor_exec_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ use multiversx_sc_scenario::{

use crate::Interactor;

use super::{InteractorExecEnv, InteractorExecStep, InteractorPrepareAsync};
use super::{InteractorEnvExec, InteractorExecStep, InteractorPrepareAsync};

impl<'w, From, To, Payment, Gas, RH> InteractorPrepareAsync
for Tx<InteractorExecEnv<'w>, From, To, Payment, Gas, FunctionCall<StaticApi>, RH>
for Tx<InteractorEnvExec<'w>, From, To, Payment, Gas, FunctionCall<StaticApi>, RH>
where
From: TxFromSpecified<InteractorExecEnv<'w>>,
To: TxToSpecified<InteractorExecEnv<'w>>,
Payment: TxPayment<InteractorExecEnv<'w>>,
Gas: TxGas<InteractorExecEnv<'w>>,
RH: RHListExec<TxResponse, InteractorExecEnv<'w>>,
From: TxFromSpecified<InteractorEnvExec<'w>>,
To: TxToSpecified<InteractorEnvExec<'w>>,
Payment: TxPayment<InteractorEnvExec<'w>>,
Gas: TxGas<InteractorEnvExec<'w>>,
RH: RHListExec<TxResponse, InteractorEnvExec<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
type Exec = InteractorExecStep<'w, ScCallStep, RH>;
Expand All @@ -37,7 +37,7 @@ where

impl<'w, RH> InteractorExecStep<'w, ScCallStep, RH>
where
RH: RHListExec<TxResponse, InteractorExecEnv<'w>>,
RH: RHListExec<TxResponse, InteractorEnvExec<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
pub async fn run(mut self) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked {
Expand Down
18 changes: 9 additions & 9 deletions framework/snippets/src/interactor_tx/interactor_exec_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,24 @@ use multiversx_sc_scenario::{

use crate::Interactor;

use super::{InteractorExecEnv, InteractorExecStep, InteractorPrepareAsync};
use super::{InteractorEnvExec, InteractorExecStep, InteractorPrepareAsync};

impl<'w, From, Payment, Gas, CodeValue, RH> InteractorPrepareAsync
for Tx<
InteractorExecEnv<'w>,
InteractorEnvExec<'w>,
From,
(),
Payment,
Gas,
DeployCall<InteractorExecEnv<'w>, Code<CodeValue>>,
DeployCall<InteractorEnvExec<'w>, Code<CodeValue>>,
RH,
>
where
From: TxFromSpecified<InteractorExecEnv<'w>>,
Payment: TxPayment<InteractorExecEnv<'w>>,
Gas: TxGas<InteractorExecEnv<'w>>,
CodeValue: TxCodeValue<InteractorExecEnv<'w>>,
RH: RHListExec<TxResponse, InteractorExecEnv<'w>>,
From: TxFromSpecified<InteractorEnvExec<'w>>,
Payment: TxPayment<InteractorEnvExec<'w>>,
Gas: TxGas<InteractorEnvExec<'w>>,
CodeValue: TxCodeValue<InteractorEnvExec<'w>>,
RH: RHListExec<TxResponse, InteractorEnvExec<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
type Exec = InteractorExecStep<'w, ScDeployStep, RH>;
Expand All @@ -44,7 +44,7 @@ where

impl<'w, RH> InteractorExecStep<'w, ScDeployStep, RH>
where
RH: RHListExec<TxResponse, InteractorExecEnv<'w>>,
RH: RHListExec<TxResponse, InteractorEnvExec<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
pub async fn run(mut self) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked {
Expand Down
10 changes: 5 additions & 5 deletions framework/snippets/src/interactor_tx/interactor_exec_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ use multiversx_sc_scenario::{
use crate::Interactor;

impl Interactor {
pub fn tx(&mut self) -> TxBaseWithEnv<InteractorExecEnv<'_>> {
pub fn tx(&mut self) -> TxBaseWithEnv<InteractorEnvExec<'_>> {
let data = self.new_env_data();
let env = InteractorExecEnv { world: self, data };
let env = InteractorEnvExec { world: self, data };
Tx::new_with_env(env)
}
}

/// Environment for executing transactions.
pub struct InteractorExecEnv<'w> {
pub struct InteractorEnvExec<'w> {
pub world: &'w mut Interactor,
pub data: ScenarioTxEnvData,
}

impl<'w> TxEnv for InteractorExecEnv<'w> {
impl<'w> TxEnv for InteractorEnvExec<'w> {
type Api = StaticApi;

type RHExpect = TxExpect;
Expand All @@ -39,7 +39,7 @@ impl<'w> TxEnv for InteractorExecEnv<'w> {
}
}

impl<'w> ScenarioTxEnv for InteractorExecEnv<'w> {
impl<'w> ScenarioTxEnv for InteractorEnvExec<'w> {
fn env_data(&self) -> &ScenarioTxEnvData {
&self.data
}
Expand Down
6 changes: 3 additions & 3 deletions framework/snippets/src/interactor_tx/interactor_exec_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use multiversx_sc_scenario::{
scenario_model::TxResponse,
};

use super::InteractorExecEnv;
use super::InteractorEnvExec;

pub struct InteractorExecStep<'w, Step, RH>
where
RH: RHListExec<TxResponse, InteractorExecEnv<'w>>,
RH: RHListExec<TxResponse, InteractorEnvExec<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
pub(crate) step_wrapper: StepWrapper<InteractorExecEnv<'w>, Step, RH>,
pub(crate) step_wrapper: StepWrapper<InteractorEnvExec<'w>, Step, RH>,
}
12 changes: 6 additions & 6 deletions framework/snippets/src/interactor_tx/interactor_exec_transf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use multiversx_sc_scenario::{
scenario_model::TransferStep,
};

use super::{InteractorExecEnv, InteractorExecStep, InteractorPrepareAsync};
use super::{InteractorEnvExec, InteractorExecStep, InteractorPrepareAsync};

impl<'w, From, To, Payment, Gas> InteractorPrepareAsync
for Tx<InteractorExecEnv<'w>, From, To, Payment, Gas, (), ()>
for Tx<InteractorEnvExec<'w>, From, To, Payment, Gas, (), ()>
where
From: TxFromSpecified<InteractorExecEnv<'w>>,
To: TxToSpecified<InteractorExecEnv<'w>>,
Payment: TxPayment<InteractorExecEnv<'w>>,
Gas: TxGas<InteractorExecEnv<'w>>,
From: TxFromSpecified<InteractorEnvExec<'w>>,
To: TxToSpecified<InteractorEnvExec<'w>>,
Payment: TxPayment<InteractorEnvExec<'w>>,
Gas: TxGas<InteractorEnvExec<'w>>,
{
type Exec = InteractorExecStep<'w, TransferStep, ()>;

Expand Down
12 changes: 6 additions & 6 deletions framework/snippets/src/interactor_tx/interactor_query_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ use multiversx_sc_scenario::{

use crate::Interactor;

use super::{InteractorPrepareAsync, InteractorQueryEnv, InteractorQueryStep};
use super::{InteractorEnvQuery, InteractorPrepareAsync, InteractorQueryStep};

impl<'w, To, Payment, RH> InteractorPrepareAsync
for Tx<InteractorQueryEnv<'w>, (), To, Payment, (), FunctionCall<StaticApi>, RH>
for Tx<InteractorEnvQuery<'w>, (), To, Payment, (), FunctionCall<StaticApi>, RH>
where
To: TxToSpecified<InteractorQueryEnv<'w>>,
Payment: TxNoPayment<InteractorQueryEnv<'w>>,
RH: RHListExec<TxResponse, InteractorQueryEnv<'w>>,
To: TxToSpecified<InteractorEnvQuery<'w>>,
Payment: TxNoPayment<InteractorEnvQuery<'w>>,
RH: RHListExec<TxResponse, InteractorEnvQuery<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
type Exec = InteractorQueryStep<'w, RH>;
Expand All @@ -32,7 +32,7 @@ where

impl<'w, RH> InteractorQueryStep<'w, RH>
where
RH: RHListExec<TxResponse, InteractorQueryEnv<'w>>,
RH: RHListExec<TxResponse, InteractorEnvQuery<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
pub async fn run(mut self) -> <RH::ListReturns as NestedTupleFlatten>::Unpacked {
Expand Down
10 changes: 5 additions & 5 deletions framework/snippets/src/interactor_tx/interactor_query_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ use multiversx_sc_scenario::{
use crate::Interactor;

impl Interactor {
pub fn query(&mut self) -> TxBaseWithEnv<InteractorQueryEnv<'_>> {
pub fn query(&mut self) -> TxBaseWithEnv<InteractorEnvQuery<'_>> {
let data = self.new_env_data();
let env = InteractorQueryEnv { world: self, data };
let env = InteractorEnvQuery { world: self, data };
Tx::new_with_env(env)
}
}

pub struct InteractorQueryEnv<'w> {
pub struct InteractorEnvQuery<'w> {
pub world: &'w mut Interactor,
pub data: ScenarioTxEnvData,
}

impl<'w> TxEnv for InteractorQueryEnv<'w> {
impl<'w> TxEnv for InteractorEnvQuery<'w> {
type Api = StaticApi;

type RHExpect = TxExpect;
Expand All @@ -38,7 +38,7 @@ impl<'w> TxEnv for InteractorQueryEnv<'w> {
}
}

impl<'w> ScenarioTxEnv for InteractorQueryEnv<'w> {
impl<'w> ScenarioTxEnv for InteractorEnvQuery<'w> {
fn env_data(&self) -> &ScenarioTxEnvData {
&self.data
}
Expand Down
6 changes: 3 additions & 3 deletions framework/snippets/src/interactor_tx/interactor_query_step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use multiversx_sc_scenario::{
scenario_model::{ScQueryStep, TxResponse},
};

use super::InteractorQueryEnv;
use super::InteractorEnvQuery;

pub struct InteractorQueryStep<'w, RH>
where
RH: RHListExec<TxResponse, InteractorQueryEnv<'w>>,
RH: RHListExec<TxResponse, InteractorEnvQuery<'w>>,
RH::ListReturns: NestedTupleFlatten,
{
pub(crate) step_wrapper: StepWrapper<InteractorQueryEnv<'w>, ScQueryStep, RH>,
pub(crate) step_wrapper: StepWrapper<InteractorEnvQuery<'w>, ScQueryStep, RH>,
}
6 changes: 3 additions & 3 deletions framework/snippets/src/multi/homogenous_tx_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use multiversx_sc_scenario::{
ScenarioTxEnvData,
};

use crate::{Interactor, InteractorExecEnv, InteractorStep, StepBuffer};
use crate::{Interactor, InteractorEnvExec, InteractorStep, StepBuffer};

pub struct HomogenousTxBuffer<'w, Step, RH> {
env: InteractorExecEnv<'w>,
env: InteractorEnvExec<'w>,
steps: Vec<StepWrapper<ScenarioTxEnvData, Step, RH>>,
}

Expand All @@ -22,7 +22,7 @@ impl Interactor {
/// Therefore, after execution, all results will have the same type.
pub fn homogenous_call_buffer<Step, RH>(&mut self) -> HomogenousTxBuffer<'_, Step, RH> {
let data = self.new_env_data();
let env = InteractorExecEnv { world: self, data };
let env = InteractorEnvExec { world: self, data };
HomogenousTxBuffer {
env,
steps: Vec::new(),
Expand Down

0 comments on commit 1e30e7d

Please sign in to comment.