Skip to content

Commit

Permalink
TxToStep refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Apr 11, 2024
1 parent fafe621 commit bd2bf9c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 33 deletions.
8 changes: 2 additions & 6 deletions framework/scenario/src/scenario/tx_to_step/tx_to_step_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::scenario_model::{ScCallStep, TxExpect, TxResponse};

use super::{address_annotated, gas_annotated, StepWrapper, TxToStep};

impl<Env, From, To, Payment, Gas, RH> TxToStep
impl<Env, From, To, Payment, Gas, RH> TxToStep<Env, RH>
for Tx<Env, From, To, Payment, Gas, FunctionCall<Env::Api>, RH>
where
Env: TxEnv<RHExpect = TxExpect>,
Expand All @@ -16,13 +16,9 @@ where
Gas: TxGas<Env>,
RH: RHListExec<TxResponse, Env>,
{
type Env = Env;

type Step = ScCallStep;

type RH = RH;

fn tx_to_step(self) -> StepWrapper<Self::Env, Self::Step, Self::RH> {
fn tx_to_step(self) -> StepWrapper<Env, Self::Step, RH> {
let mut step = tx_to_sc_call_step(
&self.env,
self.from,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::scenario_model::{ScDeployStep, TxExpect, TxResponse};

use super::{address_annotated, code_annotated, gas_annotated, StepWrapper, TxToStep};

impl<Env, From, Payment, Gas, CodeValue, RH> TxToStep
impl<Env, From, Payment, Gas, CodeValue, RH> TxToStep<Env, RH>
for Tx<Env, From, (), Payment, Gas, DeployCall<Env, Code<CodeValue>>, RH>
where
Env: TxEnv<RHExpect = TxExpect>,
Expand All @@ -16,13 +16,9 @@ where
CodeValue: TxCodeValue<Env>,
RH: RHListExec<TxResponse, Env>,
{
type Env = Env;

type Step = ScDeployStep;

type RH = RH;

fn tx_to_step(self) -> StepWrapper<Self::Env, Self::Step, Self::RH> {
fn tx_to_step(self) -> StepWrapper<Env, Self::Step, RH> {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@ use crate::scenario_model::{ScQueryStep, TxExpect, TxResponse};

use super::{address_annotated, StepWrapper, TxToQueryStep};

impl<Env, To, RH> TxToQueryStep for Tx<Env, (), To, (), (), FunctionCall<Env::Api>, RH>
impl<Env, To, RH> TxToQueryStep<Env, RH> for Tx<Env, (), To, (), (), FunctionCall<Env::Api>, RH>
where
Env: TxEnv<RHExpect = TxExpect>,
To: TxToSpecified<Env>,
RH: RHListExec<TxResponse, Env>,
{
type Env = Env;

type Step = ScQueryStep;

type RH = RH;

fn tx_to_query_step(self) -> StepWrapper<Self::Env, Self::Step, Self::RH> {
fn tx_to_query_step(self) -> StepWrapper<Env, Self::Step, RH> {
let mut step = tx_to_sc_query_step(&self.env, self.to, self.data);
step.expect = Some(self.result_handler.list_tx_expect());

Expand Down
12 changes: 4 additions & 8 deletions framework/scenario/src/scenario/tx_to_step/tx_to_step_trait.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
use super::StepWrapper;

pub trait TxToStep {
type Env;
pub trait TxToStep<Env, RH> {
type Step;
type RH;

fn tx_to_step(self) -> StepWrapper<Self::Env, Self::Step, Self::RH>;
fn tx_to_step(self) -> StepWrapper<Env, Self::Step, RH>;
}

pub trait TxToQueryStep {
type Env;
pub trait TxToQueryStep<Env, RH> {
type Step;
type RH;

fn tx_to_query_step(self) -> StepWrapper<Self::Env, Self::Step, Self::RH>;
fn tx_to_query_step(self) -> StepWrapper<Env, Self::Step, RH>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ use crate::scenario_model::TransferStep;

use super::{address_annotated, gas_annotated, StepWrapper, TxToStep};

impl<Env, From, To, Payment, Gas> TxToStep for Tx<Env, From, To, Payment, Gas, (), ()>
impl<Env, From, To, Payment, Gas> TxToStep<Env, ()> for Tx<Env, From, To, Payment, Gas, (), ()>
where
Env: TxEnv,
From: TxFromSpecified<Env>,
To: TxToSpecified<Env>,
Payment: TxPayment<Env>,
Gas: TxGas<Env>,
{
type Env = Env;

type Step = TransferStep;

type RH = ();

fn tx_to_step(self) -> StepWrapper<Self::Env, Self::Step, Self::RH> {
fn tx_to_step(self) -> StepWrapper<Env, Self::Step, ()> {
let step = tx_to_transfer_step(&self.env, self.from, self.to, self.payment, self.gas);

StepWrapper {
Expand Down
2 changes: 1 addition & 1 deletion framework/snippets/src/multi/homogenous_tx_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ where
{
pub fn push_tx<Tx, F>(&mut self, f: F) -> &mut Self
where
Tx: TxToStep<Env = ScenarioTxEnvData, Step = Step, RH = RH>,
Tx: TxToStep<ScenarioTxEnvData, RH, Step = Step>,
F: FnOnce(TxBaseWithEnv<ScenarioTxEnvData>) -> Tx,
{
let env = self.env.world.new_env_data();
Expand Down

0 comments on commit bd2bf9c

Please sign in to comment.