mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 08:11:03 +00:00
change junction parachain id from named field to unnamed field (#2940)
* use unnamed field for parachain variant in junction * remove outdated comment
This commit is contained in:
committed by
GitHub
parent
55c1f7ea92
commit
41e57c4509
@@ -27,7 +27,7 @@ pub struct ChildParachainRouter<T>(PhantomData<T>);
|
||||
impl<T: configuration::Config + dmp::Config> SendXcm for ChildParachainRouter<T> {
|
||||
fn send_xcm(dest: MultiLocation, msg: Xcm) -> Result {
|
||||
match dest {
|
||||
MultiLocation::X1(Junction::Parachain { id }) => {
|
||||
MultiLocation::X1(Junction::Parachain(id)) => {
|
||||
// Downward message passing.
|
||||
let config = <configuration::Module<T>>::config();
|
||||
<dmp::Module<T>>::queue_downward_message(
|
||||
|
||||
@@ -69,7 +69,7 @@ impl<XcmExecutor: xcm::v0::ExecuteXcm<Call>, Call> UmpSink for XcmSink<XcmExecut
|
||||
if let Ok(versioned_xcm_message) = VersionedXcm::decode(&mut msg) {
|
||||
match versioned_xcm_message {
|
||||
VersionedXcm::V0(xcm_message) => {
|
||||
let xcm_junction: Junction = Junction::Parachain { id: origin.into() };
|
||||
let xcm_junction: Junction = Junction::Parachain(origin.into());
|
||||
let xcm_location: MultiLocation = xcm_junction.into();
|
||||
match XcmExecutor::execute_xcm(xcm_location, xcm_message, max_weight) {
|
||||
Outcome::Complete(w) | Outcome::Incomplete(w, _) => Some(w),
|
||||
|
||||
@@ -603,13 +603,13 @@ pub type XcmRouter = (
|
||||
use xcm::v0::{MultiAsset, MultiAsset::AllConcreteFungible, MultiLocation::{Null, X1}, Junction::Parachain};
|
||||
parameter_types! {
|
||||
pub const RococoForTick: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain{id: 100}));
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(100)));
|
||||
pub const RococoForTrick: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain{id: 110}));
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(110)));
|
||||
pub const RococoForTrack: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain{id: 120}));
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(120)));
|
||||
pub const RococoForStatemint: (MultiAsset, MultiLocation) =
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain{id: 1}));
|
||||
(AllConcreteFungible { id: Null }, X1(Parachain(1)));
|
||||
}
|
||||
pub type TrustedTeleporters = (
|
||||
xcm_builder::Case<RococoForTick>,
|
||||
@@ -621,10 +621,10 @@ pub type TrustedTeleporters = (
|
||||
parameter_types! {
|
||||
pub AllowUnpaidFrom: Vec<MultiLocation> =
|
||||
vec![
|
||||
X1(Parachain{id: 100}),
|
||||
X1(Parachain{id: 110}),
|
||||
X1(Parachain{id: 120}),
|
||||
X1(Parachain{id: 1})
|
||||
X1(Parachain(100)),
|
||||
X1(Parachain(110)),
|
||||
X1(Parachain(120)),
|
||||
X1(Parachain(1))
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -94,11 +94,7 @@ pub enum Junction {
|
||||
/// An indexed parachain belonging to and operated by the context.
|
||||
///
|
||||
/// Generally used when the context is a Polkadot Relay-chain.
|
||||
///
|
||||
/// There is also `Parachain` which can be used in tests to avoid the faffy `{ id: ... }` syntax. Production
|
||||
/// code should use this.
|
||||
// TODO: parity-scale-codec#262: Change to be `Parachain(#[codec(compact)] u32)`
|
||||
Parachain { #[codec(compact)] id: u32 },
|
||||
Parachain(#[codec(compact)] u32),
|
||||
/// A 32-byte identifier for an account of a specific network that is respected as a sovereign endpoint within
|
||||
/// the context.
|
||||
///
|
||||
@@ -148,7 +144,7 @@ impl Junction {
|
||||
match self {
|
||||
Junction::Parent => false,
|
||||
|
||||
Junction::Parachain { .. }
|
||||
Junction::Parachain(..)
|
||||
| Junction::AccountId32 { .. }
|
||||
| Junction::AccountIndex64 { .. }
|
||||
| Junction::AccountKey20 { .. }
|
||||
|
||||
@@ -64,7 +64,7 @@ impl<
|
||||
AccountId: Clone,
|
||||
> Convert<MultiLocation, AccountId> for ChildParachainConvertsVia<ParaId, AccountId> {
|
||||
fn convert_ref(location: impl Borrow<MultiLocation>) -> Result<AccountId, ()> {
|
||||
if let &MultiLocation::X1(Junction::Parachain { id }) = location.borrow() {
|
||||
if let &MultiLocation::X1(Junction::Parachain(id)) = location.borrow() {
|
||||
Ok(ParaId::from(id).into_account())
|
||||
} else {
|
||||
Err(())
|
||||
@@ -73,7 +73,7 @@ impl<
|
||||
|
||||
fn reverse_ref(who: impl Borrow<AccountId>) -> Result<MultiLocation, ()> {
|
||||
if let Some(id) = ParaId::try_from_account(who.borrow()) {
|
||||
Ok(Junction::Parachain { id: id.into() }.into())
|
||||
Ok(Junction::Parachain(id.into()).into())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
@@ -87,7 +87,7 @@ impl<
|
||||
AccountId: Clone,
|
||||
> Convert<MultiLocation, AccountId> for SiblingParachainConvertsVia<ParaId, AccountId> {
|
||||
fn convert_ref(location: impl Borrow<MultiLocation>) -> Result<AccountId, ()> {
|
||||
if let &MultiLocation::X2(Junction::Parent, Junction::Parachain { id }) = location.borrow() {
|
||||
if let &MultiLocation::X2(Junction::Parent, Junction::Parachain(id)) = location.borrow() {
|
||||
Ok(ParaId::from(id).into_account())
|
||||
} else {
|
||||
Err(())
|
||||
@@ -96,7 +96,7 @@ impl<
|
||||
|
||||
fn reverse_ref(who: impl Borrow<AccountId>) -> Result<MultiLocation, ()> {
|
||||
if let Some(id) = ParaId::try_from_account(who.borrow()) {
|
||||
Ok([Junction::Parent, Junction::Parachain { id: id.into() }].into())
|
||||
Ok([Junction::Parent, Junction::Parachain(id.into())].into())
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
|
||||
@@ -144,11 +144,11 @@ impl TransactAsset for TestAssetTransactor {
|
||||
pub fn to_account(l: MultiLocation) -> Result<u64, MultiLocation> {
|
||||
Ok(match l {
|
||||
// Siblings at 2000+id
|
||||
X2(Parent, Parachain { id }) => 2000 + id as u64,
|
||||
X2(Parent, Parachain(id)) => 2000 + id as u64,
|
||||
// Accounts are their number
|
||||
X1(AccountIndex64 { index, .. }) => index,
|
||||
// Children at 1000+id
|
||||
X1(Parachain { id }) => 1000 + id as u64,
|
||||
X1(Parachain(id)) => 1000 + id as u64,
|
||||
// Self at 3000
|
||||
Null => 3000,
|
||||
// Parent at 3000
|
||||
@@ -160,11 +160,11 @@ pub fn to_account(l: MultiLocation) -> Result<u64, MultiLocation> {
|
||||
pub struct TestOriginConverter;
|
||||
impl ConvertOrigin<TestOrigin> for TestOriginConverter {
|
||||
fn convert_origin(origin: MultiLocation, kind: OriginKind) -> Result<TestOrigin, MultiLocation> {
|
||||
use {OriginKind::*};
|
||||
use OriginKind::*;
|
||||
match (kind, origin) {
|
||||
(Superuser, _) => Ok(TestOrigin::Root),
|
||||
(SovereignAccount, l) => Ok(TestOrigin::Signed(to_account(l)?)),
|
||||
(Native, X1(Parachain { id })) => Ok(TestOrigin::Parachain(id)),
|
||||
(Native, X1(Parachain(id))) => Ok(TestOrigin::Parachain(id)),
|
||||
(Native, X1(Parent)) => Ok(TestOrigin::Relay),
|
||||
(Native, X1(AccountIndex64 {index, ..})) => Ok(TestOrigin::Signed(index)),
|
||||
(_, origin) => Err(origin),
|
||||
@@ -243,7 +243,7 @@ pub fn response(query_id: u64) -> Option<Response> {
|
||||
}
|
||||
|
||||
parameter_types! {
|
||||
pub TestAncestry: MultiLocation = X1(Parachain{id: 42});
|
||||
pub TestAncestry: MultiLocation = X1(Parachain(42));
|
||||
pub UnitWeightCost: Weight = 10;
|
||||
}
|
||||
parameter_types! {
|
||||
|
||||
@@ -60,7 +60,7 @@ impl<
|
||||
> ConvertOrigin<Origin> for ChildSystemParachainAsSuperuser<ParaId, Origin> {
|
||||
fn convert_origin(origin: MultiLocation, kind: OriginKind) -> Result<Origin, MultiLocation> {
|
||||
match (kind, origin) {
|
||||
(OriginKind::Superuser, MultiLocation::X1(Junction::Parachain { id }))
|
||||
(OriginKind::Superuser, MultiLocation::X1(Junction::Parachain(id)))
|
||||
if ParaId::from(id).is_system() =>
|
||||
Ok(Origin::root()),
|
||||
(_, origin) => Err(origin),
|
||||
@@ -75,7 +75,7 @@ impl<
|
||||
> ConvertOrigin<Origin> for SiblingSystemParachainAsSuperuser<ParaId, Origin> {
|
||||
fn convert_origin(origin: MultiLocation, kind: OriginKind) -> Result<Origin, MultiLocation> {
|
||||
match (kind, origin) {
|
||||
(OriginKind::Superuser, MultiLocation::X2(Junction::Parent, Junction::Parachain { id }))
|
||||
(OriginKind::Superuser, MultiLocation::X2(Junction::Parent, Junction::Parachain(id)))
|
||||
if ParaId::from(id).is_system() =>
|
||||
Ok(Origin::root()),
|
||||
(_, origin) => Err(origin),
|
||||
@@ -92,7 +92,7 @@ impl<
|
||||
> ConvertOrigin<Origin> for ChildParachainAsNative<ParachainOrigin, Origin> {
|
||||
fn convert_origin(origin: MultiLocation, kind: OriginKind) -> Result<Origin, MultiLocation> {
|
||||
match (kind, origin) {
|
||||
(OriginKind::Native, MultiLocation::X1(Junction::Parachain { id }))
|
||||
(OriginKind::Native, MultiLocation::X1(Junction::Parachain(id)))
|
||||
=> Ok(Origin::from(ParachainOrigin::from(id))),
|
||||
(_, origin) => Err(origin),
|
||||
}
|
||||
@@ -108,7 +108,7 @@ impl<
|
||||
> ConvertOrigin<Origin> for SiblingParachainAsNative<ParachainOrigin, Origin> {
|
||||
fn convert_origin(origin: MultiLocation, kind: OriginKind) -> Result<Origin, MultiLocation> {
|
||||
match (kind, origin) {
|
||||
(OriginKind::Native, MultiLocation::X2(Junction::Parent, Junction::Parachain { id }))
|
||||
(OriginKind::Native, MultiLocation::X2(Junction::Parent, Junction::Parachain(id)))
|
||||
=> Ok(Origin::from(ParachainOrigin::from(id))),
|
||||
(_, origin) => Err(origin),
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ fn basic_setup_works() {
|
||||
&X1(Parent),
|
||||
));
|
||||
|
||||
assert_eq!(to_account(X1(Parachain{id:1})), Ok(1001));
|
||||
assert_eq!(to_account(X1(Parachain{id:50})), Ok(1050));
|
||||
assert_eq!(to_account(X2(Parent, Parachain{id:1})), Ok(2001));
|
||||
assert_eq!(to_account(X2(Parent, Parachain{id:50})), Ok(2050));
|
||||
assert_eq!(to_account(X1(Parachain(1))), Ok(1001));
|
||||
assert_eq!(to_account(X1(Parachain(50))), Ok(1050));
|
||||
assert_eq!(to_account(X2(Parent, Parachain(1))), Ok(2001));
|
||||
assert_eq!(to_account(X2(Parent, Parachain(50))), Ok(2050));
|
||||
assert_eq!(to_account(X1(AccountIndex64{index:1, network:Any})), Ok(1));
|
||||
assert_eq!(to_account(X1(AccountIndex64{index:42, network:Any})), Ok(42));
|
||||
assert_eq!(to_account(Null), Ok(3000));
|
||||
@@ -88,7 +88,7 @@ fn allow_unpaid_should_work() {
|
||||
AllowUnpaidFrom::set(vec![ X1(Parent) ]);
|
||||
|
||||
let r = AllowUnpaidExecutionFrom::<IsInVec<AllowUnpaidFrom>>::should_execute(
|
||||
&X1(Parachain { id: 1 }),
|
||||
&X1(Parachain(1)),
|
||||
true,
|
||||
&mut message,
|
||||
10,
|
||||
@@ -116,7 +116,7 @@ fn allow_paid_should_work() {
|
||||
};
|
||||
|
||||
let r = AllowTopLevelPaidExecutionFrom::<IsInVec<AllowPaidFrom>>::should_execute(
|
||||
&X1(Parachain { id: 1 }),
|
||||
&X1(Parachain(1)),
|
||||
true,
|
||||
&mut message,
|
||||
10,
|
||||
@@ -150,7 +150,7 @@ fn allow_paid_should_work() {
|
||||
};
|
||||
|
||||
let r = AllowTopLevelPaidExecutionFrom::<IsInVec<AllowPaidFrom>>::should_execute(
|
||||
&X1(Parachain { id: 1 }),
|
||||
&X1(Parachain(1)),
|
||||
true,
|
||||
&mut paying_message,
|
||||
30,
|
||||
@@ -191,12 +191,12 @@ fn paying_reserve_deposit_should_work() {
|
||||
#[test]
|
||||
fn transfer_should_work() {
|
||||
// we'll let them have message execution for free.
|
||||
AllowUnpaidFrom::set(vec![ X1(Parachain{id:1}) ]);
|
||||
AllowUnpaidFrom::set(vec![ X1(Parachain(1)) ]);
|
||||
// Child parachain #1 owns 1000 tokens held by us in reserve.
|
||||
add_asset(1001, ConcreteFungible { id: Null, amount: 1000 });
|
||||
// They want to transfer 100 of them to their sibling parachain #2
|
||||
let r = XcmExecutor::<TestConfig>::execute_xcm(
|
||||
X1(Parachain{id:1}),
|
||||
X1(Parachain(1)),
|
||||
Xcm::TransferAsset {
|
||||
assets: vec![ ConcreteFungible { id: Null, amount: 100 } ],
|
||||
dest: X1(AccountIndex64{index:3, network:Any}),
|
||||
@@ -211,7 +211,7 @@ fn transfer_should_work() {
|
||||
|
||||
#[test]
|
||||
fn reserve_transfer_should_work() {
|
||||
AllowUnpaidFrom::set(vec![ X1(Parachain{id:1}) ]);
|
||||
AllowUnpaidFrom::set(vec![ X1(Parachain(1)) ]);
|
||||
// Child parachain #1 owns 1000 tokens held by us in reserve.
|
||||
add_asset(1001, ConcreteFungible { id: Null, amount: 1000 });
|
||||
// The remote account owned by gav.
|
||||
@@ -220,10 +220,10 @@ fn reserve_transfer_should_work() {
|
||||
// They want to transfer 100 of our native asset from sovereign account of parachain #1 into #2
|
||||
// and let them know to hand it to account #3.
|
||||
let r = XcmExecutor::<TestConfig>::execute_xcm(
|
||||
X1(Parachain{id:1}),
|
||||
X1(Parachain(1)),
|
||||
Xcm::TransferReserveAsset {
|
||||
assets: vec![ ConcreteFungible { id: Null, amount: 100 } ],
|
||||
dest: X1(Parachain{id:2}),
|
||||
dest: X1(Parachain(2)),
|
||||
effects: vec![ Order::DepositAsset { assets: vec![ All ], dest: three.clone() } ],
|
||||
},
|
||||
50,
|
||||
@@ -232,7 +232,7 @@ fn reserve_transfer_should_work() {
|
||||
|
||||
assert_eq!(assets(1002), vec![ ConcreteFungible { id: Null, amount: 100 } ]);
|
||||
assert_eq!(sent_xcm(), vec![(
|
||||
X1(Parachain { id: 2 }),
|
||||
X1(Parachain(2)),
|
||||
Xcm::ReserveAssetDeposit {
|
||||
assets: vec![ ConcreteFungible { id: X1(Parent), amount: 100 } ],
|
||||
effects: vec![ Order::DepositAsset { assets: vec![ All ], dest: three } ],
|
||||
|
||||
Reference in New Issue
Block a user