mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 01:41:03 +00:00
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:
@@ -24,7 +24,7 @@ use frame_support::{
|
||||
use sp_runtime::traits::{Bounded, Zero};
|
||||
use sp_std::{prelude::*, vec};
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_executor::traits::{Convert, TransactAsset};
|
||||
use xcm_executor::traits::{ConvertLocation, TransactAsset};
|
||||
|
||||
benchmarks_instance_pallet! {
|
||||
where_clause { where
|
||||
@@ -75,7 +75,7 @@ benchmarks_instance_pallet! {
|
||||
// this xcm doesn't use holding
|
||||
|
||||
let dest_location = T::valid_destination()?;
|
||||
let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap();
|
||||
let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap();
|
||||
|
||||
<AssetTransactorOf<T>>::deposit_asset(
|
||||
&asset,
|
||||
@@ -101,7 +101,7 @@ benchmarks_instance_pallet! {
|
||||
transfer_reserve_asset {
|
||||
let (sender_account, sender_location) = account_and_location::<T>(1);
|
||||
let dest_location = T::valid_destination()?;
|
||||
let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap();
|
||||
let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap();
|
||||
|
||||
let asset = T::get_multi_asset();
|
||||
<AssetTransactorOf<T>>::deposit_asset(
|
||||
@@ -171,7 +171,7 @@ benchmarks_instance_pallet! {
|
||||
|
||||
// our dest must have no balance initially.
|
||||
let dest_location = T::valid_destination()?;
|
||||
let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap();
|
||||
let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap();
|
||||
assert!(T::TransactAsset::balance(&dest_account).is_zero());
|
||||
|
||||
let mut executor = new_executor::<T>(Default::default());
|
||||
@@ -197,7 +197,7 @@ benchmarks_instance_pallet! {
|
||||
|
||||
// our dest must have no balance initially.
|
||||
let dest_location = T::valid_destination()?;
|
||||
let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap();
|
||||
let dest_account = T::AccountIdConverter::convert_location(&dest_location).unwrap();
|
||||
assert!(T::TransactAsset::balance(&dest_account).is_zero());
|
||||
|
||||
let mut executor = new_executor::<T>(Default::default());
|
||||
|
||||
@@ -22,7 +22,7 @@ use codec::Encode;
|
||||
use frame_benchmarking::{account, BenchmarkError};
|
||||
use sp_std::prelude::*;
|
||||
use xcm::latest::prelude::*;
|
||||
use xcm_executor::{traits::Convert, Config as XcmConfig};
|
||||
use xcm_executor::{traits::ConvertLocation, Config as XcmConfig};
|
||||
|
||||
pub mod fungible;
|
||||
pub mod generic;
|
||||
@@ -39,7 +39,7 @@ pub trait Config: frame_system::Config {
|
||||
type XcmConfig: XcmConfig;
|
||||
|
||||
/// A converter between a multi-location to a sovereign account.
|
||||
type AccountIdConverter: Convert<MultiLocation, Self::AccountId>;
|
||||
type AccountIdConverter: ConvertLocation<Self::AccountId>;
|
||||
|
||||
/// Does any necessary setup to create a valid destination for XCM messages.
|
||||
/// Returns that destination's multi-location to be used in benchmarks.
|
||||
@@ -104,7 +104,7 @@ fn account_id_junction<T: frame_system::Config>(index: u32) -> Junction {
|
||||
|
||||
pub fn account_and_location<T: Config>(index: u32) -> (T::AccountId, MultiLocation) {
|
||||
let location: MultiLocation = account_id_junction::<T>(index).into();
|
||||
let account = T::AccountIdConverter::convert(location.clone()).unwrap();
|
||||
let account = T::AccountIdConverter::convert_location(&location).unwrap();
|
||||
|
||||
(account, location)
|
||||
}
|
||||
|
||||
@@ -47,18 +47,14 @@ impl xcm_executor::traits::OnResponse for DevNull {
|
||||
}
|
||||
|
||||
pub struct AccountIdConverter;
|
||||
impl xcm_executor::traits::Convert<MultiLocation, u64> for AccountIdConverter {
|
||||
fn convert(ml: MultiLocation) -> Result<u64, MultiLocation> {
|
||||
impl xcm_executor::traits::ConvertLocation<u64> for AccountIdConverter {
|
||||
fn convert_location(ml: &MultiLocation) -> Option<u64> {
|
||||
match ml {
|
||||
MultiLocation { parents: 0, interior: X1(Junction::AccountId32 { id, .. }) } =>
|
||||
Ok(<u64 as codec::Decode>::decode(&mut &*id.to_vec()).unwrap()),
|
||||
_ => Err(ml),
|
||||
Some(<u64 as codec::Decode>::decode(&mut &*id.to_vec()).unwrap()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
fn reverse(acc: u64) -> Result<MultiLocation, u64> {
|
||||
Err(acc)
|
||||
}
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
|
||||
Reference in New Issue
Block a user