Skip to content

Commit

Permalink
unified sytax - remove direct_esdt usage in contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Mar 22, 2024
1 parent 051fecf commit 0b6e0d6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
6 changes: 4 additions & 2 deletions contracts/examples/digital-cash/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ pub trait HelpersModule: storage::StorageModule {
self.tx().to(address).egld(&fee.amount).transfer();
} else {
let esdt_fee = fee.clone().unwrap_esdt();
self.send()
.direct_esdt(address, &esdt_fee.token_identifier, 0, &esdt_fee.amount);
self.tx()
.to(address)
.esdt_refs(&esdt_fee.token_identifier, 0, &esdt_fee.amount)
.transfer();
}
}

Expand Down
10 changes: 4 additions & 6 deletions contracts/examples/order-book/pair/src/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,10 @@ pub trait OrdersModule:
fn execute_transfers(&self, transfers: ManagedVec<Transfer<Self::Api>>) {
for transfer in &transfers {
if transfer.payment.amount > 0 {
self.send().direct_esdt(
&transfer.to,
&transfer.payment.token_id,
0,
&transfer.payment.amount,
)
self.tx()
.to(&transfer.to)
.esdt_refs(&transfer.payment.token_id, 0, &transfer.payment.amount)
.transfer();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ pub trait ForwarderRawAsync: super::forwarder_raw_common::ForwarderRawCommon {
#[payable("*")]
fn forward_direct_esdt_via_transf_exec(&self, to: ManagedAddress) {
let (token, payment) = self.call_value().single_fungible_esdt();
self.send().direct_esdt(&to, &token, 0, &payment);
self.tx().to(&to).esdt_refs(&token, 0, &payment).transfer();
}

#[endpoint]
#[payable("*")]
fn forward_direct_esdt_multi(&self, to: ManagedAddress) {
let payments = self.call_value().all_esdt_transfers();
self.send().direct_multi(&to, &payments);
self.tx().to(&to).multi_esdt_ref(&payments).transfer();
}

fn forward_contract_call(
Expand Down
6 changes: 4 additions & 2 deletions contracts/modules/src/bonding_curve/utils/user_endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ pub trait UserEndpointsModule: storage::StorageModule + events::EventsModule {

match requested_nonce {
OptionalValue::Some(nonce) => {
self.send()
.direct_esdt(&caller, &requested_token, nonce, &requested_amount);
self.tx()
.to(&caller)
.esdt_refs(&requested_token, nonce, &requested_amount)
.transfer();
if self.nonce_amount(&requested_token, nonce).get() - requested_amount.clone() > 0 {
self.nonce_amount(&requested_token, nonce)
.update(|val| *val -= requested_amount.clone());
Expand Down

0 comments on commit 0b6e0d6

Please sign in to comment.