-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Inconsistency in XCM Versioned* try_as implementation #8185
Copy link
Copy link
Open
Labels
T6-XCMThis PR/Issue is related to XCM.This PR/Issue is related to XCM.
Description
A conversion with TryInto works between different VersionedLocation version and xcm::v*::Location, but TryAs works only with the same version.
Other words, I can try_into convert VersionedLocation::V4 to v4::Location or v3::Location or v5::Location, but I can try_as convert VersionedLocation::V4 only to v4::Location and nothing else.
Solution
Behavior should be aligned or we just remove TryAs.
Demo
#[test]
fn test_try_as() {
let versioned_location_v4 = VersionedLocation::V4(v4::Location::parent());
// TryInto:
// Works
assert!(TryInto::<v4::Location>::try_into(versioned_location_v4.clone()).is_ok());
assert!(TryInto::<v3::Location>::try_into(versioned_location_v4.clone()).is_ok());
assert!(TryInto::<v5::Location>::try_into(versioned_location_v4.clone()).is_ok());
// TryAs:
// Works
assert!(versioned_location_v4.try_as::<v4::Location>().is_ok());
// Fails - should work also!!!
assert!(versioned_location_v4.try_as::<v3::Location>().is_err());
assert!(versioned_location_v4.try_as::<v5::Location>().is_err());
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T6-XCMThis PR/Issue is related to XCM.This PR/Issue is related to XCM.
Type
Projects
Status
No status