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