use frame_support::{
sp_runtime::{traits::OpaqueKeys, RuntimeAppPublic},
};
use core_primitives::AuthorityId;
use sp_std::prelude::*;
use sp_std::vec;
use crate::Config;
pub trait NextSessionAuthorityProvider<T: Config> {
fn next_authorities() -> Vec<T::AuthorityId>;
}
impl<T> NextSessionAuthorityProvider<T> for pallet_session::Pallet<T>
where
T: Config + pallet_session::Config,
{
fn next_authorities() -> Vec<T::AuthorityId> {
let next: Option<Vec<_>> = pallet_session::Pallet::<T>::queued_keys()
.iter()
.map(|(_, key)| key.get(AuthorityId::ID))
.collect();
next.unwrap_or_else(|| {
log::error!(target: "pallet_phron", "Missing next session keys");
vec![]
})
}
}