Skip to content

Commit

Permalink
fix: native_asset_location_to_collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mrshiposha committed Oct 30, 2023
1 parent 51a4a2c commit 994b525
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions pallets/foreign-assets/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,9 @@ impl<T: Config> Pallet<T> {
/// to the collection with the ID equal to `<Collection ID>`. The `<Collection ID>` must be in the valid range,
/// otherwise the `AssetIdConversionFailed` error will be returned.
///
/// If the multilocation doesn't match the patterns listed above, the function returns `Ok(None)`,
/// identifying that the given multilocation doesn't correspond to a local collection.
/// If the multilocation doesn't match the patterns listed above,
/// or the `<Collection ID>` points to a foreign collection,
/// the function returns `Ok(None)`, identifying that the given multilocation doesn't correspond to a local collection.
fn native_asset_location_to_collection(
asset_location: &MultiLocation,
) -> Result<Option<CollectionId>, XcmError> {
Expand All @@ -247,11 +248,19 @@ impl<T: Config> Pallet<T> {
.interior
.match_and_split(&self_location.interior)
{
Some(GeneralIndex(collection_id)) => Ok(Some(CollectionId(
(*collection_id)
.try_into()
.map_err(|_| XcmExecutorError::AssetIdConversionFailed)?,
))),
Some(GeneralIndex(collection_id)) => {
let collection_id = CollectionId(
(*collection_id)
.try_into()
.map_err(|_| XcmExecutorError::AssetIdConversionFailed)?,
);

if Self::collection_to_foreign_reserve_location(collection_id).is_some() {
Ok(None)
} else {
Ok(Some(collection_id))
}
}
_ => Ok(None),
}
} else {
Expand Down

0 comments on commit 994b525

Please sign in to comment.