Skip to content

Commit

Permalink
unified sytax - remove direct_multi usage in contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Mar 23, 2024
1 parent e168ede commit f1d0737
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 17 deletions.
6 changes: 4 additions & 2 deletions contracts/examples/digital-cash/src/digital_cash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
12 changes: 8 additions & 4 deletions contracts/examples/digital-cash/src/signature_operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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("*")]
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 8 additions & 4 deletions contracts/modules/src/token_merge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 4 additions & 2 deletions contracts/modules/src/transfer_role_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f1d0737

Please sign in to comment.