2022-07-15 04:05:00 +00:00
|
|
|
use sc_service::ChainType;
|
|
|
|
|
|
|
|
use sp_runtime::traits::Verify;
|
|
|
|
use sp_core::{sr25519, Pair, Public};
|
|
|
|
|
|
|
|
use sp_runtime::traits::IdentifyAccount;
|
|
|
|
|
2022-07-15 05:26:07 +00:00
|
|
|
use serai_runtime::{WASM_BINARY, AccountId, Signature, GenesisConfig, SystemConfig, BalancesConfig};
|
2022-07-15 04:05:00 +00:00
|
|
|
|
|
|
|
pub type ChainSpec = sc_service::GenericChainSpec<GenesisConfig>;
|
|
|
|
type AccountPublic = <Signature as Verify>::Signer;
|
|
|
|
|
|
|
|
fn get_from_seed<TPublic: Public>(seed: &'static str) -> <TPublic::Pair as Pair>::Public {
|
|
|
|
TPublic::Pair::from_string(&format!("//{}", seed), None).unwrap().public()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn get_account_id_from_seed<TPublic: Public>(seed: &'static str) -> AccountId
|
2022-07-15 05:26:07 +00:00
|
|
|
where
|
|
|
|
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
|
|
|
|
{
|
2022-07-15 04:05:00 +00:00
|
|
|
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
|
|
|
}
|
|
|
|
|
2022-07-15 05:26:07 +00:00
|
|
|
fn testnet_genesis(wasm_binary: &[u8], endowed_accounts: Vec<AccountId>) -> GenesisConfig {
|
2022-07-15 04:05:00 +00:00
|
|
|
GenesisConfig {
|
2022-07-15 05:26:07 +00:00
|
|
|
system: SystemConfig { code: wasm_binary.to_vec() },
|
2022-07-15 04:05:00 +00:00
|
|
|
balances: BalancesConfig {
|
|
|
|
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
|
|
|
},
|
2022-07-15 05:26:07 +00:00
|
|
|
transaction_payment: Default::default(),
|
2022-07-15 04:05:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn development_config() -> Result<ChainSpec, &'static str> {
|
2022-07-22 06:34:36 +00:00
|
|
|
let wasm_binary = WASM_BINARY.ok_or("Development wasm not available")?;
|
2022-07-15 04:05:00 +00:00
|
|
|
|
2022-07-15 05:26:07 +00:00
|
|
|
Ok(ChainSpec::from_genesis(
|
|
|
|
// Name
|
|
|
|
"Development Network",
|
|
|
|
// ID
|
|
|
|
"dev",
|
|
|
|
ChainType::Development,
|
|
|
|
|| {
|
|
|
|
testnet_genesis(
|
|
|
|
wasm_binary,
|
|
|
|
vec![
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
2022-09-12 20:01:14 +00:00
|
|
|
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
2022-07-15 05:26:07 +00:00
|
|
|
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
2022-09-12 20:01:14 +00:00
|
|
|
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
|
|
|
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
2022-07-15 05:26:07 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
},
|
|
|
|
// Bootnodes
|
|
|
|
vec![],
|
|
|
|
// Telemetry
|
|
|
|
None,
|
|
|
|
// Protocol ID
|
|
|
|
Some("serai"),
|
|
|
|
// Fork ID
|
|
|
|
None,
|
|
|
|
// Properties
|
|
|
|
None,
|
|
|
|
// Extensions
|
|
|
|
None,
|
|
|
|
))
|
2022-07-15 04:05:00 +00:00
|
|
|
}
|