--- a/pallets/common/src/lib.rs +++ b/pallets/common/src/lib.rs @@ -365,6 +365,10 @@ /// Tried to store more data than allowed in collection field CollectionFieldSizeExceeded, + + NoSpaceForProperty, + + PropertyLimitReached, } #[pallet::storage] @@ -651,7 +655,10 @@ CollectionProperties::::insert( id, - Properties::from_collection_props_vec(data.properties)?, + Properties::from_collection_props_vec(data.properties) + .map_err(|e| -> Error:: { + e.into() + })?, ); let token_props_permissions: PropertiesPermissionMap = data @@ -660,7 +667,9 @@ .map(|property| (property.key, property.permission)) .collect::>() .try_into() - .map_err(|_| PropertiesError::PropertyLimitReached)?; + .map_err(|_| -> Error:: { + PropertiesError::PropertyLimitReached.into() + })?; CollectionPropertyPermissions::::insert(id, token_props_permissions); @@ -744,6 +753,9 @@ CollectionProperties::::try_mutate(collection.id, |properties| { properties.try_set_property(property.clone()) + }) + .map_err(|e| -> Error:: { + e.into() })?; Self::deposit_event(Event::CollectionPropertySet(collection.id, property)); @@ -811,7 +823,9 @@ let property_permission = property_permission.clone(); permissions.try_insert(property_permission.key, property_permission.permission) }) - .map_err(|_| PropertiesError::PropertyLimitReached)?; + .map_err(|_| -> Error:: { + PropertiesError::PropertyLimitReached.into() + })?; Self::deposit_event(Event::PropertyPermissionSet( collection.id, @@ -1133,3 +1147,12 @@ Err(error) => Err(DispatchErrorWithPostInfo { post_info, error }), } } + +impl From for Error { + fn from(error: PropertiesError) -> Self { + match error { + PropertiesError::NoSpaceForProperty => Self::NoSpaceForProperty, + PropertiesError::PropertyLimitReached => Self::PropertyLimitReached, + } + } +} --- a/pallets/nonfungible/src/lib.rs +++ b/pallets/nonfungible/src/lib.rs @@ -265,6 +265,8 @@ >::try_mutate((collection.id, token_id), |properties| { properties.try_set_property(property.clone()) + }).map_err(|e| -> CommonError:: { + e.into() })?; >::deposit_event(CommonEvent::TokenPropertySet( --- a/primitives/data-structs/src/lib.rs +++ b/primitives/data-structs/src/lib.rs @@ -660,17 +660,6 @@ PropertyLimitReached, } -impl From for DispatchError { - fn from(error: PropertiesError) -> Self { - match error { - PropertiesError::NoSpaceForProperty => DispatchError::Other("no space for property"), - PropertiesError::PropertyLimitReached => { - DispatchError::Other("property key limit reached") - } - } - } -} - pub type PropertiesMap = BoundedBTreeMap>; pub type PropertiesPermissionMap =