|
| 1 | +use sc_service::ChainType; |
| 2 | +// use sp_core::sr25519; |
| 3 | +use sp_core::{crypto::UncheckedInto}; |
| 4 | + |
| 5 | +use hex_literal::hex; |
| 6 | + |
| 7 | +use super::{ |
| 8 | + /*get_account_id_from_seed, get_collator_keys_from_seed,*/ session_keys, SAFE_XCM_VERSION, Extensions, |
| 9 | +}; |
| 10 | + |
| 11 | +use cumulus_primitives_core::ParaId; |
| 12 | +use hashed_parachain_runtime::{AccountId, AuraId, SudoConfig, EXISTENTIAL_DEPOSIT}; |
| 13 | + |
| 14 | +/// Specialized `ChainSpec` for Hashed Network |
| 15 | +pub type HashedChainSpec = |
| 16 | + sc_service::GenericChainSpec<hashed_parachain_runtime::GenesisConfig, Extensions>; |
| 17 | + |
| 18 | +/// Gen HASH chain specification |
| 19 | +pub fn get_chain_spec() -> HashedChainSpec { |
| 20 | + |
| 21 | + let mut properties = sc_chain_spec::Properties::new(); |
| 22 | + properties.insert("tokenSymbol".into(), "LUHN".into()); |
| 23 | + properties.insert("tokenDecimals".into(), 18.into()); |
| 24 | + properties.insert("ss58Format".into(), 11486.into()); |
| 25 | + properties.insert("prefix".into(), 11486.into()); |
| 26 | + properties.insert("network".into(), "luhn".into()); |
| 27 | + properties.insert("displayName".into(), "Luhn Network".into()); |
| 28 | + properties.insert("standardAccount".into(),"*25519".into()); |
| 29 | + properties.insert("website".into(), "https://luhn.network".into()); |
| 30 | + |
| 31 | + HashedChainSpec::from_genesis( |
| 32 | + "Luhn Network", |
| 33 | + "luhn", |
| 34 | + ChainType::Live, |
| 35 | + move || { |
| 36 | + hashed_genesis( |
| 37 | + // initial collators. |
| 38 | + vec![ |
| 39 | + ( |
| 40 | + // Collator #1 |
| 41 | + // uhsPQGuXYwjnLvoJWWttQ6FEVtztHSvsjE7UFzxS8mSfoSmts |
| 42 | + hex!["1cfc7e49e91696b84bf8e931c16375ea634c3997b36155657faf7dc4716e273e"].into(), |
| 43 | + hex!["1cfc7e49e91696b84bf8e931c16375ea634c3997b36155657faf7dc4716e273e"].unchecked_into(), |
| 44 | + ), |
| 45 | + ( |
| 46 | + // Collator #2 |
| 47 | + // uhujXWvqSqGrY3K62qeamwCGQd7tTo1hm1s9ZYrgxAZFBLyLv |
| 48 | + hex!["84ce3f0bc9ae73d8497c6161927e9e04f39f4bc54579689532d048188c10a77c"].into(), |
| 49 | + hex!["84ce3f0bc9ae73d8497c6161927e9e04f39f4bc54579689532d048188c10a77c"].unchecked_into(), |
| 50 | + ), |
| 51 | + ], |
| 52 | + vec![ |
| 53 | + // PH |
| 54 | + // uhtqJBJ9ZeKguyAG4GJ2S7cme5FvJ661P5NVdHTYKQgvDEQAR |
| 55 | + hex!["5cf8957922e4058a953281f82fdced2e4d389fe37c77f41a0fd2379df0caf877"].into(), |
| 56 | + ], |
| 57 | + // uhtqJBJ9ZeKguyAG4GJ2S7cme5FvJ661P5NVdHTYKQgvDEQAR |
| 58 | + hex!["5cf8957922e4058a953281f82fdced2e4d389fe37c77f41a0fd2379df0caf877"].into(), |
| 59 | + 2232.into(), |
| 60 | + ) |
| 61 | + }, |
| 62 | + Vec::new(), |
| 63 | + None, |
| 64 | + None, |
| 65 | + None, |
| 66 | + Some(properties), |
| 67 | + Extensions { |
| 68 | + relay_chain: "kusama".into(), |
| 69 | + para_id: 2232, |
| 70 | + }, |
| 71 | + ) |
| 72 | +} |
| 73 | + |
| 74 | +fn hashed_genesis( |
| 75 | + invulnerables: Vec<(AccountId, AuraId)>, |
| 76 | + endowed_accounts: Vec<AccountId>, |
| 77 | + root_key: AccountId, |
| 78 | + id: ParaId, |
| 79 | +) -> hashed_parachain_runtime::GenesisConfig { |
| 80 | + hashed_parachain_runtime::GenesisConfig { |
| 81 | + system: hashed_parachain_runtime::SystemConfig { |
| 82 | + code: hashed_parachain_runtime::WASM_BINARY |
| 83 | + .expect("WASM binary was not build, please build it!") |
| 84 | + .to_vec(), |
| 85 | + }, |
| 86 | + balances: hashed_parachain_runtime::BalancesConfig { |
| 87 | + balances: endowed_accounts.iter().cloned().map(|k| (k, 1000000000000000000000000000)).collect(), |
| 88 | + }, |
| 89 | + sudo: SudoConfig { key: Some(root_key) }, |
| 90 | + council: Default::default(), |
| 91 | + treasury: Default::default(), |
| 92 | + parachain_info: hashed_parachain_runtime::ParachainInfoConfig { parachain_id: id }, |
| 93 | + collator_selection: hashed_parachain_runtime::CollatorSelectionConfig { |
| 94 | + invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), |
| 95 | + candidacy_bond: EXISTENTIAL_DEPOSIT * 16, |
| 96 | + ..Default::default() |
| 97 | + }, |
| 98 | + session: hashed_parachain_runtime::SessionConfig { |
| 99 | + keys: invulnerables |
| 100 | + .into_iter() |
| 101 | + .map(|(acc, aura)| { |
| 102 | + ( |
| 103 | + acc.clone(), // account id |
| 104 | + acc, // validator id |
| 105 | + session_keys(aura), // session keys |
| 106 | + ) |
| 107 | + }) |
| 108 | + .collect(), |
| 109 | + }, |
| 110 | + // no need to pass anything to aura, in fact it will panic if we do. Session will take care |
| 111 | + // of this. |
| 112 | + aura: Default::default(), |
| 113 | + aura_ext: Default::default(), |
| 114 | + parachain_system: Default::default(), |
| 115 | + polkadot_xcm: hashed_parachain_runtime::PolkadotXcmConfig { |
| 116 | + safe_xcm_version: Some(SAFE_XCM_VERSION), |
| 117 | + }, |
| 118 | + } |
| 119 | +} |
| 120 | + |
0 commit comments