difftreelog
chore code review requests
in: master
20 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth34use sp_std::vec::Vec;34use sp_std::vec::Vec;35use pallet_common::{35use pallet_common::{36 erc::{36 erc::{37 CommonEvmHandler, PrecompileResult, CollectionCall,37 CommonEvmHandler, PrecompileResult, CollectionCall, static_property::key,38 static_property::{key, value as property_value},38 static_property::value,39 },39 },40 CollectionHandle, CollectionPropertyPermissions,40 CollectionHandle, CollectionPropertyPermissions,41};41};42use pallet_evm::{account::CrossAccountId, PrecompileHandle};42use pallet_evm::{account::CrossAccountId, PrecompileHandle};43use pallet_evm_coder_substrate::call;43use pallet_evm_coder_substrate::call;44use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};44use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};45use alloc::string::ToString;464547use crate::{46use crate::{48 AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,47 AccountBalance, Config, CreateItemData, NonfungibleHandle, Pallet, TokenData, TokensMinted,226 /// @return token's const_metadata225 /// @return token's const_metadata227 #[solidity(rename_selector = "tokenURI")]226 #[solidity(rename_selector = "tokenURI")]228 fn token_uri(&self, token_id: uint256) -> Result<string> {227 fn token_uri(&self, token_id: uint256) -> Result<string> {228 if !self.supports_metadata() {229 return Ok("".into());230 }231229 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;232 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;230233231 if let Ok(url) = get_token_property(self, token_id_u32, &key::url()) {234 match get_token_property(self, token_id_u32, &key::url()).as_deref() {232 if !url.is_empty() {235 Err(_) | Ok("") => (),233 return Ok(url);234 }235 } else if !self.supports_metadata() {236 Ok(url) => {236 return Err("tokenURI not set".into());237 return Ok(url.into());237 }238 }239 };238240239 if let Some(base_uri) =241 let base_uri =240 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())242 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())241 {242 if !base_uri.is_empty() {243 .map(BoundedVec::into_inner)243 let base_uri = string::from_utf8(base_uri.into_inner()).map_err(|e| {244 .map(string::from_utf8)245 .transpose()246 .map_err(|e| {244 Error::Revert(alloc::format!(247 Error::Revert(alloc::format!(245 "Can not convert value \"baseURI\" to string with error \"{}\"",248 "Can not convert value \"baseURI\" to string with error \"{}\"",246 e249 e247 ))250 ))248 })?;251 })?;249 if let Ok(suffix) = get_token_property(self, token_id_u32, &key::suffix()) {252250 if !suffix.is_empty() {253 let base_uri = match base_uri.as_deref() {251 return Ok(base_uri + suffix.as_str());254 None | Some("") => {252 }253 }254255 return Ok(base_uri);256 }257 }258259 Ok("".into())255 return Ok("".into());256 }257 Some(base_uri) => base_uri.into(),258 };259260 Ok(261 match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {262 Err(_) | Ok("") => base_uri,263 Ok(suffix) => base_uri + suffix,264 },265 )260 }266 }261}267}262268706 }712 }707}713}714715impl<T: Config> NonfungibleHandle<T> {716 pub fn supports_metadata(&self) -> bool {717 if let Some(erc721_metadata) =718 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::erc721_metadata())719 {720 *erc721_metadata.into_inner() == *value::ERC721_METADATA_SUPPORTED721 } else {722 false723 }724 }725}708726709#[solidity_interface(727#[solidity_interface(710 name = UniqueNFT,728 name = UniqueNFT,711 is(729 is(712 ERC721,730 ERC721,713 ERC721Metadata(if(this.supports_metadata())),714 ERC721Enumerable,731 ERC721Enumerable,715 ERC721UniqueExtensions,732 ERC721UniqueExtensions,716 ERC721Mintable,733 ERC721Mintable,717 ERC721Burnable,734 ERC721Burnable,718 Collection(via(common_mut returns CollectionHandle<T>)),735 Collection(via(common_mut returns CollectionHandle<T>)),719 TokenProperties,736 TokenProperties,737 ERC721Metadata(if(this.supports_metadata())),720 )738 )721)]739)]722impl<T: Config> NonfungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}740impl<T: Config> NonfungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}pallets/nonfungible/src/lib.rsdiffbeforeafterboth297 }297 }298}298}299300impl<T: Config> NonfungibleHandle<T> {301 pub fn supports_metadata(&self) -> bool {302 if let Some(erc721_metadata) =303 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::erc721_metadata())304 {305 *erc721_metadata.into_inner() == *value::ERC721_METADATA_SUPPORTED306 } else {307 false308 }309 }310}311299312impl<T: Config> WithRecorder<T> for NonfungibleHandle<T> {300impl<T: Config> WithRecorder<T> for NonfungibleHandle<T> {313 fn recorder(&self) -> &SubstrateRecorder<T> {301 fn recorder(&self) -> &SubstrateRecorder<T> {pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth17 }17 }18}18}1920/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension21/// @dev See https://eips.ethereum.org/EIPS/eip-72122/// @dev the ERC-165 identifier for this interface is 0x5b5e139f23contract ERC721Metadata is Dummy, ERC165 {24 /// @notice A descriptive name for a collection of NFTs in this contract25 /// @dev EVM selector for this function is: 0x06fdde03,26 /// or in textual repr: name()27 function name() public view returns (string memory) {28 require(false, stub_error);29 dummy;30 return "";31 }3233 /// @notice An abbreviated name for NFTs in this contract34 /// @dev EVM selector for this function is: 0x95d89b41,35 /// or in textual repr: symbol()36 function symbol() public view returns (string memory) {37 require(false, stub_error);38 dummy;39 return "";40 }4142 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.43 ///44 /// @dev If the token has a `url` property and it is not empty, it is returned.45 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.46 /// If the collection property `baseURI` is empty or absent, return "" (empty string)47 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix48 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).49 ///50 /// @return token's const_metadata51 /// @dev EVM selector for this function is: 0xc87b56dd,52 /// or in textual repr: tokenURI(uint256)53 function tokenURI(uint256 tokenId) public view returns (string memory) {54 require(false, stub_error);55 tokenId;56 dummy;57 return "";58 }59}196020/// @title A contract that allows to set and delete token properties and change token property permissions.61/// @title A contract that allows to set and delete token properties and change token property permissions.21/// @dev the ERC-165 identifier for this interface is 0x4136937762/// @dev the ERC-165 identifier for this interface is 0x41369377177 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.218 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.178 /// @dev EVM selector for this function is: 0x6ec0a9f1,219 /// @dev EVM selector for this function is: 0x6ec0a9f1,179 /// or in textual repr: collectionSponsor()220 /// or in textual repr: collectionSponsor()180 function collectionSponsor() public view returns (Tuple17 memory) {221 function collectionSponsor() public view returns (Tuple15 memory) {181 require(false, stub_error);222 require(false, stub_error);182 dummy;223 dummy;183 return Tuple17(0x0000000000000000000000000000000000000000, 0);224 return Tuple15(0x0000000000000000000000000000000000000000, 0);184 }225 }185226186 /// Set limits for the collection.227 /// Set limits for the collection.359 /// If address is canonical then substrate mirror is zero and vice versa.400 /// If address is canonical then substrate mirror is zero and vice versa.360 /// @dev EVM selector for this function is: 0xdf727d3b,401 /// @dev EVM selector for this function is: 0xdf727d3b,361 /// or in textual repr: collectionOwner()402 /// or in textual repr: collectionOwner()362 function collectionOwner() public view returns (Tuple17 memory) {403 function collectionOwner() public view returns (Tuple15 memory) {363 require(false, stub_error);404 require(false, stub_error);364 dummy;405 dummy;365 return Tuple17(0x0000000000000000000000000000000000000000, 0);406 return Tuple15(0x0000000000000000000000000000000000000000, 0);366 }407 }367408368 /// Changes collection owner to another account409 /// Changes collection owner to another account379}420}380421381/// @dev anonymous struct422/// @dev anonymous struct382struct Tuple17 {423struct Tuple15 {383 address field_0;424 address field_0;384 uint256 field_1;425 uint256 field_1;385}426}525 /// @param tokens array of pairs of token ID and token URI for minted tokens566 /// @param tokens array of pairs of token ID and token URI for minted tokens526 /// @dev EVM selector for this function is: 0x36543006,567 /// @dev EVM selector for this function is: 0x36543006,527 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])568 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])528 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {569 function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) public returns (bool) {529 require(false, stub_error);570 require(false, stub_error);530 to;571 to;531 tokens;572 tokens;535}576}536577537/// @dev anonymous struct578/// @dev anonymous struct538struct Tuple8 {579struct Tuple6 {539 uint256 field_0;580 uint256 field_0;540 string field_1;581 string field_1;541}582}580 }621 }581}622}582583/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension584/// @dev See https://eips.ethereum.org/EIPS/eip-721585/// @dev the ERC-165 identifier for this interface is 0x5b5e139f586contract ERC721Metadata is Dummy, ERC165 {587 /// @notice A descriptive name for a collection of NFTs in this contract588 /// @dev EVM selector for this function is: 0x06fdde03,589 /// or in textual repr: name()590 function name() public view returns (string memory) {591 require(false, stub_error);592 dummy;593 return "";594 }595596 /// @notice An abbreviated name for NFTs in this contract597 /// @dev EVM selector for this function is: 0x95d89b41,598 /// or in textual repr: symbol()599 function symbol() public view returns (string memory) {600 require(false, stub_error);601 dummy;602 return "";603 }604605 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.606 ///607 /// @dev If the token has a `url` property and it is not empty, it is returned.608 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.609 /// If the collection property `baseURI` is empty or absent, return "" (empty string)610 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix611 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).612 ///613 /// @return token's const_metadata614 /// @dev EVM selector for this function is: 0xc87b56dd,615 /// or in textual repr: tokenURI(uint256)616 function tokenURI(uint256 tokenId) public view returns (string memory) {617 require(false, stub_error);618 tokenId;619 dummy;620 return "";621 }622}623623624/// @dev inlined interface624/// @dev inlined interface625contract ERC721Events {625contract ERC721Events {766 Dummy,766 Dummy,767 ERC165,767 ERC165,768 ERC721,768 ERC721,769 ERC721Metadata,770 ERC721Enumerable,769 ERC721Enumerable,771 ERC721UniqueExtensions,770 ERC721UniqueExtensions,772 ERC721Mintable,771 ERC721Mintable,773 ERC721Burnable,772 ERC721Burnable,774 Collection,773 Collection,775 TokenProperties774 TokenProperties,775 ERC721Metadata776{}776{}777777pallets/refungible/src/erc.rsdiffbeforeafterboth212122extern crate alloc;22extern crate alloc;232324use alloc::string::ToString;25use core::{24use core::{26 char::{REPLACEMENT_CHARACTER, decode_utf16},25 char::{REPLACEMENT_CHARACTER, decode_utf16},27 convert::TryInto,26 convert::TryInto,28};27};29use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};28use evm_coder::{ToLog, execution::*, generate_stubgen, solidity, solidity_interface, types::*, weight};30use frame_support::BoundedBTreeMap;29use frame_support::{BoundedBTreeMap, BoundedVec};31use pallet_common::{30use pallet_common::{32 CollectionHandle, CollectionPropertyPermissions,31 CollectionHandle, CollectionPropertyPermissions,33 erc::{32 erc::{CommonEvmHandler, CollectionCall, static_property::key, static_property::value},34 CommonEvmHandler, CollectionCall,35 static_property::{key, value as property_value},36 },37};33};38use pallet_evm::{account::CrossAccountId, PrecompileHandle};34use pallet_evm::{account::CrossAccountId, PrecompileHandle};222 /// @return token's const_metadata218 /// @return token's const_metadata223 #[solidity(rename_selector = "tokenURI")]219 #[solidity(rename_selector = "tokenURI")]224 fn token_uri(&self, token_id: uint256) -> Result<string> {220 fn token_uri(&self, token_id: uint256) -> Result<string> {221 if !self.supports_metadata() {222 return Ok("".into());223 }224225 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;225 let token_id_u32: u32 = token_id.try_into().map_err(|_| "token id overflow")?;226226227 if let Ok(url) = get_token_property(self, token_id_u32, &key::url()) {227 match get_token_property(self, token_id_u32, &key::url()).as_deref() {228 if !url.is_empty() {228 Err(_) | Ok("") => (),229 return Ok(url);230 }231 } else if !self.supports_metadata() {229 Ok(url) => {232 return Err("tokenURI not set".into());230 return Ok(url.into());233 }231 }232 };234233235 if let Some(base_uri) =234 let base_uri =236 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())235 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::base_uri())237 {238 if !base_uri.is_empty() {236 .map(BoundedVec::into_inner)239 let base_uri = string::from_utf8(base_uri.into_inner()).map_err(|e| {237 .map(string::from_utf8)238 .transpose()239 .map_err(|e| {240 Error::Revert(alloc::format!(240 Error::Revert(alloc::format!(241 "Can not convert value \"baseURI\" to string with error \"{}\"",241 "Can not convert value \"baseURI\" to string with error \"{}\"",242 e242 e243 ))243 ))244 })?;244 })?;245 if let Ok(suffix) = get_token_property(self, token_id_u32, &key::suffix()) {245246 if !suffix.is_empty() {246 let base_uri = match base_uri.as_deref() {247 return Ok(base_uri + suffix.as_str());247 None | Some("") => {248 }249 }250251 return Ok(base_uri);252 }253 }254255 Ok("".into())248 return Ok("".into());249 }250 Some(base_uri) => base_uri.into(),251 };252253 Ok(254 match get_token_property(self, token_id_u32, &key::suffix()).as_deref() {255 Err(_) | Ok("") => base_uri,256 Ok(suffix) => base_uri + suffix,257 },258 )256 }259 }257}260}258261765 }768 }766}769}770771impl<T: Config> RefungibleHandle<T> {772 pub fn supports_metadata(&self) -> bool {773 if let Some(erc721_metadata) =774 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::erc721_metadata())775 {776 *erc721_metadata.into_inner() == *value::ERC721_METADATA_SUPPORTED777 } else {778 false779 }780 }781}767782768#[solidity_interface(783#[solidity_interface(769 name = UniqueRefungible,784 name = UniqueRefungible,770 is(785 is(771 ERC721,786 ERC721,772 ERC721Metadata(if(this.supports_metadata())),773 ERC721Enumerable,787 ERC721Enumerable,774 ERC721UniqueExtensions,788 ERC721UniqueExtensions,775 ERC721Mintable,789 ERC721Mintable,776 ERC721Burnable,790 ERC721Burnable,777 Collection(via(common_mut returns CollectionHandle<T>)),791 Collection(via(common_mut returns CollectionHandle<T>)),778 TokenProperties,792 TokenProperties,793 ERC721Metadata(if(this.supports_metadata())),779 )794 )780)]795)]781impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}796impl<T: Config> RefungibleHandle<T> where T::AccountId: From<[u8; 32]> + AsRef<[u8; 32]> {}pallets/refungible/src/lib.rsdiffbeforeafterboth304 }304 }305}305}306307impl<T: Config> RefungibleHandle<T> {308 pub fn supports_metadata(&self) -> bool {309 if let Some(erc721_metadata) =310 pallet_common::Pallet::<T>::get_collection_property(self.id, &key::erc721_metadata())311 {312 *erc721_metadata.into_inner() == *value::ERC721_METADATA_SUPPORTED313 } else {314 false315 }316 }317}318306319impl<T: Config> Deref for RefungibleHandle<T> {307impl<T: Config> Deref for RefungibleHandle<T> {320 type Target = pallet_common::CollectionHandle<T>;308 type Target = pallet_common::CollectionHandle<T>;pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth17 }17 }18}18}1920/// @dev the ERC-165 identifier for this interface is 0x5b5e139f21contract ERC721Metadata is Dummy, ERC165 {22 /// @notice A descriptive name for a collection of RFTs in this contract23 /// @dev EVM selector for this function is: 0x06fdde03,24 /// or in textual repr: name()25 function name() public view returns (string memory) {26 require(false, stub_error);27 dummy;28 return "";29 }3031 /// @notice An abbreviated name for RFTs in this contract32 /// @dev EVM selector for this function is: 0x95d89b41,33 /// or in textual repr: symbol()34 function symbol() public view returns (string memory) {35 require(false, stub_error);36 dummy;37 return "";38 }3940 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.41 ///42 /// @dev If the token has a `url` property and it is not empty, it is returned.43 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.44 /// If the collection property `baseURI` is empty or absent, return "" (empty string)45 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix46 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).47 ///48 /// @return token's const_metadata49 /// @dev EVM selector for this function is: 0xc87b56dd,50 /// or in textual repr: tokenURI(uint256)51 function tokenURI(uint256 tokenId) public view returns (string memory) {52 require(false, stub_error);53 tokenId;54 dummy;55 return "";56 }57}195820/// @title A contract that allows to set and delete token properties and change token property permissions.59/// @title A contract that allows to set and delete token properties and change token property permissions.21/// @dev the ERC-165 identifier for this interface is 0x4136937760/// @dev the ERC-165 identifier for this interface is 0x41369377177 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.216 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.178 /// @dev EVM selector for this function is: 0x6ec0a9f1,217 /// @dev EVM selector for this function is: 0x6ec0a9f1,179 /// or in textual repr: collectionSponsor()218 /// or in textual repr: collectionSponsor()180 function collectionSponsor() public view returns (Tuple17 memory) {219 function collectionSponsor() public view returns (Tuple15 memory) {181 require(false, stub_error);220 require(false, stub_error);182 dummy;221 dummy;183 return Tuple17(0x0000000000000000000000000000000000000000, 0);222 return Tuple15(0x0000000000000000000000000000000000000000, 0);184 }223 }185224186 /// Set limits for the collection.225 /// Set limits for the collection.359 /// If address is canonical then substrate mirror is zero and vice versa.398 /// If address is canonical then substrate mirror is zero and vice versa.360 /// @dev EVM selector for this function is: 0xdf727d3b,399 /// @dev EVM selector for this function is: 0xdf727d3b,361 /// or in textual repr: collectionOwner()400 /// or in textual repr: collectionOwner()362 function collectionOwner() public view returns (Tuple17 memory) {401 function collectionOwner() public view returns (Tuple15 memory) {363 require(false, stub_error);402 require(false, stub_error);364 dummy;403 dummy;365 return Tuple17(0x0000000000000000000000000000000000000000, 0);404 return Tuple15(0x0000000000000000000000000000000000000000, 0);366 }405 }367406368 /// Changes collection owner to another account407 /// Changes collection owner to another account379}418}380419381/// @dev anonymous struct420/// @dev anonymous struct382struct Tuple17 {421struct Tuple15 {383 address field_0;422 address field_0;384 uint256 field_1;423 uint256 field_1;385}424}527 /// @param tokens array of pairs of token ID and token URI for minted tokens566 /// @param tokens array of pairs of token ID and token URI for minted tokens528 /// @dev EVM selector for this function is: 0x36543006,567 /// @dev EVM selector for this function is: 0x36543006,529 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])568 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])530 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) public returns (bool) {569 function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) public returns (bool) {531 require(false, stub_error);570 require(false, stub_error);532 to;571 to;533 tokens;572 tokens;549}588}550589551/// @dev anonymous struct590/// @dev anonymous struct552struct Tuple8 {591struct Tuple6 {553 uint256 field_0;592 uint256 field_0;554 string field_1;593 string field_1;555}594}594 }633 }595}634}596597/// @dev the ERC-165 identifier for this interface is 0x5b5e139f598contract ERC721Metadata is Dummy, ERC165 {599 /// @notice A descriptive name for a collection of RFTs in this contract600 /// @dev EVM selector for this function is: 0x06fdde03,601 /// or in textual repr: name()602 function name() public view returns (string memory) {603 require(false, stub_error);604 dummy;605 return "";606 }607608 /// @notice An abbreviated name for RFTs in this contract609 /// @dev EVM selector for this function is: 0x95d89b41,610 /// or in textual repr: symbol()611 function symbol() public view returns (string memory) {612 require(false, stub_error);613 dummy;614 return "";615 }616617 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.618 ///619 /// @dev If the token has a `url` property and it is not empty, it is returned.620 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.621 /// If the collection property `baseURI` is empty or absent, return "" (empty string)622 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix623 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).624 ///625 /// @return token's const_metadata626 /// @dev EVM selector for this function is: 0xc87b56dd,627 /// or in textual repr: tokenURI(uint256)628 function tokenURI(uint256 tokenId) public view returns (string memory) {629 require(false, stub_error);630 tokenId;631 dummy;632 return "";633 }634}635635636/// @dev inlined interface636/// @dev inlined interface637contract ERC721Events {637contract ERC721Events {776 Dummy,776 Dummy,777 ERC165,777 ERC165,778 ERC721,778 ERC721,779 ERC721Metadata,780 ERC721Enumerable,779 ERC721Enumerable,781 ERC721UniqueExtensions,780 ERC721UniqueExtensions,782 ERC721Mintable,781 ERC721Mintable,783 ERC721Burnable,782 ERC721Burnable,784 Collection,783 Collection,785 TokenProperties784 TokenProperties,785 ERC721Metadata786{}786{}787787pallets/unique/src/eth/mod.rsdiffbeforeafterboth335 )335 )336 }336 }337338 #[weight(<SelfWeightOf<T>>::create_collection())]339 #[deprecated(note = "mathod was renamed to `create_rft_collection`, prefer it instead")]340 fn create_refungible_collection(341 &mut self,342 caller: caller,343 value: value,344 name: string,345 description: string,346 token_prefix: string,347 ) -> Result<address> {348 create_refungible_collection_internal::<T>(349 caller,350 value,351 name,352 description,353 token_prefix,354 Default::default(),355 false,356 )357 }358337359 #[weight(<SelfWeightOf<T>>::create_collection())]338 #[weight(<SelfWeightOf<T>>::create_collection())]360 #[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]339 #[solidity(rename_selector = "createERC721MetadataCompatibleRFTCollection")]pallets/unique/src/eth/stubs/CollectionHelpers.rawdiffbeforeafterbothbinary blob — no preview
pallets/unique/src/eth/stubs/CollectionHelpers.soldiffbeforeafterboth23}23}242425/// @title Contract, which allows users to operate with collections25/// @title Contract, which allows users to operate with collections26/// @dev the ERC-165 identifier for this interface is 0x95eb98f426/// @dev the ERC-165 identifier for this interface is 0xd14d122127contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {27contract CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {28 /// Create an NFT collection28 /// Create an NFT collection29 /// @param name Name of the collection29 /// @param name Name of the collection97 return 0x0000000000000000000000000000000000000000;97 return 0x0000000000000000000000000000000000000000;98 }98 }99100 /// @dev EVM selector for this function is: 0x44a68ad5,101 /// or in textual repr: createRefungibleCollection(string,string,string)102 function createRefungibleCollection(103 string memory name,104 string memory description,105 string memory tokenPrefix106 ) public payable returns (address) {107 require(false, stub_error);108 name;109 description;110 tokenPrefix;111 dummy = 0;112 return 0x0000000000000000000000000000000000000000;113 }11499115 /// @dev EVM selector for this function is: 0xa5596388,100 /// @dev EVM selector for this function is: 0xa5596388,116 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)101 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)tests/src/eth/api/CollectionHelpers.soldiffbeforeafterboth18}18}191920/// @title Contract, which allows users to operate with collections20/// @title Contract, which allows users to operate with collections21/// @dev the ERC-165 identifier for this interface is 0x95eb98f421/// @dev the ERC-165 identifier for this interface is 0xd14d122122interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {22interface CollectionHelpers is Dummy, ERC165, CollectionHelpersEvents {23 /// Create an NFT collection23 /// Create an NFT collection24 /// @param name Name of the collection24 /// @param name Name of the collection63 string memory tokenPrefix63 string memory tokenPrefix64 ) external payable returns (address);64 ) external payable returns (address);6566 /// @dev EVM selector for this function is: 0x44a68ad5,67 /// or in textual repr: createRefungibleCollection(string,string,string)68 function createRefungibleCollection(69 string memory name,70 string memory description,71 string memory tokenPrefix72 ) external payable returns (address);736574 /// @dev EVM selector for this function is: 0xa5596388,66 /// @dev EVM selector for this function is: 0xa5596388,75 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)67 /// or in textual repr: createERC721MetadataCompatibleRFTCollection(string,string,string,string)tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}13}1415/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension16/// @dev See https://eips.ethereum.org/EIPS/eip-72117/// @dev the ERC-165 identifier for this interface is 0x5b5e139f18interface ERC721Metadata is Dummy, ERC165 {19 /// @notice A descriptive name for a collection of NFTs in this contract20 /// @dev EVM selector for this function is: 0x06fdde03,21 /// or in textual repr: name()22 function name() external view returns (string memory);2324 /// @notice An abbreviated name for NFTs in this contract25 /// @dev EVM selector for this function is: 0x95d89b41,26 /// or in textual repr: symbol()27 function symbol() external view returns (string memory);2829 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.30 ///31 /// @dev If the token has a `url` property and it is not empty, it is returned.32 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.33 /// If the collection property `baseURI` is empty or absent, return "" (empty string)34 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix35 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).36 ///37 /// @return token's const_metadata38 /// @dev EVM selector for this function is: 0xc87b56dd,39 /// or in textual repr: tokenURI(uint256)40 function tokenURI(uint256 tokenId) external view returns (string memory);41}144215/// @title A contract that allows to set and delete token properties and change token property permissions.43/// @title A contract that allows to set and delete token properties and change token property permissions.16/// @dev the ERC-165 identifier for this interface is 0x4136937744/// @dev the ERC-165 identifier for this interface is 0x41369377120 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.148 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.121 /// @dev EVM selector for this function is: 0x6ec0a9f1,149 /// @dev EVM selector for this function is: 0x6ec0a9f1,122 /// or in textual repr: collectionSponsor()150 /// or in textual repr: collectionSponsor()123 function collectionSponsor() external view returns (Tuple17 memory);151 function collectionSponsor() external view returns (Tuple15 memory);124152125 /// Set limits for the collection.153 /// Set limits for the collection.126 /// @dev Throws error if limit not found.154 /// @dev Throws error if limit not found.237 /// If address is canonical then substrate mirror is zero and vice versa.265 /// If address is canonical then substrate mirror is zero and vice versa.238 /// @dev EVM selector for this function is: 0xdf727d3b,266 /// @dev EVM selector for this function is: 0xdf727d3b,239 /// or in textual repr: collectionOwner()267 /// or in textual repr: collectionOwner()240 function collectionOwner() external view returns (Tuple17 memory);268 function collectionOwner() external view returns (Tuple15 memory);241269242 /// Changes collection owner to another account270 /// Changes collection owner to another account243 ///271 ///249}277}250278251/// @dev anonymous struct279/// @dev anonymous struct252struct Tuple17 {280struct Tuple15 {253 address field_0;281 address field_0;254 uint256 field_1;282 uint256 field_1;255}283}350 /// @param tokens array of pairs of token ID and token URI for minted tokens378 /// @param tokens array of pairs of token ID and token URI for minted tokens351 /// @dev EVM selector for this function is: 0x36543006,379 /// @dev EVM selector for this function is: 0x36543006,352 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])380 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])353 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);381 function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) external returns (bool);354}382}355383356/// @dev anonymous struct384/// @dev anonymous struct357struct Tuple8 {385struct Tuple6 {358 uint256 field_0;386 uint256 field_0;359 string field_1;387 string field_1;360}388}384 function totalSupply() external view returns (uint256);412 function totalSupply() external view returns (uint256);385}413}386387/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension388/// @dev See https://eips.ethereum.org/EIPS/eip-721389/// @dev the ERC-165 identifier for this interface is 0x5b5e139f390interface ERC721Metadata is Dummy, ERC165 {391 /// @notice A descriptive name for a collection of NFTs in this contract392 /// @dev EVM selector for this function is: 0x06fdde03,393 /// or in textual repr: name()394 function name() external view returns (string memory);395396 /// @notice An abbreviated name for NFTs in this contract397 /// @dev EVM selector for this function is: 0x95d89b41,398 /// or in textual repr: symbol()399 function symbol() external view returns (string memory);400401 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.402 ///403 /// @dev If the token has a `url` property and it is not empty, it is returned.404 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.405 /// If the collection property `baseURI` is empty or absent, return "" (empty string)406 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix407 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).408 ///409 /// @return token's const_metadata410 /// @dev EVM selector for this function is: 0xc87b56dd,411 /// or in textual repr: tokenURI(uint256)412 function tokenURI(uint256 tokenId) external view returns (string memory);413}414414415/// @dev inlined interface415/// @dev inlined interface416interface ERC721Events {416interface ERC721Events {507 Dummy,507 Dummy,508 ERC165,508 ERC165,509 ERC721,509 ERC721,510 ERC721Metadata,511 ERC721Enumerable,510 ERC721Enumerable,512 ERC721UniqueExtensions,511 ERC721UniqueExtensions,513 ERC721Mintable,512 ERC721Mintable,514 ERC721Burnable,513 ERC721Burnable,515 Collection,514 Collection,516 TokenProperties515 TokenProperties,516 ERC721Metadata517{}517{}518518tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth12 function supportsInterface(bytes4 interfaceID) external view returns (bool);12 function supportsInterface(bytes4 interfaceID) external view returns (bool);13}13}1415/// @dev the ERC-165 identifier for this interface is 0x5b5e139f16interface ERC721Metadata is Dummy, ERC165 {17 /// @notice A descriptive name for a collection of RFTs in this contract18 /// @dev EVM selector for this function is: 0x06fdde03,19 /// or in textual repr: name()20 function name() external view returns (string memory);2122 /// @notice An abbreviated name for RFTs in this contract23 /// @dev EVM selector for this function is: 0x95d89b41,24 /// or in textual repr: symbol()25 function symbol() external view returns (string memory);2627 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.28 ///29 /// @dev If the token has a `url` property and it is not empty, it is returned.30 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.31 /// If the collection property `baseURI` is empty or absent, return "" (empty string)32 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix33 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).34 ///35 /// @return token's const_metadata36 /// @dev EVM selector for this function is: 0xc87b56dd,37 /// or in textual repr: tokenURI(uint256)38 function tokenURI(uint256 tokenId) external view returns (string memory);39}144015/// @title A contract that allows to set and delete token properties and change token property permissions.41/// @title A contract that allows to set and delete token properties and change token property permissions.16/// @dev the ERC-165 identifier for this interface is 0x4136937742/// @dev the ERC-165 identifier for this interface is 0x41369377120 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.146 /// @return Tuble with sponsor address and his substrate mirror. If there is no confirmed sponsor error "Contract has no sponsor" throw.121 /// @dev EVM selector for this function is: 0x6ec0a9f1,147 /// @dev EVM selector for this function is: 0x6ec0a9f1,122 /// or in textual repr: collectionSponsor()148 /// or in textual repr: collectionSponsor()123 function collectionSponsor() external view returns (Tuple17 memory);149 function collectionSponsor() external view returns (Tuple15 memory);124150125 /// Set limits for the collection.151 /// Set limits for the collection.126 /// @dev Throws error if limit not found.152 /// @dev Throws error if limit not found.237 /// If address is canonical then substrate mirror is zero and vice versa.263 /// If address is canonical then substrate mirror is zero and vice versa.238 /// @dev EVM selector for this function is: 0xdf727d3b,264 /// @dev EVM selector for this function is: 0xdf727d3b,239 /// or in textual repr: collectionOwner()265 /// or in textual repr: collectionOwner()240 function collectionOwner() external view returns (Tuple17 memory);266 function collectionOwner() external view returns (Tuple15 memory);241267242 /// Changes collection owner to another account268 /// Changes collection owner to another account243 ///269 ///249}275}250276251/// @dev anonymous struct277/// @dev anonymous struct252struct Tuple17 {278struct Tuple15 {253 address field_0;279 address field_0;254 uint256 field_1;280 uint256 field_1;255}281}352 /// @param tokens array of pairs of token ID and token URI for minted tokens378 /// @param tokens array of pairs of token ID and token URI for minted tokens353 /// @dev EVM selector for this function is: 0x36543006,379 /// @dev EVM selector for this function is: 0x36543006,354 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])380 /// or in textual repr: mintBulkWithTokenURI(address,(uint256,string)[])355 function mintBulkWithTokenURI(address to, Tuple8[] memory tokens) external returns (bool);381 function mintBulkWithTokenURI(address to, Tuple6[] memory tokens) external returns (bool);356382357 /// Returns EVM address for refungible token383 /// Returns EVM address for refungible token358 ///384 ///363}389}364390365/// @dev anonymous struct391/// @dev anonymous struct366struct Tuple8 {392struct Tuple6 {367 uint256 field_0;393 uint256 field_0;368 string field_1;394 string field_1;369}395}393 function totalSupply() external view returns (uint256);419 function totalSupply() external view returns (uint256);394}420}395396/// @dev the ERC-165 identifier for this interface is 0x5b5e139f397interface ERC721Metadata is Dummy, ERC165 {398 /// @notice A descriptive name for a collection of RFTs in this contract399 /// @dev EVM selector for this function is: 0x06fdde03,400 /// or in textual repr: name()401 function name() external view returns (string memory);402403 /// @notice An abbreviated name for RFTs in this contract404 /// @dev EVM selector for this function is: 0x95d89b41,405 /// or in textual repr: symbol()406 function symbol() external view returns (string memory);407408 /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.409 ///410 /// @dev If the token has a `url` property and it is not empty, it is returned.411 /// Else If the collection does not have a property with key `schemaName` or its value is not equal to `ERC721Metadata`, it return an error `tokenURI not set`.412 /// If the collection property `baseURI` is empty or absent, return "" (empty string)413 /// otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix414 /// otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).415 ///416 /// @return token's const_metadata417 /// @dev EVM selector for this function is: 0xc87b56dd,418 /// or in textual repr: tokenURI(uint256)419 function tokenURI(uint256 tokenId) external view returns (string memory);420}421421422/// @dev inlined interface422/// @dev inlined interface423interface ERC721Events {423interface ERC721Events {512 Dummy,512 Dummy,513 ERC165,513 ERC165,514 ERC721,514 ERC721,515 ERC721Metadata,516 ERC721Enumerable,515 ERC721Enumerable,517 ERC721UniqueExtensions,516 ERC721UniqueExtensions,518 ERC721Mintable,517 ERC721Mintable,519 ERC721Burnable,518 ERC721Burnable,520 Collection,519 Collection,521 TokenProperties520 TokenProperties,521 ERC721Metadata522{}522{}523523tests/src/eth/collectionHelpersAbi.jsondiffbeforeafterboth82 "stateMutability": "payable",82 "stateMutability": "payable",83 "type": "function"83 "type": "function"84 },84 },85 {86 "inputs": [87 { "internalType": "string", "name": "name", "type": "string" },88 { "internalType": "string", "name": "description", "type": "string" },89 { "internalType": "string", "name": "tokenPrefix", "type": "string" }90 ],91 "name": "createRefungibleCollection",92 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],93 "stateMutability": "payable",94 "type": "function"95 },96 {85 {97 "inputs": [86 "inputs": [98 {87 {tests/src/eth/collectionProperties.test.tsdiffbeforeafterboth1import {itEth, usingEthPlaygrounds, expect} from './util/playgrounds';1import {itEth, usingEthPlaygrounds, expect} from './util/playgrounds';2import {IKeyringPair} from '@polkadot/types/types';2import {IKeyringPair} from '@polkadot/types/types';3import {Pallets} from '../util/playgrounds';344describe('EVM collection properties', () => {5describe('EVM collection properties', () => {5 let donor: IKeyringPair;6 let donor: IKeyringPair;80 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;81 expect(await contract.methods.supportsInterface('0x5b5e139f').call()).to.be.false;81 });82 });828383 itEth('ERC721Metadata property can be set for RFT collection', async({helper}) => {84 itEth.ifWithPallets('ERC721Metadata property can be set for RFT collection', [Pallets.ReFungible], async({helper}) => {84 const caller = await helper.eth.createAccountWithBalance(donor);85 const caller = await helper.eth.createAccountWithBalance(donor);85 const collection = await helper.rft.mintCollection(donor, {name: 'col', description: 'descr', tokenPrefix: 'COL'});86 const collection = await helper.rft.mintCollection(donor, {name: 'col', description: 'descr', tokenPrefix: 'COL'});8687tests/src/eth/nonFungible.test.tsdiffbeforeafterboth79 });79 });80 });80 });818182 async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {82 async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {83 const owner = await helper.eth.createAccountWithBalance(donor);83 const owner = await helper.eth.createAccountWithBalance(donor);84 const receiver = helper.eth.createAccount();84 const receiver = helper.eth.createAccount();858586 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', tokenPrefix);86 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleNFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);87 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);87 const contract = helper.ethNativeContract.collection(collectionAddress, 'nft', owner);88 88 89 const nextTokenId = await contract.methods.nextTokenId().call();89 const nextTokenId = await contract.methods.nextTokenId().call();tests/src/eth/nonFungibleAbi.jsondiffbeforeafterboth154 { "internalType": "address", "name": "field_0", "type": "address" },154 { "internalType": "address", "name": "field_0", "type": "address" },155 { "internalType": "uint256", "name": "field_1", "type": "uint256" }155 { "internalType": "uint256", "name": "field_1", "type": "uint256" }156 ],156 ],157 "internalType": "struct Tuple17",157 "internalType": "struct Tuple15",158 "name": "",158 "name": "",159 "type": "tuple"159 "type": "tuple"160 }160 }178 { "internalType": "address", "name": "field_0", "type": "address" },178 { "internalType": "address", "name": "field_0", "type": "address" },179 { "internalType": "uint256", "name": "field_1", "type": "uint256" }179 { "internalType": "uint256", "name": "field_1", "type": "uint256" }180 ],180 ],181 "internalType": "struct Tuple17",181 "internalType": "struct Tuple15",182 "name": "",182 "name": "",183 "type": "tuple"183 "type": "tuple"184 }184 }287 { "internalType": "uint256", "name": "field_0", "type": "uint256" },287 { "internalType": "uint256", "name": "field_0", "type": "uint256" },288 { "internalType": "string", "name": "field_1", "type": "string" }288 { "internalType": "string", "name": "field_1", "type": "string" }289 ],289 ],290 "internalType": "struct Tuple8[]",290 "internalType": "struct Tuple6[]",291 "name": "tokens",291 "name": "tokens",292 "type": "tuple[]"292 "type": "tuple[]"293 }293 }tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth154 { "internalType": "address", "name": "field_0", "type": "address" },154 { "internalType": "address", "name": "field_0", "type": "address" },155 { "internalType": "uint256", "name": "field_1", "type": "uint256" }155 { "internalType": "uint256", "name": "field_1", "type": "uint256" }156 ],156 ],157 "internalType": "struct Tuple17",157 "internalType": "struct Tuple15",158 "name": "",158 "name": "",159 "type": "tuple"159 "type": "tuple"160 }160 }178 { "internalType": "address", "name": "field_0", "type": "address" },178 { "internalType": "address", "name": "field_0", "type": "address" },179 { "internalType": "uint256", "name": "field_1", "type": "uint256" }179 { "internalType": "uint256", "name": "field_1", "type": "uint256" }180 ],180 ],181 "internalType": "struct Tuple17",181 "internalType": "struct Tuple15",182 "name": "",182 "name": "",183 "type": "tuple"183 "type": "tuple"184 }184 }287 { "internalType": "uint256", "name": "field_0", "type": "uint256" },287 { "internalType": "uint256", "name": "field_0", "type": "uint256" },288 { "internalType": "string", "name": "field_1", "type": "string" }288 { "internalType": "string", "name": "field_1", "type": "string" }289 ],289 ],290 "internalType": "struct Tuple8[]",290 "internalType": "struct Tuple6[]",291 "name": "tokens",291 "name": "tokens",292 "type": "tuple[]"292 "type": "tuple[]"293 }293 }tests/src/eth/reFungibleToken.test.tsdiffbeforeafterboth76 });76 });77 });77 });787879 async function setup(helper: EthUniqueHelper, tokenPrefix: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {79 async function setup(helper: EthUniqueHelper, baseUri: string, propertyKey?: string, propertyValue?: string): Promise<{contract: Contract, nextTokenId: string}> {80 const owner = await helper.eth.createAccountWithBalance(donor);80 const owner = await helper.eth.createAccountWithBalance(donor);81 const receiver = helper.eth.createAccount();81 const receiver = helper.eth.createAccount();828283 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Mint collection', 'a', 'b', tokenPrefix);83 const {collectionAddress} = await helper.eth.createERC721MetadataCompatibleRFTCollection(owner, 'Mint collection', 'a', 'b', baseUri);84 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);84 const contract = helper.ethNativeContract.collection(collectionAddress, 'rft', owner);85 85 86 const nextTokenId = await contract.methods.nextTokenId().call();86 const nextTokenId = await contract.methods.nextTokenId().call();