difftreelog
feat(rmrk) add accept_resource_removal
in: master
1 file changed
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth577579578 <PalletNft<T>>::set_scoped_token_property(580 <PalletNft<T>>::set_scoped_token_property(579 resource_collection_id,581 resource_collection_id,580 resource_id,582 rmrk_resource_id.into(),581 PropertyScope::Rmrk,583 PropertyScope::Rmrk,582 Self::rmrk_property(PendingResourceAccept, &false)?,584 Self::rmrk_property(PendingResourceAccept, &false)?,583 )?;585 )?;584586585 Ok(())587 Ok(())586 }588 }589590 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]591 #[transactional]592 pub fn accept_resource_removal(593 origin: OriginFor<T>,594 rmrk_collection_id: RmrkCollectionId,595 rmrk_nft_id: RmrkNftId,596 rmrk_resource_id: RmrkResourceId,597 ) -> DispatchResult {598 let sender = ensure_signed(origin)?;599 let cross_sender = T::CrossAccountId::from_sub(sender);600601 let collection_id = Self::unique_collection_id(rmrk_collection_id)602 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;603604 let nft_id = rmrk_nft_id.into();605 let resource_id = rmrk_resource_id.into();606607 let budget = budget::Value::new(NESTING_BUDGET);608609 let nft_owner =610 <PalletStructure<T>>::find_topmost_owner(collection_id, nft_id, &budget)611 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;612613 ensure!(cross_sender == nft_owner, <Error<T>>::NoPermission);614615 let resource_collection_id: CollectionId =616 Self::get_nft_property_decoded(collection_id, nft_id, ResourceCollection)617 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;618619 let is_pending: bool = Self::get_nft_property_decoded(620 resource_collection_id,621 resource_id,622 PendingResourceRemoval,623 )624 .map_err(|_| <Error<T>>::ResourceDoesntExist)?;625626 ensure!(is_pending, <Error<T>>::ResourceNotPending);627628 let resource_collection = Self::get_typed_nft_collection(629 resource_collection_id,630 misc::CollectionType::Resource,631 )?;632633 <PalletNft<T>>::burn(&resource_collection, &cross_sender, rmrk_resource_id.into())634 .map_err(Self::map_unique_err_to_proxy)?;635636 Ok(())637 }587638588 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]639 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]589 #[transactional]640 #[transactional]