Skip to content

Commit 083d0dd

Browse files
committed
AHM change parent location
1 parent 2fd6442 commit 083d0dd

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

traits/src/location.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use sp_core::{bounded::BoundedVec, ConstU32};
22
use xcm::v5::prelude::*;
33

4+
pub const ASSET_HUB_ID: u32 = 1000;
5+
46
pub trait Parse {
57
/// Returns the "chain" location part. It could be parent, sibling
68
/// parachain, or child parachain.
@@ -18,8 +20,8 @@ impl Parse for Location {
1820
match (self.parents, self.first_interior()) {
1921
// sibling parachain
2022
(1, Some(Parachain(id))) => Some(Location::new(1, [Parachain(*id)])),
21-
// parent
22-
(1, _) => Some(Location::parent()),
23+
// parent -> assethub
24+
(1, _) => Some(Location::new(1, Parachain(ASSET_HUB_ID))),
2325
// children parachain
2426
(0, Some(Parachain(id))) => Some(Location::new(0, [Parachain(*id)])),
2527
_ => None,
@@ -95,11 +97,11 @@ mod tests {
9597
fn parent_as_reserve_chain() {
9698
assert_eq!(
9799
AbsoluteReserveProvider::reserve(&concrete_fungible(Location::new(1, [GENERAL_INDEX]))),
98-
Some(Location::parent())
100+
Some(Location::new(1, Parachain(ASSET_HUB_ID)))
99101
);
100102
assert_eq!(
101103
RelativeReserveProvider::reserve(&concrete_fungible(Location::new(1, [GENERAL_INDEX]))),
102-
Some(Location::parent())
104+
Some(Location::new(1, Parachain(ASSET_HUB_ID)))
103105
);
104106
}
105107

traits/src/xcm_transfer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
use sp_runtime::DispatchError;
1+
use parity_scale_codec::{Decode, Encode, MaxEncodedLen};
2+
use scale_info::TypeInfo;
3+
use sp_runtime::{DispatchError, RuntimeDebug};
24
use sp_std::vec::Vec;
35
use xcm::{
46
v5::{prelude::*, Weight},
57
VersionedAsset, VersionedAssets, VersionedLocation,
68
};
9+
10+
#[derive(Encode, Decode, Clone, PartialEq, Eq, MaxEncodedLen, RuntimeDebug, TypeInfo)]
711
pub struct Transferred<AccountId> {
812
pub sender: AccountId,
913
pub assets: Assets,

xcm-support/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn multi_native_asset() {
9696
fun: Fungible(10),
9797
id: AssetId(Location::parent())
9898
},
99-
&Parent.into()
99+
&Location::new(1, Parachain(1000))
100100
));
101101
assert!(MultiNativeAsset::<AbsoluteReserveProvider>::contains(
102102
&Asset::sibling_parachain_asset(1, b"TokenA".to_vec().try_into().unwrap(), 100),

xtokens/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ enum TransferKind {
7171
}
7272
use TransferKind::*;
7373

74+
const LOG_TARGET: &str = "xtokens";
75+
7476
#[frame_support::pallet]
7577
pub mod module {
7678
use super::*;
@@ -686,10 +688,15 @@ pub mod module {
686688
let mut hash = msg.using_encoded(sp_io::hashing::blake2_256);
687689

688690
let weight = T::Weigher::weight(&mut msg).map_err(|()| Error::<T>::UnweighableMessage)?;
691+
log::debug!(
692+
target: LOG_TARGET,
693+
"origin_location {:?} execute transfer message {:?}, hash {:?}, weight: {:?}",
694+
origin_location, msg, hash, weight
695+
);
689696
T::XcmExecutor::prepare_and_execute(origin_location, msg, &mut hash, weight, weight)
690697
.ensure_complete()
691698
.map_err(|error| {
692-
log::error!("Failed execute transfer message with {:?}", error);
699+
log::error!(target: LOG_TARGET, "Failed execute transfer message with {:?}", error);
693700
Error::<T>::XcmExecutionFailed
694701
})?;
695702

0 commit comments

Comments
 (0)