git.delta.rocks / unique-network / refs/commits / 4bd95ca73321

difftreelog

doc: fix code review request

Grigoriy Simonov2022-07-21parent: #395c681.patch.diff
in: master

1 file changed

modifiedpallets/nonfungible/src/erc.rsdiffbeforeafterboth
before · pallets/nonfungible/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//! # Nonfungible Pallet EVM API18//!19//! Provides ERC-721 standart support implementation and EVM API for unique extensions for Nonfungible Pallet.20//! Method implementations are mostly doing parameter conversion and calling Nonfungible Pallet methods.2122extern crate alloc;23use core::{24	char::{REPLACEMENT_CHARACTER, decode_utf16},25	convert::TryInto,26};27use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};28use frame_support::BoundedVec;29use up_data_structs::{30	TokenId, PropertyPermission, PropertyKeyPermission, Property, CollectionId, PropertyKey,31	CollectionPropertiesVec,32};33use pallet_evm_coder_substrate::dispatch_to_evm;34use sp_std::vec::Vec;35use pallet_common::{36	erc::{CommonEvmHandler, PrecompileResult, CollectionCall, token_uri_key},37	CollectionHandle, CollectionPropertyPermissions,38};39use pallet_evm::{account::CrossAccountId, PrecompileHandle};40use pallet_evm_coder_substrate::call;41use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};4243use crate::{44	AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,45	SelfWeightOf, weights::WeightInfo, TokenProperties,46};4748/// @title A contract that allows to set and delete token properties and change token property permissions.49///50#[solidity_interface(name = "TokenProperties")]51impl<T: Config> NonfungibleHandle<T> {52	/// @notice Set permissions for token property.53	/// @dev Throws error if `msg.sender` is not admin or owner of the collection.54	/// @param key Property key.55	/// @param is_mutable Permission to mutate property.56	/// @param collection_admin Permission to mutate property by collection admin if property is mutable.57	/// @param token_owner Permission to mutate property by token owner if property is mutable.58	fn set_token_property_permission(59		&mut self,60		caller: caller,61		key: string,62		is_mutable: bool,63		collection_admin: bool,64		token_owner: bool,65	) -> Result<()> {66		let caller = T::CrossAccountId::from_eth(caller);67		<Pallet<T>>::set_property_permission(68			self,69			&caller,70			PropertyKeyPermission {71				key: <Vec<u8>>::from(key)72					.try_into()73					.map_err(|_| "too long key")?,74				permission: PropertyPermission {75					mutable: is_mutable,76					collection_admin,77					token_owner,78				},79			},80		)81		.map_err(dispatch_to_evm::<T>)82	}8384	/// @notice Set token property value.85	/// @dev Throws error if `msg.sender` has no permission to edit the property.86	/// @param tokenId ID of the token.87	/// @param key Property key.88	/// @param value Property value.89	fn set_property(90		&mut self,91		caller: caller,92		token_id: uint256,93		key: string,94		value: bytes,95	) -> Result<()> {96		let caller = T::CrossAccountId::from_eth(caller);97		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;98		let key = <Vec<u8>>::from(key)99			.try_into()100			.map_err(|_| "key too long")?;101		let value = value.try_into().map_err(|_| "value too long")?;102103		let nesting_budget = self104			.recorder105			.weight_calls_budget(<StructureWeight<T>>::find_parent());106107		<Pallet<T>>::set_token_property(108			self,109			&caller,110			TokenId(token_id),111			Property { key, value },112			&nesting_budget,113		)114		.map_err(dispatch_to_evm::<T>)115	}116117	/// @notice Delete token property value.118	/// @dev Throws error if `msg.sender` has no permission to edit the property.119	/// @param tokenId ID of the token.120	/// @param key Property key.121	fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {122		let caller = T::CrossAccountId::from_eth(caller);123		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;124		let key = <Vec<u8>>::from(key)125			.try_into()126			.map_err(|_| "key too long")?;127128		let nesting_budget = self129			.recorder130			.weight_calls_budget(<StructureWeight<T>>::find_parent());131132		<Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)133			.map_err(dispatch_to_evm::<T>)134	}135136	/// @notice Get token property value.137	/// @dev Throws error if key not found138	/// @param tokenId ID of the token.139	/// @param key Property key.140	/// @return Property value bytes141	fn property(&self, token_id: uint256, key: string) -> Result<bytes> {142		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;143		let key = <Vec<u8>>::from(key)144			.try_into()145			.map_err(|_| "key too long")?;146147		let props = <TokenProperties<T>>::get((self.id, token_id));148		let prop = props.get(&key).ok_or("key not found")?;149150		Ok(prop.to_vec())151	}152}153154#[derive(ToLog)]155pub enum ERC721Events {156	/// @dev This emits when ownership of any NFT changes by any mechanism.157	///  This event emits when NFTs are created (`from` == 0) and destroyed158	///  (`to` == 0). Exception: during contract creation, any number of NFTs159	///  may be created and assigned without emitting Transfer. At the time of160	///  any transfer, the approved address for that NFT (if any) is reset to none.161	Transfer {162		#[indexed]163		from: address,164		#[indexed]165		to: address,166		#[indexed]167		token_id: uint256,168	},169	/// @dev This emits when the approved address for an NFT is changed or170	///  reaffirmed. The zero address indicates there is no approved address.171	///  When a Transfer event emits, this also indicates that the approved172	///  address for that NFT (if any) is reset to none.173	Approval {174		#[indexed]175		owner: address,176		#[indexed]177		approved: address,178		#[indexed]179		token_id: uint256,180	},181	/// @dev This emits when an operator is enabled or disabled for an owner.182	///  The operator can manage all NFTs of the owner.183	#[allow(dead_code)]184	ApprovalForAll {185		#[indexed]186		owner: address,187		#[indexed]188		operator: address,189		approved: bool,190	},191}192193#[derive(ToLog)]194pub enum ERC721MintableEvents {195	#[allow(dead_code)]196	MintingFinished {},197}198199/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension200/// @dev See https://eips.ethereum.org/EIPS/eip-721201#[solidity_interface(name = "ERC721Metadata")]202impl<T: Config> NonfungibleHandle<T> {203	/// @notice A descriptive name for a collection of NFTs in this contract204	fn name(&self) -> Result<string> {205		Ok(decode_utf16(self.name.iter().copied())206			.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))207			.collect::<string>())208	}209210	/// @notice An abbreviated name for NFTs in this contract211	fn symbol(&self) -> Result<string> {212		Ok(string::from_utf8_lossy(&self.token_prefix).into())213	}214215	/// @notice A distinct Uniform Resource Identifier (URI) for a given asset.216	/// @dev Throws if `tokenId` is not a valid NFT. URIs are defined in RFC217	///  3986. The URI may point to a JSON file that conforms to the "ERC721218	///  Metadata JSON Schema".219	/// @return token's const_metadata220	#[solidity(rename_selector = "tokenURI")]221	fn token_uri(&self, token_id: uint256) -> Result<string> {222		let key = token_uri_key();223		if !has_token_permission::<T>(self.id, &key) {224			return Err("No tokenURI permission".into());225		}226227		self.consume_store_reads(1)?;228		let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;229230		let properties = <TokenProperties<T>>::try_get((self.id, token_id))231			.map_err(|_| Error::Revert("Token properties not found".into()))?;232		if let Some(property) = properties.get(&key) {233			return Ok(string::from_utf8_lossy(property).into());234		}235236		Err("Property tokenURI not found".into())237	}238}239240/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension241/// @dev See https://eips.ethereum.org/EIPS/eip-721242#[solidity_interface(name = "ERC721Enumerable")]243impl<T: Config> NonfungibleHandle<T> {244	/// @notice Enumerate valid NFTs245	/// @param index A counter less than `totalSupply()`246	/// @return The token identifier for the `index`th NFT,247	///  (sort order not specified)248	fn token_by_index(&self, index: uint256) -> Result<uint256> {249		Ok(index)250	}251252	/// @dev Not implemented253	fn token_of_owner_by_index(&self, _owner: address, _index: uint256) -> Result<uint256> {254		// TODO: Not implemetable255		Err("not implemented".into())256	}257258	/// @notice Count NFTs tracked by this contract259	/// @return A count of valid NFTs tracked by this contract, where each one of260	///  them has an assigned and queryable owner not equal to the zero address261	fn total_supply(&self) -> Result<uint256> {262		self.consume_store_reads(1)?;263		Ok(<Pallet<T>>::total_supply(self).into())264	}265}266267/// @title ERC-721 Non-Fungible Token Standard268/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md269#[solidity_interface(name = "ERC721", events(ERC721Events))]270impl<T: Config> NonfungibleHandle<T> {271	/// @notice Count all NFTs assigned to an owner272	/// @dev NFTs assigned to the zero address are considered invalid, and this273	///  function throws for queries about the zero address.274	/// @param owner An address for whom to query the balance275	/// @return The number of NFTs owned by `owner`, possibly zero276	fn balance_of(&self, owner: address) -> Result<uint256> {277		self.consume_store_reads(1)?;278		let owner = T::CrossAccountId::from_eth(owner);279		let balance = <AccountBalance<T>>::get((self.id, owner));280		Ok(balance.into())281	}282	/// @notice Find the owner of an NFT283	/// @dev NFTs assigned to zero address are considered invalid, and queries284	///  about them do throw.285	/// @param tokenId The identifier for an NFT286	/// @return The address of the owner of the NFT287	fn owner_of(&self, token_id: uint256) -> Result<address> {288		self.consume_store_reads(1)?;289		let token: TokenId = token_id.try_into()?;290		Ok(*<TokenData<T>>::get((self.id, token))291			.ok_or("token not found")?292			.owner293			.as_eth())294	}295	/// @dev Not implemented296	fn safe_transfer_from_with_data(297		&mut self,298		_from: address,299		_to: address,300		_token_id: uint256,301		_data: bytes,302		_value: value,303	) -> Result<void> {304		// TODO: Not implemetable305		Err("not implemented".into())306	}307	/// @dev Not implemented308	fn safe_transfer_from(309		&mut self,310		_from: address,311		_to: address,312		_token_id: uint256,313		_value: value,314	) -> Result<void> {315		// TODO: Not implemetable316		Err("not implemented".into())317	}318319	/// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE320	///  TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE321	///  THEY MAY BE PERMANENTLY LOST322	/// @dev Throws unless `msg.sender` is the current owner or an authorized323	///  operator for this NFT. Throws if `from` is not the current owner. Throws324	///  if `to` is the zero address. Throws if `tokenId` is not a valid NFT.325	/// @param from The current owner of the NFT326	/// @param to The new owner327	/// @param tokenId The NFT to transfer328	/// @param _value Not used for an NFT329	#[weight(<SelfWeightOf<T>>::transfer_from())]330	fn transfer_from(331		&mut self,332		caller: caller,333		from: address,334		to: address,335		token_id: uint256,336		_value: value,337	) -> Result<void> {338		let caller = T::CrossAccountId::from_eth(caller);339		let from = T::CrossAccountId::from_eth(from);340		let to = T::CrossAccountId::from_eth(to);341		let token = token_id.try_into()?;342		let budget = self343			.recorder344			.weight_calls_budget(<StructureWeight<T>>::find_parent());345346		<Pallet<T>>::transfer_from(self, &caller, &from, &to, token, &budget)347			.map_err(dispatch_to_evm::<T>)?;348		Ok(())349	}350351	/// @notice Set or reaffirm the approved address for an NFT352	/// @dev The zero address indicates there is no approved address.353	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized354	///  operator of the current owner.355	/// @param approved The new approved NFT controller356	/// @param tokenId The NFT to approve357	#[weight(<SelfWeightOf<T>>::approve())]358	fn approve(359		&mut self,360		caller: caller,361		approved: address,362		token_id: uint256,363		_value: value,364	) -> Result<void> {365		let caller = T::CrossAccountId::from_eth(caller);366		let approved = T::CrossAccountId::from_eth(approved);367		let token = token_id.try_into()?;368369		<Pallet<T>>::set_allowance(self, &caller, token, Some(&approved))370			.map_err(dispatch_to_evm::<T>)?;371		Ok(())372	}373374	/// @dev Not implemented375	fn set_approval_for_all(376		&mut self,377		_caller: caller,378		_operator: address,379		_approved: bool,380	) -> Result<void> {381		// TODO: Not implemetable382		Err("not implemented".into())383	}384385	/// @dev Not implemented386	fn get_approved(&self, _token_id: uint256) -> Result<address> {387		// TODO: Not implemetable388		Err("not implemented".into())389	}390391	/// @dev Not implemented392	fn is_approved_for_all(&self, _owner: address, _operator: address) -> Result<address> {393		// TODO: Not implemetable394		Err("not implemented".into())395	}396}397398/// @title ERC721 Token that can be irreversibly burned (destroyed).399#[solidity_interface(name = "ERC721Burnable")]400impl<T: Config> NonfungibleHandle<T> {401	/// @notice Burns a specific ERC721 token.402	/// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized403	///  operator of the current owner.404	/// @param tokenId The NFT to approve405	#[weight(<SelfWeightOf<T>>::burn_item())]406	fn burn(&mut self, caller: caller, token_id: uint256) -> Result<void> {407		let caller = T::CrossAccountId::from_eth(caller);408		let token = token_id.try_into()?;409410		<Pallet<T>>::burn(self, &caller, token).map_err(dispatch_to_evm::<T>)?;411		Ok(())412	}413}414415/// @title ERC721 minting logic.416#[solidity_interface(name = "ERC721Mintable", events(ERC721MintableEvents))]417impl<T: Config> NonfungibleHandle<T> {418	fn minting_finished(&self) -> Result<bool> {419		Ok(false)420	}421422	/// @notice Function to mint token.423	/// @dev `tokenId` should be obtained with `nextTokenId` method,424	///  unlike standard, you can't specify it manually425	/// @param to The new owner426	/// @param tokenId ID of the minted NFT427	#[weight(<SelfWeightOf<T>>::create_item())]428	fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {429		let caller = T::CrossAccountId::from_eth(caller);430		let to = T::CrossAccountId::from_eth(to);431		let token_id: u32 = token_id.try_into()?;432		let budget = self433			.recorder434			.weight_calls_budget(<StructureWeight<T>>::find_parent());435436		if <TokensMinted<T>>::get(self.id)437			.checked_add(1)438			.ok_or("item id overflow")?439			!= token_id440		{441			return Err("item id should be next".into());442		}443444		<Pallet<T>>::create_item(445			self,446			&caller,447			CreateItemData::<T> {448				properties: BoundedVec::default(),449				owner: to,450			},451			&budget,452		)453		.map_err(dispatch_to_evm::<T>)?;454455		Ok(true)456	}457458	/// @notice Function to mint token with the given tokenUri.459	/// @dev `tokenId` should be obtained with `nextTokenId` method,460	///  unlike standard, you can't specify it manually461	/// @param to The new owner462	/// @param tokenId ID of the minted NFT463	/// @param tokenUri Token URI that would be stored in the NFT properties464	#[solidity(rename_selector = "mintWithTokenURI")]465	#[weight(<SelfWeightOf<T>>::create_item())]466	fn mint_with_token_uri(467		&mut self,468		caller: caller,469		to: address,470		token_id: uint256,471		token_uri: string,472	) -> Result<bool> {473		let key = token_uri_key();474		let permission = get_token_permission::<T>(self.id, &key)?;475		if !permission.collection_admin {476			return Err("Operation is not allowed".into());477		}478479		let caller = T::CrossAccountId::from_eth(caller);480		let to = T::CrossAccountId::from_eth(to);481		let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;482		let budget = self483			.recorder484			.weight_calls_budget(<StructureWeight<T>>::find_parent());485486		if <TokensMinted<T>>::get(self.id)487			.checked_add(1)488			.ok_or("item id overflow")?489			!= token_id490		{491			return Err("item id should be next".into());492		}493494		let mut properties = CollectionPropertiesVec::default();495		properties496			.try_push(Property {497				key,498				value: token_uri499					.into_bytes()500					.try_into()501					.map_err(|_| "token uri is too long")?,502			})503			.map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;504505		<Pallet<T>>::create_item(506			self,507			&caller,508			CreateItemData::<T> {509				properties,510				owner: to,511			},512			&budget,513		)514		.map_err(dispatch_to_evm::<T>)?;515		Ok(true)516	}517518	/// @dev Not implemented519	fn finish_minting(&mut self, _caller: caller) -> Result<bool> {520		Err("not implementable".into())521	}522}523524fn get_token_permission<T: Config>(525	collection_id: CollectionId,526	key: &PropertyKey,527) -> Result<PropertyPermission> {528	let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)529		.map_err(|_| Error::Revert("No permissions for collection".into()))?;530	let a = token_property_permissions531		.get(key)532		.map(|p| p.clone())533		.ok_or_else(|| Error::Revert("No permission".into()))?;534	Ok(a)535}536537fn has_token_permission<T: Config>(collection_id: CollectionId, key: &PropertyKey) -> bool {538	if let Ok(token_property_permissions) =539		CollectionPropertyPermissions::<T>::try_get(collection_id)540	{541		return token_property_permissions.contains_key(key);542	}543544	false545}546547/// @title Unique extensions for ERC721.548#[solidity_interface(name = "ERC721UniqueExtensions")]549impl<T: Config> NonfungibleHandle<T> {550	/// @notice Transfer ownership of an NFT551	/// @dev Throws unless `msg.sender` is the current owner. Throws if `to`552	///  is the zero address. Throws if `tokenId` is not a valid NFT.553	/// @param to The new owner554	/// @param tokenId The NFT to transfer555	/// @param _value Not used for an NFT556	#[weight(<SelfWeightOf<T>>::transfer())]557	fn transfer(558		&mut self,559		caller: caller,560		to: address,561		token_id: uint256,562		_value: value,563	) -> Result<void> {564		let caller = T::CrossAccountId::from_eth(caller);565		let to = T::CrossAccountId::from_eth(to);566		let token = token_id.try_into()?;567		let budget = self568			.recorder569			.weight_calls_budget(<StructureWeight<T>>::find_parent());570571		<Pallet<T>>::transfer(self, &caller, &to, token, &budget).map_err(dispatch_to_evm::<T>)?;572		Ok(())573	}574575	/// @notice Burns a specific ERC721 token.576	/// @dev Throws unless `msg.sender` is the current owner or an authorized577	///  operator for this NFT. Throws if `from` is not the current owner. Throws578	///  if `to` is the zero address. Throws if `tokenId` is not a valid NFT.579	/// @param from The current owner of the NFT580	/// @param tokenId The NFT to transfer581	/// @param _value Not used for an NFT582	#[weight(<SelfWeightOf<T>>::burn_from())]583	fn burn_from(584		&mut self,585		caller: caller,586		from: address,587		token_id: uint256,588		_value: value,589	) -> Result<void> {590		let caller = T::CrossAccountId::from_eth(caller);591		let from = T::CrossAccountId::from_eth(from);592		let token = token_id.try_into()?;593		let budget = self594			.recorder595			.weight_calls_budget(<StructureWeight<T>>::find_parent());596597		<Pallet<T>>::burn_from(self, &caller, &from, token, &budget)598			.map_err(dispatch_to_evm::<T>)?;599		Ok(())600	}601602	/// @notice Returns next free NFT ID.603	fn next_token_id(&self) -> Result<uint256> {604		self.consume_store_reads(1)?;605		Ok(<TokensMinted<T>>::get(self.id)606			.checked_add(1)607			.ok_or("item id overflow")?608			.into())609	}610611	/// @notice Function to mint multiple tokens.612	/// @dev `tokenIds` should be an array of consecutive numbers and first number613	///  should be obtained with `nextTokenId` method614	/// @param to The new owner615	/// @param tokenIds IDs of the minted NFTs616	#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]617	fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {618		let caller = T::CrossAccountId::from_eth(caller);619		let to = T::CrossAccountId::from_eth(to);620		let mut expected_index = <TokensMinted<T>>::get(self.id)621			.checked_add(1)622			.ok_or("item id overflow")?;623		let budget = self624			.recorder625			.weight_calls_budget(<StructureWeight<T>>::find_parent());626627		let total_tokens = token_ids.len();628		for id in token_ids.into_iter() {629			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;630			if id != expected_index {631				return Err("item id should be next".into());632			}633			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;634		}635		let data = (0..total_tokens)636			.map(|_| CreateItemData::<T> {637				properties: BoundedVec::default(),638				owner: to.clone(),639			})640			.collect();641642		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)643			.map_err(dispatch_to_evm::<T>)?;644		Ok(true)645	}646647	/// @notice Function to mint multiple tokens with the given tokenUris.648	/// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive649	///  numbers and first number should be obtained with `nextTokenId` method650	/// @param to The new owner651	/// @param tokens array of pairs of token ID and token URI for minted tokens652	#[solidity(rename_selector = "mintBulkWithTokenURI")]653	#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]654	fn mint_bulk_with_token_uri(655		&mut self,656		caller: caller,657		to: address,658		tokens: Vec<(uint256, string)>,659	) -> Result<bool> {660		let key = token_uri_key();661		let caller = T::CrossAccountId::from_eth(caller);662		let to = T::CrossAccountId::from_eth(to);663		let mut expected_index = <TokensMinted<T>>::get(self.id)664			.checked_add(1)665			.ok_or("item id overflow")?;666		let budget = self667			.recorder668			.weight_calls_budget(<StructureWeight<T>>::find_parent());669670		let mut data = Vec::with_capacity(tokens.len());671		for (id, token_uri) in tokens {672			let id: u32 = id.try_into().map_err(|_| "token id overflow")?;673			if id != expected_index {674				return Err("item id should be next".into());675			}676			expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;677678			let mut properties = CollectionPropertiesVec::default();679			properties680				.try_push(Property {681					key: key.clone(),682					value: token_uri683						.into_bytes()684						.try_into()685						.map_err(|_| "token uri is too long")?,686				})687				.map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;688689			data.push(CreateItemData::<T> {690				properties,691				owner: to.clone(),692			});693		}694695		<Pallet<T>>::create_multiple_items(self, &caller, data, &budget)696			.map_err(dispatch_to_evm::<T>)?;697		Ok(true)698	}699}700701#[solidity_interface(702	name = "UniqueNFT",703	is(704		ERC721,705		ERC721Metadata,706		ERC721Enumerable,707		ERC721UniqueExtensions,708		ERC721Mintable,709		ERC721Burnable,710		via("CollectionHandle<T>", common_mut, Collection),711		TokenProperties,712	)713)]714impl<T: Config> NonfungibleHandle<T> where T::AccountId: From<[u8; 32]> {}715716// Not a tests, but code generators717generate_stubgen!(gen_impl, UniqueNFTCall<()>, true);718generate_stubgen!(gen_iface, UniqueNFTCall<()>, false);719720impl<T: Config> CommonEvmHandler for NonfungibleHandle<T>721where722	T::AccountId: From<[u8; 32]>,723{724	const CODE: &'static [u8] = include_bytes!("./stubs/UniqueNFT.raw");725726	fn call(self, handle: &mut impl PrecompileHandle) -> Option<PrecompileResult> {727		call::<T, UniqueNFTCall<T>, _, _>(handle, self)728	}729}