mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-18 12:55:41 +00:00
make polkadot-runtime optional feature (#3820)
* make polkadot-runtime optional feature * sprinkle some cfg statements * ok * ok, ok * add CI check * set -e * chmod +x * fixes * fmt * nicer compile errors * Update outdated comments
This commit is contained in:
@@ -24,8 +24,10 @@ use kusama_runtime as kusama;
|
||||
use kusama_runtime::constants::currency::UNITS as KSM;
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use pallet_staking::Forcing;
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
use polkadot::constants::currency::UNITS as DOT;
|
||||
use polkadot_primitives::v1::{AccountId, AccountPublic, AssignmentId, ValidatorId};
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
use polkadot_runtime as polkadot;
|
||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||
use sp_consensus_babe::AuthorityId as BabeId;
|
||||
@@ -44,6 +46,7 @@ use westend_runtime as westend;
|
||||
#[cfg(feature = "westend-native")]
|
||||
use westend_runtime::constants::currency::UNITS as WND;
|
||||
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
const POLKADOT_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
#[cfg(feature = "kusama-native")]
|
||||
const KUSAMA_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||
@@ -71,34 +74,42 @@ pub struct Extensions {
|
||||
}
|
||||
|
||||
/// The `ChainSpec` parameterized for the polkadot runtime.
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
pub type PolkadotChainSpec = service::GenericChainSpec<polkadot::GenesisConfig, Extensions>;
|
||||
|
||||
// Dummy chain spec, in case when we don't have the native runtime.
|
||||
pub type DummyChainSpec = service::GenericChainSpec<(), Extensions>;
|
||||
|
||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
||||
#[cfg(not(feature = "polkadot-native"))]
|
||||
pub type PolkadotChainSpec = DummyChainSpec;
|
||||
|
||||
/// The `ChainSpec` parameterized for the kusama runtime.
|
||||
#[cfg(feature = "kusama-native")]
|
||||
pub type KusamaChainSpec = service::GenericChainSpec<kusama::GenesisConfig, Extensions>;
|
||||
|
||||
/// The `ChainSpec` parameterized for the kusama runtime.
|
||||
// This actually uses the polkadot chain spec, but that is fine when we don't have the native runtime.
|
||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
||||
#[cfg(not(feature = "kusama-native"))]
|
||||
pub type KusamaChainSpec = PolkadotChainSpec;
|
||||
pub type KusamaChainSpec = DummyChainSpec;
|
||||
|
||||
/// The `ChainSpec` parameterized for the westend runtime.
|
||||
#[cfg(feature = "westend-native")]
|
||||
pub type WestendChainSpec = service::GenericChainSpec<westend::GenesisConfig, Extensions>;
|
||||
|
||||
/// The `ChainSpec` parameterized for the westend runtime.
|
||||
// This actually uses the polkadot chain spec, but that is fine when we don't have the native runtime.
|
||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
||||
#[cfg(not(feature = "westend-native"))]
|
||||
pub type WestendChainSpec = PolkadotChainSpec;
|
||||
pub type WestendChainSpec = DummyChainSpec;
|
||||
|
||||
/// The `ChainSpec` parameterized for the rococo runtime.
|
||||
#[cfg(feature = "rococo-native")]
|
||||
pub type RococoChainSpec = service::GenericChainSpec<RococoGenesisExt, Extensions>;
|
||||
|
||||
/// The `ChainSpec` parameterized for the rococo runtime.
|
||||
// This actually uses the polkadot chain spec, but that is fine when we don't have the native runtime.
|
||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
||||
#[cfg(not(feature = "rococo-native"))]
|
||||
pub type RococoChainSpec = PolkadotChainSpec;
|
||||
pub type RococoChainSpec = DummyChainSpec;
|
||||
|
||||
/// Extension for the Rococo genesis config to support a custom changes to the genesis state.
|
||||
#[derive(serde::Serialize, serde::Deserialize)]
|
||||
@@ -195,6 +206,7 @@ fn default_parachains_host_configuration(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
fn polkadot_session_keys(
|
||||
babe: BabeId,
|
||||
grandpa: GrandpaId,
|
||||
@@ -272,6 +284,7 @@ fn rococo_session_keys(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
fn polkadot_staging_testnet_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
|
||||
// subkey inspect "$SECRET"
|
||||
let endowed_accounts = vec![];
|
||||
@@ -1053,6 +1066,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
|
||||
}
|
||||
|
||||
/// Polkadot staging testnet config.
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
pub fn polkadot_staging_testnet_config() -> Result<PolkadotChainSpec, String> {
|
||||
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
|
||||
let boot_nodes = vec![];
|
||||
@@ -1218,6 +1232,7 @@ fn testnet_accounts() -> Vec<AccountId> {
|
||||
}
|
||||
|
||||
/// Helper function to create polkadot `GenesisConfig` for testing
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
pub fn polkadot_testnet_genesis(
|
||||
wasm_binary: &[u8],
|
||||
initial_authorities: Vec<(
|
||||
@@ -1557,6 +1572,7 @@ pub fn rococo_testnet_genesis(
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
|
||||
polkadot_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1597,6 +1613,7 @@ fn rococo_development_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::Gene
|
||||
}
|
||||
|
||||
/// Polkadot development config (single validator Alice)
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
pub fn polkadot_development_config() -> Result<PolkadotChainSpec, String> {
|
||||
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
|
||||
|
||||
@@ -1694,6 +1711,7 @@ pub fn wococo_development_config() -> Result<RococoChainSpec, String> {
|
||||
))
|
||||
}
|
||||
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig {
|
||||
polkadot_testnet_genesis(
|
||||
wasm_binary,
|
||||
@@ -1707,6 +1725,7 @@ fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig
|
||||
}
|
||||
|
||||
/// Polkadot local testnet config (multivalidator Alice + Bob)
|
||||
#[cfg(feature = "polkadot-native")]
|
||||
pub fn polkadot_local_testnet_config() -> Result<PolkadotChainSpec, String> {
|
||||
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user