astar_collator/parachain/chain_spec/
mod.rs

1// This file is part of Astar.
2
3// Copyright (C) Stake Technologies Pte.Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later
5
6// Astar is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// Astar is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with Astar. If not, see <http://www.gnu.org/licenses/>.
18
19use astar_primitives::Block;
20use sc_chain_spec::ChainSpecExtension;
21use serde::{Deserialize, Serialize};
22
23pub mod astar;
24pub mod shibuya;
25pub mod shiden;
26
27pub use astar::AstarChainSpec;
28pub use shibuya::ShibuyaChainSpec;
29pub use shiden::ShidenChainSpec;
30
31/// Node `ChainSpec` extensions.
32///
33/// Additional parameters for some Substrate core modules,
34/// customizable from the chain spec.
35#[derive(Default, Clone, Serialize, Deserialize, ChainSpecExtension)]
36#[serde(rename_all = "camelCase")]
37pub struct Extensions {
38    /// Known bad block hashes.
39    pub bad_blocks: sc_client_api::BadBlocks<Block>,
40    /// The relay chain of the Parachain.
41    pub relay_chain: String,
42    /// The id of the Parachain.
43    pub para_id: u32,
44}
45
46impl Extensions {
47    /// Try to get the extension from the given `ChainSpec`.
48    pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
49        sc_chain_spec::get_extension(chain_spec.extensions())
50    }
51}