git.delta.rocks / unique-network / refs/commits / 866e42a32607

difftreelog

fix(rmrk) map CollectionNotEmpty error

Daniel Shiposha2022-06-05parent: #800b656.patch.diff
in: master

2 files changed

modifiedpallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth
--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -204,11 +204,6 @@
 				misc::CollectionType::Regular,
 			)?;
 
-			ensure!(
-				collection.total_supply() == 0,
-				<Error<T>>::CollectionNotEmpty
-			);
-
 			<PalletNft<T>>::destroy_collection(collection, &cross_sender)
 				.map_err(Self::map_unique_err_to_proxy)?;
 
@@ -1142,8 +1137,9 @@
 				CommonError::PublicMintingNotAllowed => NoPermission,
 				CommonError::TokenNotFound => NoAvailableNftId,
 				CommonError::ApprovedValueTooLow => NoPermission,
+				CommonError::CantDestroyNotEmptyCollection => CollectionNotEmpty,
 				StructureError::TokenNotFound => NoAvailableNftId,
-				StructureError::OuroborosDetected => CannotSendToDescendentOrSelf
+				StructureError::OuroborosDetected => CannotSendToDescendentOrSelf,
 			}
 		}
 	}
modifiedpallets/proxy-rmrk-core/src/misc.rsdiffbeforeafterboth
before · pallets/proxy-rmrk-core/src/misc.rs
1use super::*;2use codec::{Encode, Decode, Error};34#[macro_export]5macro_rules! map_unique_err_to_proxy {6    (match $err:ident { $($unique_err_ty:ident :: $unique_err:ident => $proxy_err:ident),+ }) => {7        $(8            if $err == <$unique_err_ty<T>>::$unique_err.into() {9                return <Error<T>>::$proxy_err.into()10            } else11        )+ {12            $err13        }14    };15}1617// Utilize the RmrkCore pallet for access to Runtime errors.18pub trait RmrkDecode<T: Decode, S> {19	fn decode(&self) -> Result<T, Error>;20}2122impl<T: Decode, S> RmrkDecode<T, S> for BoundedVec<u8, S> {23	fn decode(&self) -> Result<T, Error> {24		let mut value = self.as_slice();2526		T::decode(&mut value)27	}28}2930// Utilize the RmrkCore pallet for access to Runtime errors.31pub trait RmrkRebind<T, S> {32	fn rebind(&self) -> Result<BoundedVec<u8, S>, Error>;33}3435impl<T, S> RmrkRebind<T, S> for BoundedVec<u8, T>36where37	BoundedVec<u8, S>: TryFrom<Vec<u8>>,38{39	fn rebind(&self) -> Result<BoundedVec<u8, S>, Error> {40		BoundedVec::<u8, S>::try_from(self.clone().into_inner())41			.map_err(|_| "BoundedVec exceeds its limit".into())42	}43}4445#[derive(Encode, Decode, PartialEq, Eq)]46pub enum CollectionType {47	Regular,48	Resource,49	Base,50}5152#[derive(Encode, Decode, PartialEq, Eq)]53pub enum NftType {54	Regular,55	Resource,56	FixedPart,57	SlotPart,58	Theme,59}6061#[derive(Encode, Decode, PartialEq, Eq)]62pub enum ResourceType {63	Basic,64	Composable,65	Slot,66}
after · pallets/proxy-rmrk-core/src/misc.rs
1use super::*;2use codec::{Encode, Decode, Error};34#[macro_export]5macro_rules! map_unique_err_to_proxy {6    (match $err:ident { $($unique_err_ty:ident :: $unique_err:ident => $proxy_err:ident),+ $(,)? }) => {7        $(8            if $err == <$unique_err_ty<T>>::$unique_err.into() {9                return <Error<T>>::$proxy_err.into()10            } else11        )+ {12            $err13        }14    };15}1617// Utilize the RmrkCore pallet for access to Runtime errors.18pub trait RmrkDecode<T: Decode, S> {19	fn decode(&self) -> Result<T, Error>;20}2122impl<T: Decode, S> RmrkDecode<T, S> for BoundedVec<u8, S> {23	fn decode(&self) -> Result<T, Error> {24		let mut value = self.as_slice();2526		T::decode(&mut value)27	}28}2930// Utilize the RmrkCore pallet for access to Runtime errors.31pub trait RmrkRebind<T, S> {32	fn rebind(&self) -> Result<BoundedVec<u8, S>, Error>;33}3435impl<T, S> RmrkRebind<T, S> for BoundedVec<u8, T>36where37	BoundedVec<u8, S>: TryFrom<Vec<u8>>,38{39	fn rebind(&self) -> Result<BoundedVec<u8, S>, Error> {40		BoundedVec::<u8, S>::try_from(self.clone().into_inner())41			.map_err(|_| "BoundedVec exceeds its limit".into())42	}43}4445#[derive(Encode, Decode, PartialEq, Eq)]46pub enum CollectionType {47	Regular,48	Resource,49	Base,50}5152#[derive(Encode, Decode, PartialEq, Eq)]53pub enum NftType {54	Regular,55	Resource,56	FixedPart,57	SlotPart,58	Theme,59}6061#[derive(Encode, Decode, PartialEq, Eq)]62pub enum ResourceType {63	Basic,64	Composable,65	Slot,66}