@@ -26,7 +26,7 @@ pub use std::{
2626// Substrate
2727pub use frame_support:: {
2828 assert_ok,
29- sp_runtime:: { traits:: Header as HeaderT , AccountId32 , DispatchResult } ,
29+ sp_runtime:: { traits:: Header as HeaderT , DispatchResult } ,
3030 traits:: {
3131 EnqueueMessage , Get , Hooks , OriginTrait , ProcessMessage , ProcessMessageError , ServiceQueues ,
3232 } ,
@@ -61,6 +61,8 @@ pub use xcm::v3::prelude::{
6161} ;
6262pub use xcm_executor:: traits:: ConvertLocation ;
6363
64+ pub type AccountIdOf < T > = <T as frame_system:: Config >:: AccountId ;
65+
6466thread_local ! {
6567 /// Downward messages, each message is: `(to_para_id, [(relay_block_number, msg)])`
6668 #[ allow( clippy:: type_complexity) ]
@@ -90,8 +92,8 @@ pub trait CheckAssertion<Origin, Destination, Hops, Args>
9092where
9193 Origin : Chain + Clone ,
9294 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 ,
9597 Hops : Clone ,
9698 Args : Clone ,
9799{
@@ -103,8 +105,8 @@ impl<Origin, Destination, Hops, Args> CheckAssertion<Origin, Destination, Hops,
103105where
104106 Origin : Chain + Clone ,
105107 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 ,
108110 Hops : Clone ,
109111 Args : Clone ,
110112{
@@ -219,32 +221,32 @@ pub trait Chain: TestExt + NetworkComponent {
219221 helpers:: get_account_id_from_seed :: < sr25519:: Public > ( seed)
220222 }
221223
222- fn account_data_of ( account : AccountId ) -> AccountData < Balance > ;
224+ fn account_data_of ( account : AccountIdOf < Self :: Runtime > ) -> AccountData < Balance > ;
223225
224226 fn events ( ) -> Vec < <Self as Chain >:: RuntimeEvent > ;
225227}
226228
227229pub trait RelayChain : Chain {
228230 type MessageProcessor : ProcessMessage ;
229- type SovereignAccountOf : ConvertLocation < AccountId > ;
231+ type SovereignAccountOf : ConvertLocation < AccountIdOf < Self :: Runtime > > ;
230232
231233 fn child_location_of ( id : ParaId ) -> MultiLocation {
232234 ( Ancestor ( 0 ) , ParachainJunction ( id. into ( ) ) ) . into ( )
233235 }
234236
235- fn sovereign_account_id_of ( location : MultiLocation ) -> AccountId {
237+ fn sovereign_account_id_of ( location : MultiLocation ) -> AccountIdOf < Self :: Runtime > {
236238 Self :: SovereignAccountOf :: convert_location ( & location) . unwrap ( )
237239 }
238240
239- fn sovereign_account_id_of_child_para ( id : ParaId ) -> AccountId {
241+ fn sovereign_account_id_of_child_para ( id : ParaId ) -> AccountIdOf < Self :: Runtime > {
240242 Self :: sovereign_account_id_of ( Self :: child_location_of ( id) )
241243 }
242244}
243245
244246pub trait Parachain : Chain {
245247 type XcmpMessageHandler : XcmpMessageHandler ;
246248 type DmpMessageHandler : DmpMessageHandler ;
247- type LocationToAccountId : ConvertLocation < AccountId > ;
249+ type LocationToAccountId : ConvertLocation < AccountIdOf < Self :: Runtime > > ;
248250 type ParachainInfo : Get < ParaId > ;
249251 type ParachainSystem ;
250252
@@ -268,7 +270,7 @@ pub trait Parachain: Chain {
268270 ( Parent , X1 ( ParachainJunction ( para_id. into ( ) ) ) ) . into ( )
269271 }
270272
271- fn sovereign_account_id_of ( location : MultiLocation ) -> AccountId {
273+ fn sovereign_account_id_of ( location : MultiLocation ) -> AccountIdOf < Self :: Runtime > {
272274 Self :: LocationToAccountId :: convert_location ( & location) . unwrap ( )
273275 }
274276}
@@ -365,7 +367,7 @@ macro_rules! decl_test_relay_chains {
365367 type RuntimeEvent = $runtime:: RuntimeEvent ;
366368 type System = $crate:: SystemPallet :: <Self :: Runtime >;
367369
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 > {
369371 <Self as $crate:: TestExt >:: ext_wrapper( || $crate:: SystemPallet :: <Self :: Runtime >:: account( account) . data. into( ) )
370372 }
371373
@@ -590,7 +592,7 @@ macro_rules! decl_test_parachains {
590592 type RuntimeEvent = $runtime:: RuntimeEvent ;
591593 type System = $crate:: SystemPallet :: <Self :: Runtime >;
592594
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 > {
594596 <Self as $crate:: TestExt >:: ext_wrapper( || $crate:: SystemPallet :: <Self :: Runtime >:: account( account) . data. into( ) )
595597 }
596598
@@ -1159,9 +1161,10 @@ macro_rules! __impl_check_assertion {
11591161 where
11601162 Origin : $crate:: Chain + Clone ,
11611163 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 ,
11631166 Destination :: RuntimeOrigin :
1164- $crate:: OriginTrait <AccountId = $crate:: AccountId32 > + Clone ,
1167+ $crate:: OriginTrait <AccountId = $crate:: AccountIdOf < Destination :: Runtime > > + Clone ,
11651168 Hops : Clone ,
11661169 Args : Clone ,
11671170 {
@@ -1308,8 +1311,8 @@ where
13081311
13091312/// Struct that keeps account's id and balance
13101313#[ derive( Clone ) ]
1311- pub struct TestAccount {
1312- pub account_id : AccountId ,
1314+ pub struct TestAccount < R : Chain > {
1315+ pub account_id : AccountIdOf < R :: Runtime > ,
13131316 pub balance : Balance ,
13141317}
13151318
@@ -1326,9 +1329,9 @@ pub struct TestArgs {
13261329}
13271330
13281331/// 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 > ,
13321335 pub args : T ,
13331336}
13341337
@@ -1345,12 +1348,12 @@ pub struct Test<Origin, Destination, Hops = (), Args = TestArgs>
13451348where
13461349 Origin : Chain + Clone ,
13471350 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 ,
13501353 Hops : Clone ,
13511354{
1352- pub sender : TestAccount ,
1353- pub receiver : TestAccount ,
1355+ pub sender : TestAccount < Origin > ,
1356+ pub receiver : TestAccount < Destination > ,
13541357 pub signed_origin : Origin :: RuntimeOrigin ,
13551358 pub root_origin : Origin :: RuntimeOrigin ,
13561359 pub hops_assertion : HashMap < String , fn ( Self ) > ,
@@ -1365,12 +1368,12 @@ where
13651368 Args : Clone ,
13661369 Origin : Chain + Clone + CheckAssertion < Origin , Destination , Hops , Args > ,
13671370 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 ,
13701373 Hops : Clone + CheckAssertion < Origin , Destination , Hops , Args > ,
13711374{
13721375 /// 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 {
13741377 Test {
13751378 sender : TestAccount {
13761379 account_id : test_args. sender . clone ( ) ,
0 commit comments