pub fn testnet_genesis(
	initial_authorities: Vec<(
		AccountId,
		AccountId,
		GrandpaId,
		BabeId,
		ImOnlineId,
		AuthorityDiscoveryId,
	)>,
	initial_nominators: Vec<AccountId>,
	root_key: AccountId,
	endowed_accounts: Option<Vec<AccountId>>,
) -> GenesisConfig {
	let mut endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
		vec![
			get_account_id_from_seed::<sr25519::Public>("Alice"),
			get_account_id_from_seed::<sr25519::Public>("Bob"),
			get_account_id_from_seed::<sr25519::Public>("Charlie"),
			get_account_id_from_seed::<sr25519::Public>("Dave"),
			get_account_id_from_seed::<sr25519::Public>("Eve"),
			get_account_id_from_seed::<sr25519::Public>("Ferdie"),
			get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
			get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
			get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
			get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
			get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
			get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
		]
	});
	// endow all authorities and nominators.
	initial_authorities
		.iter()
		.map(|x| &x.0)
		.chain(initial_nominators.iter())
		.for_each(|x| {
			if !endowed_accounts.contains(&x) {
				endowed_accounts.push(x.clone())
			}
		});

	// stakers: all validators and nominators.
	let mut rng = rand::thread_rng();
	let stakers = initial_authorities
		.iter()
		.map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator))
		.chain(initial_nominators.iter().map(|x| {
			use rand::{seq::SliceRandom, Rng};
			let limit = (MAX_NOMINATIONS as usize).min(initial_authorities.len());
			let count = rng.gen::<usize>() % limit;
			let nominations = initial_authorities
				.as_slice()
				.choose_multiple(&mut rng, count)
				.into_iter()
				.map(|choice| choice.0.clone())
				.collect::<Vec<_>>();
			(x.clone(), x.clone(), STASH, StakerStatus::Nominator(nominations))
		}))
		.collect::<Vec<_>>();

	let num_endowed_accounts = endowed_accounts.len();

	const ENDOWMENT: Balance = 10_000_000 * DOLLARS;
	const STASH: Balance = ENDOWMENT / 1000;

	GenesisConfig {
		system: SystemConfig {
			code: wasm_binary_unwrap().to_vec(),
			changes_trie_config: Default::default(),
		},
		balances: BalancesConfig {
			balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(),
		},
		indices: IndicesConfig { indices: vec![] },
		session: SessionConfig {
			keys: initial_authorities
				.iter()
				.map(|x| {
					(
						x.0.clone(),
						x.0.clone(),
						session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()),
					)
				})
				.collect::<Vec<_>>(),
		},
		staking: StakingConfig {
			validator_count: initial_authorities.len() as u32,
			minimum_validator_count: initial_authorities.len() as u32,
			invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
			slash_reward_fraction: Perbill::from_percent(10),
			stakers,
			..Default::default()
		},
		democracy: DemocracyConfig::default(),
		elections: ElectionsConfig {
			members: endowed_accounts
				.iter()
				.take((num_endowed_accounts + 1) / 2)
				.cloned()
				.map(|member| (member, STASH))
				.collect(),
		},
		council: CouncilConfig::default(),
		technical_committee: TechnicalCommitteeConfig {
			members: endowed_accounts
				.iter()
				.take((num_endowed_accounts + 1) / 2)
				.cloned()
				.collect(),
			phantom: Default::default(),
		},
		sudo: SudoConfig { key: root_key },
		babe: BabeConfig {
			authorities: vec![],
			epoch_config: Some(tewai_runtime::BABE_GENESIS_EPOCH_CONFIG),
		},
		im_online: ImOnlineConfig { keys: vec![] },
		authority_discovery: AuthorityDiscoveryConfig { keys: vec![] },
		grandpa: GrandpaConfig { authorities: vec![] },
		treasury: Default::default(),
		vesting: Default::default(),
		transaction_storage: Default::default(),
		tokens: Default::default(),
		continuum: ContinuumConfig {
			initial_active_session: Default::default(),
			initial_auction_rate: 5,
			initial_max_bound: (-100, 100),
			spot_price: 5 * DOLLARS,
		},
		estate: EstateConfig {
			minting_rate_config: metaverse_land_minting_config(),
		},
	}
}
/// Helper function to create GenesisConfig for testing
Helper function to create GenesisConfig for testing
Helper function to create GenesisConfig for testing
pub fn testnet_genesis(
	initial_authorities: Vec<(
		AccountId,
		AccountId,
		GrandpaId,
		BabeId,
		ImOnlineId,
		AuthorityDiscoveryId,
	)>,
	initial_nominators: Vec<AccountId>,
	root_key: AccountId,
	endowed_accounts: Option<Vec<AccountId>>,
) -> GenesisConfig {
	let mut endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(|| {
		vec![
			get_account_id_from_seed::<sr25519::Public>("Alice"),
			get_account_id_from_seed::<sr25519::Public>("Bob"),
			get_account_id_from_seed::<sr25519::Public>("Charlie"),
			get_account_id_from_seed::<sr25519::Public>("Dave"),
			get_account_id_from_seed::<sr25519::Public>("Eve"),
			get_account_id_from_seed::<sr25519::Public>("Ferdie"),
			get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
			get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
			get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
			get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
			get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
			get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
		]
	});
	// endow all authorities and nominators.
	initial_authorities
		.iter()
		.map(|x| &x.0)
		.chain(initial_nominators.iter())
		.for_each(|x| {
			if !endowed_accounts.contains(&x) {
				endowed_accounts.push(x.clone())
			}
		});
	// stakers: all validators and nominators.
	let mut rng = rand::thread_rng();
	let stakers = initial_authorities
		.iter()
		.map(|x| (x.0.clone(), x.1.clone(), STASH, StakerStatus::Validator))
		.chain(initial_nominators.iter().map(|x| {
			use rand::{seq::SliceRandom, Rng};
			let limit = (MAX_NOMINATIONS as usize).min(initial_authorities.len());
			let count = rng.gen::<usize>() % limit;
			let nominations = initial_authorities
				.as_slice()
				.choose_multiple(&mut rng, count)
				.into_iter()
				.map(|choice| choice.0.clone())
				.collect::<Vec<_>>();
			(x.clone(), x.clone(), STASH, StakerStatus::Nominator(nominations))
		}))
		.collect::<Vec<_>>();
	let num_endowed_accounts = endowed_accounts.len();
	const ENDOWMENT: Balance = 10_000_000 * DOLLARS;
	const STASH: Balance = ENDOWMENT / 1000;
	GenesisConfig {
		system: SystemConfig {
			code: wasm_binary_unwrap().to_vec(),
			changes_trie_config: Default::default(),
		},
		balances: BalancesConfig {
			balances: endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT)).collect(),
		},
		indices: IndicesConfig { indices: vec![] },
		session: SessionConfig {
			keys: initial_authorities
				.iter()
				.map(|x| {
					(
						x.0.clone(),
						x.0.clone(),
						session_keys(x.2.clone(), x.3.clone(), x.4.clone(), x.5.clone()),
					)
				})
				.collect::<Vec<_>>(),
		},
		staking: StakingConfig {
			validator_count: initial_authorities.len() as u32,
			minimum_validator_count: initial_authorities.len() as u32,
			invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
			slash_reward_fraction: Perbill::from_percent(10),
			stakers,
			..Default::default()
		},
		democracy: DemocracyConfig::default(),
		elections: ElectionsConfig {
			members: endowed_accounts
				.iter()
				.take((num_endowed_accounts + 1) / 2)
				.cloned()
				.map(|member| (member, STASH))
				.collect(),
		},
		council: CouncilConfig::default(),
		technical_committee: TechnicalCommitteeConfig {
			members: endowed_accounts
				.iter()
				.take((num_endowed_accounts + 1) / 2)
				.cloned()
				.collect(),
			phantom: Default::default(),
		},
		sudo: SudoConfig { key: root_key },
		babe: BabeConfig {
			authorities: vec![],
			epoch_config: Some(tewai_runtime::BABE_GENESIS_EPOCH_CONFIG),
		},
		im_online: ImOnlineConfig { keys: vec![] },
		authority_discovery: AuthorityDiscoveryConfig { keys: vec![] },
		grandpa: GrandpaConfig { authorities: vec![] },
		treasury: Default::default(),
		vesting: Default::default(),
		transaction_storage: Default::default(),
		tokens: Default::default(),
		continuum: ContinuumConfig {
			initial_active_session: Default::default(),
			initial_auction_rate: 5,
			initial_max_bound: (-100, 100),
			spot_price: 5 * DOLLARS,
		},
		estate: EstateConfig {
			minting_rate_config: metaverse_land_minting_config(),
		},
	}
}
pub fn testnet_genesis ( initial_authorities : Vec < ( AccountId , AccountId , GrandpaId , BabeId , ImOnlineId , AuthorityDiscoveryId , ) > , initial_nominators : Vec < AccountId > , root_key : AccountId , endowed_accounts : Option < Vec < AccountId > > , ) -> GenesisConfig { let mut endowed_accounts : Vec < AccountId > = endowed_accounts . unwrap_or_else ( | | { vec ! [ get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) get_account_id_from_seed sr25519 Public ( " " ) ] } ) ; // endow all authorities and nominators. initial_authorities . iter ( ) . map ( | x | & x . 0 ) . chain ( initial_nominators . iter ( ) ) . for_each ( | x | { if ! endowed_accounts . contains ( & x ) { endowed_accounts . push ( x . clone ( ) ) } } ) ; // stakers: all validators and nominators. let mut rng = rand :: thread_rng ( ) ; let stakers = initial_authorities . iter ( ) . map ( | x | ( x . 0 . clone ( ) , x . 1 . clone ( ) , STASH , StakerStatus :: Validator ) ) . chain ( initial_nominators . iter ( ) . map ( | x | { use rand :: { seq :: SliceRandom , Rng } ; let limit = ( MAX_NOMINATIONS as usize ) . min ( initial_authorities . len ( ) ) ; let count = rng . gen :: < usize > ( ) % limit ; let nominations = initial_authorities . as_slice ( ) . choose_multiple ( & mut rng , count ) . into_iter ( ) . map ( | choice | choice . 0 . clone ( ) ) . collect :: < Vec < _ > > ( ) ; ( x . clone ( ) , x . clone ( ) , STASH , StakerStatus :: Nominator ( nominations ) ) } ) ) . collect :: < Vec < _ > > ( ) ; let num_endowed_accounts = endowed_accounts . len ( ) ; const ENDOWMENT : Balance = 10_000_000 * DOLLARS ; const STASH : Balance = ENDOWMENT / 1000 ; GenesisConfig { system : SystemConfig { code : wasm_binary_unwrap ( ) . to_vec ( ) , changes_trie_config : Default :: default ( ) , } , balances : BalancesConfig { balances : endowed_accounts . iter ( ) . cloned ( ) . map ( | x | ( x , ENDOWMENT ) ) . collect ( ) , } , indices : IndicesConfig { indices : vec ! [ ] } , session : SessionConfig { keys : initial_authorities . iter ( ) . map ( | x | { ( x . 0 . clone ( ) , x . 0 . clone ( ) , session_keys ( x . 2 . clone ( ) , x . 3 . clone ( ) , x . 4 . clone ( ) , x . 5 . clone ( ) ) , ) } ) . collect :: < Vec < _ > > ( ) , } , staking : StakingConfig { validator_count : initial_authorities . len ( ) as u32 , minimum_validator_count : initial_authorities . len ( ) as u32 , invulnerables : initial_authorities . iter ( ) . map ( | x | x . 0 . clone ( ) ) . collect ( ) , slash_reward_fraction : Perbill :: from_percent ( 10 ) , stakers , .. Default :: default ( ) } , democracy : DemocracyConfig :: default ( ) , elections : ElectionsConfig { members : endowed_accounts . iter ( ) . take ( ( num_endowed_accounts + 1 ) / 2 ) . cloned ( ) . map ( | member | ( member , STASH ) ) . collect ( ) , } , council : CouncilConfig :: default ( ) , technical_committee : TechnicalCommitteeConfig { members : endowed_accounts . iter ( ) . take ( ( num_endowed_accounts + 1 ) / 2 ) . cloned ( ) . collect ( ) , phantom : Default :: default ( ) , } , sudo : SudoConfig { key : root_key } , babe : BabeConfig { authorities : vec ! [ ] , epoch_config : Some ( tewai_runtime :: BABE_GENESIS_EPOCH_CONFIG ) , } , im_online : ImOnlineConfig { keys : vec ! [ ] } , authority_discovery : AuthorityDiscoveryConfig { keys : vec ! [ ] } , grandpa : GrandpaConfig { authorities : vec ! [ ] } , treasury : Default :: default ( ) , vesting : Default :: default ( ) , transaction_storage : Default :: default ( ) , tokens : Default :: default ( ) , continuum : ContinuumConfig { initial_active_session : Default :: default ( ) , initial_auction_rate : 5 , initial_max_bound : ( - 100 , 100 ) , spot_price : 5 * DOLLARS , } , estate : EstateConfig { minting_rate_config : metaverse_land_minting_config ( ) , } , } }
Helper function to create GenesisConfig for testing
Helper function to create GenesisConfig for testing
initial_authorities
Vec<(
		AccountId,
		AccountId,
		GrandpaId,
		BabeId,
		ImOnlineId,
		AuthorityDiscoveryId,
	)>
initial_nominators
Vec<AccountId>
root_key
AccountId
endowed_accounts
Option<Vec<AccountId>>