sc_rpc_spec_v2/archive/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 archive methods.
20
21use crate::{
22 common::events::{ArchiveStorageResult, PaginatedStorageQuery},
23 MethodResult,
24};
25use jsonrpsee::{core::RpcResult, proc_macros::rpc};
26
27#[rpc(client, server)]
28pub trait ArchiveApi<Hash> {
29 /// Retrieves the body (list of transactions) of a given block hash.
30 ///
31 /// Returns an array of strings containing the hexadecimal-encoded SCALE-codec-encoded
32 /// transactions in that block. If no block with that hash is found, null.
33 ///
34 /// # Unstable
35 ///
36 /// This method is unstable and subject to change in the future.
37 #[method(name = "archive_unstable_body")]
38 fn archive_unstable_body(&self, hash: Hash) -> RpcResult<Option<Vec<String>>>;
39
40 /// Get the chain's genesis hash.
41 ///
42 /// Returns a string containing the hexadecimal-encoded hash of the genesis block of the chain.
43 ///
44 /// # Unstable
45 ///
46 /// This method is unstable and subject to change in the future.
47 #[method(name = "archive_unstable_genesisHash")]
48 fn archive_unstable_genesis_hash(&self) -> RpcResult<String>;
49
50 /// Get the block's header.
51 ///
52 /// Returns a string containing the hexadecimal-encoded SCALE-codec encoding header of the
53 /// block.
54 ///
55 /// # Unstable
56 ///
57 /// This method is unstable and subject to change in the future.
58 #[method(name = "archive_unstable_header")]
59 fn archive_unstable_header(&self, hash: Hash) -> RpcResult<Option<String>>;
60
61 /// Get the height of the current finalized block.
62 ///
63 /// Returns an integer height of the current finalized block of the chain.
64 ///
65 /// # Unstable
66 ///
67 /// This method is unstable and subject to change in the future.
68 #[method(name = "archive_unstable_finalizedHeight")]
69 fn archive_unstable_finalized_height(&self) -> RpcResult<u64>;
70
71 /// Get the hashes of blocks from the given height.
72 ///
73 /// Returns an array (possibly empty) of strings containing an hexadecimal-encoded hash of a
74 /// block header.
75 ///
76 /// # Unstable
77 ///
78 /// This method is unstable and subject to change in the future.
79 #[method(name = "archive_unstable_hashByHeight")]
80 fn archive_unstable_hash_by_height(&self, height: u64) -> RpcResult<Vec<String>>;
81
82 /// Call into the Runtime API at a specified block's state.
83 ///
84 /// # Unstable
85 ///
86 /// This method is unstable and subject to change in the future.
87 #[method(name = "archive_unstable_call")]
88 fn archive_unstable_call(
89 &self,
90 hash: Hash,
91 function: String,
92 call_parameters: String,
93 ) -> RpcResult<MethodResult>;
94
95 /// Returns storage entries at a specific block's state.
96 ///
97 /// # Unstable
98 ///
99 /// This method is unstable and subject to change in the future.
100 #[method(name = "archive_unstable_storage", blocking)]
101 fn archive_unstable_storage(
102 &self,
103 hash: Hash,
104 items: Vec<PaginatedStorageQuery<String>>,
105 child_trie: Option<String>,
106 ) -> RpcResult<ArchiveStorageResult>;
107}