git.delta.rocks / unique-network / refs/commits / 719aab2a882e

difftreelog

source

pallets/proxy-rmrk-core/src/misc.rs1.4 KiBsourcehistory
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}