diff --git a/traits/src/location.rs b/traits/src/location.rs index 63496d25d..6dda230cb 100644 --- a/traits/src/location.rs +++ b/traits/src/location.rs @@ -1,6 +1,8 @@ use sp_core::{bounded::BoundedVec, ConstU32}; use xcm::v5::prelude::*; +pub const ASSET_HUB_ID: u32 = 1000; + pub trait Parse { /// Returns the "chain" location part. It could be parent, sibling /// parachain, or child parachain. @@ -18,8 +20,8 @@ impl Parse for Location { match (self.parents, self.first_interior()) { // sibling parachain (1, Some(Parachain(id))) => Some(Location::new(1, [Parachain(*id)])), - // parent - (1, _) => Some(Location::parent()), + // parent -> assethub + (1, _) => Some(Location::new(1, Parachain(ASSET_HUB_ID))), // children parachain (0, Some(Parachain(id))) => Some(Location::new(0, [Parachain(*id)])), _ => None, @@ -95,11 +97,11 @@ mod tests { fn parent_as_reserve_chain() { assert_eq!( AbsoluteReserveProvider::reserve(&concrete_fungible(Location::new(1, [GENERAL_INDEX]))), - Some(Location::parent()) + Some(Location::new(1, Parachain(ASSET_HUB_ID))) ); assert_eq!( RelativeReserveProvider::reserve(&concrete_fungible(Location::new(1, [GENERAL_INDEX]))), - Some(Location::parent()) + Some(Location::new(1, Parachain(ASSET_HUB_ID))) ); } diff --git a/traits/src/xcm_transfer.rs b/traits/src/xcm_transfer.rs index 5a2ab80fb..d66a12186 100644 --- a/traits/src/xcm_transfer.rs +++ b/traits/src/xcm_transfer.rs @@ -1,9 +1,13 @@ -use sp_runtime::DispatchError; +use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; +use scale_info::TypeInfo; +use sp_runtime::{DispatchError, RuntimeDebug}; use sp_std::vec::Vec; use xcm::{ v5::{prelude::*, Weight}, VersionedAsset, VersionedAssets, VersionedLocation, }; + +#[derive(Encode, Decode, Clone, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)] pub struct Transferred { pub sender: AccountId, pub assets: Assets, diff --git a/xcm-support/src/tests.rs b/xcm-support/src/tests.rs index 9b38d0360..b0f9f8682 100644 --- a/xcm-support/src/tests.rs +++ b/xcm-support/src/tests.rs @@ -96,7 +96,7 @@ fn multi_native_asset() { fun: Fungible(10), id: AssetId(Location::parent()) }, - &Parent.into() + &Location::new(1, Parachain(1000)) )); assert!(MultiNativeAsset::::contains( &Asset::sibling_parachain_asset(1, b"TokenA".to_vec().try_into().unwrap(), 100), diff --git a/xtokens/src/lib.rs b/xtokens/src/lib.rs index ff43bcd08..e04b68952 100644 --- a/xtokens/src/lib.rs +++ b/xtokens/src/lib.rs @@ -71,6 +71,8 @@ enum TransferKind { } use TransferKind::*; +const LOG_TARGET: &str = "xtokens"; + #[frame_support::pallet] pub mod module { use super::*; @@ -686,10 +688,15 @@ pub mod module { let mut hash = msg.using_encoded(sp_io::hashing::blake2_256); let weight = T::Weigher::weight(&mut msg).map_err(|()| Error::::UnweighableMessage)?; + log::debug!( + target: LOG_TARGET, + "origin_location {:?} execute transfer message {:?}, hash {:?}, weight: {:?}", + origin_location, msg, hash, weight + ); T::XcmExecutor::prepare_and_execute(origin_location, msg, &mut hash, weight, weight) .ensure_complete() .map_err(|error| { - log::error!("Failed execute transfer message with {:?}", error); + log::error!(target: LOG_TARGET, "Failed execute transfer message with {:?}", error); Error::::XcmExecutionFailed })?;