Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
272c31d
Introduce XcmFeesToAccount fee manager
KiChjang Apr 4, 2023
13f5944
Fixes
KiChjang Apr 4, 2023
3d0cfde
Fixes
KiChjang Apr 4, 2023
c28700d
Put system parachain IDs into consts
KiChjang Apr 4, 2023
d5b760b
Fixes
KiChjang Apr 4, 2023
a2d3604
Remove XcmFeesToAccount config for Westend
KiChjang Apr 4, 2023
7e99987
Include Encointer as a system parachain
KiChjang Apr 4, 2023
04d4410
Emit warning when deposit_asset fails
KiChjang Apr 5, 2023
5d6e2c2
Add comment on what happens when deposit_asset errors
KiChjang Apr 5, 2023
7e4cc0a
Fixes
KiChjang Apr 5, 2023
17c0f5c
Move SystemParachains to constants
KiChjang Apr 6, 2023
12b816e
Fixes
KiChjang Apr 6, 2023
d22046f
Fixes
KiChjang Apr 6, 2023
6c9f3f9
cargo fmt
KiChjang Apr 7, 2023
424c903
Added BridgeHubs constants (#7053)
bkontur Apr 12, 2023
7b140f0
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
KiChjang Apr 13, 2023
a852957
Add SystemParachain type to Westmint
KiChjang Apr 13, 2023
e1b6af0
Fixes
KiChjang Apr 20, 2023
20b4f66
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
KiChjang Apr 20, 2023
09828da
Fixes
KiChjang Apr 24, 2023
0e06f73
Waive fee handling during benchmarking
KiChjang Apr 28, 2023
6a4fd76
Fixes
KiChjang Apr 28, 2023
6eccb05
Fixes
KiChjang Apr 28, 2023
2df8cbf
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
KiChjang Apr 28, 2023
de0e397
Rename to ASSET_HUB_ID
KiChjang Jun 22, 2023
8bb8fb9
Rename all asset parachains to AssetHub
KiChjang Jun 22, 2023
3ea877f
Merge branch 'master' into kckyeung/xcm-fee-manager
KiChjang Jun 22, 2023
4843e58
Fix typo
KiChjang Jun 22, 2023
7c3bb1a
".git/.scripts/commands/fmt/fmt.sh"
Jun 22, 2023
50a008e
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
Jul 4, 2023
76a4cd0
Merge branch 'master' into kckyeung/xcm-fee-manager
KiChjang Aug 2, 2023
7d61d2e
Fixes
KiChjang Aug 2, 2023
18945f8
Fixes
KiChjang Aug 2, 2023
6f4a8bb
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
KiChjang Aug 3, 2023
4fa5016
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
Aug 8, 2023
88b9582
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
Aug 13, 2023
2c7d14c
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
Aug 15, 2023
57b3a6d
Merge remote-tracking branch 'origin/master' into kckyeung/xcm-fee-ma…
Aug 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions runtime/kusama/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ pub mod fee {
}
}

/// System Parachains.
pub mod system_parachain {
/// Statemine parachain ID.
pub const STATEMINE_ID: u32 = 1000;
}

#[cfg(test)]
mod tests {
use super::{
Expand Down
16 changes: 11 additions & 5 deletions runtime/kusama/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

use super::{
parachains_origin, AccountId, AllPalletsWithSystem, Balances, Fellows, ParaId, Runtime,
RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, WeightToFee, XcmPallet,
RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin, Treasury, WeightToFee, XcmPallet,
};
use frame_support::{
match_types, parameter_types,
traits::{Contains, Everything, Nothing},
weights::Weight,
};
use frame_system::EnsureRoot;
use kusama_runtime_constants::system_parachain::*;
use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor};
use sp_core::ConstU32;
use xcm::latest::prelude::*;
Expand All @@ -36,7 +37,7 @@ use xcm_builder::{
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative, SignedToAccountId32,
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
WithComputedOrigin,
WithComputedOrigin, XcmFeesToAccount,
};
use xcm_executor::traits::WithOriginFilter;

Expand All @@ -55,6 +56,8 @@ parameter_types! {
pub CheckAccount: AccountId = XcmPallet::check_account();
/// The check account that is allowed to mint assets locally.
pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
/// The treasury account where XCM fees would be sent to.
pub TreasuryAccount: Option<AccountId> = Some(Treasury::account_id());
}

/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine
Expand Down Expand Up @@ -112,7 +115,7 @@ pub type XcmRouter = (

parameter_types! {
pub const Ksm: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
pub const Statemine: MultiLocation = Parachain(1000).into_location();
pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location();
pub const Encointer: MultiLocation = Parachain(1001).into_location();
pub const KsmForStatemine: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Statemine::get());
pub const KsmForEncointer: (MultiAssetFilter, MultiLocation) = (Ksm::get(), Encointer::get());
Expand All @@ -125,6 +128,9 @@ match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID)) }
};
}

/// The barriers one of which must be passed for an XCM message to be executed.
Expand Down Expand Up @@ -335,7 +341,7 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = XcmPallet;
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type FeeManager = ();
type FeeManager = XcmFeesToAccount<Self, SystemParachains, AccountId, TreasuryAccount>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this change () -> XcmFeesToAccount
Is there any change or consequence for non-system parachains or end users?
I mean, is there anything which will start failing after this is upgraded on-live?
Something like: non-system parachain should drip their sovereign account on relay chain?
If so, maybe should be part of release notes or something like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be -- with or without a FeeManager, we've still been collecting fees, the only difference here is that previously we were just burning them after collecting them, but with this change, we simply deposit them to the treasury account.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actual impl FeeManager for () here behaves as everything is waived now,
so, iiuc charge_fees and takes_fee they never do AssetTransactor::withdraw_asset, but now with XcmFeesToAccount they will do AssetTransactor::withdraw_asset,

so I think this is the change, that origin needs to have some balance > ED + fees, but I dont know how much this is a really issue. I can imaging just some scenarios/calls from some non-system parachain that does not have sovereign account with balance on relay chain, so after this change they will need to drip some DOTs/KSMs to pass

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, so I just took a look at where we collect fees in the XCM executor: it looks like any instruction where it creates and sends an XCM back to the origin would require the origin to pay for fees, and this includes the Query* instructions, the Report* instructions, the ExportMessage instruction and most of the cross-chain asset transfer instructions (e.g. InitiateTeleport).

This isn't a huge deal, I think what we do need to do is to display delivery fees in the UI clearly so that users are informed about how much they need to pay, otherwise their XCM would fail to be sent.

// No bridges yet...
type MessageExporter = ();
type UniversalAliases = Nothing;
Expand All @@ -352,7 +358,7 @@ parameter_types! {

#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
pub ReachableDest: Option<MultiLocation> = Some(Parachain(STATEMINE_ID).into());
}

/// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location
Expand Down
11 changes: 8 additions & 3 deletions runtime/polkadot/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use super::{
parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective,
FellowshipAdmin, ParaId, Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, StakingAdmin,
WeightToFee, XcmPallet,
Treasury, WeightToFee, XcmPallet,
};
use frame_support::{
match_types, parameter_types,
Expand All @@ -38,7 +38,7 @@ use xcm_builder::{
ChildParachainAsNative, ChildParachainConvertsVia, CurrencyAdapter as XcmCurrencyAdapter,
FixedWeightBounds, IsConcrete, MintLocation, OriginToPluralityVoice, SignedAccountId32AsNative,
SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,
WithComputedOrigin,
WithComputedOrigin, XcmFeesToAccount,
};
use xcm_executor::traits::WithOriginFilter;

Expand All @@ -55,6 +55,8 @@ parameter_types! {
pub CheckAccount: AccountId = XcmPallet::check_account();
/// The Checking Account along with the indication that the local chain is able to mint tokens.
pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
/// The treasury account where XCM fees would be sent to.
pub TreasuryAccount: Option<AccountId> = Some(Treasury::account_id());
}

/// The canonical means of converting a `MultiLocation` into an `AccountId`, used when we want to determine
Expand Down Expand Up @@ -135,6 +137,9 @@ match_types! {
MultiLocation { parents: 0, interior: X1(Parachain(COLLECTIVES_ID)) } |
MultiLocation { parents: 0, interior: X2(Parachain(COLLECTIVES_ID), Plurality { id: BodyId::Technical, .. }) }
};
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(STATEMINT_ID | COLLECTIVES_ID)) }
};
}

/// The barriers one of which must be passed for an XCM message to be executed.
Expand Down Expand Up @@ -354,7 +359,7 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = XcmPallet;
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type FeeManager = ();
type FeeManager = XcmFeesToAccount<Self, SystemParachains, AccountId, TreasuryAccount>;
// No bridges yet...
type MessageExporter = ();
type UniversalAliases = Nothing;
Expand Down
8 changes: 8 additions & 0 deletions runtime/rococo/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ pub mod fee {
}
}

/// System Parachains.
pub mod system_parachain {
/// Statemine parachain ID.
pub const STATEMINE_ID: u32 = 1000;
/// Contracts parachain ID.
pub const CONTRACTS_ID: u32 = 1002;
}

#[cfg(test)]
mod tests {
use super::{
Expand Down
17 changes: 11 additions & 6 deletions runtime/rococo/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

use super::{
parachains_origin, AccountId, AllPalletsWithSystem, Balances, CouncilCollective, ParaId,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmPallet,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, Treasury, WeightToFee, XcmPallet,
};
use frame_support::{
match_types, parameter_types,
traits::{Contains, Everything, Nothing},
weights::Weight,
};
use frame_system::EnsureRoot;
use rococo_runtime_constants::system_parachain::*;
use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor};
use sp_core::ConstU32;
use xcm::latest::prelude::*;
Expand All @@ -35,7 +36,7 @@ use xcm_builder::{
ChildParachainAsNative, ChildParachainConvertsVia, ChildSystemParachainAsSuperuser,
CurrencyAdapter as XcmCurrencyAdapter, FixedWeightBounds, IsChildSystemParachain, IsConcrete,
MintLocation, SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation,
TakeWeightCredit, UsingComponents, WeightInfoBounds, WithComputedOrigin,
TakeWeightCredit, UsingComponents, WeightInfoBounds, WithComputedOrigin, XcmFeesToAccount,
};
use xcm_executor::{traits::WithOriginFilter, XcmExecutor};

Expand All @@ -45,6 +46,7 @@ parameter_types! {
pub UniversalLocation: InteriorMultiLocation = ThisNetwork::get().into();
pub CheckAccount: AccountId = XcmPallet::check_account();
pub LocalCheckAccount: (AccountId, MintLocation) = (CheckAccount::get(), MintLocation::Local);
pub TreasuryAccount: Option<AccountId> = Some(Treasury::account_id());
}

pub type LocationConverter =
Expand Down Expand Up @@ -92,8 +94,8 @@ pub type XcmRouter = (

parameter_types! {
pub const Roc: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
pub const Statemine: MultiLocation = Parachain(1000).into_location();
pub const Contracts: MultiLocation = Parachain(1002).into_location();
pub const Statemine: MultiLocation = Parachain(STATEMINE_ID).into_location();
pub const Contracts: MultiLocation = Parachain(CONTRACTS_ID).into_location();
pub const Encointer: MultiLocation = Parachain(1003).into_location();
pub const Tick: MultiLocation = Parachain(100).into_location();
pub const Trick: MultiLocation = Parachain(110).into_location();
Expand All @@ -120,6 +122,9 @@ match_types! {
pub type OnlyParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(_)) }
};
pub type SystemParachains: impl Contains<MultiLocation> = {
MultiLocation { parents: 0, interior: X1(Parachain(STATEMINE_ID | CONTRACTS_ID)) }
};
}

/// The barriers one of which must be passed for an XCM message to be executed.
Expand Down Expand Up @@ -313,7 +318,7 @@ impl xcm_executor::Config for XcmConfig {
type SubscriptionService = XcmPallet;
type PalletInstancesInfo = AllPalletsWithSystem;
type MaxAssetsIntoHolding = MaxAssetsIntoHolding;
type FeeManager = ();
type FeeManager = XcmFeesToAccount<Self, SystemParachains, AccountId, TreasuryAccount>;
type MessageExporter = ();
type UniversalAliases = Nothing;
type CallDispatcher = WithOriginFilter<SafeCallFilter>;
Expand All @@ -330,7 +335,7 @@ parameter_types! {

#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
pub ReachableDest: Option<MultiLocation> = Some(Parachain(STATEMINE_ID).into());
}

/// Type to convert the council origin to a Plurality `MultiLocation` value.
Expand Down
8 changes: 8 additions & 0 deletions runtime/westend/constants/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ pub mod fee {
}
}

/// System Parachains.
pub mod system_parachain {
/// Westmint parachain ID.
pub const WESTMINT_ID: u32 = 1000;
/// Collectives parachain ID.
pub const COLLECTIVES_ID: u32 = 1001;
}

#[cfg(test)]
mod tests {
use super::{
Expand Down
7 changes: 4 additions & 3 deletions runtime/westend/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use frame_support::{
use frame_system::EnsureRoot;
use runtime_common::{crowdloan, paras_registrar, xcm_sender, ToAuthor};
use sp_core::ConstU32;
use westend_runtime_constants::system_parachain::*;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
Expand Down Expand Up @@ -77,8 +78,8 @@ pub type XcmRouter = (
);

parameter_types! {
pub const Westmint: MultiLocation = Parachain(1000).into_location();
pub const Collectives: MultiLocation = Parachain(1001).into_location();
pub const Westmint: MultiLocation = Parachain(WESTMINT_ID).into_location();
pub const Collectives: MultiLocation = Parachain(COLLECTIVES_ID).into_location();
pub const Wnd: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(TokenLocation::get()) });
pub const WndForWestmint: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Westmint::get());
pub const WndForCollectives: (MultiAssetFilter, MultiLocation) = (Wnd::get(), Collectives::get());
Expand All @@ -88,7 +89,7 @@ parameter_types! {

#[cfg(feature = "runtime-benchmarks")]
parameter_types! {
pub ReachableDest: Option<MultiLocation> = Some(Parachain(1000).into());
pub ReachableDest: Option<MultiLocation> = Some(Parachain(WESTMINT_ID).into());
}

pub type TrustedTeleporters =
Expand Down
30 changes: 3 additions & 27 deletions xcm/pallet-xcm-benchmarks/src/fungible/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,7 @@ benchmarks_instance_pallet! {
let worst_case_holding = T::worst_case_holding(0);
let asset = T::get_multi_asset();

<AssetTransactorOf<T>>::deposit_asset(
&asset,
&sender_location,
&XcmContext {
origin: Some(sender_location.clone()),
message_hash: [0; 32],
topic: None,
},
).unwrap();
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
// check the assets of origin.
assert!(!T::TransactAsset::balance(&sender_account).is_zero());

Expand All @@ -77,15 +69,7 @@ benchmarks_instance_pallet! {
let dest_location = T::valid_destination()?;
let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap();

<AssetTransactorOf<T>>::deposit_asset(
&asset,
&sender_location,
&XcmContext {
origin: Some(sender_location.clone()),
message_hash: [0; 32],
topic: None,
},
).unwrap();
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
assert!(T::TransactAsset::balance(&dest_account).is_zero());

let mut executor = new_executor::<T>(sender_location);
Expand All @@ -104,15 +88,7 @@ benchmarks_instance_pallet! {
let dest_account = T::AccountIdConverter::convert(dest_location.clone()).unwrap();

let asset = T::get_multi_asset();
<AssetTransactorOf<T>>::deposit_asset(
&asset,
&sender_location,
&XcmContext {
origin: Some(sender_location.clone()),
message_hash: [0; 32],
topic: None,
},
).unwrap();
<AssetTransactorOf<T>>::deposit_asset(&asset, &sender_location, None).unwrap();
let assets: MultiAssets = vec![ asset ].into();
assert!(T::TransactAsset::balance(&dest_account).is_zero());

Expand Down
6 changes: 5 additions & 1 deletion xcm/pallet-xcm-benchmarks/src/generic/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,11 @@ impl frame_system::Config for Test {
/// The benchmarks in this pallet should never need an asset transactor to begin with.
pub struct NoAssetTransactor;
impl xcm_executor::traits::TransactAsset for NoAssetTransactor {
fn deposit_asset(_: &MultiAsset, _: &MultiLocation, _: &XcmContext) -> Result<(), XcmError> {
fn deposit_asset(
_: &MultiAsset,
_: &MultiLocation,
_: Option<&XcmContext>,
) -> Result<(), XcmError> {
unreachable!();
}

Expand Down
6 changes: 5 additions & 1 deletion xcm/xcm-builder/src/currency_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ impl<
}
}

fn deposit_asset(what: &MultiAsset, who: &MultiLocation, _context: &XcmContext) -> Result {
fn deposit_asset(
what: &MultiAsset,
who: &MultiLocation,
_context: Option<&XcmContext>,
) -> Result {
log::trace!(target: "xcm::currency_adapter", "deposit_asset what: {:?}, who: {:?}", what, who);
// Check we handle this asset.
let amount = Matcher::matches_fungible(&what).ok_or(Error::AssetNotHandled)?;
Expand Down
51 changes: 51 additions & 0 deletions xcm/xcm-builder/src/fee_handling.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use core::marker::PhantomData;
use frame_support::traits::{Contains, Get};
use xcm::prelude::*;
use xcm_executor::traits::{FeeManager, FeeReason, TransactAsset};

/// A `FeeManager` implementation that simply deposits the fees handled into a specific on-chain
/// `ReceiverAccount`.
///
/// It reuses the `AssetTransactor` configured on the XCM executor to deposit fee assets, and also
/// permits specifying `WaivedLocations` for locations that are privileged to not pay for fees.
pub struct XcmFeesToAccount<XcmConfig, WaivedLocations, AccountId, ReceiverAccount>(
PhantomData<(XcmConfig, WaivedLocations, AccountId, ReceiverAccount)>,
);
impl<
XcmConfig: xcm_executor::Config,
WaivedLocations: Contains<MultiLocation>,
AccountId: Clone + Into<[u8; 32]>,
ReceiverAccount: Get<Option<AccountId>>,
> FeeManager for XcmFeesToAccount<XcmConfig, WaivedLocations, AccountId, ReceiverAccount>
{
fn is_waived(origin: Option<&MultiLocation>, _: FeeReason) -> bool {
let Some(loc) = origin else { return false };
WaivedLocations::contains(loc)
}

fn handle_fee(fees: MultiAssets, context: Option<&XcmContext>) {
if let Some(receiver) = ReceiverAccount::get() {
let dest = AccountId32 { network: None, id: receiver.into() }.into();
for asset in fees.into_inner() {
let ok = XcmConfig::AssetTransactor::deposit_asset(&asset, &dest, context).is_ok();
debug_assert!(ok, "`deposit_asset` cannot generally fail");
}
}
}
}
Loading