git.delta.rocks / unique-network / refs/commits / ed10be88c2d6

difftreelog

Logging for account conversion

str-mv2022-01-25parent: #b3ebe07.patch.diff
in: master

2 files changed

modifiedruntime/Cargo.tomldiffbeforeafterboth
377scale-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 }
modifiedruntime/src/lib.rsdiffbeforeafterboth
89};89};
90use xcm_executor::{Config, XcmExecutor};90use xcm_executor::{Config, XcmExecutor};
91
92use log::{debug};
93use sp_std::{borrow::Borrow, marker::PhantomData};
9194
92use xcm::latest::{95use xcm::latest::{
93// Xcm, 96// Xcm,
94 AssetId::{Concrete},97 AssetId::{Concrete},
95 Fungibility::Fungible as XcmFungible,98 Fungibility::Fungible as XcmFungible,
96 MultiAsset99 MultiAsset
97};100};
98use xcm_executor::traits::MatchesFungible;101use xcm_executor::traits::{ShouldExecute, WeightBounds, MatchesFungible, WeightTrader, Convert};
102//use xcm_executor::traits::MatchesFungible;
99use sp_runtime::traits::CheckedConversion;103use sp_runtime::traits::CheckedConversion;
100104
101// mod chain_extension;105// mod chain_extension;
602 type XcmpMessageHandler = XcmpQueue;606 type XcmpMessageHandler = XcmpQueue;
603}607}
608
609pub struct SiblingParachainConvertsVia2<ParaId, AccountId>(PhantomData<(ParaId, AccountId)>);
610impl<ParaId: From<u32> + Into<u32> + AccountIdConversion<AccountId>, AccountId: Clone + core::fmt::Debug>
611 Convert<MultiLocation, AccountId> for SiblingParachainConvertsVia2<ParaId, AccountId>
612{
613 fn convert_ref(location: impl Borrow<MultiLocation>) -> Result<AccountId, ()> {
614
615
616
617 match location.borrow() {
618 MultiLocation { parents: 1, interior: X1(Parachain(id)) } => {
619 log::debug!(
620 target: "xcm::converter",
621 "SiblingParachainConvertsVia2 accountId: {:?}",
622 ParaId::from(*id).into_account(),
623 );
624 Ok(ParaId::from(*id).into_account())
625 }
626 _ => Err(()),
627 }
628 }
629
630 fn reverse_ref(who: impl Borrow<AccountId>) -> Result<MultiLocation, ()> {
631 if let Some(id) = ParaId::try_from_account(who.borrow()) {
632 Ok(MultiLocation::new(1, X1(Parachain(id.into()))))
633 } else {
634 Err(())
635 }
636 }
637}
638
604639
605impl parachain_info::Config for Runtime {}640impl parachain_info::Config for Runtime {}
620 // The parent (Relay-chain) origin converts to the default `AccountId`.655 // The parent (Relay-chain) origin converts to the default `AccountId`.
621 ParentIsDefault<AccountId>,656 ParentIsDefault<AccountId>,
622 // Sibling parachain origins convert to AccountId via the `ParaId::into`.657 // Sibling parachain origins convert to AccountId via the `ParaId::into`.
623 SiblingParachainConvertsVia<Sibling, AccountId>,658 SiblingParachainConvertsVia2<Sibling, AccountId>,
624 // Straight up local `AccountId32` origins just alias directly to `AccountId`.659 // Straight up local `AccountId32` origins just alias directly to `AccountId`.
625 AccountId32Aliases<RelayNetwork, AccountId>,660 AccountId32Aliases<RelayNetwork, AccountId>,
626);661);