Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TxToStep refactor #1554

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading