git.delta.rocks / unique-network / refs/commits / ba69054f3875

difftreelog

style fix clippy warnings

Yaroslav Bolyukin2021-11-26parent: #d1696cc.patch.diff
in: master

26 files changed

modified.maintain/frame-weight-template.hbsdiffbeforeafterboth
--- a/.maintain/frame-weight-template.hbs
+++ b/.maintain/frame-weight-template.hbs
@@ -14,6 +14,7 @@
 #![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(unused_parens)]
 #![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
 
 use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
 use sp_std::marker::PhantomData;
modifiedMakefilediffbeforeafterboth
--- a/Makefile
+++ b/Makefile
@@ -57,9 +57,5 @@
 bench-nonfungible:
 	make _bench PALLET=nonfungible
 
-.PHONY: bench-evm-coder-substrate
-bench-evm-coder-substrate:
-	make _bench PALLET=evm-coder-substrate
-
 .PHONY: bench
-bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible bench-evm-coder-substrate
+bench: bench-evm-migration bench-nft bench-fungible bench-refungible bench-nonfungible
modifiedcrates/evm-coder-macros/src/solidity_interface.rsdiffbeforeafterboth
--- a/crates/evm-coder-macros/src/solidity_interface.rs
+++ b/crates/evm-coder-macros/src/solidity_interface.rs
@@ -226,16 +226,10 @@
 		}
 	}
 	fn is_value(&self) -> bool {
-		match self {
-			Self::Plain(v) if v == "value" => true,
-			_ => false,
-		}
+		matches!(self, Self::Plain(v) if v == "value")
 	}
 	fn is_caller(&self) -> bool {
-		match self {
-			Self::Plain(v) if v == "caller" => true,
-			_ => false,
-		}
+		matches!(self, Self::Plain(v) if v == "caller")
 	}
 	fn is_special(&self) -> bool {
 		self.is_caller() || self.is_value()
@@ -599,7 +593,7 @@
 						#args,
 					)*
 				)?;
-				(&result).into_result()
+				(&result).to_result()
 			}
 		}
 	}
modifiedcrates/evm-coder/src/abi.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi.rs
+++ b/crates/evm-coder/src/abi.rs
@@ -310,7 +310,7 @@
 
 pub trait AbiWrite {
 	fn abi_write(&self, writer: &mut AbiWriter);
-	fn into_result(&self) -> ResultWithPostInfo<AbiWriter> {
+	fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {
 		let mut writer = AbiWriter::new();
 		self.abi_write(&mut writer);
 		Ok(writer.into())
@@ -319,7 +319,7 @@
 
 impl<T: AbiWrite> AbiWrite for ResultWithPostInfo<T> {
 	// this particular AbiWrite implementation should be split to another trait,
-	// which only implements [`into_result`]
+	// which only implements [`to_result`]
 	//
 	// But due to lack of specialization feature in stable Rust, we can't have
 	// blanket impl of this trait `for T where T: AbiWrite`, so here we abusing
@@ -327,7 +327,7 @@
 	fn abi_write(&self, _writer: &mut AbiWriter) {
 		debug_assert!(false, "shouldn't be called, see comment")
 	}
-	fn into_result(&self) -> ResultWithPostInfo<AbiWriter> {
+	fn to_result(&self) -> ResultWithPostInfo<AbiWriter> {
 		match self {
 			Ok(v) => Ok(WithPostDispatchInfo {
 				post_info: v.post_info.clone(),
modifiednode/rpc/src/lib.rsdiffbeforeafterboth
--- a/node/rpc/src/lib.rs
+++ b/node/rpc/src/lib.rs
@@ -214,7 +214,7 @@
 			500_usize, // max stored filters
 			overrides.clone(),
 			max_past_logs,
-			block_data_cache.clone(),
+			block_data_cache,
 		)));
 	}
 
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
before · pallets/common/src/lib.rs
1#![cfg_attr(not(feature = "std"), no_std)]23use core::ops::{Deref, DerefMut};4use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};5use sp_std::vec::Vec;6use account::CrossAccountId;7use frame_support::{8	dispatch::{DispatchErrorWithPostInfo, DispatchResultWithPostInfo},9	ensure, fail,10	traits::{Imbalance, Get, Currency},11};12use pallet_evm::GasWeightMapping;13use nft_data_structs::{14	COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, ExistenceRequirement,15	MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,16	COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, Pays, PostDispatchInfo, TokenId, Weight,17	WithdrawReasons, CollectionStats,18};19pub use pallet::*;20use sp_core::H160;21use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};22pub mod account;23#[cfg(feature = "runtime-benchmarks")]24pub mod benchmarking;25pub mod erc;26pub mod eth;2728#[must_use = "Should call submit_logs or save, otherwise some data will be lost for evm side"]29pub struct CollectionHandle<T: Config> {30	pub id: CollectionId,31	collection: Collection<T::AccountId>,32	pub recorder: SubstrateRecorder<T>,33}34impl<T: Config> WithRecorder<T> for CollectionHandle<T> {35	fn recorder(&self) -> &SubstrateRecorder<T> {36		&self.recorder37	}38	fn into_recorder(self) -> SubstrateRecorder<T> {39		self.recorder40	}41}42impl<T: Config> CollectionHandle<T> {43	pub fn new_with_gas_limit(id: CollectionId, gas_limit: u64) -> Option<Self> {44		<CollectionById<T>>::get(id).map(|collection| Self {45			id,46			collection,47			recorder: SubstrateRecorder::new(eth::collection_id_to_address(id), gas_limit),48		})49	}50	pub fn new(id: CollectionId) -> Option<Self> {51		Self::new_with_gas_limit(id, u64::MAX)52	}53	pub fn try_get(id: CollectionId) -> Result<Self, DispatchError> {54		Ok(Self::new(id).ok_or_else(|| <Error<T>>::CollectionNotFound)?)55	}56	pub fn log(&self, log: impl evm_coder::ToLog) {57		self.recorder.log(log)58	}59	pub fn consume_store_reads(&self, reads: u64) -> evm_coder::execution::Result<()> {60		self.recorder61			.consume_gas(T::GasWeightMapping::weight_to_gas(62				<T as frame_system::Config>::DbWeight::get()63					.read64					.saturating_mul(reads),65			))66	}67	pub fn consume_store_writes(&self, writes: u64) -> evm_coder::execution::Result<()> {68		self.recorder69			.consume_gas(T::GasWeightMapping::weight_to_gas(70				<T as frame_system::Config>::DbWeight::get()71					.write72					.saturating_mul(writes),73			))74	}75	pub fn submit_logs(self) {76		self.recorder.submit_logs()77	}78	pub fn save(self) -> DispatchResult {79		self.recorder.submit_logs();80		<CollectionById<T>>::insert(self.id, self.collection);81		Ok(())82	}83}84impl<T: Config> Deref for CollectionHandle<T> {85	type Target = Collection<T::AccountId>;8687	fn deref(&self) -> &Self::Target {88		&self.collection89	}90}9192impl<T: Config> DerefMut for CollectionHandle<T> {93	fn deref_mut(&mut self) -> &mut Self::Target {94		&mut self.collection95	}96}9798impl<T: Config> CollectionHandle<T> {99	pub fn check_is_owner(&self, subject: &T::CrossAccountId) -> DispatchResult {100		ensure!(*subject.as_sub() == self.owner, <Error<T>>::NoPermission);101		Ok(())102	}103	pub fn is_owner_or_admin(&self, subject: &T::CrossAccountId) -> bool {104		*subject.as_sub() == self.owner || <IsAdmin<T>>::get((self.id, subject))105	}106	pub fn check_is_owner_or_admin(&self, subject: &T::CrossAccountId) -> DispatchResult {107		ensure!(self.is_owner_or_admin(subject), <Error<T>>::NoPermission);108		Ok(())109	}110	pub fn ignores_allowance(&self, user: &T::CrossAccountId) -> bool {111		self.limits.owner_can_transfer() && self.is_owner_or_admin(user)112	}113	pub fn ignores_owned_amount(&self, user: &T::CrossAccountId) -> bool {114		self.limits.owner_can_transfer() && self.is_owner_or_admin(user)115	}116	pub fn check_allowlist(&self, user: &T::CrossAccountId) -> DispatchResult {117		ensure!(118			<Allowlist<T>>::get((self.id, user)),119			<Error<T>>::AddressNotInAllowlist120		);121		Ok(())122	}123124	pub fn check_can_update_meta(125		&self,126		subject: &T::CrossAccountId,127		item_owner: &T::CrossAccountId,128	) -> DispatchResult {129		match self.meta_update_permission {130			MetaUpdatePermission::ItemOwner => {131				ensure!(subject == item_owner, <Error<T>>::NoPermission);132				Ok(())133			}134			MetaUpdatePermission::Admin => self.check_is_owner_or_admin(subject),135			MetaUpdatePermission::None => fail!(<Error<T>>::NoPermission),136		}137	}138}139140#[frame_support::pallet]141pub mod pallet {142	use super::*;143	use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};144	use account::CrossAccountId;145	use frame_support::traits::Currency;146	use nft_data_structs::TokenId;147	use scale_info::TypeInfo;148149	#[pallet::config]150	pub trait Config: frame_system::Config + pallet_evm_coder_substrate::Config + TypeInfo {151		type Event: IsType<<Self as frame_system::Config>::Event> + From<Event<Self>>;152153		type CrossAccountId: CrossAccountId<Self::AccountId>;154155		type EvmAddressMapping: pallet_evm::AddressMapping<Self::AccountId>;156		type EvmBackwardsAddressMapping: up_evm_mapping::EvmBackwardsAddressMapping<Self::AccountId>;157158		type Currency: Currency<Self::AccountId>;159		type CollectionCreationPrice: Get<160			<<Self as Config>::Currency as Currency<Self::AccountId>>::Balance,161		>;162		type TreasuryAccountId: Get<Self::AccountId>;163	}164165	#[pallet::pallet]166	#[pallet::generate_store(pub(super) trait Store)]167	pub struct Pallet<T>(_);168169	#[pallet::extra_constants]170	impl<T: Config> Pallet<T> {171		pub fn collection_admins_limit() -> u32 {172			COLLECTION_ADMINS_LIMIT173		}174	}175176	#[pallet::event]177	#[pallet::generate_deposit(pub fn deposit_event)]178	pub enum Event<T: Config> {179		/// New collection was created180		///181		/// # Arguments182		///183		/// * collection_id: Globally unique identifier of newly created collection.184		///185		/// * mode: [CollectionMode] converted into u8.186		///187		/// * account_id: Collection owner.188		CollectionCreated(CollectionId, u8, T::AccountId),189190		/// New item was created.191		///192		/// # Arguments193		///194		/// * collection_id: Id of the collection where item was created.195		///196		/// * item_id: Id of an item. Unique within the collection.197		///198		/// * recipient: Owner of newly created item199		///200		/// * amount: Always 1 for NFT201		ItemCreated(CollectionId, TokenId, T::CrossAccountId, u128),202203		/// Collection item was burned.204		///205		/// # Arguments206		///207		/// * collection_id.208		///209		/// * item_id: Identifier of burned NFT.210		///211		/// * owner: which user has destroyed its tokens212		///213		/// * amount: Always 1 for NFT214		ItemDestroyed(CollectionId, TokenId, T::CrossAccountId, u128),215216		/// Item was transferred217		///218		/// * collection_id: Id of collection to which item is belong219		///220		/// * item_id: Id of an item221		///222		/// * sender: Original owner of item223		///224		/// * recipient: New owner of item225		///226		/// * amount: Always 1 for NFT227		Transfer(228			CollectionId,229			TokenId,230			T::CrossAccountId,231			T::CrossAccountId,232			u128,233		),234235		/// * collection_id236		///237		/// * item_id238		///239		/// * sender240		///241		/// * spender242		///243		/// * amount244		Approved(245			CollectionId,246			TokenId,247			T::CrossAccountId,248			T::CrossAccountId,249			u128,250		),251	}252253	#[pallet::error]254	pub enum Error<T> {255		/// This collection does not exist.256		CollectionNotFound,257		/// Sender parameter and item owner must be equal.258		MustBeTokenOwner,259		/// No permission to perform action260		NoPermission,261		/// Collection is not in mint mode.262		PublicMintingNotAllowed,263		/// Address is not in allow list.264		AddressNotInAllowlist,265266		/// Collection name can not be longer than 63 char.267		CollectionNameLimitExceeded,268		/// Collection description can not be longer than 255 char.269		CollectionDescriptionLimitExceeded,270		/// Token prefix can not be longer than 15 char.271		CollectionTokenPrefixLimitExceeded,272		/// Total collections bound exceeded.273		TotalCollectionsLimitExceeded,274		/// variable_data exceeded data limit.275		TokenVariableDataLimitExceeded,276		/// Exceeded max admin amount277		CollectionAdminAmountExceeded,278279		/// Collection settings not allowing items transferring280		TransferNotAllowed,281		/// Account token limit exceeded per collection282		AccountTokenLimitExceeded,283		/// Collection token limit exceeded284		CollectionTokenLimitExceeded,285		/// Metadata flag frozen286		MetadataFlagFrozen,287288		/// Item not exists.289		TokenNotFound,290		/// Item balance not enough.291		TokenValueTooLow,292		/// Requested value more than approved.293		TokenValueNotEnough,294		/// Tried to approve more than owned295		CantApproveMoreThanOwned,296297		/// Can't transfer tokens to ethereum zero address298		AddressIsZero,299		/// Target collection doesn't supports this operation300		UnsupportedOperation,301	}302303	#[pallet::storage]304	pub type CreatedCollectionCount<T> = StorageValue<Value = CollectionId, QueryKind = ValueQuery>;305	#[pallet::storage]306	pub type DestroyedCollectionCount<T> =307		StorageValue<Value = CollectionId, QueryKind = ValueQuery>;308309	/// Collection info310	#[pallet::storage]311	pub type CollectionById<T> = StorageMap<312		Hasher = Blake2_128Concat,313		Key = CollectionId,314		Value = Collection<<T as frame_system::Config>::AccountId>,315		QueryKind = OptionQuery,316	>;317318	#[pallet::storage]319	pub type AdminAmount<T> = StorageMap<320		Hasher = Blake2_128Concat,321		Key = CollectionId,322		Value = u32,323		QueryKind = ValueQuery,324	>;325326	/// List of collection admins327	#[pallet::storage]328	pub type IsAdmin<T: Config> = StorageNMap<329		Key = (330			Key<Blake2_128Concat, CollectionId>,331			Key<Blake2_128Concat, T::CrossAccountId>,332		),333		Value = bool,334		QueryKind = ValueQuery,335	>;336337	/// Allowlisted collection users338	#[pallet::storage]339	pub type Allowlist<T: Config> = StorageNMap<340		Key = (341			Key<Blake2_128Concat, CollectionId>,342			Key<Blake2_128Concat, T::CrossAccountId>,343		),344		Value = bool,345		QueryKind = ValueQuery,346	>;347348	/// Not used by code, exists only to provide some types to metadata349	#[pallet::storage]350	pub type DummyStorageValue<T> =351		StorageValue<Value = (CollectionStats, CollectionId, TokenId), QueryKind = OptionQuery>;352}353354impl<T: Config> Pallet<T> {355	/// Ethereum receiver 0x0000000000000000000000000000000000000000 is reserved, and shouldn't own tokens356	pub fn ensure_correct_receiver(receiver: &T::CrossAccountId) -> DispatchResult {357		ensure!(358			&T::CrossAccountId::from_eth(H160([0; 20])) != receiver,359			<Error<T>>::AddressIsZero360		);361		Ok(())362	}363	pub fn adminlist(collection: CollectionId) -> Vec<T::CrossAccountId> {364		<IsAdmin<T>>::iter_prefix((collection,))365			.map(|(a, _)| a)366			.collect()367	}368	pub fn allowlist(collection: CollectionId) -> Vec<T::CrossAccountId> {369		<Allowlist<T>>::iter_prefix((collection,))370			.map(|(a, _)| a)371			.collect()372	}373	pub fn allowed(collection: CollectionId, user: T::CrossAccountId) -> bool {374		<Allowlist<T>>::get((collection, user))375	}376	pub fn collection_stats() -> CollectionStats {377		let created = <CreatedCollectionCount<T>>::get();378		let destroyed = <DestroyedCollectionCount<T>>::get();379		CollectionStats {380			created: created.0,381			destroyed: destroyed.0,382			alive: created.0 - destroyed.0,383		}384	}385}386387impl<T: Config> Pallet<T> {388	pub fn init_collection(data: Collection<T::AccountId>) -> Result<CollectionId, DispatchError> {389		{390			ensure!(391				data.name.len() <= MAX_COLLECTION_NAME_LENGTH,392				Error::<T>::CollectionNameLimitExceeded393			);394			ensure!(395				data.description.len() <= MAX_COLLECTION_DESCRIPTION_LENGTH,396				Error::<T>::CollectionDescriptionLimitExceeded397			);398			ensure!(399				data.token_prefix.len() <= MAX_TOKEN_PREFIX_LENGTH,400				Error::<T>::CollectionTokenPrefixLimitExceeded401			);402		}403404		let created_count = <CreatedCollectionCount<T>>::get()405			.0406			.checked_add(1)407			.ok_or(ArithmeticError::Overflow)?;408		let destroyed_count = <DestroyedCollectionCount<T>>::get().0;409		let id = CollectionId(created_count);410411		// bound Total number of collections412		ensure!(413			created_count - destroyed_count < COLLECTION_NUMBER_LIMIT,414			<Error<T>>::TotalCollectionsLimitExceeded415		);416417		// =========418419		// Take a (non-refundable) deposit of collection creation420		{421			let mut imbalance =422				<<<T as Config>::Currency as Currency<T::AccountId>>::PositiveImbalance>::zero();423			imbalance.subsume(424				<<T as Config>::Currency as Currency<T::AccountId>>::deposit_creating(425					&T::TreasuryAccountId::get(),426					T::CollectionCreationPrice::get(),427				),428			);429			<T as Config>::Currency::settle(430				&data.owner,431				imbalance,432				WithdrawReasons::TRANSFER,433				ExistenceRequirement::KeepAlive,434			)435			.map_err(|_| Error::<T>::NoPermission)?;436		}437438		<CreatedCollectionCount<T>>::put(created_count);439		<Pallet<T>>::deposit_event(Event::CollectionCreated(440			id,441			data.mode.id(),442			data.owner.clone(),443		));444		<CollectionById<T>>::insert(id, data);445		Ok(id)446	}447448	pub fn destroy_collection(449		collection: CollectionHandle<T>,450		sender: &T::CrossAccountId,451	) -> DispatchResult {452		ensure!(453			collection.limits.owner_can_destroy(),454			<Error<T>>::NoPermission,455		);456		collection.check_is_owner(&sender)?;457458		let destroyed_collections = <DestroyedCollectionCount<T>>::get()459			.0460			.checked_add(1)461			.ok_or(ArithmeticError::Overflow)?;462463		// =========464465		<DestroyedCollectionCount<T>>::put(destroyed_collections);466		<CollectionById<T>>::remove(collection.id);467		<AdminAmount<T>>::remove(collection.id);468		<IsAdmin<T>>::remove_prefix((collection.id,), None);469		<Allowlist<T>>::remove_prefix((collection.id,), None);470		Ok(())471	}472473	pub fn toggle_allowlist(474		collection: &CollectionHandle<T>,475		sender: &T::CrossAccountId,476		user: &T::CrossAccountId,477		allowed: bool,478	) -> DispatchResult {479		collection.check_is_owner_or_admin(&sender)?;480481		// =========482483		if allowed {484			<Allowlist<T>>::insert((collection.id, user), true);485		} else {486			<Allowlist<T>>::remove((collection.id, user));487		}488489		Ok(())490	}491492	pub fn toggle_admin(493		collection: &CollectionHandle<T>,494		sender: &T::CrossAccountId,495		user: &T::CrossAccountId,496		admin: bool,497	) -> DispatchResult {498		collection.check_is_owner_or_admin(&sender)?;499500		let was_admin = <IsAdmin<T>>::get((collection.id, user));501		if was_admin == admin {502			return Ok(());503		}504		let amount = <AdminAmount<T>>::get(collection.id);505506		if admin {507			let amount = amount508				.checked_add(1)509				.ok_or(<Error<T>>::CollectionAdminAmountExceeded)?;510			ensure!(511				amount <= Self::collection_admins_limit(),512				<Error<T>>::CollectionAdminAmountExceeded,513			);514515			// =========516517			<AdminAmount<T>>::insert(collection.id, amount);518			<IsAdmin<T>>::insert((collection.id, user), true);519		} else {520			<AdminAmount<T>>::insert(collection.id, amount.saturating_sub(1));521			<IsAdmin<T>>::remove((collection.id, user));522		}523524		Ok(())525	}526}527528#[macro_export]529macro_rules! unsupported {530	() => {531		Err(<Error<T>>::UnsupportedOperation.into())532	};533}534535/// Worst cases536pub trait CommonWeightInfo {537	fn create_item() -> Weight;538	fn create_multiple_items(amount: u32) -> Weight;539	fn burn_item() -> Weight;540	fn transfer() -> Weight;541	fn approve() -> Weight;542	fn transfer_from() -> Weight;543	fn burn_from() -> Weight;544	fn set_variable_metadata(bytes: u32) -> Weight;545}546547pub trait CommonCollectionOperations<T: Config> {548	fn create_item(549		&self,550		sender: T::CrossAccountId,551		to: T::CrossAccountId,552		data: CreateItemData,553	) -> DispatchResultWithPostInfo;554	fn create_multiple_items(555		&self,556		sender: T::CrossAccountId,557		to: T::CrossAccountId,558		data: Vec<CreateItemData>,559	) -> DispatchResultWithPostInfo;560	fn burn_item(561		&self,562		sender: T::CrossAccountId,563		token: TokenId,564		amount: u128,565	) -> DispatchResultWithPostInfo;566567	fn transfer(568		&self,569		sender: T::CrossAccountId,570		to: T::CrossAccountId,571		token: TokenId,572		amount: u128,573	) -> DispatchResultWithPostInfo;574	fn approve(575		&self,576		sender: T::CrossAccountId,577		spender: T::CrossAccountId,578		token: TokenId,579		amount: u128,580	) -> DispatchResultWithPostInfo;581	fn transfer_from(582		&self,583		sender: T::CrossAccountId,584		from: T::CrossAccountId,585		to: T::CrossAccountId,586		token: TokenId,587		amount: u128,588	) -> DispatchResultWithPostInfo;589	fn burn_from(590		&self,591		sender: T::CrossAccountId,592		from: T::CrossAccountId,593		token: TokenId,594		amount: u128,595	) -> DispatchResultWithPostInfo;596597	fn set_variable_metadata(598		&self,599		sender: T::CrossAccountId,600		token: TokenId,601		data: Vec<u8>,602	) -> DispatchResultWithPostInfo;603604	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId>;605	fn token_exists(&self, token: TokenId) -> bool;606	fn last_token_id(&self) -> TokenId;607608	fn token_owner(&self, token: TokenId) -> T::CrossAccountId;609	fn const_metadata(&self, token: TokenId) -> Vec<u8>;610	fn variable_metadata(&self, token: TokenId) -> Vec<u8>;611612	/// How many tokens collection contains (Applicable to nonfungible/refungible)613	fn collection_tokens(&self) -> u32;614	/// Amount of different tokens account has (Applicable to nonfungible/refungible)615	fn account_balance(&self, account: T::CrossAccountId) -> u32;616	/// Amount of specific token account have (Applicable to fungible/refungible)617	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128;618	fn allowance(619		&self,620		sender: T::CrossAccountId,621		spender: T::CrossAccountId,622		token: TokenId,623	) -> u128;624}625626// Flexible enough for implementing CommonCollectionOperations627pub fn with_weight(res: DispatchResult, weight: Weight) -> DispatchResultWithPostInfo {628	let post_info = PostDispatchInfo {629		actual_weight: Some(weight),630		pays_fee: Pays::Yes,631	};632	match res {633		Ok(()) => Ok(post_info),634		Err(error) => Err(DispatchErrorWithPostInfo { post_info, error }),635	}636}
modifiedpallets/evm-contract-helpers/exp.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/exp.rs
+++ b/pallets/evm-contract-helpers/exp.rs
@@ -532,11 +532,11 @@
             match c.call {
                 InternalCall::ContractOwner { contract_address } => {
                     let result = self.contract_owner(contract_address)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::SponsoringEnabled { contract_address } => {
                     let result = self.sponsoring_enabled(contract_address)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::ToggleSponsoring {
                     contract_address,
@@ -544,7 +544,7 @@
                 } => {
                     let result =
                         self.toggle_sponsoring(c.caller.clone(), contract_address, enabled)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::SetSponsoringRateLimit {
                     contract_address,
@@ -555,22 +555,22 @@
                         contract_address,
                         rate_limit,
                     )?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::GetSponsoringRateLimit { contract_address } => {
                     let result = self.get_sponsoring_rate_limit(contract_address)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::Allowed {
                     contract_address,
                     user,
                 } => {
                     let result = self.allowed(contract_address, user)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::AllowlistEnabled { contract_address } => {
                     let result = self.allowlist_enabled(contract_address)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::ToggleAllowlist {
                     contract_address,
@@ -578,7 +578,7 @@
                 } => {
                     let result =
                         self.toggle_allowlist(c.caller.clone(), contract_address, enabled)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 InternalCall::ToggleAllowed {
                     contract_address,
@@ -587,7 +587,7 @@
                 } => {
                     let result =
                         self.toggle_allowed(c.caller.clone(), contract_address, user, allowed)?;
-                    (&result).into_result()
+                    (&result).to_result()
                 }
                 _ => ::core::panicking::panic("internal error: entered unreachable code"),
             }
modifiedpallets/evm-contract-helpers/src/eth.rsdiffbeforeafterboth
--- a/pallets/evm-contract-helpers/src/eth.rs
+++ b/pallets/evm-contract-helpers/src/eth.rs
@@ -1,10 +1,7 @@
 use core::marker::PhantomData;
 use evm_coder::{abi::AbiWriter, execution::Result, generate_stubgen, solidity_interface, types::*};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
-use pallet_evm::{
-	ExitReason, ExitRevert, OnCreate, OnMethodCall, PrecompileOutput, PrecompileResult,
-	PrecompileFailure,
-};
+use pallet_evm::{ExitRevert, OnCreate, OnMethodCall, PrecompileResult, PrecompileFailure};
 use sp_core::H160;
 use crate::{
 	AllowlistEnabled, Config, Owner, Pallet, SelfSponsoring, SponsorBasket, SponsoringRateLimit,
@@ -161,7 +158,7 @@
 		if let Some(last_tx_block) = <SponsorBasket<T>>::get(&call.0, who) {
 			let limit = <SponsoringRateLimit<T>>::get(&call.0);
 
-			let timeout = last_tx_block + limit.into();
+			let timeout = last_tx_block + limit;
 			if block_number < timeout {
 				return None;
 			}
modifiedpallets/evm-migration/src/weights.rsdiffbeforeafterboth
--- a/pallets/evm-migration/src/weights.rs
+++ b/pallets/evm-migration/src/weights.rs
@@ -25,6 +25,7 @@
 #![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(unused_parens)]
 #![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
 
 use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
 use sp_std::marker::PhantomData;
modifiedpallets/evm-transaction-payment/src/lib.rsdiffbeforeafterboth
--- a/pallets/evm-transaction-payment/src/lib.rs
+++ b/pallets/evm-transaction-payment/src/lib.rs
@@ -128,7 +128,7 @@
 				let sponsor = frame_support::storage::with_transaction(|| {
 					TransactionOutcome::Rollback(T::EvmSponsorshipHandler::get_sponsor(
 						&who,
-						&(target.clone(), input.clone()),
+						&(*target, input.clone()),
 					))
 				})?;
 				let sponsor = T::EvmAddressMapping::into_account_id(sponsor);
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -116,7 +116,7 @@
 		);
 
 		with_weight(
-			<Pallet<T>>::transfer(&self, &from, &to, amount),
+			<Pallet<T>>::transfer(self, &from, &to, amount),
 			<CommonWeights<T>>::transfer(),
 		)
 	}
@@ -134,7 +134,7 @@
 		);
 
 		with_weight(
-			<Pallet<T>>::set_allowance(&self, &sender, &spender, amount),
+			<Pallet<T>>::set_allowance(self, &sender, &spender, amount),
 			<CommonWeights<T>>::approve(),
 		)
 	}
@@ -153,7 +153,7 @@
 		);
 
 		with_weight(
-			<Pallet<T>>::transfer_from(&self, &sender, &from, &to, amount),
+			<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount),
 			<CommonWeights<T>>::transfer_from(),
 		)
 	}
@@ -171,7 +171,7 @@
 		);
 
 		with_weight(
-			<Pallet<T>>::burn_from(&self, &sender, &from, amount),
+			<Pallet<T>>::burn_from(self, &sender, &from, amount),
 			<CommonWeights<T>>::burn_from(),
 		)
 	}
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -6,7 +6,6 @@
 use sp_core::{H160, U256};
 use sp_std::vec::Vec;
 use pallet_common::account::CrossAccountId;
-use pallet_common::erc::PrecompileOutput;
 use pallet_evm_coder_substrate::{call, dispatch_to_evm};
 
 use crate::{
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -303,8 +303,8 @@
 		amount: u128,
 	) -> DispatchResult {
 		if collection.access == AccessMode::AllowList {
-			collection.check_allowlist(&owner)?;
-			collection.check_allowlist(&spender)?;
+			collection.check_allowlist(owner)?;
+			collection.check_allowlist(spender)?;
 		}
 
 		if <Balance<T>>::get((collection.id, owner)) < amount {
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -25,6 +25,7 @@
 #![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(unused_parens)]
 #![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
 
 use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
 use sp_std::marker::PhantomData;
@@ -32,11 +33,11 @@
 /// Weight functions needed for pallet_fungible.
 pub trait WeightInfo {
 	fn create_item() -> Weight;
-	fn burn_from() -> Weight;
 	fn burn_item() -> Weight;
 	fn transfer() -> Weight;
 	fn approve() -> Weight;
 	fn transfer_from() -> Weight;
+	fn burn_from() -> Weight;
 }
 
 /// Weights for pallet_fungible using the Substrate node and recommended hardware.
modifiedpallets/nft/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nft/src/benchmarking.rs
+++ b/pallets/nft/src/benchmarking.rs
@@ -158,6 +158,7 @@
 			sponsored_data_size: Some(0),
 			token_limit: Some(1),
 			sponsor_transfer_timeout: Some(0),
+			sponsor_approve_timeout: None,
 			owner_can_destroy: Some(true),
 			owner_can_transfer: Some(true),
 			sponsored_data_rate_limit: None,
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -195,7 +195,7 @@
 
 			// Create new collection
 			let new_collection = Collection {
-				owner: who.clone(),
+				owner: who,
 				name: collection_name,
 				mode: mode.clone(),
 				mint_mode: false,
modifiedpallets/nft/src/weights.rsdiffbeforeafterboth
--- a/pallets/nft/src/weights.rs
+++ b/pallets/nft/src/weights.rs
@@ -25,6 +25,7 @@
 #![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(unused_parens)]
 #![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
 
 use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
 use sp_std::marker::PhantomData;
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -100,7 +100,7 @@
 		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
 		if amount == 1 {
 			with_weight(
-				<Pallet<T>>::burn(&self, &sender, token),
+				<Pallet<T>>::burn(self, &sender, token),
 				<CommonWeights<T>>::burn_item(),
 			)
 		} else {
@@ -118,7 +118,7 @@
 		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
 		if amount == 1 {
 			with_weight(
-				<Pallet<T>>::transfer(&self, &from, &to, token),
+				<Pallet<T>>::transfer(self, &from, &to, token),
 				<CommonWeights<T>>::transfer(),
 			)
 		} else {
@@ -137,9 +137,9 @@
 
 		with_weight(
 			if amount == 1 {
-				<Pallet<T>>::set_allowance(&self, &sender, token, Some(&spender))
+				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))
 			} else {
-				<Pallet<T>>::set_allowance(&self, &sender, token, None)
+				<Pallet<T>>::set_allowance(self, &sender, token, None)
 			},
 			<CommonWeights<T>>::approve(),
 		)
@@ -157,7 +157,7 @@
 
 		if amount == 1 {
 			with_weight(
-				<Pallet<T>>::transfer_from(&self, &sender, &from, &to, token),
+				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token),
 				<CommonWeights<T>>::transfer_from(),
 			)
 		} else {
@@ -176,7 +176,7 @@
 
 		if amount == 1 {
 			with_weight(
-				<Pallet<T>>::burn_from(&self, &sender, &from, token),
+				<Pallet<T>>::burn_from(self, &sender, &from, token),
 				<CommonWeights<T>>::burn_from(),
 			)
 		} else {
@@ -192,7 +192,7 @@
 	) -> DispatchResultWithPostInfo {
 		let len = data.len();
 		with_weight(
-			<Pallet<T>>::set_variable_metadata(&self, &sender, token, data),
+			<Pallet<T>>::set_variable_metadata(self, &sender, token, data),
 			<CommonWeights<T>>::set_variable_metadata(len as u32),
 		)
 	}
@@ -218,12 +218,12 @@
 	}
 	fn const_metadata(&self, token: TokenId) -> Vec<u8> {
 		<TokenData<T>>::get((self.id, token))
-			.map(|t| t.const_data.clone())
+			.map(|t| t.const_data)
 			.unwrap_or_default()
 	}
 	fn variable_metadata(&self, token: TokenId) -> Vec<u8> {
 		<TokenData<T>>::get((self.id, token))
-			.map(|t| t.variable_data.clone())
+			.map(|t| t.variable_data)
 			.unwrap_or_default()
 	}
 
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -13,7 +13,6 @@
 	erc::{CommonEvmHandler, PrecompileResult},
 };
 use pallet_evm_coder_substrate::call;
-use pallet_common::erc::PrecompileOutput;
 
 use crate::{
 	AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -169,8 +169,8 @@
 		sender: &T::CrossAccountId,
 		token: TokenId,
 	) -> DispatchResult {
-		let token_data = <TokenData<T>>::get((collection.id, token))
-			.ok_or_else(|| <CommonError<T>>::TokenNotFound)?;
+		let token_data =
+			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
 		ensure!(
 			&token_data.owner == sender
 				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(sender)),
@@ -197,7 +197,7 @@
 				collection.id,
 				token,
 				sender.clone(),
-				old_spender.clone(),
+				old_spender,
 				0,
 			));
 		}
@@ -213,7 +213,7 @@
 			token_data.owner,
 			1,
 		));
-		return Ok(());
+		Ok(())
 	}
 
 	pub fn transfer(
@@ -227,8 +227,8 @@
 			<CommonError<T>>::TransferNotAllowed
 		);
 
-		let token_data = <TokenData<T>>::get((collection.id, token))
-			.ok_or_else(|| <CommonError<T>>::TokenNotFound)?;
+		let token_data =
+			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
 		ensure!(
 			&token_data.owner == from
 				|| (collection.limits.owner_can_transfer() && collection.is_owner_or_admin(from)),
@@ -399,7 +399,7 @@
 						collection.id,
 						token,
 						sender.clone(),
-						old_owner.clone(),
+						old_owner,
 						0,
 					));
 				}
@@ -429,7 +429,7 @@
 					collection.id,
 					token,
 					sender.clone(),
-					old_spender.clone(),
+					old_spender,
 					0,
 				));
 			}
@@ -443,9 +443,9 @@
 		spender: Option<&T::CrossAccountId>,
 	) -> DispatchResult {
 		if collection.access == AccessMode::AllowList {
-			collection.check_allowlist(&sender)?;
+			collection.check_allowlist(sender)?;
 			if let Some(spender) = spender {
-				collection.check_allowlist(&spender)?;
+				collection.check_allowlist(spender)?;
 			}
 		}
 
@@ -491,7 +491,7 @@
 
 		// =========
 
-		Self::transfer(collection, &from, to, token)?;
+		Self::transfer(collection, from, to, token)?;
 		// Allowance is reset in [`transfer`]
 		Ok(())
 	}
@@ -519,7 +519,7 @@
 
 		// =========
 
-		Self::burn(collection, &from, token)
+		Self::burn(collection, from, token)
 	}
 
 	pub fn set_variable_metadata(
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -25,6 +25,7 @@
 #![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(unused_parens)]
 #![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
 
 use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
 use sp_std::marker::PhantomData;
@@ -33,11 +34,11 @@
 pub trait WeightInfo {
 	fn create_item() -> Weight;
 	fn create_multiple_items(b: u32, ) -> Weight;
-	fn burn_from() -> Weight;
 	fn burn_item() -> Weight;
 	fn transfer() -> Weight;
 	fn approve() -> Weight;
 	fn transfer_from() -> Weight;
+	fn burn_from() -> Weight;
 	fn set_variable_metadata(b: u32, ) -> Weight;
 }
 
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -135,7 +135,7 @@
 		amount: u128,
 	) -> DispatchResultWithPostInfo {
 		with_weight(
-			<Pallet<T>>::transfer(&self, &from, &to, token, amount),
+			<Pallet<T>>::transfer(self, &from, &to, token, amount),
 			<CommonWeights<T>>::transfer(),
 		)
 	}
@@ -148,7 +148,7 @@
 		amount: u128,
 	) -> DispatchResultWithPostInfo {
 		with_weight(
-			<Pallet<T>>::set_allowance(&self, &sender, &spender, token, amount),
+			<Pallet<T>>::set_allowance(self, &sender, &spender, token, amount),
 			<CommonWeights<T>>::approve(),
 		)
 	}
@@ -162,7 +162,7 @@
 		amount: u128,
 	) -> DispatchResultWithPostInfo {
 		with_weight(
-			<Pallet<T>>::transfer_from(&self, &sender, &from, &to, token, amount),
+			<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, amount),
 			<CommonWeights<T>>::transfer_from(),
 		)
 	}
@@ -175,7 +175,7 @@
 		amount: u128,
 	) -> DispatchResultWithPostInfo {
 		with_weight(
-			<Pallet<T>>::burn_from(&self, &sender, &from, token, amount),
+			<Pallet<T>>::burn_from(self, &sender, &from, token, amount),
 			<CommonWeights<T>>::burn_from(),
 		)
 	}
@@ -188,7 +188,7 @@
 	) -> DispatchResultWithPostInfo {
 		let len = data.len();
 		with_weight(
-			<Pallet<T>>::set_variable_metadata(&self, &sender, token, data),
+			<Pallet<T>>::set_variable_metadata(self, &sender, token, data),
 			<CommonWeights<T>>::set_variable_metadata(len as u32),
 		)
 	}
modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -189,7 +189,7 @@
 		<Balance<T>>::remove_prefix((collection.id, token_id), None);
 		<Allowance<T>>::remove_prefix((collection.id, token_id), None);
 		// TODO: ERC721 transfer event
-		return Ok(());
+		Ok(())
 	}
 
 	pub fn burn(
@@ -367,8 +367,8 @@
 			collection.check_allowlist(sender)?;
 
 			for item in data.iter() {
-				for (user, _) in &item.users {
-					collection.check_allowlist(&user)?;
+				for user in item.users.keys() {
+					collection.check_allowlist(user)?;
 				}
 			}
 		}
@@ -409,7 +409,7 @@
 
 		let mut balances = BTreeMap::new();
 		for data in &data {
-			for (owner, _) in &data.users {
+			for owner in data.users.keys() {
 				let balance = balances
 					.entry(owner)
 					.or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner)));
@@ -483,8 +483,8 @@
 		amount: u128,
 	) -> DispatchResult {
 		if collection.access == AccessMode::AllowList {
-			collection.check_allowlist(&sender)?;
-			collection.check_allowlist(&spender)?;
+			collection.check_allowlist(sender)?;
+			collection.check_allowlist(spender)?;
 		}
 
 		<PalletCommon<T>>::ensure_correct_receiver(spender)?;
modifiedpallets/refungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/refungible/src/weights.rs
+++ b/pallets/refungible/src/weights.rs
@@ -25,6 +25,7 @@
 #![cfg_attr(rustfmt, rustfmt_skip)]
 #![allow(unused_parens)]
 #![allow(unused_imports)]
+#![allow(clippy::unnecessary_cast)]
 
 use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}};
 use sp_std::marker::PhantomData;
@@ -33,7 +34,6 @@
 pub trait WeightInfo {
 	fn create_item() -> Weight;
 	fn create_multiple_items(b: u32, ) -> Weight;
-	fn burn_from() -> Weight;
 	fn burn_item_partial() -> Weight;
 	fn burn_item_fully() -> Weight;
 	fn transfer_normal() -> Weight;
@@ -45,6 +45,7 @@
 	fn transfer_from_creating() -> Weight;
 	fn transfer_from_removing() -> Weight;
 	fn transfer_from_creating_removing() -> Weight;
+	fn burn_from() -> Weight;
 	fn set_variable_metadata(b: u32, ) -> Weight;
 }
 
modifiedprimitives/nft/src/lib.rsdiffbeforeafterboth
--- a/primitives/nft/src/lib.rs
+++ b/primitives/nft/src/lib.rs
@@ -327,8 +327,7 @@
 		D: ser::Serializer,
 		V: Serialize,
 	{
-		let vec: &Vec<_> = &value;
-		vec.serialize(serializer)
+		(value as &Vec<_>).serialize(serializer)
 	}
 
 	pub fn deserialize<'de, D, V, S>(deserializer: D) -> Result<BoundedVec<V, S>, D::Error>
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -1177,6 +1177,7 @@
 			EVM::account_storages(address, H256::from_slice(&tmp[..]))
 		}
 
+		#[allow(clippy::redundant_closure)]
 		fn call(
 			from: H160,
 			to: H160,
@@ -1207,6 +1208,7 @@
 			).map_err(|err| err.into())
 		}
 
+		#[allow(clippy::redundant_closure)]
 		fn create(
 			from: H160,
 			data: Vec<u8>,