Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/oty-import-v1.1.0-rc2' into oty-…
Browse files Browse the repository at this point in the history
…import-v1.1.0-rc2
  • Loading branch information
ggwpez committed Sep 20, 2023
2 parents 74e4217 + 122d3b2 commit f4cab62
Show file tree
Hide file tree
Showing 5 changed files with 643 additions and 6 deletions.
97 changes: 91 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ license = "GPL-3.0-only" # TODO <https://github.com/polkadot-fellows/runtimes/is
resolver = "2"

members = [
"chain-spec-generator",
"relay/kusama",
"relay/kusama/constants",
"relay/polkadot",
Expand Down
29 changes: 29 additions & 0 deletions chain-spec-generator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "chain-spec-generator"
version.workspace = true
authors.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true

[dependencies]
clap = "4.4.4"
hex-literal = "0.4.1"
serde_json = "1.0.107"

polkadot-runtime = { path = "../relay/polkadot" }
polkadot-runtime-constants = { path = "../relay/polkadot/constants" }
kusama-runtime = { package = "staging-kusama-runtime", path = "../relay/kusama" }
kusama-runtime-constants = { path = "../relay/kusama/constants" }

sc-chain-spec = "22.0.0"
polkadot-runtime-parachains = "2.0.0"
polkadot-primitives = "2.0.0"
sp-consensus-babe = "0.27.0"
sp-authority-discovery = "21.0.0"
sp-core = "23.0.0"
pallet-staking = "23.0.0"
sc-consensus-grandpa = "0.14.0"
pallet-im-online = "22.0.0"
sp-runtime = "26.0.0"
sp-consensus-beefy = "8.0.0"
48 changes: 48 additions & 0 deletions chain-spec-generator/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
use clap::Parser;
use sc_chain_spec::ChainSpec;
use std::collections::HashMap;

mod relay_chain_specs;

#[derive(Parser)]
struct Cli {
/// The chain spec to generate.
chain: String,

/// Generate the chain spec as raw?
#[arg(long)]
raw: bool,
}

fn main() -> Result<(), String> {
let cli = Cli::parse();

let supported_chains =
HashMap::<_, Box<dyn Fn() -> Result<Box<dyn ChainSpec>, String>>>::from([
(
"polkadot-dev",
Box::new(|| relay_chain_specs::polkadot_development_config()) as Box<_>,
),
(
"polkadot-local",
Box::new(|| relay_chain_specs::polkadot_local_testnet_config()) as Box<_>,
),
("kusama-dev", Box::new(|| relay_chain_specs::kusama_development_config()) as Box<_>),
(
"kusama-local",
Box::new(|| relay_chain_specs::kusama_local_testnet_config()) as Box<_>,
),
]);

if let Some(function) = supported_chains.get(&*cli.chain) {
let chain_spec = (*function)()?.as_json(cli.raw)?;
print!("{chain_spec}");
Ok(())
} else {
let supported = supported_chains.keys().enumerate().fold(String::new(), |c, (n, k)| {
let extra = (n + 1 < supported_chains.len()).then(|| ", ").unwrap_or("");
format!("{c}{k}{extra}")
});
Err(format!("Unknown chain, only supported: {supported}"))
}
}
Loading

0 comments on commit f4cab62

Please sign in to comment.