pallet_msa_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 [MSA](../pallet_msa/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::{msa::*, node::BlockNumber};
21use parity_scale_codec::Codec;
22extern crate alloc;
23use alloc::vec::Vec;
24
25// Here we declare the runtime API. It is implemented it the `impl` block in
26// runtime files (the `runtime` folder)
27sp_api::decl_runtime_apis! {
28
29	/// Runtime Version for MSAs
30	/// - MUST be incremented if anything changes
31	/// - See: https://paritytech.github.io/polkadot/doc/polkadot_primitives/runtime_api/index.html
32	#[api_version(3)]
33
34	/// Runtime API definition for [MSA](../pallet_msa/index.html)
35	pub trait MsaRuntimeApi<AccountId> where
36		AccountId: Codec,
37	{
38		/// Check to see if a delegation existed between the given delegator and provider at a given block
39		fn has_delegation(delegator: DelegatorId, provider: ProviderId, block_number: BlockNumber, schema_id: Option<SchemaId>) -> bool;
40
41		/// Get the list of schema permission grants (if any) that exist in any delegation between the delegator and provider
42		/// The returned list contains both schema id and the block number at which permission was revoked (0 if currently not revoked)
43		fn get_granted_schemas_by_msa_id(delegator: DelegatorId, provider: ProviderId) -> Option<Vec<SchemaGrant<SchemaId, BlockNumber>>>;
44
45		/// Get the list of all delegated providers with schema permission grants (if any) that exist in any delegation between the delegator and provider
46		/// The returned list contains both schema id and the block number at which permission was revoked (0 if currently not revoked)
47		fn get_all_granted_delegations_by_msa_id(delegator: DelegatorId) -> Vec<DelegationResponse<SchemaId, BlockNumber>>;
48
49		/// Get the Ethereum address of the given MSA.
50		/// The address is returned as both a 20-byte binary address and a hex-encoded checksummed string (ERC-55).
51		fn get_ethereum_address_for_msa_id(msa_id: MessageSourceId) -> AccountId20Response;
52
53		/// Validate if the given Ethereum address is associated with the given MSA
54		fn validate_eth_address_for_msa(eth_address: &H160, msa_id: MessageSourceId) -> bool;
55	}
56}