sc_rpc_spec_v2/chain_spec/api.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program 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// This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
18
19//! API trait of the chain spec.
20
21use jsonrpsee::{core::RpcResult, proc_macros::rpc};
22use sc_chain_spec::Properties;
23
24#[rpc(client, server)]
25pub trait ChainSpecApi {
26 /// Get the chain name, as present in the chain specification.
27 #[method(name = "chainSpec_v1_chainName")]
28 fn chain_spec_v1_chain_name(&self) -> RpcResult<String>;
29
30 /// Get the chain's genesis hash.
31 #[method(name = "chainSpec_v1_genesisHash")]
32 fn chain_spec_v1_genesis_hash(&self) -> RpcResult<String>;
33
34 /// Get the properties of the chain, as present in the chain specification.
35 ///
36 /// # Note
37 ///
38 /// The json whitespaces are not guaranteed to persist.
39 #[method(name = "chainSpec_v1_properties")]
40 fn chain_spec_v1_properties(&self) -> RpcResult<Properties>;
41}