Skip to content

Commit

Permalink
call value - egld/egld_direct_non_strict; egld_value deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Jan 8, 2025
1 parent 0f8fd32 commit 616a983
Show file tree
Hide file tree
Showing 40 changed files with 108 additions and 102 deletions.
2 changes: 1 addition & 1 deletion contracts/core/wegld-swap/src/wegld.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait EgldEsdtSwap: multiversx_sc_modules::pause::PauseModule {
fn wrap_egld(&self) -> EsdtTokenPayment<Self::Api> {
self.require_not_paused();

let payment_amount = self.call_value().single_egld_value();
let payment_amount = self.call_value().egld();
require!(*payment_amount > 0u32, "Payment must be more than 0");

let wrapped_egld_token_id = self.wrapped_egld_token_id().get();
Expand Down
4 changes: 2 additions & 2 deletions contracts/examples/crypto-bubbles/src/crypto_bubbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait CryptoBubbles {
#[payable("EGLD")]
#[endpoint(topUp)]
fn top_up(&self) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let caller = self.blockchain().get_caller();
self.player_balance(&caller)
.update(|balance| *balance += &*payment);
Expand Down Expand Up @@ -63,7 +63,7 @@ pub trait CryptoBubbles {
#[payable("EGLD")]
#[endpoint(joinGame)]
fn join_game(&self, game_index: BigUint) {
let bet = self.call_value().single_egld_value();
let bet = self.call_value().egld();
let player = self.blockchain().get_caller();
self.top_up();
self.add_player_to_game_state_change(&game_index, &player, &bet)
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/crypto-kitties/kitty-auction/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub trait KittyAuction {
#[payable("EGLD")]
#[endpoint]
fn bid(&self, kitty_id: u32) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();

require!(
self.is_up_for_auction(kitty_id),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ pub trait KittyOwnership {
require!(self.is_valid_id(matron_id), "Invalid matron id!");
require!(self.is_valid_id(sire_id), "Invalid sire id!");

let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let auto_birth_fee = self.birth_fee().get();
let caller = self.blockchain().get_caller();

Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/crypto-zombies/src/zombie_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait ZombieHelper: storage::Storage {
#[payable("EGLD")]
#[endpoint]
fn level_up(&self, zombie_id: usize) {
let payment_amount = self.call_value().single_egld_value();
let payment_amount = self.call_value().egld();
let fee = self.level_up_fee().get();
require!(*payment_amount == fee, "Payment must be must be 0.001 EGLD");
self.zombies(&zombie_id)
Expand Down
5 changes: 3 additions & 2 deletions contracts/examples/digital-cash/src/pay_fee_and_fund.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait PayFeeAndFund: storage::StorageModule + helpers::HelpersModule {
#[endpoint(payFeeAndFundEGLD)]
#[payable("EGLD")]
fn pay_fee_and_fund_egld(&self, address: ManagedAddress, valability: u64) {
let mut fund = self.call_value().single_egld_value().clone_value();
let mut fund = self.call_value().egld().clone_value();
let fee_value = self.fee(&EgldOrEsdtTokenIdentifier::egld()).get();
require!(fund > fee_value, "payment not covering fees");

Expand All @@ -43,7 +43,8 @@ pub trait PayFeeAndFund: storage::StorageModule + helpers::HelpersModule {
);
let deposited_fee_token = deposit_mapper.fees.value;
let fee_amount = self.fee(&deposited_fee_token.token_identifier).get();
let egld_payment = self.call_value().egld_value().clone_value();
// TODO: switch to egld+esdt multi transfer handling
let egld_payment = self.call_value().egld_direct_non_strict().clone_value();
let esdt_payment = self.call_value().all_esdt_transfers().clone_value();

let num_tokens = self.get_num_token_transfers(&egld_payment, &esdt_payment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub trait EsdtTransferWithFee {
#[endpoint]
fn transfer(&self, address: ManagedAddress) {
require!(
*self.call_value().egld_value() == 0,
*self.call_value().egld_direct_non_strict() == 0,
"EGLD transfers not allowed"
);
let payments = self.call_value().all_esdt_transfers();
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/fractional-nfts/src/fractional_nfts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub trait FractionalNfts: default_issue_callbacks::DefaultIssueCallbacksModule {
token_ticker: ManagedBuffer,
num_decimals: usize,
) {
let issue_cost = self.call_value().egld_value();
let issue_cost = self.call_value().egld();
self.fractional_token().issue_and_set_all_roles(
EsdtTokenType::SemiFungible,
issue_cost.clone_value(),
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait NftModule {
fn issue_token(&self, token_name: ManagedBuffer, token_ticker: ManagedBuffer) {
require!(self.nft_token_id().is_empty(), "Token already issued");

let payment_amount = self.call_value().egld_value();
let payment_amount = self.call_value().egld();
self.send()
.esdt_system_sc_proxy()
.issue_non_fungible(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub trait NftStoragePrepay {
#[payable("EGLD")]
#[endpoint(depositPaymentForStorage)]
fn deposit_payment_for_storage(&self) {
let payment = self.call_value().egld_value();
let payment = self.call_value().egld();
let caller = self.blockchain().get_caller();
self.deposit(&caller)
.update(|deposit| *deposit += &*payment);
Expand Down
3 changes: 2 additions & 1 deletion contracts/examples/nft-subscription/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ pub trait NftSubscription:
fn init(&self) {}

#[endpoint]
#[payable("EGLD")]
fn issue(&self) {
self.token_id().issue_and_set_all_roles(
EsdtTokenType::NonFungible,
self.call_value().egld_value().clone_value(),
self.call_value().egld().clone_value(),
ManagedBuffer::from(b"Subscription"),
ManagedBuffer::from(b"SUB"),
0,
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/ping-pong-egld/src/ping_pong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub trait PingPong {
#[payable("EGLD")]
#[endpoint]
fn ping(&self, _data: IgnoreValue) {
let payment = self.call_value().egld_value();
let payment = self.call_value().egld();

require!(
*payment == self.ping_amount().get(),
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/seed-nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub trait NftModule:
#[payable("EGLD")]
#[endpoint(issueToken)]
fn issue_token(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) {
let issue_cost = self.call_value().egld_value();
let issue_cost = self.call_value().egld();
self.nft_token_id().issue_and_set_all_roles(
EsdtTokenType::NonFungible,
issue_cost.clone_value(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub trait FungibleTokenMapperFeatures:
token_ticker: ManagedBuffer,
initial_supply: BigUint,
) {
let payment_amount = self.call_value().egld_value();
let payment_amount = self.call_value().egld();
self.fungible_token_mapper().issue(
payment_amount.clone_value(),
ManagedBuffer::new(),
Expand All @@ -25,7 +25,7 @@ pub trait FungibleTokenMapperFeatures:
#[payable("EGLD")]
#[endpoint]
fn issue_fungible_custom_callback(&self, token_ticker: ManagedBuffer, initial_supply: BigUint) {
let payment = self.call_value().egld_value();
let payment = self.call_value().egld();
let cb = if initial_supply > 0 {
FungibleTokenMapperFeatures::callbacks(self).custom_issue_non_zero_supply_cb()
} else {
Expand Down Expand Up @@ -74,7 +74,7 @@ pub trait FungibleTokenMapperFeatures:
#[payable("EGLD")]
#[endpoint]
fn issue_and_set_all_roles_fungible(&self, token_ticker: ManagedBuffer) {
let payment = self.call_value().egld_value();
let payment = self.call_value().egld();
self.fungible_token_mapper().issue_and_set_all_roles(
payment.clone_value(),
ManagedBuffer::new(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait NonFungibleTokenMapperFeatures:
#[payable("EGLD")]
#[endpoint]
fn issue_and_set_all_roles_meta(&self, token_ticker: ManagedBuffer) {
let payment = self.call_value().egld_value();
let payment = self.call_value().egld();
self.non_fungible_token_mapper().issue_and_set_all_roles(
EsdtTokenType::Meta,
payment.clone_value(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub trait Child {
token_ticker: ManagedBuffer,
initial_supply: BigUint,
) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
self.send()
.esdt_system_sc_proxy()
.issue_fungible(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub trait Parent {
token_ticker: ManagedBuffer,
initial_supply: BigUint,
) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let child_contract_adress = self.child_contract_address().get();

self.tx()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub trait ForwarderEsdtModule: fwd_storage_legacy::ForwarderStorageModule {
token_ticker: ManagedBuffer,
initial_supply: BigUint,
) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait ForwarderNftModule: fwd_storage_legacy::ForwarderStorageModule {
#[payable("EGLD")]
#[endpoint]
fn nft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub trait ForwarderSftModule: fwd_storage_legacy::ForwarderStorageModule {
#[payable("EGLD")]
#[endpoint]
fn sft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,13 @@ pub trait ForwarderRaw:

#[callback_raw]
fn callback_raw(&self, args: MultiValueEncoded<ManagedBuffer>) {
let payments = self.call_value().all_esdt_transfers();
if payments.is_empty() {
let egld_value = self.call_value().egld_value();
if *egld_value > 0 {
let _ = self.callback_payments().push(&(
EgldOrEsdtTokenIdentifier::egld(),
0,
egld_value.clone_value(),
));
}
} else {
for payment in payments.iter() {
let _ = self.callback_payments().push(&(
EgldOrEsdtTokenIdentifier::esdt(payment.token_identifier.clone()),
payment.token_nonce,
payment.amount.clone(),
));
}
let payments = self.call_value().all_transfers();
for payment in payments.iter() {
let _ = self.callback_payments().push(&(
payment.token_identifier.clone(),
payment.token_nonce,
payment.amount.clone(),
));
}

let args_as_vec = args.into_vec_of_buffers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait ForwarderRawAlterativeInit: super::forwarder_raw_common::ForwarderRawC
endpoint_name: ManagedBuffer,
args: MultiValueEncoded<ManagedBuffer>,
) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let half_gas = self.blockchain().get_gas_left() / 2;

let result = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub trait ForwarderRawAsync: super::forwarder_raw_common::ForwarderRawCommon {
endpoint_name: ManagedBuffer,
args: MultiValueEncoded<ManagedBuffer>,
) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
self.forward_contract_call(
to,
EgldOrEsdtTokenIdentifier::egld(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait ForwarderRawSync: super::forwarder_raw_common::ForwarderRawCommon {
endpoint_name: ManagedBuffer,
args: MultiValueEncoded<ManagedBuffer>,
) {
let payment = self.call_value().single_egld_value().clone_value();
let payment = self.call_value().egld().clone_value();
let half_gas = self.blockchain().get_gas_left() / 2;
let result = self
.tx()
Expand All @@ -33,7 +33,7 @@ pub trait ForwarderRawSync: super::forwarder_raw_common::ForwarderRawCommon {
endpoint_name: ManagedBuffer,
args: MultiValueEncoded<ManagedBuffer>,
) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let one_third_gas = self.blockchain().get_gas_left() / 3;
let half_payment = &*payment / 2u32;
let arg_buffer = args.to_arg_buffer();
Expand Down Expand Up @@ -71,7 +71,7 @@ pub trait ForwarderRawSync: super::forwarder_raw_common::ForwarderRawCommon {
endpoint_name: ManagedBuffer,
args: MultiValueEncoded<ManagedBuffer>,
) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let half_gas = self.blockchain().get_gas_left() / 2;

let result = self
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait ForwarderSyncCallModule {
#[endpoint]
#[payable("EGLD")]
fn forward_sync_accept_funds_rh_egld(&self, to: ManagedAddress) -> BigUint {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let half_gas = self.blockchain().get_gas_left() / 2;

self.tx()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub trait ForwarderEsdtModule: fwd_storage::ForwarderStorageModule {
token_ticker: ManagedBuffer,
initial_supply: BigUint,
) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ pub trait ForwarderNftModule: fwd_storage::ForwarderStorageModule {
#[payable("EGLD")]
#[endpoint]
fn nft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub trait ForwarderSftModule: fwd_storage::ForwarderStorageModule {
#[payable("EGLD")]
#[endpoint]
fn sft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub trait LocalEsdtAndEsdtNft {
token_ticker: ManagedBuffer,
initial_supply: BigUint,
) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down Expand Up @@ -68,7 +68,7 @@ pub trait LocalEsdtAndEsdtNft {
#[payable("EGLD")]
#[endpoint(nftIssue)]
fn nft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down Expand Up @@ -174,7 +174,7 @@ pub trait LocalEsdtAndEsdtNft {
#[payable("EGLD")]
#[endpoint(sftIssue)]
fn sft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) {
let issue_cost = self.call_value().single_egld_value();
let issue_cost = self.call_value().egld();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub trait ProxyTestFirst {
#[payable("EGLD")]
#[endpoint(deploySecondContract)]
fn deploy_second_contract(&self, code: ManagedBuffer) -> i32 {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();

let (address, init_result) = self
.tx()
Expand All @@ -49,7 +49,7 @@ pub trait ProxyTestFirst {
#[payable("EGLD")]
#[endpoint(upgradeSecondContract)]
fn upgrade_second_contract(&self, code: ManagedBuffer) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let other_contract = self.get_other_contract();

self.tx()
Expand All @@ -66,7 +66,7 @@ pub trait ProxyTestFirst {
#[payable("EGLD")]
#[endpoint(forwardToOtherContract)]
fn forward_to_other_contract(&self) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let other_contract = self.get_other_contract();
self.tx()
.to(&other_contract)
Expand All @@ -79,7 +79,7 @@ pub trait ProxyTestFirst {
#[payable("EGLD")]
#[endpoint(forwardToOtherContractWithCallback)]
fn forward_to_other_contract_with_callback(&self) {
let payment = self.call_value().single_egld_value();
let payment = self.call_value().egld();
let other_contract = self.get_other_contract();
self.tx()
.to(&other_contract)
Expand Down
Loading

0 comments on commit 616a983

Please sign in to comment.