Skip to content

Commit

Permalink
Merge pull request multiversx#1914 from multiversx/egld-new
Browse files Browse the repository at this point in the history
call value - egld changes
  • Loading branch information
andrei-marinica authored Jan 8, 2025
2 parents d8042b5 + 64afe64 commit 0dcc3f7
Show file tree
Hide file tree
Showing 44 changed files with 176 additions and 154 deletions.
66 changes: 33 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions 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().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 All @@ -28,7 +28,7 @@ pub trait EgldEsdtSwap: multiversx_sc_modules::pause::PauseModule {
.single_esdt(&wrapped_egld_token_id, 0, &payment_amount)
.transfer();

EsdtTokenPayment::new(wrapped_egld_token_id, 0, payment_amount.clone_value())
EsdtTokenPayment::new(wrapped_egld_token_id, 0, payment_amount.clone())
}

#[payable("*")]
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().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().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
4 changes: 2 additions & 2 deletions 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().egld_value();
let payment = self.call_value().egld();

require!(
self.is_up_for_auction(kitty_id),
Expand Down Expand Up @@ -192,7 +192,7 @@ pub trait KittyAuction {
}

// update auction bid and winner
auction.current_bid = payment.clone_value();
auction.current_bid = payment.clone();
auction.current_winner = caller;
self.auction(kitty_id).set(auction);
}
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().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().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
7 changes: 4 additions & 3 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().egld_value().clone_value();
let mut fund = self.call_value().egld().clone();
let fee_value = self.fee(&EgldOrEsdtTokenIdentifier::egld()).get();
require!(fund > fee_value, "payment not covering fees");

Expand All @@ -43,8 +43,9 @@ 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();
let esdt_payment = self.call_value().all_esdt_transfers().clone_value();
// TODO: switch to egld+esdt multi transfer handling
let egld_payment = self.call_value().egld_direct_non_strict().clone();
let esdt_payment = self.call_value().all_esdt_transfers().clone();

let num_tokens = self.get_num_token_transfers(&egld_payment, &esdt_payment);
self.check_fees_cover_number_of_tokens(num_tokens, fee_amount, deposited_fee_token.amount);
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
4 changes: 2 additions & 2 deletions contracts/examples/fractional-nfts/src/fractional_nfts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ 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(),
issue_cost.clone(),
token_display_name,
token_ticker,
num_decimals,
Expand Down
4 changes: 2 additions & 2 deletions contracts/examples/nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ 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(
payment_amount.clone_value(),
payment_amount.clone(),
&token_name,
&token_ticker,
NonFungibleTokenProperties {
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(),
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
4 changes: 2 additions & 2 deletions contracts/examples/seed-nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ 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(),
issue_cost.clone(),
token_display_name,
token_ticker,
0,
Expand Down
Loading

0 comments on commit 0dcc3f7

Please sign in to comment.