Skip to content

Commit

Permalink
replaced clone_value with clone in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
andrei-marinica committed Jan 8, 2025
1 parent 4715c1d commit 64afe64
Show file tree
Hide file tree
Showing 29 changed files with 44 additions and 49 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 @@ -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
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 @@ -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
6 changes: 3 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().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 @@ -44,8 +44,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();
// 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 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
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 @@ -23,7 +23,7 @@ pub trait FractionalNfts: default_issue_callbacks::DefaultIssueCallbacksModule {
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
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 @@ -25,7 +25,7 @@ pub trait NftModule {
self.send()
.esdt_system_sc_proxy()
.issue_non_fungible(
payment_amount.clone_value(),
payment_amount.clone(),
&token_name,
&token_ticker,
NonFungibleTokenProperties {
Expand Down
2 changes: 1 addition & 1 deletion contracts/examples/nft-subscription/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub trait NftSubscription:
fn issue(&self) {
self.token_id().issue_and_set_all_roles(
EsdtTokenType::NonFungible,
self.call_value().egld().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/seed-nft-minter/src/nft_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub trait NftModule:
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait FungibleTokenMapperFeatures:
) {
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,
Expand All @@ -33,7 +33,7 @@ pub trait FungibleTokenMapperFeatures:
};

self.fungible_token_mapper().issue(
payment.clone_value(),
payment.clone(),
ManagedBuffer::new(),
token_ticker,
initial_supply,
Expand Down Expand Up @@ -76,7 +76,7 @@ pub trait FungibleTokenMapperFeatures:
fn issue_and_set_all_roles_fungible(&self, token_ticker: ManagedBuffer) {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub trait NonFungibleTokenMapperFeatures:
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub trait Child {
self.send()
.esdt_system_sc_proxy()
.issue_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
&initial_supply,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub trait ForwarderSyncCallModule {
amount,
OptionalValue::<ManagedBuffer>::Some(b"accept_funds_func".into()),
)
.with_multi_token_transfer(payments.clone_value())
.with_multi_token_transfer(payments.clone())
.execute_on_dest_context::<()>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ pub trait ForwarderEsdtModule: fwd_storage_legacy::ForwarderStorageModule {
self.send()
.esdt_system_sc_proxy()
.issue_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
&initial_supply,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub trait ForwarderNftModule: fwd_storage_legacy::ForwarderStorageModule {
self.send()
.esdt_system_sc_proxy()
.issue_non_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
NonFungibleTokenProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait ForwarderSftModule: fwd_storage_legacy::ForwarderStorageModule {
self.send()
.esdt_system_sc_proxy()
.issue_semi_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
SemiFungibleTokenProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub trait ForwarderRawAsync: super::forwarder_raw_common::ForwarderRawCommon {
self.forward_contract_call(
to,
EgldOrEsdtTokenIdentifier::egld(),
payment.clone_value(),
payment.clone(),
endpoint_name,
args,
)
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().egld().clone_value();
let payment = self.call_value().egld().clone();
let half_gas = self.blockchain().get_gas_left() / 2;
let result = self
.tx()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ pub trait ForwarderSyncCallModule {
&self,
to: ManagedAddress,
) -> ManagedVec<Self::Api, EsdtTokenPayment<Self::Api>> {
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub trait ForwarderDynamicModule:
token_type: EsdtTokenType,
num_decimals: usize,
) {
let issue_cost = self.call_value().egld().clone_value();
let issue_cost = self.call_value().egld().clone();
let caller = self.blockchain().get_caller();

self.send()
Expand All @@ -40,7 +40,7 @@ pub trait ForwarderDynamicModule:
token_type: EsdtTokenType,
num_decimals: usize,
) {
let issue_cost = self.call_value().egld().clone_value();
let issue_cost = self.call_value().egld().clone();
let caller = self.blockchain().get_caller();

self.send()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub trait ForwarderEsdtModule: fwd_storage::ForwarderStorageModule {
self.send()
.esdt_system_sc_proxy()
.issue_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
&initial_supply,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub trait ForwarderNftModule: fwd_storage::ForwarderStorageModule {
self.send()
.esdt_system_sc_proxy()
.issue_non_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
NonFungibleTokenProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub trait ForwarderSftModule: fwd_storage::ForwarderStorageModule {
self.send()
.esdt_system_sc_proxy()
.issue_semi_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
SemiFungibleTokenProperties {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub trait LocalEsdtAndEsdtNft {
self.send()
.esdt_system_sc_proxy()
.issue_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
&initial_supply,
Expand Down Expand Up @@ -74,7 +74,7 @@ pub trait LocalEsdtAndEsdtNft {
self.send()
.esdt_system_sc_proxy()
.issue_non_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
NonFungibleTokenProperties {
Expand Down Expand Up @@ -180,7 +180,7 @@ pub trait LocalEsdtAndEsdtNft {
self.send()
.esdt_system_sc_proxy()
.issue_semi_fungible(
issue_cost.clone_value(),
issue_cost.clone(),
&token_display_name,
&token_ticker,
SemiFungibleTokenProperties {
Expand Down
5 changes: 1 addition & 4 deletions contracts/feature-tests/composability/vault/src/vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ pub trait Vault {
}

fn all_transfers_multi(&self) -> MultiValueEncoded<EgldOrEsdtTokenPaymentMultiValue> {
self.call_value()
.all_transfers()
.clone_value()
.into_multi_value()
self.call_value().all_transfers().clone().into_multi_value()
}

#[payable("*")]
Expand Down
10 changes: 5 additions & 5 deletions contracts/feature-tests/payable-features/src/payable_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub trait PayableFeatures {
#[view]
#[payable("*")]
fn echo_call_value(&self) -> ManagedVec<EgldOrEsdtTokenPayment> {
self.call_value().all_transfers().clone_value()
self.call_value().all_transfers().clone()
}

#[endpoint]
Expand All @@ -34,7 +34,7 @@ pub trait PayableFeatures {
&self,
#[payment_multi] payments: ManagedRef<'static, ManagedVec<EsdtTokenPayment<Self::Api>>>,
) -> ManagedVec<EsdtTokenPayment<Self::Api>> {
payments.clone_value()
payments.clone()
}

#[endpoint]
Expand Down Expand Up @@ -104,7 +104,7 @@ pub trait PayableFeatures {
&self,
#[payment_token] token: EgldOrEsdtTokenIdentifier,
) -> MultiValue2<BigUint, EgldOrEsdtTokenIdentifier> {
let payment = self.call_value().egld().clone_value();
let payment = self.call_value().egld().clone();
(payment, token).into()
}

Expand All @@ -124,7 +124,7 @@ pub trait PayableFeatures {
&self,
#[payment_token] token: EgldOrEsdtTokenIdentifier,
) -> MultiValue2<BigUint, EgldOrEsdtTokenIdentifier> {
let payment = self.call_value().egld().clone_value();
let payment = self.call_value().egld().clone();
(payment, token).into()
}

Expand All @@ -133,7 +133,7 @@ pub trait PayableFeatures {
fn payable_egld_4(&self) -> MultiValue2<BigUint, EgldOrEsdtTokenIdentifier> {
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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub trait RustTestingFrameworkTester: dummy_module::DummyModule {
#[payable("EGLD")]
#[endpoint]
fn receive_egld(&self) -> BigUint {
self.call_value().egld().clone_value()
self.call_value().egld().clone()
}

#[payable("EGLD")]
Expand Down Expand Up @@ -95,7 +95,7 @@ pub trait RustTestingFrameworkTester: dummy_module::DummyModule {
#[payable("*")]
#[endpoint]
fn receive_multi_esdt(&self) -> ManagedVec<EsdtTokenPayment<Self::Api>> {
self.call_value().all_esdt_transfers().clone_value()
self.call_value().all_esdt_transfers().clone()
}

#[payable("*")]
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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().clone_value();
let payment = self.call_value().egld().clone();
self.tx()
.to(&dns_address)
.typed(dns_proxy::DnsProxy)
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/src/esdt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub trait EsdtModule {
) {
require!(self.token_id().is_empty(), "Token already issued");

let issue_cost = self.call_value().egld().clone_value();
let issue_cost = self.call_value().egld().clone();
let num_decimals = match opt_num_decimals {
OptionalValue::Some(d) => d,
OptionalValue::None => 0,
Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/src/token_merge/merged_token_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub trait MergedTokenSetupModule {
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,
Expand Down
10 changes: 4 additions & 6 deletions framework/base/src/contract_base/wrappers/call_value_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ where

/// Returns the EGLD call value from the VM as ManagedDecimal
pub fn egld_decimal(&self) -> ManagedDecimal<A, ConstDecimals<18>> {
ManagedDecimal::<A, ConstDecimals<18>>::const_decimals_from_raw(
self.egld_value().clone_value(),
)
ManagedDecimal::<A, ConstDecimals<18>>::const_decimals_from_raw(self.egld_value().clone())
}

/// Returns all ESDT transfers that accompany this SC call.
Expand Down Expand Up @@ -239,7 +237,7 @@ where
0 => EgldOrEsdtTokenPayment {
token_identifier: EgldOrEsdtTokenIdentifier::egld(),
token_nonce: 0,
amount: self.egld_direct_non_strict().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()),
Expand Down Expand Up @@ -269,9 +267,9 @@ where
pub fn any_payment(&self) -> EgldOrMultiEsdtPayment<A> {
let esdt_transfers = self.all_esdt_transfers();
if esdt_transfers.is_empty() {
EgldOrMultiEsdtPayment::Egld(self.egld_direct_non_strict().clone_value())
EgldOrMultiEsdtPayment::Egld(self.egld_direct_non_strict().clone())
} else {
EgldOrMultiEsdtPayment::MultiEsdt(esdt_transfers.clone_value())
EgldOrMultiEsdtPayment::MultiEsdt(esdt_transfers.clone())
}
}
}
Expand Down

0 comments on commit 64afe64

Please sign in to comment.