Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions traits/src/location.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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)))
);
}

Expand Down
6 changes: 5 additions & 1 deletion traits/src/xcm_transfer.rs
Original file line number Diff line number Diff line change
@@ -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<AccountId> {
pub sender: AccountId,
pub assets: Assets,
Expand Down
2 changes: 1 addition & 1 deletion xcm-support/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn multi_native_asset() {
fun: Fungible(10),
id: AssetId(Location::parent())
},
&Parent.into()
&Location::new(1, Parachain(1000))
));
assert!(MultiNativeAsset::<AbsoluteReserveProvider>::contains(
&Asset::sibling_parachain_asset(1, b"TokenA".to_vec().try_into().unwrap(), 100),
Expand Down
9 changes: 8 additions & 1 deletion xtokens/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ enum TransferKind {
}
use TransferKind::*;

const LOG_TARGET: &str = "xtokens";

#[frame_support::pallet]
pub mod module {
use super::*;
Expand Down Expand Up @@ -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::<T>::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::<T>::XcmExecutionFailed
})?;

Expand Down
Loading