@@ -25,17 +25,19 @@ use xcm_executor::traits::{Convert, ConvertOrigin};
25
25
26
26
/// Sovereign accounts use the system's `Signed` origin with an account ID derived from the `LocationConverter`.
27
27
pub struct SovereignSignedViaLocation < LocationConverter , RuntimeOrigin > (
28
- PhantomData < ( LocationConverter , Origin ) > ,
28
+ PhantomData < ( LocationConverter , RuntimeOrigin ) > ,
29
29
) ;
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 >
32
34
where
33
- Origin :: AccountId : Clone ,
35
+ RuntimeOrigin :: AccountId : Clone ,
34
36
{
35
37
fn convert_origin (
36
38
origin : impl Into < MultiLocation > ,
37
39
kind : OriginKind ,
38
- ) -> Result < RuntimeOrigin , MultiLocation > {
40
+ ) -> Result < Origin , MultiLocation > {
39
41
let origin = origin. into ( ) ;
40
42
log:: trace!(
41
43
target: "xcm::origin_conversion" ,
@@ -56,7 +58,7 @@ impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin> for ParentAsSuperu
56
58
fn convert_origin (
57
59
origin : impl Into < MultiLocation > ,
58
60
kind : OriginKind ,
59
- ) -> Result < RuntimeOrigin , MultiLocation > {
61
+ ) -> Result < Origin , MultiLocation > {
60
62
let origin = origin. into ( ) ;
61
63
log:: trace!( target: "xcm::origin_conversion" , "ParentAsSuperuser origin: {:?}, kind: {:?}" , origin, kind) ;
62
64
if kind == OriginKind :: Superuser && origin. contains_parents_only ( 1 ) {
@@ -67,14 +69,16 @@ impl<RuntimeOrigin: OriginTrait> ConvertOrigin<RuntimeOrigin> for ParentAsSuperu
67
69
}
68
70
}
69
71
70
- pub struct ChildSystemParachainAsSuperuser < ParaId , RuntimeOrigin > ( PhantomData < ( ParaId , Origin ) > ) ;
72
+ pub struct ChildSystemParachainAsSuperuser < ParaId , RuntimeOrigin > (
73
+ PhantomData < ( ParaId , RuntimeOrigin ) > ,
74
+ ) ;
71
75
impl < ParaId : IsSystem + From < u32 > , RuntimeOrigin : OriginTrait > ConvertOrigin < RuntimeOrigin >
72
76
for ChildSystemParachainAsSuperuser < ParaId , RuntimeOrigin >
73
77
{
74
78
fn convert_origin (
75
79
origin : impl Into < MultiLocation > ,
76
80
kind : OriginKind ,
77
- ) -> Result < RuntimeOrigin , MultiLocation > {
81
+ ) -> Result < Origin , MultiLocation > {
78
82
let origin = origin. into ( ) ;
79
83
log:: trace!( target: "xcm::origin_conversion" , "ChildSystemParachainAsSuperuser origin: {:?}, kind: {:?}" , origin, kind) ;
80
84
match ( kind, origin) {
@@ -87,14 +91,16 @@ impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<Run
87
91
}
88
92
}
89
93
90
- pub struct SiblingSystemParachainAsSuperuser < ParaId , RuntimeOrigin > ( PhantomData < ( ParaId , Origin ) > ) ;
94
+ pub struct SiblingSystemParachainAsSuperuser < ParaId , RuntimeOrigin > (
95
+ PhantomData < ( ParaId , RuntimeOrigin ) > ,
96
+ ) ;
91
97
impl < ParaId : IsSystem + From < u32 > , RuntimeOrigin : OriginTrait > ConvertOrigin < RuntimeOrigin >
92
98
for SiblingSystemParachainAsSuperuser < ParaId , RuntimeOrigin >
93
99
{
94
100
fn convert_origin (
95
101
origin : impl Into < MultiLocation > ,
96
102
kind : OriginKind ,
97
- ) -> Result < RuntimeOrigin , MultiLocation > {
103
+ ) -> Result < Origin , MultiLocation > {
98
104
let origin = origin. into ( ) ;
99
105
log:: trace!(
100
106
target: "xcm::origin_conversion" ,
@@ -112,15 +118,15 @@ impl<ParaId: IsSystem + From<u32>, RuntimeOrigin: OriginTrait> ConvertOrigin<Run
112
118
}
113
119
114
120
pub struct ChildParachainAsNative < ParachainOrigin , RuntimeOrigin > (
115
- PhantomData < ( ParachainOrigin , Origin ) > ,
121
+ PhantomData < ( ParachainOrigin , RuntimeOrigin ) > ,
116
122
) ;
117
123
impl < ParachainOrigin : From < u32 > , RuntimeOrigin : From < ParachainOrigin > > ConvertOrigin < RuntimeOrigin >
118
124
for ChildParachainAsNative < ParachainOrigin , RuntimeOrigin >
119
125
{
120
126
fn convert_origin (
121
127
origin : impl Into < MultiLocation > ,
122
128
kind : OriginKind ,
123
- ) -> Result < RuntimeOrigin , MultiLocation > {
129
+ ) -> Result < Origin , MultiLocation > {
124
130
let origin = origin. into ( ) ;
125
131
log:: trace!( target: "xcm::origin_conversion" , "ChildParachainAsNative origin: {:?}, kind: {:?}" , origin, kind) ;
126
132
match ( kind, origin) {
@@ -134,15 +140,15 @@ impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOr
134
140
}
135
141
136
142
pub struct SiblingParachainAsNative < ParachainOrigin , RuntimeOrigin > (
137
- PhantomData < ( ParachainOrigin , Origin ) > ,
143
+ PhantomData < ( ParachainOrigin , RuntimeOrigin ) > ,
138
144
) ;
139
145
impl < ParachainOrigin : From < u32 > , RuntimeOrigin : From < ParachainOrigin > > ConvertOrigin < RuntimeOrigin >
140
146
for SiblingParachainAsNative < ParachainOrigin , RuntimeOrigin >
141
147
{
142
148
fn convert_origin (
143
149
origin : impl Into < MultiLocation > ,
144
150
kind : OriginKind ,
145
- ) -> Result < RuntimeOrigin , MultiLocation > {
151
+ ) -> Result < Origin , MultiLocation > {
146
152
let origin = origin. into ( ) ;
147
153
log:: trace!(
148
154
target: "xcm::origin_conversion" ,
@@ -160,14 +166,16 @@ impl<ParachainOrigin: From<u32>, RuntimeOrigin: From<ParachainOrigin>> ConvertOr
160
166
}
161
167
162
168
// 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
+ ) ;
164
172
impl < RelayOrigin : Get < RuntimeOrigin > , RuntimeOrigin > ConvertOrigin < RuntimeOrigin >
165
173
for RelayChainAsNative < RelayOrigin , RuntimeOrigin >
166
174
{
167
175
fn convert_origin (
168
176
origin : impl Into < MultiLocation > ,
169
177
kind : OriginKind ,
170
- ) -> Result < RuntimeOrigin , MultiLocation > {
178
+ ) -> Result < Origin , MultiLocation > {
171
179
let origin = origin. into ( ) ;
172
180
log:: trace!( target: "xcm::origin_conversion" , "RelayChainAsNative origin: {:?}, kind: {:?}" , origin, kind) ;
173
181
if kind == OriginKind :: Native && origin. contains_parents_only ( 1 ) {
@@ -178,16 +186,16 @@ impl<RelayOrigin: Get<RuntimeOrigin>, RuntimeOrigin> ConvertOrigin<RuntimeOrigin
178
186
}
179
187
}
180
188
181
- pub struct SignedAccountId32AsNative < Network , RuntimeOrigin > ( PhantomData < ( Network , Origin ) > ) ;
189
+ pub struct SignedAccountId32AsNative < Network , RuntimeOrigin > ( PhantomData < ( Network , RuntimeOrigin ) > ) ;
182
190
impl < Network : Get < NetworkId > , RuntimeOrigin : OriginTrait > ConvertOrigin < RuntimeOrigin >
183
191
for SignedAccountId32AsNative < Network , RuntimeOrigin >
184
192
where
185
- Origin :: AccountId : From < [ u8 ; 32 ] > ,
193
+ RuntimeOrigin :: AccountId : From < [ u8 ; 32 ] > ,
186
194
{
187
195
fn convert_origin (
188
196
origin : impl Into < MultiLocation > ,
189
197
kind : OriginKind ,
190
- ) -> Result < RuntimeOrigin , MultiLocation > {
198
+ ) -> Result < Origin , MultiLocation > {
191
199
let origin = origin. into ( ) ;
192
200
log:: trace!(
193
201
target: "xcm::origin_conversion" ,
@@ -205,16 +213,18 @@ where
205
213
}
206
214
}
207
215
208
- pub struct SignedAccountKey20AsNative < Network , RuntimeOrigin > ( PhantomData < ( Network , Origin ) > ) ;
216
+ pub struct SignedAccountKey20AsNative < Network , RuntimeOrigin > (
217
+ PhantomData < ( Network , RuntimeOrigin ) > ,
218
+ ) ;
209
219
impl < Network : Get < NetworkId > , RuntimeOrigin : OriginTrait > ConvertOrigin < RuntimeOrigin >
210
220
for SignedAccountKey20AsNative < Network , RuntimeOrigin >
211
221
where
212
- Origin :: AccountId : From < [ u8 ; 20 ] > ,
222
+ RuntimeOrigin :: AccountId : From < [ u8 ; 20 ] > ,
213
223
{
214
224
fn convert_origin (
215
225
origin : impl Into < MultiLocation > ,
216
226
kind : OriginKind ,
217
- ) -> Result < RuntimeOrigin , MultiLocation > {
227
+ ) -> Result < Origin , MultiLocation > {
218
228
let origin = origin. into ( ) ;
219
229
log:: trace!(
220
230
target: "xcm::origin_conversion" ,
@@ -233,14 +243,14 @@ where
233
243
}
234
244
235
245
/// `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 ) > ) ;
237
247
impl < RuntimeOrigin : OriginTrait + Clone , Conversion : Convert < RuntimeOrigin , MultiLocation > >
238
248
EnsureOrigin < RuntimeOrigin > for EnsureXcmOrigin < RuntimeOrigin , Conversion >
239
249
where
240
- Origin :: PalletsOrigin : PartialEq ,
250
+ RuntimeOrigin :: PalletsOrigin : PartialEq ,
241
251
{
242
252
type Success = MultiLocation ;
243
- fn try_origin ( o : Origin ) -> Result < Self :: Success , RuntimeOrigin > {
253
+ fn try_origin ( o : RuntimeOrigin ) -> Result < Self :: Success , RuntimeOrigin > {
244
254
let o = match Conversion :: convert ( o) {
245
255
Ok ( location) => return Ok ( location) ,
246
256
Err ( o) => o,
@@ -255,7 +265,7 @@ where
255
265
}
256
266
257
267
#[ cfg( feature = "runtime-benchmarks" ) ]
258
- fn try_successful_origin ( ) -> Result < RuntimeOrigin , ( ) > {
268
+ fn try_successful_origin ( ) -> Result < Origin , ( ) > {
259
269
Ok ( RuntimeOrigin :: root ( ) )
260
270
}
261
271
}
@@ -265,15 +275,15 @@ where
265
275
/// Typically used when configuring `pallet-xcm` for allowing normal accounts to dispatch an XCM from an `AccountId32`
266
276
/// origin.
267
277
pub struct SignedToAccountId32 < RuntimeOrigin , AccountId , Network > (
268
- PhantomData < ( Origin , AccountId , Network ) > ,
278
+ PhantomData < ( RuntimeOrigin , AccountId , Network ) > ,
269
279
) ;
270
280
impl < RuntimeOrigin : OriginTrait + Clone , AccountId : Into < [ u8 ; 32 ] > , Network : Get < NetworkId > >
271
281
Convert < RuntimeOrigin , MultiLocation > for SignedToAccountId32 < RuntimeOrigin , AccountId , Network >
272
282
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 > ,
275
285
{
276
- fn convert ( o : Origin ) -> Result < MultiLocation , RuntimeOrigin > {
286
+ fn convert ( o : RuntimeOrigin ) -> Result < MultiLocation , RuntimeOrigin > {
277
287
o. try_with_caller ( |caller| match caller. try_into ( ) {
278
288
Ok ( SystemRawOrigin :: Signed ( who) ) =>
279
289
Ok ( Junction :: AccountId32 { network : Network :: get ( ) , id : who. into ( ) } . into ( ) ) ,
@@ -288,13 +298,16 @@ where
288
298
///
289
299
/// Typically used when configuring `pallet-xcm` for allowing a collective's Origin to dispatch an XCM from a
290
300
/// `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
+ ) ;
292
304
impl < RuntimeOrigin : OriginTrait + Clone , COrigin : GetBacking , Body : Get < BodyId > >
293
305
Convert < RuntimeOrigin , MultiLocation > for BackingToPlurality < RuntimeOrigin , COrigin , Body >
294
306
where
295
- Origin :: PalletsOrigin : From < COrigin > + TryInto < COrigin , Error = Origin :: PalletsOrigin > ,
307
+ RuntimeOrigin :: PalletsOrigin :
308
+ From < COrigin > + TryInto < COrigin , Error = RuntimeOrigin :: PalletsOrigin > ,
296
309
{
297
- fn convert ( o : Origin ) -> Result < MultiLocation , RuntimeOrigin > {
310
+ fn convert ( o : RuntimeOrigin ) -> Result < MultiLocation , RuntimeOrigin > {
298
311
o. try_with_caller ( |caller| match caller. try_into ( ) {
299
312
Ok ( co) => match co. get_backing ( ) {
300
313
Some ( backing) => Ok ( Junction :: Plurality {
0 commit comments