--- a/runtime/common/config/xcm/foreignassets.rs +++ b/runtime/common/config/xcm/foreignassets.rs @@ -15,13 +15,13 @@ // along with Unique Network. If not, see . use frame_support::{ - traits::{Contains, Get, fungibles, ContainsPair}, + traits::{Get, ContainsPair}, parameter_types, }; use sp_runtime::traits::Convert; -use xcm::latest::{MultiAsset, Junction::*, MultiLocation, Junctions::*}; -use xcm_builder::{FungiblesAdapter, NonLocalMint, ConvertedConcreteId}; -use xcm_executor::traits::{Convert as ConvertXcm, JustTry}; +use xcm::latest::{prelude::*, MultiAsset, MultiLocation}; +use xcm_builder::{FungiblesAdapter, NoChecking, ConvertedConcreteId}; +use xcm_executor::traits::{TransactAsset, Convert as ConvertXcm, JustTry}; use pallet_foreign_assets::{ AssetIds, AssetIdMapping, XcmForeignAssetIdMapping, NativeCurrency, FreeForAll, TryAsForeign, ForeignAssetId, CurrencyId, @@ -36,20 +36,7 @@ parameter_types! { pub CheckingAccount: AccountId = PolkadotXcm::check_account(); } - -/// No teleports are allowed -pub struct NoTeleports(PhantomData<(AccountId, ForeignAssets)>); -impl Contains<>::AssetId> - for NoTeleports -where - ForeignAssets: fungibles::Inspect, -{ - fn contains(_id: &>::AssetId) -> bool { - false - } -} - pub struct AsInnerId(PhantomData<(AssetId, ConvertAssetId)>); impl> ConvertXcm for AsInnerId @@ -131,14 +118,56 @@ LocationToAccountId, // Our chain's account ID type (we can't get away without mentioning it explicitly): AccountId, - // No teleports are allowed - NonLocalMint>, + // No Checking for teleported assets since we disallow teleports at all. + NoChecking, // The account to use for tracking teleports. CheckingAccount, >; /// Means for transacting assets on this chain. -pub type AssetTransactors = FungiblesTransactor; +pub struct AssetTransactor; +impl TransactAsset for AssetTransactor { + fn can_check_in( + _origin: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { + Err(XcmError::Unimplemented) + } + + fn check_in(_origin: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {} + + fn can_check_out( + _dest: &MultiLocation, + _what: &MultiAsset, + _context: &XcmContext, + ) -> XcmResult { + Err(XcmError::Unimplemented) + } + + fn check_out(_dest: &MultiLocation, _what: &MultiAsset, _context: &XcmContext) {} + + fn deposit_asset(what: &MultiAsset, who: &MultiLocation, context: &XcmContext) -> XcmResult { + FungiblesTransactor::deposit_asset(what, who, context) + } + + fn withdraw_asset( + what: &MultiAsset, + who: &MultiLocation, + maybe_context: Option<&XcmContext>, + ) -> Result { + FungiblesTransactor::withdraw_asset(what, who, maybe_context) + } + + fn internal_transfer_asset( + what: &MultiAsset, + from: &MultiLocation, + to: &MultiLocation, + context: &XcmContext, + ) -> Result { + FungiblesTransactor::internal_transfer_asset(what, from, to, context) + } +} pub struct AllAsset; impl ContainsPair for AllAsset { --- a/runtime/common/config/xcm/mod.rs +++ b/runtime/common/config/xcm/mod.rs @@ -49,7 +49,7 @@ #[cfg(not(feature = "foreign-assets"))] pub use nativeassets as xcm_assets; -use xcm_assets::{AssetTransactors, IsReserve, Trader}; +use xcm_assets::{AssetTransactor, IsReserve, Trader}; parameter_types! { pub const RelayLocation: MultiLocation = MultiLocation::parent(); @@ -213,7 +213,7 @@ type RuntimeCall = RuntimeCall; type XcmSender = XcmRouter; // How to withdraw and deposit an asset. - type AssetTransactor = AssetTransactors; + type AssetTransactor = AssetTransactor; type OriginConverter = XcmOriginToTransactDispatchOrigin; type IsReserve = IsReserve; type IsTeleporter = (); // Teleportation is disabled --- a/runtime/common/config/xcm/nativeassets.rs +++ b/runtime/common/config/xcm/nativeassets.rs @@ -77,7 +77,7 @@ (), >; -pub type AssetTransactors = LocalAssetTransactor; +pub type AssetTransactor = LocalAssetTransactor; pub type IsReserve = NativeAsset;