Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load battery station relay chain spec when using battery station parachain #420

Merged
merged 2 commits into from Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
139 changes: 139 additions & 0 deletions node/res/battery_station_relay.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion node/res/bs_parachain.json
Expand Up @@ -23,7 +23,7 @@
"tokenSymbol": "ZBS"
},
"parachain_id": 2050,
"relay_chain": "rococo",
"relay_chain": "battery_station_relay_v3",
"consensusEngine": null,
"codeSubstitutes": {},
"genesis": {
Expand Down
13 changes: 12 additions & 1 deletion node/src/cli/cli_parachain.rs
Expand Up @@ -6,6 +6,8 @@ use sc_service::config::{BasePath, PrometheusConfig};
use std::{net::SocketAddr, path::PathBuf};
use structopt::StructOpt;

const BATTERY_STATION_RELAY_ID: &str = "battery_station_relay_v3";

#[derive(Debug)]
pub struct RelayChainCli {
/// The actual relay chain cli object.
Expand All @@ -30,6 +32,7 @@ impl RelayChainCli {
.base_path
.as_ref()
.map(|x| x.path().join(chain_id.clone().unwrap_or_else(|| "polkadot".into())));

Self { base_path, chain_id, base: polkadot_cli::RunCmd::from_iter(relay_chain_args) }
}
}
Expand Down Expand Up @@ -178,8 +181,16 @@ impl sc_cli::SubstrateCli for RelayChainCli {
}

fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
<polkadot_cli::Cli as SubstrateCli>::from_iter([RelayChainCli::executable_name()].iter())
if id == BATTERY_STATION_RELAY_ID {
Ok(Box::new(polkadot_service::RococoChainSpec::from_json_bytes(
&include_bytes!("../../res/battery_station_relay.json")[..],
)?))
} else {
<polkadot_cli::Cli as SubstrateCli>::from_iter(
[RelayChainCli::executable_name()].iter(),
)
.load_spec(id)
}
}

fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
Expand Down