diff --git a/Cargo.lock b/Cargo.lock index 0d708521b9..96da691656 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -731,6 +731,7 @@ dependencies = [ name = "bifrost-runtime" version = "0.8.0" dependencies = [ + "bifrost-runtime-common", "bifrost-vesting", "cumulus-pallet-aura-ext", "cumulus-pallet-dmp-queue", diff --git a/runtime/bifrost/Cargo.toml b/runtime/bifrost/Cargo.toml index 62324a5a6b..608f044473 100644 --- a/runtime/bifrost/Cargo.toml +++ b/runtime/bifrost/Cargo.toml @@ -72,6 +72,7 @@ xcm-executor = { git = "https://github.com/paritytech/polkadot", default-feature # Bifrost pallet-vesting = { package = "bifrost-vesting", path = "../../pallets/vesting", default-features = false } +bifrost-runtime-common = { package = "bifrost-runtime-common", path = "../common", default-features = false } # orml orml-currencies = { version = "0.4.1-dev", default-features = false } @@ -134,6 +135,7 @@ std = [ "orml-currencies/std", "orml-traits/std", "orml-tokens/std", + "bifrost-runtime-common/std", ] with-tracing = ["frame-executive/with-tracing"] diff --git a/runtime/bifrost/src/lib.rs b/runtime/bifrost/src/lib.rs index 939ea2d6ef..46722a07cf 100644 --- a/runtime/bifrost/src/lib.rs +++ b/runtime/bifrost/src/lib.rs @@ -58,7 +58,11 @@ use sp_version::RuntimeVersion; /// Constant values used within the runtime. pub mod constants; +use bifrost_runtime_common::xcm_impl::{ + BifrostAssetMatcher, BifrostCurrencyIdConvert, BifrostFilteredAssets, BifrostXcmTransactFilter, +}; use constants::{currency::*, time::*}; +use cumulus_primitives_core::ParaId as CumulusParaId; use frame_support::traits::OnRuntimeUpgrade; use frame_system::EnsureRoot; use node_primitives::{Amount, CurrencyId, Moment, Nonce, TokenSymbol}; @@ -77,6 +81,7 @@ use xcm_builder::{ SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, }; use xcm_executor::{Config, XcmExecutor}; +use xcm_support::BifrostCurrencyAdapter; // Weights used in the runtime. mod weights; @@ -309,6 +314,7 @@ parameter_types! { pub const KsmLocation: MultiLocation = X1(Parent); pub const RelayNetwork: NetworkId = NetworkId::Kusama; pub RelayChainOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into(); + pub SelfParaChainId: CumulusParaId = ParachainInfo::parachain_id(); pub Ancestry: MultiLocation = X1(Parachain(ParachainInfo::parachain_id().into())); } @@ -380,16 +386,25 @@ pub type Barrier = ( AllowTopLevelPaidExecutionFrom>, // ^^^ Parent & its unit plurality gets free execution AllowUnpaidExecutionFrom, + BifrostXcmTransactFilter>, ); +pub type BifrostAssetTransactor = BifrostCurrencyAdapter< + Tokens, + BifrostAssetMatcher>, + AccountId, + LocationToAccountId, + CurrencyId, + BifrostCurrencyIdConvert, +>; + pub struct XcmConfig; impl Config for XcmConfig { - // How to withdraw and deposit an asset. - type AssetTransactor = LocalAssetTransactor; + type AssetTransactor = BifrostAssetTransactor; type Barrier = Barrier; type Call = Call; - type IsReserve = NativeAsset; - type IsTeleporter = NativeAsset; + type IsReserve = BifrostFilteredAssets; + type IsTeleporter = BifrostFilteredAssets; // <- should be enough to allow teleportation of ROC type LocationInverter = LocationInverter; type OriginConverter = XcmOriginToTransactDispatchOrigin;