From f1d0737565f6b52b58ce9ce702a4695586196f57 Mon Sep 17 00:00:00 2001 From: Andrei Marinica Date: Sat, 23 Mar 2024 02:11:49 +0200 Subject: [PATCH] unified sytax - remove direct_multi usage in contracts --- contracts/examples/digital-cash/src/digital_cash.rs | 6 ++++-- .../digital-cash/src/signature_operations.rs | 12 ++++++++---- .../src/esdt_transfer_with_fee.rs | 5 ++--- .../src/bonding_curve/utils/owner_endpoints.rs | 2 +- .../src/bonding_curve/utils/user_endpoints.rs | 2 +- contracts/modules/src/token_merge/mod.rs | 12 ++++++++---- contracts/modules/src/transfer_role_proxy.rs | 6 ++++-- 7 files changed, 28 insertions(+), 17 deletions(-) diff --git a/contracts/examples/digital-cash/src/digital_cash.rs b/contracts/examples/digital-cash/src/digital_cash.rs index e1384d1742..97875a1a15 100644 --- a/contracts/examples/digital-cash/src/digital_cash.rs +++ b/contracts/examples/digital-cash/src/digital_cash.rs @@ -62,8 +62,10 @@ pub trait DigitalCash: } } if !collected_esdt_fees.is_empty() { - self.send() - .direct_multi(&caller_address, &collected_esdt_fees); + self.tx() + .to(&caller_address) + .multi_esdt_ref(&collected_esdt_fees) + .transfer(); } } diff --git a/contracts/examples/digital-cash/src/signature_operations.rs b/contracts/examples/digital-cash/src/signature_operations.rs index 5a60851143..f729cb6061 100644 --- a/contracts/examples/digital-cash/src/signature_operations.rs +++ b/contracts/examples/digital-cash/src/signature_operations.rs @@ -40,8 +40,10 @@ pub trait SignatureOperationsModule: storage::StorageModule + helpers::HelpersMo } if !esdt_funds.is_empty() { - self.send() - .direct_multi(&deposit.depositor_address, &esdt_funds); + self.tx() + .to(&deposit.depositor_address) + .multi_esdt(esdt_funds) + .transfer(); } } @@ -79,8 +81,10 @@ pub trait SignatureOperationsModule: storage::StorageModule + helpers::HelpersMo .transfer(); } if !deposit.esdt_funds.is_empty() { - self.send() - .direct_multi(&caller_address, &deposit.esdt_funds); + self.tx() + .to(&caller_address) + .multi_esdt_ref(&deposit.esdt_funds) + .transfer(); } if deposited_fee.amount > 0 { self.send_fee_to_address(&deposited_fee, &deposit.depositor_address); diff --git a/contracts/examples/esdt-transfer-with-fee/src/esdt_transfer_with_fee.rs b/contracts/examples/esdt-transfer-with-fee/src/esdt_transfer_with_fee.rs index 6133e5500f..fc47ed9acd 100644 --- a/contracts/examples/esdt-transfer-with-fee/src/esdt_transfer_with_fee.rs +++ b/contracts/examples/esdt-transfer-with-fee/src/esdt_transfer_with_fee.rs @@ -40,8 +40,7 @@ pub trait EsdtTransferWithFee { } self.paid_fees().clear(); - let caller = self.blockchain().get_caller(); - self.send().direct_multi(&caller, &fees); + self.tx().to(ToCaller).multi_esdt_ref(&fees).transfer(); } #[payable("*")] @@ -82,7 +81,7 @@ pub trait EsdtTransferWithFee { }, } } - self.send().direct_multi(&address, &new_payments); + self.tx().to(&address).multi_esdt(new_payments).transfer(); } fn get_payment_after_fees( diff --git a/contracts/modules/src/bonding_curve/utils/owner_endpoints.rs b/contracts/modules/src/bonding_curve/utils/owner_endpoints.rs index 007eda5fb7..820ba41446 100644 --- a/contracts/modules/src/bonding_curve/utils/owner_endpoints.rs +++ b/contracts/modules/src/bonding_curve/utils/owner_endpoints.rs @@ -179,7 +179,7 @@ pub trait OwnerEndpointsModule: storage::StorageModule + events::EventsModule { self.bonding_curve(&token).clear(); } self.owned_tokens(&caller).clear(); - self.send().direct_multi(&caller, &tokens_to_claim); + self.tx().to(&caller).multi_esdt(tokens_to_claim).transfer(); if egld_to_claim > BigUint::zero() { self.tx().to(&caller).egld(&egld_to_claim).transfer(); } diff --git a/contracts/modules/src/bonding_curve/utils/user_endpoints.rs b/contracts/modules/src/bonding_curve/utils/user_endpoints.rs index 5eec6451d2..d81fc4f2b1 100644 --- a/contracts/modules/src/bonding_curve/utils/user_endpoints.rs +++ b/contracts/modules/src/bonding_curve/utils/user_endpoints.rs @@ -158,7 +158,7 @@ pub trait UserEndpointsModule: storage::StorageModule + events::EventsModule { } } - self.send().direct_multi(caller, &tokens_to_send); + self.tx().to(caller).multi_esdt(tokens_to_send).transfer(); self.token_details(&token) .update(|token_ownership| token_ownership.token_nonces = nonces); diff --git a/contracts/modules/src/token_merge/mod.rs b/contracts/modules/src/token_merge/mod.rs index 024626e2f1..0acdce1af8 100644 --- a/contracts/modules/src/token_merge/mod.rs +++ b/contracts/modules/src/token_merge/mod.rs @@ -118,8 +118,10 @@ pub trait TokenMergeModule: .esdt_local_burn(&token.token_identifier, token.token_nonce, &token.amount); } - let caller = self.blockchain().get_caller(); - self.send().direct_multi(&caller, &output_payments); + self.tx() + .to(ToCaller) + .multi_esdt_ref(&output_payments) + .transfer(); output_payments } @@ -165,8 +167,10 @@ pub trait TokenMergeModule: ); tokens_to_remove.push(new_merged_token); - let caller = self.blockchain().get_caller(); - self.send().direct_multi(&caller, &tokens_to_remove); + self.tx() + .to(ToCaller) + .multi_esdt_ref(&tokens_to_remove) + .transfer(); tokens_to_remove } diff --git a/contracts/modules/src/transfer_role_proxy.rs b/contracts/modules/src/transfer_role_proxy.rs index 80995eff04..2c272eb01b 100644 --- a/contracts/modules/src/transfer_role_proxy.rs +++ b/contracts/modules/src/transfer_role_proxy.rs @@ -109,8 +109,10 @@ pub trait TransferRoleProxyModule { ManagedAsyncCallResult::Ok(return_values) => return_values, ManagedAsyncCallResult::Err(err) => { if !initial_payments.is_empty() { - self.send() - .direct_multi(&original_caller, &initial_payments); + self.tx() + .to(&original_caller) + .multi_esdt(initial_payments) + .transfer(); } let mut err_result = MultiValueEncoded::new();