mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
d5d15a1802
This PR removes some `ChainSpec` types which are not necessary (left-overs from #1256). Currently `ChainSpec` does not have to be generic over the specific `RuntimeGenesisConfig`, it is enough to use single type for all: https://github.com/paritytech/polkadot-sdk/blob/9f787018857660440182142adc806954d7d07709/cumulus/polkadot-parachain/src/chain_spec/mod.rs#L53-L54 related to: https://github.com/paritytech/polkadot-sdk/issues/25 --------- Co-authored-by: command-bot <>
121 lines
4.0 KiB
Rust
121 lines
4.0 KiB
Rust
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// This file is part of Cumulus.
|
|
|
|
// Cumulus is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
|
|
// Cumulus is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU General Public License for more details.
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use crate::chain_spec::{
|
|
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, GenericChainSpec,
|
|
SAFE_XCM_VERSION,
|
|
};
|
|
use cumulus_primitives_core::ParaId;
|
|
use parachains_common::{AccountId, AuraId};
|
|
use sc_service::ChainType;
|
|
use sp_core::sr25519;
|
|
|
|
pub fn get_penpal_chain_spec(id: ParaId, relay_chain: &str) -> GenericChainSpec {
|
|
// Give your base currency a unit name and decimal places
|
|
let mut properties = sc_chain_spec::Properties::new();
|
|
properties.insert("tokenSymbol".into(), "UNIT".into());
|
|
properties.insert("tokenDecimals".into(), 12u32.into());
|
|
properties.insert("ss58Format".into(), 42u32.into());
|
|
|
|
GenericChainSpec::builder(
|
|
penpal_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
|
|
Extensions {
|
|
relay_chain: relay_chain.into(), // You MUST set this to the correct network!
|
|
para_id: id.into(),
|
|
},
|
|
)
|
|
.with_name("Penpal Parachain")
|
|
.with_id(&format!("penpal-{}", relay_chain.replace("-local", "")))
|
|
.with_chain_type(ChainType::Development)
|
|
.with_genesis_config_patch(penpal_testnet_genesis(
|
|
// initial collators.
|
|
vec![
|
|
(
|
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
get_collator_keys_from_seed::<AuraId>("Alice"),
|
|
),
|
|
(
|
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
get_collator_keys_from_seed::<AuraId>("Bob"),
|
|
),
|
|
],
|
|
vec![
|
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
|
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
|
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
|
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
|
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
|
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
|
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
|
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
|
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
|
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
|
],
|
|
id,
|
|
))
|
|
.build()
|
|
}
|
|
|
|
fn penpal_testnet_genesis(
|
|
invulnerables: Vec<(AccountId, AuraId)>,
|
|
endowed_accounts: Vec<AccountId>,
|
|
id: ParaId,
|
|
) -> serde_json::Value {
|
|
serde_json::json!({
|
|
"balances": {
|
|
"balances": endowed_accounts
|
|
.iter()
|
|
.cloned()
|
|
.map(|k| (k, penpal_runtime::EXISTENTIAL_DEPOSIT * 4096))
|
|
.collect::<Vec<_>>(),
|
|
},
|
|
"parachainInfo": {
|
|
"parachainId": id,
|
|
},
|
|
"collatorSelection": {
|
|
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
|
|
"candidacyBond": penpal_runtime::EXISTENTIAL_DEPOSIT * 16,
|
|
},
|
|
"session": {
|
|
"keys": invulnerables
|
|
.into_iter()
|
|
.map(|(acc, aura)| {
|
|
(
|
|
acc.clone(), // account id
|
|
acc, // validator id
|
|
penpal_session_keys(aura), // session keys
|
|
)
|
|
})
|
|
.collect::<Vec<_>>(),
|
|
},
|
|
"polkadotXcm": {
|
|
"safeXcmVersion": Some(SAFE_XCM_VERSION),
|
|
},
|
|
"sudo": {
|
|
"key": Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
|
},
|
|
})
|
|
}
|
|
|
|
/// Generate the session keys from individual elements.
|
|
///
|
|
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
|
|
pub fn penpal_session_keys(keys: AuraId) -> penpal_runtime::SessionKeys {
|
|
penpal_runtime::SessionKeys { aura: keys }
|
|
}
|