pallet_handles_runtime_api/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2#![allow(clippy::too_many_arguments)]
3#![allow(clippy::unnecessary_mut_passed)]
4#![allow(rustdoc::bare_urls)]
5// Strong Documentation Lints
6#![deny(
7	rustdoc::broken_intra_doc_links,
8	rustdoc::missing_crate_level_docs,
9	rustdoc::invalid_codeblock_attributes,
10	missing_docs
11)]
12
13//! Runtime API definition for [Stateful  Storage](../pallet_stateful_storage/index.html)
14//!
15//! This api must be implemented by the node runtime.
16//! Runtime APIs Provide:
17//! - An interface between the runtime and Custom RPCs.
18//! - Runtime interfaces for end users beyond just State Queries
19
20use common_primitives::{
21	handles::{
22		BaseHandle, CheckHandleResponse, DisplayHandle, HandleResponse, PresumptiveSuffixesResponse,
23	},
24	msa::MessageSourceId,
25};
26
27// Here we declare the runtime API. It is implemented it the `impl` block in
28// runtime files (the `runtime` folder)
29sp_api::decl_runtime_apis! {
30
31	/// Runtime Version for Handles
32	/// - MUST be incremented if anything changes
33	/// - See: https://paritytech.github.io/polkadot/doc/polkadot_primitives/runtime_api/index.html
34	#[api_version(2)]
35
36	/// Runtime APIs for [Handles](../pallet_handles/index.html)
37	pub trait HandlesRuntimeApi
38	{
39		/// Retrieve handle for a particular msa
40		fn get_handle_for_msa(msa_id: MessageSourceId) -> Option<HandleResponse>;
41
42		/// Retrieve the next `n` suffixes for a given handle
43		fn get_next_suffixes(base_handle: BaseHandle, count: u16) -> PresumptiveSuffixesResponse;
44
45		/// Retrieve msa for a particular handle
46		fn get_msa_for_handle(display_handle: DisplayHandle) -> Option<MessageSourceId>;
47
48		/// Check if a handle is valid
49		fn validate_handle(base_handle: BaseHandle) -> bool;
50
51		#[api_version(3)]
52		/// Return information about a given handle
53		fn check_handle(base_handle: BaseHandle) -> CheckHandleResponse;
54	}
55}