--- a/runtime/Cargo.toml +++ b/runtime/Cargo.toml @@ -377,6 +377,7 @@ scale-info = { version = "1.0.0", default-features = false, features = [ "derive", ] } +log = '0.4.14' derivative = "2.2.0" pallet-unique = { path = '../pallets/unique', default-features = false } up-rpc = { path = "../primitives/rpc", default-features = false } --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -89,13 +89,17 @@ }; use xcm_executor::{Config, XcmExecutor}; +use log::{debug}; +use sp_std::{borrow::Borrow, marker::PhantomData}; + use xcm::latest::{ // Xcm, AssetId::{Concrete}, Fungibility::Fungible as XcmFungible, MultiAsset }; -use xcm_executor::traits::MatchesFungible; +use xcm_executor::traits::{ShouldExecute, WeightBounds, MatchesFungible, WeightTrader, Convert}; +//use xcm_executor::traits::MatchesFungible; use sp_runtime::traits::CheckedConversion; // mod chain_extension; @@ -602,6 +606,37 @@ type XcmpMessageHandler = XcmpQueue; } +pub struct SiblingParachainConvertsVia2(PhantomData<(ParaId, AccountId)>); +impl + Into + AccountIdConversion, AccountId: Clone + core::fmt::Debug> + Convert for SiblingParachainConvertsVia2 +{ + fn convert_ref(location: impl Borrow) -> Result { + + + + match location.borrow() { + MultiLocation { parents: 1, interior: X1(Parachain(id)) } => { + log::debug!( + target: "xcm::converter", + "SiblingParachainConvertsVia2 accountId: {:?}", + ParaId::from(*id).into_account(), + ); + Ok(ParaId::from(*id).into_account()) + } + _ => Err(()), + } + } + + fn reverse_ref(who: impl Borrow) -> Result { + if let Some(id) = ParaId::try_from_account(who.borrow()) { + Ok(MultiLocation::new(1, X1(Parachain(id.into())))) + } else { + Err(()) + } + } +} + + impl parachain_info::Config for Runtime {} impl cumulus_pallet_aura_ext::Config for Runtime {} @@ -620,7 +655,7 @@ // The parent (Relay-chain) origin converts to the default `AccountId`. ParentIsDefault, // Sibling parachain origins convert to AccountId via the `ParaId::into`. - SiblingParachainConvertsVia, + SiblingParachainConvertsVia2, // Straight up local `AccountId32` origins just alias directly to `AccountId`. AccountId32Aliases, );