substrate_api_client/api/runtime_api/
authority_discovery.rs

1/*
2   Copyright 2024 Supercomputing Systems AG
3   Licensed under the Apache License, Version 2.0 (the "License");
4   you may not use this file except in compliance with the License.
5   You may obtain a copy of the License at
6	   http://www.apache.org/licenses/LICENSE-2.0
7   Unless required by applicable law or agreed to in writing, software
8   distributed under the License is distributed on an "AS IS" BASIS,
9   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10   See the License for the specific language governing permissions and
11   limitations under the License.
12*/
13
14use super::{RuntimeApi, RuntimeApiClient};
15use crate::{api::Result, rpc::Request};
16use ac_primitives::config::Config;
17#[cfg(all(not(feature = "sync-api"), not(feature = "std")))]
18use alloc::boxed::Box;
19use alloc::{vec, vec::Vec};
20use codec::Decode;
21
22#[maybe_async::maybe_async(?Send)]
23pub trait AuthorityDiscoveryApi: RuntimeApi {
24	/// Retrieve authority identifiers of the current and next authority set.
25	async fn authorities<AuthorityId: Decode>(
26		&self,
27		at_block: Option<Self::Hash>,
28	) -> Result<Vec<AuthorityId>>;
29}
30
31#[maybe_async::maybe_async(?Send)]
32impl<T, Client> AuthorityDiscoveryApi for RuntimeApiClient<T, Client>
33where
34	T: Config,
35	Client: Request,
36{
37	async fn authorities<AuthorityId: Decode>(
38		&self,
39		at_block: Option<Self::Hash>,
40	) -> Result<Vec<AuthorityId>> {
41		self.runtime_call("AuthorityDiscoveryApi_authorities", vec![], at_block).await
42	}
43}