difftreelog
Fix load_spec and is_opal
in: master
2 files changed
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -26,8 +26,17 @@
use unique_runtime_common::types::*;
-/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.
-pub type ChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;
+/// The `ChainSpec` parameterized for the unique runtime.
+#[cfg(feature = "unique-runtime")]
+pub type UniqueChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;
+
+/// The `ChainSpec` parameterized for the quartz runtime.
+#[cfg(feature = "quartz-runtime")]
+pub type QuartzChainSpec = sc_service::GenericChainSpec<quartz_runtime::GenesisConfig, Extensions>;
+
+/// The `ChainSpec` parameterized for the opal runtime.
+#[cfg(feature = "opal-runtime")]
+pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;
pub trait RuntimeIdentification {
fn is_unique(&self) -> bool;
@@ -48,6 +57,8 @@
fn is_opal(&self) -> bool {
self.id().starts_with("opal")
+ || self.id() == "dev"
+ || self.id() == "local_testnet"
}
}
@@ -85,13 +96,13 @@
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
-pub fn development_config() -> ChainSpec {
+pub fn development_config() -> OpalChainSpec {
let mut properties = Map::new();
properties.insert("tokenSymbol".into(), "OPL".into());
properties.insert("tokenDecimals".into(), 15.into());
properties.insert("ss58Format".into(), 42.into());
- ChainSpec::from_genesis(
+ OpalChainSpec::from_genesis(
// Name
"Development",
// ID
@@ -130,8 +141,8 @@
)
}
-pub fn local_testnet_rococo_config() -> ChainSpec {
- ChainSpec::from_genesis(
+pub fn local_testnet_rococo_config() -> OpalChainSpec {
+ OpalChainSpec::from_genesis(
// Name
"Local Testnet",
// ID
@@ -180,8 +191,8 @@
)
}
-pub fn local_testnet_westend_config() -> ChainSpec {
- ChainSpec::from_genesis(
+pub fn local_testnet_westend_config() -> OpalChainSpec {
+ OpalChainSpec::from_genesis(
// Name
"Local Testnet",
// ID
@@ -238,8 +249,8 @@
initial_authorities: Vec<AuraId>,
endowed_accounts: Vec<AccountId>,
id: ParaId,
-) -> unique_runtime::GenesisConfig {
- use unique_runtime::*;
+) -> opal_runtime::GenesisConfig {
+ use opal_runtime::*;
GenesisConfig {
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 {