frontier_template_runtime/
genesis_config_preset.rs1use crate::{
2 AccountId, BalancesConfig, EVMChainIdConfig, EVMConfig, EthereumConfig, ManualSealConfig,
3 RuntimeGenesisConfig, SudoConfig,
4};
5use hex_literal::hex;
6use sp_consensus_aura::sr25519::AuthorityId as AuraId;
7use sp_consensus_grandpa::AuthorityId as GrandpaId;
8#[allow(unused_imports)]
9use sp_core::ecdsa;
10use sp_core::{H160, U256};
11use sp_genesis_builder::PresetId;
12use sp_std::prelude::*;
13
14pub fn development() -> serde_json::Value {
16 testnet_genesis(
17 AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
19 vec![
21 AccountId::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")), AccountId::from(hex!("3Cd0A705a2DC65e5b1E1205896BaA2be8A07c6e0")), AccountId::from(hex!("798d4Ba9baf0064Ec19eB4F0a1a45785ae9D6DFc")), ],
25 vec![],
26 42, false, )
29}
30
31fn testnet_genesis(
33 sudo_key: AccountId,
34 endowed_accounts: Vec<AccountId>,
35 _initial_authorities: Vec<(AuraId, GrandpaId)>,
36 chain_id: u64,
37 enable_manual_seal: bool,
38) -> serde_json::Value {
39 let evm_accounts = {
40 let mut map = sp_std::collections::btree_map::BTreeMap::new();
41 map.insert(
42 H160::from(hex!("f24FF3a9CF04c71Dbc94D0b566f7A27B94566cac")),
48 fp_evm::GenesisAccount {
49 balance: U256::MAX,
50 code: Default::default(),
51 nonce: Default::default(),
52 storage: Default::default(),
53 },
54 );
55 map.insert(
56 H160::from(hex!("6be02d1d3665660d22ff9624b7be0551ee1ac91b")),
58 fp_evm::GenesisAccount {
59 balance: U256::MAX,
60 code: Default::default(),
61 nonce: Default::default(),
62 storage: Default::default(),
63 },
64 );
65 map.insert(
66 H160::from(hex!("1000000000000000000000000000000000000001")),
68 fp_evm::GenesisAccount {
69 nonce: U256::from(1),
70 balance: U256::from(1_000_000_000_000_000_000_000_000u128),
71 storage: Default::default(),
72 code: vec![0x00],
73 },
74 );
75 map
76 };
77
78 let config = RuntimeGenesisConfig {
79 system: Default::default(),
80 aura: Default::default(),
81 base_fee: Default::default(),
82 grandpa: Default::default(),
83 balances: BalancesConfig {
84 balances: endowed_accounts
85 .iter()
86 .cloned()
87 .map(|k| (k, 1 << 110))
88 .collect(),
89 ..Default::default()
90 },
91 ethereum: EthereumConfig {
92 ..Default::default()
93 },
94 evm: EVMConfig {
95 accounts: evm_accounts.into_iter().collect(),
96 ..Default::default()
97 },
98 evm_chain_id: EVMChainIdConfig {
99 chain_id,
100 ..Default::default()
101 },
102 manual_seal: ManualSealConfig {
103 enable: enable_manual_seal,
104 ..Default::default()
105 },
106 sudo: SudoConfig {
107 key: Some(sudo_key),
108 },
109 transaction_payment: Default::default(),
110 };
111
112 serde_json::to_value(&config).expect("Could not build genesis config.")
113}
114
115pub fn get_preset(id: &PresetId) -> Option<Vec<u8>> {
117 let patch = match id.as_str() {
118 sp_genesis_builder::DEV_RUNTIME_PRESET => development(),
119 _ => return None,
120 };
121 Some(
122 serde_json::to_string(&patch)
123 .expect("serialization to json is expected to work. qed.")
124 .into_bytes(),
125 )
126}