git.delta.rocks / unique-network / refs/commits / 742862849b4b

difftreelog

fix EVM mint with properties, minor improvements

Daniel Shiposha2023-10-13parent: #aae21d3.patch.diff
in: master

9 files changed

modifiedpallets/common/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/common/src/benchmarking.rs
+++ b/pallets/common/src/benchmarking.rs
@@ -29,9 +29,8 @@
 use sp_std::{vec, vec::Vec};
 use up_data_structs::{
 	AccessMode, CollectionId, CollectionMode, CollectionPermissions, CreateCollectionData,
-	NestingPermissions, PropertiesPermissionMap, Property, PropertyKey, PropertyValue,
-	MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_COLLECTION_NAME_LENGTH, MAX_PROPERTIES_PER_ITEM,
-	MAX_TOKEN_PREFIX_LENGTH,
+	NestingPermissions, Property, PropertyKey, PropertyValue, MAX_COLLECTION_DESCRIPTION_LENGTH,
+	MAX_COLLECTION_NAME_LENGTH, MAX_PROPERTIES_PER_ITEM, MAX_TOKEN_PREFIX_LENGTH,
 };
 
 use crate::{BenchmarkPropertyWriter, CollectionHandle, Config, Pallet};
@@ -190,31 +189,6 @@
 		#[block]
 		{
 			<Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
-		}
-
-		Ok(())
-	}
-
-	#[benchmark]
-	fn delete_collection_properties(
-		b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
-	) -> Result<(), BenchmarkError> {
-		bench_init! {
-			owner: sub; collection: collection(owner);
-			owner: cross_from_sub;
-		};
-		let props = (0..b)
-			.map(|p| Property {
-				key: property_key(p as usize),
-				value: property_value(),
-			})
-			.collect::<Vec<_>>();
-		<Pallet<T>>::set_collection_properties(&collection, &owner, props.into_iter())?;
-		let to_delete = (0..b).map(|p| property_key(p as usize)).collect::<Vec<_>>();
-
-		#[block]
-		{
-			<Pallet<T>>::delete_collection_properties(&collection, &owner, to_delete.into_iter())?;
 		}
 
 		Ok(())
@@ -253,7 +227,7 @@
 	}
 
 	#[benchmark]
-	fn init_token_properties_common() -> Result<(), BenchmarkError> {
+	fn property_writer_load_collection_info() -> Result<(), BenchmarkError> {
 		bench_init! {
 			owner: sub; collection: collection(owner);
 			sender: sub;
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -126,7 +126,7 @@
 	///
 	/// @param key Property key.
 	#[solidity(hide)]
-	#[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]
+	#[weight(<SelfWeightOf<T>>::set_collection_properties(1))]
 	fn delete_collection_property(&mut self, caller: Caller, key: String) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let key = <Vec<u8>>::from(key)
@@ -139,7 +139,7 @@
 	/// Delete collection properties.
 	///
 	/// @param keys Properties keys.
-	#[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]
+	#[weight(<SelfWeightOf<T>>::set_collection_properties(keys.len() as u32))]
 	fn delete_collection_properties(&mut self, caller: Caller, keys: Vec<String>) -> Result<()> {
 		let caller = T::CrossAccountId::from_eth(caller);
 		let keys = keys
modifiedpallets/common/src/lib.rsdiffbeforeafterboth
--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -2626,8 +2626,8 @@
 impl<T: Config> BenchmarkPropertyWriter<T> {
 	/// Creates a [`PropertyWriter`] for benchmarking tokens properties writing.
 	pub fn new<'a, Handle>(
-		collection: &Handle,
-		collection_lazy_info: PropertyWriterLazyCollectionInfo,
+		collection: &'a Handle,
+		collection_lazy_info: PropertyWriterLazyCollectionInfo<'a>,
 	) -> PropertyWriter<'a, Self, T, Handle>
 	where
 		Handle: CommonCollectionOperations<T> + Deref<Target = CollectionHandle<T>>,
modifiedpallets/nonfungible/src/benchmarking.rsdiffbeforeafterboth
before · pallets/nonfungible/src/benchmarking.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 frame_benchmarking::v2::{account, benchmarks, BenchmarkError};18use pallet_common::{19	bench_init,20	benchmarking::{create_collection_raw, property_key, property_value},21	CommonCollectionOperations,22};23use sp_std::prelude::*;24use up_data_structs::{25	budget::Unlimited, CollectionMode, PropertyPermission, MAX_ITEMS_PER_BATCH,26	MAX_PROPERTIES_PER_ITEM,27};2829use super::*;30use crate::{Config, NonfungibleHandle, Pallet};3132const SEED: u32 = 1;3334fn create_max_item_data<T: Config>(owner: T::CrossAccountId) -> CreateItemData<T> {35	CreateItemData::<T> {36		owner,37		properties: Default::default(),38	}39}40fn create_max_item<T: Config>(41	collection: &NonfungibleHandle<T>,42	sender: &T::CrossAccountId,43	owner: T::CrossAccountId,44) -> Result<TokenId, DispatchError> {45	<Pallet<T>>::create_item(46		collection,47		sender,48		create_max_item_data::<T>(owner),49		&Unlimited,50	)?;51	Ok(TokenId(<TokensMinted<T>>::get(collection.id)))52}5354fn create_collection<T: Config>(55	owner: T::CrossAccountId,56) -> Result<NonfungibleHandle<T>, DispatchError> {57	create_collection_raw(58		owner,59		CollectionMode::NFT,60		|owner: T::CrossAccountId, data| <Pallet<T>>::init_collection(owner.clone(), owner, data),61		NonfungibleHandle::cast,62	)63}6465#[benchmarks]66mod benchmarks {67	use super::*;6869	#[benchmark]70	fn create_item() -> Result<(), BenchmarkError> {71		bench_init! {72			owner: sub; collection: collection(owner);73			sender: cross_from_sub(owner); to: cross_sub;74		};7576		#[block]77		{78			create_max_item(&collection, &sender, to)?;79		}8081		Ok(())82	}8384	#[benchmark]85	fn create_multiple_items(b: Linear<0, MAX_ITEMS_PER_BATCH>) -> Result<(), BenchmarkError> {86		bench_init! {87			owner: sub; collection: collection(owner);88			sender: cross_from_sub(owner); to: cross_sub;89		};90		let data = (0..b)91			.map(|_| create_max_item_data::<T>(to.clone()))92			.collect();9394		#[block]95		{96			<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;97		}9899		Ok(())100	}101102	#[benchmark]103	fn create_multiple_items_ex(b: Linear<0, MAX_ITEMS_PER_BATCH>) -> Result<(), BenchmarkError> {104		bench_init! {105			owner: sub; collection: collection(owner);106			sender: cross_from_sub(owner);107		};108		let data = (0..b)109			.map(|i| {110				bench_init!(to: cross_sub(i););111				create_max_item_data::<T>(to)112			})113			.collect();114115		#[block]116		{117			<Pallet<T>>::create_multiple_items(&collection, &sender, data, &Unlimited)?;118		}119120		Ok(())121	}122123	#[benchmark]124	fn burn_item() -> Result<(), BenchmarkError> {125		bench_init! {126			owner: sub; collection: collection(owner);127			sender: cross_from_sub(owner); burner: cross_sub;128		};129		let item = create_max_item(&collection, &sender, burner.clone())?;130131		#[block]132		{133			<Pallet<T>>::burn(&collection, &burner, item)?;134		}135136		Ok(())137	}138139	#[benchmark]140	fn burn_recursively_self_raw() -> Result<(), BenchmarkError> {141		bench_init! {142			owner: sub; collection: collection(owner);143			sender: cross_from_sub(owner); burner: cross_sub;144		};145		let item = create_max_item(&collection, &sender, burner.clone())?;146147		#[block]148		{149			<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?;150		}151152		Ok(())153	}154155	#[benchmark]156	fn burn_recursively_breadth_plus_self_plus_self_per_each_raw(157		b: Linear<0, 200>,158	) -> Result<(), BenchmarkError> {159		bench_init! {160			owner: sub; collection: collection(owner);161			sender: cross_from_sub(owner); burner: cross_sub;162		};163		let item = create_max_item(&collection, &sender, burner.clone())?;164		for _ in 0..b {165			create_max_item(166				&collection,167				&sender,168				T::CrossTokenAddressMapping::token_to_address(collection.id, item),169			)?;170		}171172		#[block]173		{174			<Pallet<T>>::burn_recursively(&collection, &burner, item, &Unlimited, &Unlimited)?;175		}176177		Ok(())178	}179180	#[benchmark]181	fn transfer_raw() -> Result<(), BenchmarkError> {182		bench_init! {183			owner: sub; collection: collection(owner);184			owner: cross_from_sub; sender: cross_sub; receiver: cross_sub;185		};186		let item = create_max_item(&collection, &owner, sender.clone())?;187188		#[block]189		{190			<Pallet<T>>::transfer(&collection, &sender, &receiver, item, &Unlimited)?;191		}192193		Ok(())194	}195196	#[benchmark]197	fn approve() -> Result<(), BenchmarkError> {198		bench_init! {199			owner: sub; collection: collection(owner);200			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;201		};202		let item = create_max_item(&collection, &owner, sender.clone())?;203204		#[block]205		{206			<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;207		}208209		Ok(())210	}211212	#[benchmark]213	fn approve_from() -> Result<(), BenchmarkError> {214		bench_init! {215			owner: sub; collection: collection(owner);216			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;217		};218		let owner_eth = T::CrossAccountId::from_eth(*sender.as_eth());219		let item = create_max_item(&collection, &owner, owner_eth.clone())?;220221		#[block]222		{223			<Pallet<T>>::set_allowance_from(224				&collection,225				&sender,226				&owner_eth,227				item,228				Some(&spender),229			)?;230		}231232		Ok(())233	}234235	#[benchmark]236	fn check_allowed_raw() -> Result<(), BenchmarkError> {237		bench_init! {238			owner: sub; collection: collection(owner);239			owner: cross_from_sub; sender: cross_sub; spender: cross_sub;240		};241		let item = create_max_item(&collection, &owner, sender.clone())?;242		<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&spender))?;243244		#[block]245		{246			<Pallet<T>>::check_allowed(&collection, &spender, &sender, item, &Unlimited)?;247		}248249		Ok(())250	}251252	#[benchmark]253	fn burn_from() -> Result<(), BenchmarkError> {254		bench_init! {255			owner: sub; collection: collection(owner);256			owner: cross_from_sub; sender: cross_sub; burner: cross_sub;257		};258		let item = create_max_item(&collection, &owner, sender.clone())?;259		<Pallet<T>>::set_allowance(&collection, &sender, item, Some(&burner))?;260261		#[block]262		{263			<Pallet<T>>::burn_from(&collection, &burner, &sender, item, &Unlimited)?;264		}265	}266267	// set_token_properties {268	// 	let b in 0..MAX_PROPERTIES_PER_ITEM;269	// 	bench_init!{270	// 		owner: sub; collection: collection(owner);271	// 		owner: cross_from_sub;272	// 	};273	// 	let perms = (0..b).map(|k| PropertyKeyPermission {274	// 		key: property_key(k as usize),275	// 		permission: PropertyPermission {276	// 			mutable: false,277	// 			collection_admin: true,278	// 			token_owner: true,279	// 		},280	// 	}).collect::<Vec<_>>();281	// 	<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;282	// 	let props = (0..b).map(|k| Property {283	// 		key: property_key(k as usize),284	// 		value: property_value(),285	// 	}).collect::<Vec<_>>();286	// 	let item = create_max_item(&collection, &owner, owner.clone())?;287	// }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}288289	// load_token_properties {290	// 	bench_init!{291	// 		owner: sub; collection: collection(owner);292	// 		owner: cross_from_sub;293	// 	};294295	// 	let item = create_max_item(&collection, &owner, owner.clone())?;296	// }: {297	// 	pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(298	// 		&collection,299	// 		item,300	// 	)301	// }302303	// write_token_properties {304	// 	let b in 0..MAX_PROPERTIES_PER_ITEM;305	// 	bench_init!{306	// 		owner: sub; collection: collection(owner);307	// 		owner: cross_from_sub;308	// 	};309310	// 	let perms = (0..b).map(|k| PropertyKeyPermission {311	// 		key: property_key(k as usize),312	// 		permission: PropertyPermission {313	// 			mutable: false,314	// 			collection_admin: true,315	// 			token_owner: true,316	// 		},317	// 	}).collect::<Vec<_>>();318	// 	<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;319	// 	let props = (0..b).map(|k| Property {320	// 		key: property_key(k as usize),321	// 		value: property_value(),322	// 	}).collect::<Vec<_>>();323	// 	let item = create_max_item(&collection, &owner, owner.clone())?;324325	// 	let lazy_collection_info = pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(326	// 		&collection,327	// 		&owner,328	// 	);329	// }: {330	// 	let mut property_writer = pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);331332	// 	property_writer.write_token_properties(333	// 		item,334	// 		props.into_iter(),335	// 		crate::erc::ERC721TokenEvent::TokenChanged {336	// 			token_id: item.into(),337	// 		}338	// 		.to_log(T::ContractAddress::get()),339	// 	)?340	// }341342	#[benchmark]343	fn set_token_property_permissions(344		b: Linear<0, MAX_PROPERTIES_PER_ITEM>,345	) -> Result<(), BenchmarkError> {346		bench_init! {347			owner: sub; collection: collection(owner);348			owner: cross_from_sub;349		};350		let perms = (0..b)351			.map(|k| PropertyKeyPermission {352				key: property_key(k as usize),353				permission: PropertyPermission {354					mutable: false,355					collection_admin: false,356					token_owner: false,357				},358			})359			.collect::<Vec<_>>();360361		#[block]362		{363			<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;364		}365366		Ok(())367	}368369	#[benchmark]370	fn set_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {371		bench_init! {372			owner: sub; collection: collection(owner);373			owner: cross_from_sub;374		};375		let perms = (0..b)376			.map(|k| PropertyKeyPermission {377				key: property_key(k as usize),378				permission: PropertyPermission {379					mutable: false,380					collection_admin: true,381					token_owner: true,382				},383			})384			.collect::<Vec<_>>();385		<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;386		let props = (0..b)387			.map(|k| Property {388				key: property_key(k as usize),389				value: property_value(),390			})391			.collect::<Vec<_>>();392		let item = create_max_item(&collection, &owner, owner.clone())?;393394		#[block]395		{396			<Pallet<T>>::set_token_properties(397				&collection,398				&owner,399				item,400				props.into_iter(),401				&Unlimited,402			)?;403		}404405		Ok(())406	}407408	// TODO:409	#[benchmark]410	fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {411		// bench_init! {412		// 	owner: sub; collection: collection(owner);413		// 	owner: cross_from_sub;414		// };415416		// let perms = (0..b)417		// 	.map(|k| PropertyKeyPermission {418		// 		key: property_key(k as usize),419		// 		permission: PropertyPermission {420		// 			mutable: false,421		// 			collection_admin: true,422		// 			token_owner: true,423		// 		},424		// 	})425		// 	.collect::<Vec<_>>();426		// <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;427		#[block]428		{}429		// let props = (0..b)430		// 	.map(|k| Property {431		// 		key: property_key(k as usize),432		// 		value: property_value(),433		// 	})434		// 	.collect::<Vec<_>>();435		// let item = create_max_item(&collection, &owner, owner.clone())?;436437		// let (is_collection_admin, property_permissions) =438		// 	load_is_admin_and_property_permissions(&collection, &owner);439		// #[block]440		// {441		// 	let mut property_writer =442		// 		pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);443444		// 	property_writer.write_token_properties(445		// 		item,446		// 		props.into_iter(),447		// 		crate::erc::ERC721TokenEvent::TokenChanged {448		// 			token_id: item.into(),449		// 		}450		// 		.to_log(T::ContractAddress::get()),451		// 	)?;452		// }453454		Ok(())455	}456457	#[benchmark]458	fn delete_token_properties(459		b: Linear<0, MAX_PROPERTIES_PER_ITEM>,460	) -> Result<(), BenchmarkError> {461		bench_init! {462			owner: sub; collection: collection(owner);463			owner: cross_from_sub;464		};465		let perms = (0..b)466			.map(|k| PropertyKeyPermission {467				key: property_key(k as usize),468				permission: PropertyPermission {469					mutable: true,470					collection_admin: true,471					token_owner: true,472				},473			})474			.collect::<Vec<_>>();475		<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;476		let props = (0..b)477			.map(|k| Property {478				key: property_key(k as usize),479				value: property_value(),480			})481			.collect::<Vec<_>>();482		let item = create_max_item(&collection, &owner, owner.clone())?;483		<Pallet<T>>::set_token_properties(484			&collection,485			&owner,486			item,487			props.into_iter(),488			&Unlimited,489		)?;490		let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();491492		#[block]493		{494			<Pallet<T>>::delete_token_properties(495				&collection,496				&owner,497				item,498				to_delete.into_iter(),499				&Unlimited,500			)?;501		}502503		Ok(())504	}505506	#[benchmark]507	fn token_owner() -> Result<(), BenchmarkError> {508		bench_init! {509			owner: sub; collection: collection(owner);510			owner: cross_from_sub;511		};512		let item = create_max_item(&collection, &owner, owner.clone())?;513514		#[block]515		{516			collection.token_owner(item).unwrap();517		}518519		Ok(())520	}521522	#[benchmark]523	fn set_allowance_for_all() -> Result<(), BenchmarkError> {524		bench_init! {525			owner: sub; collection: collection(owner); owner: cross_from_sub;526			operator: cross_sub;527		};528529		#[block]530		{531			<Pallet<T>>::set_allowance_for_all(&collection, &owner, &operator, true)?;532		}533534		Ok(())535	}536537	#[benchmark]538	fn allowance_for_all() -> Result<(), BenchmarkError> {539		bench_init! {540			owner: sub; collection: collection(owner); owner: cross_from_sub;541			operator: cross_sub;542		};543544		#[block]545		{546			<Pallet<T>>::allowance_for_all(&collection, &owner, &operator);547		}548549		Ok(())550	}551552	#[benchmark]553	fn repair_item() -> Result<(), BenchmarkError> {554		bench_init! {555			owner: sub; collection: collection(owner);556			owner: cross_from_sub;557		};558		let item = create_max_item(&collection, &owner, owner.clone())?;559560		#[block]561		{562			<Pallet<T>>::repair_item(&collection, item)?;563		}564565		Ok(())566	}567}
modifiedpallets/nonfungible/src/common.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -39,24 +39,21 @@
 impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
 	fn create_multiple_items_ex(data: &CreateItemExData<T::CrossAccountId>) -> Weight {
 		match data {
-			CreateItemExData::NFT(t) => <SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32)
-				.saturating_add(write_token_properties_total_weight::<T, _>(
-					t.iter().map(|t| t.properties.len() as u32),
-					<SelfWeightOf<T>>::write_token_properties,
-				)),
+			CreateItemExData::NFT(t) => mint_with_props_weight::<T>(
+				<SelfWeightOf<T>>::create_multiple_items_ex(t.len() as u32),
+				t.iter().map(|t| t.properties.len() as u32),
+			),
 			_ => Weight::zero(),
 		}
 	}
 
 	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
-		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
-			write_token_properties_total_weight::<T, _>(
-				data.iter().map(|t| match t {
-					up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,
-					_ => 0,
-				}),
-				<SelfWeightOf<T>>::write_token_properties,
-			),
+		mint_with_props_weight::<T>(
+			<SelfWeightOf<T>>::create_multiple_items(data.len() as u32),
+			data.iter().map(|t| match t {
+				up_data_structs::CreateItemData::NFT(n) => n.properties.len() as u32,
+				_ => 0,
+			}),
 		)
 	}
 
@@ -113,6 +110,16 @@
 	}
 }
 
+pub(crate) fn mint_with_props_weight<T: Config>(
+	create_no_data_weight: Weight,
+	tokens: impl Iterator<Item = u32> + Clone,
+) -> Weight {
+	create_no_data_weight.saturating_add(write_token_properties_total_weight::<T, _>(
+		tokens,
+		<SelfWeightOf<T>>::write_token_properties,
+	))
+}
+
 fn map_create_data<T: Config>(
 	data: up_data_structs::CreateItemData,
 	to: &T::CrossAccountId,
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -49,8 +49,10 @@
 };
 
 use crate::{
-	common::CommonWeights, weights::WeightInfo, AccountBalance, Config, CreateItemData,
-	NonfungibleHandle, Pallet, SelfWeightOf, TokenData, TokenProperties, TokensMinted,
+	common::{mint_with_props_weight, CommonWeights},
+	weights::WeightInfo,
+	AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, SelfWeightOf, TokenData,
+	TokenProperties, TokensMinted,
 };
 
 /// Nft events.
@@ -620,7 +622,7 @@
 	/// @param tokenUri Token URI that would be stored in the NFT properties
 	/// @return uint256 The id of the newly minted token
 	#[solidity(rename_selector = "mintWithTokenURI")]
-	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+	#[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
 	fn mint_with_token_uri(
 		&mut self,
 		caller: Caller,
@@ -642,7 +644,7 @@
 	/// @param tokenId ID of the minted NFT
 	/// @param tokenUri Token URI that would be stored in the NFT properties
 	#[solidity(hide, rename_selector = "mintWithTokenURI")]
-	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+	#[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
 	fn mint_with_token_uri_check_id(
 		&mut self,
 		caller: Caller,
@@ -974,7 +976,12 @@
 
 	/// @notice Function to mint a token.
 	/// @param data Array of pairs of token owner and token's properties for minted token
-	#[weight(<SelfWeightOf<T>>::create_multiple_items(data.len() as u32) + <SelfWeightOf<T>>::set_token_properties(data.len() as u32))]
+	#[weight(
+		mint_with_props_weight::<T>(
+			<SelfWeightOf<T>>::create_multiple_items_ex(data.len() as u32),
+			data.iter().map(|d| d.properties.len() as u32),
+		)
+	)]
 	fn mint_bulk_cross(&mut self, caller: Caller, data: Vec<MintTokenData>) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
 
@@ -1008,7 +1015,12 @@
 	/// @param to The new owner
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
 	#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]
-	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]
+	#[weight(
+		mint_with_props_weight::<T>(
+			<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32),
+			tokens.iter().map(|_| 1),
+		)
+	)]
 	fn mint_bulk_with_token_uri(
 		&mut self,
 		caller: Caller,
@@ -1056,7 +1068,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() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+	#[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [properties.len() as u32].into_iter()))]
 	fn mint_cross(
 		&mut self,
 		caller: Caller,
modifiedpallets/refungible/src/benchmarking.rsdiffbeforeafterboth
--- a/pallets/refungible/src/benchmarking.rs
+++ b/pallets/refungible/src/benchmarking.rs
@@ -421,114 +421,30 @@
 		Ok(())
 	}
 
-	// set_token_properties {
-	// 	let b in 0..MAX_PROPERTIES_PER_ITEM;
-	// 	bench_init!{
-	// 		owner: sub; collection: collection(owner);
-	// 		owner: cross_from_sub;
-	// 	};
-	// 	let perms = (0..b).map(|k| PropertyKeyPermission {
-	// 		key: property_key(k as usize),
-	// 		permission: PropertyPermission {
-	// 			mutable: false,
-	// 			collection_admin: true,
-	// 			token_owner: true,
-	// 		},
-	// 	}).collect::<Vec<_>>();
-	// 	<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
-	// 	let props = (0..b).map(|k| Property {
-	// 		key: property_key(k as usize),
-	// 		value: property_value(),
-	// 	}).collect::<Vec<_>>();
-	// 	let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
-	// }: {<Pallet<T>>::set_token_properties(&collection, &owner, item, props.into_iter(), &Unlimited)?}
-
-	// load_token_properties {
-	// 	bench_init!{
-	// 		owner: sub; collection: collection(owner);
-	// 		owner: cross_from_sub;
-	// 	};
-
-	// 	let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
-	// }: {
-	// 	pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(
-	// 		&collection,
-	// 		item,
-	// 	)
-	// }
-
-	// write_token_properties {
-	// 	let b in 0..MAX_PROPERTIES_PER_ITEM;
-	// 	bench_init!{
-	// 		owner: sub; collection: collection(owner);
-	// 		owner: cross_from_sub;
-	// 	};
-
-	// 	let perms = (0..b).map(|k| PropertyKeyPermission {
-	// 		key: property_key(k as usize),
-	// 		permission: PropertyPermission {
-	// 			mutable: false,
-	// 			collection_admin: true,
-	// 			token_owner: true,
-	// 		},
-	// 	}).collect::<Vec<_>>();
-	// 	<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
-	// 	let props = (0..b).map(|k| Property {
-	// 		key: property_key(k as usize),
-	// 		value: property_value(),
-	// 	}).collect::<Vec<_>>();
-	// 	let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
-
-	// 	let lazy_collection_info = pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(
-	// 		&collection,
-	// 		&owner,
-	// 	);
-	// }: {
-	// 	let mut property_writer = pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
-
-	// 	property_writer.write_token_properties(
-	// 		item,
-	// 		props.into_iter(),
-	// 		crate::erc::ERC721TokenEvent::TokenChanged {
-	// 			token_id: item.into(),
-	// 		}
-	// 		.to_log(T::ContractAddress::get()),
-	// 	)?
-	// }
-
 	#[benchmark]
-	fn set_token_property_permissions(
-		b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
-	) -> Result<(), BenchmarkError> {
+	fn load_token_properties() -> Result<(), BenchmarkError> {
 		bench_init! {
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub;
 		};
-		let perms = (0..b)
-			.map(|k| PropertyKeyPermission {
-				key: property_key(k as usize),
-				permission: PropertyPermission {
-					mutable: false,
-					collection_admin: false,
-					token_owner: false,
-				},
-			})
-			.collect::<Vec<_>>();
 
+		let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
+
 		#[block]
 		{
-			<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
+			pallet_common::BenchmarkPropertyWriter::<T>::load_token_properties(&collection, item);
 		}
 
 		Ok(())
 	}
 
 	#[benchmark]
-	fn set_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
+	fn write_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
 		bench_init! {
 			owner: sub; collection: collection(owner);
 			owner: cross_from_sub;
 		};
+
 		let perms = (0..b)
 			.map(|k| PropertyKeyPermission {
 				key: property_key(k as usize),
@@ -548,73 +464,29 @@
 			.collect::<Vec<_>>();
 		let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
 
+		let lazy_collection_info =
+			pallet_common::BenchmarkPropertyWriter::<T>::load_collection_info(&collection, &owner);
+
 		#[block]
 		{
-			<Pallet<T>>::set_token_properties(
-				&collection,
-				&owner,
+			let mut property_writer =
+				pallet_common::BenchmarkPropertyWriter::new(&collection, lazy_collection_info);
+
+			property_writer.write_token_properties(
 				item,
 				props.into_iter(),
-				&Unlimited,
+				crate::erc::ERC721TokenEvent::TokenChanged {
+					token_id: item.into(),
+				}
+				.to_log(T::ContractAddress::get()),
 			)?;
 		}
 
 		Ok(())
 	}
 
-	// TODO:
 	#[benchmark]
-	fn init_token_properties(b: Linear<0, MAX_PROPERTIES_PER_ITEM>) -> Result<(), BenchmarkError> {
-		// bench_init! {
-		// 	owner: sub; collection: collection(owner);
-		// 	owner: cross_from_sub;
-		// };
-
-		// let perms = (0..b)
-		// 	.map(|k| PropertyKeyPermission {
-		// 		key: property_key(k as usize),
-		// 		permission: PropertyPermission {
-		// 			mutable: false,
-		// 			collection_admin: true,
-		// 			token_owner: true,
-		// 		},
-		// 	})
-		// 	.collect::<Vec<_>>();
-		// <Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
-
-		#[block]
-		{}
-		// let props = (0..b).map(|k| Property {
-		// 	key: property_key(k as usize),
-		// 	value: property_value(),
-		// }).collect::<Vec<_>>();
-		// let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
-
-		// let (is_collection_admin, property_permissions) = load_is_admin_and_property_permissions(&collection, &owner)
-		// let mut property_writer = pallet_common::collection_info_loaded_property_writer(
-		// 	&collection,
-		// 	is_collection_admin,
-		// 	property_permissions,
-		// );
-
-		// #[block]
-		// {
-		// 	property_writer.write_token_properties(
-		// 		true,
-		// 		item,
-		// 		props.into_iter(),
-		// 		crate::erc::ERC721TokenEvent::TokenChanged {
-		// 			token_id: item.into(),
-		// 		}
-		// 		.to_log(T::ContractAddress::get()),
-		// 	)?;
-		// }
-
-		Ok(())
-	}
-
-	#[benchmark]
-	fn delete_token_properties(
+	fn set_token_property_permissions(
 		b: Linear<0, MAX_PROPERTIES_PER_ITEM>,
 	) -> Result<(), BenchmarkError> {
 		bench_init! {
@@ -625,38 +497,16 @@
 			.map(|k| PropertyKeyPermission {
 				key: property_key(k as usize),
 				permission: PropertyPermission {
-					mutable: true,
-					collection_admin: true,
-					token_owner: true,
+					mutable: false,
+					collection_admin: false,
+					token_owner: false,
 				},
-			})
-			.collect::<Vec<_>>();
-		<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
-		let props = (0..b)
-			.map(|k| Property {
-				key: property_key(k as usize),
-				value: property_value(),
 			})
 			.collect::<Vec<_>>();
-		let item = create_max_item(&collection, &owner, [(owner.clone(), 200)])?;
-		<Pallet<T>>::set_token_properties(
-			&collection,
-			&owner,
-			item,
-			props.into_iter(),
-			&Unlimited,
-		)?;
-		let to_delete = (0..b).map(|k| property_key(k as usize)).collect::<Vec<_>>();
 
 		#[block]
 		{
-			<Pallet<T>>::delete_token_properties(
-				&collection,
-				&owner,
-				item,
-				to_delete.into_iter(),
-				&Unlimited,
-			)?;
+			<Pallet<T>>::set_token_property_permissions(&collection, &owner, perms)?;
 		}
 
 		Ok(())
@@ -673,22 +523,6 @@
 		#[block]
 		{
 			<Pallet<T>>::repartition(&collection, &owner, item, 200)?;
-		}
-
-		Ok(())
-	}
-
-	#[benchmark]
-	fn token_owner() -> Result<(), BenchmarkError> {
-		bench_init! {
-			owner: sub; collection: collection(owner);
-			sender: cross_from_sub(owner); owner: cross_sub;
-		};
-		let item = create_max_item(&collection, &sender, [(owner, 100)])?;
-
-		#[block]
-		{
-			<Pallet<T>>::token_owner(collection.id, item).unwrap();
 		}
 
 		Ok(())
modifiedpallets/refungible/src/common.rsdiffbeforeafterboth
--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -47,35 +47,27 @@
 pub struct CommonWeights<T: Config>(PhantomData<T>);
 impl<T: Config> CommonWeightInfo<T::CrossAccountId> for CommonWeights<T> {
 	fn create_multiple_items(data: &[up_data_structs::CreateItemData]) -> Weight {
-		<SelfWeightOf<T>>::create_multiple_items(data.len() as u32).saturating_add(
-			write_token_properties_total_weight::<T, _>(
-				data.iter().map(|data| match data {
-					up_data_structs::CreateItemData::ReFungible(rft_data) => {
-						rft_data.properties.len() as u32
-					}
-					_ => 0,
-				}),
-				<SelfWeightOf<T>>::write_token_properties,
-			),
+		mint_with_props_weight::<T>(
+			<SelfWeightOf<T>>::create_multiple_items(data.len() as u32),
+			data.iter().map(|data| match data {
+				up_data_structs::CreateItemData::ReFungible(rft_data) => {
+					rft_data.properties.len() as u32
+				}
+				_ => 0,
+			}),
 		)
 	}
 
 	fn create_multiple_items_ex(call: &CreateItemExData<T::CrossAccountId>) -> Weight {
 		match call {
-			CreateItemExData::RefungibleMultipleOwners(i) => {
-				<SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32)
-					.saturating_add(write_token_properties_total_weight::<T, _>(
-						[i.properties.len() as u32].into_iter(),
-						<SelfWeightOf<T>>::write_token_properties,
-					))
-			}
-			CreateItemExData::RefungibleMultipleItems(i) => {
-				<SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32)
-					.saturating_add(write_token_properties_total_weight::<T, _>(
-						i.iter().map(|d| d.properties.len() as u32),
-						<SelfWeightOf<T>>::write_token_properties,
-					))
-			}
+			CreateItemExData::RefungibleMultipleOwners(i) => mint_with_props_weight::<T>(
+				<SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(i.users.len() as u32),
+				[i.properties.len() as u32].into_iter(),
+			),
+			CreateItemExData::RefungibleMultipleItems(i) => mint_with_props_weight::<T>(
+				<SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(i.len() as u32),
+				i.iter().map(|d| d.properties.len() as u32),
+			),
 			_ => Weight::zero(),
 		}
 	}
@@ -138,6 +130,16 @@
 	}
 }
 
+pub(crate) fn mint_with_props_weight<T: Config>(
+	create_no_data_weight: Weight,
+	tokens: impl Iterator<Item = u32> + Clone,
+) -> Weight {
+	create_no_data_weight.saturating_add(write_token_properties_total_weight::<T, _>(
+		tokens,
+		<SelfWeightOf<T>>::write_token_properties,
+	))
+}
+
 fn map_create_data<T: Config>(
 	data: up_data_structs::CreateItemData,
 	to: &T::CrossAccountId,
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -50,8 +50,10 @@
 };
 
 use crate::{
-	common::CommonWeights, weights::WeightInfo, AccountBalance, Balance, Config, CreateItemData,
-	Pallet, RefungibleHandle, SelfWeightOf, TokenProperties, TokensMinted, TotalSupply,
+	common::{mint_with_props_weight, CommonWeights},
+	weights::WeightInfo,
+	AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, SelfWeightOf,
+	TokenProperties, TokensMinted, TotalSupply,
 };
 
 frontier_contract! {
@@ -661,7 +663,7 @@
 	/// @param tokenUri Token URI that would be stored in the NFT properties
 	/// @return uint256 The id of the newly minted token
 	#[solidity(rename_selector = "mintWithTokenURI")]
-	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+	#[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
 	fn mint_with_token_uri(
 		&mut self,
 		caller: Caller,
@@ -683,7 +685,7 @@
 	/// @param tokenId ID of the minted RFT
 	/// @param tokenUri Token URI that would be stored in the RFT properties
 	#[solidity(hide, rename_selector = "mintWithTokenURI")]
-	#[weight(<SelfWeightOf<T>>::create_item() + <SelfWeightOf<T>>::set_token_properties(1))]
+	#[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [1].into_iter()))]
 	fn mint_with_token_uri_check_id(
 		&mut self,
 		caller: Caller,
@@ -1052,22 +1054,26 @@
 	}
 
 	/// @notice Function to mint a token.
-	/// @param tokenProperties Properties of minted token
-	#[weight(if token_properties.len() == 1 {
-		<SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(token_properties.iter().next().unwrap().owners.len() as u32)
+	/// @param tokensData Data of minted token(s)
+	#[weight(if tokens_data.len() == 1 {
+		let token_data = tokens_data.first().unwrap();
+
+		mint_with_props_weight::<T>(
+			<SelfWeightOf<T>>::create_multiple_items_ex_multiple_owners(token_data.owners.len() as u32),
+			[token_data.properties.len() as u32].into_iter(),
+		)
 	} else {
-		<SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(token_properties.len() as u32)
-	} + <SelfWeightOf<T>>::set_token_properties(token_properties.len() as u32))]
-	fn mint_bulk_cross(
-		&mut self,
-		caller: Caller,
-		token_properties: Vec<MintTokenData>,
-	) -> Result<bool> {
+		mint_with_props_weight::<T>(
+			<SelfWeightOf<T>>::create_multiple_items_ex_multiple_items(tokens_data.len() as u32),
+			tokens_data.iter().map(|d| d.properties.len() as u32),
+		)
+	})]
+	fn mint_bulk_cross(&mut self, caller: Caller, tokens_data: Vec<MintTokenData>) -> Result<bool> {
 		let caller = T::CrossAccountId::from_eth(caller);
-		let has_multiple_tokens = token_properties.len() > 1;
+		let has_multiple_tokens = tokens_data.len() > 1;
 
-		let mut create_rft_data = Vec::with_capacity(token_properties.len());
-		for MintTokenData { owners, properties } in token_properties {
+		let mut create_rft_data = Vec::with_capacity(tokens_data.len());
+		for MintTokenData { owners, properties } in tokens_data {
 			let has_multiple_owners = owners.len() > 1;
 			if has_multiple_tokens & has_multiple_owners {
 				return Err(
@@ -1108,7 +1114,12 @@
 	/// @param to The new owner
 	/// @param tokens array of pairs of token ID and token URI for minted tokens
 	#[solidity(hide, rename_selector = "mintBulkWithTokenURI")]
-	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32) + <SelfWeightOf<T>>::set_token_properties(tokens.len() as u32))]
+	#[weight(
+		mint_with_props_weight::<T>(
+			<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32),
+			tokens.iter().map(|_| 1),
+		)
+	)]
 	fn mint_bulk_with_token_uri(
 		&mut self,
 		caller: Caller,
@@ -1162,7 +1173,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() + <SelfWeightOf<T>>::set_token_properties(properties.len() as u32))]
+	#[weight(mint_with_props_weight::<T>(<SelfWeightOf<T>>::create_item(), [properties.len() as u32].into_iter()))]
 	fn mint_cross(
 		&mut self,
 		caller: Caller,