sc_rpc_api/statement/mod.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//! Substrate Statement Store RPC API.
20
21use jsonrpsee::{core::RpcResult, proc_macros::rpc};
22use sp_core::Bytes;
23
24pub mod error;
25
26/// Substrate statement RPC API
27#[rpc(client, server)]
28pub trait StatementApi {
29 /// Return all statements, SCALE-encoded.
30 #[method(name = "statement_dump", with_extensions)]
31 fn dump(&self) -> RpcResult<Vec<Bytes>>;
32
33 /// Return the data of all known statements which include all topics and have no `DecryptionKey`
34 /// field.
35 ///
36 /// To get the statement, and not just the data, use `statement_broadcastsStatement`.
37 #[method(name = "statement_broadcasts")]
38 fn broadcasts(&self, match_all_topics: Vec<[u8; 32]>) -> RpcResult<Vec<Bytes>>;
39
40 /// Return the data of all known statements whose decryption key is identified as `dest` (this
41 /// will generally be the public key or a hash thereof for symmetric ciphers, or a hash of the
42 /// private key for symmetric ciphers).
43 ///
44 /// To get the statement, and not just the data, use `statement_postedStatement`.
45 #[method(name = "statement_posted")]
46 fn posted(&self, match_all_topics: Vec<[u8; 32]>, dest: [u8; 32]) -> RpcResult<Vec<Bytes>>;
47
48 /// Return the decrypted data of all known statements whose decryption key is identified as
49 /// `dest`. The key must be available to the client.
50 ///
51 /// To get the statement, and not just the data, use `statement_postedClearStatement`.
52 #[method(name = "statement_postedClear")]
53 fn posted_clear(
54 &self,
55 match_all_topics: Vec<[u8; 32]>,
56 dest: [u8; 32],
57 ) -> RpcResult<Vec<Bytes>>;
58
59 /// Return all known statements which include all topics and have no `DecryptionKey`
60 /// field.
61 ///
62 /// This returns the SCALE-encoded statements not just the data as in rpc
63 /// `statement_broadcasts`.
64 #[method(name = "statement_broadcastsStatement")]
65 fn broadcasts_stmt(&self, match_all_topics: Vec<[u8; 32]>) -> RpcResult<Vec<Bytes>>;
66
67 /// Return all known statements whose decryption key is identified as `dest` (this
68 /// will generally be the public key or a hash thereof for symmetric ciphers, or a hash of the
69 /// private key for symmetric ciphers).
70 ///
71 /// This returns the SCALE-encoded statements not just the data as in rpc `statement_posted`.
72 #[method(name = "statement_postedStatement")]
73 fn posted_stmt(&self, match_all_topics: Vec<[u8; 32]>, dest: [u8; 32])
74 -> RpcResult<Vec<Bytes>>;
75
76 /// Return the statement and the decrypted data of all known statements whose decryption key is
77 /// identified as `dest`. The key must be available to the client.
78 ///
79 /// This returns for each statement: the SCALE-encoded statement concatenated to the decrypted
80 /// data. Not just the data as in rpc `statement_postedClear`.
81 #[method(name = "statement_postedClearStatement")]
82 fn posted_clear_stmt(
83 &self,
84 match_all_topics: Vec<[u8; 32]>,
85 dest: [u8; 32],
86 ) -> RpcResult<Vec<Bytes>>;
87
88 /// Submit a pre-encoded statement.
89 #[method(name = "statement_submit")]
90 fn submit(&self, encoded: Bytes) -> RpcResult<()>;
91
92 /// Remove a statement from the store.
93 #[method(name = "statement_remove")]
94 fn remove(&self, statement_hash: [u8; 32]) -> RpcResult<()>;
95}