diff --git a/Cargo.lock b/Cargo.lock index 7b428f03b5..aeef450add 100755 --- a/Cargo.lock +++ b/Cargo.lock @@ -486,9 +486,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3135e7ec2ef7b10c6ed8950f0f792ed96ee093fa088608f1c76e569722700c84" +checksum = "9560b07a799281c7e0958b9296854d6fafd4c5f31444a7e5bb1ad6dde5ccf1bd" dependencies = [ "clap_builder", "clap_derive", @@ -496,9 +496,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.23" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30582fc632330df2bd26877bde0c1f4470d57c582bbc070376afcd04d8cb4838" +checksum = "874e0dd3eb68bf99058751ac9712f622e61e6f393a94f7128fa26e3f02f5c7cd" dependencies = [ "anstream", "anstyle", @@ -508,9 +508,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.18" +version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" +checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ "heck", "proc-macro2", @@ -2206,9 +2206,9 @@ dependencies = [ [[package]] name = "linux-raw-sys" -version = "0.4.14" +version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" [[package]] name = "litemap" @@ -3038,18 +3038,18 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" [[package]] name = "pin-project" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" +checksum = "1e2ec53ad785f4d35dac0adea7f7dc6f1bb277ad84a680c7afefeae05d1f5916" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.7" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" +checksum = "d56a66c0c55993aa927429d0f8a0abfd74f084e4d9c192cffed01e418d83eefb" dependencies = [ "proc-macro2", "quote", @@ -3058,9 +3058,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.15" +version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" [[package]] name = "pin-utils" @@ -3622,9 +3622,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.42" +version = "0.38.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f93dc38ecbab2eb790ff964bb77fa94faf256fd3e73285fd7ba0903b76bedb85" +checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6" dependencies = [ "bitflags", "errno", @@ -3793,9 +3793,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.13.0" +version = "2.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1863fd3768cd83c56a7f60faa4dc0d403f1b6df0a38c3c25f44b7894e45370d5" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" dependencies = [ "core-foundation-sys", "libc", @@ -3873,9 +3873,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.134" +version = "1.0.135" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d00f4175c42ee48b15416f6193a959ba3a0d67fc699a0db9ad12df9f83991c7d" +checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9" dependencies = [ "indexmap 2.7.0", "itoa", @@ -4261,9 +4261,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.42.0" +version = "1.43.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551" +checksum = "3d61fa4ffa3de412bfea335c6ecff681de2b609ba3c77ef3e00e521813a9ed9e" dependencies = [ "backtrace", "bytes", @@ -4279,9 +4279,9 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" dependencies = [ "proc-macro2", "quote", @@ -4689,12 +4689,12 @@ checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6" [[package]] name = "wasm-encoder" -version = "0.222.0" +version = "0.223.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3432682105d7e994565ef928ccf5856cf6af4ba3dddebedb737f61caed70f956" +checksum = "7e636076193fa68103e937ac951b5f2f587624097017d764b8984d9c0f149464" dependencies = [ "leb128", - "wasmparser 0.222.0", + "wasmparser 0.223.0", ] [[package]] @@ -4713,9 +4713,9 @@ dependencies = [ [[package]] name = "wasmparser" -version = "0.222.0" +version = "0.223.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4adf50fde1b1a49c1add6a80d47aea500c88db70551805853aa8b88f3ea27ab5" +checksum = "d5a99faceb1a5a84dd6084ec4bfa4b2ab153b5793b43fd8f58b89232634afc35" dependencies = [ "bitflags", "indexmap 2.7.0", @@ -4735,9 +4735,9 @@ dependencies = [ [[package]] name = "wast" -version = "222.0.0" +version = "223.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5ce7191f4b7da0dd300cc32476abae6457154e4625d9b1bc26890828a9a26f6e" +checksum = "d59b2ba8a2ff9f06194b7be9524f92e45e70149f4dacc0d0c7ad92b59ac875e4" dependencies = [ "bumpalo", "leb128", @@ -4748,9 +4748,9 @@ dependencies = [ [[package]] name = "wat" -version = "1.222.0" +version = "1.223.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fde61b4b52f9a84ae31b5e8902a2cd3162ea45d8bf564c729c3288fe52f4334" +checksum = "662786915c427e4918ff01eabb3c4756d4d947cd8f635761526b4cc9da2eaaad" dependencies = [ "wast", ] diff --git a/contracts/core/wegld-swap/src/wegld.rs b/contracts/core/wegld-swap/src/wegld.rs index 1c9cf11a2a..36c2d0fe37 100644 --- a/contracts/core/wegld-swap/src/wegld.rs +++ b/contracts/core/wegld-swap/src/wegld.rs @@ -16,7 +16,7 @@ pub trait EgldEsdtSwap: multiversx_sc_modules::pause::PauseModule { fn wrap_egld(&self) -> EsdtTokenPayment { 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(); @@ -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("*")] diff --git a/contracts/examples/crypto-bubbles/src/crypto_bubbles.rs b/contracts/examples/crypto-bubbles/src/crypto_bubbles.rs index 35b687f2cc..8867e6db39 100644 --- a/contracts/examples/crypto-bubbles/src/crypto_bubbles.rs +++ b/contracts/examples/crypto-bubbles/src/crypto_bubbles.rs @@ -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); @@ -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) diff --git a/contracts/examples/crypto-kitties/kitty-auction/src/lib.rs b/contracts/examples/crypto-kitties/kitty-auction/src/lib.rs index 60a30c382e..39f4841f8b 100644 --- a/contracts/examples/crypto-kitties/kitty-auction/src/lib.rs +++ b/contracts/examples/crypto-kitties/kitty-auction/src/lib.rs @@ -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), @@ -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); } diff --git a/contracts/examples/crypto-kitties/kitty-ownership/src/lib.rs b/contracts/examples/crypto-kitties/kitty-ownership/src/lib.rs index dbde8aed52..a56382fe54 100644 --- a/contracts/examples/crypto-kitties/kitty-ownership/src/lib.rs +++ b/contracts/examples/crypto-kitties/kitty-ownership/src/lib.rs @@ -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(); diff --git a/contracts/examples/crypto-zombies/src/zombie_helper.rs b/contracts/examples/crypto-zombies/src/zombie_helper.rs index c38edc9ea0..cc3786049c 100644 --- a/contracts/examples/crypto-zombies/src/zombie_helper.rs +++ b/contracts/examples/crypto-zombies/src/zombie_helper.rs @@ -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) diff --git a/contracts/examples/digital-cash/src/pay_fee_and_fund.rs b/contracts/examples/digital-cash/src/pay_fee_and_fund.rs index 3815ea38cc..514bbb8e74 100644 --- a/contracts/examples/digital-cash/src/pay_fee_and_fund.rs +++ b/contracts/examples/digital-cash/src/pay_fee_and_fund.rs @@ -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"); @@ -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); 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 b885ec371f..4f21906d89 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 @@ -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(); diff --git a/contracts/examples/fractional-nfts/src/fractional_nfts.rs b/contracts/examples/fractional-nfts/src/fractional_nfts.rs index fea51e2431..007ecffc39 100644 --- a/contracts/examples/fractional-nfts/src/fractional_nfts.rs +++ b/contracts/examples/fractional-nfts/src/fractional_nfts.rs @@ -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, diff --git a/contracts/examples/nft-minter/src/nft_module.rs b/contracts/examples/nft-minter/src/nft_module.rs index 6629c22d11..8f503014da 100644 --- a/contracts/examples/nft-minter/src/nft_module.rs +++ b/contracts/examples/nft-minter/src/nft_module.rs @@ -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 { diff --git a/contracts/examples/nft-storage-prepay/src/nft_storage_prepay.rs b/contracts/examples/nft-storage-prepay/src/nft_storage_prepay.rs index 7e1c6115d3..e7ec86abea 100644 --- a/contracts/examples/nft-storage-prepay/src/nft_storage_prepay.rs +++ b/contracts/examples/nft-storage-prepay/src/nft_storage_prepay.rs @@ -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); diff --git a/contracts/examples/nft-subscription/src/lib.rs b/contracts/examples/nft-subscription/src/lib.rs index beca5ac5bf..f64140a6b7 100644 --- a/contracts/examples/nft-subscription/src/lib.rs +++ b/contracts/examples/nft-subscription/src/lib.rs @@ -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, diff --git a/contracts/examples/ping-pong-egld/src/ping_pong.rs b/contracts/examples/ping-pong-egld/src/ping_pong.rs index abecb0dbcc..0f44ffdee8 100644 --- a/contracts/examples/ping-pong-egld/src/ping_pong.rs +++ b/contracts/examples/ping-pong-egld/src/ping_pong.rs @@ -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(), diff --git a/contracts/examples/seed-nft-minter/src/nft_module.rs b/contracts/examples/seed-nft-minter/src/nft_module.rs index 8c271e5686..6d11532fe0 100644 --- a/contracts/examples/seed-nft-minter/src/nft_module.rs +++ b/contracts/examples/seed-nft-minter/src/nft_module.rs @@ -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, diff --git a/contracts/feature-tests/basic-features/src/storage_mapper_fungible_token.rs b/contracts/feature-tests/basic-features/src/storage_mapper_fungible_token.rs index feeecb2b33..203dd28c64 100644 --- a/contracts/feature-tests/basic-features/src/storage_mapper_fungible_token.rs +++ b/contracts/feature-tests/basic-features/src/storage_mapper_fungible_token.rs @@ -11,9 +11,9 @@ 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(), + payment_amount.clone(), ManagedBuffer::new(), token_ticker, initial_supply, @@ -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 { @@ -33,7 +33,7 @@ pub trait FungibleTokenMapperFeatures: }; self.fungible_token_mapper().issue( - payment.clone_value(), + payment.clone(), ManagedBuffer::new(), token_ticker, initial_supply, @@ -74,9 +74,9 @@ 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(), + payment.clone(), ManagedBuffer::new(), token_ticker, 0, diff --git a/contracts/feature-tests/basic-features/src/storage_mapper_non_fungible_token.rs b/contracts/feature-tests/basic-features/src/storage_mapper_non_fungible_token.rs index 4e341f04bd..5a19517b01 100644 --- a/contracts/feature-tests/basic-features/src/storage_mapper_non_fungible_token.rs +++ b/contracts/feature-tests/basic-features/src/storage_mapper_non_fungible_token.rs @@ -16,10 +16,10 @@ 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(), + payment.clone(), ManagedBuffer::new(), token_ticker, 0, diff --git a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/src/lib.rs b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/src/lib.rs index dcb634f054..dc732e82f9 100644 --- a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/src/lib.rs +++ b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/src/lib.rs @@ -17,11 +17,11 @@ pub trait Child { token_ticker: ManagedBuffer, initial_supply: BigUint, ) { - let issue_cost = self.call_value().egld_value(); + let issue_cost = self.call_value().egld(); self.send() .esdt_system_sc_proxy() .issue_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, &initial_supply, diff --git a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs index 5c4bff50d0..8ee7f26c69 100644 --- a/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs +++ b/contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/parent/src/lib.rs @@ -38,7 +38,7 @@ pub trait Parent { token_ticker: ManagedBuffer, initial_supply: BigUint, ) { - let issue_cost = self.call_value().egld_value(); + let issue_cost = self.call_value().egld(); let child_contract_adress = self.child_contract_address().get(); self.tx() diff --git a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_sync_legacy.rs b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_sync_legacy.rs index 67d923936e..53a12a0a1a 100644 --- a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_sync_legacy.rs +++ b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_call_sync_legacy.rs @@ -141,7 +141,7 @@ pub trait ForwarderSyncCallModule { amount, OptionalValue::::Some(b"accept_funds_func".into()), ) - .with_multi_token_transfer(payments.clone_value()) + .with_multi_token_transfer(payments.clone()) .execute_on_dest_context::<()>(); } diff --git a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_esdt_legacy.rs b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_esdt_legacy.rs index 7ba477b448..ace0684bab 100644 --- a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_esdt_legacy.rs +++ b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_esdt_legacy.rs @@ -90,13 +90,13 @@ pub trait ForwarderEsdtModule: fwd_storage_legacy::ForwarderStorageModule { token_ticker: ManagedBuffer, initial_supply: BigUint, ) { - let issue_cost = self.call_value().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, &initial_supply, diff --git a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs index 8e04da46a1..1c18fb556a 100644 --- a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs +++ b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_nft_legacy.rs @@ -52,13 +52,13 @@ 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().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_non_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, NonFungibleTokenProperties { diff --git a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_sft_legacy.rs b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_sft_legacy.rs index 41d01c6f7a..a2b1b583af 100644 --- a/contracts/feature-tests/composability/forwarder-legacy/src/fwd_sft_legacy.rs +++ b/contracts/feature-tests/composability/forwarder-legacy/src/fwd_sft_legacy.rs @@ -7,13 +7,13 @@ 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().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_semi_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, SemiFungibleTokenProperties { diff --git a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw.rs b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw.rs index 796bea5684..810cddba5e 100644 --- a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw.rs +++ b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw.rs @@ -24,24 +24,13 @@ pub trait ForwarderRaw: #[callback_raw] fn callback_raw(&self, args: MultiValueEncoded) { - 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(); diff --git a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_alt_init.rs b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_alt_init.rs index f00a10d434..e0b6058bcd 100644 --- a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_alt_init.rs +++ b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_alt_init.rs @@ -52,7 +52,7 @@ pub trait ForwarderRawAlterativeInit: super::forwarder_raw_common::ForwarderRawC endpoint_name: ManagedBuffer, args: MultiValueEncoded, ) { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); let half_gas = self.blockchain().get_gas_left() / 2; let result = self diff --git a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_async.rs b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_async.rs index df66f30a30..0af2c870e4 100644 --- a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_async.rs +++ b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_async.rs @@ -91,11 +91,11 @@ pub trait ForwarderRawAsync: super::forwarder_raw_common::ForwarderRawCommon { endpoint_name: ManagedBuffer, args: MultiValueEncoded, ) { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); self.forward_contract_call( to, EgldOrEsdtTokenIdentifier::egld(), - payment.clone_value(), + payment.clone(), endpoint_name, args, ) diff --git a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_sync.rs b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_sync.rs index 07a095ed9d..bd1188c1bb 100644 --- a/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_sync.rs +++ b/contracts/feature-tests/composability/forwarder-raw/src/forwarder_raw_sync.rs @@ -10,7 +10,7 @@ pub trait ForwarderRawSync: super::forwarder_raw_common::ForwarderRawCommon { endpoint_name: ManagedBuffer, args: MultiValueEncoded, ) { - let payment = self.call_value().egld_value().clone_value(); + let payment = self.call_value().egld().clone(); let half_gas = self.blockchain().get_gas_left() / 2; let result = self .tx() @@ -33,7 +33,7 @@ pub trait ForwarderRawSync: super::forwarder_raw_common::ForwarderRawCommon { endpoint_name: ManagedBuffer, args: MultiValueEncoded, ) { - let payment = self.call_value().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(); @@ -71,7 +71,7 @@ pub trait ForwarderRawSync: super::forwarder_raw_common::ForwarderRawCommon { endpoint_name: ManagedBuffer, args: MultiValueEncoded, ) { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); let half_gas = self.blockchain().get_gas_left() / 2; let result = self diff --git a/contracts/feature-tests/composability/forwarder/src/fwd_call_sync.rs b/contracts/feature-tests/composability/forwarder/src/fwd_call_sync.rs index d5b6f63492..0a8602ee33 100644 --- a/contracts/feature-tests/composability/forwarder/src/fwd_call_sync.rs +++ b/contracts/feature-tests/composability/forwarder/src/fwd_call_sync.rs @@ -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().egld_value(); + let payment = self.call_value().egld(); let half_gas = self.blockchain().get_gas_left() / 2; self.tx() @@ -125,7 +125,7 @@ pub trait ForwarderSyncCallModule { &self, to: ManagedAddress, ) -> ManagedVec> { - let payment = self.call_value().all_esdt_transfers().clone_value(); + let payment = self.call_value().all_esdt_transfers().clone(); let half_gas = self.blockchain().get_gas_left() / 2; self.tx() diff --git a/contracts/feature-tests/composability/forwarder/src/fwd_dynamic.rs b/contracts/feature-tests/composability/forwarder/src/fwd_dynamic.rs index 14549d99ad..8fd139d485 100644 --- a/contracts/feature-tests/composability/forwarder/src/fwd_dynamic.rs +++ b/contracts/feature-tests/composability/forwarder/src/fwd_dynamic.rs @@ -15,7 +15,7 @@ pub trait ForwarderDynamicModule: token_type: EsdtTokenType, num_decimals: usize, ) { - let issue_cost = self.call_value().egld_value().clone_value(); + let issue_cost = self.call_value().egld().clone(); let caller = self.blockchain().get_caller(); self.send() @@ -40,7 +40,7 @@ pub trait ForwarderDynamicModule: token_type: EsdtTokenType, num_decimals: usize, ) { - let issue_cost = self.call_value().egld_value().clone_value(); + let issue_cost = self.call_value().egld().clone(); let caller = self.blockchain().get_caller(); self.send() diff --git a/contracts/feature-tests/composability/forwarder/src/fwd_esdt.rs b/contracts/feature-tests/composability/forwarder/src/fwd_esdt.rs index 425ca07053..e66f697f88 100644 --- a/contracts/feature-tests/composability/forwarder/src/fwd_esdt.rs +++ b/contracts/feature-tests/composability/forwarder/src/fwd_esdt.rs @@ -95,13 +95,13 @@ pub trait ForwarderEsdtModule: fwd_storage::ForwarderStorageModule { token_ticker: ManagedBuffer, initial_supply: BigUint, ) { - let issue_cost = self.call_value().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, &initial_supply, diff --git a/contracts/feature-tests/composability/forwarder/src/fwd_nft.rs b/contracts/feature-tests/composability/forwarder/src/fwd_nft.rs index 53f01ec5ea..883851f178 100644 --- a/contracts/feature-tests/composability/forwarder/src/fwd_nft.rs +++ b/contracts/feature-tests/composability/forwarder/src/fwd_nft.rs @@ -52,13 +52,13 @@ 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().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_non_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, NonFungibleTokenProperties { diff --git a/contracts/feature-tests/composability/forwarder/src/fwd_sft.rs b/contracts/feature-tests/composability/forwarder/src/fwd_sft.rs index 13d0b3a5ad..657608f17b 100644 --- a/contracts/feature-tests/composability/forwarder/src/fwd_sft.rs +++ b/contracts/feature-tests/composability/forwarder/src/fwd_sft.rs @@ -7,13 +7,13 @@ 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().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_semi_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, SemiFungibleTokenProperties { diff --git a/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs b/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs index e0cf22ab74..457c76b722 100644 --- a/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs +++ b/contracts/feature-tests/composability/local-esdt-and-nft/src/lib.rs @@ -27,13 +27,13 @@ pub trait LocalEsdtAndEsdtNft { token_ticker: ManagedBuffer, initial_supply: BigUint, ) { - let issue_cost = self.call_value().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, &initial_supply, @@ -68,13 +68,13 @@ pub trait LocalEsdtAndEsdtNft { #[payable("EGLD")] #[endpoint(nftIssue)] fn nft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) { - let issue_cost = self.call_value().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_non_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, NonFungibleTokenProperties { @@ -174,13 +174,13 @@ pub trait LocalEsdtAndEsdtNft { #[payable("EGLD")] #[endpoint(sftIssue)] fn sft_issue(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) { - let issue_cost = self.call_value().egld_value(); + let issue_cost = self.call_value().egld(); let caller = self.blockchain().get_caller(); self.send() .esdt_system_sc_proxy() .issue_semi_fungible( - issue_cost.clone_value(), + issue_cost.clone(), &token_display_name, &token_ticker, SemiFungibleTokenProperties { diff --git a/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs b/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs index eacc3064d0..718ecf4a61 100644 --- a/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs +++ b/contracts/feature-tests/composability/proxy-test-first/src/proxy-test-first.rs @@ -29,7 +29,7 @@ pub trait ProxyTestFirst { #[payable("EGLD")] #[endpoint(deploySecondContract)] fn deploy_second_contract(&self, code: ManagedBuffer) -> i32 { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); let (address, init_result) = self .tx() @@ -49,7 +49,7 @@ pub trait ProxyTestFirst { #[payable("EGLD")] #[endpoint(upgradeSecondContract)] fn upgrade_second_contract(&self, code: ManagedBuffer) { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); let other_contract = self.get_other_contract(); self.tx() @@ -66,7 +66,7 @@ pub trait ProxyTestFirst { #[payable("EGLD")] #[endpoint(forwardToOtherContract)] fn forward_to_other_contract(&self) { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); let other_contract = self.get_other_contract(); self.tx() .to(&other_contract) @@ -79,7 +79,7 @@ pub trait ProxyTestFirst { #[payable("EGLD")] #[endpoint(forwardToOtherContractWithCallback)] fn forward_to_other_contract_with_callback(&self) { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); let other_contract = self.get_other_contract(); self.tx() .to(&other_contract) diff --git a/contracts/feature-tests/composability/proxy-test-second/src/proxy-test-second.rs b/contracts/feature-tests/composability/proxy-test-second/src/proxy-test-second.rs index 33f199cfb5..5f0d249f89 100644 --- a/contracts/feature-tests/composability/proxy-test-second/src/proxy-test-second.rs +++ b/contracts/feature-tests/composability/proxy-test-second/src/proxy-test-second.rs @@ -28,7 +28,7 @@ pub trait ProxyTestSecond { #[init] #[payable("EGLD")] fn init(&self, init_arg: i32) -> i32 { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); self.set_last_payment(&payment); self.set_init_arg(init_arg); init_arg + 1 @@ -43,7 +43,7 @@ pub trait ProxyTestSecond { #[payable("EGLD")] #[endpoint(payMe)] fn pay_me(&self, arg1: i64) { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); self.set_last_payment(&payment); self.set_pay_me_arg(arg1); } @@ -51,7 +51,7 @@ pub trait ProxyTestSecond { #[payable("EGLD")] #[endpoint(payMeWithResult)] fn pay_me_with_result_endpoint(&self, arg1: i64) -> i64 { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); self.set_last_payment(&payment); self.set_pay_me_arg(arg1); diff --git a/contracts/feature-tests/composability/vault/src/vault.rs b/contracts/feature-tests/composability/vault/src/vault.rs index 47d7406ac4..38f9237ef8 100644 --- a/contracts/feature-tests/composability/vault/src/vault.rs +++ b/contracts/feature-tests/composability/vault/src/vault.rs @@ -51,10 +51,7 @@ pub trait Vault { } fn all_transfers_multi(&self) -> MultiValueEncoded { - self.call_value() - .all_transfers() - .clone_value() - .into_multi_value() + self.call_value().all_transfers().clone().into_multi_value() } #[payable("*")] diff --git a/contracts/feature-tests/payable-features/src/payable_features.rs b/contracts/feature-tests/payable-features/src/payable_features.rs index 27ecd1f439..22c2cda5e7 100644 --- a/contracts/feature-tests/payable-features/src/payable_features.rs +++ b/contracts/feature-tests/payable-features/src/payable_features.rs @@ -16,7 +16,7 @@ pub trait PayableFeatures { #[payable("*")] fn echo_call_value_legacy(&self) -> MultiValue2> { ( - self.call_value().egld_value().clone_value(), + self.call_value().egld_direct_non_strict().clone_value(), self.call_value().all_esdt_transfers().clone_value(), ) .into() @@ -25,7 +25,7 @@ pub trait PayableFeatures { #[view] #[payable("*")] fn echo_call_value(&self) -> ManagedVec { - self.call_value().all_transfers().clone_value() + self.call_value().all_transfers().clone() } #[endpoint] @@ -34,7 +34,7 @@ pub trait PayableFeatures { &self, #[payment_multi] payments: ManagedRef<'static, ManagedVec>>, ) -> ManagedVec> { - payments.clone_value() + payments.clone() } #[endpoint] @@ -104,7 +104,7 @@ pub trait PayableFeatures { &self, #[payment_token] token: EgldOrEsdtTokenIdentifier, ) -> MultiValue2 { - let payment = self.call_value().egld_value().clone_value(); + let payment = self.call_value().egld().clone(); (payment, token).into() } @@ -124,16 +124,16 @@ pub trait PayableFeatures { &self, #[payment_token] token: EgldOrEsdtTokenIdentifier, ) -> MultiValue2 { - let payment = self.call_value().egld_value().clone_value(); + let payment = self.call_value().egld().clone(); (payment, token).into() } #[endpoint] #[payable("EGLD")] fn payable_egld_4(&self) -> MultiValue2 { - let payment = self.call_value().egld_value(); + let payment = self.call_value().egld(); let token = self.call_value().egld_or_single_esdt().token_identifier; - (payment.clone_value(), token).into() + (payment.clone(), token).into() } #[endpoint] diff --git a/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs b/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs index 9d7be05858..67157e0142 100644 --- a/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs +++ b/contracts/feature-tests/rust-testing-framework-tester/src/lib.rs @@ -57,13 +57,13 @@ pub trait RustTestingFrameworkTester: dummy_module::DummyModule { #[payable("EGLD")] #[endpoint] fn receive_egld(&self) -> BigUint { - self.call_value().egld_value().clone_value() + self.call_value().egld().clone() } #[payable("EGLD")] #[endpoint] fn recieve_egld_half(&self) { - let payment_amount = &*self.call_value().egld_value() / 2u32; + let payment_amount = &*self.call_value().egld() / 2u32; self.tx().to(ToCaller).egld(payment_amount).transfer(); } @@ -95,7 +95,7 @@ pub trait RustTestingFrameworkTester: dummy_module::DummyModule { #[payable("*")] #[endpoint] fn receive_multi_esdt(&self) -> ManagedVec> { - self.call_value().all_esdt_transfers().clone_value() + self.call_value().all_esdt_transfers().clone() } #[payable("*")] diff --git a/contracts/feature-tests/use-module/tests/use_module_scenario_rs_test.rs b/contracts/feature-tests/use-module/tests/use_module_scenario_rs_test.rs index 7a14793c46..27e698c153 100644 --- a/contracts/feature-tests/use-module/tests/use_module_scenario_rs_test.rs +++ b/contracts/feature-tests/use-module/tests/use_module_scenario_rs_test.rs @@ -6,7 +6,7 @@ mod dns_mock { #[payable("EGLD")] #[endpoint] fn register(&self, name: BoxedBytes) { - let _payment = self.call_value().egld_value(); + let _payment = self.call_value().egld(); let address = self.blockchain().get_caller(); self.tx() .to(&address) diff --git a/contracts/modules/src/default_issue_callbacks.rs b/contracts/modules/src/default_issue_callbacks.rs index 8e9e1c6e90..036ac2da0d 100644 --- a/contracts/modules/src/default_issue_callbacks.rs +++ b/contracts/modules/src/default_issue_callbacks.rs @@ -46,8 +46,8 @@ pub trait DefaultIssueCallbacksModule { } fn return_failed_issue_funds(&self, initial_caller: ManagedAddress) { - let egld_returned = self.call_value().egld_value().to_u64().unwrap(); - if egld_returned > 0u64 { + let egld_returned = self.call_value().egld_direct_non_strict(); + if *egld_returned > 0u64 { self.tx().to(&initial_caller).egld(egld_returned).transfer(); } } diff --git a/contracts/modules/src/dns.rs b/contracts/modules/src/dns.rs index 7e8123a0cf..8b4706fcf9 100644 --- a/contracts/modules/src/dns.rs +++ b/contracts/modules/src/dns.rs @@ -13,7 +13,7 @@ pub trait DnsModule { #[only_owner] #[endpoint(dnsRegister)] fn dns_register(&self, dns_address: ManagedAddress, name: ManagedBuffer) { - let payment = self.call_value().egld_value().clone_value(); + let payment = self.call_value().egld().clone(); self.tx() .to(&dns_address) .typed(dns_proxy::DnsProxy) diff --git a/contracts/modules/src/esdt.rs b/contracts/modules/src/esdt.rs index 42314e9608..4fd821b24b 100644 --- a/contracts/modules/src/esdt.rs +++ b/contracts/modules/src/esdt.rs @@ -34,7 +34,7 @@ pub trait EsdtModule { ) { require!(self.token_id().is_empty(), "Token already issued"); - let issue_cost = self.call_value().egld_value().clone_value(); + let issue_cost = self.call_value().egld().clone(); let num_decimals = match opt_num_decimals { OptionalValue::Some(d) => d, OptionalValue::None => 0, @@ -62,7 +62,7 @@ pub trait EsdtModule { ManagedAsyncCallResult::Err(_) => { // return payment to initial caller let initial_caller = self.blockchain().get_owner_address(); - let egld_returned = self.call_value().egld_value(); + let egld_returned = self.call_value().egld(); self.tx() .to(&initial_caller) .egld(egld_returned) diff --git a/contracts/modules/src/token_merge/merged_token_setup.rs b/contracts/modules/src/token_merge/merged_token_setup.rs index f99618e073..540293984c 100644 --- a/contracts/modules/src/token_merge/merged_token_setup.rs +++ b/contracts/modules/src/token_merge/merged_token_setup.rs @@ -14,10 +14,10 @@ pub trait MergedTokenSetupModule { #[payable("EGLD")] #[endpoint(issueMergedToken)] fn issue_merged_token(&self, token_display_name: ManagedBuffer, token_ticker: ManagedBuffer) { - let payment_amount = self.call_value().egld_value(); + let payment_amount = self.call_value().egld(); self.merged_token().issue_and_set_all_roles( EsdtTokenType::NonFungible, - payment_amount.clone_value(), + payment_amount.clone(), token_display_name, token_ticker, 0, diff --git a/framework/base/src/contract_base/wrappers/call_value_wrapper.rs b/framework/base/src/contract_base/wrappers/call_value_wrapper.rs index 043b37e7f4..10a0117af5 100644 --- a/framework/base/src/contract_base/wrappers/call_value_wrapper.rs +++ b/framework/base/src/contract_base/wrappers/call_value_wrapper.rs @@ -47,7 +47,10 @@ where all_transfers_unchecked_handle } - fn egld_value_unchecked(&self) -> ManagedRef<'static, A, BigUint> { + /// Retrieves the EGLD call value from the VM. + /// + /// Will return 0 in case of an ESDT transfer, even though EGLD and ESDT transfers are now posible. + pub fn egld_direct_non_strict(&self) -> ManagedRef<'static, A, BigUint> { let call_value_handle: A::BigIntHandle = use_raw_handle(const_handles::CALL_VALUE_EGLD); if !A::static_var_api_impl() .flag_is_set_or_update(StaticVarApiFlags::CALL_VALUE_EGLD_DIRECT_INITIALIZED) @@ -57,18 +60,50 @@ where unsafe { ManagedRef::wrap_handle(call_value_handle) } } + /// Retrieves the EGLD call value and crashes if anything else was transferred. + /// + /// Accepts both EGLD sent directly, as well as EGLD sent alone in a multi-transfer. + /// + /// Does not accept a multi-transfer with 2 or more transfers, not even 2 or more EGLD transfers. + pub fn egld(&self) -> ManagedRef<'static, A, BigUint> { + let esdt_transfers_handle = self.all_esdt_transfers_unchecked(); + let esdt_transfers: ManagedRef<'static, A, ManagedVec>> = + unsafe { ManagedRef::wrap_handle(esdt_transfers_handle) }; + match esdt_transfers.len() { + 0 => self.egld_direct_non_strict(), + 1 => { + let first = esdt_transfers.get(0); + if !first.token_identifier.is_egld() { + A::error_api_impl().signal_error(err_msg::NON_PAYABLE_FUNC_ESDT.as_bytes()); + } + unsafe { ManagedRef::wrap_handle(first.amount.get_handle()) } + }, + _ => A::error_api_impl().signal_error(err_msg::INCORRECT_NUM_TRANSFERS.as_bytes()), + } + } + /// Retrieves the EGLD call value from the VM. /// /// Will return 0 in case of an ESDT transfer, even though EGLD and ESDT transfers are now posible. + /// + /// ## Important! + /// + /// Does not cover multi-transfer scenarios properly, but left for backwards compatibility. + /// + /// Please use `.egld()` instead! + /// + /// For raw handling, `.egld_direct_non_strict()` is also acceptable. + #[deprecated( + since = "0.55.0", + note = "Does not cover multi-transfer scenarios properly, but left for backwards compatibility. Please use .egld() instead!" + )] pub fn egld_value(&self) -> ManagedRef<'static, A, BigUint> { - self.egld_value_unchecked() + self.egld_direct_non_strict() } /// Returns the EGLD call value from the VM as ManagedDecimal pub fn egld_decimal(&self) -> ManagedDecimal> { - ManagedDecimal::>::const_decimals_from_raw( - self.egld_value().clone_value(), - ) + ManagedDecimal::>::const_decimals_from_raw(self.egld_value().clone()) } /// Returns all ESDT transfers that accompany this SC call. @@ -100,7 +135,7 @@ where if !A::static_var_api_impl() .flag_is_set_or_update(StaticVarApiFlags::CALL_VALUE_ALL_INITIALIZED) { - let egld_single = self.egld_value_unchecked(); + let egld_single = self.egld_direct_non_strict(); if bi_gt_zero::(egld_single.get_handle()) { A::managed_type_impl().mb_overwrite( use_raw_handle(const_handles::MBUF_EGLD_000000), @@ -202,7 +237,7 @@ where 0 => EgldOrEsdtTokenPayment { token_identifier: EgldOrEsdtTokenIdentifier::egld(), token_nonce: 0, - amount: self.egld_value_unchecked().clone_value(), + amount: self.egld_direct_non_strict().clone(), }, 1 => esdt_transfers.get(0).clone(), _ => A::error_api_impl().signal_error(err_msg::INCORRECT_NUM_ESDT_TRANSFERS.as_bytes()), @@ -232,9 +267,9 @@ where pub fn any_payment(&self) -> EgldOrMultiEsdtPayment { let esdt_transfers = self.all_esdt_transfers(); if esdt_transfers.is_empty() { - EgldOrMultiEsdtPayment::Egld(self.egld_value_unchecked().clone_value()) + EgldOrMultiEsdtPayment::Egld(self.egld_direct_non_strict().clone()) } else { - EgldOrMultiEsdtPayment::MultiEsdt(esdt_transfers.clone_value()) + EgldOrMultiEsdtPayment::MultiEsdt(esdt_transfers.clone()) } } } diff --git a/framework/base/src/io/call_value_init.rs b/framework/base/src/io/call_value_init.rs index 93c1bd4f67..81a79b7cd7 100644 --- a/framework/base/src/io/call_value_init.rs +++ b/framework/base/src/io/call_value_init.rs @@ -28,11 +28,10 @@ where /// Called initially in the generated code whenever `#[payable("EGLD")]` annotation is provided. pub fn payable_egld() where - A: CallValueApi + ErrorApi, + A: CallValueApi + ErrorApi + ManagedTypeApi, { - if A::call_value_api_impl().esdt_num_transfers() > 0 { - A::error_api_impl().signal_error(err_msg::NON_PAYABLE_FUNC_ESDT.as_bytes()); - } + // will crash if anything other than (single) EGLD was transferred + let _ = CallValueWrapper::::new().egld(); } /// Called initially in the generated code whenever `#[payable("")]` annotation is provided.