b6d35f6faf
Updated 4763 files with dual copyright: - Parity Technologies (UK) Ltd. - Dijital Kurdistan Tech Institute
74 lines
2.5 KiB
Rust
74 lines
2.5 KiB
Rust
// Copyright (C) Parity Technologies (UK) Ltd. and Dijital Kurdistan Tech Institute
|
|
// This file is part of Pezcumulus.
|
|
|
|
// Pezcumulus 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.
|
|
|
|
// Pezcumulus 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 Pezcumulus. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use super::{
|
|
AccountId, AuraConfig, AuraId, BalancesConfig, RuntimeGenesisConfig, SudoConfig,
|
|
TeyrchainInfoConfig,
|
|
};
|
|
use alloc::{vec, vec::Vec};
|
|
|
|
use pezcumulus_primitives_core::ParaId;
|
|
use pezframe_support::build_struct_json_patch;
|
|
use pezsp_genesis_builder::PresetId;
|
|
use pezsp_keyring::Sr25519Keyring;
|
|
|
|
fn pezcumulus_test_runtime(
|
|
invulnerables: Vec<AuraId>,
|
|
endowed_accounts: Vec<AccountId>,
|
|
id: ParaId,
|
|
) -> serde_json::Value {
|
|
build_struct_json_patch!(RuntimeGenesisConfig {
|
|
balances: BalancesConfig {
|
|
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
|
},
|
|
sudo: SudoConfig { key: Some(Sr25519Keyring::Alice.public().into()) },
|
|
teyrchain_info: TeyrchainInfoConfig { teyrchain_id: id },
|
|
aura: AuraConfig { authorities: invulnerables },
|
|
})
|
|
}
|
|
|
|
fn testnet_genesis_with_default_endowed(self_para_id: ParaId) -> serde_json::Value {
|
|
let endowed = Sr25519Keyring::well_known().map(|x| x.to_account_id()).collect::<Vec<_>>();
|
|
|
|
let invulnerables =
|
|
Sr25519Keyring::invulnerable().map(|x| x.public().into()).collect::<Vec<_>>();
|
|
pezcumulus_test_runtime(invulnerables, endowed, self_para_id)
|
|
}
|
|
|
|
/// List of supported presets.
|
|
pub fn preset_names() -> Vec<PresetId> {
|
|
vec![
|
|
PresetId::from(pezsp_genesis_builder::DEV_RUNTIME_PRESET),
|
|
PresetId::from(pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET),
|
|
]
|
|
}
|
|
|
|
/// Provides the JSON representation of predefined genesis config for given `id`.
|
|
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
|
|
let patch = match id.as_ref() {
|
|
pezsp_genesis_builder::DEV_RUNTIME_PRESET
|
|
| pezsp_genesis_builder::LOCAL_TESTNET_RUNTIME_PRESET => {
|
|
testnet_genesis_with_default_endowed(100.into())
|
|
},
|
|
_ => return None,
|
|
};
|
|
Some(
|
|
serde_json::to_string(&patch)
|
|
.expect("serialization to json is expected to work. qed.")
|
|
.into_bytes(),
|
|
)
|
|
}
|