12345678910111213141516171819202122extern crate alloc;2324use core::{25 char::{REPLACEMENT_CHARACTER, decode_utf16},26 convert::TryInto,27};28use evm_coder::{29 ToLog,30 execution::*,31 generate_stubgen, solidity, solidity_interface,32 types::*,33 weight,34 custom_signature::{SignatureUnit, FunctionSignature, SignaturePreferences},35 make_signature,36};37use frame_support::{BoundedBTreeMap, BoundedVec};38use pallet_common::{39 CollectionHandle, CollectionPropertyPermissions,40 erc::{CommonEvmHandler, CollectionCall, static_property::key},41};42use pallet_evm::{account::CrossAccountId, PrecompileHandle};43use pallet_evm_coder_substrate::{call, dispatch_to_evm};44use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};45use sp_core::H160;46use sp_std::{collections::btree_map::BTreeMap, vec::Vec, vec};47use up_data_structs::{48 CollectionId, CollectionPropertiesVec, mapping::TokenAddressMapping, Property, PropertyKey,49 PropertyKeyPermission, PropertyPermission, TokenId,50};5152use crate::{53 AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, SelfWeightOf,54 TokenProperties, TokensMinted, TotalSupply, weights::WeightInfo,55};5657pub const ADDRESS_FOR_PARTIALLY_OWNED_TOKENS: H160 = H160::repeat_byte(0xff);585960#[solidity_interface(name = TokenProperties)]61impl<T: Config> RefungibleHandle<T> {62 63 64 65 66 67 68 fn set_token_property_permission(69 &mut self,70 caller: caller,71 key: string,72 is_mutable: bool,73 collection_admin: bool,74 token_owner: bool,75 ) -> Result<()> {76 let caller = T::CrossAccountId::from_eth(caller);77 <Pallet<T>>::set_token_property_permissions(78 self,79 &caller,80 vec![PropertyKeyPermission {81 key: <Vec<u8>>::from(key)82 .try_into()83 .map_err(|_| "too long key")?,84 permission: PropertyPermission {85 mutable: is_mutable,86 collection_admin,87 token_owner,88 },89 }],90 )91 .map_err(dispatch_to_evm::<T>)92 }9394 95 96 97 98 99 fn set_property(100 &mut self,101 caller: caller,102 token_id: uint256,103 key: string,104 value: bytes,105 ) -> Result<()> {106 let caller = T::CrossAccountId::from_eth(caller);107 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;108 let key = <Vec<u8>>::from(key)109 .try_into()110 .map_err(|_| "key too long")?;111 let value = value.0.try_into().map_err(|_| "value too long")?;112113 let nesting_budget = self114 .recorder115 .weight_calls_budget(<StructureWeight<T>>::find_parent());116117 <Pallet<T>>::set_token_property(118 self,119 &caller,120 TokenId(token_id),121 Property { key, value },122 &nesting_budget,123 )124 .map_err(dispatch_to_evm::<T>)125 }126127 128 129 130 131 fn set_properties(132 &mut self,133 caller: caller,134 token_id: uint256,135 properties: Vec<(string, bytes)>,136 ) -> Result<()> {137 let caller = T::CrossAccountId::from_eth(caller);138 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;139140 let nesting_budget = self141 .recorder142 .weight_calls_budget(<StructureWeight<T>>::find_parent());143144 let properties = properties145 .into_iter()146 .map(|(key, value)| {147 let key = <Vec<u8>>::from(key)148 .try_into()149 .map_err(|_| "key too large")?;150151 let value = value.0.try_into().map_err(|_| "value too large")?;152153 Ok(Property { key, value })154 })155 .collect::<Result<Vec<_>>>()?;156157 <Pallet<T>>::set_token_properties(158 self,159 &caller,160 TokenId(token_id),161 properties.into_iter(),162 <Pallet<T>>::token_exists(&self, TokenId(token_id)),163 &nesting_budget,164 )165 .map_err(dispatch_to_evm::<T>)166 }167168 169 170 171 172 fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {173 let caller = T::CrossAccountId::from_eth(caller);174 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;175 let key = <Vec<u8>>::from(key)176 .try_into()177 .map_err(|_| "key too long")?;178179 let nesting_budget = self180 .recorder181 .weight_calls_budget(<StructureWeight<T>>::find_parent());182183 <Pallet<T>>::delete_token_property(self, &caller, TokenId(token_id), key, &nesting_budget)184 .map_err(dispatch_to_evm::<T>)185 }186187 188 189 190 191 192 fn property(&self, token_id: uint256, key: string) -> Result<bytes> {193 let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;194 let key = <Vec<u8>>::from(key)195 .try_into()196 .map_err(|_| "key too long")?;197198 let props = <TokenProperties<T>>::get((self.id, token_id));199 let prop = props.get(&key).ok_or("key not found")?;200201 Ok(prop.to_vec().into())202 }203}204205#[derive(ToLog)]206pub enum ERC721Events {207 208 209 210 Transfer {211 #[indexed]212 from: address,213 #[indexed]214 to: address,215 #[indexed]216 token_id: uint256,217 },218 219 Approval {220 #[indexed]221 owner: address,222 #[indexed]223 approved: address,224 #[indexed]225 token_id: uint256,226 },227 228 #[allow(dead_code)]229 ApprovalForAll {230 #[indexed]231 owner: address,232 #[indexed]233 operator: address,234 approved: bool,235 },236}237238#[derive(ToLog)]239pub enum ERC721UniqueMintableEvents {240 241 #[allow(dead_code)]242 MintingFinished {},243}244245#[solidity_interface(name = ERC721Metadata)]246impl<T: Config> RefungibleHandle<T>247where248 T::AccountId: From<[u8; 32]>,249{250 251 252 #[solidity(hide, rename_selector = "name")]253 fn name_proxy(&self) -> Result<string> {254 self.name()255 }256257 258 259 #[solidity(hide, rename_selector = "symbol")]260 fn symbol_proxy(&self) -> Result<string> {261 self.symbol()262 }263264 265 266 267 268 269 270 271 272 273 #[solidity(rename_selector = "tokenURI")]274 fn token_uri(&self, token_id: uint256) -> Result<string> {275 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;276277 match get_token_property(self, token_id_u32, &key::url()).as_deref() {278 Err(_) | Ok("") => (),279 Ok(url) => {280 return Ok(url.into());281 }282 };283284 let base_uri =285 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())286 .map(BoundedVec::into_inner)287 .map(string::from_utf8)288 .transpose()289 .map_err(|e| {290 Error::Revert(alloc::format!(291 "Can not convert value \"baseURI\" to string with error \"{}\"",292 e293 ))294 })?;295296 let base_uri = match base_uri.as_deref() {297 None | Some("") => {298 return Ok("".into());299 }300 Some(base_uri) => base_uri.into(),301 };302303 Ok(304 match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {305 Err(_) | Ok("") => base_uri,306 Ok(suffix) => base_uri + suffix,307 },308 )309 }310}311312313314#[solidity_interface(name = ERC721Enumerable)]315impl<T: Config> RefungibleHandle<T> {316 317 318 319 320 fn token_by_index(&self, index: uint256) -> Result<uint256> {321 Ok(index)322 }323324 325 fn token_of_owner_by_index(&self, _owner: address, _index: uint256) -> Result<uint256> {326 327 Err("not implemented".into())328 }329330 331 332 333 fn total_supply(&self) -> Result<uint256> {334 self.consume_store_reads(1)?;335 Ok(<Pallet<T>>::total_supply(self).into())336 }337}338339340341#[solidity_interface(name = ERC721, events(ERC721Events))]342impl<T: Config> RefungibleHandle<T> {343 344 345 346 347 348 fn balance_of(&self, owner: address) -> Result<uint256> {349 self.consume_store_reads(1)?;350 let owner = T::CrossAccountId::from_eth(owner);351 let balance = <AccountBalance<T>>::get((self.id, owner));352 Ok(balance.into())353 }354355 356 357 358 359 360 361 362 fn owner_of(&self, token_id: uint256) -> Result<address> {363 self.consume_store_reads(2)?;364 let token = token_id.try_into()?;365 let owner = <Pallet<T>>::token_owner(self.id, token);366 Ok(owner367 .map(|address| *address.as_eth())368 .unwrap_or_else(|| ADDRESS_FOR_PARTIALLY_OWNED_TOKENS))369 }370371 372 fn safe_transfer_from_with_data(373 &mut self,374 _from: address,375 _to: address,376 _token_id: uint256,377 _data: bytes,378 ) -> Result<void> {379 380 Err("not implemented".into())381 }382383 384 fn safe_transfer_from(385 &mut self,386 _from: address,387 _to: address,388 _token_id: uint256,389 ) -> Result<void> {390 391 Err("not implemented".into())392 }393394 395 396 397 398 399 400 401 402 403 404 #[weight(<SelfWeightOf<T>>::transfer_from_creating_removing())]405 fn transfer_from(406 &mut self,407 caller: caller,408 from: address,409 to: address,410 token_id: uint256,411 ) -> Result<void> {412 let caller = T::CrossAccountId::from_eth(caller);413 let from = T::CrossAccountId::from_eth(from);414 let to = T::CrossAccountId::from_eth(to);415 let token = token_id.try_into()?;416 let budget = self417 .recorder418 .weight_calls_budget(<StructureWeight<T>>::find_parent());419420 let balance = balance(&self, token, &from)?;421 ensure_single_owner(&self, token, balance)?;422423 <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)424 .map_err(dispatch_to_evm::<T>)?;425426 Ok(())427 }428429 430 fn approve(&mut self, _caller: caller, _approved: address, _token_id: uint256) -> Result<void> {431 Err("not implemented".into())432 }433434 435 fn set_approval_for_all(436 &mut self,437 _caller: caller,438 _operator: address,439 _approved: bool,440 ) -> Result<void> {441 442 Err("not implemented".into())443 }444445 446 fn get_approved(&self, _token_id: uint256) -> Result<address> {447 448 Err("not implemented".into())449 }450451 452 fn is_approved_for_all(&self, _owner: address, _operator: address) -> Result<address> {453 454 Err("not implemented".into())455 }456}457458459pub fn balance<T: Config>(460 collection: &RefungibleHandle<T>,461 token: TokenId,462 owner: &T::CrossAccountId,463) -> Result<u128> {464 collection.consume_store_reads(1)?;465 let balance = <Balance<T>>::get((collection.id, token, &owner));466 Ok(balance)467}468469470pub fn ensure_single_owner<T: Config>(471 collection: &RefungibleHandle<T>,472 token: TokenId,473 owner_balance: u128,474) -> Result<()> {475 collection.consume_store_reads(1)?;476 let total_supply = <TotalSupply<T>>::get((collection.id, token));477 if total_supply != owner_balance {478 return Err("token has multiple owners".into());479 }480 Ok(())481}482483484#[solidity_interface(name = ERC721Burnable)]485impl<T: Config> RefungibleHandle<T> {486 487 488 489 490 #[weight(<SelfWeightOf<T>>::burn_item_fully())]491 fn burn(&mut self, caller: caller, token_id: uint256) -> Result<void> {492 let caller = T::CrossAccountId::from_eth(caller);493 let token = token_id.try_into()?;494495 let balance = balance(&self, token, &caller)?;496 ensure_single_owner(&self, token, balance)?;497498 <Pallet<T>>::burn(self, &caller, token, balance).map_err(dispatch_to_evm::<T>)?;499 Ok(())500 }501}502503504#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]505impl<T: Config> RefungibleHandle<T> {506 fn minting_finished(&self) -> Result<bool> {507 Ok(false)508 }509510 511 512 513 #[weight(<SelfWeightOf<T>>::create_item())]514 fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {515 let token_id: uint256 = <TokensMinted<T>>::get(self.id)516 .checked_add(1)517 .ok_or("item id overflow")?518 .into();519 self.mint_check_id(caller, to, token_id)?;520 Ok(token_id)521 }522523 524 525 526 527 528 #[solidity(hide, rename_selector = "mint")]529 #[weight(<SelfWeightOf<T>>::create_item())]530 fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {531 let caller = T::CrossAccountId::from_eth(caller);532 let to = T::CrossAccountId::from_eth(to);533 let token_id: u32 = token_id.try_into()?;534 let budget = self535 .recorder536 .weight_calls_budget(<StructureWeight<T>>::find_parent());537538 if <TokensMinted<T>>::get(self.id)539 .checked_add(1)540 .ok_or("item id overflow")?541 != token_id542 {543 return Err("item id should be next".into());544 }545546 let users = [(to.clone(), 1)]547 .into_iter()548 .collect::<BTreeMap<_, _>>()549 .try_into()550 .unwrap();551 <Pallet<T>>::create_item(552 self,553 &caller,554 CreateItemData::<T::CrossAccountId> {555 users,556 properties: CollectionPropertiesVec::default(),557 },558 &budget,559 )560 .map_err(dispatch_to_evm::<T>)?;561562 Ok(true)563 }564565 566 567 568 569 #[solidity(rename_selector = "mintWithTokenURI")]570 #[weight(<SelfWeightOf<T>>::create_item())]571 fn mint_with_token_uri(572 &mut self,573 caller: caller,574 to: address,575 token_uri: string,576 ) -> Result<uint256> {577 let token_id: uint256 = <TokensMinted<T>>::get(self.id)578 .checked_add(1)579 .ok_or("item id overflow")?580 .into();581 self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;582 Ok(token_id)583 }584585 586 587 588 589 590 591 #[solidity(hide, rename_selector = "mintWithTokenURI")]592 #[weight(<SelfWeightOf<T>>::create_item())]593 fn mint_with_token_uri_check_id(594 &mut self,595 caller: caller,596 to: address,597 token_id: uint256,598 token_uri: string,599 ) -> Result<bool> {600 let key = key::url();601 let permission = get_token_permission::<T>(self.id, &key)?;602 if !permission.collection_admin {603 return Err("Operation is not allowed".into());604 }605606 let caller = T::CrossAccountId::from_eth(caller);607 let to = T::CrossAccountId::from_eth(to);608 let token_id: u32 = token_id.try_into().map_err(|_| "amount overflow")?;609 let budget = self610 .recorder611 .weight_calls_budget(<StructureWeight<T>>::find_parent());612613 if <TokensMinted<T>>::get(self.id)614 .checked_add(1)615 .ok_or("item id overflow")?616 != token_id617 {618 return Err("item id should be next".into());619 }620621 let mut properties = CollectionPropertiesVec::default();622 properties623 .try_push(Property {624 key,625 value: token_uri626 .into_bytes()627 .try_into()628 .map_err(|_| "token uri is too long")?,629 })630 .map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;631632 let users = [(to.clone(), 1)]633 .into_iter()634 .collect::<BTreeMap<_, _>>()635 .try_into()636 .unwrap();637 <Pallet<T>>::create_item(638 self,639 &caller,640 CreateItemData::<T::CrossAccountId> { users, properties },641 &budget,642 )643 .map_err(dispatch_to_evm::<T>)?;644 Ok(true)645 }646647 648 fn finish_minting(&mut self, _caller: caller) -> Result<bool> {649 Err("not implementable".into())650 }651}652653fn get_token_property<T: Config>(654 collection: &CollectionHandle<T>,655 token_id: u32,656 key: &up_data_structs::PropertyKey,657) -> Result<string> {658 collection.consume_store_reads(1)?;659 let properties = <TokenProperties<T>>::try_get((collection.id, token_id))660 .map_err(|_| Error::Revert("Token properties not found".into()))?;661 if let Some(property) = properties.get(key) {662 return Ok(string::from_utf8_lossy(property).into());663 }664665 Err("Property tokenURI not found".into())666}667668fn get_token_permission<T: Config>(669 collection_id: CollectionId,670 key: &PropertyKey,671) -> Result<PropertyPermission> {672 let token_property_permissions = CollectionPropertyPermissions::<T>::try_get(collection_id)673 .map_err(|_| Error::Revert("No permissions for collection".into()))?;674 let a = token_property_permissions675 .get(key)676 .map(Clone::clone)677 .ok_or_else(|| {678 let key = string::from_utf8(key.clone().into_inner()).unwrap_or_default();679 Error::Revert(alloc::format!("No permission for key {}", key))680 })?;681 Ok(a)682}683684685#[solidity_interface(name = ERC721UniqueExtensions)]686impl<T: Config> RefungibleHandle<T>687where688 T::AccountId: From<[u8; 32]>,689{690 691 fn name(&self) -> Result<string> {692 Ok(decode_utf16(self.name.iter().copied())693 .map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))694 .collect::<string>())695 }696697 698 fn symbol(&self) -> Result<string> {699 Ok(string::from_utf8_lossy(&self.token_prefix).into())700 }701702 703 704 705 706 707 708 #[weight(<SelfWeightOf<T>>::transfer_creating_removing())]709 fn transfer(&mut self, caller: caller, to: address, token_id: uint256) -> Result<void> {710 let caller = T::CrossAccountId::from_eth(caller);711 let to = T::CrossAccountId::from_eth(to);712 let token = token_id.try_into()?;713 let budget = self714 .recorder715 .weight_calls_budget(<StructureWeight<T>>::find_parent());716717 let balance = balance(self, token, &caller)?;718 ensure_single_owner(self, token, balance)?;719720 <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)721 .map_err(dispatch_to_evm::<T>)?;722 Ok(())723 }724725 726 727 728 729 730 731 #[weight(<SelfWeightOf<T>>::transfer_creating_removing())]732 fn transfer_from_cross(733 &mut self,734 caller: caller,735 from: EthCrossAccount,736 to: EthCrossAccount,737 token_id: uint256,738 ) -> Result<void> {739 let caller = T::CrossAccountId::from_eth(caller);740 let from = from.into_sub_cross_account::<T>()?;741 let to = to.into_sub_cross_account::<T>()?;742 let token_id = token_id.try_into()?;743 let budget = self744 .recorder745 .weight_calls_budget(<StructureWeight<T>>::find_parent());746747 let balance = balance(self, token_id, &from)?;748 ensure_single_owner(self, token_id, balance)?;749750 Pallet::<T>::transfer_from(self, &caller, &from, &to, token_id, balance, &budget)751 .map_err(dispatch_to_evm::<T>)?;752 Ok(())753 }754755 756 757 758 759 760 761 762 #[weight(<SelfWeightOf<T>>::burn_from())]763 fn burn_from(&mut self, caller: caller, from: address, token_id: uint256) -> Result<void> {764 let caller = T::CrossAccountId::from_eth(caller);765 let from = T::CrossAccountId::from_eth(from);766 let token = token_id.try_into()?;767 let budget = self768 .recorder769 .weight_calls_budget(<StructureWeight<T>>::find_parent());770771 let balance = balance(self, token, &from)?;772 ensure_single_owner(self, token, balance)?;773774 <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)775 .map_err(dispatch_to_evm::<T>)?;776 Ok(())777 }778779 780 781 782 783 784 785 786 #[weight(<SelfWeightOf<T>>::burn_from())]787 fn burn_from_cross(788 &mut self,789 caller: caller,790 from: EthCrossAccount,791 token_id: uint256,792 ) -> Result<void> {793 let caller = T::CrossAccountId::from_eth(caller);794 let from = from.into_sub_cross_account::<T>()?;795 let token = token_id.try_into()?;796 let budget = self797 .recorder798 .weight_calls_budget(<StructureWeight<T>>::find_parent());799800 let balance = balance(self, token, &from)?;801 ensure_single_owner(self, token, balance)?;802803 <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)804 .map_err(dispatch_to_evm::<T>)?;805 Ok(())806 }807808 809 fn next_token_id(&self) -> Result<uint256> {810 self.consume_store_reads(1)?;811 Ok(<TokensMinted<T>>::get(self.id)812 .checked_add(1)813 .ok_or("item id overflow")?814 .into())815 }816817 818 819 820 821 822 #[solidity(hide)]823 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]824 fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {825 let caller = T::CrossAccountId::from_eth(caller);826 let to = T::CrossAccountId::from_eth(to);827 let mut expected_index = <TokensMinted<T>>::get(self.id)828 .checked_add(1)829 .ok_or("item id overflow")?;830 let budget = self831 .recorder832 .weight_calls_budget(<StructureWeight<T>>::find_parent());833834 let total_tokens = token_ids.len();835 for id in token_ids.into_iter() {836 let id: u32 = id.try_into().map_err(|_| "token id overflow")?;837 if id != expected_index {838 return Err("item id should be next".into());839 }840 expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;841 }842 let users = [(to.clone(), 1)]843 .into_iter()844 .collect::<BTreeMap<_, _>>()845 .try_into()846 .unwrap();847 let create_item_data = CreateItemData::<T::CrossAccountId> {848 users,849 properties: CollectionPropertiesVec::default(),850 };851 let data = (0..total_tokens)852 .map(|_| create_item_data.clone())853 .collect();854855 <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)856 .map_err(dispatch_to_evm::<T>)?;857 Ok(true)858 }859860 861 862 863 864 865 #[solidity(hide, rename_selector = "mintBulkWithTokenURI")]866 #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]867 fn mint_bulk_with_token_uri(868 &mut self,869 caller: caller,870 to: address,871 tokens: Vec<(uint256, string)>,872 ) -> Result<bool> {873 let key = key::url();874 let caller = T::CrossAccountId::from_eth(caller);875 let to = T::CrossAccountId::from_eth(to);876 let mut expected_index = <TokensMinted<T>>::get(self.id)877 .checked_add(1)878 .ok_or("item id overflow")?;879 let budget = self880 .recorder881 .weight_calls_budget(<StructureWeight<T>>::find_parent());882883 let mut data = Vec::with_capacity(tokens.len());884 let users: BoundedBTreeMap<_, _, _> = [(to.clone(), 1)]885 .into_iter()886 .collect::<BTreeMap<_, _>>()887 .try_into()888 .unwrap();889 for (id, token_uri) in tokens {890 let id: u32 = id.try_into().map_err(|_| "token id overflow")?;891 if id != expected_index {892 return Err("item id should be next".into());893 }894 expected_index = expected_index.checked_add(1).ok_or("item id overflow")?;895896 let mut properties = CollectionPropertiesVec::default();897 properties898 .try_push(Property {899 key: key.clone(),900 value: token_uri901 .into_bytes()902 .try_into()903 .map_err(|_| "token uri is too long")?,904 })905 .map_err(|e| Error::Revert(alloc::format!("Can't add property: {:?}", e)))?;906907 let create_item_data = CreateItemData::<T::CrossAccountId> {908 users: users.clone(),909 properties,910 };911 data.push(create_item_data);912 }913914 <Pallet<T>>::create_multiple_items(self, &caller, data, &budget)915 .map_err(dispatch_to_evm::<T>)?;916 Ok(true)917 }918919 920 921 922 fn token_contract_address(&self, token: uint256) -> Result<address> {923 Ok(T::EvmTokenAddressMapping::token_to_address(924 self.id,925 token.try_into().map_err(|_| "token id overflow")?,926 ))927 }928}929930#[solidity_interface(931 name = UniqueRefungible,932 is(933 ERC721,934 ERC721Enumerable,935 ERC721UniqueExtensions,936 ERC721UniqueMintable,937 ERC721Burnable,938 ERC721Metadata(if(this.flags.erc721metadata)),939 Collection(via(common_mut returns CollectionHandle<T>)),940 TokenProperties,941 )942)]943impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}944945946generate_stubgen!(gen_impl, UniqueRefungibleCall<()>, true);947generate_stubgen!(gen_iface, UniqueRefungibleCall<()>, false);948949impl<T: Config> CommonEvmHandler for RefungibleHandle<T>950where951 T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]>,952{953 const CODE: &'static [u8] = include_bytes!("./stubs/UniqueRefungible.raw");954 fn call(955 self,956 handle: &mut impl PrecompileHandle,957 ) -> Option<pallet_common::erc::PrecompileResult> {958 call::<T, UniqueRefungibleCall<T>, _, _>(handle, self)959 }960}