#![allow(missing_docs)]
use common_primitives::node::{AccountId, Signature};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::Properties;
use serde::{Deserialize, Serialize};
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{Pair, Public};
use sp_runtime::traits::{IdentifyAccount, Verify};
pub type DummyChainSpec = sc_service::GenericChainSpec<Extensions>;
#[cfg(feature = "frequency")]
pub mod frequency;
#[cfg(any(
feature = "frequency-testnet",
feature = "frequency-local",
feature = "frequency-no-relay"
))]
pub mod frequency_paseo;
#[cfg(any(feature = "frequency-no-relay"))]
pub mod frequency_dev;
#[allow(clippy::expect_used)]
pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
.public()
}
type AccountPublic = <Signature as Verify>::Signer;
pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
get_public_from_seed::<AuraId>(seed)
}
pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_public_from_seed::<TPublic>(seed)).into_account()
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
#[serde(deny_unknown_fields)]
pub struct Extensions {
pub relay_chain: String,
pub para_id: u32,
}
impl Extensions {
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
sc_chain_spec::get_extension(chain_spec.extensions())
}
}
pub fn get_properties(symbol: &str, decimals: u32, ss58format: u32) -> Properties {
let mut properties = Properties::new();
properties.insert("tokenSymbol".into(), symbol.into());
properties.insert("tokenDecimals".into(), decimals.into());
properties.insert("ss58Format".into(), ss58format.into());
properties
}