referrerpolicy=no-referrer-when-downgrade

polkadot_parachain/chain_spec/
glutton.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 polkadot_omni_node_lib::chain_spec::{Extensions, GenericChainSpec};
19use sc_service::ChainType;
20
21/// Generic Glutton Westend Config for all currently used setups.
22pub fn glutton_westend_config(
23	para_id: ParaId,
24	chain_type: ChainType,
25	relay_chain: &str,
26) -> GenericChainSpec {
27	let mut properties = sc_chain_spec::Properties::new();
28	properties.insert("ss58Format".into(), 42.into());
29
30	GenericChainSpec::builder(
31		glutton_westend_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
32		Extensions::new_with_relay_chain(relay_chain.into()),
33	)
34	.with_name(&chain_type_name(para_id, &chain_type))
35	.with_id(&chain_id(para_id, &chain_type))
36	.with_chain_type(chain_type.clone())
37	.with_genesis_config_preset_name(match chain_type {
38		ChainType::Development => sp_genesis_builder::DEV_RUNTIME_PRESET,
39		ChainType::Local => sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET,
40		_ => panic!("chain_type: {chain_type:?} not supported here!"),
41	})
42	.build()
43}
44
45/// Generate the name directly from the ChainType
46fn chain_type_name(para_id: ParaId, chain_type: &ChainType) -> String {
47	match chain_type {
48		ChainType::Development => format!("Glutton Development {}", para_id),
49		ChainType::Local => format!("Glutton Local {}", para_id),
50		ChainType::Live => format!("Glutton {}", para_id),
51		ChainType::Custom(name) => name.clone(),
52	}
53}
54
55/// Generate the name directly from the ChainType
56pub fn chain_id(para_id: ParaId, chain_type: &ChainType) -> String {
57	match chain_type {
58		ChainType::Development => format!("glutton-westend-dev-{}", para_id),
59		ChainType::Local => format!("glutton-westend-local-{}", para_id),
60		ChainType::Live => format!("glutton-westend-{}", para_id),
61		ChainType::Custom(_) => format!("glutton-westend-custom-{}", para_id),
62	}
63}