mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-06 02:08:02 +00:00
Fix chain spec handling (#438)
Before when loading a chain spec from a file it was always using the rococo parachains runtime genesis config. This leaded to problems when trying to convert a shell chain spec json file to a raw chain spec.
This commit is contained in:
@@ -49,9 +49,17 @@ fn load_spec(
|
||||
)?)),
|
||||
"shell" => Ok(Box::new(chain_spec::get_shell_chain_spec(para_id))),
|
||||
"" => Ok(Box::new(chain_spec::get_chain_spec(para_id))),
|
||||
path => Ok(Box::new(chain_spec::ChainSpec::from_json_file(
|
||||
path => Ok({
|
||||
let chain_spec = chain_spec::ChainSpec::from_json_file(
|
||||
path.into(),
|
||||
)?)),
|
||||
)?;
|
||||
|
||||
if use_shell_runtime(&chain_spec) {
|
||||
Box::new(chain_spec::ShellChainSpec::from_json_file(path.into())?)
|
||||
} else {
|
||||
Box::new(chain_spec)
|
||||
}
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +99,7 @@ impl SubstrateCli for Cli {
|
||||
}
|
||||
|
||||
fn native_runtime_version(chain_spec: &Box<dyn ChainSpec>) -> &'static RuntimeVersion {
|
||||
if use_shell_runtime(chain_spec) {
|
||||
if use_shell_runtime(&**chain_spec) {
|
||||
&shell_runtime::VERSION
|
||||
} else {
|
||||
&rococo_parachain_runtime::VERSION
|
||||
@@ -149,8 +157,8 @@ fn extract_genesis_wasm(chain_spec: &Box<dyn sc_service::ChainSpec>) -> Result<V
|
||||
.ok_or_else(|| "Could not find wasm file in genesis state!".into())
|
||||
}
|
||||
|
||||
fn use_shell_runtime(chain_spec: &Box<dyn ChainSpec>) -> bool {
|
||||
chain_spec.id().starts_with("track") || chain_spec.id().starts_with("shell")
|
||||
fn use_shell_runtime(chain_spec: &dyn ChainSpec) -> bool {
|
||||
chain_spec.id().starts_with("shell")
|
||||
}
|
||||
|
||||
use crate::service::{new_partial, RococoParachainRuntimeExecutor, ShellRuntimeExecutor};
|
||||
@@ -158,7 +166,7 @@ use crate::service::{new_partial, RococoParachainRuntimeExecutor, ShellRuntimeEx
|
||||
macro_rules! construct_async_run {
|
||||
(|$components:ident, $cli:ident, $cmd:ident, $config:ident| $( $code:tt )* ) => {{
|
||||
let runner = $cli.create_runner($cmd)?;
|
||||
if use_shell_runtime(&runner.config().chain_spec) {
|
||||
if use_shell_runtime(&*runner.config().chain_spec) {
|
||||
runner.async_run(|$config| {
|
||||
let $components = new_partial::<shell_runtime::RuntimeApi, ShellRuntimeExecutor, _>(
|
||||
&$config,
|
||||
@@ -284,7 +292,7 @@ pub fn run() -> Result<()> {
|
||||
}
|
||||
None => {
|
||||
let runner = cli.create_runner(&cli.run.normalize())?;
|
||||
let use_shell = use_shell_runtime(&runner.config().chain_spec);
|
||||
let use_shell = use_shell_runtime(&*runner.config().chain_spec);
|
||||
|
||||
runner.run_node_until_exit(|config| async move {
|
||||
// TODO
|
||||
|
||||
Reference in New Issue
Block a user