difftreelog
Use default runtime in the local testnet
in: master
4 files changed
node/cli/src/chain_spec.rsdiffbeforeafterboth14// You should have received a copy of the GNU General Public License14// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.161617use cumulus_primitives_core::ParaId;18use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};17use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};19use sc_service::ChainType;18use sc_service::ChainType;20use sp_core::{sr25519, Pair, Public};19use sp_core::{sr25519, Pair, Public};262527use unique_runtime_common::types::*;26use unique_runtime_common::types::*;2728#[cfg(feature = "unique-runtime")]29use unique_runtime as default_runtime;3031#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]32use quartz_runtime as default_runtime;3334#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]35use opal_runtime as default_runtime;283629/// The `ChainSpec` parameterized for the unique runtime.37/// The `ChainSpec` parameterized for the unique runtime.30#[cfg(feature = "unique-runtime")]38#[cfg(feature = "unique-runtime")]37/// The `ChainSpec` parameterized for the opal runtime.45/// The `ChainSpec` parameterized for the opal runtime.38pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;46pub type OpalChainSpec = sc_service::GenericChainSpec<opal_runtime::GenesisConfig, Extensions>;4748#[cfg(feature = "unique-runtime")]49pub type DefaultChainSpec = UniqueChainSpec;5051#[cfg(all(not(feature = "unique-runtime"), feature = "quartz-runtime"))]52pub type DefaultChainSpec = QuartzChainSpec;5354#[cfg(all(not(feature = "unique-runtime"), not(feature = "quartz-runtime")))]55pub type DefaultChainSpec = OpalChainSpec;395640pub enum RuntimeId {57pub enum RuntimeId {41 #[cfg(feature = "unique-runtime")]58 #[cfg(feature = "unique-runtime")]125 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()142 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()126}143}144145macro_rules! testnet_genesis {146 (147 $runtime:path,148 $root_key:expr,149 $initial_authorities:expr,150 $endowed_accounts:expr,151 $id:expr152 ) => {{153 use $runtime::*;154155 GenesisConfig {156 system: SystemConfig {157 code: WASM_BINARY158 .expect("WASM binary was not build, please build it!")159 .to_vec(),160 },161 balances: BalancesConfig {162 balances: $endowed_accounts163 .iter()164 .cloned()165 // 1e13 UNQ166 .map(|k| (k, 1 << 100))167 .collect(),168 },169 treasury: Default::default(),170 sudo: SudoConfig {171 key: Some($root_key),172 },173 vesting: VestingConfig { vesting: vec![] },174 parachain_info: ParachainInfoConfig { parachain_id: $id.into() },175 parachain_system: Default::default(),176 aura: AuraConfig {177 authorities: $initial_authorities,178 },179 aura_ext: Default::default(),180 evm: EVMConfig {181 accounts: BTreeMap::new(),182 },183 ethereum: EthereumConfig {},184 }185 }};186}127187128pub fn development_config() -> OpalChainSpec {188pub fn development_config() -> OpalChainSpec {129 let mut properties = Map::new();189 let mut properties = Map::new();130 properties.insert("tokenSymbol".into(), "OPL".into());190 properties.insert("tokenSymbol".into(), opal_runtime::TOKEN_SYMBOL.into());131 properties.insert("tokenDecimals".into(), 18.into());191 properties.insert("tokenDecimals".into(), 18.into());132 properties.insert("ss58Format".into(), 42.into());192 properties.insert("ss58Format".into(), opal_runtime::SS58Prefix::get().into());133193134 OpalChainSpec::from_genesis(194 OpalChainSpec::from_genesis(135 // Name195 // Name138 "opal_dev",198 "opal_dev",139 ChainType::Local,199 ChainType::Local,140 move || {200 move || {141 testnet_genesis(201 testnet_genesis!(202 opal_runtime,203142 // Sudo account204 // Sudo account143 get_account_id_from_seed::<sr25519::Public>("Alice"),205 get_account_id_from_seed::<sr25519::Public>("Alice"),144 vec![206 vec![145 get_from_seed::<AuraId>("Alice"),207 get_from_seed::<AuraId>("Alice"),146 get_from_seed::<AuraId>("Bob"),208 get_from_seed::<AuraId>("Bob"),150 get_account_id_from_seed::<sr25519::Public>("Alice"),212 get_account_id_from_seed::<sr25519::Public>("Alice"),151 get_account_id_from_seed::<sr25519::Public>("Bob"),213 get_account_id_from_seed::<sr25519::Public>("Bob"),152 ],214 ],153 1000.into(),215 1000154 )216 )155 },217 },156 // Bootnodes218 // Bootnodes170 )232 )171}233}172234173pub fn local_testnet_rococo_config() -> OpalChainSpec {235pub fn local_testnet_rococo_config() -> DefaultChainSpec {174 let mut properties = Map::new();236 let mut properties = Map::new();175 properties.insert("tokenSymbol".into(), "OPL".into());237 properties.insert("tokenSymbol".into(), default_runtime::TOKEN_SYMBOL.into());176 properties.insert("tokenDecimals".into(), 18.into());238 properties.insert("tokenDecimals".into(), 18.into());177 properties.insert("ss58Format".into(), 42.into());239 properties.insert("ss58Format".into(), default_runtime::SS58Prefix::get().into());178240179 OpalChainSpec::from_genesis(241 DefaultChainSpec::from_genesis(180 // Name242 // Name243 format!(244 "{}{}",245 default_runtime::RUNTIME_NAME.to_uppercase(),181 "OPAL by UNIQUE",246 if cfg!(feature = "unique-runtime") { "" } else { " by UNIQUE" }247 ).as_str(),182 // ID248 // ID183 "opal_local",249 format!("{}_local", default_runtime::RUNTIME_NAME).as_str(),184 ChainType::Local,250 ChainType::Local,185 move || {251 move || {186 testnet_genesis(252 testnet_genesis!(253 default_runtime,254187 // Sudo account255 // Sudo account188 get_account_id_from_seed::<sr25519::Public>("Alice"),256 get_account_id_from_seed::<sr25519::Public>("Alice"),189 vec![257 vec![190 get_from_seed::<AuraId>("Alice"),258 get_from_seed::<AuraId>("Alice"),191 get_from_seed::<AuraId>("Bob"),259 get_from_seed::<AuraId>("Bob"),205 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),273 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),206 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),274 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),207 ],275 ],208 1000.into(),276 1000209 )277 )210 },278 },211 // Bootnodes279 // Bootnodes225 )293 )226}294}227228fn testnet_genesis(229 root_key: AccountId,230 initial_authorities: Vec<AuraId>,231 endowed_accounts: Vec<AccountId>,232 id: ParaId,233) -> opal_runtime::GenesisConfig {234 use opal_runtime::*;235236 GenesisConfig {237 system: SystemConfig {238 code: WASM_BINARY239 .expect("WASM binary was not build, please build it!")240 .to_vec(),241 },242 balances: BalancesConfig {243 balances: endowed_accounts244 .iter()245 .cloned()246 // 1e13 UNQ247 .map(|k| (k, 1 << 100))248 .collect(),249 },250 treasury: Default::default(),251 sudo: SudoConfig {252 key: Some(root_key),253 },254 vesting: VestingConfig { vesting: vec![] },255 parachain_info: ParachainInfoConfig { parachain_id: id },256 parachain_system: Default::default(),257 aura: AuraConfig {258 authorities: initial_authorities,259 },260 aura_ext: Default::default(),261 evm: EVMConfig {262 accounts: BTreeMap::new(),263 },264 ethereum: EthereumConfig {},265 }266}267295runtime/opal/src/lib.rsdiffbeforeafterboth115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};116116117pub const RUNTIME_NAME: &str = "opal";117pub const RUNTIME_NAME: &str = "opal";118pub const TOKEN_SYMBOL: &str = "OPL";118119119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120121runtime/quartz/src/lib.rsdiffbeforeafterboth115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};116116117pub const RUNTIME_NAME: &str = "quartz";117pub const RUNTIME_NAME: &str = "quartz";118pub const TOKEN_SYMBOL: &str = "QTZ";118119119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;120121runtime/unique/src/lib.rsdiffbeforeafterboth114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};114use unique_runtime_common::{impl_common_runtime_apis, types::*, constants::*};115115116pub const RUNTIME_NAME: &str = "unique";116pub const RUNTIME_NAME: &str = "unique";117pub const TOKEN_SYMBOL: &str = "UNQ";117118118type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;119type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;119120