difftreelog
fix burn_nft with children
in: master
1 file changed
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth417 origin: OriginFor<T>,417 origin: OriginFor<T>,418 collection_id: RmrkCollectionId,418 collection_id: RmrkCollectionId,419 nft_id: RmrkNftId,419 nft_id: RmrkNftId,420 max_burns: u32,420 ) -> DispatchResult {421 ) -> DispatchResult {421 let sender = ensure_signed(origin)?;422 let sender = ensure_signed(origin)?;422 let cross_sender = T::CrossAccountId::from_sub(sender.clone());423 let cross_sender = T::CrossAccountId::from_sub(sender.clone());431 cross_sender,432 cross_sender,432 Self::unique_collection_id(collection_id)?,433 Self::unique_collection_id(collection_id)?,433 nft_id.into(),434 nft_id.into(),435 max_burns,436 <Error<T>>::NoPermission,434 )437 )435 .map_err(Self::map_unique_err_to_proxy)?;438 .map_err(|err| Self::map_unique_err_to_proxy(err.error))?;436439437 Self::deposit_event(Event::NFTBurned {440 Self::deposit_event(Event::NFTBurned {438 owner: sender,441 owner: sender,642 origin: OriginFor<T>,645 origin: OriginFor<T>,643 rmrk_collection_id: RmrkCollectionId,646 rmrk_collection_id: RmrkCollectionId,644 rmrk_nft_id: RmrkNftId,647 rmrk_nft_id: RmrkNftId,648 max_burns: u32,645 ) -> DispatchResult {649 ) -> DispatchResult {646 let sender = ensure_signed(origin)?;650 let sender = ensure_signed(origin)?;647 let cross_sender = T::CrossAccountId::from_sub(sender.clone());651 let cross_sender = T::CrossAccountId::from_sub(sender.clone());653 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;657 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;654 collection.check_is_external()?;658 collection.check_is_external()?;655659656 Self::destroy_nft(cross_sender, collection_id, nft_id).map_err(|err| {660 Self::destroy_nft(657 if err == <CommonError<T>>::NoPermission.into()661 cross_sender,658 || err == <CommonError<T>>::ApprovedValueTooLow.into()662 collection_id,659 {663 nft_id,660 <Error<T>>::CannotRejectNonOwnedNft.into()664 max_burns,661 } else {665 <Error<T>>::CannotRejectNonOwnedNft,662 Self::map_unique_err_to_proxy(err)666 ).map_err(|err| Self::map_unique_err_to_proxy(err.error))?;663 }664 })?;665667666 Self::deposit_event(Event::NFTRejected {668 Self::deposit_event(Event::NFTRejected {667 sender,669 sender,1124 sender: T::CrossAccountId,1126 sender: T::CrossAccountId,1125 collection_id: CollectionId,1127 collection_id: CollectionId,1126 token_id: TokenId,1128 token_id: TokenId,1129 max_burns: u32,1130 error_if_not_owned: Error<T>,1127 ) -> DispatchResult {1131 ) -> DispatchResultWithPostInfo {1128 let collection =1132 let collection =1129 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;1133 Self::get_typed_nft_collection(collection_id, misc::CollectionType::Regular)?;11301134113311371134 let from = token_data.owner;1138 let from = token_data.owner;113511391136 let budget = budget::Value::new(NESTING_BUDGET);1140 let owner_check_budget = budget::Value::new(NESTING_BUDGET);11411142 ensure!(1143 <PalletStructure<T>>::check_indirectly_owned(1144 sender.clone(),1145 collection_id,1146 token_id,1147 None,1148 &owner_check_budget1149 )?,1150 error_if_not_owned,1151 );11521153 let burns_budget = budget::Value::new(max_burns);1154 let breadth_budget = budget::Value::new(max_burns);113711551138 <PalletNft<T>>::burn_from(&collection, &sender, &from, token_id, &budget)1156 <PalletNft<T>>::burn_recursively(&collection, &from, token_id, &burns_budget, &breadth_budget)1139 }1157 }114011581141 fn resource_add(1159 fn resource_add(1202 Error::<T>::ResourceDoesntExist1220 Error::<T>::ResourceDoesntExist1203 );1221 );120412221205 let budget = up_data_structs::budget::Value::new(10);1223 let budget = up_data_structs::budget::Value::new(NESTING_BUDGET);1206 let topmost_owner =1224 let topmost_owner =1207 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)?;1225 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)?;12081226