Skip to content

Commit

Permalink
Merge pull request #56 from Snowfork/ron/pr-comments
Browse files Browse the repository at this point in the history
TrustedTeleporters from SnowBridgeMessageQueue
  • Loading branch information
claravanstaden authored Dec 2, 2023
2 parents e107680 + cdbb714 commit afbb976
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use rococo_runtime_constants::system_parachain;
use snowbridge_rococo_common::EthereumNetwork;
use snowbridge_router_primitives::inbound::GlobalConsensusEthereumConvertsFor;
use sp_runtime::traits::{AccountIdConversion, ConvertInto};
use sp_std::marker::PhantomData;
use xcm::latest::prelude::*;
use xcm_builder::{
AccountId32Aliases, AllowExplicitUnpaidExecutionFrom, AllowKnownQueryResponses,
Expand All @@ -60,6 +61,7 @@ use xcm_executor::{traits::WithOriginFilter, XcmExecutor};

#[cfg(feature = "runtime-benchmarks")]
use cumulus_primitives_core::ParaId;
use frame_support::traits::{ContainsPair, Get};

parameter_types! {
pub const TokenLocation: MultiLocation = MultiLocation::parent();
Expand Down Expand Up @@ -544,6 +546,7 @@ pub type WaivedLocations =
/// - Sibling parachains' assets from where they originate (as `ForeignCreators`).
pub type TrustedTeleporters = (
ConcreteAssetFromSystem<TokenLocation>,
ConcreteAssetFromSnowBridgeMessageQueue<TokenLocation>,
IsForeignConcreteAsset<FromSiblingParachain<parachain_info::Pallet<Runtime>>>,
);

Expand Down Expand Up @@ -727,6 +730,18 @@ where
}
}

pub struct ConcreteAssetFromSnowBridgeMessageQueue<AssetLocation>(PhantomData<AssetLocation>);
impl<AssetLocation: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation>
for ConcreteAssetFromSnowBridgeMessageQueue<AssetLocation>
{
fn contains(asset: &MultiAsset, origin: &MultiLocation) -> bool {
log::trace!(target: "xcm::contains", "ConcreteAssetFromSystem asset: {:?}, origin: {:?}", asset, origin);
let from_snowbridge = origin
.eq(&bridging::to_ethereum::SiblingBridgeHubWithEthereumInboundQueueInstance::get());
matches!(asset.id, Concrete(id) if id == AssetLocation::get()) && from_snowbridge
}
}

/// All configuration related to bridging
pub mod bridging {
use super::*;
Expand Down

0 comments on commit afbb976

Please sign in to comment.