diff --git a/pallets/nft/src/lib.rs b/pallets/nft/src/lib.rs index ae1d8b15..24f3f244 100644 --- a/pallets/nft/src/lib.rs +++ b/pallets/nft/src/lib.rs @@ -545,7 +545,7 @@ pub mod pallet { ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; - Self::update_class_total_issuance(&sender, &class_id, 1u32)?; + Self::update_class_total_issuance(&sender, &class_id, 1u32, false)?; // Collect minting deposit let class_fund: T::AccountId = T::Treasury::get().into_account_truncating(); let deposit = T::AssetMintingFee::get().saturating_mul(Into::>::into(1u32)); @@ -1167,7 +1167,7 @@ impl Pallet { ); // Update class total issuance - Self::update_class_total_issuance(&sender, &class_id, quantity)?; + Self::update_class_total_issuance(&sender, &class_id, quantity, false)?; let class_fund: T::AccountId = T::Treasury::get().into_account_truncating(); let deposit = T::AssetMintingFee::get().saturating_mul(Into::>::into(quantity)); @@ -1212,6 +1212,7 @@ impl Pallet { metadata: NftMetadata, attributes: Attributes, is_locked: bool, + is_pre_signed_mint: bool, ) -> Result, DispatchError> { ensure!(!Self::is_collection_locked(&class_id), Error::::CollectionIsLocked); @@ -1221,7 +1222,7 @@ impl Pallet { ); // Update class total issuance - Self::update_class_total_issuance(&sender, &class_id, 1u32)?; + Self::update_class_total_issuance(&sender, &class_id, 1u32, is_pre_signed_mint)?; let class_fund: T::AccountId = T::Treasury::get().into_account_truncating(); let deposit = T::AssetMintingFee::get().saturating_mul(Into::>::into(1u32)); @@ -1301,7 +1302,9 @@ impl Pallet { )?; } - Self::do_mint_nft_with_token_id(&mint_to, &mint_to, class_id, token_id, metadata, attributes, false)?; + Self::do_mint_nft_with_token_id( + &mint_to, &mint_to, class_id, token_id, metadata, attributes, false, true, + )?; Ok(()) } @@ -1316,8 +1319,9 @@ impl Pallet { attributes: Attributes, is_locked: bool, ) -> Result<(ClassIdOf, TokenIdOf), DispatchError> { - let minted_token_id = - Self::do_mint_nft_with_token_id(&sender, &mint_to, class_id, token_id, metadata, attributes, is_locked)?; + let minted_token_id = Self::do_mint_nft_with_token_id( + &sender, &mint_to, class_id, token_id, metadata, attributes, is_locked, false, + )?; let nft_proxy_account: T::AccountId = T::PalletId::get().into_sub_account_truncating((class_id, &minted_token_id)); let proxy_deposit = >::deposit(1u32); @@ -1423,11 +1427,18 @@ impl Pallet { } /// Update total minted tokens for a class - fn update_class_total_issuance(sender: &T::AccountId, class_id: &ClassIdOf, quantity: u32) -> DispatchResult { + fn update_class_total_issuance( + sender: &T::AccountId, + class_id: &ClassIdOf, + quantity: u32, + is_pre_signed_mint: bool, + ) -> DispatchResult { // update class total issuance Classes::::try_mutate(class_id, |class_info| -> DispatchResult { let info = class_info.as_mut().ok_or(Error::::ClassIdNotFound)?; - ensure!(info.owner == sender.clone(), Error::::NoPermission); + if !is_pre_signed_mint { + ensure!(info.owner == sender.clone(), Error::::NoPermission); + } match info.data.mint_limit { Some(l) => { ensure!( @@ -1707,7 +1718,16 @@ impl NFTTrait> for Pallet { metadata: NftMetadata, attributes: Attributes, ) -> Result { - Self::do_mint_nft_with_token_id(sender, sender, class_id, Some(token_id), metadata, attributes, false) + Self::do_mint_nft_with_token_id( + sender, + sender, + class_id, + Some(token_id), + metadata, + attributes, + false, + false, + ) } fn get_free_stackable_nft_balance(who: &T::AccountId, asset_id: &(Self::ClassId, Self::TokenId)) -> BalanceOf {