frequency_service/
chain_spec.rs1#![allow(missing_docs)]
2use common_primitives::node::{AccountId, Signature};
3use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
4use sc_service::Properties;
5use serde::{Deserialize, Serialize};
6pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
7use sp_core::{Pair, Public};
8use sp_runtime::traits::{IdentifyAccount, Verify};
9
10pub type DummyChainSpec = sc_service::GenericChainSpec<Extensions>;
12
13#[cfg(feature = "frequency")]
14pub mod frequency;
15
16#[cfg(feature = "frequency-testnet")]
17pub mod frequency_paseo;
18
19#[cfg(feature = "frequency-westend")]
20pub mod frequency_westend;
21
22#[cfg(any(feature = "frequency-local", feature = "frequency-no-relay"))]
23pub mod frequency_paseo_local;
24
25#[cfg(feature = "frequency-bridging")]
26pub mod frequency_westend_local;
27
28#[cfg(feature = "frequency-no-relay")]
29pub mod frequency_dev;
30
31#[allow(clippy::expect_used)]
32pub fn get_public_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
34 TPublic::Pair::from_string(&format!("//{seed}"), None)
35 .expect("static values are valid; qed")
36 .public()
37}
38
39type AccountPublic = <Signature as Verify>::Signer;
40
41pub fn get_collator_keys_from_seed(seed: &str) -> AuraId {
45 get_public_from_seed::<AuraId>(seed)
46}
47
48pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
50where
51 AccountPublic: From<<TPublic::Pair as Pair>::Public>,
52{
53 AccountPublic::from(get_public_from_seed::<TPublic>(seed)).into_account()
54}
55
56#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]
58#[serde(deny_unknown_fields)]
59pub struct Extensions {
60 pub relay_chain: String,
62 pub para_id: u32,
64}
65
66impl Extensions {
67 pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
69 sc_chain_spec::get_extension(chain_spec.extensions())
70 }
71}
72
73pub fn get_properties(symbol: &str, decimals: u32, ss58format: u32) -> Properties {
74 let mut properties = Properties::new();
75 properties.insert("tokenSymbol".into(), symbol.into());
76 properties.insert("tokenDecimals".into(), decimals.into());
77 properties.insert("ss58Format".into(), ss58format.into());
78
79 properties
80}