Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
9 changes: 5 additions & 4 deletions polkadot/xcm/xcm-builder/src/fee_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use core::marker::PhantomData;
use frame_support::traits::{Contains, Get};
use xcm::prelude::*;
use xcm_executor::traits::{FeeManager, FeeReason, TransactAsset};
use xcm_executor::traits::{FeeManager, FeeReason, IntoLocation, TransactAsset};

/// Handles the fees that are taken by certain XCM instructions.
pub trait HandleFee {
Expand Down Expand Up @@ -70,12 +70,13 @@ impl<WaivedLocations: Contains<Location>, FeeHandler: HandleFee> FeeManager

/// Try to deposit the given fee in the specified account.
/// Burns the fee in case of a failure.
pub fn deposit_or_burn_fee<AssetTransactor: TransactAsset, AccountId: Clone + Into<[u8; 32]>>(
pub fn deposit_or_burn_fee<AssetTransactor: TransactAsset, AccountId: Clone + IntoLocation>(
fee: Assets,
context: Option<&XcmContext>,
receiver: AccountId,
) {
let dest = AccountId32 { network: None, id: receiver.into() }.into();
// let dest = AccountId32 { network: None, id: receiver.into() }.into();
let dest = receiver.into_location();
for asset in fee.into_inner() {
if let Err(e) = AssetTransactor::deposit_asset(&asset, &dest, context) {
log::trace!(
Expand All @@ -100,7 +101,7 @@ pub struct XcmFeeToAccount<AssetTransactor, AccountId, ReceiverAccount>(

impl<
AssetTransactor: TransactAsset,
AccountId: Clone + Into<[u8; 32]>,
AccountId: Clone + IntoLocation,
Comment thread
ozgunozerk marked this conversation as resolved.
Outdated
ReceiverAccount: Get<AccountId>,
> HandleFee for XcmFeeToAccount<AssetTransactor, AccountId, ReceiverAccount>
{
Expand Down
12 changes: 11 additions & 1 deletion polkadot/xcm/xcm-executor/src/traits/conversion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use frame_support::traits::{Contains, OriginTrait};
use sp_runtime::{traits::Dispatchable, DispatchErrorWithPostInfo};
use sp_runtime::{traits::Dispatchable, AccountId32, DispatchErrorWithPostInfo};
use sp_std::{marker::PhantomData, result::Result};
use xcm::latest::prelude::*;

Expand Down Expand Up @@ -145,3 +145,13 @@ impl<Call: Dispatchable> CallDispatcher<Call> for Call {
call.dispatch(origin)
}
}

pub trait IntoLocation {
fn into_location(self) -> Location;
}

impl IntoLocation for AccountId32 {
fn into_location(self) -> Location {
xcm::v4::Junction::AccountId32 { network: None, id: self.into() }.into()
}
}
4 changes: 3 additions & 1 deletion polkadot/xcm/xcm-executor/src/traits/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
//! Various traits used in configuring the executor.

mod conversion;
pub use conversion::{CallDispatcher, ConvertLocation, ConvertOrigin, WithOriginFilter};
pub use conversion::{
CallDispatcher, ConvertLocation, ConvertOrigin, IntoLocation, WithOriginFilter,
};
mod drop_assets;
pub use drop_assets::{ClaimAssets, DropAssets};
mod asset_exchange;
Expand Down