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

Commit 6e107bc

Browse files
committed
fixes
1 parent 4217749 commit 6e107bc

File tree

7 files changed

+65
-53
lines changed

7 files changed

+65
-53
lines changed

runtime/common/src/paras_registrar.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ pub mod pallet {
103103
/// same type, we just can't express that to the Rust type system without writing a `where`
104104
/// clause everywhere.
105105
type RuntimeOrigin: From<<Self as frame_system::Config>::RuntimeOrigin>
106-
+ Into<result::Result<RuntimeOrigin, <Self as Config>::RuntimeOrigin>>;
106+
+ Into<result::Result<Origin, <Self as Config>::RuntimeOrigin>>;
107107

108108
/// The system's currency for parathread payment.
109109
type Currency: ReservableCurrency<Self::AccountId>;

runtime/parachains/src/hrmp/benchmarking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn establish_para_connection<T: Config>(
6464
from: u32,
6565
to: u32,
6666
until: ParachainSetupStep,
67-
) -> [(ParaId, crate::Origin); 2]
67+
) -> [(ParaId, crate::RuntimeOrigin); 2]
6868
where
6969
<T as frame_system::Config>::RuntimeOrigin: From<crate::RuntimeOrigin>,
7070
{

runtime/parachains/src/origin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ pub use pallet::*;
2626
/// Returns `Ok` with the parachain ID that effected the extrinsic or an `Err` otherwise.
2727
pub fn ensure_parachain<OuterOrigin>(o: OuterOrigin) -> result::Result<ParaId, BadOrigin>
2828
where
29-
OuterOrigin: Into<result::Result<RuntimeOrigin, OuterOrigin>>,
29+
OuterOrigin: Into<result::Result<Origin, OuterOrigin>>,
3030
{
3131
match o.into() {
32-
Ok(Origin::Parachain(id)) => Ok(id),
32+
Ok(RuntimeOrigin::Parachain(id)) => Ok(id),
3333
_ => Err(BadOrigin),
3434
}
3535
}

xcm/pallet-xcm-benchmarks/src/generic/mock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ where
168168
fn convert_origin(
169169
_origin: impl Into<MultiLocation>,
170170
_kind: OriginKind,
171-
) -> Result<RuntimeOrigin, MultiLocation> {
171+
) -> Result<Origin, MultiLocation> {
172172
Ok(RuntimeOrigin::signed(
173173
<RuntimeOrigin as OriginTrait>::AccountId::decode(&mut TrailingZeroInput::zeroes())
174174
.expect("infinite length input; no invalid inputs for type; qed"),

xcm/pallet-xcm/src/lib.rs

+13-14
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub mod pallet {
110110
type LocationInverter: InvertLocation;
111111

112112
/// The outer `Origin` type.
113-
type RuntimeOrigin: From<RuntimeOrigin> + From<<Self as SysConfig>::RuntimeOrigin>;
113+
type RuntimeOrigin: From<Origin> + From<<Self as SysConfig>::RuntimeOrigin>;
114114

115115
/// The outer `Call` type.
116116
type RuntimeCall: Parameter
@@ -1477,10 +1477,10 @@ pub mod pallet {
14771477
/// Returns `Ok` with the location of the XCM sender or an `Err` otherwise.
14781478
pub fn ensure_xcm<OuterOrigin>(o: OuterOrigin) -> Result<MultiLocation, BadOrigin>
14791479
where
1480-
OuterOrigin: Into<Result<RuntimeOrigin, OuterOrigin>>,
1480+
OuterOrigin: Into<Result<Origin, OuterOrigin>>,
14811481
{
14821482
match o.into() {
1483-
Ok(Origin::Xcm(location)) => Ok(location),
1483+
Ok(RuntimeOrigin::Xcm(location)) => Ok(location),
14841484
_ => Err(BadOrigin),
14851485
}
14861486
}
@@ -1490,10 +1490,10 @@ where
14901490
/// Returns `Ok` with the location of the responder or an `Err` otherwise.
14911491
pub fn ensure_response<OuterOrigin>(o: OuterOrigin) -> Result<MultiLocation, BadOrigin>
14921492
where
1493-
OuterOrigin: Into<Result<RuntimeOrigin, OuterOrigin>>,
1493+
OuterOrigin: Into<Result<Origin, OuterOrigin>>,
14941494
{
14951495
match o.into() {
1496-
Ok(Origin::Response(location)) => Ok(location),
1496+
Ok(RuntimeOrigin::Response(location)) => Ok(location),
14971497
_ => Err(BadOrigin),
14981498
}
14991499
}
@@ -1515,36 +1515,35 @@ impl<Prefix: Get<MultiLocation>, Body: Get<BodyId>> Contains<MultiLocation>
15151515
/// `EnsureOrigin` implementation succeeding with a `MultiLocation` value to recognize and filter the
15161516
/// `Origin::Xcm` item.
15171517
pub struct EnsureXcm<F>(PhantomData<F>);
1518-
impl<O: OriginTrait + From<RuntimeOrigin>, F: Contains<MultiLocation>> EnsureOrigin<O>
1519-
for EnsureXcm<F>
1518+
impl<O: OriginTrait + From<Origin>, F: Contains<MultiLocation>> EnsureOrigin<O> for EnsureXcm<F>
15201519
where
1521-
O::PalletsOrigin: From<RuntimeOrigin> + TryInto<RuntimeOrigin, Error = O::PalletsOrigin>,
1520+
O::PalletsOrigin: From<Origin> + TryInto<Origin, Error = O::PalletsOrigin>,
15221521
{
15231522
type Success = MultiLocation;
15241523

15251524
fn try_origin(outer: O) -> Result<Self::Success, O> {
15261525
outer.try_with_caller(|caller| {
15271526
caller.try_into().and_then(|o| match o {
15281527
Origin::Xcm(location) if F::contains(&location) => Ok(location),
1529-
Origin::Xcm(location) => Err(Origin::Xcm(location).into()),
1528+
Origin::Xcm(location) => Err(RuntimeOrigin::Xcm(location).into()),
15301529
o => Err(o.into()),
15311530
})
15321531
})
15331532
}
15341533

15351534
#[cfg(feature = "runtime-benchmarks")]
15361535
fn try_successful_origin() -> Result<O, ()> {
1537-
Ok(O::from(Origin::Xcm(Here.into())))
1536+
Ok(O::from(RuntimeOrigin::Xcm(Here.into())))
15381537
}
15391538
}
15401539

15411540
/// `EnsureOrigin` implementation succeeding with a `MultiLocation` value to recognize and filter
15421541
/// the `Origin::Response` item.
15431542
pub struct EnsureResponse<F>(PhantomData<F>);
1544-
impl<O: OriginTrait + From<RuntimeOrigin>, F: Contains<MultiLocation>> EnsureOrigin<O>
1543+
impl<O: OriginTrait + From<Origin>, F: Contains<MultiLocation>> EnsureOrigin<O>
15451544
for EnsureResponse<F>
15461545
where
1547-
O::PalletsOrigin: From<RuntimeOrigin> + TryInto<RuntimeOrigin, Error = O::PalletsOrigin>,
1546+
O::PalletsOrigin: From<Origin> + TryInto<Origin, Error = O::PalletsOrigin>,
15481547
{
15491548
type Success = MultiLocation;
15501549

@@ -1559,7 +1558,7 @@ where
15591558

15601559
#[cfg(feature = "runtime-benchmarks")]
15611560
fn try_successful_origin() -> Result<O, ()> {
1562-
Ok(O::from(Origin::Response(Here.into())))
1561+
Ok(O::from(RuntimeOrigin::Response(Here.into())))
15631562
}
15641563
}
15651564

@@ -1572,7 +1571,7 @@ impl<RuntimeOrigin: From<crate::RuntimeOrigin>> ConvertOrigin<RuntimeOrigin>
15721571
fn convert_origin(
15731572
origin: impl Into<MultiLocation>,
15741573
kind: OriginKind,
1575-
) -> Result<RuntimeOrigin, MultiLocation> {
1574+
) -> Result<Origin, MultiLocation> {
15761575
let origin = origin.into();
15771576
match kind {
15781577
OriginKind::Xcm => Ok(crate::Origin::Xcm(origin).into()),

xcm/xcm-builder/src/origin_conversion.rs

+46-33
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,19 @@ use xcm_executor::traits::{Convert, ConvertOrigin};
2525

2626
/// Sovereign accounts use the system's `Signed` origin with an account ID derived from the `LocationConverter`.
2727
pub struct SovereignSignedViaLocation<LocationConverter, RuntimeOrigin>(
28-
PhantomData<(LocationConverter, Origin)>,
28+
PhantomData<(LocationConverter, RuntimeOrigin)>,
2929
);
30-
impl<LocationConverter: Convert<MultiLocation, Origin::AccountId>, RuntimeOrigin: OriginTrait>
31-
ConvertOrigin<RuntimeOrigin> for SovereignSignedViaLocation<LocationConverter, RuntimeOrigin>
30+
impl<
31+
LocationConverter: Convert<MultiLocation, RuntimeOrigin::AccountId>,
32+
RuntimeOrigin: OriginTrait,
33+
> ConvertOrigin<RuntimeOrigin> for SovereignSignedViaLocation<LocationConverter, RuntimeOrigin>
3234
where
33-
Origin::AccountId: Clone,
35+
RuntimeOrigin::AccountId: Clone,
3436
{
3537
fn convert_origin(
3638
origin: impl Into<MultiLocation>,
3739
kind: OriginKind,
38-
) -> Result<RuntimeOrigin, MultiLocation> {
40+
) -> Result<Origin, MultiLocation> {
3941
let origin = origin.into();
4042
log::trace!(
4143
target: "xcm::origin_conversion",
@@ -56,7 +58,7 @@ impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin> for ParentAsSuperu
5658
fn convert_origin(
5759
origin: impl Into<MultiLocation>,
5860
kind: OriginKind,
59-
) -> Result<RuntimeOrigin, MultiLocation> {
61+
) -> Result<Origin, MultiLocation> {
6062
let origin = origin.into();
6163
log::trace!(target: "xcm::origin_conversion", "ParentAsSuperuser origin: {:?}, kind: {:?}", origin, kind);
6264
if kind == OriginKind::Superuser && origin.contains_parents_only(1) {
@@ -67,14 +69,16 @@ impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin> for ParentAsSuperu
6769
}
6870
}
6971

70-
pub struct ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>(PhantomData<(ParaId, Origin)>);
72+
pub struct ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>(
73+
PhantomData<(ParaId, RuntimeOrigin)>,
74+
);
7175
impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
7276
for ChildSystemParachainAsSuperuser<ParaId, RuntimeOrigin>
7377
{
7478
fn convert_origin(
7579
origin: impl Into<MultiLocation>,
7680
kind: OriginKind,
77-
) -> Result<RuntimeOrigin, MultiLocation> {
81+
) -> Result<Origin, MultiLocation> {
7882
let origin = origin.into();
7983
log::trace!(target: "xcm::origin_conversion", "ChildSystemParachainAsSuperuser origin: {:?}, kind: {:?}", origin, kind);
8084
match (kind, origin) {
@@ -87,14 +91,16 @@ impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<Run
8791
}
8892
}
8993

90-
pub struct SiblingSystemParachainAsSuperuser<ParaId, RuntimeOrigin>(PhantomData<(ParaId, Origin)>);
94+
pub struct SiblingSystemParachainAsSuperuser<ParaId, RuntimeOrigin>(
95+
PhantomData<(ParaId, RuntimeOrigin)>,
96+
);
9197
impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
9298
for SiblingSystemParachainAsSuperuser<ParaId, RuntimeOrigin>
9399
{
94100
fn convert_origin(
95101
origin: impl Into<MultiLocation>,
96102
kind: OriginKind,
97-
) -> Result<RuntimeOrigin, MultiLocation> {
103+
) -> Result<Origin, MultiLocation> {
98104
let origin = origin.into();
99105
log::trace!(
100106
target: "xcm::origin_conversion",
@@ -112,15 +118,15 @@ impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<Run
112118
}
113119

114120
pub struct ChildParachainAsNative<ParachainOrigin, RuntimeOrigin>(
115-
PhantomData<(ParachainOrigin, Origin)>,
121+
PhantomData<(ParachainOrigin, RuntimeOrigin)>,
116122
);
117123
impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOrigin<RuntimeOrigin>
118124
for ChildParachainAsNative<ParachainOrigin, RuntimeOrigin>
119125
{
120126
fn convert_origin(
121127
origin: impl Into<MultiLocation>,
122128
kind: OriginKind,
123-
) -> Result<RuntimeOrigin, MultiLocation> {
129+
) -> Result<Origin, MultiLocation> {
124130
let origin = origin.into();
125131
log::trace!(target: "xcm::origin_conversion", "ChildParachainAsNative origin: {:?}, kind: {:?}", origin, kind);
126132
match (kind, origin) {
@@ -134,15 +140,15 @@ impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOr
134140
}
135141

136142
pub struct SiblingParachainAsNative<ParachainOrigin, RuntimeOrigin>(
137-
PhantomData<(ParachainOrigin, Origin)>,
143+
PhantomData<(ParachainOrigin, RuntimeOrigin)>,
138144
);
139145
impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOrigin<RuntimeOrigin>
140146
for SiblingParachainAsNative<ParachainOrigin, RuntimeOrigin>
141147
{
142148
fn convert_origin(
143149
origin: impl Into<MultiLocation>,
144150
kind: OriginKind,
145-
) -> Result<RuntimeOrigin, MultiLocation> {
151+
) -> Result<Origin, MultiLocation> {
146152
let origin = origin.into();
147153
log::trace!(
148154
target: "xcm::origin_conversion",
@@ -160,14 +166,16 @@ impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOr
160166
}
161167

162168
// Our Relay-chain has a native origin given by the `Get`ter.
163-
pub struct RelayChainAsNative<RelayOrigin, RuntimeOrigin>(PhantomData<(RelayOrigin, Origin)>);
169+
pub struct RelayChainAsNative<RelayOrigin, RuntimeOrigin>(
170+
PhantomData<(RelayOrigin, RuntimeOrigin)>,
171+
);
164172
impl<RelayOrigin: Get<RuntimeOrigin>, RuntimeOrigin> ConvertOrigin<RuntimeOrigin>
165173
for RelayChainAsNative<RelayOrigin, RuntimeOrigin>
166174
{
167175
fn convert_origin(
168176
origin: impl Into<MultiLocation>,
169177
kind: OriginKind,
170-
) -> Result<RuntimeOrigin, MultiLocation> {
178+
) -> Result<Origin, MultiLocation> {
171179
let origin = origin.into();
172180
log::trace!(target: "xcm::origin_conversion", "RelayChainAsNative origin: {:?}, kind: {:?}", origin, kind);
173181
if kind == OriginKind::Native && origin.contains_parents_only(1) {
@@ -178,16 +186,16 @@ impl<RelayOrigin: Get<RuntimeOrigin>, RuntimeOrigin> ConvertOrigin<RuntimeOrigin
178186
}
179187
}
180188

181-
pub struct SignedAccountId32AsNative<Network, RuntimeOrigin>(PhantomData<(Network, Origin)>);
189+
pub struct SignedAccountId32AsNative<Network, RuntimeOrigin>(PhantomData<(Network, RuntimeOrigin)>);
182190
impl<Network: Get<NetworkId>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
183191
for SignedAccountId32AsNative<Network, RuntimeOrigin>
184192
where
185-
Origin::AccountId: From<[u8; 32]>,
193+
RuntimeOrigin::AccountId: From<[u8; 32]>,
186194
{
187195
fn convert_origin(
188196
origin: impl Into<MultiLocation>,
189197
kind: OriginKind,
190-
) -> Result<RuntimeOrigin, MultiLocation> {
198+
) -> Result<Origin, MultiLocation> {
191199
let origin = origin.into();
192200
log::trace!(
193201
target: "xcm::origin_conversion",
@@ -205,16 +213,18 @@ where
205213
}
206214
}
207215

208-
pub struct SignedAccountKey20AsNative<Network, RuntimeOrigin>(PhantomData<(Network, Origin)>);
216+
pub struct SignedAccountKey20AsNative<Network, RuntimeOrigin>(
217+
PhantomData<(Network, RuntimeOrigin)>,
218+
);
209219
impl<Network: Get<NetworkId>, RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin>
210220
for SignedAccountKey20AsNative<Network, RuntimeOrigin>
211221
where
212-
Origin::AccountId: From<[u8; 20]>,
222+
RuntimeOrigin::AccountId: From<[u8; 20]>,
213223
{
214224
fn convert_origin(
215225
origin: impl Into<MultiLocation>,
216226
kind: OriginKind,
217-
) -> Result<RuntimeOrigin, MultiLocation> {
227+
) -> Result<Origin, MultiLocation> {
218228
let origin = origin.into();
219229
log::trace!(
220230
target: "xcm::origin_conversion",
@@ -233,14 +243,14 @@ where
233243
}
234244

235245
/// `EnsureOrigin` barrier to convert from dispatch origin to XCM origin, if one exists.
236-
pub struct EnsureXcmOrigin<RuntimeOrigin, Conversion>(PhantomData<(Origin, Conversion)>);
246+
pub struct EnsureXcmOrigin<RuntimeOrigin, Conversion>(PhantomData<(RuntimeOrigin, Conversion)>);
237247
impl<RuntimeOrigin: OriginTrait + Clone, Conversion: Convert<RuntimeOrigin, MultiLocation>>
238248
EnsureOrigin<RuntimeOrigin> for EnsureXcmOrigin<RuntimeOrigin, Conversion>
239249
where
240-
Origin::PalletsOrigin: PartialEq,
250+
RuntimeOrigin::PalletsOrigin: PartialEq,
241251
{
242252
type Success = MultiLocation;
243-
fn try_origin(o: Origin) -> Result<Self::Success, RuntimeOrigin> {
253+
fn try_origin(o: RuntimeOrigin) -> Result<Self::Success, RuntimeOrigin> {
244254
let o = match Conversion::convert(o) {
245255
Ok(location) => return Ok(location),
246256
Err(o) => o,
@@ -255,7 +265,7 @@ where
255265
}
256266

257267
#[cfg(feature = "runtime-benchmarks")]
258-
fn try_successful_origin() -> Result<RuntimeOrigin, ()> {
268+
fn try_successful_origin() -> Result<Origin, ()> {
259269
Ok(RuntimeOrigin::root())
260270
}
261271
}
@@ -265,15 +275,15 @@ where
265275
/// Typically used when configuring `pallet-xcm` for allowing normal accounts to dispatch an XCM from an `AccountId32`
266276
/// origin.
267277
pub struct SignedToAccountId32<RuntimeOrigin, AccountId, Network>(
268-
PhantomData<(Origin, AccountId, Network)>,
278+
PhantomData<(RuntimeOrigin, AccountId, Network)>,
269279
);
270280
impl<RuntimeOrigin: OriginTrait + Clone, AccountId: Into<[u8; 32]>, Network: Get<NetworkId>>
271281
Convert<RuntimeOrigin, MultiLocation> for SignedToAccountId32<RuntimeOrigin, AccountId, Network>
272282
where
273-
Origin::PalletsOrigin: From<SystemRawOrigin<AccountId>>
274-
+ TryInto<SystemRawOrigin<AccountId>, Error = Origin::PalletsOrigin>,
283+
RuntimeOrigin::PalletsOrigin: From<SystemRawOrigin<AccountId>>
284+
+ TryInto<SystemRawOrigin<AccountId>, Error = RuntimeOrigin::PalletsOrigin>,
275285
{
276-
fn convert(o: Origin) -> Result<MultiLocation, RuntimeOrigin> {
286+
fn convert(o: RuntimeOrigin) -> Result<MultiLocation, RuntimeOrigin> {
277287
o.try_with_caller(|caller| match caller.try_into() {
278288
Ok(SystemRawOrigin::Signed(who)) =>
279289
Ok(Junction::AccountId32 { network: Network::get(), id: who.into() }.into()),
@@ -288,13 +298,16 @@ where
288298
///
289299
/// Typically used when configuring `pallet-xcm` for allowing a collective's Origin to dispatch an XCM from a
290300
/// `Plurality` origin.
291-
pub struct BackingToPlurality<RuntimeOrigin, COrigin, Body>(PhantomData<(Origin, COrigin, Body)>);
301+
pub struct BackingToPlurality<RuntimeOrigin, COrigin, Body>(
302+
PhantomData<(RuntimeOrigin, COrigin, Body)>,
303+
);
292304
impl<RuntimeOrigin: OriginTrait + Clone, COrigin: GetBacking, Body: Get<BodyId>>
293305
Convert<RuntimeOrigin, MultiLocation> for BackingToPlurality<RuntimeOrigin, COrigin, Body>
294306
where
295-
Origin::PalletsOrigin: From<COrigin> + TryInto<COrigin, Error = Origin::PalletsOrigin>,
307+
RuntimeOrigin::PalletsOrigin:
308+
From<COrigin> + TryInto<COrigin, Error = RuntimeOrigin::PalletsOrigin>,
296309
{
297-
fn convert(o: Origin) -> Result<MultiLocation, RuntimeOrigin> {
310+
fn convert(o: RuntimeOrigin) -> Result<MultiLocation, RuntimeOrigin> {
298311
o.try_with_caller(|caller| match caller.try_into() {
299312
Ok(co) => match co.get_backing() {
300313
Some(backing) => Ok(Junction::Plurality {

xcm/xcm-executor/src/traits/conversion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ pub trait ConvertOrigin<RuntimeOrigin> {
178178
fn convert_origin(
179179
origin: impl Into<MultiLocation>,
180180
kind: OriginKind,
181-
) -> Result<RuntimeOrigin, MultiLocation>;
181+
) -> Result<Origin, MultiLocation>;
182182
}
183183

184184
#[impl_trait_for_tuples::impl_for_tuples(30)]

0 commit comments

Comments
 (0)