@@ -4,10 +4,29 @@ use frame_support::pallet_macros::pallet_section;
44/// This can later be imported into the pallet using [`import_section`].
55#[ pallet_section]
66mod genesis {
7+ use sp_core:: crypto:: Pair ;
8+ use sp_core:: sr25519:: Pair as Sr25519Pair ;
79
810 #[ pallet:: genesis_build]
911 impl < T : Config > BuildGenesisConfig for GenesisConfig < T > {
1012 fn build ( & self ) {
13+ // Alice's public key
14+ let alice_bytes = sp_keyring:: Sr25519Keyring :: Alice . public ( ) ;
15+
16+ // Create Alice's hotkey from seed string
17+ let pair = Sr25519Pair :: from_string ( "//Alice_hk" , None )
18+ . expect ( "Alice hotkey pair should be valid" ) ;
19+ let alice_hk_bytes = pair. public ( ) . 0 ;
20+
21+ let alice_account =
22+ T :: AccountId :: decode ( & mut & alice_bytes[ ..] ) . expect ( "Alice account should decode" ) ;
23+ let alice_hk_account = T :: AccountId :: decode ( & mut & alice_hk_bytes[ ..] )
24+ . expect ( "Alice hotkey account should decode" ) ;
25+
26+ let subnet_root_owner = prod_or_fast ! ( DefaultSubnetOwner :: <T >:: get( ) , alice_account) ;
27+ let subnet_root_owner_hotkey =
28+ prod_or_fast ! ( DefaultSubnetOwner :: <T >:: get( ) , alice_hk_account) ;
29+
1130 // Set initial total issuance from balances
1231 TotalIssuance :: < T > :: put ( self . balances_issuance ) ;
1332
@@ -17,6 +36,12 @@ mod genesis {
1736 // Increment the number of total networks.
1837 TotalNetworks :: < T > :: mutate ( |n| * n = n. saturating_add ( 1 ) ) ;
1938
39+ // Set the root network owner.
40+ SubnetOwner :: < T > :: insert ( NetUid :: ROOT , subnet_root_owner) ;
41+
42+ // Set the root network owner hotkey.
43+ SubnetOwnerHotkey :: < T > :: insert ( NetUid :: ROOT , subnet_root_owner_hotkey) ;
44+
2045 // Set the number of validators to 1.
2146 SubnetworkN :: < T > :: insert ( NetUid :: ROOT , 0 ) ;
2247
0 commit comments