difftreelog
fix disallow xcm teleports completely
in: master
3 files changed
runtime/common/config/xcm/foreignassets.rsdiffbeforeafterboth--- 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 <http://www.gnu.org/licenses/>.
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<AccountId, ForeignAssets>(PhantomData<(AccountId, ForeignAssets)>);
-impl<AccountId, ForeignAssets> Contains<<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId>
- for NoTeleports<AccountId, ForeignAssets>
-where
- ForeignAssets: fungibles::Inspect<AccountId>,
-{
- fn contains(_id: &<ForeignAssets as fungibles::Inspect<AccountId>>::AssetId) -> bool {
- false
- }
-}
-
pub struct AsInnerId<AssetId, ConvertAssetId>(PhantomData<(AssetId, ConvertAssetId)>);
impl<AssetId: Clone + PartialEq, ConvertAssetId: ConvertXcm<AssetId, AssetId>>
ConvertXcm<MultiLocation, AssetId> for AsInnerId<AssetId, ConvertAssetId>
@@ -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<NoTeleports<AccountId, ForeignAssets>>,
+ // 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<xcm_executor::Assets, XcmError> {
+ FungiblesTransactor::withdraw_asset(what, who, maybe_context)
+ }
+
+ fn internal_transfer_asset(
+ what: &MultiAsset,
+ from: &MultiLocation,
+ to: &MultiLocation,
+ context: &XcmContext,
+ ) -> Result<xcm_executor::Assets, XcmError> {
+ FungiblesTransactor::internal_transfer_asset(what, from, to, context)
+ }
+}
pub struct AllAsset;
impl 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.rsdiffbeforeafterboth--- 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;