Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/1208490634321836 is reserve #296

Merged
merged 2 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
32 changes: 3 additions & 29 deletions runtime/krest/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use crate::{PeaqAssetLocationIdConverter, Treasury};
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::{
parameter_types,
traits::{fungibles, Contains, ContainsPair, Everything, Nothing, TransformOrigin},
traits::{fungibles, Contains, Everything, Nothing, TransformOrigin},
};
use frame_system::EnsureRoot;
use orml_traits::location::{RelativeReserveProvider, Reserve};
use orml_xcm_support::DisabledParachainFee;
use orml_xcm_support::{DisabledParachainFee, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use parachains_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
Expand Down Expand Up @@ -266,32 +266,6 @@ pub type Barrier = TrailingSetTopicAsId<(
>,
)>;

/// Used to determine whether the cross-chain asset is coming from a trusted reserve or not
///
/// Basically, we trust any cross-chain asset from any location to act as a reserve since
/// in order to support the xc-asset, we need to first register it in the `XcAssetConfig` pallet.
pub struct ReserveAssetFilter;
impl ContainsPair<Asset, Location> for ReserveAssetFilter {
fn contains(asset: &Asset, origin: &Location) -> bool {
// We assume that relay chain and sibling parachain assets are trusted reserves for their
// assets
let AssetId(location) = &asset.id;
let reserve_location = match (location.parents, location.first_interior()) {
// sibling parachain
(1, Some(Parachain(id))) => Some(Location::new(1, [Parachain(*id)])),
// relay chain
(1, _) => Some(Location::parent()),
_ => None,
};

if let Some(ref reserve) = reserve_location {
origin == reserve
} else {
false
}
}
}

pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;

pub struct XcmConfig;
Expand All @@ -302,7 +276,7 @@ impl xcm_executor::Config for XcmConfig {
type XcmSender = XcmRouter;
type AssetTransactor = AssetTransactors;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = ReserveAssetFilter;
type IsReserve = MultiNativeAsset<AbsoluteAndRelativeReserveProvider<PeaqLocationAbsolute>>;
// type IsReserve = Everything;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
Expand Down
32 changes: 3 additions & 29 deletions runtime/peaq-dev/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use crate::{PeaqAssetLocationIdConverter, Treasury};
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::{
parameter_types,
traits::{fungibles, Contains, ContainsPair, Everything, Nothing, TransformOrigin},
traits::{fungibles, Contains, Everything, Nothing, TransformOrigin},
};
use frame_system::EnsureRoot;
use orml_traits::location::{RelativeReserveProvider, Reserve};
use orml_xcm_support::DisabledParachainFee;
use orml_xcm_support::{DisabledParachainFee, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use parachains_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
Expand Down Expand Up @@ -266,32 +266,6 @@ pub type Barrier = TrailingSetTopicAsId<(
>,
)>;

/// Used to determine whether the cross-chain asset is coming from a trusted reserve or not
///
/// Basically, we trust any cross-chain asset from any location to act as a reserve since
/// in order to support the xc-asset, we need to first register it in the `XcAssetConfig` pallet.
pub struct ReserveAssetFilter;
impl ContainsPair<Asset, Location> for ReserveAssetFilter {
fn contains(asset: &Asset, origin: &Location) -> bool {
// We assume that relay chain and sibling parachain assets are trusted reserves for their
// assets
let AssetId(location) = &asset.id;
let reserve_location = match (location.parents, location.first_interior()) {
// sibling parachain
(1, Some(Parachain(id))) => Some(Location::new(1, [Parachain(*id)])),
// relay chain
(1, _) => Some(Location::parent()),
_ => None,
};

if let Some(ref reserve) = reserve_location {
origin == reserve
} else {
false
}
}
}

pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;

pub struct XcmConfig;
Expand All @@ -302,7 +276,7 @@ impl xcm_executor::Config for XcmConfig {
type XcmSender = XcmRouter;
type AssetTransactor = AssetTransactors;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = ReserveAssetFilter;
type IsReserve = MultiNativeAsset<AbsoluteAndRelativeReserveProvider<PeaqLocationAbsolute>>;
// type IsReserve = Everything;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
Expand Down
32 changes: 3 additions & 29 deletions runtime/peaq/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ use crate::{PeaqAssetLocationIdConverter, Treasury};
use cumulus_primitives_core::{AggregateMessageOrigin, ParaId};
use frame_support::{
parameter_types,
traits::{fungibles, Contains, ContainsPair, Everything, Nothing, TransformOrigin},
traits::{fungibles, Contains, Everything, Nothing, TransformOrigin},
};
use frame_system::EnsureRoot;
use orml_traits::location::{RelativeReserveProvider, Reserve};
use orml_xcm_support::DisabledParachainFee;
use orml_xcm_support::{DisabledParachainFee, MultiNativeAsset};
use pallet_xcm::XcmPassthrough;
use parachains_common::{
message_queue::{NarrowOriginToSibling, ParaIdToSibling},
Expand Down Expand Up @@ -266,32 +266,6 @@ pub type Barrier = TrailingSetTopicAsId<(
>,
)>;

/// Used to determine whether the cross-chain asset is coming from a trusted reserve or not
///
/// Basically, we trust any cross-chain asset from any location to act as a reserve since
/// in order to support the xc-asset, we need to first register it in the `XcAssetConfig` pallet.
pub struct ReserveAssetFilter;
impl ContainsPair<Asset, Location> for ReserveAssetFilter {
fn contains(asset: &Asset, origin: &Location) -> bool {
// We assume that relay chain and sibling parachain assets are trusted reserves for their
// assets
let AssetId(location) = &asset.id;
let reserve_location = match (location.parents, location.first_interior()) {
// sibling parachain
(1, Some(Parachain(id))) => Some(Location::new(1, [Parachain(*id)])),
// relay chain
(1, _) => Some(Location::parent()),
_ => None,
};

if let Some(ref reserve) = reserve_location {
origin == reserve
} else {
false
}
}
}

pub type Weigher = FixedWeightBounds<UnitWeightCost, RuntimeCall, MaxInstructions>;

pub struct XcmConfig;
Expand All @@ -302,7 +276,7 @@ impl xcm_executor::Config for XcmConfig {
type XcmSender = XcmRouter;
type AssetTransactor = AssetTransactors;
type OriginConverter = XcmOriginToTransactDispatchOrigin;
type IsReserve = ReserveAssetFilter;
type IsReserve = MultiNativeAsset<AbsoluteAndRelativeReserveProvider<PeaqLocationAbsolute>>;
// type IsReserve = Everything;
type IsTeleporter = ();
type UniversalLocation = UniversalLocation;
Expand Down
Loading