XCM: Remove & replace XCM Convert trait (#7329)

* Introduce an extensible location-to-hash-account

* Convert becomes RevFallRefConvert

* Use ConvertLocation trait

* Remove Convert usage

* Builds

* Fix warnings

* Remove unused types

* Bump lock

* No need for aliasing

* Remove unused

* Deprecate legacy conversion

* Fixes

* Fixes

* Update Cargo.toml

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>

* Update xcm/xcm-builder/src/location_conversion.rs

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>

* Update xcm/xcm-builder/src/location_conversion.rs

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>

* Update xcm/xcm-builder/src/location_conversion.rs

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>

* Update xcm/xcm-builder/src/location_conversion.rs

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>

* Update xcm/xcm-builder/src/location_conversion.rs

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>

* Update xcm/xcm-builder/src/location_conversion.rs

Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>

---------

Co-authored-by: Muharem Ismailov <ismailov.m.h@gmail.com>
Co-authored-by: Liam Aharon <liam.aharon@hotmail.com>
This commit is contained in:
Gavin Wood
2023-06-05 12:00:53 +01:00
committed by GitHub
parent 429b1e4de7
commit c8f9b1b7a0
16 changed files with 588 additions and 609 deletions
@@ -19,7 +19,7 @@ mod relay_chain;
use frame_support::sp_tracing;
use xcm::prelude::*;
use xcm_executor::traits::Convert;
use xcm_executor::traits::ConvertLocation;
use xcm_simulator::{decl_test_network, decl_test_parachain, decl_test_relay_chain, TestExt};
pub const ALICE: sp_runtime::AccountId32 = sp_runtime::AccountId32::new([0u8; 32]);
@@ -67,27 +67,27 @@ decl_test_network! {
pub fn parent_account_id() -> parachain::AccountId {
let location = (Parent,);
parachain::LocationToAccountId::convert(location.into()).unwrap()
parachain::LocationToAccountId::convert_location(&location.into()).unwrap()
}
pub fn child_account_id(para: u32) -> relay_chain::AccountId {
let location = (Parachain(para),);
relay_chain::LocationToAccountId::convert(location.into()).unwrap()
relay_chain::LocationToAccountId::convert_location(&location.into()).unwrap()
}
pub fn child_account_account_id(para: u32, who: sp_runtime::AccountId32) -> relay_chain::AccountId {
let location = (Parachain(para), AccountId32 { network: None, id: who.into() });
relay_chain::LocationToAccountId::convert(location.into()).unwrap()
relay_chain::LocationToAccountId::convert_location(&location.into()).unwrap()
}
pub fn sibling_account_account_id(para: u32, who: sp_runtime::AccountId32) -> parachain::AccountId {
let location = (Parent, Parachain(para), AccountId32 { network: None, id: who.into() });
parachain::LocationToAccountId::convert(location.into()).unwrap()
parachain::LocationToAccountId::convert_location(&location.into()).unwrap()
}
pub fn parent_account_account_id(who: sp_runtime::AccountId32) -> parachain::AccountId {
let location = (Parent, AccountId32 { network: None, id: who.into() });
parachain::LocationToAccountId::convert(location.into()).unwrap()
parachain::LocationToAccountId::convert_location(&location.into()).unwrap()
}
pub fn para_ext(para_id: u32) -> sp_io::TestExternalities {
@@ -47,7 +47,7 @@ use xcm_builder::{
SovereignSignedViaLocation,
};
use xcm_executor::{
traits::{Convert, JustTry},
traits::{ConvertLocation, JustTry},
Config, XcmExecutor,
};
@@ -160,7 +160,7 @@ impl EnsureOriginWithArg<RuntimeOrigin, MultiLocation> for ForeignCreators {
if !a.starts_with(&origin_location) {
return Err(o)
}
SovereignAccountOf::convert(origin_location).map_err(|_| o)
SovereignAccountOf::convert_location(&origin_location).ok_or(o)
}
#[cfg(feature = "runtime-benchmarks")]