difftreelog
refactor do not receive token id as mint argument
in: master
2 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth193}193}194194195#[derive(ToLog)]195#[derive(ToLog)]196pub enum ERC721MintableEvents {196pub enum ERC721UniqueMintableEvents {197 #[allow(dead_code)]197 #[allow(dead_code)]198 MintingFinished {},198 MintingFinished {},199}199}431}431}432432433/// @title ERC721 minting logic.433/// @title ERC721 minting logic.434#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]434#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]435impl<T: Config> NonfungibleHandle<T> {435impl<T: Config> NonfungibleHandle<T> {436 fn minting_finished(&self) -> Result<bool> {436 fn minting_finished(&self) -> Result<bool> {437 Ok(false)437 Ok(false)438 }438 }439440 /// @notice Function to mint token.441 /// @param to The new owner442 /// @return uint256 The id of the newly minted token443 #[weight(<SelfWeightOf<T>>::create_item())]444 fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {445 let token_id: uint256 = <TokensMinted<T>>::get(self.id)446 .checked_add(1)447 .ok_or("item id overflow")?448 .into();449 self.mint_check_id(caller, to, token_id)?;450 Ok(token_id)451 }439452440 /// @notice Function to mint token.453 /// @notice Function to mint token.441 /// @dev `tokenId` should be obtained with `nextTokenId` method,454 /// @dev `tokenId` should be obtained with `nextTokenId` method,442 /// unlike standard, you can't specify it manually455 /// unlike standard, you can't specify it manually443 /// @param to The new owner456 /// @param to The new owner444 /// @param tokenId ID of the minted NFT457 /// @param tokenId ID of the minted NFT458 #[solidity(hide, rename_selector = "mint")]445 #[weight(<SelfWeightOf<T>>::create_item())]459 #[weight(<SelfWeightOf<T>>::create_item())]446 fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {460 fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {447 let caller = T::CrossAccountId::from_eth(caller);461 let caller = T::CrossAccountId::from_eth(caller);448 let to = T::CrossAccountId::from_eth(to);462 let to = T::CrossAccountId::from_eth(to);449 let token_id: u32 = token_id.try_into()?;463 let token_id: u32 = token_id.try_into()?;473 Ok(true)487 Ok(true)474 }488 }489490 /// @notice Function to mint token with the given tokenUri.491 /// @param to The new owner492 /// @param tokenUri Token URI that would be stored in the NFT properties493 /// @return uint256 The id of the newly minted token494 #[solidity(rename_selector = "mintWithTokenURI")]495 #[weight(<SelfWeightOf<T>>::create_item())]496 fn mint_with_token_uri(497 &mut self,498 caller: caller,499 to: address,500 token_uri: string,501 ) -> Result<uint256> {502 let token_id: uint256 = <TokensMinted<T>>::get(self.id)503 .checked_add(1)504 .ok_or("item id overflow")?505 .into();506 self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;507 Ok(token_id)508 }475509476 /// @notice Function to mint token with the given tokenUri.510 /// @notice Function to mint token with the given tokenUri.477 /// @dev `tokenId` should be obtained with `nextTokenId` method,511 /// @dev `tokenId` should be obtained with `nextTokenId` method,478 /// unlike standard, you can't specify it manually512 /// unlike standard, you can't specify it manually479 /// @param to The new owner513 /// @param to The new owner480 /// @param tokenId ID of the minted NFT514 /// @param tokenId ID of the minted NFT481 /// @param tokenUri Token URI that would be stored in the NFT properties515 /// @param tokenUri Token URI that would be stored in the NFT properties482 #[solidity(rename_selector = "mintWithTokenURI")]516 #[solidity(hide, rename_selector = "mintWithTokenURI")]483 #[weight(<SelfWeightOf<T>>::create_item())]517 #[weight(<SelfWeightOf<T>>::create_item())]484 fn mint_with_token_uri(518 fn mint_with_token_uri_check_id(485 &mut self,519 &mut self,486 caller: caller,520 caller: caller,487 to: address,521 to: address,637 /// should be obtained with `nextTokenId` method671 /// should be obtained with `nextTokenId` method638 /// @param to The new owner672 /// @param to The new owner639 /// @param tokenIds IDs of the minted NFTs673 /// @param tokenIds IDs of the minted NFTs674 #[solidity(hide)]640 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]675 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]641 fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {676 fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {642 let caller = T::CrossAccountId::from_eth(caller);677 let caller = T::CrossAccountId::from_eth(caller);673 /// numbers and first number should be obtained with `nextTokenId` method708 /// numbers and first number should be obtained with `nextTokenId` method674 /// @param to The new owner709 /// @param to The new owner675 /// @param tokens array of pairs of token ID and token URI for minted tokens710 /// @param tokens array of pairs of token ID and token URI for minted tokens676 #[solidity(rename_selector = "mintBulkWithTokenURI")]711 #[solidity(hide, rename_selector = "mintBulkWithTokenURI")]677 #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]712 #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]678 fn mint_bulk_with_token_uri(713 fn mint_bulk_with_token_uri(679 &mut self,714 &mut self,728 ERC721,763 ERC721,729 ERC721Enumerable,764 ERC721Enumerable,730 ERC721UniqueExtensions,765 ERC721UniqueExtensions,731 ERC721Mintable,766 ERC721UniqueMintable,732 ERC721Burnable,767 ERC721Burnable,733 ERC721Metadata(if(this.flags.erc721metadata)),768 ERC721Metadata(if(this.flags.erc721metadata)),734 Collection(via(common_mut returns CollectionHandle<T>)),769 Collection(via(common_mut returns CollectionHandle<T>)),pallets/refungible/src/erc.rsdiffbeforeafterboth--- a/pallets/refungible/src/erc.rs
+++ b/pallets/refungible/src/erc.rs
@@ -187,7 +187,7 @@
}
#[derive(ToLog)]
-pub enum ERC721MintableEvents {
+pub enum ERC721UniqueMintableEvents {
/// @dev Not supported
#[allow(dead_code)]
MintingFinished {},
@@ -449,19 +449,33 @@
}
/// @title ERC721 minting logic.
-#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]
+#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]
impl<T: Config> RefungibleHandle<T> {
fn minting_finished(&self) -> Result<bool> {
Ok(false)
}
/// @notice Function to mint token.
+ /// @param to The new owner
+ /// @return uint256 The id of the newly minted token
+ #[weight(<SelfWeightOf<T>>::create_item())]
+ fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {
+ let token_id: uint256 = <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?
+ .into();
+ self.mint_check_id(caller, to, token_id)?;
+ Ok(token_id)
+ }
+
+ /// @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
+ #[solidity(hide, rename_selector = "mint")]
#[weight(<SelfWeightOf<T>>::create_item())]
- fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
+ fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {
let caller = T::CrossAccountId::from_eth(caller);
let to = T::CrossAccountId::from_eth(to);
let token_id: u32 = token_id.try_into()?;
@@ -497,14 +511,34 @@
}
/// @notice Function to mint token with the given tokenUri.
+ /// @param to The new owner
+ /// @param tokenUri Token URI that would be stored in the NFT properties
+ /// @return uint256 The id of the newly minted token
+ #[solidity(rename_selector = "mintWithTokenURI")]
+ #[weight(<SelfWeightOf<T>>::create_item())]
+ fn mint_with_token_uri(
+ &mut self,
+ caller: caller,
+ to: address,
+ token_uri: string,
+ ) -> Result<uint256> {
+ let token_id: uint256 = <TokensMinted<T>>::get(self.id)
+ .checked_add(1)
+ .ok_or("item id overflow")?
+ .into();
+ self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;
+ Ok(token_id)
+ }
+
+ /// @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
- #[solidity(rename_selector = "mintWithTokenURI")]
+ #[solidity(hide, rename_selector = "mintWithTokenURI")]
#[weight(<SelfWeightOf<T>>::create_item())]
- fn mint_with_token_uri(
+ fn mint_with_token_uri_check_id(
&mut self,
caller: caller,
to: address,
@@ -671,6 +705,7 @@
/// should be obtained with `nextTokenId` method
/// @param to The new owner
/// @param tokenIds IDs of the minted RFTs
+ #[solidity(hide)]
#[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);
@@ -713,7 +748,7 @@
/// 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")]
+ #[solidity(hide, rename_selector = "mintBulkWithTokenURI")]
#[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]
fn mint_bulk_with_token_uri(
&mut self,
@@ -784,7 +819,7 @@
ERC721,
ERC721Enumerable,
ERC721UniqueExtensions,
- ERC721Mintable,
+ ERC721UniqueMintable,
ERC721Burnable,
ERC721Metadata(if(this.flags.erc721metadata)),
Collection(via(common_mut returns CollectionHandle<T>)),