// Copyright 2021 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 . use frame_support::{parameter_types, traits::Everything, weights::Weight}; use xcm::latest::{ Error as XcmError, Junctions::Here, MultiAsset, MultiLocation, NetworkId, Parent, Result as XcmResult, SendXcm, Xcm, }; use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32}; use xcm_executor::{ traits::{InvertLocation, TransactAsset, WeightTrader}, Assets, }; parameter_types! { pub const OurNetwork: NetworkId = NetworkId::Polkadot; } /// Type to convert an `Origin` type value into a `MultiLocation` value which represents an interior location /// of this chain. pub type LocalOriginToLocation = ( // And a usual Signed origin to be used in XCM as a corresponding AccountId32 SignedToAccountId32, ); pub struct DoNothingRouter; impl SendXcm for DoNothingRouter { fn send_xcm(_dest: MultiLocation, _msg: Xcm<()>) -> XcmResult { Ok(()) } } pub type Barrier = AllowUnpaidExecutionFrom; pub struct DummyAssetTransactor; impl TransactAsset for DummyAssetTransactor { fn deposit_asset(_what: &MultiAsset, _who: &MultiLocation) -> XcmResult { Ok(()) } fn withdraw_asset(_what: &MultiAsset, _who: &MultiLocation) -> Result { let asset: MultiAsset = (Parent, 100_000).into(); Ok(asset.into()) } } pub struct DummyWeightTrader; impl WeightTrader for DummyWeightTrader { fn new() -> Self { DummyWeightTrader } fn buy_weight(&mut self, _weight: Weight, _payment: Assets) -> Result { Ok(Assets::default()) } } pub struct InvertNothing; impl InvertLocation for InvertNothing { fn invert_location(_: &MultiLocation) -> MultiLocation { Here.into() } } pub struct XcmConfig; impl xcm_executor::Config for XcmConfig { type Call = super::Call; type XcmSender = DoNothingRouter; type AssetTransactor = DummyAssetTransactor; type OriginConverter = pallet_xcm::XcmPassthrough; type IsReserve = (); type IsTeleporter = (); type LocationInverter = InvertNothing; type Barrier = Barrier; type Weigher = FixedWeightBounds; type Trader = DummyWeightTrader; type ResponseHandler = (); }