11use crate :: {
2- bridge_config:: XCM_LANE , opaque:: SessionKeys , AccountId , BabeConfig , BridgeRococoGrandpaConfig ,
3- BridgeRococoMessagesConfig , BridgeRococoParachainsConfig , RelayerSetConfig ,
4- RuntimeGenesisConfig , SessionConfig , Signature , SudoConfig , ValidatorSetConfig ,
5- BABE_GENESIS_EPOCH_CONFIG ,
2+ opaque:: SessionKeys , AccountId , BabeConfig , RelayerSetConfig , RuntimeGenesisConfig ,
3+ SessionConfig , Signature , SudoConfig , ValidatorSetConfig , BABE_GENESIS_EPOCH_CONFIG ,
64} ;
5+
6+ #[ cfg( feature = "polkadot" ) ]
7+ use crate :: {
8+ bridge_config:: XCM_LANE , BridgePolkadotGrandpaConfig , BridgePolkadotMessagesConfig ,
9+ BridgePolkadotParachainsConfig ,
10+ } ;
11+ #[ cfg( feature = "rococo" ) ]
12+ use crate :: {
13+ bridge_config:: XCM_LANE , BridgeRococoGrandpaConfig , BridgeRococoMessagesConfig ,
14+ BridgeRococoParachainsConfig ,
15+ } ;
16+
717use scale_info:: prelude:: format;
818use sp_consensus_babe:: AuthorityId as BabeId ;
919use sp_consensus_grandpa:: AuthorityId as GrandpaId ;
@@ -45,6 +55,7 @@ fn session_keys(babe: BabeId, grandpa: GrandpaId) -> SessionKeys {
4555/// Configure initial storage state for FRAME modules.
4656fn testnet_genesis (
4757 initial_authorities : Vec < ( AccountId , BabeId , GrandpaId ) > ,
58+ bridges_pallet_owner : Option < AccountId > ,
4859 root_key : AccountId ,
4960) -> serde_json:: Value {
5061 let config = RuntimeGenesisConfig {
@@ -74,16 +85,35 @@ fn testnet_genesis(
7485 // would want to use separate keys for the relayers.
7586 initial_relayers : initial_authorities. into_iter ( ) . map ( |x| x. 0 ) . collect :: < Vec < _ > > ( ) ,
7687 } ,
88+ #[ cfg( feature = "rococo" ) ]
7789 bridge_rococo_grandpa : BridgeRococoGrandpaConfig {
78- owner : Some ( root_key . clone ( ) ) ,
90+ owner : bridges_pallet_owner . clone ( ) ,
7991 ..Default :: default ( )
8092 } ,
93+ #[ cfg( feature = "rococo" ) ]
8194 bridge_rococo_parachains : BridgeRococoParachainsConfig {
82- owner : Some ( root_key . clone ( ) ) ,
95+ owner : bridges_pallet_owner . clone ( ) ,
8396 ..Default :: default ( )
8497 } ,
98+ #[ cfg( feature = "rococo" ) ]
8599 bridge_rococo_messages : BridgeRococoMessagesConfig {
86- owner : Some ( root_key) ,
100+ owner : bridges_pallet_owner,
101+ opened_lanes : vec ! [ XCM_LANE ] ,
102+ ..Default :: default ( )
103+ } ,
104+ #[ cfg( feature = "polkadot" ) ]
105+ bridge_polkadot_grandpa : BridgePolkadotGrandpaConfig {
106+ owner : bridges_pallet_owner. clone ( ) ,
107+ ..Default :: default ( )
108+ } ,
109+ #[ cfg( feature = "polkadot" ) ]
110+ bridge_polkadot_parachains : BridgePolkadotParachainsConfig {
111+ owner : bridges_pallet_owner. clone ( ) ,
112+ ..Default :: default ( )
113+ } ,
114+ #[ cfg( feature = "polkadot" ) ]
115+ bridge_polkadot_messages : BridgePolkadotMessagesConfig {
116+ owner : bridges_pallet_owner,
87117 opened_lanes : vec ! [ XCM_LANE ] ,
88118 ..Default :: default ( )
89119 } ,
@@ -99,6 +129,8 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
99129 sp_genesis_builder:: DEV_RUNTIME_PRESET => testnet_genesis (
100130 // Initial PoA authorities
101131 vec ! [ authority_keys_from_seed( "Alice" ) ] ,
132+ // Bridges pallet owner
133+ Some ( get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ) ,
102134 // Sudo account
103135 get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ,
104136 ) ,
@@ -110,14 +142,16 @@ pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
110142 authority_keys_from_seed( "Bob" ) ,
111143 authority_keys_from_seed( "Bob//stash" ) ,
112144 ] ,
145+ // Bridges pallet owner
146+ Some ( get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ) ,
113147 // Sudo account
114148 get_account_id_from_seed :: < sr25519:: Public > ( "Alice" ) ,
115149 ) ,
116150 _ => return None ,
117151 } ;
118152 Some (
119153 serde_json:: to_string ( & patch)
120- . expect ( "serialization to json is expected to work. qed." )
154+ . expect ( "serialization to JSON is expected to work. qed." )
121155 . into_bytes ( ) ,
122156 )
123157}
0 commit comments