// Copyright 2019 Parity Technologies (UK) Ltd. // This file is part of Cumulus. // Cumulus is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // Cumulus is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with Cumulus. If not, see . use parachain_runtime::{ AccountId, BalancesConfig, GenesisConfig, IndicesConfig, SudoConfig, SystemConfig, WASM_BINARY, }; use sc_service; use sp_core::{Pair, Public}; /// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type. pub type ChainSpec = sc_service::GenericChainSpec; /// Helper function to generate a crypto pair from seed pub fn get_from_seed(seed: &str) -> ::Public { TPublic::Pair::from_string(&format!("//{}", seed), None) .expect("static values are valid; qed") .public() } /// Helper function to generate stash, controller and session key from seed pub fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AccountId) { ( get_from_seed::(&format!("{}//stash", seed)), get_from_seed::(seed), ) } /// Returns the chain spec. pub fn get_chain_spec() -> ChainSpec { ChainSpec::from_genesis( "Local Testnet", "parachain_local_testnet", sc_service::ChainType::Local, || { testnet_genesis( vec![ get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob"), ], get_from_seed::("Alice"), vec![ get_from_seed::("Alice"), get_from_seed::("Bob"), get_from_seed::("Charlie"), get_from_seed::("Dave"), get_from_seed::("Eve"), get_from_seed::("Ferdie"), get_from_seed::("Alice//stash"), get_from_seed::("Bob//stash"), get_from_seed::("Charlie//stash"), get_from_seed::("Dave//stash"), get_from_seed::("Eve//stash"), get_from_seed::("Ferdie//stash"), ], true, ) }, vec![], None, None, None, None, ) } fn testnet_genesis( _initial_authorities: Vec<(AccountId, AccountId)>, root_key: AccountId, endowed_accounts: Vec, _enable_println: bool, ) -> GenesisConfig { GenesisConfig { frame_system: Some(SystemConfig { code: WASM_BINARY.to_vec(), changes_trie_config: Default::default(), }), pallet_indices: Some(IndicesConfig { indices: vec![], }), pallet_balances: Some(BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, 1 << 60)) .collect(), }), pallet_sudo: Some(SudoConfig { key: root_key }), } }