difftreelog
Logging for account conversion
in: master
2 files changed
runtime/Cargo.tomldiffbeforeafterboth377scale-info = { version = "1.0.0", default-features = false, features = [377scale-info = { version = "1.0.0", default-features = false, features = [378 "derive",378 "derive",379] }379] }380log = '0.4.14'380derivative = "2.2.0"381derivative = "2.2.0"381pallet-unique = { path = '../pallets/unique', default-features = false }382pallet-unique = { path = '../pallets/unique', default-features = false }382up-rpc = { path = "../primitives/rpc", default-features = false }383up-rpc = { path = "../primitives/rpc", default-features = false }runtime/src/lib.rsdiffbeforeafterboth--- 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<ParaId, AccountId>(PhantomData<(ParaId, AccountId)>);
+impl<ParaId: From<u32> + Into<u32> + AccountIdConversion<AccountId>, AccountId: Clone + core::fmt::Debug>
+ Convert<MultiLocation, AccountId> for SiblingParachainConvertsVia2<ParaId, AccountId>
+{
+ fn convert_ref(location: impl Borrow<MultiLocation>) -> Result<AccountId, ()> {
+
+
+
+ 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<AccountId>) -> Result<MultiLocation, ()> {
+ 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<AccountId>,
// Sibling parachain origins convert to AccountId via the `ParaId::into`.
- SiblingParachainConvertsVia<Sibling, AccountId>,
+ SiblingParachainConvertsVia2<Sibling, AccountId>,
// Straight up local `AccountId32` origins just alias directly to `AccountId`.
AccountId32Aliases<RelayNetwork, AccountId>,
);