difftreelog
feat add burn_nft rmrk proxy
in: master
1 file changed
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth75 collection_id: RmrkCollectionId,75 collection_id: RmrkCollectionId,76 nft_id: RmrkNftId,76 nft_id: RmrkNftId,77 },77 },78 NFTBurned {79 owner: T::AccountId,80 nft_id: RmrkNftId,81 },78 }82 }798380 #[pallet::error]84 #[pallet::error]106 ) -> DispatchResult {110 ) -> DispatchResult {107 let sender = ensure_signed(origin)?;111 let sender = ensure_signed(origin)?;108112109 let limits = max.map(|max| CollectionLimits {113 let limits = CollectionLimits {110 token_limit: Some(max),114 owner_can_transfer: Some(false),115 token_limit: max,111 ..Default::default()116 ..Default::default()112 });117 };113118114 let data = CreateCollectionData {119 let data = CreateCollectionData {115 limits,120 limits: Some(limits),116 token_prefix: symbol.into_inner()121 token_prefix: symbol.into_inner()117 .try_into()122 .try_into()118 .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,123 .map_err(|_| <CommonError<T>>::CollectionTokenPrefixLimitExceeded)?,266 Ok(())271 Ok(())267 }272 }273274 #[pallet::weight(10_000 + T::DbWeight::get().reads_writes(1,1))]275 #[transactional]276 pub fn burn_nft(277 origin: OriginFor<T>,278 collection_id: RmrkCollectionId,279 nft_id: RmrkNftId,280 ) -> DispatchResult {281 let sender = ensure_signed(origin.clone())?;282 let cross_sender = T::CrossAccountId::from_sub(sender.clone());283284 Self::destroy_nft(285 cross_sender,286 collection_id.into(),287 CollectionType::Regular,288 nft_id.into()289 )?;290291 Self::deposit_event(Event::NFTBurned { owner: sender, nft_id });292293 Ok(())294 }268 }295 }269}296}270297311 Ok(nft_id)338 Ok(nft_id)312 }339 }340341 fn destroy_nft(342 sender: T::CrossAccountId,343 collection_id: CollectionId,344 collection_type: CollectionType,345 token_id: TokenId346 ) -> DispatchResult {347 let collection = Self::get_typed_nft_collection(348 collection_id,349 collection_type350 )?;351352 <PalletNft<T>>::burn(&collection, &sender, token_id)353 .map_err(Self::map_common_err_to_proxy)?;354355 Ok(())356 }313357314 fn change_collection_owner(358 fn change_collection_owner(315 collection_id: CollectionId,359 collection_id: CollectionId,