git.delta.rocks / unique-network / refs/commits / 2eecdab55d8c

difftreelog

Merge pull request #907 from UniqueNetwork/feature/nft-transfer-correct-weight

Yaroslav Bolyukin2023-04-19parents: #6e3cf5e #ff11326.patch.diff
in: master
feat(weight): added benchs for decompose weight

23 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6262,7 +6262,7 @@
 
 [[package]]
 name = "pallet-common"
-version = "0.1.13"
+version = "0.1.14"
 dependencies = [
  "ethereum",
  "evm-coder",
@@ -6558,7 +6558,7 @@
 
 [[package]]
 name = "pallet-fungible"
-version = "0.1.10"
+version = "0.1.11"
 dependencies = [
  "evm-coder",
  "frame-benchmarking",
@@ -6814,7 +6814,7 @@
 
 [[package]]
 name = "pallet-nonfungible"
-version = "0.1.13"
+version = "0.1.14"
 dependencies = [
  "evm-coder",
  "frame-benchmarking",
modifiedpallets/app-promotion/src/lib.rsdiffbeforeafterboth
--- a/pallets/app-promotion/src/lib.rs
+++ b/pallets/app-promotion/src/lib.rs
@@ -845,7 +845,6 @@
 	/// - `staker`: staker account.
 	pub fn total_staked_by_id(staker: impl EncodeLike<T::AccountId>) -> Option<BalanceOf<T>> {
 		let staked = Staked::<T>::iter_prefix((staker,))
-			.into_iter()
 			.fold(<BalanceOf<T>>::default(), |acc, (_, (amount, _))| {
 				acc + amount
 			});
@@ -864,7 +863,6 @@
 		staker: impl EncodeLike<T::AccountId>,
 	) -> Option<Vec<(T::BlockNumber, BalanceOf<T>)>> {
 		let mut staked = Staked::<T>::iter_prefix((staker,))
-			.into_iter()
 			.map(|(block, (amount, _))| (block, amount))
 			.collect::<Vec<_>>();
 		staked.sort_by_key(|(block, _)| *block);
@@ -883,12 +881,6 @@
 			Self::total_staked_by_id(s.as_sub())
 		})
 	}
-
-	// pub fn cross_id_locked_balance(staker: T::CrossAccountId) -> BalanceOf<T> {
-	// 	Self::get_locked_balance(staker.as_sub())
-	// 		.map(|l| l.amount)
-	// 		.unwrap_or_default()
-	// }
 
 	/// Returns all relay block numbers when stake was made,
 	/// the amount of the stake.
modifiedpallets/common/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/common/CHANGELOG.md
+++ b/pallets/common/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.14] - 2023-03-28
+
+### Added
+
+- Added benchmark to check if user is contained in AllowList (`check_accesslist()`).
+
 ## [0.1.13] - 2023-01-20
 
 ### Changed
modifiedpallets/common/Cargo.tomldiffbeforeafterboth
--- a/pallets/common/Cargo.toml
+++ b/pallets/common/Cargo.toml
@@ -2,7 +2,7 @@
 edition = "2021"
 license = "GPLv3"
 name = "pallet-common"
-version = "0.1.13"
+version = "0.1.14"
 
 [dependencies]
 # Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.
modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -22,8 +22,9 @@
 use frame_benchmarking::{benchmarks, account};
 use up_data_structs::{
 	CollectionMode, CollectionFlags, CreateCollectionData, CollectionId, Property, PropertyKey,
-	PropertyValue, CollectionPermissions, NestingPermissions, MAX_COLLECTION_NAME_LENGTH,
-	MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH, MAX_PROPERTIES_PER_ITEM,
+	PropertyValue, CollectionPermissions, NestingPermissions, AccessMode,
+	MAX_COLLECTION_NAME_LENGTH, MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
+	MAX_PROPERTIES_PER_ITEM,
 };
 use frame_support::{
 	traits::{Currency, Get},
@@ -193,4 +194,28 @@
 		<Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
 		let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();
 	}: {<Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete.into_iter())?}
+
+	check_accesslist{
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			sender: cross_from_sub(owner);
+		};
+
+		let mut collection_handle = <CollectionHandle<T>>::try_get(collection.id)?;
+			<Pallet<T>>::update_permissions(
+				&sender,
+				&mut collection_handle,
+				CollectionPermissions { access: Some(AccessMode::AllowList), ..Default::default() }
+			)?;
+
+		<Pallet<T>>::toggle_allowlist(
+				&collection,
+				&sender,
+				&sender,
+				true,
+			)?;
+
+		assert_eq!(collection_handle.permissions.access(), AccessMode::AllowList);
+
+	}: {collection_handle.check_allowlist(&sender)?;}
 }
addedpallets/common/src/helpers.rsdiffbeforeafterboth
--- /dev/null
+++ b/pallets/common/src/helpers.rs
@@ -0,0 +1,30 @@
+//! # Helpers module
+//!
+//! The module contains helpers.
+//!
+use frame_support::{
+	pallet_prelude::DispatchResultWithPostInfo,
+	weights::Weight,
+	dispatch::{DispatchErrorWithPostInfo, PostDispatchInfo},
+};
+
+/// Add weight for a `DispatchResultWithPostInfo`
+///
+/// - `target`: DispatchResultWithPostInfo to which weight will be added
+/// - `additional_weight`: Weight to be added
+pub fn add_weight_to_post_info(target: &mut DispatchResultWithPostInfo, additional_weight: Weight) {
+	match target {
+		Ok(PostDispatchInfo {
+			actual_weight: Some(weight),
+			..
+		})
+		| Err(DispatchErrorWithPostInfo {
+			post_info: PostDispatchInfo {
+				actual_weight: Some(weight),
+				..
+			},
+			..
+		}) => *weight += additional_weight,
+		_ => {}
+	}
+}
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -92,9 +92,9 @@
 pub mod dispatch;
 pub mod erc;
 pub mod eth;
+pub mod helpers;
 #[allow(missing_docs)]
 pub mod weights;
-
 /// Weight info.
 pub type SelfWeightOf<T> = <T as Config>::WeightInfo;
 
modifiedpallets/common/src/weights.rsdiffbeforeafterboth
--- a/pallets/common/src/weights.rs
+++ b/pallets/common/src/weights.rs
@@ -36,6 +36,7 @@
 pub trait WeightInfo {
 	fn set_collection_properties(b: u32, ) -> Weight;
 	fn delete_collection_properties(b: u32, ) -> Weight;
+	fn check_accesslist() -> Weight;
 }
 
 /// Weights for pallet_common using the Substrate node and recommended hardware.
@@ -69,6 +70,16 @@
 			.saturating_add(T::DbWeight::get().reads(1_u64))
 			.saturating_add(T::DbWeight::get().writes(1_u64))
 	}
+	/// Storage: Common Allowlist (r:1 w:0)
+	/// Proof: Common Allowlist (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
+	fn check_accesslist() -> Weight {
+		// Proof Size summary in bytes:
+		//  Measured:  `340`
+		//  Estimated: `2545`
+		// Minimum execution time: 2_887_000 picoseconds.
+		Weight::from_parts(3_072_000, 2545)
+			.saturating_add(T::DbWeight::get().reads(1_u64))
+	}
 }
 
 // For backwards compatibility and tests
@@ -101,5 +112,15 @@
 			.saturating_add(RocksDbWeight::get().reads(1_u64))
 			.saturating_add(RocksDbWeight::get().writes(1_u64))
 	}
+	/// Storage: Common Allowlist (r:1 w:0)
+	/// Proof: Common Allowlist (max_values: None, max_size: Some(70), added: 2545, mode: MaxEncodedLen)
+	fn check_accesslist() -> Weight {
+		// Proof Size summary in bytes:
+		//  Measured:  `340`
+		//  Estimated: `2545`
+		// Minimum execution time: 2_887_000 picoseconds.
+		Weight::from_parts(3_072_000, 2545)
+			.saturating_add(RocksDbWeight::get().reads(1_u64))
+	}
 }
 
modifiedpallets/foreign-assets/src/impl_fungibles.rsdiffbeforeafterboth
--- a/pallets/foreign-assets/src/impl_fungibles.rs
+++ b/pallets/foreign-assets/src/impl_fungibles.rs
@@ -452,7 +452,8 @@
 					&T::CrossAccountId::from_sub(dest.clone()),
 					amount.into(),
 					&Value::new(0),
-				)?;
+				)
+				.map_err(|e| e.error)?;
 
 				Ok(amount)
 			}
modifiedpallets/fungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/fungible/CHANGELOG.md
+++ b/pallets/fungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.11] - 2023-03-28
+
+### Fixed
+
+- The weight of `transfer` and `transfer_from`.
+
 ## [0.1.10] - 2023-02-01
 
 ### Added
modifiedpallets/fungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/fungible/Cargo.toml
+++ b/pallets/fungible/Cargo.toml
@@ -2,7 +2,7 @@
 edition = "2021"
 license = "GPLv3"
 name = "pallet-fungible"
-version = "0.1.10"
+version = "0.1.11"
 
 [dependencies]
 # Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.
modifiedpallets/fungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/fungible/src/benchmarking.rs
+++ b/pallets/fungible/src/benchmarking.rs
@@ -66,7 +66,7 @@
 		<Pallet<T>>::create_item(&collection, &owner, (burner.clone(), 200), &Unlimited)?;
 	}: {<Pallet<T>>::burn(&collection, &burner, 100)?}
 
-	transfer {
+	transfer_raw {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; to: cross_sub;
@@ -92,14 +92,22 @@
 		<Pallet<T>>::create_item(&collection, &owner, (owner_eth.clone(), 200), &Unlimited)?;
 	}: {<Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, &spender, 100)?}
 
-	transfer_from {
+	check_allowed_raw {
 		bench_init!{
 			owner: sub; collection: collection(owner);
-			owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
+			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
 		};
 		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
 		<Pallet<T>>::set_allowance(&collection, &sender, &spender, 200)?;
-	}: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, 100, &Unlimited)?}
+	}: {<Pallet<T>>::check_allowed(&collection, &spender, &sender, 200, &Unlimited)?;}
+
+	set_allowance_unchecked_raw {
+		bench_init!{
+			owner: sub; collection: collection(owner);
+			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;
+		};
+		<Pallet<T>>::create_item(&collection, &owner, (sender.clone(), 200), &Unlimited)?;
+	}: {<Pallet<T>>::set_allowance_unchecked(&collection, &sender, &spender, 200);}
 
 	burn_from {
 		bench_init!{
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -22,7 +22,7 @@
 };
 use pallet_common::{
 	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
-	weights::WeightInfo as _,
+	weights::WeightInfo as _, SelfWeightOf as PalletCommonWeightOf,
 };
 use pallet_structure::Error as StructureError;
 use sp_runtime::ArithmeticError;
@@ -78,7 +78,7 @@
 	}
 
 	fn transfer() -> Weight {
-		<SelfWeightOf<T>>::transfer()
+		<SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
 	}
 
 	fn approve() -> Weight {
@@ -90,7 +90,9 @@
 	}
 
 	fn transfer_from() -> Weight {
-		<SelfWeightOf<T>>::transfer_from()
+		Self::transfer()
+			+ <SelfWeightOf<T>>::check_allowed_raw()
+			+ <SelfWeightOf<T>>::set_allowance_unchecked_raw()
 	}
 
 	fn burn_from() -> Weight {
@@ -232,10 +234,7 @@
 			<Error<T>>::FungibleItemsHaveNoId
 		);
 
-		with_weight(
-			<Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget),
-			<CommonWeights<T>>::transfer(),
-		)
+		<Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget)
 	}
 
 	fn approve(
@@ -289,10 +288,7 @@
 			<Error<T>>::FungibleItemsHaveNoId
 		);
 
-		with_weight(
-			<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget),
-			<CommonWeights<T>>::transfer_from(),
-		)
+		<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget)
 	}
 
 	fn burn_from(
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -26,6 +26,7 @@
 	CollectionHandle,
 	erc::{CommonEvmHandler, PrecompileResult, CollectionCall},
 	eth::CrossAddress,
+	CommonWeightInfo as _,
 };
 use sp_std::vec::Vec;
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
@@ -39,7 +40,7 @@
 
 use crate::{
 	Allowance, Balance, Config, FungibleHandle, Pallet, TotalSupply, SelfWeightOf,
-	weights::WeightInfo,
+	weights::WeightInfo, common::CommonWeights,
 };
 
 frontier_contract! {
@@ -99,7 +100,7 @@
 		let balance = <Balance<T>>::get((self.id, owner));
 		Ok(balance.into())
 	}
-	#[weight(<SelfWeightOf<T>>::transfer())]
+	#[weight(<CommonWeights<T>>::transfer())]
 	fn transfer(&mut self, caller: Caller, to: Address, amount: U256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = T::CrossAccountId::from_eth(to);
@@ -112,7 +113,7 @@
 		Ok(true)
 	}
 
-	#[weight(<SelfWeightOf<T>>::transfer_from())]
+	#[weight(<CommonWeights<T>>::transfer_from())]
 	fn transfer_from(
 		&mut self,
 		caller: Caller,
@@ -129,7 +130,7 @@
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
 		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
-			.map_err(dispatch_to_evm::<T>)?;
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(true)
 	}
 	#[weight(<SelfWeightOf<T>>::approve())]
@@ -201,7 +202,7 @@
 		let budget = self
 			.recorder
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
-		<Pallet<T>>::create_item(&self, &caller, (to, amount), &budget)
+		<Pallet<T>>::create_item(self, &caller, (to, amount), &budget)
 			.map_err(dispatch_to_evm::<T>)?;
 		Ok(true)
 	}
@@ -289,7 +290,7 @@
 		Ok(true)
 	}
 
-	#[weight(<SelfWeightOf<T>>::transfer())]
+	#[weight(<CommonWeights<T>>::transfer())]
 	fn transfer_cross(&mut self, caller: Caller, to: CrossAddress, amount: U256) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = to.into_sub_cross_account::<T>()?;
@@ -302,7 +303,7 @@
 		Ok(true)
 	}
 
-	#[weight(<SelfWeightOf<T>>::transfer_from())]
+	#[weight(<CommonWeights<T>>::transfer_from())]
 	fn transfer_from_cross(
 		&mut self,
 		caller: Caller,
@@ -319,7 +320,7 @@
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
 		<Pallet<T>>::transfer_from(self, &caller, &from, &to, amount, &budget)
-			.map_err(dispatch_to_evm::<T>)?;
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(true)
 	}
 
modifiedpallets/fungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -80,7 +80,11 @@
 
 use core::ops::Deref;
 use evm_coder::ToLog;
-use frame_support::ensure;
+use frame_support::{
+	ensure,
+	pallet_prelude::{DispatchResultWithPostInfo, Pays},
+	dispatch::PostDispatchInfo,
+};
 use pallet_evm::account::CrossAccountId;
 use up_data_structs::{
 	AccessMode, CollectionId, CollectionFlags, TokenId, CreateCollectionData,
@@ -88,7 +92,8 @@
 };
 use pallet_common::{
 	Error as CommonError, Event as CommonEvent, Pallet as PalletCommon,
-	eth::collection_id_to_address,
+	eth::collection_id_to_address, SelfWeightOf as PalletCommonWeightOf,
+	weights::WeightInfo as CommonWeightInfo, helpers::add_weight_to_post_info,
 };
 use pallet_evm::Pallet as PalletEvm;
 use pallet_structure::Pallet as PalletStructure;
@@ -96,7 +101,7 @@
 use sp_core::H160;
 use sp_runtime::{ArithmeticError, DispatchError, DispatchResult};
 use sp_std::{collections::btree_map::BTreeMap, vec::Vec};
-
+use weights::WeightInfo;
 pub use pallet::*;
 
 use crate::erc::ERC20Events;
@@ -389,18 +394,20 @@
 		to: &T::CrossAccountId,
 		amount: u128,
 		nesting_budget: &dyn Budget,
-	) -> DispatchResult {
+	) -> DispatchResultWithPostInfo {
 		ensure!(
 			collection.limits.transfers_enabled(),
 			<CommonError<T>>::TransferNotAllowed,
 		);
 
+		let mut actual_weight = <SelfWeightOf<T>>::transfer_raw();
+
 		if collection.permissions.access() == AccessMode::AllowList {
 			collection.check_allowlist(from)?;
 			collection.check_allowlist(to)?;
+			actual_weight += <PalletCommonWeightOf<T>>::check_accesslist() * 2;
 		}
 		<PalletCommon<T>>::ensure_correct_receiver(to)?;
-
 		let balance_from = <Balance<T>>::get((collection.id, from))
 			.checked_sub(amount)
 			.ok_or(<CommonError<T>>::TokenValueTooLow)?;
@@ -451,7 +458,11 @@
 			to.clone(),
 			amount,
 		));
-		Ok(())
+
+		Ok(PostDispatchInfo {
+			actual_weight: Some(actual_weight),
+			pays_fee: Pays::Yes,
+		})
 	}
 
 	/// Minting tokens for multiple IDs.
@@ -464,8 +475,8 @@
 		nesting_budget: &dyn Budget,
 	) -> DispatchResult {
 		let total_supply = data
-			.iter()
-			.map(|(_, v)| *v)
+			.values()
+			.copied()
 			.try_fold(<TotalSupply<T>>::get(collection.id), |acc, v| {
 				acc.checked_add(v)
 			})
@@ -718,7 +729,6 @@
 	/// Same as the [`transfer`][`Pallet::transfer`] but spender doesn't needs to be an owner of the token pieces.
 	/// The owner should set allowance for the spender to transfer pieces.
 	///	See [`set_allowance`][`Pallet::set_allowance`] for more details.
-
 	pub fn transfer_from(
 		collection: &FungibleHandle<T>,
 		spender: &T::CrossAccountId,
@@ -726,16 +736,23 @@
 		to: &T::CrossAccountId,
 		amount: u128,
 		nesting_budget: &dyn Budget,
-	) -> DispatchResult {
+	) -> DispatchResultWithPostInfo {
 		let allowance = Self::check_allowed(collection, spender, from, amount, nesting_budget)?;
 
 		// =========
 
-		Self::transfer(collection, from, to, amount, nesting_budget)?;
+		let mut result = Self::transfer(collection, from, to, amount, nesting_budget);
+		add_weight_to_post_info(&mut result, <SelfWeightOf<T>>::check_allowed_raw());
+		result?;
+
 		if let Some(allowance) = allowance {
 			Self::set_allowance_unchecked(collection, from, spender, allowance);
+			add_weight_to_post_info(
+				&mut result,
+				<SelfWeightOf<T>>::set_allowance_unchecked_raw(),
+			)
 		}
-		Ok(())
+		result
 	}
 
 	/// Burn fungible tokens from the account.
modifiedpallets/fungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/fungible/src/weights.rs
+++ b/pallets/fungible/src/weights.rs
@@ -37,10 +37,11 @@
 	fn create_item() -> Weight;
 	fn create_multiple_items_ex(b: u32, ) -> Weight;
 	fn burn_item() -> Weight;
-	fn transfer() -> Weight;
+	fn transfer_raw() -> Weight;
 	fn approve() -> Weight;
 	fn approve_from() -> Weight;
-	fn transfer_from() -> Weight;
+	fn check_allowed_raw() -> Weight;
+	fn set_allowance_unchecked_raw() -> Weight;
 	fn burn_from() -> Weight;
 }
 
@@ -94,12 +95,12 @@
 	}
 	/// Storage: Fungible Balance (r:2 w:2)
 	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
+	fn transfer_raw() -> Weight {
 		// Proof Size summary in bytes:
 		//  Measured:  `182`
 		//  Estimated: `5104`
-		// Minimum execution time: 13_832_000 picoseconds.
-		Weight::from_parts(14_064_000, 5104)
+		// Minimum execution time: 6_678_000 picoseconds.
+		Weight::from_parts(7_151_000, 5104)
 			.saturating_add(T::DbWeight::get().reads(2_u64))
 			.saturating_add(T::DbWeight::get().writes(2_u64))
 	}
@@ -129,19 +130,26 @@
 			.saturating_add(T::DbWeight::get().reads(1_u64))
 			.saturating_add(T::DbWeight::get().writes(1_u64))
 	}
-	/// Storage: Fungible Allowance (r:1 w:1)
+	/// Storage: Fungible Allowance (r:1 w:0)
 	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)
-	/// Storage: Fungible Balance (r:2 w:2)
-	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
-	fn transfer_from() -> Weight {
+	fn check_allowed_raw() -> Weight {
 		// Proof Size summary in bytes:
-		//  Measured:  `300`
-		//  Estimated: `7672`
-		// Minimum execution time: 21_667_000 picoseconds.
-		Weight::from_parts(22_166_000, 7672)
-			.saturating_add(T::DbWeight::get().reads(3_u64))
-			.saturating_add(T::DbWeight::get().writes(3_u64))
+		//  Measured:  `210`
+		//  Estimated: `2568`
+		// Minimum execution time: 2_842_000 picoseconds.
+		Weight::from_parts(3_077_000, 2568)
+			.saturating_add(T::DbWeight::get().reads(1_u64))
 	}
+	/// Storage: Fungible Allowance (r:0 w:1)
+	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)
+	fn set_allowance_unchecked_raw() -> Weight {
+		// Proof Size summary in bytes:
+		//  Measured:  `0`
+		//  Estimated: `0`
+		// Minimum execution time: 2_532_000 picoseconds.
+		Weight::from_parts(2_680_000, 0)
+			.saturating_add(T::DbWeight::get().writes(1_u64))
+	}
 	/// Storage: Fungible Allowance (r:1 w:1)
 	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)
 	/// Storage: Fungible TotalSupply (r:1 w:1)
@@ -208,12 +216,12 @@
 	}
 	/// Storage: Fungible Balance (r:2 w:2)
 	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
+	fn transfer_raw() -> Weight {
 		// Proof Size summary in bytes:
 		//  Measured:  `182`
 		//  Estimated: `5104`
-		// Minimum execution time: 13_832_000 picoseconds.
-		Weight::from_parts(14_064_000, 5104)
+		// Minimum execution time: 6_678_000 picoseconds.
+		Weight::from_parts(7_151_000, 5104)
 			.saturating_add(RocksDbWeight::get().reads(2_u64))
 			.saturating_add(RocksDbWeight::get().writes(2_u64))
 	}
@@ -243,18 +251,25 @@
 			.saturating_add(RocksDbWeight::get().reads(1_u64))
 			.saturating_add(RocksDbWeight::get().writes(1_u64))
 	}
-	/// Storage: Fungible Allowance (r:1 w:1)
+	/// Storage: Fungible Allowance (r:1 w:0)
 	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)
-	/// Storage: Fungible Balance (r:2 w:2)
-	/// Proof: Fungible Balance (max_values: None, max_size: Some(77), added: 2552, mode: MaxEncodedLen)
-	fn transfer_from() -> Weight {
+	fn check_allowed_raw() -> Weight {
 		// Proof Size summary in bytes:
-		//  Measured:  `300`
-		//  Estimated: `7672`
-		// Minimum execution time: 21_667_000 picoseconds.
-		Weight::from_parts(22_166_000, 7672)
-			.saturating_add(RocksDbWeight::get().reads(3_u64))
-			.saturating_add(RocksDbWeight::get().writes(3_u64))
+		//  Measured:  `210`
+		//  Estimated: `2568`
+		// Minimum execution time: 2_842_000 picoseconds.
+		Weight::from_parts(3_077_000, 2568)
+			.saturating_add(RocksDbWeight::get().reads(1_u64))
+	}
+	/// Storage: Fungible Allowance (r:0 w:1)
+	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)
+	fn set_allowance_unchecked_raw() -> Weight {
+		// Proof Size summary in bytes:
+		//  Measured:  `0`
+		//  Estimated: `0`
+		// Minimum execution time: 2_532_000 picoseconds.
+		Weight::from_parts(2_680_000, 0)
+			.saturating_add(RocksDbWeight::get().writes(1_u64))
 	}
 	/// Storage: Fungible Allowance (r:1 w:1)
 	/// Proof: Fungible Allowance (max_values: None, max_size: Some(93), added: 2568, mode: MaxEncodedLen)
modifiedpallets/nonfungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/nonfungible/CHANGELOG.md
+++ b/pallets/nonfungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.14] - 2023-03-28
+
+### Fixed
+
+- The weight of `transfer` and `transfer_from`.
+
 ## [0.1.13] - 2023-01-20
 
 ### Fixed
modifiedpallets/nonfungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/nonfungible/Cargo.toml
+++ b/pallets/nonfungible/Cargo.toml
@@ -2,7 +2,7 @@
 edition = "2021"
 license = "GPLv3"
 name = "pallet-nonfungible"
-version = "0.1.13"
+version = "0.1.14"
 
 [dependencies]
 # Note: `package = "parity-scale-codec"` must be supplied since the `Encode` macro searches for it.
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/benchmarking.rs
+++ b/pallets/nonfungible/src/benchmarking.rs
@@ -121,7 +121,7 @@
 		}
 	}: {<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?}
 
-	transfer {
+	transfer_raw {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; receiver: cross_sub;
@@ -146,14 +146,14 @@
 		let item = create_max_item(&collection, &owner, owner_eth.clone())?;
 	}: {<Pallet<T>>::set_allowance_from(&collection, &sender, &owner_eth, item, Some(&spender))?}
 
-	transfer_from {
+	check_allowed_raw {
 		bench_init!{
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub; sender: cross_sub; spender: cross_sub; receiver: cross_sub;
 		};
 		let item = create_max_item(&collection, &owner, sender.clone())?;
 		<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;
-	}: {<Pallet<T>>::transfer_from(&collection, &spender, &sender, &receiver, item, &Unlimited)?}
+	}: {<Pallet<T>>::check_allowed(&collection, &spender, &sender, item, &Unlimited)?}
 
 	burn_from {
 		bench_init!{
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
before · pallets/nonfungible/src/common.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use core::marker::PhantomData;1819use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};20use up_data_structs::{21	TokenId, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKey,22	PropertyKeyPermission, PropertyValue, TokenOwnerError,23};24use pallet_common::{25	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,26	weights::WeightInfo as _,27};28use sp_runtime::DispatchError;29use sp_std::{vec::Vec, vec};3031use crate::{32	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,33	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,34};3536pub struct CommonWeights<T: Config>(PhantomData<T>);37impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {38	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {39		match data {40			CreateItemExData::NFT(t) => {41				<SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)42					+ t.iter()43						.filter_map(|t| {44							if t.properties.len() > 0 {45								Some(Self::set_token_properties(t.properties.len() as u32))46							} else {47								None48							}49						})50						.fold(Weight::zero(), |a, b| a.saturating_add(b))51			}52			_ => Weight::zero(),53		}54	}5556	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {57		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32)58			+ data59				.iter()60				.filter_map(|t| match t {61					up_data_structs::CreateItemData::NFT(n) if n.properties.len() > 0 => {62						Some(Self::set_token_properties(n.properties.len() as u32))63					}64					_ => None,65				})66				.fold(Weight::zero(), |a, b| a.saturating_add(b))67	}6869	fn burn_item() -> Weight {70		<SelfWeightOf<T>>::burn_item()71	}7273	fn set_collection_properties(amount: u32) -> Weight {74		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)75	}7677	fn delete_collection_properties(amount: u32) -> Weight {78		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)79	}8081	fn set_token_properties(amount: u32) -> Weight {82		<SelfWeightOf<T>>::set_token_properties(amount)83	}8485	fn delete_token_properties(amount: u32) -> Weight {86		<SelfWeightOf<T>>::delete_token_properties(amount)87	}8889	fn set_token_property_permissions(amount: u32) -> Weight {90		<SelfWeightOf<T>>::set_token_property_permissions(amount)91	}9293	fn transfer() -> Weight {94		<SelfWeightOf<T>>::transfer()95	}9697	fn approve() -> Weight {98		<SelfWeightOf<T>>::approve()99	}100101	fn approve_from() -> Weight {102		<SelfWeightOf<T>>::approve_from()103	}104105	fn transfer_from() -> Weight {106		<SelfWeightOf<T>>::transfer_from()107	}108109	fn burn_from() -> Weight {110		<SelfWeightOf<T>>::burn_from()111	}112113	fn burn_recursively_self_raw() -> Weight {114		<SelfWeightOf<T>>::burn_recursively_self_raw()115	}116117	fn burn_recursively_breadth_raw(amount: u32) -> Weight {118		<SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)119			.saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))120	}121122	fn token_owner() -> Weight {123		<SelfWeightOf<T>>::token_owner()124	}125126	fn set_allowance_for_all() -> Weight {127		<SelfWeightOf<T>>::set_allowance_for_all()128	}129130	fn force_repair_item() -> Weight {131		<SelfWeightOf<T>>::repair_item()132	}133}134135fn map_create_data<T: Config>(136	data: up_data_structs::CreateItemData,137	to: &T::CrossAccountId,138) -> Result<CreateItemData<T>, DispatchError> {139	match data {140		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {141			properties: data.properties,142			owner: to.clone(),143		}),144		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),145	}146}147148/// Implementation of `CommonCollectionOperations` for `NonfungibleHandle`. It wraps Nonfungible Pallete149/// methods and adds weight info.150impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {151	fn create_item(152		&self,153		sender: T::CrossAccountId,154		to: T::CrossAccountId,155		data: up_data_structs::CreateItemData,156		nesting_budget: &dyn Budget,157	) -> DispatchResultWithPostInfo {158		let weight = <CommonWeights<T>>::create_item(&data);159		with_weight(160			<Pallet<T>>::create_item(161				self,162				&sender,163				map_create_data::<T>(data, &to)?,164				nesting_budget,165			),166			weight,167		)168	}169170	fn create_multiple_items(171		&self,172		sender: T::CrossAccountId,173		to: T::CrossAccountId,174		data: Vec<up_data_structs::CreateItemData>,175		nesting_budget: &dyn Budget,176	) -> DispatchResultWithPostInfo {177		let weight = <CommonWeights<T>>::create_multiple_items(&data);178		let data = data179			.into_iter()180			.map(|d| map_create_data::<T>(d, &to))181			.collect::<Result<Vec<_>, DispatchError>>()?;182183		with_weight(184			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),185			weight,186		)187	}188189	fn create_multiple_items_ex(190		&self,191		sender: <T>::CrossAccountId,192		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,193		nesting_budget: &dyn Budget,194	) -> DispatchResultWithPostInfo {195		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);196		let data = match data {197			up_data_structs::CreateItemExData::NFT(nft) => nft,198			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),199		};200201		with_weight(202			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),203			weight,204		)205	}206207	fn set_collection_properties(208		&self,209		sender: T::CrossAccountId,210		properties: Vec<Property>,211	) -> DispatchResultWithPostInfo {212		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);213214		with_weight(215			<Pallet<T>>::set_collection_properties(self, &sender, properties),216			weight,217		)218	}219220	fn delete_collection_properties(221		&self,222		sender: &T::CrossAccountId,223		property_keys: Vec<PropertyKey>,224	) -> DispatchResultWithPostInfo {225		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);226227		with_weight(228			<Pallet<T>>::delete_collection_properties(self, sender, property_keys),229			weight,230		)231	}232233	fn set_token_properties(234		&self,235		sender: T::CrossAccountId,236		token_id: TokenId,237		properties: Vec<Property>,238		nesting_budget: &dyn Budget,239	) -> DispatchResultWithPostInfo {240		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);241242		with_weight(243			<Pallet<T>>::set_token_properties(244				self,245				&sender,246				token_id,247				properties.into_iter(),248				false,249				nesting_budget,250			),251			weight,252		)253	}254255	fn delete_token_properties(256		&self,257		sender: T::CrossAccountId,258		token_id: TokenId,259		property_keys: Vec<PropertyKey>,260		nesting_budget: &dyn Budget,261	) -> DispatchResultWithPostInfo {262		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);263264		with_weight(265			<Pallet<T>>::delete_token_properties(266				self,267				&sender,268				token_id,269				property_keys.into_iter(),270				nesting_budget,271			),272			weight,273		)274	}275276	fn set_token_property_permissions(277		&self,278		sender: &T::CrossAccountId,279		property_permissions: Vec<PropertyKeyPermission>,280	) -> DispatchResultWithPostInfo {281		let weight =282			<CommonWeights<T>>::set_token_property_permissions(property_permissions.len() as u32);283284		with_weight(285			<Pallet<T>>::set_token_property_permissions(self, sender, property_permissions),286			weight,287		)288	}289290	fn burn_item(291		&self,292		sender: T::CrossAccountId,293		token: TokenId,294		amount: u128,295	) -> DispatchResultWithPostInfo {296		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);297		if amount == 1 {298			with_weight(299				<Pallet<T>>::burn(self, &sender, token),300				<CommonWeights<T>>::burn_item(),301			)302		} else {303			<Pallet<T>>::check_token_immediate_ownership(self, token, &sender)?;304			Ok(().into())305		}306	}307308	fn burn_item_recursively(309		&self,310		sender: T::CrossAccountId,311		token: TokenId,312		self_budget: &dyn Budget,313		breadth_budget: &dyn Budget,314	) -> DispatchResultWithPostInfo {315		<Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)316	}317318	fn transfer(319		&self,320		from: T::CrossAccountId,321		to: T::CrossAccountId,322		token: TokenId,323		amount: u128,324		nesting_budget: &dyn Budget,325	) -> DispatchResultWithPostInfo {326		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);327		if amount == 1 {328			with_weight(329				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),330				<CommonWeights<T>>::transfer(),331			)332		} else {333			<Pallet<T>>::check_token_immediate_ownership(self, token, &from)?;334			Ok(().into())335		}336	}337338	fn approve(339		&self,340		sender: T::CrossAccountId,341		spender: T::CrossAccountId,342		token: TokenId,343		amount: u128,344	) -> DispatchResultWithPostInfo {345		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);346347		with_weight(348			if amount == 1 {349				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))350			} else {351				<Pallet<T>>::set_allowance(self, &sender, token, None)352			},353			<CommonWeights<T>>::approve(),354		)355	}356357	fn approve_from(358		&self,359		sender: T::CrossAccountId,360		from: T::CrossAccountId,361		to: T::CrossAccountId,362		token: TokenId,363		amount: u128,364	) -> DispatchResultWithPostInfo {365		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);366367		with_weight(368			if amount == 1 {369				<Pallet<T>>::set_allowance_from(self, &sender, &from, token, Some(&to))370			} else {371				<Pallet<T>>::set_allowance_from(self, &sender, &from, token, None)372			},373			<CommonWeights<T>>::approve_from(),374		)375	}376377	fn transfer_from(378		&self,379		sender: T::CrossAccountId,380		from: T::CrossAccountId,381		to: T::CrossAccountId,382		token: TokenId,383		amount: u128,384		nesting_budget: &dyn Budget,385	) -> DispatchResultWithPostInfo {386		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);387388		if amount == 1 {389			with_weight(390				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),391				<CommonWeights<T>>::transfer_from(),392			)393		} else {394			<Pallet<T>>::check_allowed(self, &sender, &from, token, nesting_budget)?;395396			Ok(().into())397		}398	}399400	fn burn_from(401		&self,402		sender: T::CrossAccountId,403		from: T::CrossAccountId,404		token: TokenId,405		amount: u128,406		nesting_budget: &dyn Budget,407	) -> DispatchResultWithPostInfo {408		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);409410		if amount == 1 {411			with_weight(412				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),413				<CommonWeights<T>>::burn_from(),414			)415		} else {416			<Pallet<T>>::check_allowed(self, &sender, &from, token, nesting_budget)?;417418			Ok(().into())419		}420	}421422	fn check_nesting(423		&self,424		sender: T::CrossAccountId,425		from: (CollectionId, TokenId),426		under: TokenId,427		nesting_budget: &dyn Budget,428	) -> sp_runtime::DispatchResult {429		<Pallet<T>>::check_nesting(self, sender, from, under, nesting_budget)430	}431432	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId)) {433		<Pallet<T>>::nest((self.id, under), to_nest);434	}435436	fn unnest(&self, under: TokenId, to_unnest: (CollectionId, TokenId)) {437		<Pallet<T>>::unnest((self.id, under), to_unnest);438	}439440	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {441		<Owned<T>>::iter_prefix((self.id, account))442			.map(|(id, _)| id)443			.collect()444	}445446	fn collection_tokens(&self) -> Vec<TokenId> {447		<TokenData<T>>::iter_prefix((self.id,))448			.map(|(id, _)| id)449			.collect()450	}451452	fn token_exists(&self, token: TokenId) -> bool {453		<Pallet<T>>::token_exists(self, token)454	}455456	fn last_token_id(&self) -> TokenId {457		TokenId(<TokensMinted<T>>::get(self.id))458	}459460	fn token_owner(&self, token: TokenId) -> Result<T::CrossAccountId, TokenOwnerError> {461		<TokenData<T>>::get((self.id, token))462			.map(|t| t.owner)463			.ok_or(TokenOwnerError::NotFound)464	}465466	/// Returns token owners.467	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {468		self.token_owner(token).map_or_else(|_| vec![], |t| vec![t])469	}470471	fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue> {472		<Pallet<T>>::token_properties((self.id, token_id))473			.get(key)474			.cloned()475	}476477	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {478		let properties = <Pallet<T>>::token_properties((self.id, token_id));479480		keys.map(|keys| {481			keys.into_iter()482				.filter_map(|key| {483					properties.get(&key).map(|value| Property {484						key,485						value: value.clone(),486					})487				})488				.collect()489		})490		.unwrap_or_else(|| {491			properties492				.into_iter()493				.map(|(key, value)| Property { key, value })494				.collect()495		})496	}497498	fn total_supply(&self) -> u32 {499		<Pallet<T>>::total_supply(self)500	}501502	fn account_balance(&self, account: T::CrossAccountId) -> u32 {503		<AccountBalance<T>>::get((self.id, account))504	}505506	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {507		if <TokenData<T>>::get((self.id, token))508			.map(|a| a.owner == account)509			.unwrap_or(false)510		{511			1512		} else {513			0514		}515	}516517	fn allowance(518		&self,519		sender: T::CrossAccountId,520		spender: T::CrossAccountId,521		token: TokenId,522	) -> u128 {523		if <TokenData<T>>::get((self.id, token))524			.map(|a| a.owner != sender)525			.unwrap_or(true)526		{527			0528		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {529			1530		} else {531			0532		}533	}534535	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {536		None537	}538539	fn total_pieces(&self, token: TokenId) -> Option<u128> {540		if <TokenData<T>>::contains_key((self.id, token)) {541			Some(1)542		} else {543			None544		}545	}546547	fn set_allowance_for_all(548		&self,549		owner: T::CrossAccountId,550		operator: T::CrossAccountId,551		approve: bool,552	) -> DispatchResultWithPostInfo {553		with_weight(554			<Pallet<T>>::set_allowance_for_all(self, &owner, &operator, approve),555			<CommonWeights<T>>::set_allowance_for_all(),556		)557	}558559	fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {560		<Pallet<T>>::allowance_for_all(self, &owner, &operator)561	}562563	fn repair_item(&self, token: TokenId) -> DispatchResultWithPostInfo {564		with_weight(565			<Pallet<T>>::repair_item(self, token),566			<CommonWeights<T>>::force_repair_item(),567		)568	}569}
after · pallets/nonfungible/src/common.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use core::marker::PhantomData;1819use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};20use up_data_structs::{21	TokenId, CreateItemExData, CollectionId, budget::Budget, Property, PropertyKey,22	PropertyKeyPermission, PropertyValue, TokenOwnerError,23};24use pallet_common::{25	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,26	weights::WeightInfo as _, SelfWeightOf as PalletCommonWeightOf,27};28use sp_runtime::DispatchError;29use sp_std::{vec::Vec, vec};3031use crate::{32	AccountBalance, Allowance, Config, CreateItemData, Error, NonfungibleHandle, Owned, Pallet,33	SelfWeightOf, TokenData, weights::WeightInfo, TokensMinted,34};3536pub struct CommonWeights<T: Config>(PhantomData<T>);37impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {38	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {39		match data {40			CreateItemExData::NFT(t) => {41				<SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)42					+ t.iter()43						.filter_map(|t| {44							if t.properties.len() > 0 {45								Some(Self::set_token_properties(t.properties.len() as u32))46							} else {47								None48							}49						})50						.fold(Weight::zero(), |a, b| a.saturating_add(b))51			}52			_ => Weight::zero(),53		}54	}5556	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {57		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32)58			+ data59				.iter()60				.filter_map(|t| match t {61					up_data_structs::CreateItemData::NFT(n) if n.properties.len() > 0 => {62						Some(Self::set_token_properties(n.properties.len() as u32))63					}64					_ => None,65				})66				.fold(Weight::zero(), |a, b| a.saturating_add(b))67	}6869	fn burn_item() -> Weight {70		<SelfWeightOf<T>>::burn_item()71	}7273	fn set_collection_properties(amount: u32) -> Weight {74		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)75	}7677	fn delete_collection_properties(amount: u32) -> Weight {78		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)79	}8081	fn set_token_properties(amount: u32) -> Weight {82		<SelfWeightOf<T>>::set_token_properties(amount)83	}8485	fn delete_token_properties(amount: u32) -> Weight {86		<SelfWeightOf<T>>::delete_token_properties(amount)87	}8889	fn set_token_property_permissions(amount: u32) -> Weight {90		<SelfWeightOf<T>>::set_token_property_permissions(amount)91	}9293	fn transfer() -> Weight {94		<SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 295	}9697	fn approve() -> Weight {98		<SelfWeightOf<T>>::approve()99	}100101	fn approve_from() -> Weight {102		<SelfWeightOf<T>>::approve_from()103	}104105	fn transfer_from() -> Weight {106		Self::transfer() + <SelfWeightOf<T>>::check_allowed_raw()107	}108109	fn burn_from() -> Weight {110		<SelfWeightOf<T>>::burn_from()111	}112113	fn burn_recursively_self_raw() -> Weight {114		<SelfWeightOf<T>>::burn_recursively_self_raw()115	}116117	fn burn_recursively_breadth_raw(amount: u32) -> Weight {118		<SelfWeightOf<T>>::burn_recursively_breadth_plus_self_plus_self_per_each_raw(amount)119			.saturating_sub(Self::burn_recursively_self_raw().saturating_mul(amount as u64 + 1))120	}121122	fn token_owner() -> Weight {123		<SelfWeightOf<T>>::token_owner()124	}125126	fn set_allowance_for_all() -> Weight {127		<SelfWeightOf<T>>::set_allowance_for_all()128	}129130	fn force_repair_item() -> Weight {131		<SelfWeightOf<T>>::repair_item()132	}133}134135fn map_create_data<T: Config>(136	data: up_data_structs::CreateItemData,137	to: &T::CrossAccountId,138) -> Result<CreateItemData<T>, DispatchError> {139	match data {140		up_data_structs::CreateItemData::NFT(data) => Ok(CreateItemData::<T> {141			properties: data.properties,142			owner: to.clone(),143		}),144		_ => fail!(<Error<T>>::NotNonfungibleDataUsedToMintFungibleCollectionToken),145	}146}147148/// Implementation of `CommonCollectionOperations` for `NonfungibleHandle`. It wraps Nonfungible Pallete149/// methods and adds weight info.150impl<T: Config> CommonCollectionOperations<T> for NonfungibleHandle<T> {151	fn create_item(152		&self,153		sender: T::CrossAccountId,154		to: T::CrossAccountId,155		data: up_data_structs::CreateItemData,156		nesting_budget: &dyn Budget,157	) -> DispatchResultWithPostInfo {158		let weight = <CommonWeights<T>>::create_item(&data);159		with_weight(160			<Pallet<T>>::create_item(161				self,162				&sender,163				map_create_data::<T>(data, &to)?,164				nesting_budget,165			),166			weight,167		)168	}169170	fn create_multiple_items(171		&self,172		sender: T::CrossAccountId,173		to: T::CrossAccountId,174		data: Vec<up_data_structs::CreateItemData>,175		nesting_budget: &dyn Budget,176	) -> DispatchResultWithPostInfo {177		let weight = <CommonWeights<T>>::create_multiple_items(&data);178		let data = data179			.into_iter()180			.map(|d| map_create_data::<T>(d, &to))181			.collect::<Result<Vec<_>, DispatchError>>()?;182183		with_weight(184			<Pallet<T>>::create_multiple_items(self, &sender, data, nesting_budget),185			weight,186		)187	}188189	fn create_multiple_items_ex(190		&self,191		sender: <T>::CrossAccountId,192		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,193		nesting_budget: &dyn Budget,194	) -> DispatchResultWithPostInfo {195		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);196		let data = match data {197			up_data_structs::CreateItemExData::NFT(nft) => nft,198			_ => fail!(Error::<T>::NotNonfungibleDataUsedToMintFungibleCollectionToken),199		};200201		with_weight(202			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),203			weight,204		)205	}206207	fn set_collection_properties(208		&self,209		sender: T::CrossAccountId,210		properties: Vec<Property>,211	) -> DispatchResultWithPostInfo {212		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);213214		with_weight(215			<Pallet<T>>::set_collection_properties(self, &sender, properties),216			weight,217		)218	}219220	fn delete_collection_properties(221		&self,222		sender: &T::CrossAccountId,223		property_keys: Vec<PropertyKey>,224	) -> DispatchResultWithPostInfo {225		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);226227		with_weight(228			<Pallet<T>>::delete_collection_properties(self, sender, property_keys),229			weight,230		)231	}232233	fn set_token_properties(234		&self,235		sender: T::CrossAccountId,236		token_id: TokenId,237		properties: Vec<Property>,238		nesting_budget: &dyn Budget,239	) -> DispatchResultWithPostInfo {240		let weight = <CommonWeights<T>>::set_token_properties(properties.len() as u32);241242		with_weight(243			<Pallet<T>>::set_token_properties(244				self,245				&sender,246				token_id,247				properties.into_iter(),248				false,249				nesting_budget,250			),251			weight,252		)253	}254255	fn delete_token_properties(256		&self,257		sender: T::CrossAccountId,258		token_id: TokenId,259		property_keys: Vec<PropertyKey>,260		nesting_budget: &dyn Budget,261	) -> DispatchResultWithPostInfo {262		let weight = <CommonWeights<T>>::delete_token_properties(property_keys.len() as u32);263264		with_weight(265			<Pallet<T>>::delete_token_properties(266				self,267				&sender,268				token_id,269				property_keys.into_iter(),270				nesting_budget,271			),272			weight,273		)274	}275276	fn set_token_property_permissions(277		&self,278		sender: &T::CrossAccountId,279		property_permissions: Vec<PropertyKeyPermission>,280	) -> DispatchResultWithPostInfo {281		let weight =282			<CommonWeights<T>>::set_token_property_permissions(property_permissions.len() as u32);283284		with_weight(285			<Pallet<T>>::set_token_property_permissions(self, sender, property_permissions),286			weight,287		)288	}289290	fn burn_item(291		&self,292		sender: T::CrossAccountId,293		token: TokenId,294		amount: u128,295	) -> DispatchResultWithPostInfo {296		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);297		if amount == 1 {298			with_weight(299				<Pallet<T>>::burn(self, &sender, token),300				<CommonWeights<T>>::burn_item(),301			)302		} else {303			<Pallet<T>>::check_token_immediate_ownership(self, token, &sender)?;304			Ok(().into())305		}306	}307308	fn burn_item_recursively(309		&self,310		sender: T::CrossAccountId,311		token: TokenId,312		self_budget: &dyn Budget,313		breadth_budget: &dyn Budget,314	) -> DispatchResultWithPostInfo {315		<Pallet<T>>::burn_recursively(self, &sender, token, self_budget, breadth_budget)316	}317318	fn transfer(319		&self,320		from: T::CrossAccountId,321		to: T::CrossAccountId,322		token: TokenId,323		amount: u128,324		nesting_budget: &dyn Budget,325	) -> DispatchResultWithPostInfo {326		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);327		if amount == 1 {328			<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget)329		} else {330			<Pallet<T>>::check_token_immediate_ownership(self, token, &from)?;331			Ok(().into())332		}333	}334335	fn approve(336		&self,337		sender: T::CrossAccountId,338		spender: T::CrossAccountId,339		token: TokenId,340		amount: u128,341	) -> DispatchResultWithPostInfo {342		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);343344		with_weight(345			if amount == 1 {346				<Pallet<T>>::set_allowance(self, &sender, token, Some(&spender))347			} else {348				<Pallet<T>>::set_allowance(self, &sender, token, None)349			},350			<CommonWeights<T>>::approve(),351		)352	}353354	fn approve_from(355		&self,356		sender: T::CrossAccountId,357		from: T::CrossAccountId,358		to: T::CrossAccountId,359		token: TokenId,360		amount: u128,361	) -> DispatchResultWithPostInfo {362		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);363364		with_weight(365			if amount == 1 {366				<Pallet<T>>::set_allowance_from(self, &sender, &from, token, Some(&to))367			} else {368				<Pallet<T>>::set_allowance_from(self, &sender, &from, token, None)369			},370			<CommonWeights<T>>::approve_from(),371		)372	}373374	fn transfer_from(375		&self,376		sender: T::CrossAccountId,377		from: T::CrossAccountId,378		to: T::CrossAccountId,379		token: TokenId,380		amount: u128,381		nesting_budget: &dyn Budget,382	) -> DispatchResultWithPostInfo {383		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);384385		if amount == 1 {386			<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget)387		} else {388			<Pallet<T>>::check_allowed(self, &sender, &from, token, nesting_budget)?;389390			Ok(().into())391		}392	}393394	fn burn_from(395		&self,396		sender: T::CrossAccountId,397		from: T::CrossAccountId,398		token: TokenId,399		amount: u128,400		nesting_budget: &dyn Budget,401	) -> DispatchResultWithPostInfo {402		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);403404		if amount == 1 {405			with_weight(406				<Pallet<T>>::burn_from(self, &sender, &from, token, nesting_budget),407				<CommonWeights<T>>::burn_from(),408			)409		} else {410			<Pallet<T>>::check_allowed(self, &sender, &from, token, nesting_budget)?;411412			Ok(().into())413		}414	}415416	fn check_nesting(417		&self,418		sender: T::CrossAccountId,419		from: (CollectionId, TokenId),420		under: TokenId,421		nesting_budget: &dyn Budget,422	) -> sp_runtime::DispatchResult {423		<Pallet<T>>::check_nesting(self, sender, from, under, nesting_budget)424	}425426	fn nest(&self, under: TokenId, to_nest: (CollectionId, TokenId)) {427		<Pallet<T>>::nest((self.id, under), to_nest);428	}429430	fn unnest(&self, under: TokenId, to_unnest: (CollectionId, TokenId)) {431		<Pallet<T>>::unnest((self.id, under), to_unnest);432	}433434	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {435		<Owned<T>>::iter_prefix((self.id, account))436			.map(|(id, _)| id)437			.collect()438	}439440	fn collection_tokens(&self) -> Vec<TokenId> {441		<TokenData<T>>::iter_prefix((self.id,))442			.map(|(id, _)| id)443			.collect()444	}445446	fn token_exists(&self, token: TokenId) -> bool {447		<Pallet<T>>::token_exists(self, token)448	}449450	fn last_token_id(&self) -> TokenId {451		TokenId(<TokensMinted<T>>::get(self.id))452	}453454	fn token_owner(&self, token: TokenId) -> Result<T::CrossAccountId, TokenOwnerError> {455		<TokenData<T>>::get((self.id, token))456			.map(|t| t.owner)457			.ok_or(TokenOwnerError::NotFound)458	}459460	/// Returns token owners.461	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {462		self.token_owner(token).map_or_else(|_| vec![], |t| vec![t])463	}464465	fn token_property(&self, token_id: TokenId, key: &PropertyKey) -> Option<PropertyValue> {466		<Pallet<T>>::token_properties((self.id, token_id))467			.get(key)468			.cloned()469	}470471	fn token_properties(&self, token_id: TokenId, keys: Option<Vec<PropertyKey>>) -> Vec<Property> {472		let properties = <Pallet<T>>::token_properties((self.id, token_id));473474		keys.map(|keys| {475			keys.into_iter()476				.filter_map(|key| {477					properties.get(&key).map(|value| Property {478						key,479						value: value.clone(),480					})481				})482				.collect()483		})484		.unwrap_or_else(|| {485			properties486				.into_iter()487				.map(|(key, value)| Property { key, value })488				.collect()489		})490	}491492	fn total_supply(&self) -> u32 {493		<Pallet<T>>::total_supply(self)494	}495496	fn account_balance(&self, account: T::CrossAccountId) -> u32 {497		<AccountBalance<T>>::get((self.id, account))498	}499500	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {501		if <TokenData<T>>::get((self.id, token))502			.map(|a| a.owner == account)503			.unwrap_or(false)504		{505			1506		} else {507			0508		}509	}510511	fn allowance(512		&self,513		sender: T::CrossAccountId,514		spender: T::CrossAccountId,515		token: TokenId,516	) -> u128 {517		if <TokenData<T>>::get((self.id, token))518			.map(|a| a.owner != sender)519			.unwrap_or(true)520		{521			0522		} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {523			1524		} else {525			0526		}527	}528529	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {530		None531	}532533	fn total_pieces(&self, token: TokenId) -> Option<u128> {534		if <TokenData<T>>::contains_key((self.id, token)) {535			Some(1)536		} else {537			None538		}539	}540541	fn set_allowance_for_all(542		&self,543		owner: T::CrossAccountId,544		operator: T::CrossAccountId,545		approve: bool,546	) -> DispatchResultWithPostInfo {547		with_weight(548			<Pallet<T>>::set_allowance_for_all(self, &owner, &operator, approve),549			<CommonWeights<T>>::set_allowance_for_all(),550		)551	}552553	fn allowance_for_all(&self, owner: T::CrossAccountId, operator: T::CrossAccountId) -> bool {554		<Pallet<T>>::allowance_for_all(self, &owner, &operator)555	}556557	fn repair_item(&self, token: TokenId) -> DispatchResultWithPostInfo {558		with_weight(559			<Pallet<T>>::repair_item(self, token),560			<CommonWeights<T>>::force_repair_item(),561		)562	}563}
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -39,6 +39,7 @@
 	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
 	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
 	eth::{self, TokenUri},
+	CommonWeightInfo,
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::call;
@@ -47,7 +48,7 @@
 
 use crate::{
 	AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,
-	TokenProperties, SelfWeightOf, weights::WeightInfo,
+	TokenProperties, SelfWeightOf, weights::WeightInfo, common::CommonWeights,
 };
 
 /// Nft events.
@@ -458,7 +459,7 @@
 	/// @param from The current owner of the NFT
 	/// @param to The new owner
 	/// @param tokenId The NFT to transfer
-	#[weight(<SelfWeightOf<T>>::transfer_from())]
+	#[weight(<CommonWeights<T>>::transfer_from())]
 	fn transfer_from(
 		&mut self,
 		caller: Caller,
@@ -475,7 +476,7 @@
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
 		<Pallet<T>>::transfer_from(self, &caller, &from, &to, token, &budget)
-			.map_err(dispatch_to_evm::<T>)?;
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(())
 	}
 
@@ -824,7 +825,7 @@
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
 	/// @param to The new owner
 	/// @param tokenId The NFT to transfer
-	#[weight(<SelfWeightOf<T>>::transfer())]
+	#[weight(<CommonWeights<T>>::transfer())]
 	fn transfer(&mut self, caller: Caller, to: Address, token_id: U256) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let to = T::CrossAccountId::from_eth(to);
@@ -833,7 +834,8 @@
 			.recorder
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
-		<Pallet<T>>::transfer(self, &caller, &to, token, &budget).map_err(dispatch_to_evm::<T>)?;
+		<Pallet<T>>::transfer(self, &caller, &to, token, &budget)
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(())
 	}
 
@@ -842,7 +844,7 @@
 	///  is the zero address. Throws if `tokenId` is not a valid NFT.
 	/// @param to The new owner
 	/// @param tokenId The NFT to transfer
-	#[weight(<SelfWeightOf<T>>::transfer())]
+	#[weight(<CommonWeights<T>>::transfer())]
 	fn transfer_cross(
 		&mut self,
 		caller: Caller,
@@ -856,7 +858,8 @@
 			.recorder
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 
-		<Pallet<T>>::transfer(self, &caller, &to, token, &budget).map_err(dispatch_to_evm::<T>)?;
+		<Pallet<T>>::transfer(self, &caller, &to, token, &budget)
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(())
 	}
 
@@ -866,7 +869,7 @@
 	/// @param from Cross acccount address of current owner
 	/// @param to Cross acccount address of new owner
 	/// @param tokenId The NFT to transfer
-	#[weight(<SelfWeightOf<T>>::transfer())]
+	#[weight(<CommonWeights<T>>::transfer_from())]
 	fn transfer_from_cross(
 		&mut self,
 		caller: Caller,
@@ -882,7 +885,7 @@
 			.recorder
 			.weight_calls_budget(<StructureWeight<T>>::find_parent());
 		Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, &budget)
-			.map_err(dispatch_to_evm::<T>)?;
+			.map_err(|e| dispatch_to_evm::<T>(e.error))?;
 		Ok(())
 	}
 
modifiedpallets/nonfungible/src/lib.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -108,7 +108,8 @@
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
 use pallet_common::{
 	Error as CommonError, Pallet as PalletCommon, Event as CommonEvent, CollectionHandle,
-	eth::collection_id_to_address,
+	eth::collection_id_to_address, SelfWeightOf as PalletCommonWeightOf,
+	weights::WeightInfo as CommonWeightInfo, helpers::add_weight_to_post_info,
 };
 use pallet_structure::{Pallet as PalletStructure, Error as StructureError};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
@@ -802,12 +803,13 @@
 		to: &T::CrossAccountId,
 		token: TokenId,
 		nesting_budget: &dyn Budget,
-	) -> DispatchResult {
+	) -> DispatchResultWithPostInfo {
 		ensure!(
 			collection.limits.transfers_enabled(),
 			<CommonError<T>>::TransferNotAllowed
 		);
 
+		let mut actual_weight = <SelfWeightOf<T>>::transfer_raw();
 		let token_data =
 			<TokenData<T>>::get((collection.id, token)).ok_or(<CommonError<T>>::TokenNotFound)?;
 		ensure!(&token_data.owner == from, <CommonError<T>>::NoPermission);
@@ -815,6 +817,7 @@
 		if collection.permissions.access() == AccessMode::AllowList {
 			collection.check_allowlist(from)?;
 			collection.check_allowlist(to)?;
+			actual_weight += <PalletCommonWeightOf<T>>::check_accesslist() * 2;
 		}
 		<PalletCommon<T>>::ensure_correct_receiver(to)?;
 
@@ -884,7 +887,11 @@
 			to.clone(),
 			1,
 		));
-		Ok(())
+
+		Ok(PostDispatchInfo {
+			actual_weight: Some(actual_weight),
+			pays_fee: Pays::Yes,
+		})
 	}
 
 	/// Batch operation to mint multiple NFT tokens.
@@ -1228,13 +1235,15 @@
 		to: &T::CrossAccountId,
 		token: TokenId,
 		nesting_budget: &dyn Budget,
-	) -> DispatchResult {
+	) -> DispatchResultWithPostInfo {
 		Self::check_allowed(collection, spender, from, token, nesting_budget)?;
 
 		// =========
 
 		// Allowance is reset in [`transfer`]
-		Self::transfer(collection, from, to, token, nesting_budget)
+		let mut result = Self::transfer(collection, from, to, token, nesting_budget);
+		add_weight_to_post_info(&mut result, <SelfWeightOf<T>>::check_allowed_raw());
+		result
 	}
 
 	/// Burn NFT token for `from` account.
modifiedpallets/nonfungible/src/weights.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/weights.rs
+++ b/pallets/nonfungible/src/weights.rs
@@ -40,10 +40,10 @@
 	fn burn_item() -> Weight;
 	fn burn_recursively_self_raw() -> Weight;
 	fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(b: u32, ) -> Weight;
-	fn transfer() -> Weight;
+	fn transfer_raw() -> Weight;
 	fn approve() -> Weight;
 	fn approve_from() -> Weight;
-	fn transfer_from() -> Weight;
+	fn check_allowed_raw() -> Weight;
 	fn burn_from() -> Weight;
 	fn set_token_property_permissions(b: u32, ) -> Weight;
 	fn set_token_properties(b: u32, ) -> Weight;
@@ -217,12 +217,12 @@
 	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
 	/// Storage: Nonfungible Owned (r:0 w:2)
 	/// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
+	fn transfer_raw() -> Weight {
 		// Proof Size summary in bytes:
 		//  Measured:  `412`
 		//  Estimated: `10144`
-		// Minimum execution time: 18_629_000 picoseconds.
-		Weight::from_parts(18_997_000, 10144)
+		// Minimum execution time: 9_307_000 picoseconds.
+		Weight::from_parts(10_108_000, 10144)
 			.saturating_add(T::DbWeight::get().reads(4_u64))
 			.saturating_add(T::DbWeight::get().writes(5_u64))
 	}
@@ -252,22 +252,15 @@
 			.saturating_add(T::DbWeight::get().reads(2_u64))
 			.saturating_add(T::DbWeight::get().writes(1_u64))
 	}
-	/// Storage: Nonfungible Allowance (r:1 w:1)
+	/// Storage: Nonfungible Allowance (r:1 w:0)
 	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible TokenData (r:1 w:1)
-	/// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible AccountBalance (r:2 w:2)
-	/// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
-	/// Storage: Nonfungible Owned (r:0 w:2)
-	/// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
-	fn transfer_from() -> Weight {
+	fn check_allowed_raw() -> Weight {
 		// Proof Size summary in bytes:
-		//  Measured:  `527`
-		//  Estimated: `10144`
-		// Minimum execution time: 24_919_000 picoseconds.
-		Weight::from_parts(25_333_000, 10144)
-			.saturating_add(T::DbWeight::get().reads(4_u64))
-			.saturating_add(T::DbWeight::get().writes(6_u64))
+		//  Measured:  `394`
+		//  Estimated: `2532`
+		// Minimum execution time: 2_668_000 picoseconds.
+		Weight::from_parts(2_877_000, 2532)
+			.saturating_add(T::DbWeight::get().reads(1_u64))
 	}
 	/// Storage: Nonfungible Allowance (r:1 w:1)
 	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
@@ -543,12 +536,12 @@
 	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
 	/// Storage: Nonfungible Owned (r:0 w:2)
 	/// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
-	fn transfer() -> Weight {
+	fn transfer_raw() -> Weight {
 		// Proof Size summary in bytes:
 		//  Measured:  `412`
 		//  Estimated: `10144`
-		// Minimum execution time: 18_629_000 picoseconds.
-		Weight::from_parts(18_997_000, 10144)
+		// Minimum execution time: 9_307_000 picoseconds.
+		Weight::from_parts(10_108_000, 10144)
 			.saturating_add(RocksDbWeight::get().reads(4_u64))
 			.saturating_add(RocksDbWeight::get().writes(5_u64))
 	}
@@ -578,22 +571,15 @@
 			.saturating_add(RocksDbWeight::get().reads(2_u64))
 			.saturating_add(RocksDbWeight::get().writes(1_u64))
 	}
-	/// Storage: Nonfungible Allowance (r:1 w:1)
+	/// Storage: Nonfungible Allowance (r:1 w:0)
 	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible TokenData (r:1 w:1)
-	/// Proof: Nonfungible TokenData (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)
-	/// Storage: Nonfungible AccountBalance (r:2 w:2)
-	/// Proof: Nonfungible AccountBalance (max_values: None, max_size: Some(65), added: 2540, mode: MaxEncodedLen)
-	/// Storage: Nonfungible Owned (r:0 w:2)
-	/// Proof: Nonfungible Owned (max_values: None, max_size: Some(74), added: 2549, mode: MaxEncodedLen)
-	fn transfer_from() -> Weight {
+	fn check_allowed_raw() -> Weight {
 		// Proof Size summary in bytes:
-		//  Measured:  `527`
-		//  Estimated: `10144`
-		// Minimum execution time: 24_919_000 picoseconds.
-		Weight::from_parts(25_333_000, 10144)
-			.saturating_add(RocksDbWeight::get().reads(4_u64))
-			.saturating_add(RocksDbWeight::get().writes(6_u64))
+		//  Measured:  `394`
+		//  Estimated: `2532`
+		// Minimum execution time: 2_668_000 picoseconds.
+		Weight::from_parts(2_877_000, 2532)
+			.saturating_add(RocksDbWeight::get().reads(1_u64))
 	}
 	/// Storage: Nonfungible Allowance (r:1 w:1)
 	/// Proof: Nonfungible Allowance (max_values: None, max_size: Some(57), added: 2532, mode: MaxEncodedLen)