git.delta.rocks / unique-network / refs/commits / 6bf8d7b241a9

difftreelog

Merge pull request #728 from UniqueNetwork/feature/newCallMethods

Yaroslav Bolyukin2022-11-24parents: #074bf74 #d64c3f7.patch.diff
in: master
Added new call functions

31 files changed

modifiedcrates/evm-coder/src/abi/impls.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi/impls.rs
+++ b/crates/evm-coder/src/abi/impls.rs
@@ -184,8 +184,7 @@
 
 impl AbiWrite for Property {
 	fn abi_write(&self, writer: &mut AbiWriter) {
-		self.key.abi_write(writer);
-		self.value.abi_write(writer);
+		(&self.key, &self.value).abi_write(writer);
 	}
 }
 
modifiedcrates/evm-coder/src/abi/traits.rsdiffbeforeafterboth
--- a/crates/evm-coder/src/abi/traits.rs
+++ b/crates/evm-coder/src/abi/traits.rs
@@ -49,3 +49,9 @@
 		Ok(writer.into())
 	}
 }
+
+impl<T: AbiWrite> AbiWrite for &T {
+	fn abi_write(&self, writer: &mut AbiWriter) {
+		T::abi_write(self, writer);
+	}
+}
modifiedpallets/common/src/erc.rsdiffbeforeafterboth
before · pallets/common/src/erc.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//! This module contains the implementation of pallet methods for evm.1819use evm_coder::{20	abi::AbiType,21	solidity_interface, solidity, ToLog,22	types::*,23	types::Property as PropertyStruct,24	execution::{Result, Error},25	weight,26};27pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};28use pallet_evm_coder_substrate::dispatch_to_evm;29use sp_std::vec::Vec;30use up_data_structs::{31	AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,32	SponsoringRateLimit, SponsorshipState,33};34use alloc::format;3536use crate::{37	Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,38	eth::convert_cross_account_to_uint256, weights::WeightInfo,39};4041/// Events for ethereum collection helper.42#[derive(ToLog)]43pub enum CollectionHelpersEvents {44	/// The collection has been created.45	CollectionCreated {46		/// Collection owner.47		#[indexed]48		owner: address,4950		/// Collection ID.51		#[indexed]52		collection_id: address,53	},54	/// The collection has been destroyed.55	CollectionDestroyed {56		/// Collection ID.57		#[indexed]58		collection_id: address,59	},60}6162/// Does not always represent a full collection, for RFT it is either63/// collection (Implementing ERC721), or specific collection token (Implementing ERC20).64pub trait CommonEvmHandler {65	/// Raw compiled binary code of the contract stub66	const CODE: &'static [u8];6768	/// Call precompiled handle.69	fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult>;70}7172/// @title A contract that allows you to work with collections.73#[solidity_interface(name = Collection)]74impl<T: Config> CollectionHandle<T>75where76	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,77{78	/// Set collection property.79	///80	/// @param key Property key.81	/// @param value Propery value.82	#[solidity(hide)]83	#[weight(<SelfWeightOf<T>>::set_collection_properties(1))]84	fn set_collection_property(85		&mut self,86		caller: caller,87		key: string,88		value: bytes,89	) -> Result<void> {90		let caller = T::CrossAccountId::from_eth(caller);91		let key = <Vec<u8>>::from(key)92			.try_into()93			.map_err(|_| "key too large")?;94		let value = value.0.try_into().map_err(|_| "value too large")?;9596		<Pallet<T>>::set_collection_property(self, &caller, Property { key, value })97			.map_err(dispatch_to_evm::<T>)98	}99100	/// Set collection properties.101	///102	/// @param properties Vector of properties key/value pair.103	#[weight(<SelfWeightOf<T>>::set_collection_properties(properties.len() as u32))]104	fn set_collection_properties(105		&mut self,106		caller: caller,107		properties: Vec<PropertyStruct>,108	) -> Result<void> {109		let caller = T::CrossAccountId::from_eth(caller);110111		let properties = properties112			.into_iter()113			.map(|PropertyStruct { key, value }| {114				let key = <Vec<u8>>::from(key)115					.try_into()116					.map_err(|_| "key too large")?;117118				let value = value.0.try_into().map_err(|_| "value too large")?;119120				Ok(Property { key, value })121			})122			.collect::<Result<Vec<_>>>()?;123124		<Pallet<T>>::set_collection_properties(self, &caller, properties)125			.map_err(dispatch_to_evm::<T>)126	}127128	/// Delete collection property.129	///130	/// @param key Property key.131	#[solidity(hide)]132	#[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]133	fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {134		let caller = T::CrossAccountId::from_eth(caller);135		let key = <Vec<u8>>::from(key)136			.try_into()137			.map_err(|_| "key too large")?;138139		<Pallet<T>>::delete_collection_property(self, &caller, key).map_err(dispatch_to_evm::<T>)140	}141142	/// Delete collection properties.143	///144	/// @param keys Properties keys.145	#[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]146	fn delete_collection_properties(&mut self, caller: caller, keys: Vec<string>) -> Result<()> {147		let caller = T::CrossAccountId::from_eth(caller);148		let keys = keys149			.into_iter()150			.map(|key| {151				<Vec<u8>>::from(key)152					.try_into()153					.map_err(|_| Error::Revert("key too large".into()))154			})155			.collect::<Result<Vec<_>>>()?;156157		<Pallet<T>>::delete_collection_properties(self, &caller, keys).map_err(dispatch_to_evm::<T>)158	}159160	/// Get collection property.161	///162	/// @dev Throws error if key not found.163	///164	/// @param key Property key.165	/// @return bytes The property corresponding to the key.166	fn collection_property(&self, key: string) -> Result<bytes> {167		let key = <Vec<u8>>::from(key)168			.try_into()169			.map_err(|_| "key too large")?;170171		let props = CollectionProperties::<T>::get(self.id);172		let prop = props.get(&key).ok_or("key not found")?;173174		Ok(bytes(prop.to_vec()))175	}176177	/// Get collection properties.178	///179	/// @param keys Properties keys. Empty keys for all propertyes.180	/// @return Vector of properties key/value pairs.181	fn collection_properties(&self, keys: Vec<string>) -> Result<Vec<(string, bytes)>> {182		let keys = keys183			.into_iter()184			.map(|key| {185				<Vec<u8>>::from(key)186					.try_into()187					.map_err(|_| Error::Revert("key too large".into()))188			})189			.collect::<Result<Vec<_>>>()?;190191		let properties = Pallet::<T>::filter_collection_properties(192			self.id,193			if keys.is_empty() { None } else { Some(keys) },194		)195		.map_err(dispatch_to_evm::<T>)?;196197		let properties = properties198			.into_iter()199			.map(|p| {200				let key =201					string::from_utf8(p.key.into()).map_err(|e| Error::Revert(format!("{}", e)))?;202				let value = bytes(p.value.to_vec());203				Ok((key, value))204			})205			.collect::<Result<Vec<_>>>()?;206		Ok(properties)207	}208209	/// Set the sponsor of the collection.210	///211	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.212	///213	/// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.214	#[solidity(hide)]215	fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {216		self.consume_store_reads_and_writes(1, 1)?;217218		check_is_owner_or_admin(caller, self)?;219220		let sponsor = T::CrossAccountId::from_eth(sponsor);221		self.set_sponsor(sponsor.as_sub().clone())222			.map_err(dispatch_to_evm::<T>)?;223		save(self)224	}225226	/// Set the sponsor of the collection.227	///228	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.229	///230	/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.231	fn set_collection_sponsor_cross(232		&mut self,233		caller: caller,234		sponsor: EthCrossAccount,235	) -> Result<void> {236		self.consume_store_reads_and_writes(1, 1)?;237238		check_is_owner_or_admin(caller, self)?;239240		let sponsor = sponsor.into_sub_cross_account::<T>()?;241		self.set_sponsor(sponsor.as_sub().clone())242			.map_err(dispatch_to_evm::<T>)?;243		save(self)244	}245246	/// Whether there is a pending sponsor.247	fn has_collection_pending_sponsor(&self) -> Result<bool> {248		Ok(matches!(249			self.collection.sponsorship,250			SponsorshipState::Unconfirmed(_)251		))252	}253254	/// Collection sponsorship confirmation.255	///256	/// @dev After setting the sponsor for the collection, it must be confirmed with this function.257	fn confirm_collection_sponsorship(&mut self, caller: caller) -> Result<void> {258		self.consume_store_writes(1)?;259260		let caller = T::CrossAccountId::from_eth(caller);261		if !self262			.confirm_sponsorship(caller.as_sub())263			.map_err(dispatch_to_evm::<T>)?264		{265			return Err("caller is not set as sponsor".into());266		}267		save(self)268	}269270	/// Remove collection sponsor.271	fn remove_collection_sponsor(&mut self, caller: caller) -> Result<void> {272		self.consume_store_reads_and_writes(1, 1)?;273		check_is_owner_or_admin(caller, self)?;274		self.remove_sponsor().map_err(dispatch_to_evm::<T>)?;275		save(self)276	}277278	/// Get current sponsor.279	///280	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.281	fn collection_sponsor(&self) -> Result<(address, uint256)> {282		let sponsor = match self.collection.sponsorship.sponsor() {283			Some(sponsor) => sponsor,284			None => return Ok(Default::default()),285		};286		let sponsor = T::CrossAccountId::from_sub(sponsor.clone());287		let result: (address, uint256) = if sponsor.is_canonical_substrate() {288			let sponsor = convert_cross_account_to_uint256::<T>(&sponsor);289			(Default::default(), sponsor)290		} else {291			let sponsor = *sponsor.as_eth();292			(sponsor, Default::default())293		};294		Ok(result)295	}296297	/// Set limits for the collection.298	/// @dev Throws error if limit not found.299	/// @param limit Name of the limit. Valid names:300	/// 	"accountTokenOwnershipLimit",301	/// 	"sponsoredDataSize",302	/// 	"sponsoredDataRateLimit",303	/// 	"tokenLimit",304	/// 	"sponsorTransferTimeout",305	/// 	"sponsorApproveTimeout"306	///  	"ownerCanTransfer",307	/// 	"ownerCanDestroy",308	/// 	"transfersEnabled"309	/// @param value Value of the limit.310	#[solidity(rename_selector = "setCollectionLimit")]311	fn set_int_limit(&mut self, caller: caller, limit: string, value: uint256) -> Result<void> {312		self.consume_store_reads_and_writes(1, 1)?;313314		let value = value315			.try_into()316			.map_err(|_| Error::Revert(format!("can't convert value to u32 \"{}\"", value)))?;317318		let convert_value_to_bool = || match value {319			0 => Ok(false),320			1 => Ok(true),321			_ => {322				return Err(Error::Revert(format!(323					"can't convert value to boolean \"{}\"",324					value325				)))326			}327		};328329		check_is_owner_or_admin(caller, self)?;330		let mut limits = self.limits.clone();331332		match limit.as_str() {333			"accountTokenOwnershipLimit" => {334				limits.account_token_ownership_limit = Some(value);335			}336			"sponsoredDataSize" => {337				limits.sponsored_data_size = Some(value);338			}339			"sponsoredDataRateLimit" => {340				limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(value));341			}342			"tokenLimit" => {343				limits.token_limit = Some(value);344			}345			"sponsorTransferTimeout" => {346				limits.sponsor_transfer_timeout = Some(value);347			}348			"sponsorApproveTimeout" => {349				limits.sponsor_approve_timeout = Some(value);350			}351			"ownerCanTransfer" => {352				limits.owner_can_transfer = Some(convert_value_to_bool()?);353			}354			"ownerCanDestroy" => {355				limits.owner_can_destroy = Some(convert_value_to_bool()?);356			}357			"transfersEnabled" => {358				limits.transfers_enabled = Some(convert_value_to_bool()?);359			}360			_ => return Err(Error::Revert(format!("unknown limit \"{}\"", limit))),361		}362		self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)363			.map_err(dispatch_to_evm::<T>)?;364		save(self)365	}366367	/// Get contract address.368	fn contract_address(&self) -> Result<address> {369		Ok(crate::eth::collection_id_to_address(self.id))370	}371372	/// Add collection admin.373	/// @param newAdmin Cross account administrator address.374	fn add_collection_admin_cross(375		&mut self,376		caller: caller,377		new_admin: EthCrossAccount,378	) -> Result<void> {379		self.consume_store_writes(2)?;380381		let caller = T::CrossAccountId::from_eth(caller);382		let new_admin = new_admin.into_sub_cross_account::<T>()?;383		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;384		Ok(())385	}386387	/// Remove collection admin.388	/// @param admin Cross account administrator address.389	fn remove_collection_admin_cross(390		&mut self,391		caller: caller,392		admin: EthCrossAccount,393	) -> Result<void> {394		self.consume_store_writes(2)?;395396		let caller = T::CrossAccountId::from_eth(caller);397		let admin = admin.into_sub_cross_account::<T>()?;398		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;399		Ok(())400	}401402	/// Add collection admin.403	/// @param newAdmin Address of the added administrator.404	#[solidity(hide)]405	fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<void> {406		self.consume_store_writes(2)?;407408		let caller = T::CrossAccountId::from_eth(caller);409		let new_admin = T::CrossAccountId::from_eth(new_admin);410		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;411		Ok(())412	}413414	/// Remove collection admin.415	///416	/// @param admin Address of the removed administrator.417	#[solidity(hide)]418	fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<void> {419		self.consume_store_writes(2)?;420421		let caller = T::CrossAccountId::from_eth(caller);422		let admin = T::CrossAccountId::from_eth(admin);423		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;424		Ok(())425	}426427	/// Toggle accessibility of collection nesting.428	///429	/// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'430	#[solidity(rename_selector = "setCollectionNesting")]431	fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {432		self.consume_store_reads_and_writes(1, 1)?;433434		check_is_owner_or_admin(caller, self)?;435436		let mut permissions = self.collection.permissions.clone();437		let mut nesting = permissions.nesting().clone();438		nesting.token_owner = enable;439		nesting.restricted = None;440		permissions.nesting = Some(nesting);441442		self.collection.permissions = <Pallet<T>>::clamp_permissions(443			self.collection.mode.clone(),444			&self.collection.permissions,445			permissions,446		)447		.map_err(dispatch_to_evm::<T>)?;448449		save(self)450	}451452	/// Toggle accessibility of collection nesting.453	///454	/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'455	/// @param collections Addresses of collections that will be available for nesting.456	#[solidity(rename_selector = "setCollectionNesting")]457	fn set_nesting(458		&mut self,459		caller: caller,460		enable: bool,461		collections: Vec<address>,462	) -> Result<void> {463		self.consume_store_reads_and_writes(1, 1)?;464465		if collections.is_empty() {466			return Err("no addresses provided".into());467		}468		check_is_owner_or_admin(caller, self)?;469470		let mut permissions = self.collection.permissions.clone();471		match enable {472			false => {473				let mut nesting = permissions.nesting().clone();474				nesting.token_owner = false;475				nesting.restricted = None;476				permissions.nesting = Some(nesting);477			}478			true => {479				let mut bv = OwnerRestrictedSet::new();480				for i in collections {481					bv.try_insert(crate::eth::map_eth_to_id(&i).ok_or_else(|| {482						Error::Revert("Can't convert address into collection id".into())483					})?)484					.map_err(|_| "too many collections")?;485				}486				let mut nesting = permissions.nesting().clone();487				nesting.token_owner = true;488				nesting.restricted = Some(bv);489				permissions.nesting = Some(nesting);490			}491		};492493		self.collection.permissions = <Pallet<T>>::clamp_permissions(494			self.collection.mode.clone(),495			&self.collection.permissions,496			permissions,497		)498		.map_err(dispatch_to_evm::<T>)?;499500		save(self)501	}502503	/// Set the collection access method.504	/// @param mode Access mode505	/// 	0 for Normal506	/// 	1 for AllowList507	fn set_collection_access(&mut self, caller: caller, mode: uint8) -> Result<void> {508		self.consume_store_reads_and_writes(1, 1)?;509510		check_is_owner_or_admin(caller, self)?;511		let permissions = CollectionPermissions {512			access: Some(match mode {513				0 => AccessMode::Normal,514				1 => AccessMode::AllowList,515				_ => return Err("not supported access mode".into()),516			}),517			..Default::default()518		};519		self.collection.permissions = <Pallet<T>>::clamp_permissions(520			self.collection.mode.clone(),521			&self.collection.permissions,522			permissions,523		)524		.map_err(dispatch_to_evm::<T>)?;525526		save(self)527	}528529	/// Checks that user allowed to operate with collection.530	///531	/// @param user User address to check.532	fn allowed(&self, user: address) -> Result<bool> {533		Ok(Pallet::<T>::allowed(534			self.id,535			T::CrossAccountId::from_eth(user),536		))537	}538539	/// Add the user to the allowed list.540	///541	/// @param user Address of a trusted user.542	#[solidity(hide)]543	fn add_to_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {544		self.consume_store_writes(1)?;545546		let caller = T::CrossAccountId::from_eth(caller);547		let user = T::CrossAccountId::from_eth(user);548		<Pallet<T>>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;549		Ok(())550	}551552	/// Add user to allowed list.553	///554	/// @param user User cross account address.555	fn add_to_collection_allow_list_cross(556		&mut self,557		caller: caller,558		user: EthCrossAccount,559	) -> Result<void> {560		self.consume_store_writes(1)?;561562		let caller = T::CrossAccountId::from_eth(caller);563		let user = user.into_sub_cross_account::<T>()?;564		Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;565		Ok(())566	}567568	/// Remove the user from the allowed list.569	///570	/// @param user Address of a removed user.571	#[solidity(hide)]572	fn remove_from_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {573		self.consume_store_writes(1)?;574575		let caller = T::CrossAccountId::from_eth(caller);576		let user = T::CrossAccountId::from_eth(user);577		<Pallet<T>>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;578		Ok(())579	}580581	/// Remove user from allowed list.582	///583	/// @param user User cross account address.584	fn remove_from_collection_allow_list_cross(585		&mut self,586		caller: caller,587		user: EthCrossAccount,588	) -> Result<void> {589		self.consume_store_writes(1)?;590591		let caller = T::CrossAccountId::from_eth(caller);592		let user = user.into_sub_cross_account::<T>()?;593		Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;594		Ok(())595	}596597	/// Switch permission for minting.598	///599	/// @param mode Enable if "true".600	fn set_collection_mint_mode(&mut self, caller: caller, mode: bool) -> Result<void> {601		self.consume_store_reads_and_writes(1, 1)?;602603		check_is_owner_or_admin(caller, self)?;604		let permissions = CollectionPermissions {605			mint_mode: Some(mode),606			..Default::default()607		};608		self.collection.permissions = <Pallet<T>>::clamp_permissions(609			self.collection.mode.clone(),610			&self.collection.permissions,611			permissions,612		)613		.map_err(dispatch_to_evm::<T>)?;614615		save(self)616	}617618	/// Check that account is the owner or admin of the collection619	///620	/// @param user account to verify621	/// @return "true" if account is the owner or admin622	#[solidity(hide, rename_selector = "isOwnerOrAdmin")]623	fn is_owner_or_admin_eth(&self, user: address) -> Result<bool> {624		let user = T::CrossAccountId::from_eth(user);625		Ok(self.is_owner_or_admin(&user))626	}627628	/// Check that account is the owner or admin of the collection629	///630	/// @param user User cross account to verify631	/// @return "true" if account is the owner or admin632	fn is_owner_or_admin_cross(&self, user: EthCrossAccount) -> Result<bool> {633		let user = user.into_sub_cross_account::<T>()?;634		Ok(self.is_owner_or_admin(&user))635	}636637	/// Returns collection type638	///639	/// @return `Fungible` or `NFT` or `ReFungible`640	fn unique_collection_type(&self) -> Result<string> {641		let mode = match self.collection.mode {642			CollectionMode::Fungible(_) => "Fungible",643			CollectionMode::NFT => "NFT",644			CollectionMode::ReFungible => "ReFungible",645		};646		Ok(mode.into())647	}648649	/// Get collection owner.650	///651	/// @return Tuble with sponsor address and his substrate mirror.652	/// If address is canonical then substrate mirror is zero and vice versa.653	fn collection_owner(&self) -> Result<EthCrossAccount> {654		Ok(EthCrossAccount::from_sub_cross_account::<T>(655			&T::CrossAccountId::from_sub(self.owner.clone()),656		))657	}658659	/// Changes collection owner to another account660	///661	/// @dev Owner can be changed only by current owner662	/// @param newOwner new owner account663	#[solidity(hide, rename_selector = "changeCollectionOwner")]664	fn set_owner(&mut self, caller: caller, new_owner: address) -> Result<void> {665		self.consume_store_writes(1)?;666667		let caller = T::CrossAccountId::from_eth(caller);668		let new_owner = T::CrossAccountId::from_eth(new_owner);669		self.set_owner_internal(caller, new_owner)670			.map_err(dispatch_to_evm::<T>)671	}672673	/// Get collection administrators674	///675	/// @return Vector of tuples with admins address and his substrate mirror.676	/// If address is canonical then substrate mirror is zero and vice versa.677	fn collection_admins(&self) -> Result<Vec<EthCrossAccount>> {678		let result = crate::IsAdmin::<T>::iter_prefix((self.id,))679			.map(|(admin, _)| EthCrossAccount::from_sub_cross_account::<T>(&admin))680			.collect();681		Ok(result)682	}683684	/// Changes collection owner to another account685	///686	/// @dev Owner can be changed only by current owner687	/// @param newOwner new owner cross account688	fn change_collection_owner_cross(689		&mut self,690		caller: caller,691		new_owner: EthCrossAccount,692	) -> Result<void> {693		self.consume_store_writes(1)?;694695		let caller = T::CrossAccountId::from_eth(caller);696		let new_owner = new_owner.into_sub_cross_account::<T>()?;697		self.set_owner_internal(caller, new_owner)698			.map_err(dispatch_to_evm::<T>)699	}700}701702/// ### Note703/// Do not forget to add: `self.consume_store_reads(1)?;`704fn check_is_owner_or_admin<T: Config>(705	caller: caller,706	collection: &CollectionHandle<T>,707) -> Result<T::CrossAccountId> {708	let caller = T::CrossAccountId::from_eth(caller);709	collection710		.check_is_owner_or_admin(&caller)711		.map_err(dispatch_to_evm::<T>)?;712	Ok(caller)713}714715/// ### Note716/// Do not forget to add: `self.consume_store_writes(1)?;`717fn save<T: Config>(collection: &CollectionHandle<T>) -> Result<void> {718	collection719		.check_is_internal()720		.map_err(dispatch_to_evm::<T>)?;721	collection.save().map_err(dispatch_to_evm::<T>)?;722	Ok(())723}724725/// Contains static property keys and values.726pub mod static_property {727	use evm_coder::{728		execution::{Result, Error},729	};730	use alloc::format;731732	const EXPECT_CONVERT_ERROR: &str = "length < limit";733734	/// Keys.735	pub mod key {736		use super::*;737738		/// Key "baseURI".739		pub fn base_uri() -> up_data_structs::PropertyKey {740			property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)741		}742743		/// Key "url".744		pub fn url() -> up_data_structs::PropertyKey {745			property_key_from_bytes(b"URI").expect(EXPECT_CONVERT_ERROR)746		}747748		/// Key "suffix".749		pub fn suffix() -> up_data_structs::PropertyKey {750			property_key_from_bytes(b"URISuffix").expect(EXPECT_CONVERT_ERROR)751		}752753		/// Key "parentNft".754		pub fn parent_nft() -> up_data_structs::PropertyKey {755			property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)756		}757	}758759	/// Convert `byte` to [`PropertyKey`].760	pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {761		bytes.to_vec().try_into().map_err(|_| {762			Error::Revert(format!(763				"Property key is too long. Max length is {}.",764				up_data_structs::PropertyKey::bound()765			))766		})767	}768769	/// Convert `bytes` to [`PropertyValue`].770	pub fn property_value_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyValue> {771		bytes.to_vec().try_into().map_err(|_| {772			Error::Revert(format!(773				"Property key is too long. Max length is {}.",774				up_data_structs::PropertyKey::bound()775			))776		})777	}778}
after · pallets/common/src/erc.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//! This module contains the implementation of pallet methods for evm.1819use evm_coder::{20	abi::AbiType,21	solidity_interface, solidity, ToLog,22	types::*,23	types::Property as PropertyStruct,24	execution::{Result, Error},25	weight,26};27pub use pallet_evm::{PrecompileOutput, PrecompileResult, PrecompileHandle, account::CrossAccountId};28use pallet_evm_coder_substrate::dispatch_to_evm;29use sp_std::vec::Vec;30use up_data_structs::{31	AccessMode, CollectionMode, CollectionPermissions, OwnerRestrictedSet, Property,32	SponsoringRateLimit, SponsorshipState,33};34use alloc::format;3536use crate::{37	Pallet, CollectionHandle, Config, CollectionProperties, SelfWeightOf,38	eth::convert_cross_account_to_uint256, weights::WeightInfo,39};4041/// Events for ethereum collection helper.42#[derive(ToLog)]43pub enum CollectionHelpersEvents {44	/// The collection has been created.45	CollectionCreated {46		/// Collection owner.47		#[indexed]48		owner: address,4950		/// Collection ID.51		#[indexed]52		collection_id: address,53	},54	/// The collection has been destroyed.55	CollectionDestroyed {56		/// Collection ID.57		#[indexed]58		collection_id: address,59	},60}6162/// Does not always represent a full collection, for RFT it is either63/// collection (Implementing ERC721), or specific collection token (Implementing ERC20).64pub trait CommonEvmHandler {65	/// Raw compiled binary code of the contract stub66	const CODE: &'static [u8];6768	/// Call precompiled handle.69	fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult>;70}7172/// @title A contract that allows you to work with collections.73#[solidity_interface(name = Collection)]74impl<T: Config> CollectionHandle<T>75where76	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,77{78	/// Set collection property.79	///80	/// @param key Property key.81	/// @param value Propery value.82	#[solidity(hide)]83	#[weight(<SelfWeightOf<T>>::set_collection_properties(1))]84	fn set_collection_property(85		&mut self,86		caller: caller,87		key: string,88		value: bytes,89	) -> Result<void> {90		let caller = T::CrossAccountId::from_eth(caller);91		let key = <Vec<u8>>::from(key)92			.try_into()93			.map_err(|_| "key too large")?;94		let value = value.0.try_into().map_err(|_| "value too large")?;9596		<Pallet<T>>::set_collection_property(self, &caller, Property { key, value })97			.map_err(dispatch_to_evm::<T>)98	}99100	/// Set collection properties.101	///102	/// @param properties Vector of properties key/value pair.103	#[weight(<SelfWeightOf<T>>::set_collection_properties(properties.len() as u32))]104	fn set_collection_properties(105		&mut self,106		caller: caller,107		properties: Vec<PropertyStruct>,108	) -> Result<void> {109		let caller = T::CrossAccountId::from_eth(caller);110111		let properties = properties112			.into_iter()113			.map(|PropertyStruct { key, value }| {114				let key = <Vec<u8>>::from(key)115					.try_into()116					.map_err(|_| "key too large")?;117118				let value = value.0.try_into().map_err(|_| "value too large")?;119120				Ok(Property { key, value })121			})122			.collect::<Result<Vec<_>>>()?;123124		<Pallet<T>>::set_collection_properties(self, &caller, properties)125			.map_err(dispatch_to_evm::<T>)126	}127128	/// Delete collection property.129	///130	/// @param key Property key.131	#[solidity(hide)]132	#[weight(<SelfWeightOf<T>>::delete_collection_properties(1))]133	fn delete_collection_property(&mut self, caller: caller, key: string) -> Result<()> {134		let caller = T::CrossAccountId::from_eth(caller);135		let key = <Vec<u8>>::from(key)136			.try_into()137			.map_err(|_| "key too large")?;138139		<Pallet<T>>::delete_collection_property(self, &caller, key).map_err(dispatch_to_evm::<T>)140	}141142	/// Delete collection properties.143	///144	/// @param keys Properties keys.145	#[weight(<SelfWeightOf<T>>::delete_collection_properties(keys.len() as u32))]146	fn delete_collection_properties(&mut self, caller: caller, keys: Vec<string>) -> Result<()> {147		let caller = T::CrossAccountId::from_eth(caller);148		let keys = keys149			.into_iter()150			.map(|key| {151				<Vec<u8>>::from(key)152					.try_into()153					.map_err(|_| Error::Revert("key too large".into()))154			})155			.collect::<Result<Vec<_>>>()?;156157		<Pallet<T>>::delete_collection_properties(self, &caller, keys).map_err(dispatch_to_evm::<T>)158	}159160	/// Get collection property.161	///162	/// @dev Throws error if key not found.163	///164	/// @param key Property key.165	/// @return bytes The property corresponding to the key.166	fn collection_property(&self, key: string) -> Result<bytes> {167		let key = <Vec<u8>>::from(key)168			.try_into()169			.map_err(|_| "key too large")?;170171		let props = CollectionProperties::<T>::get(self.id);172		let prop = props.get(&key).ok_or("key not found")?;173174		Ok(bytes(prop.to_vec()))175	}176177	/// Get collection properties.178	///179	/// @param keys Properties keys. Empty keys for all propertyes.180	/// @return Vector of properties key/value pairs.181	fn collection_properties(&self, keys: Vec<string>) -> Result<Vec<PropertyStruct>> {182		let keys = keys183			.into_iter()184			.map(|key| {185				<Vec<u8>>::from(key)186					.try_into()187					.map_err(|_| Error::Revert("key too large".into()))188			})189			.collect::<Result<Vec<_>>>()?;190191		let properties = Pallet::<T>::filter_collection_properties(192			self.id,193			if keys.is_empty() { None } else { Some(keys) },194		)195		.map_err(dispatch_to_evm::<T>)?;196197		let properties = properties198			.into_iter()199			.map(|p| {200				let key =201					string::from_utf8(p.key.into()).map_err(|e| Error::Revert(format!("{}", e)))?;202				let value = bytes(p.value.to_vec());203				Ok(PropertyStruct { key, value })204			})205			.collect::<Result<Vec<_>>>()?;206		Ok(properties)207	}208209	/// Set the sponsor of the collection.210	///211	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.212	///213	/// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.214	#[solidity(hide)]215	fn set_collection_sponsor(&mut self, caller: caller, sponsor: address) -> Result<void> {216		self.consume_store_reads_and_writes(1, 1)?;217218		check_is_owner_or_admin(caller, self)?;219220		let sponsor = T::CrossAccountId::from_eth(sponsor);221		self.set_sponsor(sponsor.as_sub().clone())222			.map_err(dispatch_to_evm::<T>)?;223		save(self)224	}225226	/// Set the sponsor of the collection.227	///228	/// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.229	///230	/// @param sponsor Cross account address of the sponsor from whose account funds will be debited for operations with the contract.231	fn set_collection_sponsor_cross(232		&mut self,233		caller: caller,234		sponsor: EthCrossAccount,235	) -> Result<void> {236		self.consume_store_reads_and_writes(1, 1)?;237238		check_is_owner_or_admin(caller, self)?;239240		let sponsor = sponsor.into_sub_cross_account::<T>()?;241		self.set_sponsor(sponsor.as_sub().clone())242			.map_err(dispatch_to_evm::<T>)?;243		save(self)244	}245246	/// Whether there is a pending sponsor.247	fn has_collection_pending_sponsor(&self) -> Result<bool> {248		Ok(matches!(249			self.collection.sponsorship,250			SponsorshipState::Unconfirmed(_)251		))252	}253254	/// Collection sponsorship confirmation.255	///256	/// @dev After setting the sponsor for the collection, it must be confirmed with this function.257	fn confirm_collection_sponsorship(&mut self, caller: caller) -> Result<void> {258		self.consume_store_writes(1)?;259260		let caller = T::CrossAccountId::from_eth(caller);261		if !self262			.confirm_sponsorship(caller.as_sub())263			.map_err(dispatch_to_evm::<T>)?264		{265			return Err("caller is not set as sponsor".into());266		}267		save(self)268	}269270	/// Remove collection sponsor.271	fn remove_collection_sponsor(&mut self, caller: caller) -> Result<void> {272		self.consume_store_reads_and_writes(1, 1)?;273		check_is_owner_or_admin(caller, self)?;274		self.remove_sponsor().map_err(dispatch_to_evm::<T>)?;275		save(self)276	}277278	/// Get current sponsor.279	///280	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.281	fn collection_sponsor(&self) -> Result<(address, uint256)> {282		let sponsor = match self.collection.sponsorship.sponsor() {283			Some(sponsor) => sponsor,284			None => return Ok(Default::default()),285		};286		let sponsor = T::CrossAccountId::from_sub(sponsor.clone());287		let result: (address, uint256) = if sponsor.is_canonical_substrate() {288			let sponsor = convert_cross_account_to_uint256::<T>(&sponsor);289			(Default::default(), sponsor)290		} else {291			let sponsor = *sponsor.as_eth();292			(sponsor, Default::default())293		};294		Ok(result)295	}296297	/// Set limits for the collection.298	/// @dev Throws error if limit not found.299	/// @param limit Name of the limit. Valid names:300	/// 	"accountTokenOwnershipLimit",301	/// 	"sponsoredDataSize",302	/// 	"sponsoredDataRateLimit",303	/// 	"tokenLimit",304	/// 	"sponsorTransferTimeout",305	/// 	"sponsorApproveTimeout"306	///  	"ownerCanTransfer",307	/// 	"ownerCanDestroy",308	/// 	"transfersEnabled"309	/// @param value Value of the limit.310	#[solidity(rename_selector = "setCollectionLimit")]311	fn set_int_limit(&mut self, caller: caller, limit: string, value: uint256) -> Result<void> {312		self.consume_store_reads_and_writes(1, 1)?;313314		let value = value315			.try_into()316			.map_err(|_| Error::Revert(format!("can't convert value to u32 \"{}\"", value)))?;317318		let convert_value_to_bool = || match value {319			0 => Ok(false),320			1 => Ok(true),321			_ => {322				return Err(Error::Revert(format!(323					"can't convert value to boolean \"{}\"",324					value325				)))326			}327		};328329		check_is_owner_or_admin(caller, self)?;330		let mut limits = self.limits.clone();331332		match limit.as_str() {333			"accountTokenOwnershipLimit" => {334				limits.account_token_ownership_limit = Some(value);335			}336			"sponsoredDataSize" => {337				limits.sponsored_data_size = Some(value);338			}339			"sponsoredDataRateLimit" => {340				limits.sponsored_data_rate_limit = Some(SponsoringRateLimit::Blocks(value));341			}342			"tokenLimit" => {343				limits.token_limit = Some(value);344			}345			"sponsorTransferTimeout" => {346				limits.sponsor_transfer_timeout = Some(value);347			}348			"sponsorApproveTimeout" => {349				limits.sponsor_approve_timeout = Some(value);350			}351			"ownerCanTransfer" => {352				limits.owner_can_transfer = Some(convert_value_to_bool()?);353			}354			"ownerCanDestroy" => {355				limits.owner_can_destroy = Some(convert_value_to_bool()?);356			}357			"transfersEnabled" => {358				limits.transfers_enabled = Some(convert_value_to_bool()?);359			}360			_ => return Err(Error::Revert(format!("unknown limit \"{}\"", limit))),361		}362		self.limits = <Pallet<T>>::clamp_limits(self.mode.clone(), &self.limits, limits)363			.map_err(dispatch_to_evm::<T>)?;364		save(self)365	}366367	/// Get contract address.368	fn contract_address(&self) -> Result<address> {369		Ok(crate::eth::collection_id_to_address(self.id))370	}371372	/// Add collection admin.373	/// @param newAdmin Cross account administrator address.374	fn add_collection_admin_cross(375		&mut self,376		caller: caller,377		new_admin: EthCrossAccount,378	) -> Result<void> {379		self.consume_store_writes(2)?;380381		let caller = T::CrossAccountId::from_eth(caller);382		let new_admin = new_admin.into_sub_cross_account::<T>()?;383		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;384		Ok(())385	}386387	/// Remove collection admin.388	/// @param admin Cross account administrator address.389	fn remove_collection_admin_cross(390		&mut self,391		caller: caller,392		admin: EthCrossAccount,393	) -> Result<void> {394		self.consume_store_writes(2)?;395396		let caller = T::CrossAccountId::from_eth(caller);397		let admin = admin.into_sub_cross_account::<T>()?;398		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;399		Ok(())400	}401402	/// Add collection admin.403	/// @param newAdmin Address of the added administrator.404	#[solidity(hide)]405	fn add_collection_admin(&mut self, caller: caller, new_admin: address) -> Result<void> {406		self.consume_store_writes(2)?;407408		let caller = T::CrossAccountId::from_eth(caller);409		let new_admin = T::CrossAccountId::from_eth(new_admin);410		<Pallet<T>>::toggle_admin(self, &caller, &new_admin, true).map_err(dispatch_to_evm::<T>)?;411		Ok(())412	}413414	/// Remove collection admin.415	///416	/// @param admin Address of the removed administrator.417	#[solidity(hide)]418	fn remove_collection_admin(&mut self, caller: caller, admin: address) -> Result<void> {419		self.consume_store_writes(2)?;420421		let caller = T::CrossAccountId::from_eth(caller);422		let admin = T::CrossAccountId::from_eth(admin);423		<Pallet<T>>::toggle_admin(self, &caller, &admin, false).map_err(dispatch_to_evm::<T>)?;424		Ok(())425	}426427	/// Toggle accessibility of collection nesting.428	///429	/// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'430	#[solidity(rename_selector = "setCollectionNesting")]431	fn set_nesting_bool(&mut self, caller: caller, enable: bool) -> Result<void> {432		self.consume_store_reads_and_writes(1, 1)?;433434		check_is_owner_or_admin(caller, self)?;435436		let mut permissions = self.collection.permissions.clone();437		let mut nesting = permissions.nesting().clone();438		nesting.token_owner = enable;439		nesting.restricted = None;440		permissions.nesting = Some(nesting);441442		self.collection.permissions = <Pallet<T>>::clamp_permissions(443			self.collection.mode.clone(),444			&self.collection.permissions,445			permissions,446		)447		.map_err(dispatch_to_evm::<T>)?;448449		save(self)450	}451452	/// Toggle accessibility of collection nesting.453	///454	/// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'455	/// @param collections Addresses of collections that will be available for nesting.456	#[solidity(rename_selector = "setCollectionNesting")]457	fn set_nesting(458		&mut self,459		caller: caller,460		enable: bool,461		collections: Vec<address>,462	) -> Result<void> {463		self.consume_store_reads_and_writes(1, 1)?;464465		if collections.is_empty() {466			return Err("no addresses provided".into());467		}468		check_is_owner_or_admin(caller, self)?;469470		let mut permissions = self.collection.permissions.clone();471		match enable {472			false => {473				let mut nesting = permissions.nesting().clone();474				nesting.token_owner = false;475				nesting.restricted = None;476				permissions.nesting = Some(nesting);477			}478			true => {479				let mut bv = OwnerRestrictedSet::new();480				for i in collections {481					bv.try_insert(crate::eth::map_eth_to_id(&i).ok_or_else(|| {482						Error::Revert("Can't convert address into collection id".into())483					})?)484					.map_err(|_| "too many collections")?;485				}486				let mut nesting = permissions.nesting().clone();487				nesting.token_owner = true;488				nesting.restricted = Some(bv);489				permissions.nesting = Some(nesting);490			}491		};492493		self.collection.permissions = <Pallet<T>>::clamp_permissions(494			self.collection.mode.clone(),495			&self.collection.permissions,496			permissions,497		)498		.map_err(dispatch_to_evm::<T>)?;499500		save(self)501	}502503	/// Set the collection access method.504	/// @param mode Access mode505	/// 	0 for Normal506	/// 	1 for AllowList507	fn set_collection_access(&mut self, caller: caller, mode: uint8) -> Result<void> {508		self.consume_store_reads_and_writes(1, 1)?;509510		check_is_owner_or_admin(caller, self)?;511		let permissions = CollectionPermissions {512			access: Some(match mode {513				0 => AccessMode::Normal,514				1 => AccessMode::AllowList,515				_ => return Err("not supported access mode".into()),516			}),517			..Default::default()518		};519		self.collection.permissions = <Pallet<T>>::clamp_permissions(520			self.collection.mode.clone(),521			&self.collection.permissions,522			permissions,523		)524		.map_err(dispatch_to_evm::<T>)?;525526		save(self)527	}528529	/// Checks that user allowed to operate with collection.530	///531	/// @param user User address to check.532	fn allowed(&self, user: address) -> Result<bool> {533		Ok(Pallet::<T>::allowed(534			self.id,535			T::CrossAccountId::from_eth(user),536		))537	}538539	/// Add the user to the allowed list.540	///541	/// @param user Address of a trusted user.542	#[solidity(hide)]543	fn add_to_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {544		self.consume_store_writes(1)?;545546		let caller = T::CrossAccountId::from_eth(caller);547		let user = T::CrossAccountId::from_eth(user);548		<Pallet<T>>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;549		Ok(())550	}551552	/// Add user to allowed list.553	///554	/// @param user User cross account address.555	fn add_to_collection_allow_list_cross(556		&mut self,557		caller: caller,558		user: EthCrossAccount,559	) -> Result<void> {560		self.consume_store_writes(1)?;561562		let caller = T::CrossAccountId::from_eth(caller);563		let user = user.into_sub_cross_account::<T>()?;564		Pallet::<T>::toggle_allowlist(self, &caller, &user, true).map_err(dispatch_to_evm::<T>)?;565		Ok(())566	}567568	/// Remove the user from the allowed list.569	///570	/// @param user Address of a removed user.571	#[solidity(hide)]572	fn remove_from_collection_allow_list(&mut self, caller: caller, user: address) -> Result<void> {573		self.consume_store_writes(1)?;574575		let caller = T::CrossAccountId::from_eth(caller);576		let user = T::CrossAccountId::from_eth(user);577		<Pallet<T>>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;578		Ok(())579	}580581	/// Remove user from allowed list.582	///583	/// @param user User cross account address.584	fn remove_from_collection_allow_list_cross(585		&mut self,586		caller: caller,587		user: EthCrossAccount,588	) -> Result<void> {589		self.consume_store_writes(1)?;590591		let caller = T::CrossAccountId::from_eth(caller);592		let user = user.into_sub_cross_account::<T>()?;593		Pallet::<T>::toggle_allowlist(self, &caller, &user, false).map_err(dispatch_to_evm::<T>)?;594		Ok(())595	}596597	/// Switch permission for minting.598	///599	/// @param mode Enable if "true".600	fn set_collection_mint_mode(&mut self, caller: caller, mode: bool) -> Result<void> {601		self.consume_store_reads_and_writes(1, 1)?;602603		check_is_owner_or_admin(caller, self)?;604		let permissions = CollectionPermissions {605			mint_mode: Some(mode),606			..Default::default()607		};608		self.collection.permissions = <Pallet<T>>::clamp_permissions(609			self.collection.mode.clone(),610			&self.collection.permissions,611			permissions,612		)613		.map_err(dispatch_to_evm::<T>)?;614615		save(self)616	}617618	/// Check that account is the owner or admin of the collection619	///620	/// @param user account to verify621	/// @return "true" if account is the owner or admin622	#[solidity(hide, rename_selector = "isOwnerOrAdmin")]623	fn is_owner_or_admin_eth(&self, user: address) -> Result<bool> {624		let user = T::CrossAccountId::from_eth(user);625		Ok(self.is_owner_or_admin(&user))626	}627628	/// Check that account is the owner or admin of the collection629	///630	/// @param user User cross account to verify631	/// @return "true" if account is the owner or admin632	fn is_owner_or_admin_cross(&self, user: EthCrossAccount) -> Result<bool> {633		let user = user.into_sub_cross_account::<T>()?;634		Ok(self.is_owner_or_admin(&user))635	}636637	/// Returns collection type638	///639	/// @return `Fungible` or `NFT` or `ReFungible`640	fn unique_collection_type(&self) -> Result<string> {641		let mode = match self.collection.mode {642			CollectionMode::Fungible(_) => "Fungible",643			CollectionMode::NFT => "NFT",644			CollectionMode::ReFungible => "ReFungible",645		};646		Ok(mode.into())647	}648649	/// Get collection owner.650	///651	/// @return Tuble with sponsor address and his substrate mirror.652	/// If address is canonical then substrate mirror is zero and vice versa.653	fn collection_owner(&self) -> Result<EthCrossAccount> {654		Ok(EthCrossAccount::from_sub_cross_account::<T>(655			&T::CrossAccountId::from_sub(self.owner.clone()),656		))657	}658659	/// Changes collection owner to another account660	///661	/// @dev Owner can be changed only by current owner662	/// @param newOwner new owner account663	#[solidity(hide, rename_selector = "changeCollectionOwner")]664	fn set_owner(&mut self, caller: caller, new_owner: address) -> Result<void> {665		self.consume_store_writes(1)?;666667		let caller = T::CrossAccountId::from_eth(caller);668		let new_owner = T::CrossAccountId::from_eth(new_owner);669		self.set_owner_internal(caller, new_owner)670			.map_err(dispatch_to_evm::<T>)671	}672673	/// Get collection administrators674	///675	/// @return Vector of tuples with admins address and his substrate mirror.676	/// If address is canonical then substrate mirror is zero and vice versa.677	fn collection_admins(&self) -> Result<Vec<EthCrossAccount>> {678		let result = crate::IsAdmin::<T>::iter_prefix((self.id,))679			.map(|(admin, _)| EthCrossAccount::from_sub_cross_account::<T>(&admin))680			.collect();681		Ok(result)682	}683684	/// Changes collection owner to another account685	///686	/// @dev Owner can be changed only by current owner687	/// @param newOwner new owner cross account688	fn change_collection_owner_cross(689		&mut self,690		caller: caller,691		new_owner: EthCrossAccount,692	) -> Result<void> {693		self.consume_store_writes(1)?;694695		let caller = T::CrossAccountId::from_eth(caller);696		let new_owner = new_owner.into_sub_cross_account::<T>()?;697		self.set_owner_internal(caller, new_owner)698			.map_err(dispatch_to_evm::<T>)699	}700}701702/// ### Note703/// Do not forget to add: `self.consume_store_reads(1)?;`704fn check_is_owner_or_admin<T: Config>(705	caller: caller,706	collection: &CollectionHandle<T>,707) -> Result<T::CrossAccountId> {708	let caller = T::CrossAccountId::from_eth(caller);709	collection710		.check_is_owner_or_admin(&caller)711		.map_err(dispatch_to_evm::<T>)?;712	Ok(caller)713}714715/// ### Note716/// Do not forget to add: `self.consume_store_writes(1)?;`717fn save<T: Config>(collection: &CollectionHandle<T>) -> Result<void> {718	collection719		.check_is_internal()720		.map_err(dispatch_to_evm::<T>)?;721	collection.save().map_err(dispatch_to_evm::<T>)?;722	Ok(())723}724725/// Contains static property keys and values.726pub mod static_property {727	use evm_coder::{728		execution::{Result, Error},729	};730	use alloc::format;731732	const EXPECT_CONVERT_ERROR: &str = "length < limit";733734	/// Keys.735	pub mod key {736		use super::*;737738		/// Key "baseURI".739		pub fn base_uri() -> up_data_structs::PropertyKey {740			property_key_from_bytes(b"baseURI").expect(EXPECT_CONVERT_ERROR)741		}742743		/// Key "url".744		pub fn url() -> up_data_structs::PropertyKey {745			property_key_from_bytes(b"URI").expect(EXPECT_CONVERT_ERROR)746		}747748		/// Key "suffix".749		pub fn suffix() -> up_data_structs::PropertyKey {750			property_key_from_bytes(b"URISuffix").expect(EXPECT_CONVERT_ERROR)751		}752753		/// Key "parentNft".754		pub fn parent_nft() -> up_data_structs::PropertyKey {755			property_key_from_bytes(b"parentNft").expect(EXPECT_CONVERT_ERROR)756		}757	}758759	/// Convert `byte` to [`PropertyKey`].760	pub fn property_key_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyKey> {761		bytes.to_vec().try_into().map_err(|_| {762			Error::Revert(format!(763				"Property key is too long. Max length is {}.",764				up_data_structs::PropertyKey::bound()765			))766		})767	}768769	/// Convert `bytes` to [`PropertyValue`].770	pub fn property_value_from_bytes(bytes: &[u8]) -> Result<up_data_structs::PropertyValue> {771		bytes.to_vec().try_into().map_err(|_| {772			Error::Revert(format!(773				"Property key is too long. Max length is {}.",774				up_data_structs::PropertyKey::bound()775			))776		})777	}778}
modifiedpallets/evm-contract-helpers/src/stubs/ContractHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/fungible/CHANGELOG.md
+++ b/pallets/fungible/CHANGELOG.md
@@ -4,12 +4,22 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.8] - 2022-11-18
+
+### Added
+
+- The function `description` to `ERC20UniqueExtensions` interface.
+
 ## [0.1.7] - 2022-11-14
 
 ### Changed
 
 - Added `transfer_cross` in eth functions.
 
+### Changed
+
+- Use named structure `EthCrossAccount` in eth functions.
+
 ## [0.1.6] - 2022-11-02
 
 ### Changed
modifiedpallets/fungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -158,6 +158,13 @@
 where
 	T::AccountId: From<[u8; 32]>,
 {
+	/// @notice A description for the collection.
+	fn description(&self) -> Result<string> {
+		Ok(decode_utf16(self.description.iter().copied())
+			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
+			.collect::<string>())
+	}
+
 	#[weight(<SelfWeightOf<T>>::approve())]
 	fn approve_cross(
 		&mut self,
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -87,11 +87,11 @@
 	/// @return Vector of properties key/value pairs.
 	/// @dev EVM selector for this function is: 0x285fb8e6,
 	///  or in textual repr: collectionProperties(string[])
-	function collectionProperties(string[] memory keys) public view returns (Tuple16[] memory) {
+	function collectionProperties(string[] memory keys) public view returns (Property[] memory) {
 		require(false, stub_error);
 		keys;
 		dummy;
-		return new Tuple16[](0);
+		return new Property[](0);
 	}
 
 	// /// Set the sponsor of the collection.
@@ -425,20 +425,23 @@
 	uint256 sub;
 }
 
-/// @dev anonymous struct
-struct Tuple16 {
-	string field_0;
-	bytes field_1;
-}
-
 /// @dev Property struct
 struct Property {
 	string key;
 	bytes value;
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9
+/// @dev the ERC-165 identifier for this interface is 0x5b7038cf
 contract ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @notice A description for the collection.
+	/// @dev EVM selector for this function is: 0x7284e416,
+	///  or in textual repr: description()
+	function description() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
 	/// @dev EVM selector for this function is: 0x0ecd0ab0,
 	///  or in textual repr: approveCross((address,uint256),uint256)
 	function approveCross(EthCrossAccount memory spender, uint256 amount) public returns (bool) {
modifiedpallets/nonfungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/nonfungible/CHANGELOG.md
+++ b/pallets/nonfungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.1.10] - 2022-11-18
+
+### Added
+
+- The functions `description`, `crossOwnerOf`, `tokenProperties` to `ERC721UniqueExtensions` interface.
+
 ## [0.1.9] - 2022-11-14
 
 ### Changed
modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -37,7 +37,7 @@
 use sp_std::vec::Vec;
 use pallet_common::{
 	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key},
-	CollectionHandle, CollectionPropertyPermissions,
+	CollectionHandle, CollectionPropertyPermissions, CommonCollectionOperations,
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::call;
@@ -278,7 +278,7 @@
 #[solidity_interface(name = ERC721Metadata, expect_selector = 0x5b5e139f)]
 impl<T: Config> NonfungibleHandle<T>
 where
-	T::AccountId: From<[u8; 32]>,
+	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
@@ -686,7 +686,7 @@
 #[solidity_interface(name = ERC721UniqueExtensions)]
 impl<T: Config> NonfungibleHandle<T>
 where
-	T::AccountId: From<[u8; 32]>,
+	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	fn name(&self) -> Result<string> {
@@ -700,6 +700,56 @@
 		Ok(string::from_utf8_lossy(&self.token_prefix).into())
 	}
 
+	/// @notice A description for the collection.
+	fn description(&self) -> Result<string> {
+		Ok(decode_utf16(self.description.iter().copied())
+			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
+			.collect::<string>())
+	}
+
+	/// Returns the owner (in cross format) of the token.
+	///
+	/// @param tokenId Id for the token.
+	fn cross_owner_of(&self, token_id: uint256) -> Result<EthCrossAccount> {
+		Self::token_owner(&self, token_id.try_into()?)
+			.map(|o| EthCrossAccount::from_sub_cross_account::<T>(&o))
+			.ok_or(Error::Revert("key too large".into()))
+	}
+
+	/// Returns the token properties.
+	///
+	/// @param tokenId Id for the token.
+	/// @param keys Properties keys. Empty keys for all propertyes.
+	/// @return Vector of properties key/value pairs.
+	fn token_properties(
+		&self,
+		token_id: uint256,
+		keys: Vec<string>,
+	) -> Result<Vec<PropertyStruct>> {
+		let keys = keys
+			.into_iter()
+			.map(|key| {
+				<Vec<u8>>::from(key)
+					.try_into()
+					.map_err(|_| Error::Revert("key too large".into()))
+			})
+			.collect::<Result<Vec<_>>>()?;
+
+		<Self as CommonCollectionOperations<T>>::token_properties(
+			&self,
+			token_id.try_into()?,
+			if keys.is_empty() { None } else { Some(keys) },
+		)
+		.into_iter()
+		.map(|p| {
+			let key = string::from_utf8(p.key.to_vec())
+				.map_err(|e| Error::Revert(alloc::format!("{}", e)))?;
+			let value = bytes(p.value.to_vec());
+			Ok(PropertyStruct { key, value })
+		})
+		.collect::<Result<Vec<_>>>()
+	}
+
 	/// @notice Set or reaffirm the approved address for an NFT
 	/// @dev The zero address indicates there is no approved address.
 	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
modifiedpallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -188,11 +188,11 @@
 	/// @return Vector of properties key/value pairs.
 	/// @dev EVM selector for this function is: 0x285fb8e6,
 	///  or in textual repr: collectionProperties(string[])
-	function collectionProperties(string[] memory keys) public view returns (Tuple23[] memory) {
+	function collectionProperties(string[] memory keys) public view returns (Property[] memory) {
 		require(false, stub_error);
 		keys;
 		dummy;
-		return new Tuple23[](0);
+		return new Property[](0);
 	}
 
 	// /// Set the sponsor of the collection.
@@ -253,10 +253,10 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() public view returns (Tuple26 memory) {
+	function collectionSponsor() public view returns (Tuple30 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple26(0x0000000000000000000000000000000000000000, 0);
+		return Tuple30(0x0000000000000000000000000000000000000000, 0);
 	}
 
 	/// Set limits for the collection.
@@ -527,17 +527,11 @@
 }
 
 /// @dev anonymous struct
-struct Tuple26 {
+struct Tuple30 {
 	address field_0;
 	uint256 field_1;
 }
 
-/// @dev anonymous struct
-struct Tuple23 {
-	string field_0;
-	bytes field_1;
-}
-
 /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 /// @dev See https://eips.ethereum.org/EIPS/eip-721
 /// @dev the ERC-165 identifier for this interface is 0x5b5e139f
@@ -682,7 +676,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x0e9fc611
+/// @dev the ERC-165 identifier for this interface is 0xb8f094a0
 contract ERC721UniqueExtensions is Dummy, ERC165 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev EVM selector for this function is: 0x06fdde03,
@@ -702,6 +696,42 @@
 		return "";
 	}
 
+	/// @notice A description for the collection.
+	/// @dev EVM selector for this function is: 0x7284e416,
+	///  or in textual repr: description()
+	function description() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	/// Returns the owner (in cross format) of the token.
+	///
+	/// @param tokenId Id for the token.
+	/// @dev EVM selector for this function is: 0x2b29dace,
+	///  or in textual repr: crossOwnerOf(uint256)
+	function crossOwnerOf(uint256 tokenId) public view returns (EthCrossAccount memory) {
+		require(false, stub_error);
+		tokenId;
+		dummy;
+		return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
+	}
+
+	/// Returns the token properties.
+	///
+	/// @param tokenId Id for the token.
+	/// @param keys Properties keys. Empty keys for all propertyes.
+	/// @return Vector of properties key/value pairs.
+	/// @dev EVM selector for this function is: 0xefc26c69,
+	///  or in textual repr: tokenProperties(uint256,string[])
+	function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Property[] memory) {
+		require(false, stub_error);
+		tokenId;
+		keys;
+		dummy;
+		return new Property[](0);
+	}
+
 	/// @notice Set or reaffirm the approved address for an NFT
 	/// @dev The zero address indicates there is no approved address.
 	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
@@ -825,7 +855,7 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple11[] memory tokens) public returns (bool) {
+	// function mintBulkWithTokenURI(address to, Tuple15[] memory tokens) public returns (bool) {
 	// 	require(false, stub_error);
 	// 	to;
 	// 	tokens;
@@ -836,7 +866,7 @@
 }
 
 /// @dev anonymous struct
-struct Tuple11 {
+struct Tuple15 {
 	uint256 field_0;
 	string field_1;
 }
modifiedpallets/refungible/CHANGELOG.mddiffbeforeafterboth
--- a/pallets/refungible/CHANGELOG.md
+++ b/pallets/refungible/CHANGELOG.md
@@ -4,6 +4,12 @@
 
 <!-- bureaucrate goes here -->
 
+## [0.2.9] - 2022-11-18
+
+### Added
+
+- The functions `description`, `crossOwnerOf`, `tokenProperties` to `ERC721UniqueExtensions` interface.
+
 ## [0.2.8] - 2022-11-14
 
 ### Changed
modifiedpallets/refungible/src/erc.rsdiffbeforeafterboth
--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -33,6 +33,7 @@
 use pallet_common::{
 	CollectionHandle, CollectionPropertyPermissions,
 	erc::{CommonEvmHandler, CollectionCall, static_property::key},
+	CommonCollectionOperations,
 };
 use pallet_evm::{account::CrossAccountId, PrecompileHandle};
 use pallet_evm_coder_substrate::{call, dispatch_to_evm};
@@ -273,7 +274,7 @@
 #[solidity_interface(name = ERC721Metadata)]
 impl<T: Config> RefungibleHandle<T>
 where
-	T::AccountId: From<[u8; 32]>,
+	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev real implementation of this function lies in `ERC721UniqueExtensions`
@@ -713,7 +714,7 @@
 #[solidity_interface(name = ERC721UniqueExtensions)]
 impl<T: Config> RefungibleHandle<T>
 where
-	T::AccountId: From<[u8; 32]>,
+	T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,
 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	fn name(&self) -> Result<string> {
@@ -727,6 +728,55 @@
 		Ok(string::from_utf8_lossy(&self.token_prefix).into())
 	}
 
+	/// @notice A description for the collection.
+	fn description(&self) -> Result<string> {
+		Ok(decode_utf16(self.description.iter().copied())
+			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
+			.collect::<string>())
+	}
+
+	/// Returns the owner (in cross format) of the token.
+	///
+	/// @param tokenId Id for the token.
+	fn cross_owner_of(&self, token_id: uint256) -> Result<EthCrossAccount> {
+		Self::token_owner(&self, token_id.try_into()?)
+			.map(|o| EthCrossAccount::from_sub_cross_account::<T>(&o))
+			.ok_or(Error::Revert("key too large".into()))
+	}
+
+	/// Returns the token properties.
+	///
+	/// @param tokenId Id for the token.
+	/// @param keys Properties keys. Empty keys for all propertyes.
+	/// @return Vector of properties key/value pairs.
+	fn token_properties(
+		&self,
+		token_id: uint256,
+		keys: Vec<string>,
+	) -> Result<Vec<PropertyStruct>> {
+		let keys = keys
+			.into_iter()
+			.map(|key| {
+				<Vec<u8>>::from(key)
+					.try_into()
+					.map_err(|_| Error::Revert("key too large".into()))
+			})
+			.collect::<Result<Vec<_>>>()?;
+
+		<Self as CommonCollectionOperations<T>>::token_properties(
+			&self,
+			token_id.try_into()?,
+			if keys.is_empty() { None } else { Some(keys) },
+		)
+		.into_iter()
+		.map(|p| {
+			let key = string::from_utf8(p.key.to_vec())
+				.map_err(|e| Error::Revert(alloc::format!("{}", e)))?;
+			let value = bytes(p.value.to_vec());
+			Ok(PropertyStruct { key, value })
+		})
+		.collect::<Result<Vec<_>>>()
+	}
 	/// @notice Transfer ownership of an RFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid RFT.
modifiedpallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -188,11 +188,11 @@
 	/// @return Vector of properties key/value pairs.
 	/// @dev EVM selector for this function is: 0x285fb8e6,
 	///  or in textual repr: collectionProperties(string[])
-	function collectionProperties(string[] memory keys) public view returns (Tuple22[] memory) {
+	function collectionProperties(string[] memory keys) public view returns (Property[] memory) {
 		require(false, stub_error);
 		keys;
 		dummy;
-		return new Tuple22[](0);
+		return new Property[](0);
 	}
 
 	// /// Set the sponsor of the collection.
@@ -253,10 +253,10 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() public view returns (Tuple25 memory) {
+	function collectionSponsor() public view returns (Tuple29 memory) {
 		require(false, stub_error);
 		dummy;
-		return Tuple25(0x0000000000000000000000000000000000000000, 0);
+		return Tuple29(0x0000000000000000000000000000000000000000, 0);
 	}
 
 	/// Set limits for the collection.
@@ -527,17 +527,11 @@
 }
 
 /// @dev anonymous struct
-struct Tuple25 {
+struct Tuple29 {
 	address field_0;
 	uint256 field_1;
 }
 
-/// @dev anonymous struct
-struct Tuple22 {
-	string field_0;
-	bytes field_1;
-}
-
 /// @dev the ERC-165 identifier for this interface is 0x5b5e139f
 contract ERC721Metadata is Dummy, ERC165 {
 	// /// @notice A descriptive name for a collection of NFTs in this contract
@@ -680,7 +674,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xab243667
+/// @dev the ERC-165 identifier for this interface is 0x1d4b64d6
 contract ERC721UniqueExtensions is Dummy, ERC165 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev EVM selector for this function is: 0x06fdde03,
@@ -700,6 +694,42 @@
 		return "";
 	}
 
+	/// @notice A description for the collection.
+	/// @dev EVM selector for this function is: 0x7284e416,
+	///  or in textual repr: description()
+	function description() public view returns (string memory) {
+		require(false, stub_error);
+		dummy;
+		return "";
+	}
+
+	/// Returns the owner (in cross format) of the token.
+	///
+	/// @param tokenId Id for the token.
+	/// @dev EVM selector for this function is: 0x2b29dace,
+	///  or in textual repr: crossOwnerOf(uint256)
+	function crossOwnerOf(uint256 tokenId) public view returns (EthCrossAccount memory) {
+		require(false, stub_error);
+		tokenId;
+		dummy;
+		return EthCrossAccount(0x0000000000000000000000000000000000000000, 0);
+	}
+
+	/// Returns the token properties.
+	///
+	/// @param tokenId Id for the token.
+	/// @param keys Properties keys. Empty keys for all propertyes.
+	/// @return Vector of properties key/value pairs.
+	/// @dev EVM selector for this function is: 0xefc26c69,
+	///  or in textual repr: tokenProperties(uint256,string[])
+	function tokenProperties(uint256 tokenId, string[] memory keys) public view returns (Property[] memory) {
+		require(false, stub_error);
+		tokenId;
+		keys;
+		dummy;
+		return new Property[](0);
+	}
+
 	/// @notice Transfer ownership of an RFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid RFT.
@@ -813,7 +843,7 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) public returns (bool) {
+	// function mintBulkWithTokenURI(address to, Tuple14[] memory tokens) public returns (bool) {
 	// 	require(false, stub_error);
 	// 	to;
 	// 	tokens;
@@ -835,7 +865,7 @@
 }
 
 /// @dev anonymous struct
-struct Tuple10 {
+struct Tuple14 {
 	uint256 field_0;
 	string field_1;
 }
modifiedpallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterboth

binary blob — no preview

modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -216,10 +216,10 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "string", "name": "field_0", "type": "string" },
-          { "internalType": "bytes", "name": "field_1", "type": "bytes" }
+          { "internalType": "string", "name": "key", "type": "string" },
+          { "internalType": "bytes", "name": "value", "type": "bytes" }
         ],
-        "internalType": "struct Tuple16[]",
+        "internalType": "struct Property[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -283,6 +283,13 @@
   },
   {
     "inputs": [],
+    "name": "description",
+    "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [],
     "name": "hasCollectionPendingSponsor",
     "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
     "stateMutability": "view",
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -246,10 +246,10 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "string", "name": "field_0", "type": "string" },
-          { "internalType": "bytes", "name": "field_1", "type": "bytes" }
+          { "internalType": "string", "name": "key", "type": "string" },
+          { "internalType": "bytes", "name": "value", "type": "bytes" }
         ],
-        "internalType": "struct Tuple23[]",
+        "internalType": "struct Property[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -273,7 +273,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple26",
+        "internalType": "struct Tuple30",
         "name": "",
         "type": "tuple"
       }
@@ -297,6 +297,25 @@
   },
   {
     "inputs": [
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "crossOwnerOf",
+    "outputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+        ],
+        "internalType": "struct EthCrossAccount",
+        "name": "",
+        "type": "tuple"
+      }
+    ],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "string[]", "name": "keys", "type": "string[]" }
     ],
     "name": "deleteCollectionProperties",
@@ -316,6 +335,13 @@
   },
   {
     "inputs": [],
+    "name": "description",
+    "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [],
     "name": "finishMinting",
     "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
     "stateMutability": "nonpayable",
@@ -641,6 +667,26 @@
   },
   {
     "inputs": [
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
+      { "internalType": "string[]", "name": "keys", "type": "string[]" }
+    ],
+    "name": "tokenProperties",
+    "outputs": [
+      {
+        "components": [
+          { "internalType": "string", "name": "key", "type": "string" },
+          { "internalType": "bytes", "name": "value", "type": "bytes" }
+        ],
+        "internalType": "struct Property[]",
+        "name": "",
+        "type": "tuple[]"
+      }
+    ],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
     ],
     "name": "tokenURI",
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -228,10 +228,10 @@
     "outputs": [
       {
         "components": [
-          { "internalType": "string", "name": "field_0", "type": "string" },
-          { "internalType": "bytes", "name": "field_1", "type": "bytes" }
+          { "internalType": "string", "name": "key", "type": "string" },
+          { "internalType": "bytes", "name": "value", "type": "bytes" }
         ],
-        "internalType": "struct Tuple22[]",
+        "internalType": "struct Property[]",
         "name": "",
         "type": "tuple[]"
       }
@@ -255,7 +255,7 @@
           { "internalType": "address", "name": "field_0", "type": "address" },
           { "internalType": "uint256", "name": "field_1", "type": "uint256" }
         ],
-        "internalType": "struct Tuple25",
+        "internalType": "struct Tuple29",
         "name": "",
         "type": "tuple"
       }
@@ -279,6 +279,25 @@
   },
   {
     "inputs": [
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
+    ],
+    "name": "crossOwnerOf",
+    "outputs": [
+      {
+        "components": [
+          { "internalType": "address", "name": "eth", "type": "address" },
+          { "internalType": "uint256", "name": "sub", "type": "uint256" }
+        ],
+        "internalType": "struct EthCrossAccount",
+        "name": "",
+        "type": "tuple"
+      }
+    ],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "string[]", "name": "keys", "type": "string[]" }
     ],
     "name": "deleteCollectionProperties",
@@ -298,6 +317,13 @@
   },
   {
     "inputs": [],
+    "name": "description",
+    "outputs": [{ "internalType": "string", "name": "", "type": "string" }],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [],
     "name": "finishMinting",
     "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
     "stateMutability": "nonpayable",
@@ -632,6 +658,26 @@
   },
   {
     "inputs": [
+      { "internalType": "uint256", "name": "tokenId", "type": "uint256" },
+      { "internalType": "string[]", "name": "keys", "type": "string[]" }
+    ],
+    "name": "tokenProperties",
+    "outputs": [
+      {
+        "components": [
+          { "internalType": "string", "name": "key", "type": "string" },
+          { "internalType": "bytes", "name": "value", "type": "bytes" }
+        ],
+        "internalType": "struct Property[]",
+        "name": "",
+        "type": "tuple[]"
+      }
+    ],
+    "stateMutability": "view",
+    "type": "function"
+  },
+  {
+    "inputs": [
       { "internalType": "uint256", "name": "tokenId", "type": "uint256" }
     ],
     "name": "tokenURI",
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -60,7 +60,7 @@
 	/// @return Vector of properties key/value pairs.
 	/// @dev EVM selector for this function is: 0x285fb8e6,
 	///  or in textual repr: collectionProperties(string[])
-	function collectionProperties(string[] memory keys) external view returns (Tuple16[] memory);
+	function collectionProperties(string[] memory keys) external view returns (Property[] memory);
 
 	// /// Set the sponsor of the collection.
 	// ///
@@ -276,12 +276,6 @@
 struct EthCrossAccount {
 	address eth;
 	uint256 sub;
-}
-
-/// @dev anonymous struct
-struct Tuple16 {
-	string field_0;
-	bytes field_1;
 }
 
 /// @dev Property struct
@@ -290,8 +284,13 @@
 	bytes value;
 }
 
-/// @dev the ERC-165 identifier for this interface is 0x29f4dcd9
+/// @dev the ERC-165 identifier for this interface is 0x5b7038cf
 interface ERC20UniqueExtensions is Dummy, ERC165 {
+	/// @notice A description for the collection.
+	/// @dev EVM selector for this function is: 0x7284e416,
+	///  or in textual repr: description()
+	function description() external view returns (string memory);
+
 	/// @dev EVM selector for this function is: 0x0ecd0ab0,
 	///  or in textual repr: approveCross((address,uint256),uint256)
 	function approveCross(EthCrossAccount memory spender, uint256 amount) external returns (bool);
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -127,7 +127,7 @@
 	/// @return Vector of properties key/value pairs.
 	/// @dev EVM selector for this function is: 0x285fb8e6,
 	///  or in textual repr: collectionProperties(string[])
-	function collectionProperties(string[] memory keys) external view returns (Tuple23[] memory);
+	function collectionProperties(string[] memory keys) external view returns (Property[] memory);
 
 	// /// Set the sponsor of the collection.
 	// ///
@@ -169,7 +169,7 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() external view returns (Tuple26 memory);
+	function collectionSponsor() external view returns (Tuple27 memory);
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
@@ -346,15 +346,9 @@
 }
 
 /// @dev anonymous struct
-struct Tuple26 {
+struct Tuple27 {
 	address field_0;
 	uint256 field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple23 {
-	string field_0;
-	bytes field_1;
 }
 
 /// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
@@ -452,7 +446,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0x0e9fc611
+/// @dev the ERC-165 identifier for this interface is 0xb8f094a0
 interface ERC721UniqueExtensions is Dummy, ERC165 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev EVM selector for this function is: 0x06fdde03,
@@ -464,6 +458,27 @@
 	///  or in textual repr: symbol()
 	function symbol() external view returns (string memory);
 
+	/// @notice A description for the collection.
+	/// @dev EVM selector for this function is: 0x7284e416,
+	///  or in textual repr: description()
+	function description() external view returns (string memory);
+
+	/// Returns the owner (in cross format) of the token.
+	///
+	/// @param tokenId Id for the token.
+	/// @dev EVM selector for this function is: 0x2b29dace,
+	///  or in textual repr: crossOwnerOf(uint256)
+	function crossOwnerOf(uint256 tokenId) external view returns (EthCrossAccount memory);
+
+	/// Returns the token properties.
+	///
+	/// @param tokenId Id for the token.
+	/// @param keys Properties keys. Empty keys for all propertyes.
+	/// @return Vector of properties key/value pairs.
+	/// @dev EVM selector for this function is: 0xefc26c69,
+	///  or in textual repr: tokenProperties(uint256,string[])
+	function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Property[] memory);
+
 	/// @notice Set or reaffirm the approved address for an NFT
 	/// @dev The zero address indicates there is no approved address.
 	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
@@ -546,12 +561,12 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple11[] memory tokens) external returns (bool);
+	// function mintBulkWithTokenURI(address to, Tuple13[] memory tokens) external returns (bool);
 
 }
 
 /// @dev anonymous struct
-struct Tuple11 {
+struct Tuple13 {
 	uint256 field_0;
 	string field_1;
 }
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -127,7 +127,7 @@
 	/// @return Vector of properties key/value pairs.
 	/// @dev EVM selector for this function is: 0x285fb8e6,
 	///  or in textual repr: collectionProperties(string[])
-	function collectionProperties(string[] memory keys) external view returns (Tuple22[] memory);
+	function collectionProperties(string[] memory keys) external view returns (Property[] memory);
 
 	// /// Set the sponsor of the collection.
 	// ///
@@ -169,7 +169,7 @@
 	/// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.
 	/// @dev EVM selector for this function is: 0x6ec0a9f1,
 	///  or in textual repr: collectionSponsor()
-	function collectionSponsor() external view returns (Tuple25 memory);
+	function collectionSponsor() external view returns (Tuple26 memory);
 
 	/// Set limits for the collection.
 	/// @dev Throws error if limit not found.
@@ -346,15 +346,9 @@
 }
 
 /// @dev anonymous struct
-struct Tuple25 {
+struct Tuple26 {
 	address field_0;
 	uint256 field_1;
-}
-
-/// @dev anonymous struct
-struct Tuple22 {
-	string field_0;
-	bytes field_1;
 }
 
 /// @dev the ERC-165 identifier for this interface is 0x5b5e139f
@@ -450,7 +444,7 @@
 }
 
 /// @title Unique extensions for ERC721.
-/// @dev the ERC-165 identifier for this interface is 0xab243667
+/// @dev the ERC-165 identifier for this interface is 0x1d4b64d6
 interface ERC721UniqueExtensions is Dummy, ERC165 {
 	/// @notice A descriptive name for a collection of NFTs in this contract
 	/// @dev EVM selector for this function is: 0x06fdde03,
@@ -462,6 +456,27 @@
 	///  or in textual repr: symbol()
 	function symbol() external view returns (string memory);
 
+	/// @notice A description for the collection.
+	/// @dev EVM selector for this function is: 0x7284e416,
+	///  or in textual repr: description()
+	function description() external view returns (string memory);
+
+	/// Returns the owner (in cross format) of the token.
+	///
+	/// @param tokenId Id for the token.
+	/// @dev EVM selector for this function is: 0x2b29dace,
+	///  or in textual repr: crossOwnerOf(uint256)
+	function crossOwnerOf(uint256 tokenId) external view returns (EthCrossAccount memory);
+
+	/// Returns the token properties.
+	///
+	/// @param tokenId Id for the token.
+	/// @param keys Properties keys. Empty keys for all propertyes.
+	/// @return Vector of properties key/value pairs.
+	/// @dev EVM selector for this function is: 0xefc26c69,
+	///  or in textual repr: tokenProperties(uint256,string[])
+	function tokenProperties(uint256 tokenId, string[] memory keys) external view returns (Property[] memory);
+
 	/// @notice Transfer ownership of an RFT
 	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
 	///  is the zero address. Throws if `tokenId` is not a valid RFT.
@@ -539,7 +554,7 @@
 	// /// @param tokens array of pairs of token ID and token URI for minted tokens
 	// /// @dev EVM selector for this function is: 0x36543006,
 	// ///  or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])
-	// function mintBulkWithTokenURI(address to, Tuple10[] memory tokens) external returns (bool);
+	// function mintBulkWithTokenURI(address to, Tuple12[] memory tokens) external returns (bool);
 
 	/// Returns EVM address for refungible token
 	///
@@ -550,7 +565,7 @@
 }
 
 /// @dev anonymous struct
-struct Tuple10 {
+struct Tuple12 {
 	uint256 field_0;
 	string field_1;
 }
modifiedtests/src/eth/base.test.tsdiffbeforeafterboth
--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -117,7 +117,7 @@
   });
 
   itEth('ERC721UniqueExtensions support', async ({helper}) => {
-    await checkInterface(helper, '0x0e9fc611', true, true);
+    await checkInterface(helper, '0xb8f094a0', true, true);
   });
 
   itEth('ERC721Burnable - 0x42966c68 - support', async ({helper}) => {
modifiedtests/src/eth/createFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createFTCollection.test.ts
+++ b/tests/src/eth/createFTCollection.test.ts
@@ -36,9 +36,11 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
     const ss58Format = helper.chain.getChainProperties().ss58Format;
-    const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, 'absolutely anything', 'ENVY');
+    const description = 'absolutely anything';
+    
+    const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');
 
-    const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner, true);
+    const collection = helper.ethNativeContract.collection(collectionAddress, 'ft', owner, true);
     await collection.methods.setCollectionSponsor(sponsor).send();
 
     let data = (await helper.rft.getData(collectionId))!;
@@ -57,8 +59,9 @@
     const owner = await helper.eth.createAccountWithBalance(donor);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
     const ss58Format = helper.chain.getChainProperties().ss58Format;
-    const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, 'absolutely anything', 'ENVY');
-
+    const description = 'absolutely anything';
+    const {collectionId, collectionAddress} = await helper.eth.createFungibleCollection(owner, 'Sponsor', DECIMALS, description, 'ENVY');
+    
     const collection = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);
     const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
     await collection.methods.setCollectionSponsorCross(sponsorCross).send();
@@ -73,6 +76,7 @@
 
     data = (await helper.rft.getData(collectionId))!;
     expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
+    expect(await collection.methods.description().call()).to.deep.equal(description);
   });
 
   itEth('Set limits', async ({helper}) => {
modifiedtests/src/eth/createNFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createNFTCollection.test.ts
+++ b/tests/src/eth/createNFTCollection.test.ts
@@ -28,7 +28,7 @@
     });
   });
 
-  itEth('Create collection with properties', async ({helper}) => {
+  itEth('Create collection with properties & get desctription', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
 
     const name = 'CollectionEVM';
@@ -37,7 +37,8 @@
     const baseUri = 'BaseURI';
 
     const {collectionId, collectionAddress, events} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, name, description, prefix, baseUri);
-
+    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');
+    
     expect(events).to.be.deep.equal([
       {
         address: '0x6C4E9fE1AE37a41E93CEE429e8E1881aBdcbb54F',
@@ -56,7 +57,9 @@
     expect(data.description).to.be.eq(description);
     expect(data.raw.tokenPrefix).to.be.eq(prefix);
     expect(data.raw.mode).to.be.eq('NFT');
-
+    
+    expect(await contract.methods.description().call()).to.deep.equal(description);
+    
     const options = await collection.getOptions();
     expect(options.tokenPropertyPermissions).to.be.deep.equal([
       {
@@ -92,11 +95,12 @@
     expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
   });
 
-  itEth('[cross] Set sponsorship', async ({helper}) => {
+  itEth('[cross] Set sponsorship & get description', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const sponsor = await helper.eth.createAccountWithBalance(donor);
     const ss58Format = helper.chain.getChainProperties().ss58Format;
-    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', 'absolutely anything', 'ROC');
+    const description = 'absolutely anything';
+    const {collectionId, collectionAddress} = await helper.eth.createNFTCollection(owner, 'Sponsor', description, 'ROC');
 
     const collection = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);
     const sponsorCross = helper.ethCrossAccount.fromAddress(sponsor);
@@ -112,6 +116,8 @@
 
     data = (await helper.nft.getData(collectionId))!;
     expect(data.raw.sponsorship.Confirmed).to.be.equal(evmToAddress(sponsor, Number(ss58Format)));
+    
+    expect(await sponsorCollection.methods.description().call()).to.deep.equal(description);
   });
 
   itEth('Set limits', async ({helper}) => {
modifiedtests/src/eth/createRFTCollection.test.tsdiffbeforeafterboth
--- a/tests/src/eth/createRFTCollection.test.ts
+++ b/tests/src/eth/createRFTCollection.test.ts
@@ -53,7 +53,7 @@
 
   
 
-  itEth('Create collection with properties', async ({helper}) => {
+  itEth('Create collection with properties & get description', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
 
     const name = 'CollectionEVM';
@@ -61,7 +61,8 @@
     const prefix = 'token prefix';
     const baseUri = 'BaseURI';
 
-    const {collectionId} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);
+    const {collectionId, collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, name, description, prefix, baseUri);
+    const contract = helper.ethNativeContract.collection(collectionAddress, 'nft');
 
     const collection = helper.rft.getCollectionObject(collectionId);
     const data = (await collection.getData())!;
@@ -71,6 +72,8 @@
     expect(data.raw.tokenPrefix).to.be.eq(prefix);
     expect(data.raw.mode).to.be.eq('ReFungible');
 
+    expect(await contract.methods.description().call()).to.deep.equal(description);
+
     const options = await collection.getOptions();
     expect(options.tokenPropertyPermissions).to.be.deep.equal([
       {
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -17,6 +17,7 @@
 import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';
 import {IKeyringPair} from '@polkadot/types/types';
 import {Contract} from 'web3-eth-contract';
+import exp from 'constants';
 
 
 describe('NFT: Information getting', () => {
@@ -149,7 +150,7 @@
     });
   });
 
-  itEth('Can perform mint()', async ({helper}) => {
+  itEth('Can perform mint() & get crossOwner()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
 
@@ -166,7 +167,8 @@
     expect(event.returnValues.to).to.be.equal(receiver);
 
     expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
-
+    console.log(await contract.methods.crossOwnerOf(tokenId).call());
+    expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
     // TODO: this wont work right now, need release 919000 first
     // await helper.methods.setOffchainSchema(collectionIdAddress, 'https://offchain-service.local/token-info/{id}').send();
     // const tokenUri = await contract.methods.tokenURI(nextTokenId).call();
modifiedtests/src/eth/reFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -117,7 +117,7 @@
     });
   });
 
-  itEth('Can perform mint()', async ({helper}) => {
+  itEth('Can perform mint() & crossOwnerOf()', async ({helper}) => {
     const owner = await helper.eth.createAccountWithBalance(donor);
     const receiver = helper.eth.createAccount();
     const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Minty', '6', '6', '');
@@ -132,6 +132,7 @@
     const tokenId = event.returnValues.tokenId;
     expect(tokenId).to.be.equal('1');
 
+    expect(await contract.methods.crossOwnerOf(tokenId).call()).to.be.like([receiver, '0']);
     expect(await contract.methods.tokenURI(tokenId).call()).to.be.equal('Test URI');
   });
 
modifiedtests/src/eth/tokenProperties.test.tsdiffbeforeafterboth
--- a/tests/src/eth/tokenProperties.test.ts
+++ b/tests/src/eth/tokenProperties.test.ts
@@ -14,10 +14,11 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-import {itEth, usingEthPlaygrounds, expect} from './util';
+import {itEth, usingEthPlaygrounds, expect, EthUniqueHelper} from './util';
 import {IKeyringPair} from '@polkadot/types/types';
-import {ITokenPropertyPermission} from '../util/playgrounds/types';
+import {ITokenPropertyPermission, TCollectionMode} from '../util/playgrounds/types';
 import {Pallets} from '../util';
+import {UniqueNFTCollection, UniqueRFTCollection} from '../util/playgrounds/unique';
 
 describe('EVM token properties', () => {
   let donor: IKeyringPair;
@@ -95,7 +96,7 @@
     expect(value).to.equal('testValue');
   });
   
-  itEth('Can be multiple set for NFT ', async({helper}) => {
+  async function checkProps(helper: EthUniqueHelper, mode: TCollectionMode) {
     const caller = await helper.eth.createAccountWithBalance(donor);
     
     const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
@@ -103,56 +104,44 @@
       collectionAdmin: true,
       mutable: true}}; });
     
-    const collection = await helper.nft.mintCollection(alice, {
+    const collection = await helper[mode].mintCollection(alice, {
       tokenPrefix: 'ethp',
       tokenPropertyPermissions: permissions,
-    });
+    }) as UniqueNFTCollection | UniqueRFTCollection;
     
     const token = await collection.mintToken(alice);
     
     const valuesBefore = await token.getProperties(properties.map(p => p.key));
     expect(valuesBefore).to.be.deep.equal([]);
     
+    
     await collection.addAdmin(alice, {Ethereum: caller});
-
+    
     const address = helper.ethAddress.fromCollectionId(collection.collectionId);
-    const contract = helper.ethNativeContract.collection(address, 'nft', caller);
+    const contract = helper.ethNativeContract.collection(address, mode, caller);
+    
+    expect(await contract.methods.tokenProperties(token.tokenId, []).call()).to.be.deep.equal([]);
 
     await contract.methods.setProperties(token.tokenId, properties).send({from: caller});
 
     const values = await token.getProperties(properties.map(p => p.key));
     expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));
-  });
-  
-  itEth.ifWithPallets('Can be multiple set for RFT ', [Pallets.ReFungible], async({helper}) => {
-    const caller = await helper.eth.createAccountWithBalance(donor);
     
-    const properties = Array(5).fill(0).map((_, i) => { return {key: `key_${i}`, value: Buffer.from(`value_${i}`)}; });
-    const permissions: ITokenPropertyPermission[] = properties.map(p => { return {key: p.key, permission: {tokenOwner: true,
-      collectionAdmin: true,
-      mutable: true}}; });
-    
-    const collection = await helper.rft.mintCollection(alice, {
-      tokenPrefix: 'ethp',
-      tokenPropertyPermissions: permissions,
-    });
-        
-    const token = await collection.mintToken(alice);
-    
-    const valuesBefore = await token.getProperties(properties.map(p => p.key));
-    expect(valuesBefore).to.be.deep.equal([]);
+    expect(await contract.methods.tokenProperties(token.tokenId, []).call()).to.be.like(properties
+      .map(p => { return helper.ethProperty.property(p.key, p.value.toString()); }));
     
-    await collection.addAdmin(alice, {Ethereum: caller});
-
-    const address = helper.ethAddress.fromCollectionId(collection.collectionId);
-    const contract = helper.ethNativeContract.collection(address, 'rft', caller);
-
-    await contract.methods.setProperties(token.tokenId, properties).send({from: caller});
-
-    const values = await token.getProperties(properties.map(p => p.key));
-    expect(values).to.be.deep.equal(properties.map(p => { return {key: p.key, value: p.value.toString()}; }));
+    expect(await contract.methods.tokenProperties(token.tokenId, [properties[0].key]).call())
+      .to.be.like([helper.ethProperty.property(properties[0].key, properties[0].value.toString())]);
+  }
+  
+  itEth('Can be multiple set/read for NFT ', async({helper}) => {
+    await checkProps(helper, 'nft');
+  });
+  
+  itEth.ifWithPallets('Can be multiple set/read for RFT ', [Pallets.ReFungible], async({helper}) => {
+    await checkProps(helper, 'rft');
   });
-
+  
   itEth('Can be deleted', async({helper}) => {
     const caller = await helper.eth.createAccountWithBalance(donor);
     const collection = await helper.nft.mintCollection(alice, {