referrerpolicy=no-referrer-when-downgrade

polkadot_parachain/chain_spec/
rococo_parachain.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Cumulus.
3// SPDX-License-Identifier: Apache-2.0
4
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// 	http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17//! ChainSpecs dedicated to Rococo parachain setups (for testing and example purposes)
18
19use cumulus_primitives_core::ParaId;
20use hex_literal::hex;
21use parachains_common::AccountId;
22use polkadot_omni_node_lib::chain_spec::{Extensions, GenericChainSpec};
23use rococo_parachain_runtime::AuraId;
24use sc_chain_spec::ChainType;
25use sp_core::crypto::UncheckedInto;
26
27pub fn rococo_parachain_local_config() -> GenericChainSpec {
28	GenericChainSpec::builder(
29		rococo_parachain_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
30		Extensions::new_with_relay_chain("rococo-local".into()),
31	)
32	.with_name("Rococo Parachain Local")
33	.with_id("local_testnet")
34	.with_chain_type(ChainType::Local)
35	.with_genesis_config_preset_name(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
36	.build()
37}
38
39pub fn staging_rococo_parachain_local_config() -> GenericChainSpec {
40	GenericChainSpec::builder(
41		rococo_parachain_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
42		Extensions::new_with_relay_chain("rococo-local".into()),
43	)
44	.with_name("Staging Rococo Parachain Local")
45	.with_id("staging_testnet")
46	.with_chain_type(ChainType::Live)
47	.with_genesis_config_preset_name(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
48	.with_genesis_config_patch(testnet_genesis_patch(
49		hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into(),
50		vec![
51			// $secret//one
52			hex!["aad9fa2249f87a210a0f93400b7f90e47b810c6d65caa0ca3f5af982904c2a33"]
53				.unchecked_into(),
54			// $secret//two
55			hex!["d47753f0cca9dd8da00c70e82ec4fc5501a69c49a5952a643d18802837c88212"]
56				.unchecked_into(),
57		],
58		vec![hex!["9ed7705e3c7da027ba0583a22a3212042f7e715d3c168ba14f1424e2bc111d00"].into()],
59		1000.into(),
60	))
61	.build()
62}
63
64pub(crate) fn testnet_genesis_patch(
65	root_key: AccountId,
66	initial_authorities: Vec<AuraId>,
67	endowed_accounts: Vec<AccountId>,
68	id: ParaId,
69) -> serde_json::Value {
70	serde_json::json!({
71		"balances": {
72			"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
73		},
74		"sudo": { "key": Some(root_key) },
75		"parachainInfo": {
76			"parachainId": id,
77		},
78		"aura": { "authorities": initial_authorities },
79	})
80}