difftreelog
refactor do not receive token id as mint argument
in: master
2 files changed
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -193,7 +193,7 @@
}
#[derive(ToLog)]
-pub enum ERC721MintableEvents {
+pub enum ERC721UniqueMintableEvents {
#[allow(dead_code)]
MintingFinished {},
}
@@ -431,19 +431,33 @@
}
/// @title ERC721 minting logic.
-#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]
+#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]
impl<T: Config> NonfungibleHandle<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 NFT
+ #[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()?;
@@ -474,14 +488,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 NFT
/// @param tokenUri Token URI that would be stored in the NFT 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,
@@ -637,6 +671,7 @@
/// should be obtained with `nextTokenId` method
/// @param to The new owner
/// @param tokenIds IDs of the minted NFTs
+ #[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);
@@ -673,7 +708,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,
@@ -728,7 +763,7 @@
ERC721,
ERC721Enumerable,
ERC721UniqueExtensions,
- ERC721Mintable,
+ ERC721UniqueMintable,
ERC721Burnable,
ERC721Metadata(if(this.flags.erc721metadata)),
Collection(via(common_mut returns CollectionHandle<T>)),
pallets/refungible/src/erc.rsdiffbeforeafterboth187}187}188188189#[derive(ToLog)]189#[derive(ToLog)]190pub enum ERC721MintableEvents {190pub enum ERC721UniqueMintableEvents {191 /// @dev Not supported191 /// @dev Not supported192 #[allow(dead_code)]192 #[allow(dead_code)]193 MintingFinished {},193 MintingFinished {},449}449}450450451/// @title ERC721 minting logic.451/// @title ERC721 minting logic.452#[solidity_interface(name = ERC721Mintable, events(ERC721MintableEvents))]452#[solidity_interface(name = ERC721UniqueMintable, events(ERC721UniqueMintableEvents))]453impl<T: Config> RefungibleHandle<T> {453impl<T: Config> RefungibleHandle<T> {454 fn minting_finished(&self) -> Result<bool> {454 fn minting_finished(&self) -> Result<bool> {455 Ok(false)455 Ok(false)456 }456 }457458 /// @notice Function to mint token.459 /// @param to The new owner460 /// @return uint256 The id of the newly minted token461 #[weight(<SelfWeightOf<T>>::create_item())]462 fn mint(&mut self, caller: caller, to: address) -> Result<uint256> {463 let token_id: uint256 = <TokensMinted<T>>::get(self.id)464 .checked_add(1)465 .ok_or("item id overflow")?466 .into();467 self.mint_check_id(caller, to, token_id)?;468 Ok(token_id)469 }457470458 /// @notice Function to mint token.471 /// @notice Function to mint token.459 /// @dev `tokenId` should be obtained with `nextTokenId` method,472 /// @dev `tokenId` should be obtained with `nextTokenId` method,460 /// unlike standard, you can't specify it manually473 /// unlike standard, you can't specify it manually461 /// @param to The new owner474 /// @param to The new owner462 /// @param tokenId ID of the minted RFT475 /// @param tokenId ID of the minted RFT476 #[solidity(hide, rename_selector = "mint")]463 #[weight(<SelfWeightOf<T>>::create_item())]477 #[weight(<SelfWeightOf<T>>::create_item())]464 fn mint(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {478 fn mint_check_id(&mut self, caller: caller, to: address, token_id: uint256) -> Result<bool> {465 let caller = T::CrossAccountId::from_eth(caller);479 let caller = T::CrossAccountId::from_eth(caller);466 let to = T::CrossAccountId::from_eth(to);480 let to = T::CrossAccountId::from_eth(to);467 let token_id: u32 = token_id.try_into()?;481 let token_id: u32 = token_id.try_into()?;496 Ok(true)510 Ok(true)497 }511 }512513 /// @notice Function to mint token with the given tokenUri.514 /// @param to The new owner515 /// @param tokenUri Token URI that would be stored in the NFT properties516 /// @return uint256 The id of the newly minted token517 #[solidity(rename_selector = "mintWithTokenURI")]518 #[weight(<SelfWeightOf<T>>::create_item())]519 fn mint_with_token_uri(520 &mut self,521 caller: caller,522 to: address,523 token_uri: string,524 ) -> Result<uint256> {525 let token_id: uint256 = <TokensMinted<T>>::get(self.id)526 .checked_add(1)527 .ok_or("item id overflow")?528 .into();529 self.mint_with_token_uri_check_id(caller, to, token_id, token_uri)?;530 Ok(token_id)531 }498532499 /// @notice Function to mint token with the given tokenUri.533 /// @notice Function to mint token with the given tokenUri.500 /// @dev `tokenId` should be obtained with `nextTokenId` method,534 /// @dev `tokenId` should be obtained with `nextTokenId` method,501 /// unlike standard, you can't specify it manually535 /// unlike standard, you can't specify it manually502 /// @param to The new owner536 /// @param to The new owner503 /// @param tokenId ID of the minted RFT537 /// @param tokenId ID of the minted RFT504 /// @param tokenUri Token URI that would be stored in the RFT properties538 /// @param tokenUri Token URI that would be stored in the RFT properties505 #[solidity(rename_selector = "mintWithTokenURI")]539 #[solidity(hide, rename_selector = "mintWithTokenURI")]506 #[weight(<SelfWeightOf<T>>::create_item())]540 #[weight(<SelfWeightOf<T>>::create_item())]507 fn mint_with_token_uri(541 fn mint_with_token_uri_check_id(508 &mut self,542 &mut self,509 caller: caller,543 caller: caller,510 to: address,544 to: address,671 /// should be obtained with `nextTokenId` method705 /// should be obtained with `nextTokenId` method672 /// @param to The new owner706 /// @param to The new owner673 /// @param tokenIds IDs of the minted RFTs707 /// @param tokenIds IDs of the minted RFTs708 #[solidity(hide)]674 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]709 #[weight(<SelfWeightOf<T>>::create_multiple_items(token_ids.len() as u32))]675 fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {710 fn mint_bulk(&mut self, caller: caller, to: address, token_ids: Vec<uint256>) -> Result<bool> {676 let caller = T::CrossAccountId::from_eth(caller);711 let caller = T::CrossAccountId::from_eth(caller);713 /// numbers and first number should be obtained with `nextTokenId` method748 /// numbers and first number should be obtained with `nextTokenId` method714 /// @param to The new owner749 /// @param to The new owner715 /// @param tokens array of pairs of token ID and token URI for minted tokens750 /// @param tokens array of pairs of token ID and token URI for minted tokens716 #[solidity(rename_selector = "mintBulkWithTokenURI")]751 #[solidity(hide, rename_selector = "mintBulkWithTokenURI")]717 #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]752 #[weight(<SelfWeightOf<T>>::create_multiple_items(tokens.len() as u32))]718 fn mint_bulk_with_token_uri(753 fn mint_bulk_with_token_uri(719 &mut self,754 &mut self,784 ERC721,819 ERC721,785 ERC721Enumerable,820 ERC721Enumerable,786 ERC721UniqueExtensions,821 ERC721UniqueExtensions,787 ERC721Mintable,822 ERC721UniqueMintable,788 ERC721Burnable,823 ERC721Burnable,789 ERC721Metadata(if(this.flags.erc721metadata)),824 ERC721Metadata(if(this.flags.erc721metadata)),790 Collection(via(common_mut returns CollectionHandle<T>)),825 Collection(via(common_mut returns CollectionHandle<T>)),