polkadot_parachain/chain_spec/
penpal.rs1use 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 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 hex!["aad9fa2249f87a210a0f93400b7f90e47b810c6d65caa0ca3f5af982904c2a33"]
61 .unchecked_into(),
62 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}