1
// Copyright (C) Moondance Labs Ltd.
2
// This file is part of Tanssi.
3

            
4
// Tanssi is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8

            
9
// Tanssi is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13

            
14
// You should have received a copy of the GNU General Public License
15
// along with Tanssi.  If not, see <http://www.gnu.org/licenses/>.
16

            
17
use {
18
    crate as container_chain_template_simple_runtime,
19
    crate::{AccountId, MaintenanceModeConfig, MigrationsConfig, PolkadotXcmConfig},
20
    alloc::vec::Vec,
21
    cumulus_primitives_core::ParaId,
22
    sp_keyring::Sr25519Keyring,
23
};
24

            
25
/// Orcherstrator's parachain id
26
pub const ORCHESTRATOR: ParaId = ParaId::new(1000);
27

            
28
pub fn local(
29
    endowed_accounts: Vec<AccountId>,
30
    id: ParaId,
31
    root_key: AccountId,
32
) -> serde_json::Value {
33
    testnet_genesis(endowed_accounts, id, root_key)
34
}
35

            
36
2
pub fn development(
37
2
    endowed_accounts: Vec<AccountId>,
38
2
    id: ParaId,
39
2
    root_key: AccountId,
40
2
) -> serde_json::Value {
41
2
    testnet_genesis(endowed_accounts, id, root_key)
42
2
}
43

            
44
2
fn testnet_genesis(
45
2
    endowed_accounts: Vec<AccountId>,
46
2
    id: ParaId,
47
2
    root_key: AccountId,
48
2
) -> serde_json::Value {
49
2
    let g = container_chain_template_simple_runtime::RuntimeGenesisConfig {
50
        balances: container_chain_template_simple_runtime::BalancesConfig {
51
2
            balances: endowed_accounts
52
2
                .iter()
53
2
                .cloned()
54
24
                .map(|k| (k, 1 << 60))
55
2
                .collect(),
56
2
            ..Default::default()
57
        },
58
2
        parachain_info: container_chain_template_simple_runtime::ParachainInfoConfig {
59
2
            parachain_id: id,
60
2
            ..Default::default()
61
2
        },
62
2
        parachain_system: Default::default(),
63
2
        sudo: container_chain_template_simple_runtime::SudoConfig {
64
2
            key: Some(root_key),
65
2
        },
66
2
        authorities_noting: container_chain_template_simple_runtime::AuthoritiesNotingConfig {
67
2
            orchestrator_para_id: ORCHESTRATOR,
68
2
            ..Default::default()
69
2
        },
70
2
        migrations: MigrationsConfig::default(),
71
2
        maintenance_mode: MaintenanceModeConfig {
72
2
            start_in_maintenance_mode: false,
73
2
            ..Default::default()
74
2
        },
75
        // This should initialize it to whatever we have set in the pallet
76
2
        polkadot_xcm: PolkadotXcmConfig::default(),
77
2
        transaction_payment: Default::default(),
78
2
        tx_pause: Default::default(),
79
2
        system: Default::default(),
80
    };
81

            
82
2
    serde_json::to_value(g).unwrap()
83
2
}
84

            
85
/// Get pre-funded accounts
86
2
pub fn pre_funded_accounts() -> Vec<AccountId> {
87
2
    Sr25519Keyring::well_known()
88
24
        .map(|k| k.to_account_id())
89
2
        .collect()
90
2
}