difftreelog
chore implement transfer and burn for ERC-721
in: master
9 files changed
Makefilediffbeforeafterboth--- a/Makefile
+++ b/Makefile
@@ -41,10 +41,6 @@
UniqueRefungible.sol:
PACKAGE=pallet-refungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
PACKAGE=pallet-refungible NAME=erc::gen_impl OUTPUT=$(REFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
-
-UniqueRefungible.sol:
- PACKAGE=pallet-refungible NAME=erc::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
- PACKAGE=pallet-refungible NAME=erc::gen_impl OUTPUT=$(REFUNGIBLE_EVM_STUBS)/$@ ./.maintain/scripts/generate_sol.sh
UniqueRefungibleToken.sol:
PACKAGE=pallet-refungible NAME=erc_token::gen_iface OUTPUT=$(TESTS_API)/$@ ./.maintain/scripts/generate_sol.sh
@@ -73,10 +69,6 @@
UniqueRefungibleToken: UniqueRefungibleToken.sol
INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungibleToken.raw ./.maintain/scripts/compile_stub.sh
INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_TOKEN_EVM_ABI) ./.maintain/scripts/generate_abi.sh
-
-UniqueRefungible: UniqueRefungible.sol
- INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_STUBS)/UniqueRefungible.raw ./.maintain/scripts/compile_stub.sh
- INPUT=$(REFUNGIBLE_EVM_STUBS)/$< OUTPUT=$(REFUNGIBLE_EVM_ABI) ./.maintain/scripts/generate_abi.sh
ContractHelpers: ContractHelpers.sol
INPUT=$(CONTRACT_HELPERS_STUBS)/$< OUTPUT=$(CONTRACT_HELPERS_STUBS)/ContractHelpers.raw ./.maintain/scripts/compile_stub.sh
pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -34,8 +34,9 @@
CommonEvmHandler, CollectionCall,
static_property::{key, value as property_value},
},
+ eth::collection_id_to_address,
};
-use pallet_evm::{account::CrossAccountId, PrecompileHandle};
+use pallet_evm::{account::CrossAccountId, Pallet as PalletEvm, PrecompileHandle};
use pallet_evm_coder_substrate::{call, dispatch_to_evm};
use pallet_structure::{SelfWeightOf as StructureWeight, weights::WeightInfo as _};
use sp_core::H160;
@@ -46,8 +47,8 @@
};
use crate::{
- AccountBalance, Config, CreateItemData, Pallet, RefungibleHandle, SelfWeightOf,
- TokenProperties, TokensMinted, weights::WeightInfo,
+ AccountBalance, Balance, Config, CreateItemData, Pallet, RefungibleHandle, SelfWeightOf,
+ TokenProperties, TokensMinted, TotalSupply, weights::WeightInfo,
};
/// @title A contract that allows to set and delete token properties and change token property permissions.
@@ -331,16 +332,49 @@
Err("not implemented".into())
}
- /// @dev Not implemented
+ /// @notice Transfer ownership of an RFT -- 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 RFT. Throws if `from` is not the current owner. Throws
+ /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+ /// Throws if RFT pieces have multiple owners.
+ /// @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_creating_removing())]
fn transfer_from(
&mut self,
- _caller: caller,
- _from: address,
- _to: address,
- _token_id: uint256,
+ caller: caller,
+ from: address,
+ to: address,
+ token_id: uint256,
_value: value,
) -> Result<void> {
- Err("not implemented".into())
+ let caller = T::CrossAccountId::from_eth(caller);
+ let from = T::CrossAccountId::from_eth(from);
+ let to = T::CrossAccountId::from_eth(to);
+ let token = token_id.try_into()?;
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ let balance = balance(&self, token, &from)?;
+ ensure_single_owner(&self, token, balance)?;
+
+ <Pallet<T>>::transfer_from(self, &caller, &from, &to, token, balance, &budget)
+ .map_err(dispatch_to_evm::<T>)?;
+
+ <PalletEvm<T>>::deposit_log(
+ ERC721Events::Transfer {
+ from: *from.as_eth(),
+ to: *to.as_eth(),
+ token_id: token_id.into(),
+ }
+ .to_log(collection_id_to_address(self.id)),
+ );
+ Ok(())
}
/// @dev Not implemented
@@ -378,12 +412,48 @@
}
}
+/// Returns amount of pieces of `token` that `owner` have
+fn balance<T: Config>(
+ collection: &RefungibleHandle<T>,
+ token: TokenId,
+ owner: &T::CrossAccountId,
+) -> Result<u128> {
+ collection.consume_store_reads(1)?;
+ let balance = <Balance<T>>::get((collection.id, token, &owner));
+ Ok(balance)
+}
+
+/// Throws if `owner_balance` is lower than total amount of `token` pieces
+fn ensure_single_owner<T: Config>(
+ collection: &RefungibleHandle<T>,
+ token: TokenId,
+ owner_balance: u128,
+) -> Result<()> {
+ collection.consume_store_reads(1)?;
+ let total_supply = <TotalSupply<T>>::get((collection.id, token));
+ if total_supply != owner_balance {
+ return Err("token has multiple owners".into());
+ }
+ Ok(())
+}
+
/// @title ERC721 Token that can be irreversibly burned (destroyed).
#[solidity_interface(name = "ERC721Burnable")]
impl<T: Config> RefungibleHandle<T> {
- /// @dev Not implemented
- fn burn(&mut self, _caller: caller, _token_id: uint256, _value: value) -> Result<void> {
- Err("not implemented".into())
+ /// @notice Burns a specific ERC721 token.
+ /// @dev Throws unless `msg.sender` is the current RFT owner, or an authorized
+ /// operator of the current owner.
+ /// @param tokenId The RFT to approve
+ #[weight(<SelfWeightOf<T>>::burn_item_fully())]
+ fn burn(&mut self, caller: caller, token_id: uint256) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let token = token_id.try_into()?;
+
+ let balance = balance(&self, token, &caller)?;
+ ensure_single_owner(&self, token, balance)?;
+
+ <Pallet<T>>::burn(self, &caller, token, balance).map_err(dispatch_to_evm::<T>)?;
+ Ok(())
}
}
@@ -555,6 +625,75 @@
/// @title Unique extensions for ERC721.
#[solidity_interface(name = "ERC721UniqueExtensions")]
impl<T: Config> RefungibleHandle<T> {
+ /// @notice Transfer ownership of an RFT
+ /// @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+ /// is the zero address. Throws if `tokenId` is not a valid RFT.
+ /// Throws if RFT pieces have multiple owners.
+ /// @param to The new owner
+ /// @param tokenId The RFT to transfer
+ /// @param _value Not used for an RFT
+ #[weight(<SelfWeightOf<T>>::transfer_creating_removing())]
+ fn transfer(
+ &mut self,
+ caller: caller,
+ to: address,
+ token_id: uint256,
+ _value: value,
+ ) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let to = T::CrossAccountId::from_eth(to);
+ let token = token_id.try_into()?;
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ let balance = balance(&self, token, &caller)?;
+ ensure_single_owner(&self, token, balance)?;
+
+ <Pallet<T>>::transfer(self, &caller, &to, token, balance, &budget)
+ .map_err(dispatch_to_evm::<T>)?;
+ <PalletEvm<T>>::deposit_log(
+ ERC721Events::Transfer {
+ from: *caller.as_eth(),
+ to: *to.as_eth(),
+ token_id: token_id.into(),
+ }
+ .to_log(collection_id_to_address(self.id)),
+ );
+ Ok(())
+ }
+
+ /// @notice Burns a specific ERC721 token.
+ /// @dev Throws unless `msg.sender` is the current owner or an authorized
+ /// operator for this RFT. Throws if `from` is not the current owner. Throws
+ /// if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+ /// Throws if RFT pieces have multiple owners.
+ /// @param from The current owner of the RFT
+ /// @param tokenId The RFT to transfer
+ /// @param _value Not used for an RFT
+ #[weight(<SelfWeightOf<T>>::burn_from())]
+ fn burn_from(
+ &mut self,
+ caller: caller,
+ from: address,
+ token_id: uint256,
+ _value: value,
+ ) -> Result<void> {
+ let caller = T::CrossAccountId::from_eth(caller);
+ let from = T::CrossAccountId::from_eth(from);
+ let token = token_id.try_into()?;
+ let budget = self
+ .recorder
+ .weight_calls_budget(<StructureWeight<T>>::find_parent());
+
+ let balance = balance(&self, token, &caller)?;
+ ensure_single_owner(&self, token, balance)?;
+
+ <Pallet<T>>::burn_from(self, &caller, &from, token, balance, &budget)
+ .map_err(dispatch_to_evm::<T>)?;
+ Ok(())
+ }
+
/// @notice Returns next free RFT ID.
fn next_token_id(&self) -> Result<uint256> {
self.consume_store_reads(1)?;
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -454,6 +454,14 @@
<PalletStructure<T>>::unnest_if_nested(owner, collection.id, token);
<AccountBalance<T>>::insert((collection.id, owner), account_balance);
Self::burn_token_unchecked(collection, token)?;
+ <PalletEvm<T>>::deposit_log(
+ ERC721Events::Transfer {
+ from: *owner.as_eth(),
+ to: H160::default(),
+ token_id: token.into(),
+ }
+ .to_log(collection_id_to_address(collection.id)),
+ );
<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
collection.id,
token,
pallets/refungible/src/stubs/UniqueRefungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -51,44 +51,15 @@
event MintingFinished();
}
-// Selector: 0784ee64
-contract ERC721UniqueExtensions is Dummy, ERC165 {
- // @notice Returns next free RFT ID.
- //
- // Selector: nextTokenId() 75794a3c
- function nextTokenId() public view returns (uint256) {
- require(false, stub_error);
- dummy;
- return 0;
- }
-
- // Selector: mintBulk(address,uint256[]) 44a9945e
- function mintBulk(address to, uint256[] memory tokenIds)
- public
- returns (bool)
- {
- require(false, stub_error);
- to;
- tokenIds;
- dummy = 0;
- return false;
- }
-
- // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
- function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
- public
- returns (bool)
- {
- require(false, stub_error);
- to;
- tokens;
- dummy = 0;
- return false;
- }
-}
-
// 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,
@@ -104,6 +75,12 @@
dummy = 0;
}
+ // @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.
+ //
// Selector: setProperty(uint256,string,bytes) 1752d67b
function setProperty(
uint256 tokenId,
@@ -117,6 +94,11 @@
dummy = 0;
}
+ // @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.
+ //
// Selector: deleteProperty(uint256,string) 066111d1
function deleteProperty(uint256 tokenId, string memory key) public {
require(false, stub_error);
@@ -125,7 +107,11 @@
dummy = 0;
}
- // 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.
+ // @return Property value bytes
//
// Selector: property(uint256,string) 7228c327
function property(uint256 tokenId, string memory key)
@@ -143,7 +129,10 @@
// Selector: 42966c68
contract ERC721Burnable is Dummy, ERC165 {
- // @dev Not implemented
+ // @notice Burns a specific ERC721 token.
+ // @dev Throws unless `msg.sender` is the current RFT owner, or an authorized
+ // operator of the current owner.
+ // @param tokenId The RFT to approve
//
// Selector: burn(uint256) 42966c68
function burn(uint256 tokenId) public {
@@ -155,6 +144,12 @@
// Selector: 58800161
contract ERC721 is Dummy, ERC165, ERC721Events {
+ // @notice Count all RFTs assigned to an owner
+ // @dev RFTs 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 RFTs owned by `owner`, possibly zero
+ //
// Selector: balanceOf(address) 70a08231
function balanceOf(address owner) public view returns (uint256) {
require(false, stub_error);
@@ -203,7 +198,17 @@
dummy = 0;
}
- // @dev Not implemented
+ // @notice Transfer ownership of an RFT -- 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 RFT. Throws if `from` is not the current owner. Throws
+ // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+ // Throws if RFT pieces have multiple owners.
+ // @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(
@@ -266,6 +271,8 @@
// Selector: 5b5e139f
contract ERC721Metadata is Dummy, ERC165 {
+ // @notice A descriptive name for a collection of RFTs in this contract
+ //
// Selector: name() 06fdde03
function name() public view returns (string memory) {
require(false, stub_error);
@@ -273,6 +280,8 @@
return "";
}
+ // @notice An abbreviated name for RFTs in this contract
+ //
// Selector: symbol() 95d89b41
function symbol() public view returns (string memory) {
require(false, stub_error);
@@ -280,7 +289,15 @@
return "";
}
- // Returns token's const_metadata
+ // @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+ //
+ // @dev If the token has a `url` property and it is not empty, it is returned.
+ // 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`.
+ // If the collection property `baseURI` is empty or absent, return "" (empty string)
+ // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
+ // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
+ //
+ // @return token's const_metadata
//
// Selector: tokenURI(uint256) c87b56dd
function tokenURI(uint256 tokenId) public view returns (string memory) {
@@ -300,8 +317,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 RFT
//
// Selector: mint(address,uint256) 40c10f19
function mint(address to, uint256 tokenId) public returns (bool) {
@@ -312,8 +332,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 RFT
+ // @param tokenUri Token URI that would be stored in the RFT properties
//
// Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f
function mintWithTokenURI(
@@ -341,6 +365,11 @@
// Selector: 780e9d63
contract ERC721Enumerable is Dummy, ERC165 {
+ // @notice Enumerate valid RFTs
+ // @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);
@@ -364,6 +393,10 @@
return 0;
}
+ // @notice Count RFTs tracked by this contract
+ // @return A count of valid RFTs 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);
@@ -599,6 +632,87 @@
}
}
+// Selector: d74d154f
+contract ERC721UniqueExtensions is Dummy, ERC165 {
+ // @notice Transfer ownership of an RFT
+ // @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+ // is the zero address. Throws if `tokenId` is not a valid RFT.
+ // Throws if RFT pieces have multiple owners.
+ // @param to The new owner
+ // @param tokenId The RFT to transfer
+ // @param _value Not used for an RFT
+ //
+ // Selector: transfer(address,uint256) a9059cbb
+ function transfer(address to, uint256 tokenId) public {
+ require(false, stub_error);
+ to;
+ tokenId;
+ dummy = 0;
+ }
+
+ // @notice Burns a specific ERC721 token.
+ // @dev Throws unless `msg.sender` is the current owner or an authorized
+ // operator for this RFT. Throws if `from` is not the current owner. Throws
+ // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+ // Throws if RFT pieces have multiple owners.
+ // @param from The current owner of the RFT
+ // @param tokenId The RFT to transfer
+ // @param _value Not used for an RFT
+ //
+ // Selector: burnFrom(address,uint256) 79cc6790
+ function burnFrom(address from, uint256 tokenId) public {
+ require(false, stub_error);
+ from;
+ tokenId;
+ dummy = 0;
+ }
+
+ // @notice Returns next free RFT ID.
+ //
+ // Selector: nextTokenId() 75794a3c
+ function nextTokenId() public view returns (uint256) {
+ require(false, stub_error);
+ dummy;
+ 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 RFTs
+ //
+ // Selector: mintBulk(address,uint256[]) 44a9945e
+ function mintBulk(address to, uint256[] memory tokenIds)
+ public
+ returns (bool)
+ {
+ require(false, stub_error);
+ to;
+ tokenIds;
+ dummy = 0;
+ 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
+ returns (bool)
+ {
+ require(false, stub_error);
+ to;
+ tokens;
+ dummy = 0;
+ return false;
+ }
+}
+
contract UniqueRefungible is
Dummy,
ERC165,
pallets/refungible/src/stubs/UniqueRefungibleToken.rawdiffbeforeafterbothbinary blob — no preview
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -42,26 +42,15 @@
event MintingFinished();
}
-// Selector: 0784ee64
-interface ERC721UniqueExtensions is Dummy, ERC165 {
- // @notice Returns next free RFT ID.
- //
- // Selector: nextTokenId() 75794a3c
- function nextTokenId() external view returns (uint256);
-
- // Selector: mintBulk(address,uint256[]) 44a9945e
- function mintBulk(address to, uint256[] memory tokenIds)
- external
- returns (bool);
-
- // Selector: mintBulkWithTokenURI(address,(uint256,string)[]) 36543006
- function mintBulkWithTokenURI(address to, Tuple0[] memory tokens)
- external
- returns (bool);
-}
-
// Selector: 41369377
interface 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,
@@ -70,6 +59,12 @@
bool tokenOwner
) external;
+ // @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.
+ //
// Selector: setProperty(uint256,string,bytes) 1752d67b
function setProperty(
uint256 tokenId,
@@ -77,10 +72,19 @@
bytes memory value
) external;
+ // @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.
+ //
// Selector: deleteProperty(uint256,string) 066111d1
function deleteProperty(uint256 tokenId, string memory key) external;
- // 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.
+ // @return Property value bytes
//
// Selector: property(uint256,string) 7228c327
function property(uint256 tokenId, string memory key)
@@ -91,7 +95,10 @@
// Selector: 42966c68
interface ERC721Burnable is Dummy, ERC165 {
- // @dev Not implemented
+ // @notice Burns a specific ERC721 token.
+ // @dev Throws unless `msg.sender` is the current RFT owner, or an authorized
+ // operator of the current owner.
+ // @param tokenId The RFT to approve
//
// Selector: burn(uint256) 42966c68
function burn(uint256 tokenId) external;
@@ -99,6 +106,12 @@
// Selector: 58800161
interface ERC721 is Dummy, ERC165, ERC721Events {
+ // @notice Count all RFTs assigned to an owner
+ // @dev RFTs 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 RFTs owned by `owner`, possibly zero
+ //
// Selector: balanceOf(address) 70a08231
function balanceOf(address owner) external view returns (uint256);
@@ -124,7 +137,17 @@
uint256 tokenId
) external;
- // @dev Not implemented
+ // @notice Transfer ownership of an RFT -- 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 RFT. Throws if `from` is not the current owner. Throws
+ // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+ // Throws if RFT pieces have multiple owners.
+ // @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(
@@ -159,13 +182,25 @@
// Selector: 5b5e139f
interface ERC721Metadata is Dummy, ERC165 {
+ // @notice A descriptive name for a collection of RFTs in this contract
+ //
// Selector: name() 06fdde03
function name() external view returns (string memory);
+ // @notice An abbreviated name for RFTs in this contract
+ //
// Selector: symbol() 95d89b41
function symbol() external view returns (string memory);
- // Returns token's const_metadata
+ // @notice A distinct Uniform Resource Identifier (URI) for a given asset.
+ //
+ // @dev If the token has a `url` property and it is not empty, it is returned.
+ // 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`.
+ // If the collection property `baseURI` is empty or absent, return "" (empty string)
+ // otherwise, if token property `suffix` present and is non-empty, return concatenation of baseURI and suffix
+ // otherwise, return concatenation of `baseURI` and stringified token id (decimal stringifying, without paddings).
+ //
+ // @return token's const_metadata
//
// Selector: tokenURI(uint256) c87b56dd
function tokenURI(uint256 tokenId) external view returns (string memory);
@@ -176,14 +211,21 @@
// Selector: mintingFinished() 05d2035b
function mintingFinished() external view returns (bool);
- // `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 RFT
//
// Selector: mint(address,uint256) 40c10f19
function mint(address to, uint256 tokenId) external returns (bool);
- // `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 RFT
+ // @param tokenUri Token URI that would be stored in the RFT properties
//
// Selector: mintWithTokenURI(address,uint256,string) 50bb4e7f
function mintWithTokenURI(
@@ -200,6 +242,11 @@
// Selector: 780e9d63
interface ERC721Enumerable is Dummy, ERC165 {
+ // @notice Enumerate valid RFTs
+ // @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) external view returns (uint256);
@@ -211,6 +258,10 @@
view
returns (uint256);
+ // @notice Count RFTs tracked by this contract
+ // @return A count of valid RFTs 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() external view returns (uint256);
}
@@ -363,6 +414,59 @@
function setCollectionMintMode(bool mode) external;
}
+// Selector: d74d154f
+interface ERC721UniqueExtensions is Dummy, ERC165 {
+ // @notice Transfer ownership of an RFT
+ // @dev Throws unless `msg.sender` is the current owner. Throws if `to`
+ // is the zero address. Throws if `tokenId` is not a valid RFT.
+ // Throws if RFT pieces have multiple owners.
+ // @param to The new owner
+ // @param tokenId The RFT to transfer
+ // @param _value Not used for an RFT
+ //
+ // Selector: transfer(address,uint256) a9059cbb
+ function transfer(address to, uint256 tokenId) external;
+
+ // @notice Burns a specific ERC721 token.
+ // @dev Throws unless `msg.sender` is the current owner or an authorized
+ // operator for this RFT. Throws if `from` is not the current owner. Throws
+ // if `to` is the zero address. Throws if `tokenId` is not a valid RFT.
+ // Throws if RFT pieces have multiple owners.
+ // @param from The current owner of the RFT
+ // @param tokenId The RFT to transfer
+ // @param _value Not used for an RFT
+ //
+ // Selector: burnFrom(address,uint256) 79cc6790
+ function burnFrom(address from, uint256 tokenId) external;
+
+ // @notice Returns next free RFT ID.
+ //
+ // Selector: nextTokenId() 75794a3c
+ function nextTokenId() external view returns (uint256);
+
+ // @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 RFTs
+ //
+ // Selector: mintBulk(address,uint256[]) 44a9945e
+ function mintBulk(address to, uint256[] memory tokenIds)
+ external
+ returns (bool);
+
+ // @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)
+ external
+ returns (bool);
+}
+
interface UniqueRefungible is
Dummy,
ERC165,
tests/src/eth/reFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/reFungible.test.ts
+++ b/tests/src/eth/reFungible.test.ts
@@ -14,8 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
-import {createCollectionExpectSuccess} from '../util/helpers';
-import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, tokenIdToAddress} from './util/helpers';
+import {createCollectionExpectSuccess, UNIQUE} from '../util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, evmCollection, evmCollectionHelpers, GAS_ARGS, getCollectionAddressFromResult, itWeb3, normalizeEvents, recordEthFee, tokenIdToAddress} from './util/helpers';
import reFungibleAbi from './reFungibleAbi.json';
import reFungibleTokenAbi from './reFungibleTokenAbi.json';
import {expect} from 'chai';
@@ -26,7 +26,7 @@
const helper = evmCollectionHelpers(web3, caller);
const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
- const contract = new web3.eth.Contract(reFungibleAbi as any, collectionIdAddress, {from: caller, ...GAS_ARGS});
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
const nextTokenId = await contract.methods.nextTokenId().call();
await contract.methods.mint(caller, nextTokenId).send();
const totalSupply = await contract.methods.totalSupply().call();
@@ -38,7 +38,7 @@
const helper = evmCollectionHelpers(web3, caller);
const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
- const contract = new web3.eth.Contract(reFungibleAbi as any, collectionIdAddress, {from: caller, ...GAS_ARGS});
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
{
const nextTokenId = await contract.methods.nextTokenId().call();
@@ -63,7 +63,7 @@
const helper = evmCollectionHelpers(web3, caller);
const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
- const contract = new web3.eth.Contract(reFungibleAbi as any, collectionIdAddress, {from: caller, ...GAS_ARGS});
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
const tokenId = await contract.methods.nextTokenId().call();
await contract.methods.mint(caller, tokenId).send();
@@ -79,7 +79,7 @@
const helper = evmCollectionHelpers(web3, caller);
const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
const {collectionIdAddress, collectionId} = await getCollectionAddressFromResult(api, result);
- const contract = new web3.eth.Contract(reFungibleAbi as any, collectionIdAddress, {from: caller, ...GAS_ARGS});
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
const tokenId = await contract.methods.nextTokenId().call();
await contract.methods.mint(caller, tokenId).send();
@@ -105,7 +105,7 @@
let result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
const receiver = createEthAccount(web3);
- const contract = evmCollection(web3, owner, collectionIdAddress);
+ const contract = evmCollection(web3, owner, collectionIdAddress, {type: 'ReFungible'});
const nextTokenId = await contract.methods.nextTokenId().call();
expect(nextTokenId).to.be.equal('1');
@@ -137,7 +137,7 @@
const helper = evmCollectionHelpers(web3, caller);
const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
- const contract = new web3.eth.Contract(reFungibleAbi as any, collectionIdAddress, {from: caller, ...GAS_ARGS});
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
const receiver = createEthAccount(web3);
@@ -189,8 +189,148 @@
expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');
}
});
+
+ itWeb3('Can perform burn()', async ({web3, api, privateKeyWrapper}) => {
+ const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const helper = evmCollectionHelpers(web3, caller);
+ const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
+
+ const tokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(caller, tokenId).send();
+ {
+ const result = await contract.methods.burn(tokenId).send();
+ const events = normalizeEvents(result.events);
+
+ expect(events).to.be.deep.equal([
+ {
+ address: collectionIdAddress,
+ event: 'Transfer',
+ args: {
+ from: caller,
+ to: '0x0000000000000000000000000000000000000000',
+ tokenId: tokenId.toString(),
+ },
+ },
+ ]);
+ }
+ });
+
+ itWeb3('Can perform transferFrom()', async ({web3, api, privateKeyWrapper}) => {
+ const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const helper = evmCollectionHelpers(web3, caller);
+ const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
+
+ const receiver = createEthAccount(web3);
+
+ const tokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(caller, tokenId).send();
+ {
+ const result = await contract.methods.transferFrom(caller, receiver, tokenId).send();
+ const events = normalizeEvents(result.events);
+ expect(events).to.include.deep.members([
+ {
+ address: collectionIdAddress,
+ event: 'Transfer',
+ args: {
+ from: caller,
+ to: receiver,
+ tokenId: tokenId.toString(),
+ },
+ },
+ ]);
+ }
+
+ {
+ const balance = await contract.methods.balanceOf(receiver).call();
+ expect(+balance).to.equal(1);
+ }
+
+ {
+ const balance = await contract.methods.balanceOf(caller).call();
+ expect(+balance).to.equal(0);
+ }
+ });
+
+ itWeb3('Can perform transfer()', async ({web3, api, privateKeyWrapper}) => {
+ const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const helper = evmCollectionHelpers(web3, caller);
+ const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
+
+ const receiver = createEthAccount(web3);
+
+ const tokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(caller, tokenId).send();
+
+ {
+ const result = await contract.methods.transfer(receiver, tokenId).send();
+ const events = normalizeEvents(result.events);
+ expect(events).to.include.deep.members([
+ {
+ address: collectionIdAddress,
+ event: 'Transfer',
+ args: {
+ from: caller,
+ to: receiver,
+ tokenId: tokenId.toString(),
+ },
+ },
+ ]);
+ }
+
+ {
+ const balance = await contract.methods.balanceOf(caller).call();
+ expect(+balance).to.equal(0);
+ }
+
+ {
+ const balance = await contract.methods.balanceOf(receiver).call();
+ expect(+balance).to.equal(1);
+ }
+ });
});
+describe('RFT: Fees', () => {
+ itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
+ const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const helper = evmCollectionHelpers(web3, caller);
+ const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
+
+ const receiver = createEthAccount(web3);
+
+ const tokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(caller, tokenId).send();
+
+ const cost = await recordEthFee(api, caller, () => contract.methods.transferFrom(caller, receiver, tokenId).send());
+ expect(cost < BigInt(0.2 * Number(UNIQUE)));
+ expect(cost > 0n);
+ });
+
+ itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api, privateKeyWrapper}) => {
+ const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
+ const helper = evmCollectionHelpers(web3, caller);
+ const result = await helper.methods.createRefungibleCollection('Mint collection', '6', '6').send();
+ const {collectionIdAddress} = await getCollectionAddressFromResult(api, result);
+ const contract = evmCollection(web3, caller, collectionIdAddress, {type: 'ReFungible'});
+
+ const receiver = createEthAccount(web3);
+
+ const tokenId = await contract.methods.nextTokenId().call();
+ await contract.methods.mint(caller, tokenId).send();
+
+ const cost = await recordEthFee(api, caller, () => contract.methods.transfer(receiver, tokenId).send());
+ expect(cost < BigInt(0.2 * Number(UNIQUE)));
+ expect(cost > 0n);
+ });
+});
+
describe('Common metadata', () => {
itWeb3('Returns collection name', async ({api, web3, privateKeyWrapper}) => {
const collection = await createCollectionExpectSuccess({
@@ -200,7 +340,7 @@
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(reFungibleAbi as any, address, {from: caller, ...GAS_ARGS});
+ const contract = evmCollection(web3, caller, address, {type: 'ReFungible'});
const name = await contract.methods.name().call();
expect(name).to.equal('token name');
@@ -214,7 +354,7 @@
const caller = await createEthAccountWithBalance(api, web3, privateKeyWrapper);
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(reFungibleAbi as any, address, {from: caller, ...GAS_ARGS});
+ const contract = evmCollection(web3, caller, address, {type: 'ReFungible'});
const symbol = await contract.methods.symbol().call();
expect(symbol).to.equal('TOK');
tests/src/eth/reFungibleAbi.jsondiffbeforeafterboth1[2 {3 "anonymous": false,4 "inputs": [5 {6 "indexed": true,7 "internalType": "address",8 "name": "owner",9 "type": "address"10 },11 {12 "indexed": true,13 "internalType": "address",14 "name": "approved",15 "type": "address"16 },17 {18 "indexed": true,19 "internalType": "uint256",20 "name": "tokenId",21 "type": "uint256"22 }23 ],24 "name": "Approval",25 "type": "event"26 },27 {28 "anonymous": false,29 "inputs": [30 {31 "indexed": true,32 "internalType": "address",33 "name": "owner",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "operator",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "bool",45 "name": "approved",46 "type": "bool"47 }48 ],49 "name": "ApprovalForAll",50 "type": "event"51 },52 {53 "anonymous": false,54 "inputs": [],55 "name": "MintingFinished",56 "type": "event"57 },58 {59 "anonymous": false,60 "inputs": [61 {62 "indexed": true,63 "internalType": "address",64 "name": "from",65 "type": "address"66 },67 {68 "indexed": true,69 "internalType": "address",70 "name": "to",71 "type": "address"72 },73 {74 "indexed": true,75 "internalType": "uint256",76 "name": "tokenId",77 "type": "uint256"78 }79 ],80 "name": "Transfer",81 "type": "event"82 },83 {84 "inputs": [85 { "internalType": "address", "name": "newAdmin", "type": "address" }86 ],87 "name": "addCollectionAdmin",88 "outputs": [],89 "stateMutability": "nonpayable",90 "type": "function"91 },92 {93 "inputs": [94 { "internalType": "uint256", "name": "newAdmin", "type": "uint256" }95 ],96 "name": "addCollectionAdminSubstrate",97 "outputs": [],98 "stateMutability": "nonpayable",99 "type": "function"100 },101 {102 "inputs": [103 { "internalType": "address", "name": "user", "type": "address" }104 ],105 "name": "addToCollectionAllowList",106 "outputs": [],107 "stateMutability": "nonpayable",108 "type": "function"109 },110 {111 "inputs": [112 { "internalType": "address", "name": "approved", "type": "address" },113 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }114 ],115 "name": "approve",116 "outputs": [],117 "stateMutability": "nonpayable",118 "type": "function"119 },120 {121 "inputs": [122 { "internalType": "address", "name": "owner", "type": "address" }123 ],124 "name": "balanceOf",125 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],126 "stateMutability": "view",127 "type": "function"128 },129 {130 "inputs": [131 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }132 ],133 "name": "burn",134 "outputs": [],135 "stateMutability": "nonpayable",136 "type": "function"137 },138 {139 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],140 "name": "collectionProperty",141 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],142 "stateMutability": "view",143 "type": "function"144 },145 {146 "inputs": [],147 "name": "confirmCollectionSponsorship",148 "outputs": [],149 "stateMutability": "nonpayable",150 "type": "function"151 },152 {153 "inputs": [],154 "name": "contractAddress",155 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],156 "stateMutability": "view",157 "type": "function"158 },159 {160 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],161 "name": "deleteCollectionProperty",162 "outputs": [],163 "stateMutability": "nonpayable",164 "type": "function"165 },166 {167 "inputs": [168 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },169 { "internalType": "string", "name": "key", "type": "string" }170 ],171 "name": "deleteProperty",172 "outputs": [],173 "stateMutability": "nonpayable",174 "type": "function"175 },176 {177 "inputs": [],178 "name": "finishMinting",179 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],180 "stateMutability": "nonpayable",181 "type": "function"182 },183 {184 "inputs": [185 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }186 ],187 "name": "getApproved",188 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],189 "stateMutability": "view",190 "type": "function"191 },192 {193 "inputs": [194 { "internalType": "address", "name": "owner", "type": "address" },195 { "internalType": "address", "name": "operator", "type": "address" }196 ],197 "name": "isApprovedForAll",198 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],199 "stateMutability": "view",200 "type": "function"201 },202 {203 "inputs": [204 { "internalType": "address", "name": "to", "type": "address" },205 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }206 ],207 "name": "mint",208 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],209 "stateMutability": "nonpayable",210 "type": "function"211 },212 {213 "inputs": [214 { "internalType": "address", "name": "to", "type": "address" },215 { "internalType": "uint256[]", "name": "tokenIds", "type": "uint256[]" }216 ],217 "name": "mintBulk",218 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],219 "stateMutability": "nonpayable",220 "type": "function"221 },222 {223 "inputs": [224 { "internalType": "address", "name": "to", "type": "address" },225 {226 "components": [227 { "internalType": "uint256", "name": "field_0", "type": "uint256" },228 { "internalType": "string", "name": "field_1", "type": "string" }229 ],230 "internalType": "struct Tuple0[]",231 "name": "tokens",232 "type": "tuple[]"233 }234 ],235 "name": "mintBulkWithTokenURI",236 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],237 "stateMutability": "nonpayable",238 "type": "function"239 },240 {241 "inputs": [242 { "internalType": "address", "name": "to", "type": "address" },243 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },244 { "internalType": "string", "name": "tokenUri", "type": "string" }245 ],246 "name": "mintWithTokenURI",247 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],248 "stateMutability": "nonpayable",249 "type": "function"250 },251 {252 "inputs": [],253 "name": "mintingFinished",254 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],255 "stateMutability": "view",256 "type": "function"257 },258 {259 "inputs": [],260 "name": "name",261 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],262 "stateMutability": "view",263 "type": "function"264 },265 {266 "inputs": [],267 "name": "nextTokenId",268 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],269 "stateMutability": "view",270 "type": "function"271 },272 {273 "inputs": [274 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }275 ],276 "name": "ownerOf",277 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],278 "stateMutability": "view",279 "type": "function"280 },281 {282 "inputs": [283 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },284 { "internalType": "string", "name": "key", "type": "string" }285 ],286 "name": "property",287 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],288 "stateMutability": "view",289 "type": "function"290 },291 {292 "inputs": [293 { "internalType": "address", "name": "admin", "type": "address" }294 ],295 "name": "removeCollectionAdmin",296 "outputs": [],297 "stateMutability": "nonpayable",298 "type": "function"299 },300 {301 "inputs": [302 { "internalType": "uint256", "name": "admin", "type": "uint256" }303 ],304 "name": "removeCollectionAdminSubstrate",305 "outputs": [],306 "stateMutability": "nonpayable",307 "type": "function"308 },309 {310 "inputs": [311 { "internalType": "address", "name": "user", "type": "address" }312 ],313 "name": "removeFromCollectionAllowList",314 "outputs": [],315 "stateMutability": "nonpayable",316 "type": "function"317 },318 {319 "inputs": [320 { "internalType": "address", "name": "from", "type": "address" },321 { "internalType": "address", "name": "to", "type": "address" },322 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }323 ],324 "name": "safeTransferFrom",325 "outputs": [],326 "stateMutability": "nonpayable",327 "type": "function"328 },329 {330 "inputs": [331 { "internalType": "address", "name": "from", "type": "address" },332 { "internalType": "address", "name": "to", "type": "address" },333 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },334 { "internalType": "bytes", "name": "data", "type": "bytes" }335 ],336 "name": "safeTransferFromWithData",337 "outputs": [],338 "stateMutability": "nonpayable",339 "type": "function"340 },341 {342 "inputs": [343 { "internalType": "address", "name": "operator", "type": "address" },344 { "internalType": "bool", "name": "approved", "type": "bool" }345 ],346 "name": "setApprovalForAll",347 "outputs": [],348 "stateMutability": "nonpayable",349 "type": "function"350 },351 {352 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],353 "name": "setCollectionAccess",354 "outputs": [],355 "stateMutability": "nonpayable",356 "type": "function"357 },358 {359 "inputs": [360 { "internalType": "string", "name": "limit", "type": "string" },361 { "internalType": "uint32", "name": "value", "type": "uint32" }362 ],363 "name": "setCollectionLimit",364 "outputs": [],365 "stateMutability": "nonpayable",366 "type": "function"367 },368 {369 "inputs": [370 { "internalType": "string", "name": "limit", "type": "string" },371 { "internalType": "bool", "name": "value", "type": "bool" }372 ],373 "name": "setCollectionLimit",374 "outputs": [],375 "stateMutability": "nonpayable",376 "type": "function"377 },378 {379 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],380 "name": "setCollectionMintMode",381 "outputs": [],382 "stateMutability": "nonpayable",383 "type": "function"384 },385 {386 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],387 "name": "setCollectionNesting",388 "outputs": [],389 "stateMutability": "nonpayable",390 "type": "function"391 },392 {393 "inputs": [394 { "internalType": "bool", "name": "enable", "type": "bool" },395 {396 "internalType": "address[]",397 "name": "collections",398 "type": "address[]"399 }400 ],401 "name": "setCollectionNesting",402 "outputs": [],403 "stateMutability": "nonpayable",404 "type": "function"405 },406 {407 "inputs": [408 { "internalType": "string", "name": "key", "type": "string" },409 { "internalType": "bytes", "name": "value", "type": "bytes" }410 ],411 "name": "setCollectionProperty",412 "outputs": [],413 "stateMutability": "nonpayable",414 "type": "function"415 },416 {417 "inputs": [418 { "internalType": "address", "name": "sponsor", "type": "address" }419 ],420 "name": "setCollectionSponsor",421 "outputs": [],422 "stateMutability": "nonpayable",423 "type": "function"424 },425 {426 "inputs": [427 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },428 { "internalType": "string", "name": "key", "type": "string" },429 { "internalType": "bytes", "name": "value", "type": "bytes" }430 ],431 "name": "setProperty",432 "outputs": [],433 "stateMutability": "nonpayable",434 "type": "function"435 },436 {437 "inputs": [438 { "internalType": "string", "name": "key", "type": "string" },439 { "internalType": "bool", "name": "isMutable", "type": "bool" },440 { "internalType": "bool", "name": "collectionAdmin", "type": "bool" },441 { "internalType": "bool", "name": "tokenOwner", "type": "bool" }442 ],443 "name": "setTokenPropertyPermission",444 "outputs": [],445 "stateMutability": "nonpayable",446 "type": "function"447 },448 {449 "inputs": [450 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }451 ],452 "name": "supportsInterface",453 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],454 "stateMutability": "view",455 "type": "function"456 },457 {458 "inputs": [],459 "name": "symbol",460 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],461 "stateMutability": "view",462 "type": "function"463 },464 {465 "inputs": [466 { "internalType": "uint256", "name": "index", "type": "uint256" }467 ],468 "name": "tokenByIndex",469 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],470 "stateMutability": "view",471 "type": "function"472 },473 {474 "inputs": [475 { "internalType": "address", "name": "owner", "type": "address" },476 { "internalType": "uint256", "name": "index", "type": "uint256" }477 ],478 "name": "tokenOfOwnerByIndex",479 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],480 "stateMutability": "view",481 "type": "function"482 },483 {484 "inputs": [485 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }486 ],487 "name": "tokenURI",488 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],489 "stateMutability": "view",490 "type": "function"491 },492 {493 "inputs": [],494 "name": "totalSupply",495 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],496 "stateMutability": "view",497 "type": "function"498 },499 {500 "inputs": [501 { "internalType": "address", "name": "from", "type": "address" },502 { "internalType": "address", "name": "to", "type": "address" },503 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }504 ],505 "name": "transferFrom",506 "outputs": [],507 "stateMutability": "nonpayable",508 "type": "function"509 }510]1[2 {3 "anonymous": false,4 "inputs": [5 {6 "indexed": true,7 "internalType": "address",8 "name": "owner",9 "type": "address"10 },11 {12 "indexed": true,13 "internalType": "address",14 "name": "approved",15 "type": "address"16 },17 {18 "indexed": true,19 "internalType": "uint256",20 "name": "tokenId",21 "type": "uint256"22 }23 ],24 "name": "Approval",25 "type": "event"26 },27 {28 "anonymous": false,29 "inputs": [30 {31 "indexed": true,32 "internalType": "address",33 "name": "owner",34 "type": "address"35 },36 {37 "indexed": true,38 "internalType": "address",39 "name": "operator",40 "type": "address"41 },42 {43 "indexed": false,44 "internalType": "bool",45 "name": "approved",46 "type": "bool"47 }48 ],49 "name": "ApprovalForAll",50 "type": "event"51 },52 {53 "anonymous": false,54 "inputs": [],55 "name": "MintingFinished",56 "type": "event"57 },58 {59 "anonymous": false,60 "inputs": [61 {62 "indexed": true,63 "internalType": "address",64 "name": "from",65 "type": "address"66 },67 {68 "indexed": true,69 "internalType": "address",70 "name": "to",71 "type": "address"72 },73 {74 "indexed": true,75 "internalType": "uint256",76 "name": "tokenId",77 "type": "uint256"78 }79 ],80 "name": "Transfer",81 "type": "event"82 },83 {84 "inputs": [85 { "internalType": "address", "name": "newAdmin", "type": "address" }86 ],87 "name": "addCollectionAdmin",88 "outputs": [],89 "stateMutability": "nonpayable",90 "type": "function"91 },92 {93 "inputs": [94 { "internalType": "uint256", "name": "newAdmin", "type": "uint256" }95 ],96 "name": "addCollectionAdminSubstrate",97 "outputs": [],98 "stateMutability": "nonpayable",99 "type": "function"100 },101 {102 "inputs": [103 { "internalType": "address", "name": "user", "type": "address" }104 ],105 "name": "addToCollectionAllowList",106 "outputs": [],107 "stateMutability": "nonpayable",108 "type": "function"109 },110 {111 "inputs": [112 { "internalType": "address", "name": "approved", "type": "address" },113 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }114 ],115 "name": "approve",116 "outputs": [],117 "stateMutability": "nonpayable",118 "type": "function"119 },120 {121 "inputs": [122 { "internalType": "address", "name": "owner", "type": "address" }123 ],124 "name": "balanceOf",125 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],126 "stateMutability": "view",127 "type": "function"128 },129 {130 "inputs": [131 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }132 ],133 "name": "burn",134 "outputs": [],135 "stateMutability": "nonpayable",136 "type": "function"137 },138 {139 "inputs": [140 { "internalType": "address", "name": "from", "type": "address" },141 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }142 ],143 "name": "burnFrom",144 "outputs": [],145 "stateMutability": "nonpayable",146 "type": "function"147 },148 {149 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],150 "name": "collectionProperty",151 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],152 "stateMutability": "view",153 "type": "function"154 },155 {156 "inputs": [],157 "name": "confirmCollectionSponsorship",158 "outputs": [],159 "stateMutability": "nonpayable",160 "type": "function"161 },162 {163 "inputs": [],164 "name": "contractAddress",165 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],166 "stateMutability": "view",167 "type": "function"168 },169 {170 "inputs": [{ "internalType": "string", "name": "key", "type": "string" }],171 "name": "deleteCollectionProperty",172 "outputs": [],173 "stateMutability": "nonpayable",174 "type": "function"175 },176 {177 "inputs": [178 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },179 { "internalType": "string", "name": "key", "type": "string" }180 ],181 "name": "deleteProperty",182 "outputs": [],183 "stateMutability": "nonpayable",184 "type": "function"185 },186 {187 "inputs": [],188 "name": "finishMinting",189 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],190 "stateMutability": "nonpayable",191 "type": "function"192 },193 {194 "inputs": [195 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }196 ],197 "name": "getApproved",198 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],199 "stateMutability": "view",200 "type": "function"201 },202 {203 "inputs": [204 { "internalType": "address", "name": "owner", "type": "address" },205 { "internalType": "address", "name": "operator", "type": "address" }206 ],207 "name": "isApprovedForAll",208 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],209 "stateMutability": "view",210 "type": "function"211 },212 {213 "inputs": [214 { "internalType": "address", "name": "to", "type": "address" },215 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }216 ],217 "name": "mint",218 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],219 "stateMutability": "nonpayable",220 "type": "function"221 },222 {223 "inputs": [224 { "internalType": "address", "name": "to", "type": "address" },225 { "internalType": "uint256[]", "name": "tokenIds", "type": "uint256[]" }226 ],227 "name": "mintBulk",228 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],229 "stateMutability": "nonpayable",230 "type": "function"231 },232 {233 "inputs": [234 { "internalType": "address", "name": "to", "type": "address" },235 {236 "components": [237 { "internalType": "uint256", "name": "field_0", "type": "uint256" },238 { "internalType": "string", "name": "field_1", "type": "string" }239 ],240 "internalType": "struct Tuple0[]",241 "name": "tokens",242 "type": "tuple[]"243 }244 ],245 "name": "mintBulkWithTokenURI",246 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],247 "stateMutability": "nonpayable",248 "type": "function"249 },250 {251 "inputs": [252 { "internalType": "address", "name": "to", "type": "address" },253 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },254 { "internalType": "string", "name": "tokenUri", "type": "string" }255 ],256 "name": "mintWithTokenURI",257 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],258 "stateMutability": "nonpayable",259 "type": "function"260 },261 {262 "inputs": [],263 "name": "mintingFinished",264 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],265 "stateMutability": "view",266 "type": "function"267 },268 {269 "inputs": [],270 "name": "name",271 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],272 "stateMutability": "view",273 "type": "function"274 },275 {276 "inputs": [],277 "name": "nextTokenId",278 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],279 "stateMutability": "view",280 "type": "function"281 },282 {283 "inputs": [284 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }285 ],286 "name": "ownerOf",287 "outputs": [{ "internalType": "address", "name": "", "type": "address" }],288 "stateMutability": "view",289 "type": "function"290 },291 {292 "inputs": [293 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },294 { "internalType": "string", "name": "key", "type": "string" }295 ],296 "name": "property",297 "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }],298 "stateMutability": "view",299 "type": "function"300 },301 {302 "inputs": [303 { "internalType": "address", "name": "admin", "type": "address" }304 ],305 "name": "removeCollectionAdmin",306 "outputs": [],307 "stateMutability": "nonpayable",308 "type": "function"309 },310 {311 "inputs": [312 { "internalType": "uint256", "name": "admin", "type": "uint256" }313 ],314 "name": "removeCollectionAdminSubstrate",315 "outputs": [],316 "stateMutability": "nonpayable",317 "type": "function"318 },319 {320 "inputs": [321 { "internalType": "address", "name": "user", "type": "address" }322 ],323 "name": "removeFromCollectionAllowList",324 "outputs": [],325 "stateMutability": "nonpayable",326 "type": "function"327 },328 {329 "inputs": [330 { "internalType": "address", "name": "from", "type": "address" },331 { "internalType": "address", "name": "to", "type": "address" },332 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }333 ],334 "name": "safeTransferFrom",335 "outputs": [],336 "stateMutability": "nonpayable",337 "type": "function"338 },339 {340 "inputs": [341 { "internalType": "address", "name": "from", "type": "address" },342 { "internalType": "address", "name": "to", "type": "address" },343 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },344 { "internalType": "bytes", "name": "data", "type": "bytes" }345 ],346 "name": "safeTransferFromWithData",347 "outputs": [],348 "stateMutability": "nonpayable",349 "type": "function"350 },351 {352 "inputs": [353 { "internalType": "address", "name": "operator", "type": "address" },354 { "internalType": "bool", "name": "approved", "type": "bool" }355 ],356 "name": "setApprovalForAll",357 "outputs": [],358 "stateMutability": "nonpayable",359 "type": "function"360 },361 {362 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],363 "name": "setCollectionAccess",364 "outputs": [],365 "stateMutability": "nonpayable",366 "type": "function"367 },368 {369 "inputs": [370 { "internalType": "string", "name": "limit", "type": "string" },371 { "internalType": "uint32", "name": "value", "type": "uint32" }372 ],373 "name": "setCollectionLimit",374 "outputs": [],375 "stateMutability": "nonpayable",376 "type": "function"377 },378 {379 "inputs": [380 { "internalType": "string", "name": "limit", "type": "string" },381 { "internalType": "bool", "name": "value", "type": "bool" }382 ],383 "name": "setCollectionLimit",384 "outputs": [],385 "stateMutability": "nonpayable",386 "type": "function"387 },388 {389 "inputs": [{ "internalType": "bool", "name": "mode", "type": "bool" }],390 "name": "setCollectionMintMode",391 "outputs": [],392 "stateMutability": "nonpayable",393 "type": "function"394 },395 {396 "inputs": [{ "internalType": "bool", "name": "enable", "type": "bool" }],397 "name": "setCollectionNesting",398 "outputs": [],399 "stateMutability": "nonpayable",400 "type": "function"401 },402 {403 "inputs": [404 { "internalType": "bool", "name": "enable", "type": "bool" },405 {406 "internalType": "address[]",407 "name": "collections",408 "type": "address[]"409 }410 ],411 "name": "setCollectionNesting",412 "outputs": [],413 "stateMutability": "nonpayable",414 "type": "function"415 },416 {417 "inputs": [418 { "internalType": "string", "name": "key", "type": "string" },419 { "internalType": "bytes", "name": "value", "type": "bytes" }420 ],421 "name": "setCollectionProperty",422 "outputs": [],423 "stateMutability": "nonpayable",424 "type": "function"425 },426 {427 "inputs": [428 { "internalType": "address", "name": "sponsor", "type": "address" }429 ],430 "name": "setCollectionSponsor",431 "outputs": [],432 "stateMutability": "nonpayable",433 "type": "function"434 },435 {436 "inputs": [437 { "internalType": "uint256", "name": "tokenId", "type": "uint256" },438 { "internalType": "string", "name": "key", "type": "string" },439 { "internalType": "bytes", "name": "value", "type": "bytes" }440 ],441 "name": "setProperty",442 "outputs": [],443 "stateMutability": "nonpayable",444 "type": "function"445 },446 {447 "inputs": [448 { "internalType": "string", "name": "key", "type": "string" },449 { "internalType": "bool", "name": "isMutable", "type": "bool" },450 { "internalType": "bool", "name": "collectionAdmin", "type": "bool" },451 { "internalType": "bool", "name": "tokenOwner", "type": "bool" }452 ],453 "name": "setTokenPropertyPermission",454 "outputs": [],455 "stateMutability": "nonpayable",456 "type": "function"457 },458 {459 "inputs": [460 { "internalType": "bytes4", "name": "interfaceID", "type": "bytes4" }461 ],462 "name": "supportsInterface",463 "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],464 "stateMutability": "view",465 "type": "function"466 },467 {468 "inputs": [],469 "name": "symbol",470 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],471 "stateMutability": "view",472 "type": "function"473 },474 {475 "inputs": [476 { "internalType": "uint256", "name": "index", "type": "uint256" }477 ],478 "name": "tokenByIndex",479 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],480 "stateMutability": "view",481 "type": "function"482 },483 {484 "inputs": [485 { "internalType": "address", "name": "owner", "type": "address" },486 { "internalType": "uint256", "name": "index", "type": "uint256" }487 ],488 "name": "tokenOfOwnerByIndex",489 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],490 "stateMutability": "view",491 "type": "function"492 },493 {494 "inputs": [495 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }496 ],497 "name": "tokenURI",498 "outputs": [{ "internalType": "string", "name": "", "type": "string" }],499 "stateMutability": "view",500 "type": "function"501 },502 {503 "inputs": [],504 "name": "totalSupply",505 "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }],506 "stateMutability": "view",507 "type": "function"508 },509 {510 "inputs": [511 { "internalType": "address", "name": "to", "type": "address" },512 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }513 ],514 "name": "transfer",515 "outputs": [],516 "stateMutability": "nonpayable",517 "type": "function"518 },519 {520 "inputs": [521 { "internalType": "address", "name": "from", "type": "address" },522 { "internalType": "address", "name": "to", "type": "address" },523 { "internalType": "uint256", "name": "tokenId", "type": "uint256" }524 ],525 "name": "transferFrom",526 "outputs": [],527 "stateMutability": "nonpayable",528 "type": "function"529 }530]