Companion for #7329: XCM: Remove & replace Polkadot's Convert trait (#2688)

* Fixups for new Convert APIs

* update lockfile for {"polkadot", "substrate"}

---------

Co-authored-by: parity-processbot <>
This commit is contained in:
Gavin Wood
2023-06-05 12:40:33 +01:00
committed by GitHub
parent 15c49c49ee
commit 2a4edaf39c
11 changed files with 394 additions and 327 deletions
@@ -13,7 +13,7 @@ use xcm_emulator::{
decl_test_networks, decl_test_parachains, decl_test_relay_chains, Parachain, RelayChain,
TestExt,
};
use xcm_executor::traits::Convert;
use xcm_executor::traits::ConvertLocation;
decl_test_relay_chains! {
#[api_version(5)]
@@ -1,3 +1,22 @@
// This file is part of Cumulus.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for the Statemine (Kusama Assets Hub) chain.
use asset_hub_kusama_runtime::xcm_config::{
AssetFeeAsExistentialDepositMultiplierFeeCharger, KsmLocation, TrustBackedAssetsPalletLocation,
};
@@ -17,8 +36,9 @@ use frame_support::{
weights::{Weight, WeightToFee as WeightToFeeT},
};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
use sp_runtime::traits::MaybeEquivalence;
use xcm::latest::prelude::*;
use xcm_executor::traits::{Convert, Identity, JustTry, WeightTrader};
use xcm_executor::traits::{Identity, JustTry, WeightTrader};
const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
@@ -66,7 +86,7 @@ fn test_asset_xcm_trader() {
// get asset id as multilocation
let asset_multilocation =
AssetIdForTrustBackedAssetsConvert::reverse_ref(local_asset_id).unwrap();
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap();
// Set Alice as block author, who will receive fees
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
@@ -150,7 +170,7 @@ fn test_asset_xcm_trader_with_refund() {
// We are going to buy 4e9 weight
let bought = Weight::from_parts(4_000_000_000u64, 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
// lets calculate amount needed
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -220,7 +240,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
// We are going to buy small amount
let bought = Weight::from_parts(500_000_000u64, 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -271,7 +291,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
// We are gonna buy ED
let bought = Weight::from_parts(ExistentialDeposit::get().try_into().unwrap(), 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -346,7 +366,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
// lets calculate amount needed
let asset_amount_needed = WeightToFee::weight_to_fee(&bought);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let asset: MultiAsset = (asset_multilocation, asset_amount_needed).into();
@@ -461,13 +481,13 @@ fn test_assets_balances_api_works() {
)));
// check trusted asset
assert!(result.inner().iter().any(|asset| asset.eq(&(
AssetIdForTrustBackedAssetsConvert::reverse_ref(local_asset_id).unwrap(),
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap(),
minimum_asset_balance
)
.into())));
// check foreign asset
assert!(result.inner().iter().any(|asset| asset.eq(&(
Identity::reverse_ref(foreign_asset_id_multilocation).unwrap(),
Identity::convert_back(&foreign_asset_id_multilocation).unwrap(),
6 * foreign_asset_minimum_asset_balance
)
.into())));
@@ -1,3 +1,22 @@
// This file is part of Cumulus.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for the Statemint (Polkadot Assets Hub) chain.
use asset_hub_polkadot_runtime::xcm_config::{
AssetFeeAsExistentialDepositMultiplierFeeCharger, CheckingAccount, DotLocation,
ForeignCreatorsSovereignAccountOf, TrustBackedAssetsPalletLocation, XcmConfig,
@@ -18,8 +37,9 @@ use frame_support::{
use parachains_common::{
AccountId, AssetHubPolkadotAuraId as AuraId, AssetIdForTrustBackedAssets, Balance,
};
use sp_runtime::traits::MaybeEquivalence;
use xcm::latest::prelude::*;
use xcm_executor::traits::{Convert, Identity, JustTry, WeightTrader};
use xcm_executor::traits::{Identity, JustTry, WeightTrader};
const ALICE: [u8; 32] = [1u8; 32];
const SOME_ASSET_ADMIN: [u8; 32] = [5u8; 32];
@@ -67,7 +87,7 @@ fn test_asset_xcm_trader() {
// get asset id as multilocation
let asset_multilocation =
AssetIdForTrustBackedAssetsConvert::reverse_ref(local_asset_id).unwrap();
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap();
// Set Alice as block author, who will receive fees
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
@@ -157,7 +177,7 @@ fn test_asset_xcm_trader_with_refund() {
// bit more of weight
let bought = Weight::from_parts(400_000_000_000u64, 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
// lets calculate amount needed
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -230,7 +250,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
// bit more of weight
let bought = Weight::from_parts(50_000_000_000u64, 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -281,7 +301,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
// We are gonna buy ED
let bought = Weight::from_parts(ExistentialDeposit::get().try_into().unwrap(), 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -359,7 +379,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
// lets calculate amount needed
let asset_amount_needed = WeightToFee::weight_to_fee(&bought);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let asset: MultiAsset = (asset_multilocation, asset_amount_needed).into();
@@ -474,13 +494,13 @@ fn test_assets_balances_api_works() {
)));
// check trusted asset
assert!(result.inner().iter().any(|asset| asset.eq(&(
AssetIdForTrustBackedAssetsConvert::reverse_ref(local_asset_id).unwrap(),
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap(),
minimum_asset_balance
)
.into())));
// check foreign asset
assert!(result.inner().iter().any(|asset| asset.eq(&(
Identity::reverse_ref(foreign_asset_id_multilocation).unwrap(),
Identity::convert_back(&foreign_asset_id_multilocation).unwrap(),
6 * foreign_asset_minimum_asset_balance
)
.into())));
@@ -1,3 +1,22 @@
// This file is part of Cumulus.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! Tests for the Westmint (Westend Assets Hub) chain.
pub use asset_hub_westend_runtime::{
constants::fee::WeightToFee,
xcm_config::{CheckingAccount, TrustBackedAssetsPalletLocation, XcmConfig},
@@ -20,10 +39,11 @@ use frame_support::{
weights::{Weight, WeightToFee as WeightToFeeT},
};
use parachains_common::{AccountId, AssetIdForTrustBackedAssets, AuraId, Balance};
use sp_runtime::traits::MaybeEquivalence;
use std::convert::Into;
use xcm::{latest::prelude::*, VersionedXcm, MAX_XCM_DECODE_DEPTH};
use xcm_executor::{
traits::{Convert, Identity, JustTry, WeightTrader},
traits::{Identity, JustTry, WeightTrader},
XcmExecutor,
};
@@ -73,7 +93,7 @@ fn test_asset_xcm_trader() {
// get asset id as multilocation
let asset_multilocation =
AssetIdForTrustBackedAssetsConvert::reverse_ref(local_asset_id).unwrap();
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap();
// Set Alice as block author, who will receive fees
RuntimeHelper::<Runtime>::run_to_block(2, Some(AccountId::from(ALICE)));
@@ -156,7 +176,7 @@ fn test_asset_xcm_trader_with_refund() {
// We are going to buy 4e9 weight
let bought = Weight::from_parts(4_000_000_000u64, 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
// lets calculate amount needed
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -226,7 +246,7 @@ fn test_asset_xcm_trader_refund_not_possible_since_amount_less_than_ed() {
// We are going to buy 5e9 weight
let bought = Weight::from_parts(500_000_000u64, 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -276,7 +296,7 @@ fn test_that_buying_ed_refund_does_not_refund() {
let bought = Weight::from_parts(500_000_000u64, 0);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let amount_bought = WeightToFee::weight_to_fee(&bought);
@@ -351,7 +371,7 @@ fn test_asset_xcm_trader_not_possible_for_non_sufficient_assets() {
// lets calculate amount needed
let asset_amount_needed = WeightToFee::weight_to_fee(&bought);
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::reverse_ref(1).unwrap();
let asset_multilocation = AssetIdForTrustBackedAssetsConvert::convert_back(&1).unwrap();
let asset: MultiAsset = (asset_multilocation, asset_amount_needed).into();
@@ -466,13 +486,13 @@ fn test_assets_balances_api_works() {
)));
// check trusted asset
assert!(result.inner().iter().any(|asset| asset.eq(&(
AssetIdForTrustBackedAssetsConvert::reverse_ref(local_asset_id).unwrap(),
AssetIdForTrustBackedAssetsConvert::convert_back(&local_asset_id).unwrap(),
minimum_asset_balance
)
.into())));
// check foreign asset
assert!(result.inner().iter().any(|asset| asset.eq(&(
Identity::reverse_ref(foreign_asset_id_multilocation).unwrap(),
Identity::convert_back(&foreign_asset_id_multilocation).unwrap(),
6 * foreign_asset_minimum_asset_balance
)
.into())));
@@ -14,6 +14,7 @@ log = { version = "0.4.18", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-api = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "master" }
# Polkadot
pallet-xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "master" }
@@ -38,6 +39,7 @@ std = [
"cumulus-primitives-core/std",
"sp-api/std",
"sp-std/std",
"sp-runtime/std",
"pallet-xcm/std",
"xcm/std",
"xcm-builder/std",
@@ -18,16 +18,16 @@ use frame_support::traits::{
};
use pallet_xcm::{EnsureXcm, Origin as XcmOrigin};
use xcm::latest::MultiLocation;
use xcm_executor::traits::Convert;
use xcm_executor::traits::ConvertLocation;
// `EnsureOriginWithArg` impl for `CreateOrigin` that allows only XCM origins that are locations
// containing the class location.
/// `EnsureOriginWithArg` impl for `CreateOrigin` that allows only XCM origins that are locations
/// containing the class location.
pub struct ForeignCreators<IsForeign, AccountOf, AccountId>(
sp_std::marker::PhantomData<(IsForeign, AccountOf, AccountId)>,
);
impl<
IsForeign: ContainsPair<MultiLocation, MultiLocation>,
AccountOf: Convert<MultiLocation, AccountId>,
AccountOf: ConvertLocation<AccountId>,
AccountId: Clone,
RuntimeOrigin: From<XcmOrigin> + OriginTrait + Clone,
> EnsureOriginWithArg<RuntimeOrigin, MultiLocation>
@@ -46,7 +46,7 @@ where
if !IsForeign::contains(asset_location, &origin_location) {
return Err(origin)
}
AccountOf::convert(origin_location).map_err(|_| origin)
AccountOf::convert_location(&origin_location).ok_or(origin)
}
#[cfg(feature = "runtime-benchmarks")]
@@ -17,10 +17,11 @@
use crate::runtime_api::FungiblesAccessError;
use frame_support::traits::Contains;
use sp_runtime::traits::MaybeEquivalence;
use sp_std::{borrow::Borrow, vec::Vec};
use xcm::latest::{MultiAsset, MultiLocation};
use xcm_builder::{ConvertedConcreteId, MatchedConvertedConcreteId};
use xcm_executor::traits::{Convert, MatchesFungibles};
use xcm_executor::traits::MatchesFungibles;
/// Converting any [`(AssetId, Balance)`] to [`MultiAsset`]
pub trait MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>:
@@ -28,8 +29,8 @@ pub trait MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>:
where
AssetId: Clone,
Balance: Clone,
ConvertAssetId: Convert<MultiLocation, AssetId>,
ConvertBalance: Convert<u128, Balance>,
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
ConvertBalance: MaybeEquivalence<u128, Balance>,
{
fn convert_ref(
value: impl Borrow<(AssetId, Balance)>,
@@ -39,8 +40,8 @@ where
impl<
AssetId: Clone,
Balance: Clone,
ConvertAssetId: Convert<MultiLocation, AssetId>,
ConvertBalance: Convert<u128, Balance>,
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
ConvertBalance: MaybeEquivalence<u128, Balance>,
> MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>
for ConvertedConcreteId<AssetId, Balance, ConvertAssetId, ConvertBalance>
{
@@ -48,12 +49,12 @@ impl<
value: impl Borrow<(AssetId, Balance)>,
) -> Result<MultiAsset, FungiblesAccessError> {
let (asset_id, balance) = value.borrow();
match ConvertAssetId::reverse_ref(asset_id) {
Ok(asset_id_as_multilocation) => match ConvertBalance::reverse_ref(balance) {
Ok(amount) => Ok((asset_id_as_multilocation, amount).into()),
Err(_) => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
match ConvertAssetId::convert_back(asset_id) {
Some(asset_id_as_multilocation) => match ConvertBalance::convert_back(balance) {
Some(amount) => Ok((asset_id_as_multilocation, amount).into()),
None => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
},
Err(_) => Err(FungiblesAccessError::AssetIdConversionFailed),
None => Err(FungiblesAccessError::AssetIdConversionFailed),
}
}
}
@@ -62,8 +63,8 @@ impl<
AssetId: Clone,
Balance: Clone,
MatchAssetId: Contains<MultiLocation>,
ConvertAssetId: Convert<MultiLocation, AssetId>,
ConvertBalance: Convert<u128, Balance>,
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
ConvertBalance: MaybeEquivalence<u128, Balance>,
> MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>
for MatchedConvertedConcreteId<AssetId, Balance, MatchAssetId, ConvertAssetId, ConvertBalance>
{
@@ -71,12 +72,12 @@ impl<
value: impl Borrow<(AssetId, Balance)>,
) -> Result<MultiAsset, FungiblesAccessError> {
let (asset_id, balance) = value.borrow();
match ConvertAssetId::reverse_ref(asset_id) {
Ok(asset_id_as_multilocation) => match ConvertBalance::reverse_ref(balance) {
Ok(amount) => Ok((asset_id_as_multilocation, amount).into()),
Err(_) => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
match ConvertAssetId::convert_back(asset_id) {
Some(asset_id_as_multilocation) => match ConvertBalance::convert_back(balance) {
Some(amount) => Ok((asset_id_as_multilocation, amount).into()),
None => Err(FungiblesAccessError::AmountToBalanceConversionFailed),
},
Err(_) => Err(FungiblesAccessError::AssetIdConversionFailed),
None => Err(FungiblesAccessError::AssetIdConversionFailed),
}
}
}
@@ -88,8 +89,8 @@ pub fn convert<'a, AssetId, Balance, ConvertAssetId, ConvertBalance, Converter>(
where
AssetId: Clone + 'a,
Balance: Clone + 'a,
ConvertAssetId: Convert<MultiLocation, AssetId>,
ConvertBalance: Convert<u128, Balance>,
ConvertAssetId: MaybeEquivalence<MultiLocation, AssetId>,
ConvertBalance: MaybeEquivalence<u128, Balance>,
Converter: MultiAssetConverter<AssetId, Balance, ConvertAssetId, ConvertBalance>,
{
items.map(Converter::convert_ref).collect()
@@ -80,8 +80,9 @@ pub type ForeignAssetsConvertedConcreteId<AdditionalMultiLocationExclusionFilter
mod tests {
use super::*;
use crate::matching::StartsWithExplicitGlobalConsensus;
use sp_runtime::traits::MaybeEquivalence;
use xcm::latest::prelude::*;
use xcm_executor::traits::{Convert, Error as MatchError, MatchesFungibles};
use xcm_executor::traits::{Error as MatchError, MatchesFungibles};
#[test]
fn asset_id_for_trust_backed_assets_convert_works() {
@@ -93,15 +94,15 @@ mod tests {
MultiLocation::new(5, X2(PalletInstance(13), GeneralIndex(local_asset_id.into())));
assert_eq!(
AssetIdForTrustBackedAssetsConvert::<TrustBackedAssetsPalletLocation>::reverse_ref(
local_asset_id
AssetIdForTrustBackedAssetsConvert::<TrustBackedAssetsPalletLocation>::convert_back(
&local_asset_id
)
.unwrap(),
expected_reverse_ref
);
assert_eq!(
AssetIdForTrustBackedAssetsConvert::<TrustBackedAssetsPalletLocation>::convert_ref(
expected_reverse_ref
AssetIdForTrustBackedAssetsConvert::<TrustBackedAssetsPalletLocation>::convert(
&expected_reverse_ref
)
.unwrap(),
local_asset_id
@@ -27,11 +27,11 @@ use parachains_runtimes_test_utils::{
RuntimeHelper, ValidatorIdOf, XcmReceivedFrom,
};
use sp_runtime::{
traits::{StaticLookup, Zero},
traits::{MaybeEquivalence, StaticLookup, Zero},
DispatchError, Saturating,
};
use xcm::latest::prelude::*;
use xcm_executor::{traits::Convert, XcmExecutor};
use xcm_executor::{traits::ConvertLocation, XcmExecutor};
/// Test-case makes sure that `Runtime` can receive native asset from relay chain
/// and can teleport it back and to the other parachains
@@ -308,7 +308,7 @@ pub fn teleports_for_foreign_assets_works<
>,
WeightToFee: frame_support::weights::WeightToFee<Balance = Balance>,
<WeightToFee as frame_support::weights::WeightToFee>::Balance: From<u128> + Into<u128>,
SovereignAccountOf: Convert<MultiLocation, AccountIdOf<Runtime>>,
SovereignAccountOf: ConvertLocation<AccountIdOf<Runtime>>,
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetId:
From<MultiLocation> + Into<MultiLocation>,
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetIdParameter:
@@ -330,7 +330,8 @@ pub fn teleports_for_foreign_assets_works<
// foreign creator, which can be sibling parachain to match ForeignCreators
let foreign_creator = MultiLocation { parents: 1, interior: X1(Parachain(foreign_para_id)) };
let foreign_creator_as_account_id = SovereignAccountOf::convert(foreign_creator).expect("");
let foreign_creator_as_account_id =
SovereignAccountOf::convert_location(&foreign_creator).expect("");
// we want to buy execution with local relay chain currency
let buy_execution_fee_amount =
@@ -744,7 +745,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
From<<Runtime as frame_system::Config>::AccountId>,
AssetsPalletInstance: 'static,
AssetId: Clone + Copy,
AssetIdConverter: Convert<MultiLocation, AssetId>,
AssetIdConverter: MaybeEquivalence<MultiLocation, AssetId>,
{
ExtBuilder::<Runtime>::default()
.with_collators(collator_session_keys.collators())
@@ -759,7 +760,7 @@ pub fn asset_transactor_transfer_with_pallet_assets_instance_works<
.execute_with(|| {
// create some asset class
let asset_minimum_asset_balance = 3333333_u128;
let asset_id_as_multilocation = AssetIdConverter::reverse_ref(asset_id).unwrap();
let asset_id_as_multilocation = AssetIdConverter::convert_back(&asset_id).unwrap();
assert_ok!(<pallet_assets::Pallet<Runtime, AssetsPalletInstance>>::force_create(
RuntimeHelper::<Runtime>::root_origin(),
asset_id.into(),
@@ -1002,7 +1003,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
XcmConfig: xcm_executor::Config,
WeightToFee: frame_support::weights::WeightToFee<Balance = Balance>,
<WeightToFee as frame_support::weights::WeightToFee>::Balance: From<u128> + Into<u128>,
SovereignAccountOf: Convert<MultiLocation, AccountIdOf<Runtime>>,
SovereignAccountOf: ConvertLocation<AccountIdOf<Runtime>>,
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetId:
From<AssetId> + Into<AssetId>,
<Runtime as pallet_assets::Config<ForeignAssetsPalletInstance>>::AssetIdParameter:
@@ -1015,16 +1016,17 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
From<<Runtime as frame_system::Config>::AccountId>,
ForeignAssetsPalletInstance: 'static,
AssetId: Clone + Copy,
AssetIdConverter: Convert<MultiLocation, AssetId>,
AssetIdConverter: MaybeEquivalence<MultiLocation, AssetId>,
{
// foreign parachain with the same consenus currency as asset
let foreign_asset_id_multilocation =
MultiLocation { parents: 1, interior: X2(Parachain(2222), GeneralIndex(1234567)) };
let asset_id = AssetIdConverter::convert(foreign_asset_id_multilocation).unwrap();
let asset_id = AssetIdConverter::convert(&foreign_asset_id_multilocation).unwrap();
// foreign creator, which can be sibling parachain to match ForeignCreators
let foreign_creator = MultiLocation { parents: 1, interior: X1(Parachain(2222)) };
let foreign_creator_as_account_id = SovereignAccountOf::convert(foreign_creator).expect("");
let foreign_creator_as_account_id =
SovereignAccountOf::convert_location(&foreign_creator).expect("");
// we want to buy execution with local relay chain currency
let buy_execution_fee_amount =
@@ -1204,7 +1206,7 @@ pub fn create_and_manage_foreign_assets_for_local_consensus_parachain_assets_wor
// lets try create asset for different parachain(3333) (foreign_creator(2222) can create just his assets)
let foreign_asset_id_multilocation =
MultiLocation { parents: 1, interior: X2(Parachain(3333), GeneralIndex(1234567)) };
let asset_id = AssetIdConverter::convert(foreign_asset_id_multilocation).unwrap();
let asset_id = AssetIdConverter::convert(&foreign_asset_id_multilocation).unwrap();
// prepare data for xcm::Transact(create)
let foreign_asset_create = runtime_call_encode(pallet_assets::Call::<