Skip to content

Commit

Permalink
check for supported multilocation type when creating/updating assets
Browse files Browse the repository at this point in the history
Signed-off-by: Adam Reif <[email protected]>
  • Loading branch information
Adam Reif authored and Adam Reif committed Apr 4, 2023
1 parent bfbe464 commit ed10238
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pallets/asset-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ pub mod pallet {
/// Location Already Exists
LocationAlreadyExists,

/// MultiLocation Type Not Supported
LocationNotSupported,

/// An error occured while creating a new asset at the [`AssetRegistry`].
ErrorCreatingAsset,

Expand Down Expand Up @@ -348,6 +351,7 @@ pub mod pallet {
!LocationAssetId::<T>::contains_key(&location),
Error::<T>::LocationAlreadyExists
);
ensure!(Self::contains(&location), Error::<T>::LocationNotSupported);
let asset_id = Self::next_asset_id_and_increment()?;
<T::AssetConfig as AssetConfig<T>>::AssetRegistry::create_asset(
asset_id,
Expand Down Expand Up @@ -399,6 +403,7 @@ pub mod pallet {
!LocationAssetId::<T>::contains_key(&location),
Error::<T>::LocationAlreadyExists
);
ensure!(Self::contains(&location), Error::<T>::LocationNotSupported);
// change the ledger state.
let old_location =
AssetIdLocation::<T>::get(asset_id).ok_or(Error::<T>::UpdateNonExistentAsset)?;
Expand Down

0 comments on commit ed10238

Please sign in to comment.