diff --git a/framework/base/src/types/interaction/tx.rs b/framework/base/src/types/interaction/tx.rs index 7c18c07a69..e6fe8e4d94 100644 --- a/framework/base/src/types/interaction/tx.rs +++ b/framework/base/src/types/interaction/tx.rs @@ -644,7 +644,7 @@ where fn into_normalized(self) -> ContractCallWithEgld { self.payment.with_normalized( - &self.env, + self.env, self.from, self.to, self.data, diff --git a/framework/base/src/types/interaction/tx_exec/tx_exec_async.rs b/framework/base/src/types/interaction/tx_exec/tx_exec_async.rs index 68ec172561..b7f82557c9 100644 --- a/framework/base/src/types/interaction/tx_exec/tx_exec_async.rs +++ b/framework/base/src/types/interaction/tx_exec/tx_exec_async.rs @@ -126,7 +126,7 @@ where pub fn async_call_and_exit(self) -> ! { self.result_handler.save_callback_closure_to_storage(); self.payment.with_normalized( - &self.env, + self.env, self.from, self.to, self.data.into(), diff --git a/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs b/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs index 4765b47c05..bf0474a85a 100644 --- a/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs +++ b/framework/base/src/types/interaction/tx_exec/tx_exec_async_promises.rs @@ -153,7 +153,7 @@ where let gas = self.gas.gas_value(&self.env); self.payment.with_normalized( - &self.env, + self.env, self.from, self.to, self.data, diff --git a/framework/base/src/types/interaction/tx_exec/tx_exec_sync.rs b/framework/base/src/types/interaction/tx_exec/tx_exec_sync.rs index cef7b1e7e9..f0298bce80 100644 --- a/framework/base/src/types/interaction/tx_exec/tx_exec_sync.rs +++ b/framework/base/src/types/interaction/tx_exec/tx_exec_sync.rs @@ -28,7 +28,7 @@ where let gas_limit = self.gas.gas_value(&self.env); let raw_result = self.payment.with_normalized( - &self.env, + self.env, self.from, self.to, self.data.into(), diff --git a/framework/base/src/types/interaction/tx_payment.rs b/framework/base/src/types/interaction/tx_payment.rs index f89080e57d..95f6f33613 100644 --- a/framework/base/src/types/interaction/tx_payment.rs +++ b/framework/base/src/types/interaction/tx_payment.rs @@ -42,7 +42,7 @@ where /// Converts an ESDT call to a built-in function call, if necessary. fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -54,7 +54,7 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, + FunctionCall, ) -> R; /// Payment data to be used by the testing framework. Will be refactored. diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_egld.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_egld.rs index 2b8ae73b50..c2aaee7b9f 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_egld.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_egld.rs @@ -1,7 +1,8 @@ use crate::{ contract_base::SendRawWrapper, types::{ - AnnotatedValue, BigUint, ManagedAddress, ManagedBuffer, ManagedRef, ManagedVec, TxFrom, TxToSpecified + AnnotatedValue, BigUint, ManagedAddress, ManagedBuffer, ManagedRef, ManagedVec, TxFrom, + TxToSpecified, }, }; @@ -45,7 +46,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, _from: From, to: To, fc: FunctionCall, @@ -57,12 +58,12 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { - to.with_value_ref(env, |to_addr| { + to.with_value_ref(&env, |to_addr| { self.0 - .with_value_ref(env, |egld_value| f(to_addr.into(), egld_value.into(), &fc)) + .with_value_ref(&env, |egld_value| f(to_addr.into(), egld_value.into(), fc)) }) } diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt.rs index e435747670..80f3017e47 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt.rs @@ -1,4 +1,6 @@ -use crate::types::{BigUint, Egld, EgldOrEsdtTokenPayment, ManagedAddress, ManagedRef, TxFrom, TxToSpecified}; +use crate::types::{ + BigUint, Egld, EgldOrEsdtTokenPayment, ManagedAddress, ManagedRef, TxFrom, TxToSpecified, +}; use super::{FullPaymentData, FunctionCall, TxEnv, TxPayment}; @@ -26,7 +28,7 @@ where fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -38,13 +40,13 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { self.map_ref_egld_or_esdt( - (from, to, fc, f), - |(from, to, fc, f), amount| Egld(amount).with_normalized(env, from, to, fc, f), - |(from, to, fc, f), esdt_payment| esdt_payment.with_normalized(env, from, to, fc, f), + (env, from, to, fc, f), + |(env, from, to, fc, f), amount| Egld(amount).with_normalized(env, from, to, fc, f), + |(env, from, to, fc, f), esdt_payment| esdt_payment.with_normalized(env, from, to, fc, f), ) } @@ -79,7 +81,7 @@ where fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -91,13 +93,13 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { self.map_egld_or_esdt( - (from, to, fc, f), - |(from, to, fc, f), amount| Egld(amount).with_normalized(env, from, to, fc, f), - |(from, to, fc, f), esdt_payment| esdt_payment.with_normalized(env, from, to, fc, f), + (env, from, to, fc, f), + |(env, from, to, fc, f), amount| Egld(amount).with_normalized(env, from, to, fc, f), + |(env, from, to, fc, f), esdt_payment| esdt_payment.with_normalized(env, from, to, fc, f), ) } diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt_refs.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt_refs.rs index c749e3f478..42ff0024aa 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt_refs.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_esdt_refs.rs @@ -1,4 +1,6 @@ -use crate::types::{BigUint, EgldOrEsdtTokenPaymentRefs, ManagedAddress, ManagedRef, TxFrom, TxToSpecified}; +use crate::types::{ + BigUint, EgldOrEsdtTokenPaymentRefs, ManagedAddress, ManagedRef, TxFrom, TxToSpecified, +}; use super::{Egld, FullPaymentData, FunctionCall, TxEnv, TxPayment}; @@ -26,7 +28,7 @@ where fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -38,13 +40,13 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { self.map_egld_or_esdt( - (from, to, fc, f), - |(from, to, fc, f), amount| Egld(amount).with_normalized(env, from, to, fc, f), - |(from, to, fc, f), esdt_payment| esdt_payment.with_normalized(env, from, to, fc, f), + (env, from, to, fc, f), + |(env, from, to, fc, f), amount| Egld(amount).with_normalized(env, from, to, fc, f), + |(env, from, to, fc, f), esdt_payment| esdt_payment.with_normalized(env, from, to, fc, f), ) } diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt.rs index 8da13b88e8..faf70d2c32 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt.rs @@ -27,7 +27,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -39,8 +39,8 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { self.as_refs().with_normalized(env, from, to, fc, f) } @@ -74,7 +74,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -86,7 +86,7 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, + FunctionCall, ) -> R, { self.as_refs().with_normalized(env, from, to, fc, f) diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt_ref.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt_ref.rs index ed03001f7e..ae01a44645 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt_ref.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_egld_or_multi_esdt_ref.rs @@ -1,4 +1,6 @@ -use crate::types::{BigUint, EgldOrMultiEsdtPaymentRefs, ManagedAddress, ManagedRef, TxFrom, TxToSpecified}; +use crate::types::{ + BigUint, EgldOrMultiEsdtPaymentRefs, ManagedAddress, ManagedRef, TxFrom, TxToSpecified, +}; use super::{Egld, FullPaymentData, FunctionCall, TxEnv, TxPayment}; @@ -29,7 +31,7 @@ where fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -41,8 +43,8 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { match self { EgldOrMultiEsdtPaymentRefs::Egld(egld_amount) => { diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_multi_esdt.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_multi_esdt.rs index 72d1204631..b7db6af909 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_multi_esdt.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_multi_esdt.rs @@ -47,7 +47,7 @@ where fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -59,15 +59,19 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { match self.len() { 0 => ().with_normalized(env, from, to, fc, f), 1 => self.get(0).as_refs().with_normalized(env, from, to, fc, f), - _ => to.with_value_ref(env, |to_addr| { + _ => to.with_value_ref(&env, |to_addr| { let fc_conv = fc.convert_to_multi_transfer_esdt_call(to_addr, self); - f((&from.resolve_address(env)).into(), BigUint::zero_ref(), &fc_conv) + f( + (&from.resolve_address(&env)).into(), + BigUint::zero_ref(), + fc_conv, + ) }), } } @@ -104,7 +108,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -116,8 +120,8 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { self.deref().with_normalized(env, from, to, fc, f) } @@ -150,7 +154,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -162,8 +166,8 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { (&self).with_normalized(env, from, to, fc, f) } diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_none.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_none.rs index 941964a938..92742dc253 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_none.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_none.rs @@ -25,7 +25,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, _from: From, to: To, fc: FunctionCall, @@ -37,10 +37,10 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { - to.with_value_ref(env, |to_addr| f(to_addr.into(), BigUint::zero_ref(), &fc)) + to.with_value_ref(&env, |to_addr| f(to_addr.into(), BigUint::zero_ref(), fc)) } fn into_full_payment_data(self, _env: &Env) -> FullPaymentData { diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt.rs index a8d4b63dc2..d0d2bedead 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt.rs @@ -1,5 +1,5 @@ use crate::types::{ - BigUint, EsdtTokenPayment, ManagedAddress, ManagedRef, MultiEsdtPayment, TxFrom, TxToSpecified + BigUint, EsdtTokenPayment, ManagedAddress, ManagedRef, MultiEsdtPayment, TxFrom, TxToSpecified, }; use super::{FullPaymentData, FunctionCall, TxEnv, TxPayment}; @@ -28,7 +28,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -40,8 +40,8 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { self.as_refs().with_normalized(env, from, to, fc, f) } @@ -78,7 +78,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -90,8 +90,8 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { self.as_refs().with_normalized(env, from, to, fc, f) } diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_ref.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_ref.rs index f449bc82de..9fc85f41f8 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_ref.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_ref.rs @@ -1,7 +1,8 @@ use crate::{ contract_base::SendRawWrapper, types::{ - BigUint, EsdtTokenPaymentRefs, ManagedAddress, ManagedRef, MultiEsdtPayment, TxFrom, TxToSpecified + BigUint, EsdtTokenPaymentRefs, ManagedAddress, ManagedRef, MultiEsdtPayment, TxFrom, + TxToSpecified, }, }; @@ -49,7 +50,7 @@ where fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -61,16 +62,20 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { - to.with_value_ref(env, |to_addr| { + to.with_value_ref(&env, |to_addr| { if self.token_nonce == 0 { let fc_conv = fc.convert_to_single_transfer_fungible_call(self); - f(to_addr.into(), BigUint::zero_ref(), &fc_conv) + f(to_addr.into(), BigUint::zero_ref(), fc_conv) } else { let fc_conv = fc.convert_to_single_transfer_nft_call(to_addr, self); - f(ManagedRef::from(&from.resolve_address(env)), BigUint::zero_ref(), &fc_conv) + f( + ManagedRef::from(&from.resolve_address(&env)), + BigUint::zero_ref(), + fc_conv, + ) } }) } diff --git a/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_triple.rs b/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_triple.rs index 5e6096f137..69e74a1c95 100644 --- a/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_triple.rs +++ b/framework/base/src/types/interaction/tx_payment/tx_payment_single_esdt_triple.rs @@ -1,5 +1,5 @@ use crate::types::{ - BigUint, EsdtTokenPayment, ManagedAddress, ManagedRef, TokenIdentifier, TxFrom, TxToSpecified + BigUint, EsdtTokenPayment, ManagedAddress, ManagedRef, TokenIdentifier, TxFrom, TxToSpecified, }; use super::{FullPaymentData, FunctionCall, TxEnv, TxPayment}; @@ -26,7 +26,7 @@ where #[inline] fn with_normalized( self, - env: &Env, + env: Env, from: From, to: To, fc: FunctionCall, @@ -38,8 +38,8 @@ where F: FnOnce( ManagedRef<'_, Env::Api, ManagedAddress>, ManagedRef<'_, Env::Api, BigUint>, - &FunctionCall, - ) -> R + FunctionCall, + ) -> R, { EsdtTokenPayment::from(self).with_normalized(env, from, to, fc, f) } diff --git a/framework/base/src/types/managed/basic/big_uint.rs b/framework/base/src/types/managed/basic/big_uint.rs index 657a017666..4f8ecd7b1b 100644 --- a/framework/base/src/types/managed/basic/big_uint.rs +++ b/framework/base/src/types/managed/basic/big_uint.rs @@ -12,8 +12,7 @@ use crate::{ TopEncodeOutput, TryStaticCast, }, formatter::{hex_util::encode_bytes_as_hex, FormatBuffer, FormatByteReceiver, SCDisplay}, - types::ManagedRef, - types::{heap::BoxedBytes, ManagedBuffer, ManagedBufferCachedBuilder, ManagedType}, + types::{heap::BoxedBytes, ManagedBuffer, ManagedBufferCachedBuilder, ManagedRef, ManagedType}, }; use super::cast_to_i64::cast_to_i64;