Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Ensure MultiLocation always has a canonical representation #3404

Merged
186 commits merged into from
Aug 9, 2021
Merged
Show file tree
Hide file tree
Changes from 181 commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
3e15173
MultiAsset TWO
gavofyork Apr 4, 2021
a7c51a8
Ensure MultiLocation always has a canonical representation
KiChjang Jul 4, 2021
12054df
Merge remote-tracking branch 'origin/master' into gav-multiasset-2
gavofyork Jul 29, 2021
982e654
Merge remote-tracking branch 'origin' into kckyeung/canonical-xcm-mul…
KiChjang Jul 30, 2021
621e873
Remove v1 module
KiChjang Jul 30, 2021
ee80e03
Draft next MultiAsset API.
gavofyork Jul 30, 2021
65b6fd4
Implement custom encoding/decoding scheme for MultiLocation
KiChjang Jul 30, 2021
16927cd
Properly implement IntoIterator for Junctions
KiChjang Jul 30, 2021
786fb46
Implement TryFrom<MultiLocation> for Junctions
KiChjang Jul 30, 2021
5b487a6
Fix spelling mistakes
KiChjang Jul 30, 2021
5c23328
Fix tests in xcm-executor
KiChjang Jul 30, 2021
2661b91
XCM core builds
gavofyork Jul 30, 2021
6fc030e
XCM Executor builds
gavofyork Jul 30, 2021
8017453
XCM Builder builds
gavofyork Jul 31, 2021
72c2581
Fix xcm-builder tests and compilation
KiChjang Jul 31, 2021
c4a2d68
Make pallet-xcm compile
KiChjang Jul 31, 2021
9f64f61
Use MultiLocation::default()
KiChjang Jul 31, 2021
15b1ec9
Make polkadot-runtime-common compile
KiChjang Jul 31, 2021
2370c39
Make rococo-runtime compile
KiChjang Aug 1, 2021
6aaa81b
Change return type of parent_count to u8
KiChjang Aug 1, 2021
59e5935
Change MAX_MULTILOCATION_LENGTH to 255
KiChjang Aug 1, 2021
85a61a5
Make kusama-runtime compile
KiChjang Aug 1, 2021
dba0ed9
Fix logic in pallet-xcm
KiChjang Aug 1, 2021
e1ec296
Use MultiLocation::empty()
KiChjang Aug 1, 2021
9807639
Fix logic in location_conversion
KiChjang Aug 1, 2021
57bd83a
Fix logic in origin_conversion.rs
KiChjang Aug 1, 2021
5a4dc4f
Make westend-runtime compile
KiChjang Aug 1, 2021
f313fc4
Rename prefixes and suffixes variables
KiChjang Aug 1, 2021
8cdf6c1
Rename non_parent to interior
KiChjang Aug 1, 2021
5956216
Rename non_parent to interior
KiChjang Aug 1, 2021
46aea44
Add test for encode/decode roundtrip and fix decode algorithm
KiChjang Aug 1, 2021
5445d06
API changes making their way throughout
gavofyork Aug 1, 2021
958d79a
Some TODOs
gavofyork Aug 1, 2021
7d47d21
Further build fixes
gavofyork Aug 1, 2021
6ce9f1d
Rename non_parent/junctions to interior
KiChjang Aug 1, 2021
bb5bf44
Basic compile builds
gavofyork Aug 1, 2021
acef319
First test fixed
gavofyork Aug 1, 2021
7d700b6
All executor tests fixed
gavofyork Aug 1, 2021
3e62aa3
Typo
gavofyork Aug 1, 2021
ca477f0
Optimize subsume_assets and add test
gavofyork Aug 1, 2021
3cc428f
Optimize checked_sub
gavofyork Aug 1, 2021
099aea7
XCM Builder first test fixed
gavofyork Aug 1, 2021
5158442
Fix builder tests
gavofyork Aug 2, 2021
6814aa8
Fix doc test
gavofyork Aug 2, 2021
c41afe5
Merge remote-tracking branch 'origin/master' into kckyeung/canonical-…
KiChjang Aug 2, 2021
8d8aa5c
Make xcm-simulator compile
KiChjang Aug 2, 2021
3ef2cd4
Merge remote-tracking branch 'origin/master' into kckyeung/canonical-…
KiChjang Aug 2, 2021
825a2aa
Make xcm-simulator-example compile
KiChjang Aug 2, 2021
4f4693a
Make spellcheck happy
KiChjang Aug 2, 2021
8178647
cargo fmt
KiChjang Aug 2, 2021
529a931
fix some doc tests
gavofyork Aug 2, 2021
3e93d54
spelling
gavofyork Aug 2, 2021
f42b3ab
named fields for AllOf
gavofyork Aug 2, 2021
260f8a4
Fix subtle bug where Null is treated as an identifier
KiChjang Aug 3, 2021
2a2af5b
Add FIXME comment awaiting for const generics eval stabilization
KiChjang Aug 3, 2021
97051b2
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
84b79cf
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
1f98872
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
0cc61de
Update xcm/src/v0/multiasset.rs
gavofyork Aug 3, 2021
4f57497
Merge branch 'master' into gav-multiasset-2-reformat
gavofyork Aug 3, 2021
723990c
Reformat
gavofyork Aug 3, 2021
9e2e009
Move to XCM version 1
gavofyork Aug 3, 2021
00ca37b
Spelling
gavofyork Aug 3, 2021
768c96a
warnings
gavofyork Aug 3, 2021
2936419
Replace some more v0->v1s
gavofyork Aug 3, 2021
015fff2
warnings
gavofyork Aug 3, 2021
b5fe03e
format
gavofyork Aug 3, 2021
608a212
Add max_assets param
gavofyork Aug 3, 2021
dee3be5
building
gavofyork Aug 3, 2021
a6eaaa2
test fixes
gavofyork Aug 3, 2021
f58a659
tests
gavofyork Aug 3, 2021
8a78100
another test
gavofyork Aug 3, 2021
6eb75ad
final test
gavofyork Aug 3, 2021
c4f61f3
Update rustdocs and add debug_assert where sensible
KiChjang Aug 4, 2021
a25f3ea
Revert debug_assert in const fn len()
KiChjang Aug 4, 2021
9d0b9f9
tests
gavofyork Aug 4, 2021
b5b63c8
Rename Null -> Here
gavofyork Aug 4, 2021
e9dbc72
Introduce
gavofyork Aug 4, 2021
36ccb47
More ergonomics
gavofyork Aug 4, 2021
de33d7d
More ergonomics
gavofyork Aug 4, 2021
7ff0493
test fix
gavofyork Aug 4, 2021
d43d987
Merge branch 'gav-multiasset-2' into gav-max-assets
gavofyork Aug 4, 2021
84c44f8
test fixes
gavofyork Aug 4, 2021
7d52b93
docs
gavofyork Aug 4, 2021
51c7d05
BuyExecution includes
gavofyork Aug 4, 2021
851b00e
Fix XCM extrinsics
gavofyork Aug 4, 2021
20bb714
fmt
gavofyork Aug 4, 2021
3f85ebd
Make Vec<MultiAsset>/MultiAssets conversions safe
gavofyork Aug 4, 2021
61a2231
More MultiAssets conversion safety
gavofyork Aug 4, 2021
7646446
Merge remote-tracking branch 'origin/master' into gav-multiasset-2
gavofyork Aug 4, 2021
8644265
spelling
gavofyork Aug 4, 2021
1e75953
fix doc test
gavofyork Aug 4, 2021
669dcb0
Apply suggestions from code review
gavofyork Aug 5, 2021
767bdb5
Apply suggestions from code review
gavofyork Aug 5, 2021
ec2c1e9
fmt
gavofyork Aug 5, 2021
740f6f3
Add v0, remove VersionedMultiAsset
gavofyork Aug 5, 2021
9f8606d
Remove VersionedMultiLocation
gavofyork Aug 5, 2021
1c4a89a
Update xcm/src/v1/order.rs
gavofyork Aug 5, 2021
d3fb090
Update xcm/src/v1/mod.rs
gavofyork Aug 5, 2021
a5c2bde
XCM v0 backwards compatibility
gavofyork Aug 5, 2021
2d0479a
Merge branch 'gav-multiasset-2' of github.com:paritytech/polkadot int…
gavofyork Aug 5, 2021
7130ed7
Full compatibility
gavofyork Aug 5, 2021
efa012d
fmt
gavofyork Aug 5, 2021
a0658e1
Merge branch 'master' into gav-multiasset-2
gavofyork Aug 5, 2021
e33710b
Update xcm/pallet-xcm/src/lib.rs
shawntabrizi Aug 5, 2021
a31887c
Merge branch 'master' into gav-multiasset-2
gavofyork Aug 5, 2021
fe59886
Update xcm/src/v0/order.rs
gavofyork Aug 5, 2021
d2bd1e0
Tweaks to versioning system
gavofyork Aug 6, 2021
089d90c
Merge branch 'gav-multiasset-2' of github.com:paritytech/polkadot int…
gavofyork Aug 6, 2021
d9ff88c
Fixes
gavofyork Aug 6, 2021
b40668e
fmt
gavofyork Aug 6, 2021
5e0f1f9
Merge remote-tracking branch 'origin/gav-multiasset-2' into kckyeung/…
KiChjang Aug 6, 2021
4b200be
Merge remote-tracking branch 'origin/gav-multiasset-2' into kckyeung/…
KiChjang Aug 6, 2021
a123f94
Fix pallet-xcm tests
KiChjang Aug 6, 2021
e2523e3
Merge remote-tracking branch 'origin/master' into kckyeung/canonical-…
KiChjang Aug 6, 2021
5c330ad
fix
KiChjang Aug 6, 2021
0edc39f
Substitute with_parent with with_parents_const
KiChjang Aug 6, 2021
4de501b
Rename argument name from a to m
KiChjang Aug 6, 2021
393381d
Rename split_last to split_last_interior
KiChjang Aug 6, 2021
a064c94
Allow adding multiple parents in MultiLocation
KiChjang Aug 6, 2021
0b0c22b
Rename pop_parent to dec_parent
KiChjang Aug 6, 2021
8df05d0
Ensure relay chain XCM sender receives a MultiLocation without any pa…
KiChjang Aug 6, 2021
f8bbf77
Block only when MultiLocation destination length is 8
KiChjang Aug 6, 2021
9b12f9b
Cargo fmt
KiChjang Aug 6, 2021
5edf59c
Remove reverse iterators, implement DoubleEndedIterator and add tests
KiChjang Aug 7, 2021
e9128b9
Fix iter_rev lifetime requirements
KiChjang Aug 7, 2021
56cca55
Cargo fmt
KiChjang Aug 7, 2021
3726219
Add an into() method for Junctions for conciseness in const context
KiChjang Aug 7, 2021
955b9e4
Ensure parent count is 0 while executing who in RelayedFrom
KiChjang Aug 7, 2021
da521d6
Appease spellchecker
KiChjang Aug 7, 2021
435c6a4
Merge remote-tracking branch 'origin/master' into kckyeung/canonical-…
KiChjang Aug 7, 2021
a3b84f0
Use and_then instead of repeated map_err
KiChjang Aug 7, 2021
e0dcb84
Remove custom codec indices for v1 Junctions
KiChjang Aug 7, 2021
a345988
Add convenience 'contains_parents_only' method to MultiLocation
KiChjang Aug 7, 2021
bdbbd8f
Fix merge conflict
KiChjang Aug 7, 2021
a1489cb
Use more convenience methods
KiChjang Aug 7, 2021
e6e4509
Remove with_parachain_interior
KiChjang Aug 7, 2021
139b8b1
Prefer matching against tuple instead of using match guards
KiChjang Aug 7, 2021
2b8a97d
Match against tuple instead of using more match guards
KiChjang Aug 7, 2021
db5c466
Update encode/decode test for MultiLocation
KiChjang Aug 7, 2021
c3f372d
Minor tweaks
gavofyork Aug 7, 2021
a605996
Fixes
gavofyork Aug 7, 2021
0d21a44
Fixes
gavofyork Aug 7, 2021
da77312
Fixes
gavofyork Aug 7, 2021
7d3a238
Fix MultiLocation
gavofyork Aug 7, 2021
cf14820
Add deprecation note for iter_rev and into_iter_rev
KiChjang Aug 8, 2021
a2839cf
Update some rustdocs
KiChjang Aug 8, 2021
4970fff
cargo fmt
KiChjang Aug 8, 2021
9644979
Fix xcm-executor unit tests
KiChjang Aug 8, 2021
a71cb28
Fix compilation and unit tests in xcm-builder
KiChjang Aug 8, 2021
74d4db9
cargo fmt
KiChjang Aug 8, 2021
b72f127
Fix tests in xcm-simulator-example
KiChjang Aug 8, 2021
1112e0e
Publicize MultiLocation fields
KiChjang Aug 8, 2021
b444e23
Match on the MultiLocation struct directly in xcm-builder
KiChjang Aug 8, 2021
cdbaccc
Do not dereference undereferenceable types
KiChjang Aug 8, 2021
18a82ec
Add convenience MultiLocation conversions for tuples
KiChjang Aug 8, 2021
d82fb6b
Use clearer import paths
KiChjang Aug 8, 2021
2281325
Remove unused dependency
KiChjang Aug 8, 2021
fe78be8
fix junction + response
shawntabrizi Aug 8, 2021
5d58105
Import from latest opaque xcm module
KiChjang Aug 8, 2021
a544414
Merge branch 'master' into shawntabrizi-fix-backwards-compat
shawntabrizi Aug 8, 2021
1ab9719
Update xcm/src/v1/mod.rs
shawntabrizi Aug 8, 2021
7d6daba
better comment
shawntabrizi Aug 8, 2021
dbc412b
Fix ownership transfer
KiChjang Aug 8, 2021
69ee3db
Merge remote-tracking branch 'origin/master' into kckyeung/canonical-…
KiChjang Aug 8, 2021
7727c4b
Fix merge
KiChjang Aug 8, 2021
e6a2160
Fix merge
KiChjang Aug 8, 2021
aa49333
cargo fmt
KiChjang Aug 8, 2021
5ae97f4
Merge remote-tracking branch 'origin/shawntabrizi-fix-backwards-compa…
KiChjang Aug 8, 2021
c3c0005
Fix merge
KiChjang Aug 8, 2021
15f83c3
Fix merge
KiChjang Aug 8, 2021
d73fd90
Fix integration test
KiChjang Aug 8, 2021
1a1708c
More readable Parent syntax
gavofyork Aug 9, 2021
102b9d9
cleanup
gavofyork Aug 9, 2021
36b10f3
cleanup
gavofyork Aug 9, 2021
92c9785
cleanup
gavofyork Aug 9, 2021
30c404c
cleanup
gavofyork Aug 9, 2021
4e9f958
cleanup
gavofyork Aug 9, 2021
52c0621
cleanup
gavofyork Aug 9, 2021
623039b
cleanup
gavofyork Aug 9, 2021
1c97d0f
cleanup
gavofyork Aug 9, 2021
6780778
Merge remote-tracking branch 'origin/master' into kckyeung/canonical-…
KiChjang Aug 9, 2021
425116f
cargo fmt
KiChjang Aug 9, 2021
9ed00fc
Fixes
gavofyork Aug 9, 2021
c2e6720
Merge branch 'kckyeung/canonical-xcm-multilocation' of github.com:par…
gavofyork Aug 9, 2021
38f6e3c
Fix doc test
KiChjang Aug 9, 2021
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: 5 additions & 5 deletions runtime/common/src/xcm_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use parity_scale_codec::Encode;
use runtime_parachains::{configuration, dmp};
use sp_std::marker::PhantomData;
use xcm::opaque::v1::{Error, Junction, MultiLocation, Result, SendXcm, Xcm};
use xcm::opaque::latest::*;

/// XCM sender for relay chain. It only sends downward message.
pub struct ChildParachainRouter<T, W>(PhantomData<(T, W)>);
Expand All @@ -28,21 +28,21 @@ impl<T: configuration::Config + dmp::Config, W: xcm::WrapVersion> SendXcm
for ChildParachainRouter<T, W>
{
fn send_xcm(dest: MultiLocation, msg: Xcm) -> Result {
match &dest {
MultiLocation::X1(Junction::Parachain(id)) => {
match dest {
MultiLocation { parents: 0, interior: Junctions::X1(Junction::Parachain(id)) } => {
// Downward message passing.
let versioned_xcm =
W::wrap_version(&dest, msg).map_err(|()| Error::DestinationUnsupported)?;
let config = <configuration::Pallet<T>>::config();
<dmp::Pallet<T>>::queue_downward_message(
&config,
(*id).into(),
id.into(),
versioned_xcm.encode(),
)
.map_err(Into::<Error>::into)?;
Ok(())
},
_ => Err(Error::CannotReachDestination(dest, msg)),
dest => Err(Error::CannotReachDestination(dest, msg)),
}
}
}
6 changes: 3 additions & 3 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1203,12 +1203,12 @@ parameter_types! {
/// The location of the KSM token, from the context of this chain. Since this token is native to this
/// chain, we make it synonymous with it and thus it is the `Here` location, which means "equivalent to
/// the context".
pub const KsmLocation: MultiLocation = MultiLocation::Here;
pub const KsmLocation: MultiLocation = Here.into();
/// The Kusama network ID. This is named.
pub const KusamaNetwork: NetworkId = NetworkId::Kusama;
/// Our XCM location ancestry - i.e. what, if anything, `Parent` means evaluated in our context. Since
/// Kusama is a top-level relay-chain, there is no ancestry.
pub const Ancestry: MultiLocation = MultiLocation::Here;
pub const Ancestry: MultiLocation = Here.into();
/// The check account, which holds any native assets that have been teleported out and not back in (yet).
pub CheckAccount: AccountId = XcmPallet::check_account();
}
Expand Down Expand Up @@ -1265,7 +1265,7 @@ pub type XcmRouter = (

parameter_types! {
pub const Kusama: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(KsmLocation::get()) });
pub const KusamaForStatemint: (MultiAssetFilter, MultiLocation) = (Kusama::get(), X1(Parachain(1000)));
pub const KusamaForStatemint: (MultiAssetFilter, MultiLocation) = (Kusama::get(), Parachain(1000).into());
}
pub type TrustedTeleporters = (xcm_builder::Case<KusamaForStatemint>,);

Expand Down
20 changes: 10 additions & 10 deletions runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,9 @@ impl parachains_paras::Config for Runtime {
}

parameter_types! {
pub const RocLocation: MultiLocation = MultiLocation::Here;
pub const RocLocation: MultiLocation = Here.into();
pub const RococoNetwork: NetworkId = NetworkId::Polkadot;
pub const Ancestry: MultiLocation = MultiLocation::Here;
pub const Ancestry: MultiLocation = Here.into();
pub CheckAccount: AccountId = XcmPallet::check_account();
}

Expand Down Expand Up @@ -625,10 +625,10 @@ pub type XcmRouter = (

parameter_types! {
pub const Rococo: MultiAssetFilter = Wild(AllOf { fun: WildFungible, id: Concrete(RocLocation::get()) });
pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(100)));
pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(110)));
pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(120)));
pub const RococoForStatemint: (MultiAssetFilter, MultiLocation) = (Rococo::get(), X1(Parachain(1001)));
pub const RococoForTick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(100).into());
pub const RococoForTrick: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(110).into());
pub const RococoForTrack: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(120).into());
pub const RococoForStatemint: (MultiAssetFilter, MultiLocation) = (Rococo::get(), Parachain(1001).into());
}
pub type TrustedTeleporters = (
xcm_builder::Case<RococoForTick>,
Expand All @@ -640,10 +640,10 @@ pub type TrustedTeleporters = (
parameter_types! {
pub AllowUnpaidFrom: Vec<MultiLocation> =
vec![
X1(Parachain(100)),
X1(Parachain(110)),
X1(Parachain(120)),
X1(Parachain(1001))
Parachain(100).into(),
Parachain(110).into(),
Parachain(120).into(),
Parachain(1001).into(),
];
}

Expand Down
7 changes: 3 additions & 4 deletions runtime/test-runtime/src/xcm_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

use frame_support::{parameter_types, traits::Everything, weights::Weight};
use xcm::latest::{
Error as XcmError, Junction::*, MultiAsset, MultiLocation, MultiLocation::*, NetworkId,
Result as XcmResult, SendXcm, Xcm,
Error as XcmError, MultiAsset, MultiLocation, NetworkId, Result as XcmResult, SendXcm, Xcm, Parent, Junctions::Here,
};
use xcm_builder::{AllowUnpaidExecutionFrom, FixedWeightBounds, SignedToAccountId32};
use xcm_executor::{
Expand Down Expand Up @@ -52,7 +51,7 @@ impl TransactAsset for DummyAssetTransactor {
}

fn withdraw_asset(_what: &MultiAsset, _who: &MultiLocation) -> Result<Assets, XcmError> {
let asset: MultiAsset = (X1(Parent), 100_000).into();
let asset: MultiAsset = (Parent, 100_000).into();
Ok(asset.into())
}
}
Expand All @@ -71,7 +70,7 @@ impl WeightTrader for DummyWeightTrader {
pub struct InvertNothing;
impl InvertLocation for InvertNothing {
fn invert_location(_: &MultiLocation) -> MultiLocation {
MultiLocation::Here
Here.into()
}
}

Expand Down
6 changes: 3 additions & 3 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,8 @@ impl auctions::Config for Runtime {
}

parameter_types! {
pub const WndLocation: MultiLocation = MultiLocation::Here;
pub const Ancestry: MultiLocation = MultiLocation::Here;
pub const WndLocation: MultiLocation = Here.into();
pub const Ancestry: MultiLocation = Here.into();
pub WestendNetwork: NetworkId = NetworkId::Named(b"Westend".to_vec());
pub CheckAccount: AccountId = XcmPallet::check_account();
}
Expand Down Expand Up @@ -908,7 +908,7 @@ pub type XcmRouter = (

parameter_types! {
pub const WestendForWestmint: (MultiAssetFilter, MultiLocation) =
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), X1(Parachain(1000)));
(Wild(AllOf { fun: WildFungible, id: Concrete(WndLocation::get()) }), Parachain(1000).into());
}
pub type TrustedTeleporters = (xcm_builder::Case<WestendForWestmint>,);

Expand Down
17 changes: 9 additions & 8 deletions xcm/pallet-xcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub mod pallet {
UnweighableMessage,
/// The assets to be sent are empty.
Empty,
/// Could not reanchor the assets to declare the fees for the destination chain.
/// Could not re-anchor the assets to declare the fees for the destination chain.
CannotReanchor,
/// Too many assets have been attempted for transfer.
TooManyAssets,
Expand Down Expand Up @@ -306,9 +306,10 @@ pub mod pallet {
dest: MultiLocation,
message: Xcm<()>,
) -> Result<(), XcmError> {
let message = match interior {
MultiLocation::Here => message,
who => Xcm::<()>::RelayedFrom { who, message: Box::new(message) },
let message = if interior.is_here() {
message
} else {
Xcm::<()>::RelayedFrom { who: interior, message: Box::new(message) }
};
log::trace!(target: "xcm::send_xcm", "dest: {:?}, message: {:?}", &dest, &message);
T::XcmRouter::send_xcm(dest, message)
Expand Down Expand Up @@ -384,7 +385,7 @@ where

#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> O {
O::from(Origin::Xcm(MultiLocation::Here))
O::from(Origin::Xcm(Here.into()))
}
}

Expand All @@ -393,9 +394,9 @@ where
pub struct XcmPassthrough<Origin>(PhantomData<Origin>);
impl<Origin: From<crate::Origin>> ConvertOrigin<Origin> for XcmPassthrough<Origin> {
fn convert_origin(origin: MultiLocation, kind: OriginKind) -> Result<Origin, MultiLocation> {
match (kind, origin) {
(OriginKind::Xcm, l) => Ok(crate::Origin::Xcm(l).into()),
(_, origin) => Err(origin),
match kind {
KiChjang marked this conversation as resolved.
Show resolved Hide resolved
OriginKind::Xcm => Ok(crate::Origin::Xcm(origin).into()),
_ => Err(origin),
}
}
}
6 changes: 3 additions & 3 deletions xcm/pallet-xcm/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl SendXcm for TestSendXcm {
pub struct TestSendXcmErrX8;
impl SendXcm for TestSendXcmErrX8 {
fn send_xcm(dest: MultiLocation, msg: Xcm) -> XcmResult {
if let MultiLocation::X8(..) = dest {
if dest.len() == 8 {
Err(XcmError::Undefined)
} else {
SENT_XCM.with(|q| q.borrow_mut().push((dest, msg)));
Expand Down Expand Up @@ -129,9 +129,9 @@ impl pallet_balances::Config for Test {
}

parameter_types! {
pub const RelayLocation: MultiLocation = MultiLocation::Here;
pub const RelayLocation: MultiLocation = Here.into();
pub const AnyNetwork: NetworkId = NetworkId::Any;
pub Ancestry: MultiLocation = MultiLocation::Here;
pub Ancestry: MultiLocation = Here.into();
pub UnitWeightCost: Weight = 1_000;
}

Expand Down
19 changes: 5 additions & 14 deletions xcm/pallet-xcm/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn send_works() {
let sender: MultiLocation =
AccountId32 { network: AnyNetwork::get(), id: ALICE.into() }.into();
let message = Xcm::ReserveAssetDeposited {
assets: (X1(Parent), SEND_AMOUNT).into(),
assets: (Parent, SEND_AMOUNT).into(),
effects: vec![
buy_execution((Parent, SEND_AMOUNT), weight),
DepositAsset { assets: All.into(), max_assets: 1, beneficiary: sender.clone() },
Expand All @@ -54,7 +54,7 @@ fn send_works() {
assert_eq!(
sent_xcm(),
vec![(
MultiLocation::Here,
Here.into(),
RelayedFrom { who: sender.clone(), message: Box::new(message.clone()) }
)]
);
Expand Down Expand Up @@ -87,16 +87,7 @@ fn send_fails_when_xcm_router_blocks() {
assert_noop!(
XcmPallet::send(
Origin::signed(ALICE),
Box::new(X8(
Junction::Parent,
Junction::Parent,
Junction::Parent,
Junction::Parent,
Junction::Parent,
Junction::Parent,
Junction::Parent,
Junction::Parent
)),
Box::new(MultiLocation::ancestor(8)),
Box::new(message.clone())
),
crate::Error::<Test>::SendFailure
Expand All @@ -118,7 +109,7 @@ fn teleport_assets_works() {
assert_ok!(XcmPallet::teleport_assets(
Origin::signed(ALICE),
Box::new(RelayLocation::get()),
Box::new(X1(AccountId32 { network: Any, id: BOB.into() })),
Box::new(AccountId32 { network: Any, id: BOB.into() }.into()),
(Here, SEND_AMOUNT).into(),
0,
weight,
Expand Down Expand Up @@ -162,7 +153,7 @@ fn reserve_transfer_assets_works() {
vec![(
Parachain(PARA_ID).into(),
Xcm::ReserveAssetDeposited {
assets: (X1(Parent), SEND_AMOUNT).into(),
assets: (Parent, SEND_AMOUNT).into(),
effects: vec![
buy_execution((Parent, SEND_AMOUNT), weight),
DepositAsset { assets: All.into(), max_assets: 1, beneficiary: dest },
Expand Down
Loading