difftreelog
doc: add documentstion for nonfungible EVM API
in: master
4 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -14,6 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+//! # Nonfungible Pallet EVM API
+//!
+//! Provides ERC-721 standart support implementation and EVM API for unique extensions for Nonfungible Pallet.
+//! Method implementations are mostly doing parameter conversion and calling Nonfungible Pallet methods.
+
extern crate alloc;
use core::{
char::{REPLACEMENT_CHARACTER, decode_utf16},
@@ -40,8 +45,16 @@
SelfWeightOf, weights::WeightInfo, TokenProperties,
};
+/// @title A contract that allows to set and delete token properties and change token property permissions.
+///
#[solidity_interface(name = "TokenProperties")]
impl<T: Config> NonfungibleHandle<T> {
+ /// @notice Set permissions for token property.
+ /// @dev Throws error if `msg.sender` is not admin or owner of the collection.
+ /// @param key Property key.
+ /// @param is_mutable Permission to mutate property.
+ /// @param collection_admin Permission to mutate property by collection admin if property is mutable.
+ /// @param token_owner Permission to mutate property by token owner if property is mutable.
fn set_token_property_permission(
&mut self,
caller: caller,
@@ -68,6 +81,11 @@
.map_err(dispatch_to_evm::<T>)
}
+ /// @notice Set token property value.
+ /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ /// @param tokenId ID of the token.
+ /// @param key Property key.
+ /// @param value Property value.
fn set_property(
&mut self,
caller: caller,
@@ -96,6 +114,10 @@
.map_err(dispatch_to_evm::<T>)
}
+ /// @notice Delete token property value.
+ /// @dev Throws error if `msg.sender` has no permission to edit the property.
+ /// @param tokenId ID of the token.
+ /// @param key Property key.
fn delete_property(&mut self, token_id: uint256, caller: caller, key: string) -> Result<()> {
let caller = T::CrossAccountId::from_eth(caller);
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
@@ -111,7 +133,10 @@
.map_err(dispatch_to_evm::<T>)
}
- /// Throws error if key not found
+ /// @notice Get token property value.
+ /// @dev Throws error if key not found
+ /// @param tokenId ID of the token.
+ /// @param key Property key.
fn property(&self, token_id: uint256, key: string) -> Result<bytes> {
let token_id: u32 = token_id.try_into().map_err(|_| "token id overflow")?;
let key = <Vec<u8>>::from(key)
@@ -127,6 +152,11 @@
#[derive(ToLog)]
pub enum ERC721Events {
+ /// @dev This emits when ownership of any NFT changes by any mechanism.
+ /// This event emits when NFTs are created (`from` == 0) and destroyed
+ /// (`to` == 0). Exception: during contract creation, any number of NFTs
+ /// may be created and assigned without emitting Transfer. At the time of
+ /// any transfer, the approved address for that NFT (if any) is reset to none.
Transfer {
#[indexed]
from: address,
@@ -135,6 +165,10 @@
#[indexed]
token_id: uint256,
},
+ /// @dev This emits when the approved address for an NFT is changed or
+ /// reaffirmed. The zero address indicates there is no approved address.
+ /// When a Transfer event emits, this also indicates that the approved
+ /// address for that NFT (if any) is reset to none.
Approval {
#[indexed]
owner: address,
@@ -143,6 +177,8 @@
#[indexed]
token_id: uint256,
},
+ /// @dev This emits when an operator is enabled or disabled for an owner.
+ /// The operator can manage all NFTs of the owner.
#[allow(dead_code)]
ApprovalForAll {
#[indexed]
@@ -159,19 +195,27 @@
MintingFinished {},
}
+/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
+/// @dev See https://eips.ethereum.org/EIPS/eip-721
#[solidity_interface(name = "ERC721Metadata")]
impl<T: Config> NonfungibleHandle<T> {
+ /// @notice A descriptive name for a collection of NFTs in this contract
fn name(&self) -> Result<string> {
Ok(decode_utf16(self.name.iter().copied())
.map(|r| r.unwrap_or(REPLACEMENT_CHARACTER))
.collect::<string>())
}
+ /// @notice An abbreviated name for NFTs in this contract
fn symbol(&self) -> Result<string> {
Ok(string::from_utf8_lossy(&self.token_prefix).into())
}
- /// Returns token's const_metadata
+ /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+ /// @dev Throws if `tokenId` is not a valid NFT. URIs are defined in RFC
+ /// 3986. The URI may point to a JSON file that conforms to the "ERC721
+ /// Metadata JSON Schema".
+ /// @return token's const_metadata
#[solidity(rename_selector = "tokenURI")]
fn token_uri(&self, token_id: uint256) -> Result<string> {
let key = token_uri_key();
@@ -192,32 +236,53 @@
}
}
+/// @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
+/// @dev See https://eips.ethereum.org/EIPS/eip-721
#[solidity_interface(name = "ERC721Enumerable")]
impl<T: Config> NonfungibleHandle<T> {
+ /// @notice Enumerate valid NFTs
+ /// @param index A counter less than `totalSupply()`
+ /// @return The token identifier for the `index`th NFT,
+ /// (sort order not specified)
fn token_by_index(&self, index: uint256) -> Result<uint256> {
Ok(index)
}
- /// Not implemented
+ /// @dev Not implemented
fn token_of_owner_by_index(&self, _owner: address, _index: uint256) -> Result<uint256> {
// TODO: Not implemetable
Err("not implemented".into())
}
+ /// @notice Count NFTs tracked by this contract
+ /// @return A count of valid NFTs tracked by this contract, where each one of
+ /// them has an assigned and queryable owner not equal to the zero address
fn total_supply(&self) -> Result<uint256> {
self.consume_store_reads(1)?;
Ok(<Pallet<T>>::total_supply(self).into())
}
}
+/// @title ERC-721 Non-Fungible Token Standard
+/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
#[solidity_interface(name = "ERC721", events(ERC721Events))]
impl<T: Config> NonfungibleHandle<T> {
+ /// @notice Count all NFTs assigned to an owner
+ /// @dev NFTs assigned to the zero address are considered invalid, and this
+ /// function throws for queries about the zero address.
+ /// @param owner An address for whom to query the balance
+ /// @return The number of NFTs owned by `owner`, possibly zero
fn balance_of(&self, owner: address) -> Result<uint256> {
self.consume_store_reads(1)?;
let owner = T::CrossAccountId::from_eth(owner);
let balance = <AccountBalance<T>>::get((self.id, owner));
Ok(balance.into())
}
+ /// @notice Find the owner of an NFT
+ /// @dev NFTs assigned to zero address are considered invalid, and queries
+ /// about them do throw.
+ /// @param tokenId The identifier for an NFT
+ /// @return The address of the owner of the NFT
fn owner_of(&self, token_id: uint256) -> Result<address> {
self.consume_store_reads(1)?;
let token: TokenId = token_id.try_into()?;
@@ -226,7 +291,7 @@
.owner
.as_eth())
}
- /// Not implemented
+ /// @dev Not implemented
fn safe_transfer_from_with_data(
&mut self,
_from: address,
@@ -238,7 +303,7 @@
// TODO: Not implemetable
Err("not implemented".into())
}
- /// Not implemented
+ /// @dev Not implemented
fn safe_transfer_from(
&mut self,
_from: address,
@@ -250,6 +315,16 @@
Err("not implemented".into())
}
+ /// @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
+ /// TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE
+ /// THEY MAY BE PERMANENTLY LOST
+ /// @dev Throws unless `msg.sender` is the current owner or an authorized
+ /// operator for this NFT. Throws if `from` is not the current owner. Throws
+ /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
+ /// @param from The current owner of the NFT
+ /// @param to The new owner
+ /// @param tokenId The NFT to transfer
+ /// @param _value Not used for an NFT
#[weight(<SelfWeightOf<T>>::transfer_from())]
fn transfer_from(
&mut self,
@@ -272,6 +347,12 @@
Ok(())
}
+ /// @notice Set or reaffirm the approved address for an NFT
+ /// @dev The zero address indicates there is no approved address.
+ /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
+ /// operator of the current owner.
+ /// @param approved The new approved NFT controller
+ /// @param tokenId The NFT to approve
#[weight(<SelfWeightOf<T>>::approve())]
fn approve(
&mut self,
@@ -289,7 +370,7 @@
Ok(())
}
- /// Not implemented
+ /// @dev Not implemented
fn set_approval_for_all(
&mut self,
_caller: caller,
@@ -300,21 +381,26 @@
Err("not implemented".into())
}
- /// Not implemented
+ /// @dev Not implemented
fn get_approved(&self, _token_id: uint256) -> Result<address> {
// TODO: Not implemetable
Err("not implemented".into())
}
- /// Not implemented
+ /// @dev Not implemented
fn is_approved_for_all(&self, _owner: address, _operator: address) -> Result<address> {
// TODO: Not implemetable
Err("not implemented".into())
}
}
+/// @title ERC721 Token that can be irreversibly burned (destroyed).
#[solidity_interface(name = "ERC721Burnable")]
impl<T: Config> NonfungibleHandle<T> {
+ /// @notice Burns a specific ERC721 token.
+ /// @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
+ /// operator of the current owner.
+ /// @param tokenId The NFT to approve
#[weight(<SelfWeightOf<T>>::burn_item())]
fn burn(&mut self, caller: caller, token_id: uint256) -> Result<void> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -325,14 +411,18 @@
}
}
+/// @title ERC721 minting logic.
#[solidity_interface(name = "ERC721Mintable", events(ERC721MintableEvents))]
impl<T: Config> NonfungibleHandle<T> {
fn minting_finished(&self) -> Result<bool> {
Ok(false)
}
- /// `token_id` should be obtained with `next_token_id` method,
- /// unlike standard, you can't specify it manually
+ /// @notice Function to mint token.
+ /// @dev `tokenId` should be obtained with `nextTokenId` method,
+ /// unlike standard, you can't specify it manually
+ /// @param to The new owner
+ /// @param tokenId ID of the minted NFT
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -364,8 +454,12 @@
Ok(true)
}
- /// `token_id` should be obtained with `next_token_id` method,
- /// unlike standard, you can't specify it manually
+ /// @notice Function to mint token with the given tokenUri.
+ /// @dev `tokenId` should be obtained with `nextTokenId` method,
+ /// unlike standard, you can't specify it manually
+ /// @param to The new owner
+ /// @param tokenId ID of the minted NFT
+ /// @param tokenUri Token URI that would be stored in the NFT properties
#[solidity(rename_selector = "mintWithTokenURI")]
#[weight(<SelfWeightOf<T>>::create_item())]
fn mint_with_token_uri(
@@ -420,7 +514,7 @@
Ok(true)
}
- /// Not implemented
+ /// @dev Not implemented
fn finish_minting(&mut self, _caller: caller) -> Result<bool> {
Err("not implementable".into())
}
@@ -449,8 +543,15 @@
false
}
+/// @title Unique extensions for ERC721.
#[solidity_interface(name = "ERC721UniqueExtensions")]
impl<T: Config> NonfungibleHandle<T> {
+ /// @notice Transfer ownership of an NFT
+ /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+ /// is the zero address. Throws if `tokenId` is not a valid NFT.
+ /// @param to The new owner
+ /// @param tokenId The NFT to transfer
+ /// @param _value Not used for an NFT
#[weight(<SelfWeightOf<T>>::transfer())]
fn transfer(
&mut self,
@@ -470,6 +571,13 @@
Ok(())
}
+ /// @notice Burns a specific ERC721 token.
+ /// @dev Throws unless `msg.sender` is the current owner or an authorized
+ /// operator for this NFT. Throws if `from` is not the current owner. Throws
+ /// if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
+ /// @param from The current owner of the NFT
+ /// @param tokenId The NFT to transfer
+ /// @param _value Not used for an NFT
#[weight(<SelfWeightOf<T>>::burn_from())]
fn burn_from(
&mut self,
@@ -490,6 +598,7 @@
Ok(())
}
+ /// @notice Returns next free NFT ID.
fn next_token_id(&self) -> Result<uint256> {
self.consume_store_reads(1)?;
Ok(<TokensMinted<T>>::get(self.id)
@@ -498,6 +607,11 @@
.into())
}
+ /// @notice Function to mint multiple tokens.
+ /// @dev `tokenIds` should be an array of consecutive numbers and first number
+ /// should be obtained with `nextTokenId` method
+ /// @param to The new owner
+ /// @param tokenIds IDs of the minted NFTs
#[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]
fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
@@ -529,6 +643,11 @@
Ok(true)
}
+ /// @notice Function to mint multiple tokens with the given tokenUris.
+ /// @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+ /// numbers and first number should be obtained with `nextTokenId` method
+ /// @param to The new owner
+ /// @param tokens array of pairs of token ID and token URI for minted tokens
#[solidity(rename_selector = "mintBulkWithTokenURI")]
#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]
fn mint_bulk_with_token_uri(
pallets/nonfungible/src/stubs/UniqueNFT.rawdiffbeforeafterbothbinary blob — no preview
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -53,6 +53,13 @@
// Selector: 41369377
contract TokenProperties is Dummy, ERC165 {
+ // @notice Set permissions for token property.
+ // @dev Throws error if `msg.sender` is not admin or owner of the collection.
+ // @param key Property key.
+ // @param is_mutable Permission to mutate property.
+ // @param collection_admin Permission to mutate property by collection admin if property is mutable.
+ // @param token_owner Permission to mutate property by token owner if property is mutable.
+ //
// Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa
function setTokenPropertyPermission(
string memory key,
@@ -68,6 +75,12 @@
dummy = 0;
}
+ // @notice Set token property value.
+ // @dev Throws error if `msg.sender` has no permission to edit the property.
+ // @param token_id ID of the token.
+ // @param key Property key.
+ // @param value Property value.
+ //
// Selector: setProperty(uint256,string,bytes) 1752d67b
function setProperty(
uint256 tokenId,
@@ -81,6 +94,11 @@
dummy = 0;
}
+ // @notice Delete token property value.
+ // @dev Throws error if `msg.sender` has no permission to edit the property.
+ // @param token_id ID of the token.
+ // @param key Property key.
+ //
// Selector: deleteProperty(uint256,string) 066111d1
function deleteProperty(uint256 tokenId, string memory key) public {
require(false, stub_error);
@@ -89,7 +107,10 @@
dummy = 0;
}
- // Throws error if key not found
+ // @notice Get token property value.
+ // @dev Throws error if key not found
+ // @param token_id ID of the token.
+ // @param key Property key.
//
// Selector: property(uint256,string) 7228c327
function property(uint256 tokenId, string memory key)
@@ -107,6 +128,11 @@
// Selector: 42966c68
contract ERC721Burnable is Dummy, ERC165 {
+ // @notice Burns a specific ERC721 token.
+ // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
+ // operator of the current owner.
+ // @param tokenId The NFT to approve
+ //
// Selector: burn(uint256) 42966c68
function burn(uint256 tokenId) public {
require(false, stub_error);
@@ -117,6 +143,12 @@
// Selector: 58800161
contract ERC721 is Dummy, ERC165, ERC721Events {
+ // @notice Count all NFTs assigned to an owner
+ // @dev NFTs assigned to the zero address are considered invalid, and this
+ // function throws for queries about the zero address.
+ // @param _owner An address for whom to query the balance
+ // @return The number of NFTs owned by `_owner`, possibly zero
+ //
// Selector: balanceOf(address) 70a08231
function balanceOf(address owner) public view returns (uint256) {
require(false, stub_error);
@@ -125,6 +157,12 @@
return 0;
}
+ // @notice Find the owner of an NFT
+ // @dev NFTs assigned to zero address are considered invalid, and queries
+ // about them do throw.
+ // @param _tokenId The identifier for an NFT
+ // @return The address of the owner of the NFT
+ //
// Selector: ownerOf(uint256) 6352211e
function ownerOf(uint256 tokenId) public view returns (address) {
require(false, stub_error);
@@ -133,7 +171,7 @@
return 0x0000000000000000000000000000000000000000;
}
- // Not implemented
+ // @dev Not implemented
//
// Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672
function safeTransferFromWithData(
@@ -150,7 +188,7 @@
dummy = 0;
}
- // Not implemented
+ // @dev Not implemented
//
// Selector: safeTransferFrom(address,address,uint256) 42842e0e
function safeTransferFrom(
@@ -165,6 +203,17 @@
dummy = 0;
}
+ // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
+ // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE
+ // THEY MAY BE PERMANENTLY LOST
+ // @dev Throws unless `msg.sender` is the current owner or an authorized
+ // operator for this NFT. Throws if `from` is not the current owner. Throws
+ // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
+ // @param from The current owner of the NFT
+ // @param to The new owner
+ // @param tokenId The NFT to transfer
+ // @param _value Not used for an NFT
+ //
// Selector: transferFrom(address,address,uint256) 23b872dd
function transferFrom(
address from,
@@ -178,6 +227,13 @@
dummy = 0;
}
+ // @notice Set or reaffirm the approved address for an NFT
+ // @dev The zero address indicates there is no approved address.
+ // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized
+ // operator of the current owner.
+ // @param approved The new approved NFT controller
+ // @param tokenId The NFT to approve
+ //
// Selector: approve(address,uint256) 095ea7b3
function approve(address approved, uint256 tokenId) public {
require(false, stub_error);
@@ -186,7 +242,7 @@
dummy = 0;
}
- // Not implemented
+ // @dev Not implemented
//
// Selector: setApprovalForAll(address,bool) a22cb465
function setApprovalForAll(address operator, bool approved) public {
@@ -196,7 +252,7 @@
dummy = 0;
}
- // Not implemented
+ // @dev Not implemented
//
// Selector: getApproved(uint256) 081812fc
function getApproved(uint256 tokenId) public view returns (address) {
@@ -206,7 +262,7 @@
return 0x0000000000000000000000000000000000000000;
}
- // Not implemented
+ // @dev Not implemented
//
// Selector: isApprovedForAll(address,address) e985e9c5
function isApprovedForAll(address owner, address operator)
@@ -224,6 +280,8 @@
// Selector: 5b5e139f
contract ERC721Metadata is Dummy, ERC165 {
+ // @notice A descriptive name for a collection of NFTs in this contract
+ //
// Selector: name() 06fdde03
function name() public view returns (string memory) {
require(false, stub_error);
@@ -231,6 +289,8 @@
return "";
}
+ // @notice An abbreviated name for NFTs in this contract
+ //
// Selector: symbol() 95d89b41
function symbol() public view returns (string memory) {
require(false, stub_error);
@@ -238,7 +298,11 @@
return "";
}
- // Returns token's const_metadata
+ // @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+ // @dev Throws if `tokenId` is not a valid NFT. URIs are defined in RFC
+ // 3986. The URI may point to a JSON file that conforms to the "ERC721
+ // Metadata JSON Schema".
+ // @return token's const_metadata
//
// Selector: tokenURI(uint256) c87b56dd
function tokenURI(uint256 tokenId) public view returns (string memory) {
@@ -258,8 +322,11 @@
return false;
}
- // `token_id` should be obtained with `next_token_id` method,
- // unlike standard, you can't specify it manually
+ // @notice Function to mint token.
+ // @dev `tokenId` should be obtained with `nextTokenId` method,
+ // unlike standard, you can't specify it manually
+ // @param to The new owner
+ // @param tokenId ID of the minted NFT
//
// Selector: mint(address,uint256) 40c10f19
function mint(address to, uint256 tokenId) public returns (bool) {
@@ -270,8 +337,12 @@
return false;
}
- // `token_id` should be obtained with `next_token_id` method,
- // unlike standard, you can't specify it manually
+ // @notice Function to mint token with the given tokenUri.
+ // @dev `tokenId` should be obtained with `nextTokenId` method,
+ // unlike standard, you can't specify it manually
+ // @param to The new owner
+ // @param tokenId ID of the minted NFT
+ // @param tokenUri Token URI that would be stored in the NFT properties
//
// Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f
function mintWithTokenURI(
@@ -287,7 +358,7 @@
return false;
}
- // Not implemented
+ // @dev Not implemented
//
// Selector: finishMinting() 7d64bcb4
function finishMinting() public returns (bool) {
@@ -299,6 +370,12 @@
// Selector: 780e9d63
contract ERC721Enumerable is Dummy, ERC165 {
+ // @notice Enumerate valid NFTs
+ // @dev Throws if `index` >= `totalSupply()`.
+ // @param index A counter less than `totalSupply()`
+ // @return The token identifier for the `index`th NFT,
+ // (sort order not specified)
+ //
// Selector: tokenByIndex(uint256) 4f6ccce7
function tokenByIndex(uint256 index) public view returns (uint256) {
require(false, stub_error);
@@ -307,7 +384,7 @@
return 0;
}
- // Not implemented
+ // @dev Not implemented
//
// Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59
function tokenOfOwnerByIndex(address owner, uint256 index)
@@ -322,6 +399,10 @@
return 0;
}
+ // @notice Count NFTs tracked by this contract
+ // @return A count of valid NFTs tracked by this contract, where each one of
+ // them has an assigned and queryable owner not equal to the zero address
+ //
// Selector: totalSupply() 18160ddd
function totalSupply() public view returns (uint256) {
require(false, stub_error);
@@ -475,6 +556,15 @@
// Selector: d74d154f
contract ERC721UniqueExtensions is Dummy, ERC165 {
+ // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE
+ // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE
+ // THEY MAY BE PERMANENTLY LOST
+ // @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+ // is the zero address. Throws if `tokenId` is not a valid NFT.
+ // @param to The new owner
+ // @param tokenId The NFT to transfer
+ // @param _value Not used for an NFT
+ //
// Selector: transfer(address,uint256) a9059cbb
function transfer(address to, uint256 tokenId) public {
require(false, stub_error);
@@ -483,6 +573,14 @@
dummy = 0;
}
+ // @notice Burns a specific ERC721 token.
+ // @dev Throws unless `msg.sender` is the current owner or an authorized
+ // operator for this NFT. Throws if `from` is not the current owner. Throws
+ // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.
+ // @param from The current owner of the NFT
+ // @param tokenId The NFT to transfer
+ // @param _value Not used for an NFT
+ //
// Selector: burnFrom(address,uint256) 79cc6790
function burnFrom(address from, uint256 tokenId) public {
require(false, stub_error);
@@ -491,6 +589,8 @@
dummy = 0;
}
+ // @notice Returns next free NFT ID.
+ //
// Selector: nextTokenId() 75794a3c
function nextTokenId() public view returns (uint256) {
require(false, stub_error);
@@ -498,6 +598,12 @@
return 0;
}
+ // @notice Function to mint multiple tokens.
+ // @dev `tokenIds` should be an array of consecutive numbers and first number
+ // should be obtained with `nextTokenId` method
+ // @param to The new owner
+ // @param tokenIds IDs of the minted NFTs
+ //
// Selector: mintBulk(address,uint256[]) 44a9945e
function mintBulk(address to, uint256[] memory tokenIds)
public
@@ -510,6 +616,12 @@
return false;
}
+ // @notice Function to mint multiple tokens with the given tokenUris.
+ // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive
+ // numbers and first number should be obtained with `nextTokenId` method
+ // @param to The new owner
+ // @param tokens array of pairs of token ID and token URI for minted tokens
+ //
// Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
public
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}1112// Common stubs holder13interface Dummy {1415}1617interface ERC165 is Dummy {18 function supportsInterface(bytes4 interfaceID) external view returns (bool);19}2021// Inline22interface ERC721Events {23 event Transfer(24 address indexed from,25 address indexed to,26 uint256 indexed tokenId27 );28 event Approval(29 address indexed owner,30 address indexed approved,31 uint256 indexed tokenId32 );33 event ApprovalForAll(34 address indexed owner,35 address indexed operator,36 bool approved37 );38}3940// Inline41interface ERC721MintableEvents {42 event MintingFinished();43}4445// Selector: 4136937746interface TokenProperties is Dummy, ERC165 {47 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa48 function setTokenPropertyPermission(49 string memory key,50 bool isMutable,51 bool collectionAdmin,52 bool tokenOwner53 ) external;5455 // Selector: setProperty(uint256,string,bytes) 1752d67b56 function setProperty(57 uint256 tokenId,58 string memory key,59 bytes memory value60 ) external;6162 // Selector: deleteProperty(uint256,string) 066111d163 function deleteProperty(uint256 tokenId, string memory key) external;6465 // Throws error if key not found66 //67 // Selector: property(uint256,string) 7228c32768 function property(uint256 tokenId, string memory key)69 external70 view71 returns (bytes memory);72}7374// Selector: 42966c6875interface ERC721Burnable is Dummy, ERC165 {76 // Selector: burn(uint256) 42966c6877 function burn(uint256 tokenId) external;78}7980// Selector: 5880016181interface ERC721 is Dummy, ERC165, ERC721Events {82 // Selector: balanceOf(address) 70a0823183 function balanceOf(address owner) external view returns (uint256);8485 // Selector: ownerOf(uint256) 6352211e86 function ownerOf(uint256 tokenId) external view returns (address);8788 // Not implemented89 //90 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a1167291 function safeTransferFromWithData(92 address from,93 address to,94 uint256 tokenId,95 bytes memory data96 ) external;9798 // Not implemented99 //100 // Selector: safeTransferFrom(address,address,uint256) 42842e0e101 function safeTransferFrom(102 address from,103 address to,104 uint256 tokenId105 ) external;106107 // Selector: transferFrom(address,address,uint256) 23b872dd108 function transferFrom(109 address from,110 address to,111 uint256 tokenId112 ) external;113114 // Selector: approve(address,uint256) 095ea7b3115 function approve(address approved, uint256 tokenId) external;116117 // Not implemented118 //119 // Selector: setApprovalForAll(address,bool) a22cb465120 function setApprovalForAll(address operator, bool approved) external;121122 // Not implemented123 //124 // Selector: getApproved(uint256) 081812fc125 function getApproved(uint256 tokenId) external view returns (address);126127 // Not implemented128 //129 // Selector: isApprovedForAll(address,address) e985e9c5130 function isApprovedForAll(address owner, address operator)131 external132 view133 returns (address);134}135136// Selector: 5b5e139f137interface ERC721Metadata is Dummy, ERC165 {138 // Selector: name() 06fdde03139 function name() external view returns (string memory);140141 // Selector: symbol() 95d89b41142 function symbol() external view returns (string memory);143144 // Returns token's const_metadata145 //146 // Selector: tokenURI(uint256) c87b56dd147 function tokenURI(uint256 tokenId) external view returns (string memory);148}149150// Selector: 68ccfe89151interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {152 // Selector: mintingFinished() 05d2035b153 function mintingFinished() external view returns (bool);154155 // `token_id` should be obtained with `next_token_id` method,156 // unlike standard, you can't specify it manually157 //158 // Selector: mint(address,uint256) 40c10f19159 function mint(address to, uint256 tokenId) external returns (bool);160161 // `token_id` should be obtained with `next_token_id` method,162 // unlike standard, you can't specify it manually163 //164 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f165 function mintWithTokenURI(166 address to,167 uint256 tokenId,168 string memory tokenUri169 ) external returns (bool);170171 // Not implemented172 //173 // Selector: finishMinting() 7d64bcb4174 function finishMinting() external returns (bool);175}176177// Selector: 780e9d63178interface ERC721Enumerable is Dummy, ERC165 {179 // Selector: tokenByIndex(uint256) 4f6ccce7180 function tokenByIndex(uint256 index) external view returns (uint256);181182 // Not implemented183 //184 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59185 function tokenOfOwnerByIndex(address owner, uint256 index)186 external187 view188 returns (uint256);189190 // Selector: totalSupply() 18160ddd191 function totalSupply() external view returns (uint256);192}193194// Selector: 7d9262e6195interface Collection is Dummy, ERC165 {196 // Selector: setCollectionProperty(string,bytes) 2f073f66197 function setCollectionProperty(string memory key, bytes memory value)198 external;199200 // Selector: deleteCollectionProperty(string) 7b7debce201 function deleteCollectionProperty(string memory key) external;202203 // Throws error if key not found204 //205 // Selector: collectionProperty(string) cf24fd6d206 function collectionProperty(string memory key)207 external208 view209 returns (bytes memory);210211 // Selector: setCollectionSponsor(address) 7623402e212 function setCollectionSponsor(address sponsor) external;213214 // Selector: confirmCollectionSponsorship() 3c50e97a215 function confirmCollectionSponsorship() external;216217 // Selector: setCollectionLimit(string,uint32) 6a3841db218 function setCollectionLimit(string memory limit, uint32 value) external;219220 // Selector: setCollectionLimit(string,bool) 993b7fba221 function setCollectionLimit(string memory limit, bool value) external;222223 // Selector: contractAddress() f6b4dfb4224 function contractAddress() external view returns (address);225226 // Selector: addCollectionAdminSubstrate(uint256) 5730062b227 function addCollectionAdminSubstrate(uint256 newAdmin) external view;228229 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9230 function removeCollectionAdminSubstrate(uint256 newAdmin) external view;231232 // Selector: addCollectionAdmin(address) 92e462c7233 function addCollectionAdmin(address newAdmin) external view;234235 // Selector: removeCollectionAdmin(address) fafd7b42236 function removeCollectionAdmin(address admin) external view;237238 // Selector: setCollectionNesting(bool) 112d4586239 function setCollectionNesting(bool enable) external;240241 // Selector: setCollectionNesting(bool,address[]) 64872396242 function setCollectionNesting(bool enable, address[] memory collections)243 external;244245 // Selector: setCollectionAccess(uint8) 41835d4c246 function setCollectionAccess(uint8 mode) external;247248 // Selector: addToCollectionAllowList(address) 67844fe6249 function addToCollectionAllowList(address user) external view;250251 // Selector: removeFromCollectionAllowList(address) 85c51acb252 function removeFromCollectionAllowList(address user) external view;253254 // Selector: setCollectionMintMode(bool) 00018e84255 function setCollectionMintMode(bool mode) external;256}257258// Selector: d74d154f259interface ERC721UniqueExtensions is Dummy, ERC165 {260 // Selector: transfer(address,uint256) a9059cbb261 function transfer(address to, uint256 tokenId) external;262263 // Selector: burnFrom(address,uint256) 79cc6790264 function burnFrom(address from, uint256 tokenId) external;265266 // Selector: nextTokenId() 75794a3c267 function nextTokenId() external view returns (uint256);268269 // Selector: mintBulk(address,uint256[]) 44a9945e270 function mintBulk(address to, uint256[] memory tokenIds)271 external272 returns (bool);273274 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006275 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)276 external277 returns (bool);278}279280interface UniqueNFT is281 Dummy,282 ERC165,283 ERC721,284 ERC721Metadata,285 ERC721Enumerable,286 ERC721UniqueExtensions,287 ERC721Mintable,288 ERC721Burnable,289 Collection,290 TokenProperties291{}1// SPDX-License-Identifier: OTHER2// This code is automatically generated34pragma solidity >=0.8.0 <0.9.0;56// Anonymous struct7struct Tuple0 {8 uint256 field_0;9 string field_1;10}1112// Common stubs holder13interface Dummy {1415}1617interface ERC165 is Dummy {18 function supportsInterface(bytes4 interfaceID) external view returns (bool);19}2021// Inline22interface ERC721Events {23 event Transfer(24 address indexed from,25 address indexed to,26 uint256 indexed tokenId27 );28 event Approval(29 address indexed owner,30 address indexed approved,31 uint256 indexed tokenId32 );33 event ApprovalForAll(34 address indexed owner,35 address indexed operator,36 bool approved37 );38}3940// Inline41interface ERC721MintableEvents {42 event MintingFinished();43}4445// Selector: 4136937746interface TokenProperties is Dummy, ERC165 {47 // @notice Set permissions for token property.48 // @dev Throws error if `msg.sender` is not admin or owner of the collection.49 // @param key Property key.50 // @param is_mutable Permission to mutate property.51 // @param collection_admin Permission to mutate property by collection admin if property is mutable.52 // @param token_owner Permission to mutate property by token owner if property is mutable.53 //54 // Selector: setTokenPropertyPermission(string,bool,bool,bool) 222d97fa55 function setTokenPropertyPermission(56 string memory key,57 bool isMutable,58 bool collectionAdmin,59 bool tokenOwner60 ) external;6162 // @notice Set token property value.63 // @dev Throws error if `msg.sender` has no permission to edit the property.64 // @param token_id ID of the token.65 // @param key Property key.66 // @param value Property value.67 //68 // Selector: setProperty(uint256,string,bytes) 1752d67b69 function setProperty(70 uint256 tokenId,71 string memory key,72 bytes memory value73 ) external;7475 // @notice Delete token property value.76 // @dev Throws error if `msg.sender` has no permission to edit the property.77 // @param token_id ID of the token.78 // @param key Property key.79 //80 // Selector: deleteProperty(uint256,string) 066111d181 function deleteProperty(uint256 tokenId, string memory key) external;8283 // @notice Get token property value.84 // @dev Throws error if key not found85 // @param token_id ID of the token.86 // @param key Property key.87 //88 // Selector: property(uint256,string) 7228c32789 function property(uint256 tokenId, string memory key)90 external91 view92 returns (bytes memory);93}9495// Selector: 42966c6896interface ERC721Burnable is Dummy, ERC165 {97 // @notice Burns a specific ERC721 token.98 // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized99 // operator of the current owner.100 // @param tokenId The NFT to approve101 //102 // Selector: burn(uint256) 42966c68103 function burn(uint256 tokenId) external;104}105106// Selector: 58800161107interface ERC721 is Dummy, ERC165, ERC721Events {108 // @notice Count all NFTs assigned to an owner109 // @dev NFTs assigned to the zero address are considered invalid, and this110 // function throws for queries about the zero address.111 // @param _owner An address for whom to query the balance112 // @return The number of NFTs owned by `_owner`, possibly zero113 //114 // Selector: balanceOf(address) 70a08231115 function balanceOf(address owner) external view returns (uint256);116117 // @notice Find the owner of an NFT118 // @dev NFTs assigned to zero address are considered invalid, and queries119 // about them do throw.120 // @param _tokenId The identifier for an NFT121 // @return The address of the owner of the NFT122 //123 // Selector: ownerOf(uint256) 6352211e124 function ownerOf(uint256 tokenId) external view returns (address);125126 // @dev Not implemented127 //128 // Selector: safeTransferFromWithData(address,address,uint256,bytes) 60a11672129 function safeTransferFromWithData(130 address from,131 address to,132 uint256 tokenId,133 bytes memory data134 ) external;135136 // @dev Not implemented137 //138 // Selector: safeTransferFrom(address,address,uint256) 42842e0e139 function safeTransferFrom(140 address from,141 address to,142 uint256 tokenId143 ) external;144145 // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE146 // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE147 // THEY MAY BE PERMANENTLY LOST148 // @dev Throws unless `msg.sender` is the current owner or an authorized149 // operator for this NFT. Throws if `from` is not the current owner. Throws150 // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.151 // @param from The current owner of the NFT152 // @param to The new owner153 // @param tokenId The NFT to transfer154 // @param _value Not used for an NFT155 //156 // Selector: transferFrom(address,address,uint256) 23b872dd157 function transferFrom(158 address from,159 address to,160 uint256 tokenId161 ) external;162163 // @notice Set or reaffirm the approved address for an NFT164 // @dev The zero address indicates there is no approved address.165 // @dev Throws unless `msg.sender` is the current NFT owner, or an authorized166 // operator of the current owner.167 // @param approved The new approved NFT controller168 // @param tokenId The NFT to approve169 //170 // Selector: approve(address,uint256) 095ea7b3171 function approve(address approved, uint256 tokenId) external;172173 // @dev Not implemented174 //175 // Selector: setApprovalForAll(address,bool) a22cb465176 function setApprovalForAll(address operator, bool approved) external;177178 // @dev Not implemented179 //180 // Selector: getApproved(uint256) 081812fc181 function getApproved(uint256 tokenId) external view returns (address);182183 // @dev Not implemented184 //185 // Selector: isApprovedForAll(address,address) e985e9c5186 function isApprovedForAll(address owner, address operator)187 external188 view189 returns (address);190}191192// Selector: 5b5e139f193interface ERC721Metadata is Dummy, ERC165 {194 // @notice A descriptive name for a collection of NFTs in this contract195 //196 // Selector: name() 06fdde03197 function name() external view returns (string memory);198199 // @notice An abbreviated name for NFTs in this contract200 //201 // Selector: symbol() 95d89b41202 function symbol() external view returns (string memory);203204 // @notice A distinct Uniform Resource Identifier (URI) for a given asset.205 // @dev Throws if `tokenId` is not a valid NFT. URIs are defined in RFC206 // 3986. The URI may point to a JSON file that conforms to the "ERC721207 // Metadata JSON Schema".208 // @return token's const_metadata209 //210 // Selector: tokenURI(uint256) c87b56dd211 function tokenURI(uint256 tokenId) external view returns (string memory);212}213214// Selector: 68ccfe89215interface ERC721Mintable is Dummy, ERC165, ERC721MintableEvents {216 // Selector: mintingFinished() 05d2035b217 function mintingFinished() external view returns (bool);218219 // @notice Function to mint token.220 // @dev `tokenId` should be obtained with `nextTokenId` method,221 // unlike standard, you can't specify it manually222 // @param to The new owner223 // @param tokenId ID of the minted NFT224 //225 // Selector: mint(address,uint256) 40c10f19226 function mint(address to, uint256 tokenId) external returns (bool);227228 // @notice Function to mint token with the given tokenUri.229 // @dev `tokenId` should be obtained with `nextTokenId` method,230 // unlike standard, you can't specify it manually231 // @param to The new owner232 // @param tokenId ID of the minted NFT233 // @param tokenUri Token URI that would be stored in the NFT properties234 //235 // Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f236 function mintWithTokenURI(237 address to,238 uint256 tokenId,239 string memory tokenUri240 ) external returns (bool);241242 // @dev Not implemented243 //244 // Selector: finishMinting() 7d64bcb4245 function finishMinting() external returns (bool);246}247248// Selector: 780e9d63249interface ERC721Enumerable is Dummy, ERC165 {250 // @notice Enumerate valid NFTs251 // @dev Throws if `index` >= `totalSupply()`.252 // @param index A counter less than `totalSupply()`253 // @return The token identifier for the `index`th NFT,254 // (sort order not specified)255 //256 // Selector: tokenByIndex(uint256) 4f6ccce7257 function tokenByIndex(uint256 index) external view returns (uint256);258259 // @dev Not implemented260 //261 // Selector: tokenOfOwnerByIndex(address,uint256) 2f745c59262 function tokenOfOwnerByIndex(address owner, uint256 index)263 external264 view265 returns (uint256);266267 // @notice Count NFTs tracked by this contract268 // @return A count of valid NFTs tracked by this contract, where each one of269 // them has an assigned and queryable owner not equal to the zero address270 //271 // Selector: totalSupply() 18160ddd272 function totalSupply() external view returns (uint256);273}274275// Selector: 7d9262e6276interface Collection is Dummy, ERC165 {277 // Selector: setCollectionProperty(string,bytes) 2f073f66278 function setCollectionProperty(string memory key, bytes memory value)279 external;280281 // Selector: deleteCollectionProperty(string) 7b7debce282 function deleteCollectionProperty(string memory key) external;283284 // Throws error if key not found285 //286 // Selector: collectionProperty(string) cf24fd6d287 function collectionProperty(string memory key)288 external289 view290 returns (bytes memory);291292 // Selector: setCollectionSponsor(address) 7623402e293 function setCollectionSponsor(address sponsor) external;294295 // Selector: confirmCollectionSponsorship() 3c50e97a296 function confirmCollectionSponsorship() external;297298 // Selector: setCollectionLimit(string,uint32) 6a3841db299 function setCollectionLimit(string memory limit, uint32 value) external;300301 // Selector: setCollectionLimit(string,bool) 993b7fba302 function setCollectionLimit(string memory limit, bool value) external;303304 // Selector: contractAddress() f6b4dfb4305 function contractAddress() external view returns (address);306307 // Selector: addCollectionAdminSubstrate(uint256) 5730062b308 function addCollectionAdminSubstrate(uint256 newAdmin) external view;309310 // Selector: removeCollectionAdminSubstrate(uint256) 4048fcf9311 function removeCollectionAdminSubstrate(uint256 newAdmin) external view;312313 // Selector: addCollectionAdmin(address) 92e462c7314 function addCollectionAdmin(address newAdmin) external view;315316 // Selector: removeCollectionAdmin(address) fafd7b42317 function removeCollectionAdmin(address admin) external view;318319 // Selector: setCollectionNesting(bool) 112d4586320 function setCollectionNesting(bool enable) external;321322 // Selector: setCollectionNesting(bool,address[]) 64872396323 function setCollectionNesting(bool enable, address[] memory collections)324 external;325326 // Selector: setCollectionAccess(uint8) 41835d4c327 function setCollectionAccess(uint8 mode) external;328329 // Selector: addToCollectionAllowList(address) 67844fe6330 function addToCollectionAllowList(address user) external view;331332 // Selector: removeFromCollectionAllowList(address) 85c51acb333 function removeFromCollectionAllowList(address user) external view;334335 // Selector: setCollectionMintMode(bool) 00018e84336 function setCollectionMintMode(bool mode) external;337}338339// Selector: d74d154f340interface ERC721UniqueExtensions is Dummy, ERC165 {341 // @notice Transfer ownership of an NFT -- THE CALLER IS RESPONSIBLE342 // TO CONFIRM THAT `to` IS CAPABLE OF RECEIVING NFTS OR ELSE343 // THEY MAY BE PERMANENTLY LOST344 // @dev Throws unless `msg.sender` is the current owner. Throws if `to`345 // is the zero address. Throws if `tokenId` is not a valid NFT.346 // @param to The new owner347 // @param tokenId The NFT to transfer348 // @param _value Not used for an NFT349 //350 // Selector: transfer(address,uint256) a9059cbb351 function transfer(address to, uint256 tokenId) external;352353 // @notice Burns a specific ERC721 token.354 // @dev Throws unless `msg.sender` is the current owner or an authorized355 // operator for this NFT. Throws if `from` is not the current owner. Throws356 // if `to` is the zero address. Throws if `tokenId` is not a valid NFT.357 // @param from The current owner of the NFT358 // @param tokenId The NFT to transfer359 // @param _value Not used for an NFT360 //361 // Selector: burnFrom(address,uint256) 79cc6790362 function burnFrom(address from, uint256 tokenId) external;363364 // @notice Returns next free NFT ID.365 //366 // Selector: nextTokenId() 75794a3c367 function nextTokenId() external view returns (uint256);368369 // @notice Function to mint multiple tokens.370 // @dev `tokenIds` should be an array of consecutive numbers and first number371 // should be obtained with `nextTokenId` method372 // @param to The new owner373 // @param tokenIds IDs of the minted NFTs374 //375 // Selector: mintBulk(address,uint256[]) 44a9945e376 function mintBulk(address to, uint256[] memory tokenIds)377 external378 returns (bool);379380 // @notice Function to mint multiple tokens with the given tokenUris.381 // @dev `tokenIds` is array of pairs of token ID and token URI. Token IDs should be consecutive382 // numbers and first number should be obtained with `nextTokenId` method383 // @param to The new owner384 // @param tokens array of pairs of token ID and token URI for minted tokens385 //386 // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006387 function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)388 external389 returns (bool);390}391392interface UniqueNFT is393 Dummy,394 ERC165,395 ERC721,396 ERC721Metadata,397 ERC721Enumerable,398 ERC721UniqueExtensions,399 ERC721Mintable,400 ERC721Burnable,401 Collection,402 TokenProperties403{}