You can write your own EnsureOrigin
implementation:
struct EnsureAuthority<T>(core::marker::PhantomData<T>);
impl<T> EnsureOrigin<T::RuntimeOrigin> for EnsureAuthority<T>
where
T: Config,
T::RuntimeOrigin: Into<Result<RawOrigin<T::AccountId>, T::RuntimeOrigin>> + From<RawOrigin<T::AccountId>,
{
type Success = ();
fn try_origin(o: T::RuntimeOrigin) -> Result<Self::Success, O> {
match o.clone().into()? {
RawOrigin::Signed(s) if Authority::<T>::get().map_or(false, |a| a == s) => Ok(()),
r => Err(r.into()),
}
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<T::RuntimeOrigin, ()> {
Ok(Authority::<T>::get().ok_or(())?)
}
}
struct EnsureAuthority<T>(core::marker::PhantomData<T>);
impl<T> EnsureOrigin<T::RuntimeOrigin> for EnsureAuthority<T>
where
T: Config,
T::RuntimeOrigin: Into<Result<RawOrigin<T::AccountId>, T::RuntimeOrigin>> + From<RawOrigin<T::AccountId>,
{
type Success = ();
fn try_origin(o: T::RuntimeOrigin) -> Result<Self::Success, O> {
match o.clone().into()? {
RawOrigin::Signed(s) if Authority::<T>::get().map_or(false, |a| a == s) => Ok(()),
r => Err(r.into()),
}
}
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin() -> Result<T::RuntimeOrigin, ()> {
Ok(Authority::<T>::get().ok_or(())?)
}
}