diff --git a/framework/base/src/contract_base/wrappers/send_wrapper.rs b/framework/base/src/contract_base/wrappers/send_wrapper.rs
index 62f99b767c..d73074f52d 100644
--- a/framework/base/src/contract_base/wrappers/send_wrapper.rs
+++ b/framework/base/src/contract_base/wrappers/send_wrapper.rs
@@ -75,7 +75,7 @@ where
/// Used especially for sending EGLD to regular accounts.
#[inline]
pub fn direct_egld(&self, to: &ManagedAddress, amount: &BigUint) {
- self.send_raw_wrapper().direct_egld(to, amount, Empty)
+ Tx::new_tx_from_sc().to(to).egld(amount).transfer();
}
/// Sends EGLD to a given address, directly.
@@ -83,11 +83,7 @@ where
///
/// If the amount is 0, it returns without error.
pub fn direct_non_zero_egld(&self, to: &ManagedAddress, amount: &BigUint) {
- if amount == &0 {
- return;
- }
-
- self.direct_egld(to, amount)
+ Tx::new_tx_from_sc().to(to).egld(amount).transfer_non_zero();
}
/// Sends either EGLD, ESDT or NFT to the target address,
@@ -291,13 +287,10 @@ where
to: &ManagedAddress,
payments: &ManagedVec>,
) {
- let _ = self.send_raw_wrapper().multi_esdt_transfer_execute(
- to,
- payments,
- 0,
- &ManagedBuffer::new(),
- &ManagedArgBuffer::new(),
- );
+ Tx::new_tx_from_sc()
+ .to(to)
+ .multi_esdt_ref(payments)
+ .transfer();
}
/// Performs a simple ESDT/NFT transfer, but via async call.
diff --git a/framework/base/src/types/interaction/tx.rs b/framework/base/src/types/interaction/tx.rs
index 8fae065026..d7388dc250 100644
--- a/framework/base/src/types/interaction/tx.rs
+++ b/framework/base/src/types/interaction/tx.rs
@@ -220,6 +220,22 @@ where
}
}
+ /// Sets a reference to multiple ESDT payments.
+ pub fn multi_esdt_ref(
+ self,
+ payments: &MultiEsdtPayment,
+ ) -> Tx, Gas, Data, RH> {
+ Tx {
+ env: self.env,
+ from: self.from,
+ to: self.to,
+ payment: payments,
+ gas: self.gas,
+ data: self.data,
+ result_handler: self.result_handler,
+ }
+ }
+
/// Backwards compatibility.
pub fn with_multi_token_transfer(
self,
diff --git a/framework/base/src/types/interaction/tx_call_te.rs b/framework/base/src/types/interaction/tx_call_te.rs
index 96eb1a72fb..938a6c2523 100644
--- a/framework/base/src/types/interaction/tx_call_te.rs
+++ b/framework/base/src/types/interaction/tx_call_te.rs
@@ -50,11 +50,14 @@ where
self.transfer_execute_with_gas(0)
}
+ /// Transfers funds, amount is greater than zero. Does nothing otherwise.
+ ///
+ /// Can only used for simple transfers.
pub fn transfer_non_zero(self) {
if self.payment.is_no_payment() {
return;
}
- self.transfer_execute_with_gas(0)
+ self.transfer();
}
}
diff --git a/framework/base/src/types/interaction/tx_payment.rs b/framework/base/src/types/interaction/tx_payment.rs
index beca0172f0..c3cc29fa9d 100644
--- a/framework/base/src/types/interaction/tx_payment.rs
+++ b/framework/base/src/types/interaction/tx_payment.rs
@@ -118,7 +118,7 @@ where
}
}
-impl TxPayment for MultiEsdtPayment
+impl TxPayment for &MultiEsdtPayment
where
Env: TxEnv,
{
@@ -135,13 +135,39 @@ where
) {
let _ = SendRawWrapper::::new().multi_esdt_transfer_execute(
to,
- &self,
+ self,
gas_limit,
&fc.function_name,
&fc.arg_buffer,
);
}
+ fn into_full_payment_data(self, env: &Env) -> FullPaymentData {
+ FullPaymentData {
+ egld: None,
+ multi_esdt: self.clone(),
+ }
+ }
+}
+
+impl TxPayment for MultiEsdtPayment
+where
+ Env: TxEnv,
+{
+ fn is_no_payment(&self) -> bool {
+ self.is_empty()
+ }
+
+ fn perform_transfer_execute(
+ self,
+ env: &Env,
+ to: &ManagedAddress,
+ gas_limit: u64,
+ fc: FunctionCall,
+ ) {
+ (&self).perform_transfer_execute(env, to, gas_limit, fc);
+ }
+
fn into_full_payment_data(self, env: &Env) -> FullPaymentData {
FullPaymentData {
egld: None,