|
1 | | -use node_template_runtime::{ |
2 | | - AccountId, AuraConfig, BalancesConfig, GrandpaConfig, RuntimeGenesisConfig, Signature, |
3 | | - SudoConfig, SystemConfig, WASM_BINARY, |
4 | | -}; |
| 1 | +use node_template_runtime::{AccountId, RuntimeGenesisConfig, Signature, WASM_BINARY}; |
5 | 2 | use sc_service::ChainType; |
6 | 3 | use sp_consensus_aura::sr25519::AuthorityId as AuraId; |
7 | 4 | use sp_consensus_grandpa::AuthorityId as GrandpaId; |
@@ -37,122 +34,84 @@ pub fn authority_keys_from_seed(s: &str) -> (AuraId, GrandpaId) { |
37 | 34 | } |
38 | 35 |
|
39 | 36 | pub fn development_config() -> Result<ChainSpec, String> { |
40 | | - let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; |
41 | | - |
42 | | - Ok(ChainSpec::from_genesis( |
43 | | - // Name |
44 | | - "Development", |
45 | | - // ID |
46 | | - "dev", |
47 | | - ChainType::Development, |
48 | | - move || { |
49 | | - testnet_genesis( |
50 | | - wasm_binary, |
51 | | - // Initial PoA authorities |
52 | | - vec![authority_keys_from_seed("Alice")], |
53 | | - // Sudo account |
54 | | - get_account_id_from_seed::<sr25519::Public>("Alice"), |
55 | | - // Pre-funded accounts |
56 | | - vec![ |
57 | | - get_account_id_from_seed::<sr25519::Public>("Alice"), |
58 | | - get_account_id_from_seed::<sr25519::Public>("Bob"), |
59 | | - get_account_id_from_seed::<sr25519::Public>("Alice//stash"), |
60 | | - get_account_id_from_seed::<sr25519::Public>("Bob//stash"), |
61 | | - ], |
62 | | - true, |
63 | | - ) |
64 | | - }, |
65 | | - // Bootnodes |
66 | | - vec![], |
67 | | - // Telemetry |
68 | | - None, |
69 | | - // Protocol ID |
70 | | - None, |
71 | | - None, |
72 | | - // Properties |
73 | | - None, |
74 | | - // Extensions |
| 37 | + Ok(ChainSpec::builder( |
| 38 | + WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?, |
75 | 39 | None, |
| 40 | + ) |
| 41 | + .with_name("Development") |
| 42 | + .with_id("dev") |
| 43 | + .with_chain_type(ChainType::Development) |
| 44 | + .with_genesis_config_patch(testnet_genesis( |
| 45 | + // Initial PoA authorities |
| 46 | + vec![authority_keys_from_seed("Alice")], |
| 47 | + // Sudo account |
| 48 | + get_account_id_from_seed::<sr25519::Public>("Alice"), |
| 49 | + // Pre-funded accounts |
| 50 | + vec![ |
| 51 | + get_account_id_from_seed::<sr25519::Public>("Alice"), |
| 52 | + get_account_id_from_seed::<sr25519::Public>("Bob"), |
| 53 | + get_account_id_from_seed::<sr25519::Public>("Alice//stash"), |
| 54 | + get_account_id_from_seed::<sr25519::Public>("Bob//stash"), |
| 55 | + ], |
| 56 | + true, |
76 | 57 | )) |
| 58 | + .build()) |
77 | 59 | } |
78 | 60 |
|
79 | 61 | pub fn local_testnet_config() -> Result<ChainSpec, String> { |
80 | | - let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?; |
81 | | - |
82 | | - Ok(ChainSpec::from_genesis( |
83 | | - // Name |
84 | | - "Local Testnet", |
85 | | - // ID |
86 | | - "local_testnet", |
87 | | - ChainType::Local, |
88 | | - move || { |
89 | | - testnet_genesis( |
90 | | - wasm_binary, |
91 | | - // Initial PoA authorities |
92 | | - vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], |
93 | | - // Sudo account |
94 | | - get_account_id_from_seed::<sr25519::Public>("Alice"), |
95 | | - // Pre-funded accounts |
96 | | - vec![ |
97 | | - get_account_id_from_seed::<sr25519::Public>("Alice"), |
98 | | - get_account_id_from_seed::<sr25519::Public>("Bob"), |
99 | | - get_account_id_from_seed::<sr25519::Public>("Charlie"), |
100 | | - get_account_id_from_seed::<sr25519::Public>("Dave"), |
101 | | - get_account_id_from_seed::<sr25519::Public>("Eve"), |
102 | | - get_account_id_from_seed::<sr25519::Public>("Ferdie"), |
103 | | - get_account_id_from_seed::<sr25519::Public>("Alice//stash"), |
104 | | - get_account_id_from_seed::<sr25519::Public>("Bob//stash"), |
105 | | - get_account_id_from_seed::<sr25519::Public>("Charlie//stash"), |
106 | | - get_account_id_from_seed::<sr25519::Public>("Dave//stash"), |
107 | | - get_account_id_from_seed::<sr25519::Public>("Eve//stash"), |
108 | | - get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"), |
109 | | - ], |
110 | | - true, |
111 | | - ) |
112 | | - }, |
113 | | - // Bootnodes |
114 | | - vec![], |
115 | | - // Telemetry |
116 | | - None, |
117 | | - // Protocol ID |
118 | | - None, |
119 | | - // Properties |
120 | | - None, |
121 | | - None, |
122 | | - // Extensions |
| 62 | + Ok(ChainSpec::builder( |
| 63 | + WASM_BINARY.ok_or_else(|| "Development wasm not available".to_string())?, |
123 | 64 | None, |
| 65 | + ) |
| 66 | + .with_name("Local Testnet") |
| 67 | + .with_id("local_testnet") |
| 68 | + .with_chain_type(ChainType::Local) |
| 69 | + .with_genesis_config_patch(testnet_genesis( |
| 70 | + // Initial PoA authorities |
| 71 | + vec![authority_keys_from_seed("Alice"), authority_keys_from_seed("Bob")], |
| 72 | + // Sudo account |
| 73 | + get_account_id_from_seed::<sr25519::Public>("Alice"), |
| 74 | + // Pre-funded accounts |
| 75 | + vec![ |
| 76 | + get_account_id_from_seed::<sr25519::Public>("Alice"), |
| 77 | + get_account_id_from_seed::<sr25519::Public>("Bob"), |
| 78 | + get_account_id_from_seed::<sr25519::Public>("Charlie"), |
| 79 | + get_account_id_from_seed::<sr25519::Public>("Dave"), |
| 80 | + get_account_id_from_seed::<sr25519::Public>("Eve"), |
| 81 | + get_account_id_from_seed::<sr25519::Public>("Ferdie"), |
| 82 | + get_account_id_from_seed::<sr25519::Public>("Alice//stash"), |
| 83 | + get_account_id_from_seed::<sr25519::Public>("Bob//stash"), |
| 84 | + get_account_id_from_seed::<sr25519::Public>("Charlie//stash"), |
| 85 | + get_account_id_from_seed::<sr25519::Public>("Dave//stash"), |
| 86 | + get_account_id_from_seed::<sr25519::Public>("Eve//stash"), |
| 87 | + get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"), |
| 88 | + ], |
| 89 | + true, |
124 | 90 | )) |
| 91 | + .build()) |
125 | 92 | } |
126 | 93 |
|
127 | 94 | /// Configure initial storage state for FRAME modules. |
128 | 95 | fn testnet_genesis( |
129 | | - wasm_binary: &[u8], |
130 | 96 | initial_authorities: Vec<(AuraId, GrandpaId)>, |
131 | 97 | root_key: AccountId, |
132 | 98 | endowed_accounts: Vec<AccountId>, |
133 | 99 | _enable_println: bool, |
134 | | -) -> RuntimeGenesisConfig { |
135 | | - RuntimeGenesisConfig { |
136 | | - system: SystemConfig { |
137 | | - // Add Wasm runtime to storage. |
138 | | - code: wasm_binary.to_vec(), |
139 | | - ..Default::default() |
140 | | - }, |
141 | | - balances: BalancesConfig { |
| 100 | +) -> serde_json::Value { |
| 101 | + serde_json::json!({ |
| 102 | + "balances": { |
142 | 103 | // Configure endowed accounts with initial balance of 1 << 60. |
143 | | - balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(), |
| 104 | + "balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(), |
144 | 105 | }, |
145 | | - aura: AuraConfig { |
146 | | - authorities: initial_authorities.iter().map(|x| (x.0.clone())).collect(), |
| 106 | + "aura": { |
| 107 | + "authorities": initial_authorities.iter().map(|x| (x.0.clone())).collect::<Vec<_>>(), |
147 | 108 | }, |
148 | | - grandpa: GrandpaConfig { |
149 | | - authorities: initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect(), |
150 | | - ..Default::default() |
| 109 | + "grandpa": { |
| 110 | + "authorities": initial_authorities.iter().map(|x| (x.1.clone(), 1)).collect::<Vec<_>>(), |
151 | 111 | }, |
152 | | - sudo: SudoConfig { |
| 112 | + "sudo": { |
153 | 113 | // Assign network admin rights. |
154 | | - key: Some(root_key), |
| 114 | + "key": Some(root_key), |
155 | 115 | }, |
156 | | - transaction_payment: Default::default(), |
157 | | - } |
| 116 | + }) |
158 | 117 | } |
0 commit comments