@@ -26,7 +26,7 @@ pub use std::{
26
26
// Substrate
27
27
pub use frame_support:: {
28
28
assert_ok,
29
- sp_runtime:: { traits:: Header as HeaderT , AccountId32 , DispatchResult } ,
29
+ sp_runtime:: { traits:: Header as HeaderT , DispatchResult } ,
30
30
traits:: {
31
31
EnqueueMessage , Get , Hooks , OriginTrait , ProcessMessage , ProcessMessageError , ServiceQueues ,
32
32
} ,
@@ -61,6 +61,8 @@ pub use xcm::v3::prelude::{
61
61
} ;
62
62
pub use xcm_executor:: traits:: ConvertLocation ;
63
63
64
+ pub type AccountIdOf < T > = <T as frame_system:: Config >:: AccountId ;
65
+
64
66
thread_local ! {
65
67
/// Downward messages, each message is: `(to_para_id, [(relay_block_number, msg)])`
66
68
#[ allow( clippy:: type_complexity) ]
@@ -90,8 +92,8 @@ pub trait CheckAssertion<Origin, Destination, Hops, Args>
90
92
where
91
93
Origin : Chain + Clone ,
92
94
Destination : Chain + Clone ,
93
- Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
94
- Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
95
+ Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Origin :: Runtime > > + Clone ,
96
+ Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Destination :: Runtime > > + Clone ,
95
97
Hops : Clone ,
96
98
Args : Clone ,
97
99
{
@@ -103,8 +105,8 @@ impl<Origin, Destination, Hops, Args> CheckAssertion<Origin, Destination, Hops,
103
105
where
104
106
Origin : Chain + Clone ,
105
107
Destination : Chain + Clone ,
106
- Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
107
- Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
108
+ Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Origin :: Runtime > > + Clone ,
109
+ Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Destination :: Runtime > > + Clone ,
108
110
Hops : Clone ,
109
111
Args : Clone ,
110
112
{
@@ -219,32 +221,32 @@ pub trait Chain: TestExt + NetworkComponent {
219
221
helpers:: get_account_id_from_seed :: < sr25519:: Public > ( seed)
220
222
}
221
223
222
- fn account_data_of ( account : AccountId ) -> AccountData < Balance > ;
224
+ fn account_data_of ( account : AccountIdOf < Self :: Runtime > ) -> AccountData < Balance > ;
223
225
224
226
fn events ( ) -> Vec < <Self as Chain >:: RuntimeEvent > ;
225
227
}
226
228
227
229
pub trait RelayChain : Chain {
228
230
type MessageProcessor : ProcessMessage ;
229
- type SovereignAccountOf : ConvertLocation < AccountId > ;
231
+ type SovereignAccountOf : ConvertLocation < AccountIdOf < Self :: Runtime > > ;
230
232
231
233
fn child_location_of ( id : ParaId ) -> MultiLocation {
232
234
( Ancestor ( 0 ) , ParachainJunction ( id. into ( ) ) ) . into ( )
233
235
}
234
236
235
- fn sovereign_account_id_of ( location : MultiLocation ) -> AccountId {
237
+ fn sovereign_account_id_of ( location : MultiLocation ) -> AccountIdOf < Self :: Runtime > {
236
238
Self :: SovereignAccountOf :: convert_location ( & location) . unwrap ( )
237
239
}
238
240
239
- fn sovereign_account_id_of_child_para ( id : ParaId ) -> AccountId {
241
+ fn sovereign_account_id_of_child_para ( id : ParaId ) -> AccountIdOf < Self :: Runtime > {
240
242
Self :: sovereign_account_id_of ( Self :: child_location_of ( id) )
241
243
}
242
244
}
243
245
244
246
pub trait Parachain : Chain {
245
247
type XcmpMessageHandler : XcmpMessageHandler ;
246
248
type DmpMessageHandler : DmpMessageHandler ;
247
- type LocationToAccountId : ConvertLocation < AccountId > ;
249
+ type LocationToAccountId : ConvertLocation < AccountIdOf < Self :: Runtime > > ;
248
250
type ParachainInfo : Get < ParaId > ;
249
251
type ParachainSystem ;
250
252
@@ -268,7 +270,7 @@ pub trait Parachain: Chain {
268
270
( Parent , X1 ( ParachainJunction ( para_id. into ( ) ) ) ) . into ( )
269
271
}
270
272
271
- fn sovereign_account_id_of ( location : MultiLocation ) -> AccountId {
273
+ fn sovereign_account_id_of ( location : MultiLocation ) -> AccountIdOf < Self :: Runtime > {
272
274
Self :: LocationToAccountId :: convert_location ( & location) . unwrap ( )
273
275
}
274
276
}
@@ -365,7 +367,7 @@ macro_rules! decl_test_relay_chains {
365
367
type RuntimeEvent = $runtime:: RuntimeEvent ;
366
368
type System = $crate:: SystemPallet :: <Self :: Runtime >;
367
369
368
- fn account_data_of( account: $crate:: AccountId ) -> $crate:: AccountData <$crate:: Balance > {
370
+ fn account_data_of( account: $crate:: AccountIdOf < Self :: Runtime > ) -> $crate:: AccountData <$crate:: Balance > {
369
371
<Self as $crate:: TestExt >:: ext_wrapper( || $crate:: SystemPallet :: <Self :: Runtime >:: account( account) . data. into( ) )
370
372
}
371
373
@@ -590,7 +592,7 @@ macro_rules! decl_test_parachains {
590
592
type RuntimeEvent = $runtime:: RuntimeEvent ;
591
593
type System = $crate:: SystemPallet :: <Self :: Runtime >;
592
594
593
- fn account_data_of( account: $crate:: AccountId ) -> $crate:: AccountData <$crate:: Balance > {
595
+ fn account_data_of( account: $crate:: AccountIdOf < Self :: Runtime > ) -> $crate:: AccountData <$crate:: Balance > {
594
596
<Self as $crate:: TestExt >:: ext_wrapper( || $crate:: SystemPallet :: <Self :: Runtime >:: account( account) . data. into( ) )
595
597
}
596
598
@@ -1159,9 +1161,10 @@ macro_rules! __impl_check_assertion {
1159
1161
where
1160
1162
Origin : $crate:: Chain + Clone ,
1161
1163
Destination : $crate:: Chain + Clone ,
1162
- Origin :: RuntimeOrigin : $crate:: OriginTrait <AccountId = $crate:: AccountId32 > + Clone ,
1164
+ Origin :: RuntimeOrigin :
1165
+ $crate:: OriginTrait <AccountId = $crate:: AccountIdOf <Origin :: Runtime >> + Clone ,
1163
1166
Destination :: RuntimeOrigin :
1164
- $crate:: OriginTrait <AccountId = $crate:: AccountId32 > + Clone ,
1167
+ $crate:: OriginTrait <AccountId = $crate:: AccountIdOf < Destination :: Runtime > > + Clone ,
1165
1168
Hops : Clone ,
1166
1169
Args : Clone ,
1167
1170
{
@@ -1308,8 +1311,8 @@ where
1308
1311
1309
1312
/// Struct that keeps account's id and balance
1310
1313
#[ derive( Clone ) ]
1311
- pub struct TestAccount {
1312
- pub account_id : AccountId ,
1314
+ pub struct TestAccount < R : Chain > {
1315
+ pub account_id : AccountIdOf < R :: Runtime > ,
1313
1316
pub balance : Balance ,
1314
1317
}
1315
1318
@@ -1326,9 +1329,9 @@ pub struct TestArgs {
1326
1329
}
1327
1330
1328
1331
/// Auxiliar struct to help creating a new `Test` instance
1329
- pub struct TestContext < T > {
1330
- pub sender : AccountId ,
1331
- pub receiver : AccountId ,
1332
+ pub struct TestContext < T , Origin : Chain , Destination : Chain > {
1333
+ pub sender : AccountIdOf < Origin :: Runtime > ,
1334
+ pub receiver : AccountIdOf < Destination :: Runtime > ,
1332
1335
pub args : T ,
1333
1336
}
1334
1337
@@ -1345,12 +1348,12 @@ pub struct Test<Origin, Destination, Hops = (), Args = TestArgs>
1345
1348
where
1346
1349
Origin : Chain + Clone ,
1347
1350
Destination : Chain + Clone ,
1348
- Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
1349
- Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
1351
+ Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Origin :: Runtime > > + Clone ,
1352
+ Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Destination :: Runtime > > + Clone ,
1350
1353
Hops : Clone ,
1351
1354
{
1352
- pub sender : TestAccount ,
1353
- pub receiver : TestAccount ,
1355
+ pub sender : TestAccount < Origin > ,
1356
+ pub receiver : TestAccount < Destination > ,
1354
1357
pub signed_origin : Origin :: RuntimeOrigin ,
1355
1358
pub root_origin : Origin :: RuntimeOrigin ,
1356
1359
pub hops_assertion : HashMap < String , fn ( Self ) > ,
@@ -1365,12 +1368,12 @@ where
1365
1368
Args : Clone ,
1366
1369
Origin : Chain + Clone + CheckAssertion < Origin , Destination , Hops , Args > ,
1367
1370
Destination : Chain + Clone + CheckAssertion < Origin , Destination , Hops , Args > ,
1368
- Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
1369
- Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountId32 > + Clone ,
1371
+ Origin :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Origin :: Runtime > > + Clone ,
1372
+ Destination :: RuntimeOrigin : OriginTrait < AccountId = AccountIdOf < Destination :: Runtime > > + Clone ,
1370
1373
Hops : Clone + CheckAssertion < Origin , Destination , Hops , Args > ,
1371
1374
{
1372
1375
/// Creates a new `Test` instance
1373
- pub fn new ( test_args : TestContext < Args > ) -> Self {
1376
+ pub fn new ( test_args : TestContext < Args , Origin , Destination > ) -> Self {
1374
1377
Test {
1375
1378
sender : TestAccount {
1376
1379
account_id : test_args. sender . clone ( ) ,
0 commit comments