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::chain_spec::Extensions,
19
    cumulus_primitives_core::ParaId,
20
    dancebox_runtime::genesis_config_presets::{development, local},
21
    sc_service::ChainType,
22
};
23
/// Specialized `ChainSpec` for the normal parachain runtime.
24
pub type ChainSpec = sc_service::GenericChainSpec<Extensions>;
25

            
26
4
pub fn development_config(
27
4
    para_id: ParaId,
28
4
    container_chains: Vec<String>,
29
4
    mock_container_chains: Vec<ParaId>,
30
4
    invulnerables: Vec<String>,
31
4
) -> ChainSpec {
32
    // Give your base currency a unit name and decimal places
33
4
    let mut properties = sc_chain_spec::Properties::new();
34
4
    properties.insert("tokenSymbol".into(), "DANCE".into());
35
4
    properties.insert("tokenDecimals".into(), 12.into());
36
4
    properties.insert("ss58Format".into(), 42.into());
37
4
    properties.insert("isEthereum".into(), false.into());
38

            
39
    // we do conversion from chain_spec file to the string content here because
40
    // local accepts contents vector
41
4
    let container_chains_spec_contents: Vec<_> = container_chains
42
4
        .iter()
43
4
        .map(|path| {
44
            std::fs::read_to_string(path)
45
                .map_err(|_e| format!("ChainSpec for container chain not found at {:?}", path))
46
                .unwrap()
47
        })
48
4
        .collect();
49

            
50
4
    ChainSpec::builder(
51
4
        dancebox_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
52
4
        Extensions {
53
4
            relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
54
4
            para_id: para_id.into(),
55
4
        },
56
    )
57
4
    .with_name("Dancebox Development Testnet")
58
4
    .with_id("dancebox_dev")
59
4
    .with_chain_type(ChainType::Development)
60
4
    .with_genesis_config(development(
61
4
        para_id,
62
4
        container_chains_spec_contents,
63
4
        mock_container_chains,
64
4
        invulnerables,
65
    ))
66
4
    .with_properties(properties)
67
4
    .build()
68
4
}
69

            
70
16
pub fn local_dancebox_config(
71
16
    para_id: ParaId,
72
16
    container_chains: Vec<String>,
73
16
    mock_container_chains: Vec<ParaId>,
74
16
    invulnerables: Vec<String>,
75
16
) -> ChainSpec {
76
    // Give your base currency a unit name and decimal places
77
16
    let mut properties = sc_chain_spec::Properties::new();
78
16
    properties.insert("tokenSymbol".into(), "DANCE".into());
79
16
    properties.insert("tokenDecimals".into(), 12.into());
80
16
    properties.insert("ss58Format".into(), 42.into());
81
16
    properties.insert("isEthereum".into(), false.into());
82

            
83
    // we do conversion from chain_spec file to the string content here because
84
    // local accepts contents vector
85
16
    let container_chains_spec_contents: Vec<_> = container_chains
86
16
        .iter()
87
16
        .map(|path| {
88
            std::fs::read_to_string(path)
89
                .map_err(|_e| format!("ChainSpec for container chain not found at {:?}", path))
90
                .unwrap()
91
        })
92
16
        .collect();
93

            
94
16
    ChainSpec::builder(
95
16
        dancebox_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
96
16
        Extensions {
97
16
            relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
98
16
            para_id: para_id.into(),
99
16
        },
100
    )
101
16
    .with_name("Dancebox Local Testnet")
102
16
    .with_id("dancebox_local")
103
16
    .with_chain_type(ChainType::Local)
104
16
    .with_genesis_config(local(
105
16
        para_id,
106
16
        container_chains_spec_contents,
107
16
        mock_container_chains,
108
16
        invulnerables,
109
    ))
110
16
    .with_properties(properties)
111
16
    .with_protocol_id("orchestrator")
112
16
    .build()
113
16
}