--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -14,7 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Unique Network. If not, see .
-use cumulus_primitives_core::ParaId;
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use sp_core::{sr25519, Pair, Public};
@@ -26,6 +25,15 @@
use unique_runtime_common::types::*;
+#[cfg(feature = "unique-runtime")]
+use unique_runtime as default_runtime;
+
+#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
+use quartz_runtime as default_runtime;
+
+#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
+use opal_runtime as default_runtime;
+
/// The `ChainSpec` parameterized for the unique runtime.
#[cfg(feature = "unique-runtime")]
pub type UniqueChainSpec = sc_service::GenericChainSpec;
@@ -37,6 +45,15 @@
/// The `ChainSpec` parameterized for the opal runtime.
pub type OpalChainSpec = sc_service::GenericChainSpec;
+#[cfg(feature = "unique-runtime")]
+pub type DefaultChainSpec = UniqueChainSpec;
+
+#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]
+pub type DefaultChainSpec = QuartzChainSpec;
+
+#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]
+pub type DefaultChainSpec = OpalChainSpec;
+
pub enum RuntimeId {
#[cfg(feature = "unique-runtime")]
Unique,
@@ -125,11 +142,54 @@
AccountPublic::from(get_from_seed::(seed)).into_account()
}
+macro_rules! testnet_genesis {
+ (
+ $runtime:path,
+ $root_key:expr,
+ $initial_authorities:expr,
+ $endowed_accounts:expr,
+ $id:expr
+ ) => {{
+ use $runtime::*;
+
+ GenesisConfig {
+ system: SystemConfig {
+ code: WASM_BINARY
+ .expect("WASM binary was not build, please build it!")
+ .to_vec(),
+ },
+ balances: BalancesConfig {
+ balances: $endowed_accounts
+ .iter()
+ .cloned()
+ // 1e13 UNQ
+ .map(|k| (k, 1 << 100))
+ .collect(),
+ },
+ treasury: Default::default(),
+ sudo: SudoConfig {
+ key: Some($root_key),
+ },
+ vesting: VestingConfig { vesting: vec![] },
+ parachain_info: ParachainInfoConfig { parachain_id: $id.into() },
+ parachain_system: Default::default(),
+ aura: AuraConfig {
+ authorities: $initial_authorities,
+ },
+ aura_ext: Default::default(),
+ evm: EVMConfig {
+ accounts: BTreeMap::new(),
+ },
+ ethereum: EthereumConfig {},
+ }
+ }};
+}
+
pub fn development_config() -> OpalChainSpec {
let mut properties = Map::new();
- properties.insert("tokenSymbol".into(), "OPL".into());
+ properties.insert("tokenSymbol".into(), opal_runtime::TOKEN_SYMBOL.into());
properties.insert("tokenDecimals".into(), 18.into());
- properties.insert("ss58Format".into(), 42.into());
+ properties.insert("ss58Format".into(), opal_runtime::SS58Prefix::get().into());
OpalChainSpec::from_genesis(
// Name
@@ -138,7 +198,9 @@
"opal_dev",
ChainType::Local,
move || {
- testnet_genesis(
+ testnet_genesis!(
+ opal_runtime,
+
// Sudo account
get_account_id_from_seed::("Alice"),
vec![
@@ -150,7 +212,7 @@
get_account_id_from_seed::("Alice"),
get_account_id_from_seed::("Bob"),
],
- 1000.into(),
+ 1000
)
},
// Bootnodes
@@ -170,20 +232,26 @@
)
}
-pub fn local_testnet_rococo_config() -> OpalChainSpec {
+pub fn local_testnet_rococo_config() -> DefaultChainSpec {
let mut properties = Map::new();
- properties.insert("tokenSymbol".into(), "OPL".into());
+ properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());
properties.insert("tokenDecimals".into(), 18.into());
- properties.insert("ss58Format".into(), 42.into());
+ properties.insert("ss58Format".into(), default_runtime::SS58Prefix::get().into());
- OpalChainSpec::from_genesis(
+ DefaultChainSpec::from_genesis(
// Name
- "OPAL by UNIQUE",
+ format!(
+ "{}{}",
+ default_runtime::RUNTIME_NAME.to_uppercase(),
+ if cfg!(feature = "unique-runtime") { "" } else { " by UNIQUE" }
+ ).as_str(),
// ID
- "opal_local",
+ format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),
ChainType::Local,
move || {
- testnet_genesis(
+ testnet_genesis!(
+ default_runtime,
+
// Sudo account
get_account_id_from_seed::("Alice"),
vec![
@@ -205,7 +273,7 @@
get_account_id_from_seed::("Eve//stash"),
get_account_id_from_seed::("Ferdie//stash"),
],
- 1000.into(),
+ 1000
)
},
// Bootnodes
@@ -223,44 +291,4 @@
para_id: 1000,
},
)
-}
-
-fn testnet_genesis(
- root_key: AccountId,
- initial_authorities: Vec,
- endowed_accounts: Vec,
- id: ParaId,
-) -> opal_runtime::GenesisConfig {
- use opal_runtime::*;
-
- GenesisConfig {
- system: SystemConfig {
- code: WASM_BINARY
- .expect("WASM binary was not build, please build it!")
- .to_vec(),
- },
- balances: BalancesConfig {
- balances: endowed_accounts
- .iter()
- .cloned()
- // 1e13 UNQ
- .map(|k| (k, 1 << 100))
- .collect(),
- },
- treasury: Default::default(),
- sudo: SudoConfig {
- key: Some(root_key),
- },
- vesting: VestingConfig { vesting: vec![] },
- parachain_info: ParachainInfoConfig { parachain_id: id },
- parachain_system: Default::default(),
- aura: AuraConfig {
- authorities: initial_authorities,
- },
- aura_ext: Default::default(),
- evm: EVMConfig {
- accounts: BTreeMap::new(),
- },
- ethereum: EthereumConfig {},
- }
}
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -115,6 +115,7 @@
use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
pub const RUNTIME_NAME: &str = "opal";
+pub const TOKEN_SYMBOL: &str = "OPL";
type CrossAccountId = pallet_common::account::BasicCrossAccountId;
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -115,6 +115,7 @@
use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
pub const RUNTIME_NAME: &str = "quartz";
+pub const TOKEN_SYMBOL: &str = "QTZ";
type CrossAccountId = pallet_common::account::BasicCrossAccountId;
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -114,6 +114,7 @@
use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};
pub const RUNTIME_NAME: &str = "unique";
+pub const TOKEN_SYMBOL: &str = "UNQ";
type CrossAccountId = pallet_common::account::BasicCrossAccountId;