difftreelog
fix map common error to proxy errors
in: master
1 file changed
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth162 ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);162 ensure!(collection.total_supply() == 0, <Error<T>>::CollectionNotEmpty);163163164 <PalletNft<T>>::destroy_collection(collection, &cross_sender)?;164 <PalletNft<T>>::destroy_collection(collection, &cross_sender)165 .map_err(Self::map_common_err_to_proxy)?;165166166 Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });167 Self::deposit_event(Event::CollectionDestroyed { issuer: sender, collection_id });167168209 CollectionType::Regular210 CollectionType::Regular210 )?;211 )?;212211 collection.check_is_owner(&cross_sender)?;213 Self::check_collection_owner(&collection, &cross_sender)?;212214213 let token_count = collection.total_supply();215 let token_count = collection.total_supply();214216295 &sender,297 &sender,296 data,298 data,297 &budget,299 &budget,298 ).map_err(|err| {300 ).map_err(Self::map_common_err_to_proxy)?;299 map_common_err_to_proxy!(300 match err {301 NoPermission => NoPermission,302 CollectionTokenLimitExceeded => CollectionFullOrLocked303 }304 )305 })?;306301307 let nft_id = <PalletNft<T>>::current_token_id(&collection);302 let nft_id = <PalletNft<T>>::current_token_id(&collection);308303322 sender: T::AccountId,317 sender: T::AccountId,323 new_owner: T::AccountId,318 new_owner: T::AccountId,324 ) -> DispatchResult {319 ) -> DispatchResult {325 let mut collection = Self::get_typed_nft_collection(320 let collection = Self::get_typed_nft_collection(326 collection_id,321 collection_id,327 collection_type322 collection_type328 )?.into_inner();323 )?;329 collection.check_is_owner(&T::CrossAccountId::from_sub(sender))?;324 Self::check_collection_owner(&collection, &T::CrossAccountId::from_sub(sender))?;325326 let mut collection = collection.into_inner();330327331 collection.owner = new_owner;328 collection.owner = new_owner;332 collection.save()329 collection.save()333 }330 }331332 fn check_collection_owner(collection: &NonfungibleHandle<T>, account: &T::CrossAccountId) -> DispatchResult {333 collection.check_is_owner(account)334 .map_err(Self::map_common_err_to_proxy)335 }334336335 pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {337 pub fn get_nft_collection(collection_id: CollectionId) -> Result<NonfungibleHandle<T>, DispatchError> {336 let collection = <CollectionHandle<T>>::try_get(collection_id)338 let collection = <CollectionHandle<T>>::try_get(collection_id)383 Self::get_nft_collection(collection_id)385 Self::get_nft_collection(collection_id)384 }386 }387388 fn map_common_err_to_proxy(err: DispatchError) -> DispatchError {389 map_common_err_to_proxy! {390 match err {391 NoPermission => NoPermission,392 CollectionTokenLimitExceeded => CollectionFullOrLocked393 }394 }395 }385}396}386397