mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Add an initial Substrate instantiation
Consensus has been nuked for an AcceptAny currently routed throough PoW (when it doesn't have to be, doing so just took care of a few pieces of leg work). Updates AGPL handling.
This commit is contained in:
74
substrate/node/src/chain_spec.rs
Normal file
74
substrate/node/src/chain_spec.rs
Normal file
@@ -0,0 +1,74 @@
|
||||
use sc_service::ChainType;
|
||||
|
||||
use sp_runtime::traits::Verify;
|
||||
use sp_core::{sr25519, Pair, Public};
|
||||
|
||||
use sp_runtime::traits::IdentifyAccount;
|
||||
|
||||
use serai_runtime::{
|
||||
WASM_BINARY, AccountId, Signature, GenesisConfig, SystemConfig, BalancesConfig
|
||||
};
|
||||
|
||||
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
|
||||
where AccountPublic: From<<TPublic::Pair as Pair>::Public> {
|
||||
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
|
||||
}
|
||||
|
||||
fn testnet_genesis(
|
||||
wasm_binary: &[u8],
|
||||
endowed_accounts: Vec<AccountId>
|
||||
) -> GenesisConfig {
|
||||
GenesisConfig {
|
||||
system: SystemConfig {
|
||||
code: wasm_binary.to_vec(),
|
||||
},
|
||||
balances: BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||
},
|
||||
transaction_payment: Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn development_config() -> Result<ChainSpec, &'static str> {
|
||||
let wasm_binary = WASM_BINARY.ok_or_else(|| "Development wasm not available")?;
|
||||
|
||||
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"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
]
|
||||
)
|
||||
},
|
||||
// Bootnodes
|
||||
vec![],
|
||||
// Telemetry
|
||||
None,
|
||||
// Protocol ID
|
||||
Some("serai"),
|
||||
// Fork ID
|
||||
None,
|
||||
// Properties
|
||||
None,
|
||||
// Extensions
|
||||
None
|
||||
)
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user