Skip to content

Commit

Permalink
More nits for rococo-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
bkontur committed Sep 11, 2024
1 parent 6226e84 commit c35a621
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
18 changes: 15 additions & 3 deletions polkadot/runtime/rococo/src/genesis_config_presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ use crate::{
};
#[cfg(not(feature = "std"))]
use alloc::format;
use alloc::vec::Vec;
use alloc::{vec, vec::Vec};
use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, SchedulerParams, ValidatorId};
use rococo_runtime_constants::currency::UNITS as ROC;
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
use sp_consensus_babe::AuthorityId as BabeId;
use sp_consensus_beefy::ecdsa_crypto::AuthorityId as BeefyId;
use sp_consensus_grandpa::AuthorityId as GrandpaId;
use sp_core::{sr25519, Pair, Public};
use sp_genesis_builder::PresetId;
use sp_runtime::traits::IdentifyAccount;

/// Helper function to generate a crypto pair from seed
Expand Down Expand Up @@ -522,10 +523,10 @@ fn wococo_local_testnet_genesis() -> serde_json::Value {
}

/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<alloc::vec::Vec<u8>> {
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
let patch = match id.try_into() {
Ok("local_testnet") => rococo_local_testnet_genesis(),
Ok("development") => rococo_development_config_genesis(),
Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => rococo_development_config_genesis(),
Ok("staging_testnet") => rococo_staging_testnet_config_genesis(),
Ok("wococo_local_testnet") => wococo_local_testnet_genesis(),
Ok("versi_local_testnet") => versi_local_testnet_genesis(),
Expand All @@ -537,3 +538,14 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<alloc::vec::Vec<u
.into_bytes(),
)
}

/// List of supported presets.
pub fn preset_names() -> Vec<PresetId> {
vec![
PresetId::from("local_testnet"),
PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET),
PresetId::from("staging_testnet"),
PresetId::from("wococo_local_testnet"),
PresetId::from("versi_local_testnet"),
]
}
8 changes: 1 addition & 7 deletions polkadot/runtime/rococo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2582,13 +2582,7 @@ sp_api::impl_runtime_apis! {
}

fn preset_names() -> Vec<PresetId> {
vec![
PresetId::from("local_testnet"),
PresetId::from("development"),
PresetId::from("staging_testnet"),
PresetId::from("wococo_local_testnet"),
PresetId::from("versi_local_testnet"),
]
genesis_config_presets::preset_names()
}
}
}
Expand Down

0 comments on commit c35a621

Please sign in to comment.