Skip to content

Commit

Permalink
Merge pull request #1566 from multiversx/tx-to-step
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaicalinluca authored Apr 16, 2024
2 parents 47ce977 + df8b61a commit 6665b7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
14 changes: 14 additions & 0 deletions framework/scenario/src/scenario/model/transaction/tx_esdt.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use multiversx_sc::{api::ManagedTypeApi, types::EsdtTokenPayment};

use crate::{
scenario::model::{BigUintValue, BytesValue, U64Value},
scenario_format::{
Expand Down Expand Up @@ -33,6 +35,18 @@ impl IntoRaw<TxESDTRaw> for TxESDT {
}
}

impl<M: ManagedTypeApi> From<EsdtTokenPayment<M>> for TxESDT {
fn from(value: EsdtTokenPayment<M>) -> Self {
TxESDT {
esdt_token_identifier: BytesValue::from(
value.token_identifier.as_managed_buffer().to_vec(),
),
nonce: U64Value::from(value.token_nonce),
esdt_value: BigUintValue::from(value.amount),
}
}
}

fn interpret_esdt_token_identifier(
esdt_token_identifier: Option<ValueSubTree>,
context: &InterpreterContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use multiversx_sc::types::{
FunctionCall, RHListExec, Tx, TxEnv, TxFromSpecified, TxGas, TxPayment, TxToSpecified,
};

use crate::scenario_model::{ScCallStep, TxExpect, TxResponse};
use crate::scenario_model::{ScCallStep, TxESDT, TxExpect, TxResponse};

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

Expand Down Expand Up @@ -65,6 +65,12 @@ where
let full_payment_data = payment.into_full_payment_data(env);
if let Some(annotated_egld_payment) = full_payment_data.egld {
step.tx.egld_value = annotated_egld_payment.into();
} else {
step.tx.esdt_value = full_payment_data
.multi_esdt
.iter()
.map(TxESDT::from)
.collect();
}

step
Expand Down

0 comments on commit 6665b7c

Please sign in to comment.