coretime_westend_runtime/
genesis_config_presets.rs1use crate::*;
19use alloc::{vec, vec::Vec};
20use cumulus_primitives_core::ParaId;
21use frame_support::build_struct_json_patch;
22use parachains_common::{AccountId, AuraId};
23use sp_genesis_builder::PresetId;
24use sp_keyring::Sr25519Keyring;
25use testnet_parachains_constants::westend::{
26 currency::UNITS as WND, xcm_version::SAFE_XCM_VERSION,
27};
28
29const CORETIME_WESTEND_ED: Balance = ExistentialDeposit::get();
30pub const CORETIME_PARA_ID: ParaId = ParaId::new(1005);
31
32fn coretime_westend_genesis(
33 invulnerables: Vec<(AccountId, AuraId)>,
34 endowed_accounts: Vec<AccountId>,
35 endowment: Balance,
36 id: ParaId,
37) -> serde_json::Value {
38 build_struct_json_patch!(RuntimeGenesisConfig {
39 balances: BalancesConfig {
40 balances: endowed_accounts.iter().cloned().map(|k| (k, endowment)).collect(),
41 },
42 parachain_info: ParachainInfoConfig { parachain_id: id },
43 collator_selection: CollatorSelectionConfig {
44 invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
45 candidacy_bond: CORETIME_WESTEND_ED * 16,
46 },
47 session: SessionConfig {
48 keys: invulnerables
49 .into_iter()
50 .map(|(acc, aura)| {
51 (
52 acc.clone(), acc, SessionKeys { aura }, )
56 })
57 .collect(),
58 },
59 polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(SAFE_XCM_VERSION) },
60 })
61}
62
63pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
65 let patch = match id.as_ref() {
66 sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => coretime_westend_genesis(
67 vec![
69 (Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into()),
70 (Sr25519Keyring::Bob.to_account_id(), Sr25519Keyring::Bob.public().into()),
71 ],
72 Sr25519Keyring::well_known().map(|k| k.to_account_id()).collect(),
73 WND * 1_000_000,
74 CORETIME_PARA_ID,
75 ),
76 sp_genesis_builder::DEV_RUNTIME_PRESET => coretime_westend_genesis(
77 vec![(Sr25519Keyring::Alice.to_account_id(), Sr25519Keyring::Alice.public().into())],
79 vec![
80 Sr25519Keyring::Alice.to_account_id(),
81 Sr25519Keyring::Bob.to_account_id(),
82 Sr25519Keyring::AliceStash.to_account_id(),
83 Sr25519Keyring::BobStash.to_account_id(),
84 ],
85 WND * 1_000_000,
86 CORETIME_PARA_ID,
87 ),
88 _ => return None,
89 };
90
91 Some(
92 serde_json::to_string(&patch)
93 .expect("serialization to json is expected to work. qed.")
94 .into_bytes(),
95 )
96}
97
98pub fn preset_names() -> Vec<PresetId> {
100 vec![
101 PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET),
102 PresetId::from(sp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET),
103 ]
104}