diff --git a/parachains/chain-specs/bridge-hub-wococo.json b/parachains/chain-specs/bridge-hub-wococo.json new file mode 100644 index 0000000000..b96b5d4afb --- /dev/null +++ b/parachains/chain-specs/bridge-hub-wococo.json @@ -0,0 +1 @@ +TODO: setup diff --git a/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/polkadot-parachain/src/chain_spec/bridge_hubs.rs index ed2f678ee5..7855f37866 100644 --- a/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -54,23 +54,37 @@ impl BridgeHubRuntimeType { })) } - pub fn load_config(&self) -> Box { - Box::new(match self { + pub fn load_config(&self) -> Result, String> { + match self { BridgeHubRuntimeType::Rococo => - rococo::live_config(rococo::BRIDGE_HUB_ROCOCO, "Rococo BrideHub", "rococo", ParaId::new(1013)), - BridgeHubRuntimeType::RococoLocal => - rococo::local_config(rococo::BRIDGE_HUB_ROCOCO_LOCAL, "Rococo BrideHub Local", "rococo-local", ParaId::new(1013)), + Ok(Box::new(rococo::BridgeHubChainSpec::from_json_bytes( + &include_bytes!("../../../parachains/chain-specs/bridge-hub-rococo.json")[..], + )?)), + BridgeHubRuntimeType::RococoLocal => Ok(Box::new(rococo::local_config( + rococo::BRIDGE_HUB_ROCOCO_LOCAL, + "Rococo BrideHub Local", + "rococo-local", + ParaId::new(1013), + ))), BridgeHubRuntimeType::Wococo => - wococo::live_config(wococo::BRIDGE_HUB_WOCOCO, "Wococo BrideHub", "wococo", ParaId::new(1013)), - BridgeHubRuntimeType::WococoLocal => - wococo::local_config(wococo::BRIDGE_HUB_WOCOCO_LOCAL, "Wococo BrideHub Local", "wococo-local", ParaId::new(1013)), - }) + Ok(Box::new(rococo::BridgeHubChainSpec::from_json_bytes( + &include_bytes!("../../../parachains/chain-specs/bridge-hub-wococo.json")[..], + )?)), + BridgeHubRuntimeType::WococoLocal => Ok(Box::new(wococo::local_config( + wococo::BRIDGE_HUB_WOCOCO_LOCAL, + "Wococo BrideHub Local", + "wococo-local", + ParaId::new(1013), + ))), + } } pub fn runtime_version(&self) -> &'static RuntimeVersion { match self { - BridgeHubRuntimeType::Rococo | BridgeHubRuntimeType::Wococo | - BridgeHubRuntimeType::RococoLocal | BridgeHubRuntimeType::WococoLocal => { + BridgeHubRuntimeType::Rococo | + BridgeHubRuntimeType::Wococo | + BridgeHubRuntimeType::RococoLocal | + BridgeHubRuntimeType::WococoLocal => { // this is intentional, for Rococo/Wococo we just want to have one runtime, which is configured for both sides &bridge_hub_rococo_runtime::VERSION }, @@ -110,65 +124,6 @@ pub mod rococo { pub type RuntimeApi = bridge_hub_rococo_runtime::RuntimeApi; - pub fn live_config( - id: &str, - chain_name: &str, - relay_chain: &str, - para_id: ParaId, - ) -> BridgeHubChainSpec { - let properties = sc_chain_spec::Properties::new(); - // TODO: check - // properties.insert("ss58Format".into(), 2.into()); - // properties.insert("tokenSymbol".into(), "ROC".into()); - // properties.insert("tokenDecimals".into(), 12.into()); - - BridgeHubChainSpec::from_genesis( - // Name - chain_name, - // ID - super::ensure_id(id).expect("invalid id"), - ChainType::Live, - move || { - genesis( - // initial collators. - vec![ - ( - get_account_id_from_seed::("Alice"), - get_collator_keys_from_seed::("Alice"), - ), - ( - get_account_id_from_seed::("Bob"), - get_collator_keys_from_seed::("Bob"), - ), - ], - vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ], - para_id, - None, - None, - ) - }, - Vec::new(), - None, - None, - None, - Some(properties), - Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() }, - ) - } - pub fn local_config( id: &str, chain_name: &str, @@ -302,13 +257,4 @@ pub mod wococo { ) -> BridgeHubChainSpec { rococo::local_config(id, chain_name, relay_chain, para_id) } - - pub fn live_config( - id: &str, - chain_name: &str, - relay_chain: &str, - para_id: ParaId, - ) -> BridgeHubChainSpec { - rococo::live_config(id, chain_name, relay_chain, para_id) - } } diff --git a/polkadot-parachain/src/command.rs b/polkadot-parachain/src/command.rs index 5e0950a567..fe8dc65586 100644 --- a/polkadot-parachain/src/command.rs +++ b/polkadot-parachain/src/command.rs @@ -203,7 +203,7 @@ fn load_spec(id: &str) -> std::result::Result, String> { bridge_like_id .parse::() .expect("invalid value") - .load_config(), + .load_config()?, // -- Penpall "penpal-kusama" => Box::new(chain_spec::penpal::get_penpal_chain_spec(