Skip to content
Snippets Groups Projects
Commit ded25e75 authored by Éloïs's avatar Éloïs
Browse files

feat(gdev): create local chain spec

parent 26f4cc13
No related branches found
No related tags found
1 merge request!28Smiths sub-wot
......@@ -101,6 +101,54 @@ pub fn development_chain_spec() -> Result<ChainSpec, String> {
))
}
pub fn local_testnet_config(
initial_authorities_len: usize,
initial_smiths_len: usize,
initial_identities_len: usize,
) -> Result<ChainSpec, String> {
let wasm_binary = WASM_BINARY.ok_or_else(|| "wasm not available".to_string())?;
Ok(ChainSpec::from_genesis(
// Name
"Ğdev Local Testnet",
// ID
"gdev_local_testnet",
ChainType::Local,
move || {
gen_genesis_conf(
wasm_binary,
// Initial authorities len
initial_authorities_len,
// Initial smiths len,
initial_smiths_len,
// Initial identities len
initial_identities_len,
// Sudo account
get_account_id_from_seed::<sr25519::Public>("Alice"),
true,
)
},
// Bootnodes
vec![],
// Telemetry
None,
// Protocol ID
None,
// Properties
Some(
serde_json::json!({
"tokenDecimals": TOKEN_DECIMALS,
"tokenSymbol": TOKEN_SYMBOL,
})
.as_object()
.expect("must be a map")
.clone(),
),
// Extensions
None,
))
}
fn gen_genesis_conf(
wasm_binary: &[u8],
initial_authorities_len: usize,
......
......@@ -54,15 +54,38 @@ impl SubstrateCli for Cli {
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
Ok(match id {
#[cfg(feature = "gdev")]
"dev" | "gdev" => Box::new(chain_spec::gdev::development_chain_spec()?),
"dev" => Box::new(chain_spec::gdev::development_chain_spec()?),
#[cfg(feature = "gdev")]
"local" => Box::new(chain_spec::gdev::local_testnet_config(1, 3, 4)?),
#[cfg(feature = "gdev")]
"local2" => Box::new(chain_spec::gdev::local_testnet_config(2, 3, 4)?),
#[cfg(feature = "gdev")]
"local3" => Box::new(chain_spec::gdev::local_testnet_config(3, 3, 4)?),
#[cfg(feature = "gdev")]
"local4" => Box::new(chain_spec::gdev::local_testnet_config(4, 4, 5)?),
#[cfg(feature = "gdev")]
"gdev" => {
unimplemented!()
//Box::new(chain_spec::gdev::ChainSpec::from_json_file(file_path)?)
}
#[cfg(feature = "gtest")]
"gtest_dev" => Box::new(chain_spec::gtest::development_chain_spec()?),
#[cfg(feature = "gtest")]
"local" | "gtest_local" => Box::new(chain_spec::gtest::local_testnet_config(2, 3)?),
"gtest_local" => Box::new(chain_spec::gtest::local_testnet_config(2, 3)?),
#[cfg(feature = "gtest")]
"gtest_local3" => Box::new(chain_spec::gtest::local_testnet_config(3, 4)?),
#[cfg(feature = "gtest")]
"local3" | "gtest_local3" => Box::new(chain_spec::gtest::local_testnet_config(3, 4)?),
"gtest_local4" => Box::new(chain_spec::gtest::local_testnet_config(4, 5)?),
#[cfg(feature = "gtest")]
"local4" | "gtest_local4" => Box::new(chain_spec::gtest::local_testnet_config(4, 5)?),
"gtest" => {
unimplemented!()
//Box::new(chain_spec::gtest::ChainSpec::from_json_file(file_path)?)
}
#[cfg(feature = "g1")]
"g1" => {
unimplemented!()
//Box::new(chain_spec::g1::ChainSpec::from_json_file(file_path)?)
}
// Specs provided as json specify which runtime to use in their file name. For example,
// `g1-custom.json` uses the g1 runtime.
// `gdev-workshop.json` uses the gdev runtime.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment