git.delta.rocks / unique-network / refs/commits / 118b8d5eaba9

difftreelog

feature: add `createERC721MetadataCompatibleRFTCollection` method

Trubnikov Sergey2022-07-25parent: #e516992.patch.diff
in: master

4 files changed

modifiedpallets/unique/src/eth/mod.rsdiffbeforeafterboth
before · pallets/unique/src/eth/mod.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//! Implementation of CollectionHelpers contract.1819use core::marker::PhantomData;20use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};21use ethereum as _;22use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};23use pallet_evm::{OnMethodCall, PrecompileResult, account::CrossAccountId, PrecompileHandle};24use up_data_structs::{25	CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,26	CollectionMode, PropertyValue,27};28use frame_support::traits::Get;29use pallet_common::{30	CollectionById,31	erc::{static_property::{key, value as property_value}, CollectionHelpersEvents},32};33use crate::{SelfWeightOf, Config, weights::WeightInfo};3435use sp_std::vec::Vec;36use alloc::format;3738/// See [`CollectionHelpersCall`]39pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);40impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {41	fn recorder(&self) -> &SubstrateRecorder<T> {42		&self.043	}4445	fn into_recorder(self) -> SubstrateRecorder<T> {46		self.047	}48}4950fn convert_data<T: Config>(51	caller: caller,52	name: string,53	description: string,54	token_prefix: string,55	base_uri: string,56) -> Result<(57	T::CrossAccountId,58	CollectionName,59	CollectionDescription,60	CollectionTokenPrefix,61	PropertyValue,62)> {63	let caller = T::CrossAccountId::from_eth(caller);64	let name = name65		.encode_utf16()66		.collect::<Vec<u16>>()67		.try_into()68		.map_err(|_| error_feild_too_long(stringify!(name), CollectionName::bound()))?;69	let description = description70		.encode_utf16()71		.collect::<Vec<u16>>()72		.try_into()73		.map_err(|_| {74			error_feild_too_long(stringify!(description), CollectionDescription::bound())75		})?;76	let token_prefix = token_prefix.into_bytes().try_into().map_err(|_| {77		error_feild_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())78	})?;79	let base_uri_value = base_uri80		.into_bytes()81		.try_into()82		.map_err(|_| error_feild_too_long(stringify!(token_prefix), PropertyValue::bound()))?;83	Ok((caller, name, description, token_prefix, base_uri_value))84}8586fn make_data<T: Config>(87	name: CollectionName,88	mode: CollectionMode,89	description: CollectionDescription,90	token_prefix: CollectionTokenPrefix,91	base_uri_value: PropertyValue,92	add_properties: bool,93) -> Result<CreateCollectionData<T::AccountId>> {94	let mut properties = up_data_structs::CollectionPropertiesVec::default();95	let mut token_property_permissions =96		up_data_structs::CollectionPropertiesPermissionsVec::default();9798	token_property_permissions99		.try_push(up_data_structs::PropertyKeyPermission {100			key: key::url(),101			permission: up_data_structs::PropertyPermission {102				mutable: false,103				collection_admin: true,104				token_owner: false,105			},106		})107		.map_err(|e| Error::Revert(format!("{:?}", e)))?;108109	if add_properties {110		token_property_permissions111			.try_push(up_data_structs::PropertyKeyPermission {112				key: key::suffix(),113				permission: up_data_structs::PropertyPermission {114					mutable: false,115					collection_admin: true,116					token_owner: false,117				},118			})119			.map_err(|e| Error::Revert(format!("{:?}", e)))?;120121		properties122			.try_push(up_data_structs::Property {123				key: key::schema_name(),124				value: property_value::erc721(),125			})126			.map_err(|e| Error::Revert(format!("{:?}", e)))?;127128		if !base_uri_value.is_empty() {129			properties130				.try_push(up_data_structs::Property {131					key: key::base_uri(),132					value: base_uri_value,133				})134				.map_err(|e| Error::Revert(format!("{:?}", e)))?;135		}136	}137138	let data = CreateCollectionData {139		name,140		mode,141		description,142		token_prefix,143		token_property_permissions,144		properties,145		..Default::default()146	};147	Ok(data)148}149150/// @title Contract, which allows users to operate with collections151#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]152impl<T> EvmCollectionHelpers<T>153where154	T: Config + pallet_nonfungible::Config + pallet_refungible::Config,155{156	/// Create an NFT collection157	/// @param name Name of the collection158	/// @param description Informative description of the collection159	/// @param token_prefix Token prefix to represent the collection tokens in UI and user applications160	/// @return address Address of the newly created collection161	#[weight(<SelfWeightOf<T>>::create_collection())]162	fn create_nonfungible_collection(163		&mut self,164		caller: caller,165		name: string,166		description: string,167		token_prefix: string,168	) -> Result<address> {169		let (caller, name, description, token_prefix, _base_uri_value) =170			convert_data::<T>(caller, name, description, token_prefix, "".into())?;171		let data = make_data::<T>(172			name,173			CollectionMode::NFT,174			description,175			token_prefix,176			Default::default(),177			false,178		)?;179		let collection_id =180			<pallet_nonfungible::Pallet<T>>::init_collection(caller.clone(), data, false)181				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;182183		let address = pallet_common::eth::collection_id_to_address(collection_id);184		Ok(address)185	}186187	#[weight(<SelfWeightOf<T>>::create_collection())]188	#[solidity(rename_selector = "createERC721MetadataCompatibleCollection")]189	fn create_nonfungible_collection_with_properties(190		&mut self,191		caller: caller,192		name: string,193		description: string,194		token_prefix: string,195		base_uri: string,196	) -> Result<address> {197		let (caller, name, description, token_prefix, base_uri_value) =198			convert_data::<T>(caller, name, description, token_prefix, base_uri)?;199		let data = make_data::<T>(200			name,201			CollectionMode::NFT,202			description,203			token_prefix,204			base_uri_value,205			true,206		)?;207		let collection_id =208			<pallet_nonfungible::Pallet<T>>::init_collection(caller.clone(), data, true)209				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;210211		let address = pallet_common::eth::collection_id_to_address(collection_id);212		Ok(address)213	}214215	#[weight(<SelfWeightOf<T>>::create_collection())]216	fn create_refungible_collection(217		&self,218		caller: caller,219		name: string,220		description: string,221		token_prefix: string,222	) -> Result<address> {223		let (caller, name, description, token_prefix, _base_uri) =224			convert_data::<T>(caller, name, description, token_prefix, "".into())?;225		let data = make_data::<T>(226			name,227			CollectionMode::ReFungible,228			description,229			token_prefix,230			Default::default(),231			false,232		)?;233		let collection_id = <pallet_refungible::Pallet<T>>::init_collection(caller.clone(), data)234			.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;235236		let address = pallet_common::eth::collection_id_to_address(collection_id);237		Ok(address)238	}239240	/// Check if a collection exists241	/// @param collection_address Address of the collection in question242	/// @return bool Does the collection exist?243	fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {244		if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {245			let collection_id = id;246			return Ok(<CollectionById<T>>::contains_key(collection_id));247		}248249		Ok(false)250	}251}252253/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]254pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);255impl<T: Config + pallet_nonfungible::Config + pallet_refungible::Config> OnMethodCall<T>256	for CollectionHelpersOnMethodCall<T>257{258	fn is_reserved(contract: &sp_core::H160) -> bool {259		contract == &T::ContractAddress::get()260	}261262	fn is_used(contract: &sp_core::H160) -> bool {263		contract == &T::ContractAddress::get()264	}265266	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {267		if handle.code_address() != T::ContractAddress::get() {268			return None;269		}270271		let helpers =272			EvmCollectionHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));273		pallet_evm_coder_substrate::call(handle, helpers)274	}275276	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {277		(contract == &T::ContractAddress::get())278			.then(|| include_bytes!("./stubs/CollectionHelpers.raw").to_vec())279	}280}281282generate_stubgen!(collection_helper_impl, CollectionHelpersCall<()>, true);283generate_stubgen!(collection_helper_iface, CollectionHelpersCall<()>, false);284285fn error_feild_too_long(feild: &str, bound: usize) -> Error {286	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))287}
after · pallets/unique/src/eth/mod.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//! Implementation of CollectionHelpers contract.1819use core::marker::PhantomData;20use evm_coder::{execution::*, generate_stubgen, solidity_interface, solidity, weight, types::*};21use ethereum as _;22use pallet_evm_coder_substrate::{SubstrateRecorder, WithRecorder};23use pallet_evm::{OnMethodCall, PrecompileResult, account::CrossAccountId, PrecompileHandle};24use up_data_structs::{25	CollectionName, CollectionDescription, CollectionTokenPrefix, CreateCollectionData,26	CollectionMode, PropertyValue,27};28use frame_support::traits::Get;29use pallet_common::{30	CollectionById,31	erc::{static_property::{key, value as property_value}, CollectionHelpersEvents},32};33use crate::{SelfWeightOf, Config, weights::WeightInfo};3435use sp_std::vec::Vec;36use alloc::format;3738/// See [`CollectionHelpersCall`]39pub struct EvmCollectionHelpers<T: Config>(SubstrateRecorder<T>);40impl<T: Config> WithRecorder<T> for EvmCollectionHelpers<T> {41	fn recorder(&self) -> &SubstrateRecorder<T> {42		&self.043	}4445	fn into_recorder(self) -> SubstrateRecorder<T> {46		self.047	}48}4950fn convert_data<T: Config>(51	caller: caller,52	name: string,53	description: string,54	token_prefix: string,55	base_uri: string,56) -> Result<(57	T::CrossAccountId,58	CollectionName,59	CollectionDescription,60	CollectionTokenPrefix,61	PropertyValue,62)> {63	let caller = T::CrossAccountId::from_eth(caller);64	let name = name65		.encode_utf16()66		.collect::<Vec<u16>>()67		.try_into()68		.map_err(|_| error_feild_too_long(stringify!(name), CollectionName::bound()))?;69	let description = description70		.encode_utf16()71		.collect::<Vec<u16>>()72		.try_into()73		.map_err(|_| {74			error_feild_too_long(stringify!(description), CollectionDescription::bound())75		})?;76	let token_prefix = token_prefix.into_bytes().try_into().map_err(|_| {77		error_feild_too_long(stringify!(token_prefix), CollectionTokenPrefix::bound())78	})?;79	let base_uri_value = base_uri80		.into_bytes()81		.try_into()82		.map_err(|_| error_feild_too_long(stringify!(token_prefix), PropertyValue::bound()))?;83	Ok((caller, name, description, token_prefix, base_uri_value))84}8586fn make_data<T: Config>(87	name: CollectionName,88	mode: CollectionMode,89	description: CollectionDescription,90	token_prefix: CollectionTokenPrefix,91	base_uri_value: PropertyValue,92	add_properties: bool,93) -> Result<CreateCollectionData<T::AccountId>> {94	let mut properties = up_data_structs::CollectionPropertiesVec::default();95	let mut token_property_permissions =96		up_data_structs::CollectionPropertiesPermissionsVec::default();9798	token_property_permissions99		.try_push(up_data_structs::PropertyKeyPermission {100			key: key::url(),101			permission: up_data_structs::PropertyPermission {102				mutable: false,103				collection_admin: true,104				token_owner: false,105			},106		})107		.map_err(|e| Error::Revert(format!("{:?}", e)))?;108109	if add_properties {110		token_property_permissions111			.try_push(up_data_structs::PropertyKeyPermission {112				key: key::suffix(),113				permission: up_data_structs::PropertyPermission {114					mutable: false,115					collection_admin: true,116					token_owner: false,117				},118			})119			.map_err(|e| Error::Revert(format!("{:?}", e)))?;120121		properties122			.try_push(up_data_structs::Property {123				key: key::schema_name(),124				value: property_value::erc721(),125			})126			.map_err(|e| Error::Revert(format!("{:?}", e)))?;127128		if !base_uri_value.is_empty() {129			properties130				.try_push(up_data_structs::Property {131					key: key::base_uri(),132					value: base_uri_value,133				})134				.map_err(|e| Error::Revert(format!("{:?}", e)))?;135		}136	}137138	let data = CreateCollectionData {139		name,140		mode,141		description,142		token_prefix,143		token_property_permissions,144		properties,145		..Default::default()146	};147	Ok(data)148}149150/// @title Contract, which allows users to operate with collections151#[solidity_interface(name = "CollectionHelpers", events(CollectionHelpersEvents))]152impl<T> EvmCollectionHelpers<T>153where154	T: Config + pallet_nonfungible::Config + pallet_refungible::Config,155{156	/// Create an NFT collection157	/// @param name Name of the collection158	/// @param description Informative description of the collection159	/// @param token_prefix Token prefix to represent the collection tokens in UI and user applications160	/// @return address Address of the newly created collection161	#[weight(<SelfWeightOf<T>>::create_collection())]162	fn create_nonfungible_collection(163		&mut self,164		caller: caller,165		name: string,166		description: string,167		token_prefix: string,168	) -> Result<address> {169		let (caller, name, description, token_prefix, _base_uri_value) =170			convert_data::<T>(caller, name, description, token_prefix, "".into())?;171		let data = make_data::<T>(172			name,173			CollectionMode::NFT,174			description,175			token_prefix,176			Default::default(),177			false,178		)?;179		let collection_id =180			<pallet_nonfungible::Pallet<T>>::init_collection(caller.clone(), data, false)181				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;182183		let address = pallet_common::eth::collection_id_to_address(collection_id);184		Ok(address)185	}186187	#[weight(<SelfWeightOf<T>>::create_collection())]188	#[solidity(rename_selector = "createERC721MetadataCompatibleCollection")]189	fn create_nonfungible_collection_with_properties(190		&mut self,191		caller: caller,192		name: string,193		description: string,194		token_prefix: string,195		base_uri: string,196	) -> Result<address> {197		let (caller, name, description, token_prefix, base_uri_value) =198			convert_data::<T>(caller, name, description, token_prefix, base_uri)?;199		let data = make_data::<T>(200			name,201			CollectionMode::NFT,202			description,203			token_prefix,204			base_uri_value,205			true,206		)?;207		let collection_id =208			<pallet_nonfungible::Pallet<T>>::init_collection(caller.clone(), data, true)209				.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;210211		let address = pallet_common::eth::collection_id_to_address(collection_id);212		Ok(address)213	}214215	#[weight(<SelfWeightOf<T>>::create_collection())]216	fn create_refungible_collection(217		&self,218		caller: caller,219		name: string,220		description: string,221		token_prefix: string,222	) -> Result<address> {223		let (caller, name, description, token_prefix, _base_uri) =224			convert_data::<T>(caller, name, description, token_prefix, "".into())?;225		let data = make_data::<T>(226			name,227			CollectionMode::ReFungible,228			description,229			token_prefix,230			Default::default(),231			false,232		)?;233		let collection_id = <pallet_refungible::Pallet<T>>::init_collection(caller.clone(), data)234			.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;235236		let address = pallet_common::eth::collection_id_to_address(collection_id);237		Ok(address)238	}239240	#[weight(<SelfWeightOf<T>>::create_collection())]241	#[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]242	fn create_refungible_collection_with_properties(243		&mut self,244		caller: caller,245		name: string,246		description: string,247		token_prefix: string,248		base_uri: string,249	) -> Result<address> {250		let (caller, name, description, token_prefix, base_uri_value) =251			convert_data::<T>(caller, name, description, token_prefix, base_uri)?;252		let data = make_data::<T>(253			name,254			CollectionMode::NFT,255			description,256			token_prefix,257			base_uri_value,258			true,259		)?;260		let collection_id = <pallet_refungible::Pallet<T>>::init_collection(caller.clone(), data)261			.map_err(pallet_evm_coder_substrate::dispatch_to_evm::<T>)?;262263		let address = pallet_common::eth::collection_id_to_address(collection_id);264		Ok(address)265	}266267	/// Check if a collection exists268	/// @param collection_address Address of the collection in question269	/// @return bool Does the collection exist?270	fn is_collection_exist(&self, _caller: caller, collection_address: address) -> Result<bool> {271		if let Some(id) = pallet_common::eth::map_eth_to_id(&collection_address) {272			let collection_id = id;273			return Ok(<CollectionById<T>>::contains_key(collection_id));274		}275276		Ok(false)277	}278}279280/// Implements [`OnMethodCall`], which delegates call to [`EvmCollectionHelpers`]281pub struct CollectionHelpersOnMethodCall<T: Config>(PhantomData<*const T>);282impl<T: Config + pallet_nonfungible::Config + pallet_refungible::Config> OnMethodCall<T>283	for CollectionHelpersOnMethodCall<T>284{285	fn is_reserved(contract: &sp_core::H160) -> bool {286		contract == &T::ContractAddress::get()287	}288289	fn is_used(contract: &sp_core::H160) -> bool {290		contract == &T::ContractAddress::get()291	}292293	fn call(handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {294		if handle.code_address() != T::ContractAddress::get() {295			return None;296		}297298		let helpers =299			EvmCollectionHelpers::<T>(SubstrateRecorder::<T>::new(handle.remaining_gas()));300		pallet_evm_coder_substrate::call(handle, helpers)301	}302303	fn get_code(contract: &sp_core::H160) -> Option<Vec<u8>> {304		(contract == &T::ContractAddress::get())305			.then(|| include_bytes!("./stubs/CollectionHelpers.raw").to_vec())306	}307}308309generate_stubgen!(collection_helper_impl, CollectionHelpersCall<()>, true);310generate_stubgen!(collection_helper_iface, CollectionHelpersCall<()>, false);311312fn error_feild_too_long(feild: &str, bound: usize) -> Error {313	Error::Revert(format!("{} is too long. Max length is {}.", feild, bound))314}
addedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
--- /dev/null
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -0,0 +1,163 @@
+// SPDX-License-Identifier: OTHER
+// This code is automatically generated
+
+pragma solidity >=0.8.0 <0.9.0;
+
+// Common stubs holder
+interface Dummy {
+
+}
+
+interface ERC165 is Dummy {
+	function supportsInterface(bytes4 interfaceID) external view returns (bool);
+}
+
+// Selector: 7d9262e6
+interface Collection is Dummy, ERC165 {
+	// Set collection property.
+	//
+	// @param key Property key.
+	// @param value Propery value.
+	//
+	// Selector: setCollectionProperty(string,bytes) 2f073f66
+	function setCollectionProperty(string memory key, bytes memory value)
+		external;
+
+	// Delete collection property.
+	//
+	// @param key Property key.
+	//
+	// Selector: deleteCollectionProperty(string) 7b7debce
+	function deleteCollectionProperty(string memory key) external;
+
+	// Get collection property.
+	//
+	// @dev Throws error if key not found.
+	//
+	// @param key Property key.
+	// @return bytes The property corresponding to the key.
+	//
+	// Selector: collectionProperty(string) cf24fd6d
+	function collectionProperty(string memory key)
+		external
+		view
+		returns (bytes memory);
+
+	// Set the sponsor of the collection.
+	//
+	// @dev In order for sponsorship to work, it must be confirmed on behalf of the sponsor.
+	//
+	// @param sponsor Address of the sponsor from whose account funds will be debited for operations with the contract.
+	//
+	// Selector: setCollectionSponsor(address) 7623402e
+	function setCollectionSponsor(address sponsor) external;
+
+	// Collection sponsorship confirmation.
+	//
+	// @dev After setting the sponsor for the collection, it must be confirmed with this function.
+	//
+	// Selector: confirmCollectionSponsorship() 3c50e97a
+	function confirmCollectionSponsorship() external;
+
+	// Set limits for the collection.
+	// @dev Throws error if limit not found.
+	// @param limit Name of the limit. Valid names:
+	// 	"accountTokenOwnershipLimit",
+	// 	"sponsoredDataSize",
+	// 	"sponsoredDataRateLimit",
+	// 	"tokenLimit",
+	// 	"sponsorTransferTimeout",
+	// 	"sponsorApproveTimeout"
+	// @param value Value of the limit.
+	//
+	// Selector: setCollectionLimit(string,uint32) 6a3841db
+	function setCollectionLimit(string memory limit, uint32 value) external;
+
+	// Set limits for the collection.
+	// @dev Throws error if limit not found.
+	// @param limit Name of the limit. Valid names:
+	// 	"ownerCanTransfer",
+	// 	"ownerCanDestroy",
+	// 	"transfersEnabled"
+	// @param value Value of the limit.
+	//
+	// Selector: setCollectionLimit(string,bool) 993b7fba
+	function setCollectionLimit(string memory limit, bool value) external;
+
+	// Get contract address.
+	//
+	// Selector: contractAddress() f6b4dfb4
+	function contractAddress() external view returns (address);
+
+	// Add collection admin by substrate address.
+	// @param new_admin Substrate administrator address.
+	//
+	// Selector: addCollectionAdminSubstrate(uint256) 5730062b
+	function addCollectionAdminSubstrate(uint256 newAdmin) external;
+
+	// Remove collection admin by substrate address.
+	// @param admin Substrate administrator address.
+	//
+	// Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9
+	function removeCollectionAdminSubstrate(uint256 admin) external;
+
+	// Add collection admin.
+	// @param new_admin Address of the added administrator.
+	//
+	// Selector: addCollectionAdmin(address) 92e462c7
+	function addCollectionAdmin(address newAdmin) external;
+
+	// Remove collection admin.
+	//
+	// @param new_admin Address of the removed administrator.
+	//
+	// Selector: removeCollectionAdmin(address) fafd7b42
+	function removeCollectionAdmin(address admin) external;
+
+	// Toggle accessibility of collection nesting.
+	//
+	// @param enable If "true" degenerates to nesting: 'Owner' else to nesting: 'Disabled'
+	//
+	// Selector: setCollectionNesting(bool) 112d4586
+	function setCollectionNesting(bool enable) external;
+
+	// Toggle accessibility of collection nesting.
+	//
+	// @param enable If "true" degenerates to nesting: {OwnerRestricted: [1, 2, 3]} else to nesting: 'Disabled'
+	// @param collections Addresses of collections that will be available for nesting.
+	//
+	// Selector: setCollectionNesting(bool,address[]) 64872396
+	function setCollectionNesting(bool enable, address[] memory collections)
+		external;
+
+	// Set the collection access method.
+	// @param mode Access mode
+	// 	0 for Normal
+	// 	1 for AllowList
+	//
+	// Selector: setCollectionAccess(uint8) 41835d4c
+	function setCollectionAccess(uint8 mode) external;
+
+	// Add the user to the allowed list.
+	//
+	// @param user Address of a trusted user.
+	//
+	// Selector: addToCollectionAllowList(address) 67844fe6
+	function addToCollectionAllowList(address user) external;
+
+	// Remove the user from the allowed list.
+	//
+	// @param user Address of a removed user.
+	//
+	// Selector: removeFromCollectionAllowList(address) 85c51acb
+	function removeFromCollectionAllowList(address user) external;
+
+	// Switch permission for minting.
+	//
+	// @param mode Enable if "true".
+	//
+	// Selector: setCollectionMintMode(bool) 00018e84
+	function setCollectionMintMode(bool mode) external;
+}
+
+interface UniqueRefungible is Dummy, ERC165, Collection {}
modifiedtests/src/eth/nonFungible.test.tsdiffbeforeafterboth
--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -72,7 +72,7 @@
   });
 });
 
-describe('Check ERC721 token URI', () => {
+describe('Check ERC721 token URI for NFT', () => {
   itWeb3('Empty tokenURI', async ({web3, api, privateKeyWrapper}) => {
     const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
     const helper = evmCollectionHelpers(web3, owner);
modifiedtests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth
--- a/tests/src/eth/reFungibleToken.test.ts
+++ b/tests/src/eth/reFungibleToken.test.ts
@@ -15,7 +15,7 @@
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
 import {approve, createCollection, createRefungibleToken, transfer, transferFrom, UNIQUE} from '../util/helpers';
-import {createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth} from './util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, tokenIdToAddress, transferBalanceToEth} from './util/helpers';
 import reFungibleTokenAbi from './reFungibleTokenAbi.json';
 
 import chai from 'chai';
@@ -73,6 +73,148 @@
   });
 });
 
+// FIXME: Need erc721 for ReFubgible.
+describe.skip('Check ERC721 token URI for ReFungible', () => {
+  itWeb3('Empty tokenURI', async ({web3, api, privateKeyWrapper}) => {
+    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const helper = evmCollectionHelpers(web3, owner);
+    let result = await helper.methods.createERC721MetadataCompatibleCollection('Mint collection', '1', '1', '').send();
+    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+    const receiver = createEthAccount(web3);
+    const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
+    
+    const nextTokenId = await contract.methods.nextTokenId().call();
+    expect(nextTokenId).to.be.equal('1');
+    result = await contract.methods.mint(
+      receiver,
+      nextTokenId,
+    ).send();
+
+    const events = normalizeEvents(result.events);
+    const address = collectionIdToAddress(collectionId);
+
+    expect(events).to.be.deep.equal([
+      {
+        address,
+        event: 'Transfer',
+        args: {
+          from: '0x0000000000000000000000000000000000000000',
+          to: receiver,
+          tokenId: nextTokenId,
+        },
+      },
+    ]);
+
+    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('');
+  });
+
+  itWeb3('TokenURI from url', async ({web3, api, privateKeyWrapper}) => {
+    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const helper = evmCollectionHelpers(web3, owner);
+    let result = await helper.methods.createERC721MetadataCompatibleCollection('Mint collection', '1', '1', 'BaseURI_').send();
+    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+    const receiver = createEthAccount(web3);
+    const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
+    
+    const nextTokenId = await contract.methods.nextTokenId().call();
+    expect(nextTokenId).to.be.equal('1');
+    result = await contract.methods.mint(
+      receiver,
+      nextTokenId,
+    ).send();
+    
+    // Set URL
+    await contract.methods.setProperty(nextTokenId, 'url', Buffer.from('Token URI')).send();
+      
+    const events = normalizeEvents(result.events);
+    const address = collectionIdToAddress(collectionId);
+
+    expect(events).to.be.deep.equal([
+      {
+        address,
+        event: 'Transfer',
+        args: {
+          from: '0x0000000000000000000000000000000000000000',
+          to: receiver,
+          tokenId: nextTokenId,
+        },
+      },
+    ]);
+
+    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Token URI');
+  });
+
+  itWeb3('TokenURI from baseURI + tokenId', async ({web3, api, privateKeyWrapper}) => {
+    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const helper = evmCollectionHelpers(web3, owner);
+    let result = await helper.methods.createERC721MetadataCompatibleCollection('Mint collection', '1', '1', 'BaseURI_').send();
+    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+    const receiver = createEthAccount(web3);
+    const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
+    
+    const nextTokenId = await contract.methods.nextTokenId().call();
+    expect(nextTokenId).to.be.equal('1');
+    result = await contract.methods.mint(
+      receiver,
+      nextTokenId,
+    ).send();
+          
+    const events = normalizeEvents(result.events);
+    const address = collectionIdToAddress(collectionId);
+
+    expect(events).to.be.deep.equal([
+      {
+        address,
+        event: 'Transfer',
+        args: {
+          from: '0x0000000000000000000000000000000000000000',
+          to: receiver,
+          tokenId: nextTokenId,
+        },
+      },
+    ]);
+
+    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + nextTokenId);
+  });
+
+  itWeb3('TokenURI from baseURI + suffix', async ({web3, api, privateKeyWrapper}) => {
+    const owner = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+    const helper = evmCollectionHelpers(web3, owner);
+    let result = await helper.methods.createERC721MetadataCompatibleCollection('Mint collection', '1', '1', 'BaseURI_').send();
+    const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
+    const receiver = createEthAccount(web3);
+    const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
+    
+    const nextTokenId = await contract.methods.nextTokenId().call();
+    expect(nextTokenId).to.be.equal('1');
+    result = await contract.methods.mint(
+      receiver,
+      nextTokenId,
+    ).send();
+          
+    // Set suffix
+    const suffix = '/some/suffix';
+    await contract.methods.setProperty(nextTokenId, 'suffix', Buffer.from(suffix)).send();
+
+    const events = normalizeEvents(result.events);
+    const address = collectionIdToAddress(collectionId);
+
+    expect(events).to.be.deep.equal([
+      {
+        address,
+        event: 'Transfer',
+        args: {
+          from: '0x0000000000000000000000000000000000000000',
+          to: receiver,
+          tokenId: nextTokenId,
+        },
+      },
+    ]);
+
+    expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('BaseURI_' + suffix);
+  });
+});
+
 describe('Refungible: Plain calls', () => {
   itWeb3('Can perform approve()', async ({web3, api, privateKeyWrapper}) => {
     const alice = privateKeyWrapper('//Alice');