Skip to content

Commit

Permalink
fn preset_names added
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkucharczyk committed Aug 30, 2024
1 parent ccdfe51 commit 13f411d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use cumulus_primitives_core::ParaId;
use hex_literal::hex;
use parachains_common::{genesis_config_helpers::*, AccountId, AuraId, Balance as AssetHubBalance};
use sp_core::{crypto::UncheckedInto, sr25519};
use sp_genesis_builder::PresetId;
use testnet_parachains_constants::rococo::xcm_version::SAFE_XCM_VERSION;

const ASSET_HUB_ROCOCO_ED: AssetHubBalance = crate::ExistentialDeposit::get();
Expand Down Expand Up @@ -75,14 +76,14 @@ fn asset_hub_rococo_genesis(
}

/// Encapsulates names of predefined presets.
pub mod preset_names {
mod preset_names {
pub const PRESET_DEVELOPMENT: &str = "development";
pub const PRESET_LOCAL: &str = "local";
pub const PRESET_GENESIS: &str = "genesis";
}

/// Provides the JSON representation of predefined genesis config for given `id`.
pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<Vec<u8>> {
pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
use preset_names::*;
let patch = match id.try_into() {
Ok(PRESET_GENESIS) => asset_hub_rococo_genesis(
Expand Down Expand Up @@ -170,3 +171,13 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option<Vec<u8>> {
.into_bytes(),
)
}

/// List of supported presets.
pub fn preset_names() -> Vec<PresetId> {
use preset_names::*;
vec![
PresetId::from(PRESET_GENESIS),
PresetId::from(PRESET_DEVELOPMENT),
PresetId::from(PRESET_LOCAL),
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -1776,12 +1776,7 @@ impl_runtime_apis! {
}

fn preset_names() -> Vec<PresetId> {
use crate::genesis_config_presets::preset_names::*;
vec![
PresetId::from(PRESET_GENESIS),
PresetId::from(PRESET_DEVELOPMENT),
PresetId::from(PRESET_LOCAL),
]
genesis_config_presets::preset_names()
}
}
}
Expand Down

0 comments on commit 13f411d

Please sign in to comment.