Skip to content

Commit

Permalink
remove_phantom_fields unneeded
Browse files Browse the repository at this point in the history
  • Loading branch information
dharjeezy committed Dec 26, 2024
1 parent e1fe0c2 commit de27440
Show file tree
Hide file tree
Showing 12 changed files with 12 additions and 58 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,10 @@ fn bridge_hub_kusama_genesis(
parachain_system: Default::default(),
transaction_payment: Default::default(),
bridge_polkadot_messages: Default::default(),
xcm_over_bridge_hub_polkadot: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn bridge_hub_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ fn bridge_hub_polkadot_genesis(
bridge_kusama_grandpa: Default::default(),
bridge_kusama_parachains: Default::default(),
bridge_kusama_messages: Default::default(),
xcm_over_bridge_hub_kusama: Default::default(),
ethereum_system: EthereumSystemConfig {
para_id: id,
asset_hub_para_id: polkadot_runtime_constants::system_parachain::ASSET_HUB_ID.into(),
Expand All @@ -76,10 +77,7 @@ fn bridge_hub_polkadot_genesis(
transaction_payment: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn bridge_hub_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ fn collectives_polkadot_genesis(
ambassador_treasury: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn collectives_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
1 change: 0 additions & 1 deletion system-parachains/constants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ sp-core = { workspace = true }
sp-runtime = { workspace = true }
sp-std = { workspace = true }
xcm = { workspace = true }
serde_json = { features = ["alloc"], workspace = true }

[features]
default = ["std"]
Expand Down
20 changes: 1 addition & 19 deletions system-parachains/constants/src/genesis_presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

use parachains_common::AuraId;
use polkadot_primitives::{AccountId, AccountPublic};
use serde_json::Value;
use sp_core::{sr25519, Pair, Public};
use sp_runtime::traits::IdentifyAccount;
#[cfg(not(feature = "std"))]
Expand Down Expand Up @@ -66,21 +65,4 @@ where
}

/// The default XCM version to set in genesis config.
pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;

pub fn remove_phantom_fields(value: &mut Value) {
match value {
Value::Object(map) => {
map.remove("phantom");

for (_, v) in map.iter_mut() {
remove_phantom_fields(v);
}
},
Value::Array(arr) =>
for v in arr.iter_mut() {
remove_phantom_fields(v);
},
_ => {},
}
}
pub const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ fn coretime_kusama_genesis(
broker: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn coretime_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ fn coretime_polkadot_genesis(
broker: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

fn coretime_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
5 changes: 1 addition & 4 deletions system-parachains/encointer/src/genesis_config_presets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ fn encointer_kusama_genesis(
encointer_democracy: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn encointer_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
use crate::*;
use cumulus_primitives_core::ParaId;
use sp_genesis_builder::PresetId;
use system_parachains_constants::genesis_presets::remove_phantom_fields;

fn glutton_kusama_genesis(id: ParaId) -> serde_json::Value {
let config = RuntimeGenesisConfig {
Expand All @@ -30,10 +29,7 @@ fn glutton_kusama_genesis(id: ParaId) -> serde_json::Value {
sudo: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn glutton_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ fn people_kusama_genesis(
transaction_payment: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn people_kusama_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ fn people_polkadot_genesis(
transaction_payment: Default::default(),
};

let mut config_values = serde_json::to_value(config).expect("Could not build genesis config.");
remove_phantom_fields(&mut config_values);

config_values
serde_json::to_value(config).expect("Could not build genesis config.")
}

pub fn people_polkadot_local_testnet_genesis(para_id: ParaId) -> serde_json::Value {
Expand Down

0 comments on commit de27440

Please sign in to comment.