difftreelog
Fix load_spec and is_opal
in: master
2 files changed
node/cli/src/chain_spec.rsdiffbeforeafterboth262627use unique_runtime_common::types::*;27use unique_runtime_common::types::*;282829/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.29/// The `ChainSpec` parameterized for the unique runtime.30#[cfg(feature = "unique-runtime")]30pub type ChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;31pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;3233/// The `ChainSpec` parameterized for the quartz runtime.34#[cfg(feature = "quartz-runtime")]35pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;3637/// The `ChainSpec` parameterized for the opal runtime.38#[cfg(feature = "opal-runtime")]39pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;314032pub trait RuntimeIdentification {41pub trait RuntimeIdentification {33 fn is_unique(&self) -> bool;42 fn is_unique(&self) -> bool;485749 fn is_opal(&self) -> bool {58 fn is_opal(&self) -> bool {50 self.id().starts_with("opal")59 self.id().starts_with("opal")60 || self.id() == "dev"61 || self.id() == "local_testnet"51 }62 }52}63}536485 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()96 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()86}97}879888pub fn development_config() -> ChainSpec {99pub fn development_config() -> OpalChainSpec {89 let mut properties = Map::new();100 let mut properties = Map::new();90 properties.insert("tokenSymbol".into(), "OPL".into());101 properties.insert("tokenSymbol".into(), "OPL".into());91 properties.insert("tokenDecimals".into(), 15.into());102 properties.insert("tokenDecimals".into(), 15.into());92 properties.insert("ss58Format".into(), 42.into());103 properties.insert("ss58Format".into(), 42.into());9310494 ChainSpec::from_genesis(105 OpalChainSpec::from_genesis(95 // Name106 // Name96 "Development",107 "Development",97 // ID108 // ID130 )141 )131}142}132143133pub fn local_testnet_rococo_config() -> ChainSpec {144pub fn local_testnet_rococo_config() -> OpalChainSpec {134 ChainSpec::from_genesis(145 OpalChainSpec::from_genesis(135 // Name146 // Name136 "Local Testnet",147 "Local Testnet",137 // ID148 // ID180 )191 )181}192}182193183pub fn local_testnet_westend_config() -> ChainSpec {194pub fn local_testnet_westend_config() -> OpalChainSpec {184 ChainSpec::from_genesis(195 OpalChainSpec::from_genesis(185 // Name196 // Name186 "Local Testnet",197 "Local Testnet",187 // ID198 // ID238 initial_authorities: Vec<AuraId>,249 initial_authorities: Vec<AuraId>,239 endowed_accounts: Vec<AccountId>,250 endowed_accounts: Vec<AccountId>,240 id: ParaId,251 id: ParaId,241) -> unique_runtime::GenesisConfig {252) -> opal_runtime::GenesisConfig {242 use unique_runtime::*;253 use opal_runtime::*;243254244 GenesisConfig {255 GenesisConfig {245 system: SystemConfig {256 system: SystemConfig {node/cli/src/command.rsdiffbeforeafterboth75}75}767677fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {77fn load_spec(id: &str) -> std::result::Result<Box<dyn sc_service::ChainSpec>, String> {78 Ok(match id {78 match id {79 "westend-local" => Box::new(chain_spec::local_testnet_westend_config()),79 "westend-local" => Ok(Box::new(chain_spec::local_testnet_westend_config())),80 "rococo-local" => Box::new(chain_spec::local_testnet_rococo_config()),80 "rococo-local" => Ok(Box::new(chain_spec::local_testnet_rococo_config())),81 "dev" => Box::new(chain_spec::development_config()),81 "dev" => Ok(Box::new(chain_spec::development_config())),82 "" | "local" => Box::new(chain_spec::local_testnet_rococo_config()),82 "" | "local" => Ok(Box::new(chain_spec::local_testnet_rococo_config())),83 path => Box::new(chain_spec::ChainSpec::from_json_file(83 path => {84 let path = std::path::PathBuf::from(path);85 let chain_spec = Box::new(84 std::path::PathBuf::from(path),86 chain_spec::UniqueChainSpec::from_json_file(path.clone())?85 )?),87 ) as Box<dyn sc_service::ChainSpec>;8889 #[cfg(feature = "unique-runtime")]90 if chain_spec.is_unique() {91 return Ok(chain_spec);92 }9394 #[cfg(feature = "quartz-runtime")]95 if chain_spec.is_quartz() {96 let chain_spec = chain_spec::QuartzChainSpec::from_json_file(97 path98 )?;99 return Ok(Box::new(chain_spec));100 }101102 #[cfg(feature = "opal-runtime")]103 if chain_spec.is_opal() {104 let chain_spec = chain_spec::OpalChainSpec::from_json_file(105 path106 )?;107 return Ok(Box::new(chain_spec));108 }109110 Err(no_runtime_err!(chain_spec))111 },86 })112 }87}113}8811489impl SubstrateCli for Cli {115impl SubstrateCli for Cli {