difftreelog
fix take parents:0 multilocations into account
in: master
1 file changed
pallets/foreign-assets/src/lib.rsdiffbeforeafterboth246 /// * It is `../Parachain(<Unique Network Para ID>)/GeneralIndex(<Collection ID>)` that corresponds246 /// * It is `../Parachain(<Unique Network Para ID>)/GeneralIndex(<Collection ID>)` that corresponds247 /// to the collection with the ID equal to `<Collection ID>`. The `<Collection ID>` must be in the valid range,247 /// to the collection with the ID equal to `<Collection ID>`. The `<Collection ID>` must be in the valid range,248 /// otherwise `None` is returned.248 /// otherwise `None` is returned.249 /// * It is `GeneralIndex(<Collection ID>)`. Same as the last one above.249 ///250 ///250 /// If the multilocation doesn't match the patterns listed above,251 /// If the multilocation doesn't match the patterns listed above,251 /// or the `<Collection ID>` points to a foreign collection,252 /// or the `<Collection ID>` points to a foreign collection,257258258 let self_location = T::SelfLocation::get();259 let self_location = T::SelfLocation::get();259260260 if *asset_location == Here.into() || *asset_location == self_location {261 if *asset_location == Here.into() || *asset_location == self_location {262 return Some(CollectionLocality::Local(NATIVE_FUNGIBLE_COLLECTION_ID));263 }264265 let collection_junction = if asset_location.parents == 0 {266 match &asset_location.interior {267 X1(junction) => junction,268 _ => return None,269 }270 } else if asset_location.parents == self_location.parents {271 asset_location272 .interior273 .match_and_split(&self_location.interior)?274 } else {275 return None;276 };277261 Some(CollectionLocality::Local(NATIVE_FUNGIBLE_COLLECTION_ID))278 let GeneralIndex(collection_id) = collection_junction else {262 } else if asset_location.parents == self_location.parents {279 return None;263 match asset_location280 };264 .interior281265 .match_and_split(&self_location.interior)266 {267 Some(GeneralIndex(collection_id)) => {268 let collection_id = CollectionId((*collection_id).try_into().ok()?);282 let collection_id = CollectionId((*collection_id).try_into().ok()?);269283270 Self::collection_to_foreign_asset(collection_id)284 Self::collection_to_foreign_asset(collection_id)271 .is_none()285 .is_none()272 .then_some(CollectionLocality::Local(collection_id))286 .then_some(CollectionLocality::Local(collection_id))273 }274 _ => None,275 }276 } else {277 None278 }279 }287 }280288281 /// Converts an asset ID to a Unique Network's collection locality (either foreign or a local one).289 /// Converts an asset ID to a Unique Network's collection locality (either foreign or a local one).