difftreelog
style(rmrk-proxy) cargo fmt
in: master
2 files changed
pallets/proxy-rmrk-core/src/lib.rsdiffbeforeafterboth--- a/pallets/proxy-rmrk-core/src/lib.rs
+++ b/pallets/proxy-rmrk-core/src/lib.rs
@@ -518,7 +518,8 @@
Ok(scoped_key)
}
- pub fn rmrk_property<E: Encode>( // todo think about renaming this
+ pub fn rmrk_property<E: Encode>(
+ // todo think about renaming this
rmrk_key: RmrkProperty,
value: &E,
) -> Result<Property, DispatchError> {
@@ -533,20 +534,18 @@
Ok(property)
}
-
- pub fn decode_property<D: Decode>(
- vec: PropertyValue,
- ) -> Result<D, DispatchError> {
- vec.decode().map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong.into())
+
+ pub fn decode_property<D: Decode>(vec: PropertyValue) -> Result<D, DispatchError> {
+ vec.decode()
+ .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong.into())
}
- pub fn rebind<L, S>(
- vec: &BoundedVec<u8, L>,
- ) -> Result<BoundedVec<u8, S>, DispatchError>
- where
- BoundedVec<u8, S>: TryFrom<Vec<u8>>
+ pub fn rebind<L, S>(vec: &BoundedVec<u8, L>) -> Result<BoundedVec<u8, S>, DispatchError>
+ where
+ BoundedVec<u8, S>: TryFrom<Vec<u8>>,
{
- vec.rebind().map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong.into())
+ vec.rebind()
+ .map_err(|_| <Error<T>>::RmrkPropertyValueIsTooLong.into())
}
fn init_collection(
@@ -727,9 +726,7 @@
collection_id: CollectionId,
key: RmrkProperty,
) -> Result<V, DispatchError> {
- Self::decode_property(
- Self::get_collection_property(collection_id, key)?
- )
+ Self::decode_property(Self::get_collection_property(collection_id, key)?)
}
pub fn get_collection_type(
@@ -779,9 +776,7 @@
nft_id: TokenId,
key: RmrkProperty,
) -> Result<V, DispatchError> {
- Self::decode_property(
- Self::get_nft_property(collection_id, nft_id, key)?
- )
+ Self::decode_property(Self::get_nft_property(collection_id, nft_id, key)?)
}
pub fn nft_exists(collection_id: CollectionId, nft_id: TokenId) -> bool {
pallets/proxy-rmrk-core/src/misc.rsdiffbeforeafterboth1use super::*;2use codec::{Encode, Decode, Error};34#[macro_export]5macro_rules! map_common_err_to_proxy {6 (match $err:ident { $($common_err:ident => $proxy_err:ident),+ }) => {7 $(8 if $err == <CommonError<T>>::$common_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()).map_err(|_| "BoundedVec exceeds its limit".into())41 }42}4344#[derive(Encode, Decode, PartialEq, Eq)]45pub enum CollectionType {46 Regular,47 Resource,48 Base,49}5051#[derive(Encode, Decode, PartialEq, Eq)]52pub enum NftType {53 Regular,54 Resource,55 FixedPart,56 SlotPart,57 Theme,58}5960#[derive(Encode, Decode, PartialEq, Eq)]61pub enum ResourceType {62 Basic,63 Composable,64 Slot,65}