referrerpolicy=no-referrer-when-downgrade

polkadot_parachain/chain_spec/
penpal.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
17use cumulus_primitives_core::ParaId;
18use hex_literal::hex;
19use parachains_common::{AccountId, AuraId};
20use polkadot_omni_node_lib::chain_spec::{Extensions, GenericChainSpec};
21use sc_service::ChainType;
22use sp_core::crypto::UncheckedInto;
23
24pub fn get_penpal_chain_spec(id: ParaId, relay_chain: &str) -> GenericChainSpec {
25	// Give your base currency a unit name and decimal places
26	let mut properties = sc_chain_spec::Properties::new();
27	properties.insert("tokenSymbol".into(), "UNIT".into());
28	properties.insert("tokenDecimals".into(), 12u32.into());
29	properties.insert("ss58Format".into(), 42u32.into());
30
31	GenericChainSpec::builder(
32		penpal_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
33		Extensions::new_with_relay_chain(relay_chain.into()),
34	)
35	.with_name("Penpal Parachain")
36	.with_id(&format!("penpal-{}", relay_chain.replace("-local", "")))
37	.with_chain_type(ChainType::Local)
38	.with_genesis_config_preset_name(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
39	.with_genesis_config_patch(serde_json::json!({
40		"parachainInfo": {
41			"parachainId": id,
42		},
43	}))
44	.build()
45}
46
47pub fn staging_penpal_local_config() -> GenericChainSpec {
48	GenericChainSpec::builder(
49		penpal_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
50		Extensions::new_with_relay_chain("rococo-local".into()),
51	)
52	.with_name("Staging Rococo Penpal Local")
53	.with_id("staging_testnet")
54	.with_chain_type(ChainType::Live)
55	.with_genesis_config_preset_name(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET)
56	.with_genesis_config_patch(testnet_genesis_patch(
57		hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"].into(),
58		vec![
59			// $secret//one
60			hex!["aad9fa2249f87a210a0f93400b7f90e47b810c6d65caa0ca3f5af982904c2a33"]
61				.unchecked_into(),
62			// $secret//two
63			hex!["d47753f0cca9dd8da00c70e82ec4fc5501a69c49a5952a643d18802837c88212"]
64				.unchecked_into(),
65		],
66		vec![hex!["d43593c715fdd31c61141abd04a99fd6822c8558854ccde39a5684e7a56da27d"].into()],
67		1000.into(),
68	))
69	.build()
70}
71
72pub(crate) fn testnet_genesis_patch(
73	root_key: AccountId,
74	initial_authorities: Vec<AuraId>,
75	endowed_accounts: Vec<AccountId>,
76	id: ParaId,
77) -> serde_json::Value {
78	serde_json::json!({
79			"balances": {
80					"balances": endowed_accounts.iter().cloned().map(|k| (k, 1u64 << 60)).collect::<Vec<_>>(),
81			},
82			"sudo": { "key": Some(root_key) },
83			"parachainInfo": {
84					"parachainId": id,
85			},
86			"aura": { "authorities": initial_authorities },
87	})
88}