git.delta.rocks / unique-network / refs/commits / 2c3d5fce3d0a

difftreelog

fix native_asset_location_to_collection

Daniel Shiposha2023-10-30parent: #63d711f.patch.diff
in: master

1 file changed

modifiedpallets/foreign-assets/src/lib.rsdiffbeforeafterboth
233 /// to the collection with the ID equal to `<Collection ID>`. The `<Collection ID>` must be in the valid range,233 /// to the collection with the ID equal to `<Collection ID>`. The `<Collection ID>` must be in the valid range,
234 /// otherwise the `AssetIdConversionFailed` error will be returned.234 /// otherwise the `AssetIdConversionFailed` error will be returned.
235 ///235 ///
236 /// If the multilocation doesn't match the patterns listed above, the function returns `Ok(None)`,236 /// If the multilocation doesn't match the patterns listed above,
237 /// or the `<Collection ID>` points to a foreign collection,
237 /// identifying that the given multilocation doesn't correspond to a local collection.238 /// the function returns `Ok(None)`, identifying that the given multilocation doesn't correspond to a local collection.
238 fn native_asset_location_to_collection(239 fn native_asset_location_to_collection(
239 asset_location: &MultiLocation,240 asset_location: &MultiLocation,
240 ) -> Result<Option<CollectionId>, XcmError> {241 ) -> Result<Option<CollectionId>, XcmError> {
247 .interior248 .interior
248 .match_and_split(&self_location.interior)249 .match_and_split(&self_location.interior)
249 {250 {
250 Some(GeneralIndex(collection_id)) => Ok(Some(CollectionId(251 Some(GeneralIndex(collection_id)) => {
252 let collection_id = CollectionId(
251 (*collection_id)253 (*collection_id)
252 .try_into()254 .try_into()
253 .map_err(|_| XcmExecutorError::AssetIdConversionFailed)?,255 .map_err(|_| XcmExecutorError::AssetIdConversionFailed)?,
254 ))),256 );
257
258 if Self::collection_to_foreign_reserve_location(collection_id).is_some() {
259 Ok(None)
260 } else {
261 Ok(Some(collection_id))
262 }
263 }
255 _ => Ok(None),264 _ => Ok(None),
256 }265 }
257 } else {266 } else {