polkadot_parachain/chain_spec/
glutton.rs1use cumulus_primitives_core::ParaId;
18use polkadot_omni_node_lib::chain_spec::{Extensions, GenericChainSpec};
19use sc_service::ChainType;
20
21pub 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(relay_chain.into(), para_id.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 .with_genesis_config_patch(serde_json::json!({
44 "parachainInfo": { "parachainId": u32::from(para_id) },
45 }))
46 .build()
47}
48
49fn chain_type_name(para_id: ParaId, chain_type: &ChainType) -> String {
51 match chain_type {
52 ChainType::Development => format!("Glutton Development {}", para_id),
53 ChainType::Local => format!("Glutton Local {}", para_id),
54 ChainType::Live => format!("Glutton {}", para_id),
55 ChainType::Custom(name) => name.clone(),
56 }
57}
58
59pub fn chain_id(para_id: ParaId, chain_type: &ChainType) -> String {
61 match chain_type {
62 ChainType::Development => format!("glutton-westend-dev-{}", para_id),
63 ChainType::Local => format!("glutton-westend-local-{}", para_id),
64 ChainType::Live => format!("glutton-westend-{}", para_id),
65 ChainType::Custom(_) => format!("glutton-westend-custom-{}", para_id),
66 }
67}