--- a/pallets/proxy-rmrk-core/src/lib.rs +++ b/pallets/proxy-rmrk-core/src/lib.rs @@ -417,6 +417,7 @@ origin: OriginFor, collection_id: RmrkCollectionId, nft_id: RmrkNftId, + max_burns: u32, ) -> DispatchResult { let sender = ensure_signed(origin)?; let cross_sender = T::CrossAccountId::from_sub(sender.clone()); @@ -431,8 +432,10 @@ cross_sender, Self::unique_collection_id(collection_id)?, nft_id.into(), + max_burns, + >::NoPermission, ) - .map_err(Self::map_unique_err_to_proxy)?; + .map_err(|err| Self::map_unique_err_to_proxy(err.error))?; Self::deposit_event(Event::NFTBurned { owner: sender, @@ -642,6 +645,7 @@ origin: OriginFor, rmrk_collection_id: RmrkCollectionId, rmrk_nft_id: RmrkNftId, + max_burns: u32, ) -> DispatchResult { let sender = ensure_signed(origin)?; let cross_sender = T::CrossAccountId::from_sub(sender.clone()); @@ -653,15 +657,13 @@ Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?; collection.check_is_external()?; - Self::destroy_nft(cross_sender, collection_id, nft_id).map_err(|err| { - if err == >::NoPermission.into() - || err == >::ApprovedValueTooLow.into() - { - >::CannotRejectNonOwnedNft.into() - } else { - Self::map_unique_err_to_proxy(err) - } - })?; + Self::destroy_nft( + cross_sender, + collection_id, + nft_id, + max_burns, + >::CannotRejectNonOwnedNft, + ).map_err(|err| Self::map_unique_err_to_proxy(err.error))?; Self::deposit_event(Event::NFTRejected { sender, @@ -1124,7 +1126,9 @@ sender: T::CrossAccountId, collection_id: CollectionId, token_id: TokenId, - ) -> DispatchResult { + max_burns: u32, + error_if_not_owned: Error, + ) -> DispatchResultWithPostInfo { let collection = Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?; @@ -1133,9 +1137,23 @@ let from = token_data.owner; - let budget = budget::Value::new(NESTING_BUDGET); + let owner_check_budget = budget::Value::new(NESTING_BUDGET); - >::burn_from(&collection, &sender, &from, token_id, &budget) + ensure!( + >::check_indirectly_owned( + sender.clone(), + collection_id, + token_id, + None, + &owner_check_budget + )?, + error_if_not_owned, + ); + + let burns_budget = budget::Value::new(max_burns); + let breadth_budget = budget::Value::new(max_burns); + + >::burn_recursively(&collection, &from, token_id, &burns_budget, &breadth_budget) } fn resource_add( @@ -1202,7 +1220,7 @@ Error::::ResourceDoesntExist ); - let budget = up_data_structs::budget::Value::new(10); + let budget = up_data_structs::budget::Value::new(NESTING_BUDGET); let topmost_owner = >::find_topmost_owner(collection_id, nft_id, &budget)?;