1234567891011121314151617use super::*;18use codec::{Encode, Decode, Error};1920#[macro_export]21macro_rules! map_unique_err_to_proxy {22 (match $err:ident { $($unique_err_ty:ident :: $unique_err:ident => $proxy_err:ident),+ $(,)? }) => {23 $(24 if $err == <$unique_err_ty<T>>::$unique_err.into() {25 return <Error<T>>::$proxy_err.into()26 } else27 )+ {28 $err29 }30 };31}323334pub trait RmrkDecode<T: Decode, S> {35 fn decode(&self) -> Result<T, Error>;36}3738impl<T: Decode, S> RmrkDecode<T, S> for BoundedVec<u8, S> {39 fn decode(&self) -> Result<T, Error> {40 let mut value = self.as_slice();4142 T::decode(&mut value)43 }44}454647pub trait RmrkRebind<T, S> {48 fn rebind(&self) -> Result<BoundedVec<u8, S>, Error>;49}5051impl<T, S> RmrkRebind<T, S> for BoundedVec<u8, T>52where53 BoundedVec<u8, S>: TryFrom<Vec<u8>>,54{55 fn rebind(&self) -> Result<BoundedVec<u8, S>, Error> {56 BoundedVec::<u8, S>::try_from(self.clone().into_inner())57 .map_err(|_| "BoundedVec exceeds its limit".into())58 }59}6061#[derive(Encode, Decode, PartialEq, Eq)]62pub enum CollectionType {63 Regular,64 Resource,65 Base,66}6768#[derive(Encode, Decode, PartialEq, Eq)]69pub enum NftType {70 Regular,71 Resource,72 FixedPart,73 SlotPart,74 Theme,75}7677#[derive(Encode, Decode, PartialEq, Eq)]78pub enum ResourceType {79 Basic,80 Composable,81 Slot,82}