refactor(asset-registry): improvements
@@ -86,9 +86,9 @@ pub mod pallet {
impl<T: Config> Pallet<T> {
/// Create assset for given name or return existing AssetId if already exists.
pub fn get_or_create_asset(name: Vec<u8>) -> Result<T::AssetId, DispatchError> {
- match <AssetIds<T>>::contains_key(&name) {
- true => Ok(<AssetIds<T>>::get(&name).unwrap()),
- false => {
+ if <AssetIds<T>>::contains_key(&name) {
+ Ok(<AssetIds<T>>::get(&name).unwrap())
+ } else {
let asset_id = Self::next_asset_id();
let next_id = asset_id.checked_add(&One::one()).ok_or(Error::<T>::NoIdAvailable)?;
<NextAssetId<T>>::put(next_id);
@@ -97,4 +97,3 @@ impl<T: Config> Pallet<T> {
}
}
}
-}
