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
before · pallets/foreign-assets/src/impl_fungibles.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/>.1617//! Implementations for fungibles trait.1819use super::*;20use frame_system::Config as SystemConfig;2122use frame_support::traits::tokens::{DepositConsequence, WithdrawConsequence};23use pallet_common::CollectionHandle;24use pallet_fungible::FungibleHandle;25use pallet_common::CommonCollectionOperations;26use up_data_structs::budget::Value;27use sp_runtime::traits::{CheckedAdd, CheckedSub};2829impl<T: Config> fungibles::Inspect<<T as SystemConfig>::AccountId> for Pallet<T>30where31	T: orml_tokens::Config<CurrencyId = AssetIds>,32	BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,33	BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,34	<T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,35	<T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,36{37	type AssetId = AssetIds;38	type Balance = BalanceOf<T>;3940	fn total_issuance(asset: Self::AssetId) -> Self::Balance {41		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible total_issuance");4243		match asset {44			AssetIds::NativeAssetId(NativeCurrency::Here) => {45				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::total_issuance()46					.into()47			}48			AssetIds::NativeAssetId(NativeCurrency::Parent) => {49				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::total_issuance(50					AssetIds::NativeAssetId(NativeCurrency::Parent),51				)52				.into()53			}54			AssetIds::ForeignAssetId(fid) => {55				let target_collection_id = match <AssetBinding<T>>::get(fid) {56					Some(v) => v,57					None => return Zero::zero(),58				};59				let collection_handle = match <CollectionHandle<T>>::try_get(target_collection_id) {60					Ok(v) => v,61					Err(_) => return Zero::zero(),62				};63				let collection = FungibleHandle::cast(collection_handle);64				Self::Balance::try_from(collection.total_supply()).unwrap_or(Zero::zero())65			}66		}67	}6869	fn minimum_balance(asset: Self::AssetId) -> Self::Balance {70		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible minimum_balance");71		match asset {72			AssetIds::NativeAssetId(NativeCurrency::Here) => {73				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::minimum_balance()74					.into()75			}76			AssetIds::NativeAssetId(NativeCurrency::Parent) => {77				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::minimum_balance(78					AssetIds::NativeAssetId(NativeCurrency::Parent),79				)80				.into()81			}82			AssetIds::ForeignAssetId(fid) => {83				AssetMetadatas::<T>::get(AssetIds::ForeignAssetId(fid))84					.map(|x| x.minimal_balance)85					.unwrap_or_else(Zero::zero)86			}87		}88	}8990	fn balance(asset: Self::AssetId, who: &<T as SystemConfig>::AccountId) -> Self::Balance {91		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible balance");92		match asset {93			AssetIds::NativeAssetId(NativeCurrency::Here) => {94				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::balance(who).into()95			}96			AssetIds::NativeAssetId(NativeCurrency::Parent) => {97				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::balance(98					AssetIds::NativeAssetId(NativeCurrency::Parent),99					who,100				)101				.into()102			}103			AssetIds::ForeignAssetId(fid) => {104				let target_collection_id = match <AssetBinding<T>>::get(fid) {105					Some(v) => v,106					None => return Zero::zero(),107				};108				let collection_handle = match <CollectionHandle<T>>::try_get(target_collection_id) {109					Ok(v) => v,110					Err(_) => return Zero::zero(),111				};112				let collection = FungibleHandle::cast(collection_handle);113				Self::Balance::try_from(114					collection.balance(T::CrossAccountId::from_sub(who.clone()), TokenId(0)),115				)116				.unwrap_or(Zero::zero())117			}118		}119	}120121	fn reducible_balance(122		asset: Self::AssetId,123		who: &<T as SystemConfig>::AccountId,124		keep_alive: bool,125	) -> Self::Balance {126		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible reducible_balance");127128		match asset {129			AssetIds::NativeAssetId(NativeCurrency::Here) => {130				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::reducible_balance(131					who, keep_alive,132				)133				.into()134			}135			AssetIds::NativeAssetId(NativeCurrency::Parent) => {136				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::reducible_balance(137					AssetIds::NativeAssetId(NativeCurrency::Parent),138					who,139					keep_alive,140				)141				.into()142			}143			_ => Self::balance(asset, who),144		}145	}146147	fn can_deposit(148		asset: Self::AssetId,149		who: &<T as SystemConfig>::AccountId,150		amount: Self::Balance,151		mint: bool,152	) -> DepositConsequence {153		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible can_deposit");154155		match asset {156			AssetIds::NativeAssetId(NativeCurrency::Here) => {157				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::can_deposit(158					who,159					amount.into(),160					mint,161				)162			}163			AssetIds::NativeAssetId(NativeCurrency::Parent) => {164				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::can_deposit(165					AssetIds::NativeAssetId(NativeCurrency::Parent),166					who,167					amount.into(),168					mint,169				)170			}171			_ => {172				if amount.is_zero() {173					return DepositConsequence::Success;174				}175176				let extential_deposit_value = T::ExistentialDeposit::get();177				let ed_value: u128 = match extential_deposit_value.try_into() {178					Ok(val) => val,179					Err(_) => return DepositConsequence::CannotCreate,180				};181				let extential_deposit: Self::Balance = match ed_value.try_into() {182					Ok(val) => val,183					Err(_) => return DepositConsequence::CannotCreate,184				};185186				let new_total_balance = match Self::balance(asset, who).checked_add(&amount) {187					Some(x) => x,188					None => return DepositConsequence::Overflow,189				};190191				if new_total_balance < extential_deposit {192					return DepositConsequence::BelowMinimum;193				}194195				DepositConsequence::Success196			}197		}198	}199200	fn can_withdraw(201		asset: Self::AssetId,202		who: &<T as SystemConfig>::AccountId,203		amount: Self::Balance,204	) -> WithdrawConsequence<Self::Balance> {205		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible can_withdraw");206		let value: u128 = match amount.try_into() {207			Ok(val) => val,208			Err(_) => return WithdrawConsequence::UnknownAsset,209		};210211		match asset {212			AssetIds::NativeAssetId(NativeCurrency::Here) => {213				let this_amount: <T as pallet_balances::Config>::Balance = match value.try_into() {214					Ok(val) => val,215					Err(_) => {216						return WithdrawConsequence::UnknownAsset;217					}218				};219				match <pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::can_withdraw(220					who,221					this_amount,222				) {223					WithdrawConsequence::NoFunds => WithdrawConsequence::NoFunds,224					WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,225					WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,226					WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,227					WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,228					WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,229					WithdrawConsequence::Success => WithdrawConsequence::Success,230					_ => WithdrawConsequence::NoFunds,231				}232			}233			AssetIds::NativeAssetId(NativeCurrency::Parent) => {234				let parent_amount: <T as orml_tokens::Config>::Balance = match value.try_into() {235					Ok(val) => val,236					Err(_) => {237						return WithdrawConsequence::UnknownAsset;238					}239				};240				match <orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::can_withdraw(241					AssetIds::NativeAssetId(NativeCurrency::Parent),242					who,243					parent_amount,244				) {245					WithdrawConsequence::NoFunds => WithdrawConsequence::NoFunds,246					WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,247					WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,248					WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,249					WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,250					WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,251					WithdrawConsequence::Success => WithdrawConsequence::Success,252					_ => WithdrawConsequence::NoFunds,253				}254			}255			_ => match Self::balance(asset, who).checked_sub(&amount) {256				Some(_) => WithdrawConsequence::Success,257				None => WithdrawConsequence::NoFunds,258			},259		}260	}261262	fn asset_exists(asset: AssetIds) -> bool {263		match asset {264			AssetIds::NativeAssetId(_) => true,265			AssetIds::ForeignAssetId(fid) => <AssetBinding<T>>::contains_key(fid),266		}267	}268}269270impl<T: Config> fungibles::Mutate<<T as SystemConfig>::AccountId> for Pallet<T>271where272	T: orml_tokens::Config<CurrencyId = AssetIds>,273	BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,274	BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,275	<T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,276	<T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,277	u128: From<BalanceOf<T>>,278{279	fn mint_into(280		asset: Self::AssetId,281		who: &<T as SystemConfig>::AccountId,282		amount: Self::Balance,283	) -> DispatchResult {284		//Self::do_mint(asset, who, amount, None)285		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible mint_into {:?}", asset);286287		match asset {288			AssetIds::NativeAssetId(NativeCurrency::Here) => {289				<pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::mint_into(290					who,291					amount.into(),292				)293				.into()294			}295			AssetIds::NativeAssetId(NativeCurrency::Parent) => {296				<orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::mint_into(297					AssetIds::NativeAssetId(NativeCurrency::Parent),298					who,299					amount.into(),300				)301				.into()302			}303			AssetIds::ForeignAssetId(fid) => {304				let target_collection_id = match <AssetBinding<T>>::get(fid) {305					Some(v) => v,306					None => {307						return Err(DispatchError::Other(308							"Associated collection not found for asset",309						))310					}311				};312				let collection =313					FungibleHandle::cast(<CollectionHandle<T>>::try_get(target_collection_id)?);314				let account = T::CrossAccountId::from_sub(who.clone());315316				let amount_data: pallet_fungible::CreateItemData<T> =317					(account.clone(), amount.into());318319				pallet_fungible::Pallet::<T>::create_item_foreign(320					&collection,321					&account,322					amount_data,323					&Value::new(0),324				)?;325326				Ok(())327			}328		}329	}330331	fn burn_from(332		asset: Self::AssetId,333		who: &<T as SystemConfig>::AccountId,334		amount: Self::Balance,335	) -> Result<Self::Balance, DispatchError> {336		// let f = DebitFlags { keep_alive: false, best_effort: false };337		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible burn_from");338339		match asset {340			AssetIds::NativeAssetId(NativeCurrency::Here) => {341				match <pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::burn_from(342					who,343					amount.into(),344				) {345					Ok(v) => Ok(v.into()),346					Err(e) => Err(e),347				}348			}349			AssetIds::NativeAssetId(NativeCurrency::Parent) => {350				match <orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::burn_from(351					AssetIds::NativeAssetId(NativeCurrency::Parent),352					who,353					amount.into(),354				) {355					Ok(v) => Ok(v.into()),356					Err(e) => Err(e),357				}358			}359			AssetIds::ForeignAssetId(fid) => {360				let target_collection_id = match <AssetBinding<T>>::get(fid) {361					Some(v) => v,362					None => {363						return Err(DispatchError::Other(364							"Associated collection not found for asset",365						))366					}367				};368				let collection =369					FungibleHandle::cast(<CollectionHandle<T>>::try_get(target_collection_id)?);370				pallet_fungible::Pallet::<T>::burn_foreign(371					&collection,372					&T::CrossAccountId::from_sub(who.clone()),373					amount.into(),374				)?;375376				Ok(amount)377			}378		}379	}380381	fn slash(382		asset: Self::AssetId,383		who: &<T as SystemConfig>::AccountId,384		amount: Self::Balance,385	) -> Result<Self::Balance, DispatchError> {386		// let f = DebitFlags { keep_alive: false, best_effort: true };387		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible slash");388		Ok(Self::burn_from(asset, who, amount)?)389	}390}391392impl<T: Config> fungibles::Transfer<T::AccountId> for Pallet<T>393where394	T: orml_tokens::Config<CurrencyId = AssetIds>,395	BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,396	BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,397	<T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,398	<T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,399	u128: From<BalanceOf<T>>,400{401	fn transfer(402		asset: Self::AssetId,403		source: &<T as SystemConfig>::AccountId,404		dest: &<T as SystemConfig>::AccountId,405		amount: Self::Balance,406		keep_alive: bool,407	) -> Result<Self::Balance, DispatchError> {408		// let f = TransferFlags { keep_alive, best_effort: false, burn_dust: false };409		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible transfer");410411		match asset {412			AssetIds::NativeAssetId(NativeCurrency::Here) => {413				match <pallet_balances::Pallet<T> as fungible::Transfer<T::AccountId>>::transfer(414					source,415					dest,416					amount.into(),417					keep_alive,418				) {419					Ok(_) => Ok(amount),420					Err(_) => Err(DispatchError::Other(421						"Bad amount to relay chain value conversion",422					)),423				}424			}425			AssetIds::NativeAssetId(NativeCurrency::Parent) => {426				match <orml_tokens::Pallet<T> as fungibles::Transfer<T::AccountId>>::transfer(427					AssetIds::NativeAssetId(NativeCurrency::Parent),428					source,429					dest,430					amount.into(),431					keep_alive,432				) {433					Ok(_) => Ok(amount),434					Err(e) => Err(e),435				}436			}437			AssetIds::ForeignAssetId(fid) => {438				let target_collection_id = match <AssetBinding<T>>::get(fid) {439					Some(v) => v,440					None => {441						return Err(DispatchError::Other(442							"Associated collection not found for asset",443						))444					}445				};446				let collection =447					FungibleHandle::cast(<CollectionHandle<T>>::try_get(target_collection_id)?);448449				pallet_fungible::Pallet::<T>::transfer(450					&collection,451					&T::CrossAccountId::from_sub(source.clone()),452					&T::CrossAccountId::from_sub(dest.clone()),453					amount.into(),454					&Value::new(0),455				)?;456457				Ok(amount)458			}459		}460	}461}
after · pallets/foreign-assets/src/impl_fungibles.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/>.1617//! Implementations for fungibles trait.1819use super::*;20use frame_system::Config as SystemConfig;2122use frame_support::traits::tokens::{DepositConsequence, WithdrawConsequence};23use pallet_common::CollectionHandle;24use pallet_fungible::FungibleHandle;25use pallet_common::CommonCollectionOperations;26use up_data_structs::budget::Value;27use sp_runtime::traits::{CheckedAdd, CheckedSub};2829impl<T: Config> fungibles::Inspect<<T as SystemConfig>::AccountId> for Pallet<T>30where31	T: orml_tokens::Config<CurrencyId = AssetIds>,32	BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,33	BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,34	<T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,35	<T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,36{37	type AssetId = AssetIds;38	type Balance = BalanceOf<T>;3940	fn total_issuance(asset: Self::AssetId) -> Self::Balance {41		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible total_issuance");4243		match asset {44			AssetIds::NativeAssetId(NativeCurrency::Here) => {45				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::total_issuance()46					.into()47			}48			AssetIds::NativeAssetId(NativeCurrency::Parent) => {49				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::total_issuance(50					AssetIds::NativeAssetId(NativeCurrency::Parent),51				)52				.into()53			}54			AssetIds::ForeignAssetId(fid) => {55				let target_collection_id = match <AssetBinding<T>>::get(fid) {56					Some(v) => v,57					None => return Zero::zero(),58				};59				let collection_handle = match <CollectionHandle<T>>::try_get(target_collection_id) {60					Ok(v) => v,61					Err(_) => return Zero::zero(),62				};63				let collection = FungibleHandle::cast(collection_handle);64				Self::Balance::try_from(collection.total_supply()).unwrap_or(Zero::zero())65			}66		}67	}6869	fn minimum_balance(asset: Self::AssetId) -> Self::Balance {70		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible minimum_balance");71		match asset {72			AssetIds::NativeAssetId(NativeCurrency::Here) => {73				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::minimum_balance()74					.into()75			}76			AssetIds::NativeAssetId(NativeCurrency::Parent) => {77				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::minimum_balance(78					AssetIds::NativeAssetId(NativeCurrency::Parent),79				)80				.into()81			}82			AssetIds::ForeignAssetId(fid) => {83				AssetMetadatas::<T>::get(AssetIds::ForeignAssetId(fid))84					.map(|x| x.minimal_balance)85					.unwrap_or_else(Zero::zero)86			}87		}88	}8990	fn balance(asset: Self::AssetId, who: &<T as SystemConfig>::AccountId) -> Self::Balance {91		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible balance");92		match asset {93			AssetIds::NativeAssetId(NativeCurrency::Here) => {94				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::balance(who).into()95			}96			AssetIds::NativeAssetId(NativeCurrency::Parent) => {97				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::balance(98					AssetIds::NativeAssetId(NativeCurrency::Parent),99					who,100				)101				.into()102			}103			AssetIds::ForeignAssetId(fid) => {104				let target_collection_id = match <AssetBinding<T>>::get(fid) {105					Some(v) => v,106					None => return Zero::zero(),107				};108				let collection_handle = match <CollectionHandle<T>>::try_get(target_collection_id) {109					Ok(v) => v,110					Err(_) => return Zero::zero(),111				};112				let collection = FungibleHandle::cast(collection_handle);113				Self::Balance::try_from(114					collection.balance(T::CrossAccountId::from_sub(who.clone()), TokenId(0)),115				)116				.unwrap_or(Zero::zero())117			}118		}119	}120121	fn reducible_balance(122		asset: Self::AssetId,123		who: &<T as SystemConfig>::AccountId,124		keep_alive: bool,125	) -> Self::Balance {126		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible reducible_balance");127128		match asset {129			AssetIds::NativeAssetId(NativeCurrency::Here) => {130				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::reducible_balance(131					who, keep_alive,132				)133				.into()134			}135			AssetIds::NativeAssetId(NativeCurrency::Parent) => {136				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::reducible_balance(137					AssetIds::NativeAssetId(NativeCurrency::Parent),138					who,139					keep_alive,140				)141				.into()142			}143			_ => Self::balance(asset, who),144		}145	}146147	fn can_deposit(148		asset: Self::AssetId,149		who: &<T as SystemConfig>::AccountId,150		amount: Self::Balance,151		mint: bool,152	) -> DepositConsequence {153		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible can_deposit");154155		match asset {156			AssetIds::NativeAssetId(NativeCurrency::Here) => {157				<pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::can_deposit(158					who,159					amount.into(),160					mint,161				)162			}163			AssetIds::NativeAssetId(NativeCurrency::Parent) => {164				<orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::can_deposit(165					AssetIds::NativeAssetId(NativeCurrency::Parent),166					who,167					amount.into(),168					mint,169				)170			}171			_ => {172				if amount.is_zero() {173					return DepositConsequence::Success;174				}175176				let extential_deposit_value = T::ExistentialDeposit::get();177				let ed_value: u128 = match extential_deposit_value.try_into() {178					Ok(val) => val,179					Err(_) => return DepositConsequence::CannotCreate,180				};181				let extential_deposit: Self::Balance = match ed_value.try_into() {182					Ok(val) => val,183					Err(_) => return DepositConsequence::CannotCreate,184				};185186				let new_total_balance = match Self::balance(asset, who).checked_add(&amount) {187					Some(x) => x,188					None => return DepositConsequence::Overflow,189				};190191				if new_total_balance < extential_deposit {192					return DepositConsequence::BelowMinimum;193				}194195				DepositConsequence::Success196			}197		}198	}199200	fn can_withdraw(201		asset: Self::AssetId,202		who: &<T as SystemConfig>::AccountId,203		amount: Self::Balance,204	) -> WithdrawConsequence<Self::Balance> {205		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible can_withdraw");206		let value: u128 = match amount.try_into() {207			Ok(val) => val,208			Err(_) => return WithdrawConsequence::UnknownAsset,209		};210211		match asset {212			AssetIds::NativeAssetId(NativeCurrency::Here) => {213				let this_amount: <T as pallet_balances::Config>::Balance = match value.try_into() {214					Ok(val) => val,215					Err(_) => {216						return WithdrawConsequence::UnknownAsset;217					}218				};219				match <pallet_balances::Pallet<T> as fungible::Inspect<T::AccountId>>::can_withdraw(220					who,221					this_amount,222				) {223					WithdrawConsequence::NoFunds => WithdrawConsequence::NoFunds,224					WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,225					WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,226					WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,227					WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,228					WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,229					WithdrawConsequence::Success => WithdrawConsequence::Success,230					_ => WithdrawConsequence::NoFunds,231				}232			}233			AssetIds::NativeAssetId(NativeCurrency::Parent) => {234				let parent_amount: <T as orml_tokens::Config>::Balance = match value.try_into() {235					Ok(val) => val,236					Err(_) => {237						return WithdrawConsequence::UnknownAsset;238					}239				};240				match <orml_tokens::Pallet<T> as fungibles::Inspect<T::AccountId>>::can_withdraw(241					AssetIds::NativeAssetId(NativeCurrency::Parent),242					who,243					parent_amount,244				) {245					WithdrawConsequence::NoFunds => WithdrawConsequence::NoFunds,246					WithdrawConsequence::WouldDie => WithdrawConsequence::WouldDie,247					WithdrawConsequence::UnknownAsset => WithdrawConsequence::UnknownAsset,248					WithdrawConsequence::Underflow => WithdrawConsequence::Underflow,249					WithdrawConsequence::Overflow => WithdrawConsequence::Overflow,250					WithdrawConsequence::Frozen => WithdrawConsequence::Frozen,251					WithdrawConsequence::Success => WithdrawConsequence::Success,252					_ => WithdrawConsequence::NoFunds,253				}254			}255			_ => match Self::balance(asset, who).checked_sub(&amount) {256				Some(_) => WithdrawConsequence::Success,257				None => WithdrawConsequence::NoFunds,258			},259		}260	}261262	fn asset_exists(asset: AssetIds) -> bool {263		match asset {264			AssetIds::NativeAssetId(_) => true,265			AssetIds::ForeignAssetId(fid) => <AssetBinding<T>>::contains_key(fid),266		}267	}268}269270impl<T: Config> fungibles::Mutate<<T as SystemConfig>::AccountId> for Pallet<T>271where272	T: orml_tokens::Config<CurrencyId = AssetIds>,273	BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,274	BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,275	<T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,276	<T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,277	u128: From<BalanceOf<T>>,278{279	fn mint_into(280		asset: Self::AssetId,281		who: &<T as SystemConfig>::AccountId,282		amount: Self::Balance,283	) -> DispatchResult {284		//Self::do_mint(asset, who, amount, None)285		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible mint_into {:?}", asset);286287		match asset {288			AssetIds::NativeAssetId(NativeCurrency::Here) => {289				<pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::mint_into(290					who,291					amount.into(),292				)293				.into()294			}295			AssetIds::NativeAssetId(NativeCurrency::Parent) => {296				<orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::mint_into(297					AssetIds::NativeAssetId(NativeCurrency::Parent),298					who,299					amount.into(),300				)301				.into()302			}303			AssetIds::ForeignAssetId(fid) => {304				let target_collection_id = match <AssetBinding<T>>::get(fid) {305					Some(v) => v,306					None => {307						return Err(DispatchError::Other(308							"Associated collection not found for asset",309						))310					}311				};312				let collection =313					FungibleHandle::cast(<CollectionHandle<T>>::try_get(target_collection_id)?);314				let account = T::CrossAccountId::from_sub(who.clone());315316				let amount_data: pallet_fungible::CreateItemData<T> =317					(account.clone(), amount.into());318319				pallet_fungible::Pallet::<T>::create_item_foreign(320					&collection,321					&account,322					amount_data,323					&Value::new(0),324				)?;325326				Ok(())327			}328		}329	}330331	fn burn_from(332		asset: Self::AssetId,333		who: &<T as SystemConfig>::AccountId,334		amount: Self::Balance,335	) -> Result<Self::Balance, DispatchError> {336		// let f = DebitFlags { keep_alive: false, best_effort: false };337		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible burn_from");338339		match asset {340			AssetIds::NativeAssetId(NativeCurrency::Here) => {341				match <pallet_balances::Pallet<T> as fungible::Mutate<T::AccountId>>::burn_from(342					who,343					amount.into(),344				) {345					Ok(v) => Ok(v.into()),346					Err(e) => Err(e),347				}348			}349			AssetIds::NativeAssetId(NativeCurrency::Parent) => {350				match <orml_tokens::Pallet<T> as fungibles::Mutate<T::AccountId>>::burn_from(351					AssetIds::NativeAssetId(NativeCurrency::Parent),352					who,353					amount.into(),354				) {355					Ok(v) => Ok(v.into()),356					Err(e) => Err(e),357				}358			}359			AssetIds::ForeignAssetId(fid) => {360				let target_collection_id = match <AssetBinding<T>>::get(fid) {361					Some(v) => v,362					None => {363						return Err(DispatchError::Other(364							"Associated collection not found for asset",365						))366					}367				};368				let collection =369					FungibleHandle::cast(<CollectionHandle<T>>::try_get(target_collection_id)?);370				pallet_fungible::Pallet::<T>::burn_foreign(371					&collection,372					&T::CrossAccountId::from_sub(who.clone()),373					amount.into(),374				)?;375376				Ok(amount)377			}378		}379	}380381	fn slash(382		asset: Self::AssetId,383		who: &<T as SystemConfig>::AccountId,384		amount: Self::Balance,385	) -> Result<Self::Balance, DispatchError> {386		// let f = DebitFlags { keep_alive: false, best_effort: true };387		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible slash");388		Ok(Self::burn_from(asset, who, amount)?)389	}390}391392impl<T: Config> fungibles::Transfer<T::AccountId> for Pallet<T>393where394	T: orml_tokens::Config<CurrencyId = AssetIds>,395	BalanceOf<T>: From<<T as pallet_balances::Config>::Balance>,396	BalanceOf<T>: From<<T as orml_tokens::Config>::Balance>,397	<T as pallet_balances::Config>::Balance: From<BalanceOf<T>>,398	<T as orml_tokens::Config>::Balance: From<BalanceOf<T>>,399	u128: From<BalanceOf<T>>,400{401	fn transfer(402		asset: Self::AssetId,403		source: &<T as SystemConfig>::AccountId,404		dest: &<T as SystemConfig>::AccountId,405		amount: Self::Balance,406		keep_alive: bool,407	) -> Result<Self::Balance, DispatchError> {408		// let f = TransferFlags { keep_alive, best_effort: false, burn_dust: false };409		log::trace!(target: "fassets::impl_foreign_assets", "impl_fungible transfer");410411		match asset {412			AssetIds::NativeAssetId(NativeCurrency::Here) => {413				match <pallet_balances::Pallet<T> as fungible::Transfer<T::AccountId>>::transfer(414					source,415					dest,416					amount.into(),417					keep_alive,418				) {419					Ok(_) => Ok(amount),420					Err(_) => Err(DispatchError::Other(421						"Bad amount to relay chain value conversion",422					)),423				}424			}425			AssetIds::NativeAssetId(NativeCurrency::Parent) => {426				match <orml_tokens::Pallet<T> as fungibles::Transfer<T::AccountId>>::transfer(427					AssetIds::NativeAssetId(NativeCurrency::Parent),428					source,429					dest,430					amount.into(),431					keep_alive,432				) {433					Ok(_) => Ok(amount),434					Err(e) => Err(e),435				}436			}437			AssetIds::ForeignAssetId(fid) => {438				let target_collection_id = match <AssetBinding<T>>::get(fid) {439					Some(v) => v,440					None => {441						return Err(DispatchError::Other(442							"Associated collection not found for asset",443						))444					}445				};446				let collection =447					FungibleHandle::cast(<CollectionHandle<T>>::try_get(target_collection_id)?);448449				pallet_fungible::Pallet::<T>::transfer(450					&collection,451					&T::CrossAccountId::from_sub(source.clone()),452					&T::CrossAccountId::from_sub(dest.clone()),453					amount.into(),454					&Value::new(0),455				)456				.map_err(|e| e.error)?;457458				Ok(amount)459			}460		}461	}462}
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
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -23,7 +23,7 @@
 };
 use pallet_common::{
 	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,
-	weights::WeightInfo as _,
+	weights::WeightInfo as _, SelfWeightOf as PalletCommonWeightOf,
 };
 use sp_runtime::DispatchError;
 use sp_std::{vec::Vec, vec};
@@ -91,7 +91,7 @@
 	}
 
 	fn transfer() -> Weight {
-		<SelfWeightOf<T>>::transfer()
+		<SelfWeightOf<T>>::transfer_raw() + <PalletCommonWeightOf<T>>::check_accesslist() * 2
 	}
 
 	fn approve() -> Weight {
@@ -103,7 +103,7 @@
 	}
 
 	fn transfer_from() -> Weight {
-		<SelfWeightOf<T>>::transfer_from()
+		Self::transfer() + <SelfWeightOf<T>>::check_allowed_raw()
 	}
 
 	fn burn_from() -> Weight {
@@ -325,10 +325,7 @@
 	) -> DispatchResultWithPostInfo {
 		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
 		if amount == 1 {
-			with_weight(
-				<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget),
-				<CommonWeights<T>>::transfer(),
-			)
+			<Pallet<T>>::transfer(self, &from, &to, token, nesting_budget)
 		} else {
 			<Pallet<T>>::check_token_immediate_ownership(self, token, &from)?;
 			Ok(().into())
@@ -386,10 +383,7 @@
 		ensure!(amount <= 1, <Error<T>>::NonfungibleItemsHaveNoAmount);
 
 		if amount == 1 {
-			with_weight(
-				<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget),
-				<CommonWeights<T>>::transfer_from(),
-			)
+			<Pallet<T>>::transfer_from(self, &sender, &from, &to, token, nesting_budget)
 		} else {
 			<Pallet<T>>::check_allowed(self, &sender, &from, token, nesting_budget)?;
 
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)