difftreelog
fix disallow xcm teleports completely
in: master
3 files changed
runtime/common/config/xcm/foreignassets.rsdiffbeforeafterboth15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use frame_support::{17use frame_support::{18 traits::{Contains, Get, fungibles, ContainsPair},18 traits::{Get, ContainsPair},19 parameter_types,19 parameter_types,20};20};21use sp_runtime::traits::Convert;21use sp_runtime::traits::Convert;22use xcm::latest::{MultiAsset, Junction::*, MultiLocation, Junctions::*};22use xcm::latest::{prelude::*, MultiAsset, MultiLocation};23use xcm_builder::{FungiblesAdapter, NonLocalMint, ConvertedConcreteId};23use xcm_builder::{FungiblesAdapter, NoChecking, ConvertedConcreteId};24use xcm_executor::traits::{Convert as ConvertXcm, JustTry};24use xcm_executor::traits::{TransactAsset, Convert as ConvertXcm, JustTry};25use pallet_foreign_assets::{25use pallet_foreign_assets::{26 AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, NativeCurrency, FreeForAll, TryAsForeign,26 AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, NativeCurrency, FreeForAll, TryAsForeign,27 ForeignAssetId, CurrencyId,27 ForeignAssetId, CurrencyId,37 pub CheckingAccount: AccountId = PolkadotXcm::check_account();37 pub CheckingAccount: AccountId = PolkadotXcm::check_account();38}38}3940/// No teleports are allowed41pub struct NoTeleports<AccountId, ForeignAssets>(PhantomData<(AccountId, ForeignAssets)>);4243impl<AccountId, ForeignAssets> Contains<<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId>44 for NoTeleports<AccountId, ForeignAssets>45where46 ForeignAssets: fungibles::Inspect<AccountId>,47{48 fn contains(_id: &<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {49 false50 }51}523953pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);40pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);54impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>41impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>131 LocationToAccountId,118 LocationToAccountId,132 // Our chain's account ID type (we can't get away without mentioning it explicitly):119 // Our chain's account ID type (we can't get away without mentioning it explicitly):133 AccountId,120 AccountId,134 // No teleports are allowed121 // No Checking for teleported assets since we disallow teleports at all.135 NonLocalMint<NoTeleports<AccountId, ForeignAssets>>,122 NoChecking,136 // The account to use for tracking teleports.123 // The account to use for tracking teleports.137 CheckingAccount,124 CheckingAccount,138>;125>;139126140/// Means for transacting assets on this chain.127/// Means for transacting assets on this chain.141pub type AssetTransactors = FungiblesTransactor;128pub struct AssetTransactor;129impl TransactAsset for AssetTransactor {130 fn can_check_in(131 _origin: &MultiLocation,132 _what: &MultiAsset,133 _context: &XcmContext,134 ) -> XcmResult {135 Err(XcmError::Unimplemented)136 }137138 fn check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {}139140 fn can_check_out(141 _dest: &MultiLocation,142 _what: &MultiAsset,143 _context: &XcmContext,144 ) -> XcmResult {145 Err(XcmError::Unimplemented)146 }147148 fn check_out(_dest: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {}149150 fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult {151 FungiblesTransactor::deposit_asset(what, who, context)152 }153154 fn withdraw_asset(155 what: &MultiAsset,156 who: &MultiLocation,157 maybe_context: Option<&XcmContext>,158 ) -> Result<xcm_executor::Assets, XcmError> {159 FungiblesTransactor::withdraw_asset(what, who, maybe_context)160 }161162 fn internal_transfer_asset(163 what: &MultiAsset,164 from: &MultiLocation,165 to: &MultiLocation,166 context: &XcmContext,167 ) -> Result<xcm_executor::Assets, XcmError> {168 FungiblesTransactor::internal_transfer_asset(what, from, to, context)169 }170}142171143pub struct AllAsset;172pub struct AllAsset;144impl ContainsPair<MultiAsset, MultiLocation> for AllAsset {173impl ContainsPair<MultiAsset, MultiLocation> for AllAsset {runtime/common/config/xcm/mod.rsdiffbeforeafterboth49#[cfg(not(feature = "foreign-assets"))]49#[cfg(not(feature = "foreign-assets"))]50pub use nativeassets as xcm_assets;50pub use nativeassets as xcm_assets;515152use xcm_assets::{AssetTransactors, IsReserve, Trader};52use xcm_assets::{AssetTransactor, IsReserve, Trader};535354parameter_types! {54parameter_types! {55 pub const RelayLocation: MultiLocation = MultiLocation::parent();55 pub const RelayLocation: MultiLocation = MultiLocation::parent();213 type RuntimeCall = RuntimeCall;213 type RuntimeCall = RuntimeCall;214 type XcmSender = XcmRouter;214 type XcmSender = XcmRouter;215 // How to withdraw and deposit an asset.215 // How to withdraw and deposit an asset.216 type AssetTransactor = AssetTransactors;216 type AssetTransactor = AssetTransactor;217 type OriginConverter = XcmOriginToTransactDispatchOrigin;217 type OriginConverter = XcmOriginToTransactDispatchOrigin;218 type IsReserve = IsReserve;218 type IsReserve = IsReserve;219 type IsTeleporter = (); // Teleportation is disabled219 type IsTeleporter = (); // Teleportation is disabledruntime/common/config/xcm/nativeassets.rsdiffbeforeafterboth77 (),77 (),78>;78>;797980pub type AssetTransactors = LocalAssetTransactor;80pub type AssetTransactor = LocalAssetTransactor;818182pub type IsReserve = NativeAsset;82pub type IsReserve = NativeAsset;8383