diff --git a/pallets/clients-info/src/lib.rs b/pallets/clients-info/src/lib.rs index 85095683b..18ba58d8e 100644 --- a/pallets/clients-info/src/lib.rs +++ b/pallets/clients-info/src/lib.rs @@ -1,7 +1,6 @@ //! # ClientsInfo Module //! Stores information about clients used for the network. -#![deny(warnings)] #![cfg_attr(test, feature(proc_macro_hygiene))] #![cfg_attr(not(feature = "std"), no_std)] @@ -39,7 +38,6 @@ pub use pallet::*; #[frame_support::pallet] pub mod pallet { use crate::*; - use frame_support::dispatch::RawOrigin; use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; @@ -73,26 +71,6 @@ pub mod pallet { } } - impl Pallet { - fn check_non_root_rights(origin: OriginFor) -> Result { - let origin_account_id = ensure_signed(origin)?; - ensure!( - >::contains_key(&origin_account_id), - Error::::ThisAccountIdIsNotAuthorized - ); - - Ok(origin_account_id) - } - - fn check_origin_rights(origin: OriginFor) -> DispatchResult { - if ensure_root(origin.clone()).is_err() { - let _ = Pallet::::check_non_root_rights(origin)?; - }; - - Ok(()) - } - } - #[pallet::call] impl Pallet { /// Sets the current client release version, in case of a bug fix or patch. @@ -156,20 +134,12 @@ pub mod pallet { origin: OriginFor, account_id: T::AccountId, ) -> DispatchResult { - if let Ok(origin_account_id) = ensure_signed(origin.clone()) { - Pallet::::check_non_root_rights(origin.clone())?; + if let Err(e) = ensure_root(origin.clone()) { + let origin_account_id = Pallet::::check_non_root_rights(origin)?; ensure!( account_id != origin_account_id, Error::::UserUnableToDeauthorizeThemself ); - - // do not deauthorize the root account - let account_id_to_origin = - OriginFor::::from(RawOrigin::Signed(account_id.clone())); - ensure!( - ensure_root(account_id_to_origin).is_err(), - Error::::UserUnableToDeauthorizeRootAccount - ); } if >::contains_key(&account_id) { @@ -194,7 +164,6 @@ pub mod pallet { pub enum Error { ThisAccountIdIsNotAuthorized, UserUnableToDeauthorizeThemself, - UserUnableToDeauthorizeRootAccount, } /// Mapping of client name (string literal represented as bytes) to its release details. @@ -214,6 +183,27 @@ pub mod pallet { #[pallet::getter(fn authorized_accounts)] pub(super) type AuthorizedAccounts = StorageMap<_, Blake2_128Concat, T::AccountId, ()>; + + impl Pallet { + fn check_non_root_rights(origin: OriginFor) -> Result { + let origin_account_id = ensure_signed(origin.clone())?; + + ensure!( + >::contains_key(&origin_account_id), + Error::::ThisAccountIdIsNotAuthorized + ); + + Ok(origin_account_id) + } + + fn check_origin_rights(origin: OriginFor) -> DispatchResult { + if ensure_root(origin.clone()).is_err() { + Pallet::::check_non_root_rights(origin.clone())?; + } + + Ok(()) + } + } } pub mod upgrade_client_releases {