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 #[method(name = "statement_broadcasts")]
36 fn broadcasts(&self, match_all_topics: Vec<[u8; 32]>) -> RpcResult<Vec<Bytes>>;
37
38 /// Return the data of all known statements whose decryption key is identified as `dest` (this
39 /// will generally be the public key or a hash thereof for symmetric ciphers, or a hash of the
40 /// private key for symmetric ciphers).
41 #[method(name = "statement_posted")]
42 fn posted(&self, match_all_topics: Vec<[u8; 32]>, dest: [u8; 32]) -> RpcResult<Vec<Bytes>>;
43
44 /// Return the decrypted data of all known statements whose decryption key is identified as
45 /// `dest`. The key must be available to the client.
46 #[method(name = "statement_postedClear")]
47 fn posted_clear(
48 &self,
49 match_all_topics: Vec<[u8; 32]>,
50 dest: [u8; 32],
51 ) -> RpcResult<Vec<Bytes>>;
52
53 /// Submit a pre-encoded statement.
54 #[method(name = "statement_submit")]
55 fn submit(&self, encoded: Bytes) -> RpcResult<()>;
56
57 /// Remove a statement from the store.
58 #[method(name = "statement_remove")]
59 fn remove(&self, statement_hash: [u8; 32]) -> RpcResult<()>;
60}