From bd2bf9cc09f483caa46aca84a8087b0a9ef0e62a Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Thu, 11 Apr 2024 11:16:34 +0300 Subject: [PATCH] TxToStep refactor --- .../src/scenario/tx_to_step/tx_to_step_call.rs | 8 ++------ .../src/scenario/tx_to_step/tx_to_step_deploy.rs | 8 ++------ .../src/scenario/tx_to_step/tx_to_step_query.rs | 8 ++------ .../src/scenario/tx_to_step/tx_to_step_trait.rs | 12 ++++-------- .../src/scenario/tx_to_step/tx_to_step_transfer.rs | 8 ++------ framework/snippets/src/multi/homogenous_tx_buffer.rs | 2 +- 6 files changed, 13 insertions(+), 33 deletions(-) diff --git a/framework/scenario/src/scenario/tx_to_step/tx_to_step_call.rs b/framework/scenario/src/scenario/tx_to_step/tx_to_step_call.rs index dc4850b845..b155ac66df 100644 --- a/framework/scenario/src/scenario/tx_to_step/tx_to_step_call.rs +++ b/framework/scenario/src/scenario/tx_to_step/tx_to_step_call.rs @@ -6,7 +6,7 @@ use crate::scenario_model::{ScCallStep, TxExpect, TxResponse}; use super::{address_annotated, gas_annotated, StepWrapper, TxToStep}; -impl TxToStep +impl TxToStep for Tx, RH> where Env: TxEnv, @@ -16,13 +16,9 @@ where Gas: TxGas, RH: RHListExec, { - type Env = Env; - type Step = ScCallStep; - type RH = RH; - - fn tx_to_step(self) -> StepWrapper { + fn tx_to_step(self) -> StepWrapper { let mut step = tx_to_sc_call_step( &self.env, self.from, diff --git a/framework/scenario/src/scenario/tx_to_step/tx_to_step_deploy.rs b/framework/scenario/src/scenario/tx_to_step/tx_to_step_deploy.rs index 4378bbb682..3221de4b45 100644 --- a/framework/scenario/src/scenario/tx_to_step/tx_to_step_deploy.rs +++ b/framework/scenario/src/scenario/tx_to_step/tx_to_step_deploy.rs @@ -6,7 +6,7 @@ use crate::scenario_model::{ScDeployStep, TxExpect, TxResponse}; use super::{address_annotated, code_annotated, gas_annotated, StepWrapper, TxToStep}; -impl TxToStep +impl TxToStep for Tx>, RH> where Env: TxEnv, @@ -16,13 +16,9 @@ where CodeValue: TxCodeValue, RH: RHListExec, { - type Env = Env; - type Step = ScDeployStep; - type RH = RH; - - fn tx_to_step(self) -> StepWrapper { + fn tx_to_step(self) -> StepWrapper { let mut step = tx_to_sc_deploy_step(&self.env, self.from, self.payment, self.gas, self.data); step.expect = Some(self.result_handler.list_tx_expect()); diff --git a/framework/scenario/src/scenario/tx_to_step/tx_to_step_query.rs b/framework/scenario/src/scenario/tx_to_step/tx_to_step_query.rs index 427a8e62ce..9cfbb5d39e 100644 --- a/framework/scenario/src/scenario/tx_to_step/tx_to_step_query.rs +++ b/framework/scenario/src/scenario/tx_to_step/tx_to_step_query.rs @@ -4,19 +4,15 @@ use crate::scenario_model::{ScQueryStep, TxExpect, TxResponse}; use super::{address_annotated, StepWrapper, TxToQueryStep}; -impl TxToQueryStep for Tx, RH> +impl TxToQueryStep for Tx, RH> where Env: TxEnv, To: TxToSpecified, RH: RHListExec, { - type Env = Env; - type Step = ScQueryStep; - type RH = RH; - - fn tx_to_query_step(self) -> StepWrapper { + fn tx_to_query_step(self) -> StepWrapper { let mut step = tx_to_sc_query_step(&self.env, self.to, self.data); step.expect = Some(self.result_handler.list_tx_expect()); diff --git a/framework/scenario/src/scenario/tx_to_step/tx_to_step_trait.rs b/framework/scenario/src/scenario/tx_to_step/tx_to_step_trait.rs index 708e7c8eea..60615e6bb5 100644 --- a/framework/scenario/src/scenario/tx_to_step/tx_to_step_trait.rs +++ b/framework/scenario/src/scenario/tx_to_step/tx_to_step_trait.rs @@ -1,17 +1,13 @@ use super::StepWrapper; -pub trait TxToStep { - type Env; +pub trait TxToStep { type Step; - type RH; - fn tx_to_step(self) -> StepWrapper; + fn tx_to_step(self) -> StepWrapper; } -pub trait TxToQueryStep { - type Env; +pub trait TxToQueryStep { type Step; - type RH; - fn tx_to_query_step(self) -> StepWrapper; + fn tx_to_query_step(self) -> StepWrapper; } diff --git a/framework/scenario/src/scenario/tx_to_step/tx_to_step_transfer.rs b/framework/scenario/src/scenario/tx_to_step/tx_to_step_transfer.rs index c2f31e6ff4..637d840e4e 100644 --- a/framework/scenario/src/scenario/tx_to_step/tx_to_step_transfer.rs +++ b/framework/scenario/src/scenario/tx_to_step/tx_to_step_transfer.rs @@ -4,7 +4,7 @@ use crate::scenario_model::TransferStep; use super::{address_annotated, gas_annotated, StepWrapper, TxToStep}; -impl TxToStep for Tx +impl TxToStep for Tx where Env: TxEnv, From: TxFromSpecified, @@ -12,13 +12,9 @@ where Payment: TxPayment, Gas: TxGas, { - type Env = Env; - type Step = TransferStep; - type RH = (); - - fn tx_to_step(self) -> StepWrapper { + fn tx_to_step(self) -> StepWrapper { let step = tx_to_transfer_step(&self.env, self.from, self.to, self.payment, self.gas); StepWrapper { diff --git a/framework/snippets/src/multi/homogenous_tx_buffer.rs b/framework/snippets/src/multi/homogenous_tx_buffer.rs index 7d40474d59..da177d1658 100644 --- a/framework/snippets/src/multi/homogenous_tx_buffer.rs +++ b/framework/snippets/src/multi/homogenous_tx_buffer.rs @@ -38,7 +38,7 @@ where { pub fn push_tx(&mut self, f: F) -> &mut Self where - Tx: TxToStep, + Tx: TxToStep, F: FnOnce(TxBaseWithEnv) -> Tx, { let env = self.env.world.new_env_data();