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

difftreelog

fix weight for `createItem`

PraetorP2023-01-23parent: #1154c05.patch.diff
in: master
Chnaged behaviour for `CommonWeightInfo` trait.

15 files changed

modifiedCargo.lockdiffbeforeafterboth
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5783,7 +5783,7 @@
 
 [[package]]
 name = "pallet-common"
-version = "0.1.12"
+version = "0.1.13"
 dependencies = [
  "ethereum 0.14.0",
  "evm-coder",
@@ -6340,7 +6340,7 @@
 
 [[package]]
 name = "pallet-nonfungible"
-version = "0.1.12"
+version = "0.1.13"
 dependencies = [
  "evm-coder",
  "frame-benchmarking",
@@ -6499,7 +6499,7 @@
 
 [[package]]
 name = "pallet-refungible"
-version = "0.2.11"
+version = "0.2.12"
 dependencies = [
  "evm-coder",
  "frame-benchmarking",
modifiedpallets/common/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/common/CHANGELOG.md
+++ b/pallets/common/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.13] - 2023-01-20
+
+### Changed
+
+- Behavior of the `CommonWeightInfo::create_item` method.
+
 ## [0.1.12] - 2022-11-16
 
 ### 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.12"
+version = "0.1.13"
 
 [dependencies]
 codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = "3.1.2" }
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -53,7 +53,10 @@
 #![cfg_attr(not(feature = "std"), no_std)]
 extern crate alloc;
 
-use core::ops::{Deref, DerefMut};
+use core::{
+	ops::{Deref, DerefMut},
+	slice::from_ref,
+};
 use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};
 use sp_std::vec::Vec;
 use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm};
@@ -1780,7 +1783,9 @@
 /// Return weights for various worst-case operations.
 pub trait CommonWeightInfo<CrossAccountId> {
 	/// Weight of item creation.
-	fn create_item() -> Weight;
+	fn create_item(data: &CreateItemData) -> Weight {
+		Self::create_multiple_items(from_ref(data))
+	}
 
 	/// Weight of items creation.
 	fn create_multiple_items(amount: &[CreateItemData]) -> Weight;
modifiedpallets/fungible/src/common.rsdiffbeforeafterboth
before · pallets/fungible/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, traits::Get};20use up_data_structs::{21	TokenId, CollectionId, CreateItemExData, budget::Budget, CreateItemData, TokenOwnerError,22};23use pallet_common::{24	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,25	weights::WeightInfo as _,26};27use pallet_structure::Error as StructureError;28use sp_runtime::ArithmeticError;29use sp_std::{vec::Vec, vec};30use up_data_structs::{Property, PropertyKey, PropertyValue, PropertyKeyPermission};3132use crate::{33	Allowance, TotalSupply, Balance, Config, Error, FungibleHandle, Pallet, SelfWeightOf,34	weights::WeightInfo,35};3637pub struct CommonWeights<T: Config>(PhantomData<T>);38impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {39	fn create_item() -> Weight {40		<SelfWeightOf<T>>::create_item()41	}4243	fn create_multiple_items(_data: &[CreateItemData]) -> Weight {44		// All items minted for the same user, so it works same as create_item45		Self::create_item()46	}4748	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {49		match data {50			CreateItemExData::Fungible(f) => {51				<SelfWeightOf<T>>::create_multiple_items_ex(f.len() as u32)52			}53			_ => Weight::zero(),54		}55	}5657	fn burn_item() -> Weight {58		<SelfWeightOf<T>>::burn_item()59	}6061	fn set_collection_properties(amount: u32) -> Weight {62		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)63	}6465	fn delete_collection_properties(amount: u32) -> Weight {66		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)67	}6869	fn set_token_properties(_amount: u32) -> Weight {70		// Error71		Weight::zero()72	}7374	fn delete_token_properties(_amount: u32) -> Weight {75		// Error76		Weight::zero()77	}7879	fn set_token_property_permissions(_amount: u32) -> Weight {80		// Error81		Weight::zero()82	}8384	fn transfer() -> Weight {85		<SelfWeightOf<T>>::transfer()86	}8788	fn approve() -> Weight {89		<SelfWeightOf<T>>::approve()90	}9192	fn approve_from() -> Weight {93		<SelfWeightOf<T>>::approve_from()94	}9596	fn transfer_from() -> Weight {97		<SelfWeightOf<T>>::transfer_from()98	}99100	fn burn_from() -> Weight {101		<SelfWeightOf<T>>::burn_from()102	}103104	fn burn_recursively_self_raw() -> Weight {105		// Read to get total balance106		Self::burn_item() + T::DbWeight::get().reads(1)107	}108109	fn burn_recursively_breadth_raw(_amount: u32) -> Weight {110		// Fungible tokens can't have children111		Weight::zero()112	}113114	fn token_owner() -> Weight {115		Weight::zero()116	}117118	fn set_allowance_for_all() -> Weight {119		Weight::zero()120	}121122	fn force_repair_item() -> Weight {123		Weight::zero()124	}125}126127/// Implementation of `CommonCollectionOperations` for `FungibleHandle`. It wraps FungibleHandle Pallete128/// methods and adds weight info.129impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {130	fn create_item(131		&self,132		sender: T::CrossAccountId,133		to: T::CrossAccountId,134		data: up_data_structs::CreateItemData,135		nesting_budget: &dyn Budget,136	) -> DispatchResultWithPostInfo {137		match data {138			up_data_structs::CreateItemData::Fungible(data) => with_weight(139				<Pallet<T>>::create_item(self, &sender, (to, data.value), nesting_budget),140				<CommonWeights<T>>::create_item(),141			),142			_ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),143		}144	}145146	fn create_multiple_items(147		&self,148		sender: T::CrossAccountId,149		to: T::CrossAccountId,150		data: Vec<up_data_structs::CreateItemData>,151		nesting_budget: &dyn Budget,152	) -> DispatchResultWithPostInfo {153		let mut sum: u128 = 0;154		for data in data {155			match data {156				up_data_structs::CreateItemData::Fungible(data) => {157					sum = sum158						.checked_add(data.value)159						.ok_or(ArithmeticError::Overflow)?;160				}161				_ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),162			}163		}164165		with_weight(166			<Pallet<T>>::create_item(self, &sender, (to, sum), nesting_budget),167			<CommonWeights<T>>::create_item(),168		)169	}170171	fn create_multiple_items_ex(172		&self,173		sender: <T>::CrossAccountId,174		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,175		nesting_budget: &dyn Budget,176	) -> DispatchResultWithPostInfo {177		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);178		let data = match data {179			up_data_structs::CreateItemExData::Fungible(f) => f,180			_ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),181		};182183		with_weight(184			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),185			weight,186		)187	}188189	fn burn_item(190		&self,191		sender: T::CrossAccountId,192		token: TokenId,193		amount: u128,194	) -> DispatchResultWithPostInfo {195		ensure!(196			token == TokenId::default(),197			<Error<T>>::FungibleItemsHaveNoId198		);199200		with_weight(201			<Pallet<T>>::burn(self, &sender, amount),202			<CommonWeights<T>>::burn_item(),203		)204	}205206	fn burn_item_recursively(207		&self,208		sender: T::CrossAccountId,209		token: TokenId,210		self_budget: &dyn Budget,211		_breadth_budget: &dyn Budget,212	) -> DispatchResultWithPostInfo {213		// Should not happen?214		ensure!(215			token == TokenId::default(),216			<Error<T>>::FungibleItemsHaveNoId217		);218		ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);219220		with_weight(221			<Pallet<T>>::burn(self, &sender, <Balance<T>>::get((self.id, &sender))),222			<CommonWeights<T>>::burn_recursively_self_raw(),223		)224	}225226	fn transfer(227		&self,228		from: T::CrossAccountId,229		to: T::CrossAccountId,230		token: TokenId,231		amount: u128,232		nesting_budget: &dyn Budget,233	) -> DispatchResultWithPostInfo {234		ensure!(235			token == TokenId::default(),236			<Error<T>>::FungibleItemsHaveNoId237		);238239		with_weight(240			<Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget),241			<CommonWeights<T>>::transfer(),242		)243	}244245	fn approve(246		&self,247		sender: T::CrossAccountId,248		spender: T::CrossAccountId,249		token: TokenId,250		amount: u128,251	) -> DispatchResultWithPostInfo {252		ensure!(253			token == TokenId::default(),254			<Error<T>>::FungibleItemsHaveNoId255		);256257		with_weight(258			<Pallet<T>>::set_allowance(self, &sender, &spender, amount),259			<CommonWeights<T>>::approve(),260		)261	}262263	fn approve_from(264		&self,265		sender: T::CrossAccountId,266		from: T::CrossAccountId,267		to: T::CrossAccountId,268		token: TokenId,269		amount: u128,270	) -> DispatchResultWithPostInfo {271		ensure!(272			token == TokenId::default(),273			<Error<T>>::FungibleItemsHaveNoId274		);275276		with_weight(277			<Pallet<T>>::set_allowance_from(self, &sender, &from, &to, amount),278			<CommonWeights<T>>::approve_from(),279		)280	}281282	fn transfer_from(283		&self,284		sender: T::CrossAccountId,285		from: T::CrossAccountId,286		to: T::CrossAccountId,287		token: TokenId,288		amount: u128,289		nesting_budget: &dyn Budget,290	) -> DispatchResultWithPostInfo {291		ensure!(292			token == TokenId::default(),293			<Error<T>>::FungibleItemsHaveNoId294		);295296		with_weight(297			<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget),298			<CommonWeights<T>>::transfer_from(),299		)300	}301302	fn burn_from(303		&self,304		sender: T::CrossAccountId,305		from: T::CrossAccountId,306		token: TokenId,307		amount: u128,308		nesting_budget: &dyn Budget,309	) -> DispatchResultWithPostInfo {310		ensure!(311			token == TokenId::default(),312			<Error<T>>::FungibleItemsHaveNoId313		);314315		with_weight(316			<Pallet<T>>::burn_from(self, &sender, &from, amount, nesting_budget),317			<CommonWeights<T>>::burn_from(),318		)319	}320321	fn set_collection_properties(322		&self,323		sender: T::CrossAccountId,324		properties: Vec<Property>,325	) -> DispatchResultWithPostInfo {326		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);327328		with_weight(329			<Pallet<T>>::set_collection_properties(self, &sender, properties),330			weight,331		)332	}333334	fn delete_collection_properties(335		&self,336		sender: &T::CrossAccountId,337		property_keys: Vec<PropertyKey>,338	) -> DispatchResultWithPostInfo {339		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);340341		with_weight(342			<Pallet<T>>::delete_collection_properties(self, sender, property_keys),343			weight,344		)345	}346347	fn set_token_properties(348		&self,349		_sender: T::CrossAccountId,350		_token_id: TokenId,351		_property: Vec<Property>,352		_nesting_budget: &dyn Budget,353	) -> DispatchResultWithPostInfo {354		fail!(<Error<T>>::SettingPropertiesNotAllowed)355	}356357	fn set_token_property_permissions(358		&self,359		_sender: &T::CrossAccountId,360		_property_permissions: Vec<PropertyKeyPermission>,361	) -> DispatchResultWithPostInfo {362		fail!(<Error<T>>::SettingPropertiesNotAllowed)363	}364365	fn delete_token_properties(366		&self,367		_sender: T::CrossAccountId,368		_token_id: TokenId,369		_property_keys: Vec<PropertyKey>,370		_nesting_budget: &dyn Budget,371	) -> DispatchResultWithPostInfo {372		fail!(<Error<T>>::SettingPropertiesNotAllowed)373	}374375	fn check_nesting(376		&self,377		_sender: <T>::CrossAccountId,378		_from: (CollectionId, TokenId),379		_under: TokenId,380		_nesting_budget: &dyn Budget,381	) -> sp_runtime::DispatchResult {382		fail!(<Error<T>>::FungibleDisallowsNesting)383	}384385	fn nest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}386387	fn unnest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}388389	fn collection_tokens(&self) -> Vec<TokenId> {390		vec![TokenId::default()]391	}392393	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {394		if <Balance<T>>::get((self.id, account)) != 0 {395			vec![TokenId::default()]396		} else {397			vec![]398		}399	}400401	fn token_exists(&self, token: TokenId) -> bool {402		token == TokenId::default()403	}404405	fn last_token_id(&self) -> TokenId {406		TokenId::default()407	}408409	fn token_owner(&self, _token: TokenId) -> Result<T::CrossAccountId, TokenOwnerError> {410		Err(TokenOwnerError::MultipleOwners)411	}412413	/// Returns 10 tokens owners in no particular order.414	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {415		<Pallet<T>>::token_owners(self.id, token).unwrap_or_default()416	}417418	fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {419		None420	}421422	fn token_properties(423		&self,424		_token_id: TokenId,425		_keys: Option<Vec<PropertyKey>>,426	) -> Vec<Property> {427		Vec::new()428	}429430	fn total_supply(&self) -> u32 {431		1432	}433434	fn account_balance(&self, account: T::CrossAccountId) -> u32 {435		if <Balance<T>>::get((self.id, account)) != 0 {436			1437		} else {438			0439		}440	}441442	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {443		if token != TokenId::default() {444			return 0;445		}446		<Balance<T>>::get((self.id, account))447	}448449	fn allowance(450		&self,451		sender: T::CrossAccountId,452		spender: T::CrossAccountId,453		token: TokenId,454	) -> u128 {455		if token != TokenId::default() {456			return 0;457		}458		<Allowance<T>>::get((self.id, sender, spender))459	}460461	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {462		None463	}464465	fn total_pieces(&self, token: TokenId) -> Option<u128> {466		if token != TokenId::default() {467			return None;468		}469		<TotalSupply<T>>::try_get(self.id).ok()470	}471472	fn set_allowance_for_all(473		&self,474		_owner: T::CrossAccountId,475		_operator: T::CrossAccountId,476		_approve: bool,477	) -> DispatchResultWithPostInfo {478		fail!(<Error<T>>::SettingAllowanceForAllNotAllowed)479	}480481	fn allowance_for_all(&self, _owner: T::CrossAccountId, _operator: T::CrossAccountId) -> bool {482		false483	}484485	/// Repairs a possibly broken item.486	fn repair_item(&self, _token: TokenId) -> DispatchResultWithPostInfo {487		fail!(<Error<T>>::FungibleTokensAreAlwaysValid)488	}489}
after · pallets/fungible/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, traits::Get};20use up_data_structs::{21	TokenId, CollectionId, CreateItemExData, budget::Budget, CreateItemData, TokenOwnerError,22};23use pallet_common::{24	CommonCollectionOperations, CommonWeightInfo, RefungibleExtensions, with_weight,25	weights::WeightInfo as _,26};27use pallet_structure::Error as StructureError;28use sp_runtime::ArithmeticError;29use sp_std::{vec::Vec, vec};30use up_data_structs::{Property, PropertyKey, PropertyValue, PropertyKeyPermission};3132use crate::{33	Allowance, TotalSupply, Balance, Config, Error, FungibleHandle, Pallet, SelfWeightOf,34	weights::WeightInfo,35};3637pub struct CommonWeights<T: Config>(PhantomData<T>);38impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {39	fn create_multiple_items(_data: &[CreateItemData]) -> Weight {40		// All items minted for the same user, so it works same as create_item41		<SelfWeightOf<T>>::create_item()42	}4344	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {45		match data {46			CreateItemExData::Fungible(f) => {47				<SelfWeightOf<T>>::create_multiple_items_ex(f.len() as u32)48			}49			_ => Weight::zero(),50		}51	}5253	fn burn_item() -> Weight {54		<SelfWeightOf<T>>::burn_item()55	}5657	fn set_collection_properties(amount: u32) -> Weight {58		<pallet_common::SelfWeightOf<T>>::set_collection_properties(amount)59	}6061	fn delete_collection_properties(amount: u32) -> Weight {62		<pallet_common::SelfWeightOf<T>>::delete_collection_properties(amount)63	}6465	fn set_token_properties(_amount: u32) -> Weight {66		// Error67		Weight::zero()68	}6970	fn delete_token_properties(_amount: u32) -> Weight {71		// Error72		Weight::zero()73	}7475	fn set_token_property_permissions(_amount: u32) -> Weight {76		// Error77		Weight::zero()78	}7980	fn transfer() -> Weight {81		<SelfWeightOf<T>>::transfer()82	}8384	fn approve() -> Weight {85		<SelfWeightOf<T>>::approve()86	}8788	fn approve_from() -> Weight {89		<SelfWeightOf<T>>::approve_from()90	}9192	fn transfer_from() -> Weight {93		<SelfWeightOf<T>>::transfer_from()94	}9596	fn burn_from() -> Weight {97		<SelfWeightOf<T>>::burn_from()98	}99100	fn burn_recursively_self_raw() -> Weight {101		// Read to get total balance102		Self::burn_item() + T::DbWeight::get().reads(1)103	}104105	fn burn_recursively_breadth_raw(_amount: u32) -> Weight {106		// Fungible tokens can't have children107		Weight::zero()108	}109110	fn token_owner() -> Weight {111		Weight::zero()112	}113114	fn set_allowance_for_all() -> Weight {115		Weight::zero()116	}117118	fn force_repair_item() -> Weight {119		Weight::zero()120	}121}122123/// Implementation of `CommonCollectionOperations` for `FungibleHandle`. It wraps FungibleHandle Pallete124/// methods and adds weight info.125impl<T: Config> CommonCollectionOperations<T> for FungibleHandle<T> {126	fn create_item(127		&self,128		sender: T::CrossAccountId,129		to: T::CrossAccountId,130		data: up_data_structs::CreateItemData,131		nesting_budget: &dyn Budget,132	) -> DispatchResultWithPostInfo {133		match &data {134			up_data_structs::CreateItemData::Fungible(fungible_data) => with_weight(135				<Pallet<T>>::create_item(self, &sender, (to, fungible_data.value), nesting_budget),136				<CommonWeights<T>>::create_item(&data),137			),138			_ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),139		}140	}141142	fn create_multiple_items(143		&self,144		sender: T::CrossAccountId,145		to: T::CrossAccountId,146		data: Vec<up_data_structs::CreateItemData>,147		nesting_budget: &dyn Budget,148	) -> DispatchResultWithPostInfo {149		let mut sum: u128 = 0;150		for data in &data {151			match &data {152				up_data_structs::CreateItemData::Fungible(data) => {153					sum = sum154						.checked_add(data.value)155						.ok_or(ArithmeticError::Overflow)?;156				}157				_ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),158			}159		}160161		with_weight(162			<Pallet<T>>::create_item(self, &sender, (to, sum), nesting_budget),163			<CommonWeights<T>>::create_multiple_items(&data),164		)165	}166167	fn create_multiple_items_ex(168		&self,169		sender: <T>::CrossAccountId,170		data: up_data_structs::CreateItemExData<<T>::CrossAccountId>,171		nesting_budget: &dyn Budget,172	) -> DispatchResultWithPostInfo {173		let weight = <CommonWeights<T>>::create_multiple_items_ex(&data);174		let data = match data {175			up_data_structs::CreateItemExData::Fungible(f) => f,176			_ => fail!(<Error<T>>::NotFungibleDataUsedToMintFungibleCollectionToken),177		};178179		with_weight(180			<Pallet<T>>::create_multiple_items(self, &sender, data.into_inner(), nesting_budget),181			weight,182		)183	}184185	fn burn_item(186		&self,187		sender: T::CrossAccountId,188		token: TokenId,189		amount: u128,190	) -> DispatchResultWithPostInfo {191		ensure!(192			token == TokenId::default(),193			<Error<T>>::FungibleItemsHaveNoId194		);195196		with_weight(197			<Pallet<T>>::burn(self, &sender, amount),198			<CommonWeights<T>>::burn_item(),199		)200	}201202	fn burn_item_recursively(203		&self,204		sender: T::CrossAccountId,205		token: TokenId,206		self_budget: &dyn Budget,207		_breadth_budget: &dyn Budget,208	) -> DispatchResultWithPostInfo {209		// Should not happen?210		ensure!(211			token == TokenId::default(),212			<Error<T>>::FungibleItemsHaveNoId213		);214		ensure!(self_budget.consume(), <StructureError<T>>::DepthLimit,);215216		with_weight(217			<Pallet<T>>::burn(self, &sender, <Balance<T>>::get((self.id, &sender))),218			<CommonWeights<T>>::burn_recursively_self_raw(),219		)220	}221222	fn transfer(223		&self,224		from: T::CrossAccountId,225		to: T::CrossAccountId,226		token: TokenId,227		amount: u128,228		nesting_budget: &dyn Budget,229	) -> DispatchResultWithPostInfo {230		ensure!(231			token == TokenId::default(),232			<Error<T>>::FungibleItemsHaveNoId233		);234235		with_weight(236			<Pallet<T>>::transfer(self, &from, &to, amount, nesting_budget),237			<CommonWeights<T>>::transfer(),238		)239	}240241	fn approve(242		&self,243		sender: T::CrossAccountId,244		spender: T::CrossAccountId,245		token: TokenId,246		amount: u128,247	) -> DispatchResultWithPostInfo {248		ensure!(249			token == TokenId::default(),250			<Error<T>>::FungibleItemsHaveNoId251		);252253		with_weight(254			<Pallet<T>>::set_allowance(self, &sender, &spender, amount),255			<CommonWeights<T>>::approve(),256		)257	}258259	fn approve_from(260		&self,261		sender: T::CrossAccountId,262		from: T::CrossAccountId,263		to: T::CrossAccountId,264		token: TokenId,265		amount: u128,266	) -> DispatchResultWithPostInfo {267		ensure!(268			token == TokenId::default(),269			<Error<T>>::FungibleItemsHaveNoId270		);271272		with_weight(273			<Pallet<T>>::set_allowance_from(self, &sender, &from, &to, amount),274			<CommonWeights<T>>::approve_from(),275		)276	}277278	fn transfer_from(279		&self,280		sender: T::CrossAccountId,281		from: T::CrossAccountId,282		to: T::CrossAccountId,283		token: TokenId,284		amount: u128,285		nesting_budget: &dyn Budget,286	) -> DispatchResultWithPostInfo {287		ensure!(288			token == TokenId::default(),289			<Error<T>>::FungibleItemsHaveNoId290		);291292		with_weight(293			<Pallet<T>>::transfer_from(self, &sender, &from, &to, amount, nesting_budget),294			<CommonWeights<T>>::transfer_from(),295		)296	}297298	fn burn_from(299		&self,300		sender: T::CrossAccountId,301		from: T::CrossAccountId,302		token: TokenId,303		amount: u128,304		nesting_budget: &dyn Budget,305	) -> DispatchResultWithPostInfo {306		ensure!(307			token == TokenId::default(),308			<Error<T>>::FungibleItemsHaveNoId309		);310311		with_weight(312			<Pallet<T>>::burn_from(self, &sender, &from, amount, nesting_budget),313			<CommonWeights<T>>::burn_from(),314		)315	}316317	fn set_collection_properties(318		&self,319		sender: T::CrossAccountId,320		properties: Vec<Property>,321	) -> DispatchResultWithPostInfo {322		let weight = <CommonWeights<T>>::set_collection_properties(properties.len() as u32);323324		with_weight(325			<Pallet<T>>::set_collection_properties(self, &sender, properties),326			weight,327		)328	}329330	fn delete_collection_properties(331		&self,332		sender: &T::CrossAccountId,333		property_keys: Vec<PropertyKey>,334	) -> DispatchResultWithPostInfo {335		let weight = <CommonWeights<T>>::delete_collection_properties(property_keys.len() as u32);336337		with_weight(338			<Pallet<T>>::delete_collection_properties(self, sender, property_keys),339			weight,340		)341	}342343	fn set_token_properties(344		&self,345		_sender: T::CrossAccountId,346		_token_id: TokenId,347		_property: Vec<Property>,348		_nesting_budget: &dyn Budget,349	) -> DispatchResultWithPostInfo {350		fail!(<Error<T>>::SettingPropertiesNotAllowed)351	}352353	fn set_token_property_permissions(354		&self,355		_sender: &T::CrossAccountId,356		_property_permissions: Vec<PropertyKeyPermission>,357	) -> DispatchResultWithPostInfo {358		fail!(<Error<T>>::SettingPropertiesNotAllowed)359	}360361	fn delete_token_properties(362		&self,363		_sender: T::CrossAccountId,364		_token_id: TokenId,365		_property_keys: Vec<PropertyKey>,366		_nesting_budget: &dyn Budget,367	) -> DispatchResultWithPostInfo {368		fail!(<Error<T>>::SettingPropertiesNotAllowed)369	}370371	fn check_nesting(372		&self,373		_sender: <T>::CrossAccountId,374		_from: (CollectionId, TokenId),375		_under: TokenId,376		_nesting_budget: &dyn Budget,377	) -> sp_runtime::DispatchResult {378		fail!(<Error<T>>::FungibleDisallowsNesting)379	}380381	fn nest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}382383	fn unnest(&self, _under: TokenId, _to_nest: (CollectionId, TokenId)) {}384385	fn collection_tokens(&self) -> Vec<TokenId> {386		vec![TokenId::default()]387	}388389	fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {390		if <Balance<T>>::get((self.id, account)) != 0 {391			vec![TokenId::default()]392		} else {393			vec![]394		}395	}396397	fn token_exists(&self, token: TokenId) -> bool {398		token == TokenId::default()399	}400401	fn last_token_id(&self) -> TokenId {402		TokenId::default()403	}404405	fn token_owner(&self, _token: TokenId) -> Result<T::CrossAccountId, TokenOwnerError> {406		Err(TokenOwnerError::MultipleOwners)407	}408409	/// Returns 10 tokens owners in no particular order.410	fn token_owners(&self, token: TokenId) -> Vec<T::CrossAccountId> {411		<Pallet<T>>::token_owners(self.id, token).unwrap_or_default()412	}413414	fn token_property(&self, _token_id: TokenId, _key: &PropertyKey) -> Option<PropertyValue> {415		None416	}417418	fn token_properties(419		&self,420		_token_id: TokenId,421		_keys: Option<Vec<PropertyKey>>,422	) -> Vec<Property> {423		Vec::new()424	}425426	fn total_supply(&self) -> u32 {427		1428	}429430	fn account_balance(&self, account: T::CrossAccountId) -> u32 {431		if <Balance<T>>::get((self.id, account)) != 0 {432			1433		} else {434			0435		}436	}437438	fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {439		if token != TokenId::default() {440			return 0;441		}442		<Balance<T>>::get((self.id, account))443	}444445	fn allowance(446		&self,447		sender: T::CrossAccountId,448		spender: T::CrossAccountId,449		token: TokenId,450	) -> u128 {451		if token != TokenId::default() {452			return 0;453		}454		<Allowance<T>>::get((self.id, sender, spender))455	}456457	fn refungible_extensions(&self) -> Option<&dyn RefungibleExtensions<T>> {458		None459	}460461	fn total_pieces(&self, token: TokenId) -> Option<u128> {462		if token != TokenId::default() {463			return None;464		}465		<TotalSupply<T>>::try_get(self.id).ok()466	}467468	fn set_allowance_for_all(469		&self,470		_owner: T::CrossAccountId,471		_operator: T::CrossAccountId,472		_approve: bool,473	) -> DispatchResultWithPostInfo {474		fail!(<Error<T>>::SettingAllowanceForAllNotAllowed)475	}476477	fn allowance_for_all(&self, _owner: T::CrossAccountId, _operator: T::CrossAccountId) -> bool {478		false479	}480481	/// Repairs a possibly broken item.482	fn repair_item(&self, _token: TokenId) -> DispatchResultWithPostInfo {483		fail!(<Error<T>>::FungibleTokensAreAlwaysValid)484	}485}
modifiedpallets/nonfungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/nonfungible/CHANGELOG.md
+++ b/pallets/nonfungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.13] - 2023-01-20
+
+### Fixed
+
+- The weight of properties when creating an item.
+
 ## [0.1.12] - 2022-12-16
 
 ### Added
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.12"
+version = "0.1.13"
 
 [dependencies]
 codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = "3.1.2" }
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -35,10 +35,6 @@
 
 pub struct CommonWeights<T: Config>(PhantomData<T>);
 impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
-	fn create_item() -> Weight {
-		<SelfWeightOf<T>>::create_item()
-	}
-
 	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
 		match data {
 			CreateItemExData::NFT(t) => {
@@ -159,6 +155,7 @@
 		data: up_data_structs::CreateItemData,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResultWithPostInfo {
+		let weight = <CommonWeights<T>>::create_item(&data);
 		with_weight(
 			<Pallet<T>>::create_item(
 				self,
@@ -166,7 +163,7 @@
 				map_create_data::<T>(data, &to)?,
 				nesting_budget,
 			),
-			<CommonWeights<T>>::create_item(),
+			weight,
 		)
 	}
 
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -994,7 +994,7 @@
 	/// @param to The new owner crossAccountId
 	/// @param properties Properties of minted token
 	/// @return uint256 The id of the newly minted token
-	#[weight(<SelfWeightOf<T>>::create_item())]
+	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
 	fn mint_cross(
 		&mut self,
 		caller: Caller,
modifiedpallets/refungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.2.12] - 2023-01-20
+
+### Fixed
+
+- The weight of properties when creating an item.
+
 ## [0.2.11] - 2022-12-16
 
 ### Added
modifiedpallets/refungible/Cargo.tomldiffbeforeafterboth
--- a/pallets/refungible/Cargo.toml
+++ b/pallets/refungible/Cargo.toml
@@ -2,7 +2,7 @@
 edition = "2021"
 license = "GPLv3"
 name = "pallet-refungible"
-version = "0.2.11"
+version = "0.2.12"
 
 [dependencies]
 codec = { default-features = false, features = ['derive'], package = 'parity-scale-codec', version = "3.1.2" }
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -55,10 +55,6 @@
 
 pub struct CommonWeights<T: Config>(PhantomData<T>);
 impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
-	fn create_item() -> Weight {
-		<SelfWeightOf<T>>::create_item()
-	}
-
 	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
 		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
 			data.iter()
@@ -193,6 +189,7 @@
 		data: up_data_structs::CreateItemData,
 		nesting_budget: &dyn Budget,
 	) -> DispatchResultWithPostInfo {
+		let weight = <CommonWeights<T>>::create_item(&data);
 		with_weight(
 			<Pallet<T>>::create_item(
 				self,
@@ -200,7 +197,7 @@
 				map_create_data::<T>(data, &to)?,
 				nesting_budget,
 			),
-			<CommonWeights<T>>::create_item(),
+			weight,
 		)
 	}
 
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -1051,7 +1051,7 @@
 	/// @param to The new owner crossAccountId
 	/// @param properties Properties of minted token
 	/// @return uint256 The id of the newly minted token
-	#[weight(<SelfWeightOf<T>>::create_item())]
+	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
 	fn mint_cross(
 		&mut self,
 		caller: Caller,
modifiedpallets/unique/src/lib.rsdiffbeforeafterboth
--- a/pallets/unique/src/lib.rs
+++ b/pallets/unique/src/lib.rs
@@ -518,7 +518,7 @@
 		/// * `collection_id`: ID of the collection to which an item would belong.
 		/// * `owner`: Address of the initial owner of the item.
 		/// * `data`: Token data describing the item to store on chain.
-		#[weight = T::CommonWeightInfo::create_item()]
+		#[weight = T::CommonWeightInfo::create_item(&data)]
 		pub fn create_item(origin, collection_id: CollectionId, owner: T::CrossAccountId, data: CreateItemData) -> DispatchResultWithPostInfo {
 			let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
 			let budget = budget::Value::new(NESTING_BUDGET);
modifiedruntime/common/weights.rsdiffbeforeafterboth
--- a/runtime/common/weights.rs
+++ b/runtime/common/weights.rs
@@ -57,8 +57,8 @@
 where
 	T: CommonWeightConfigs,
 {
-	fn create_item() -> Weight {
-		dispatch_weight::<T>() + max_weight_of!(create_item())
+	fn create_item(data: &CreateItemData) -> Weight {
+		dispatch_weight::<T>() + max_weight_of!(create_item(data))
 	}
 
 	fn create_multiple_items(data: &[CreateItemData]) -> Weight {