pallet-utility: Only disallow the None origin (#12351)

This commit is contained in:
Bastian Köcher
2022-09-28 14:37:03 +02:00
committed by GitHub
parent 0327258566
commit 70f372ae38
+19 -4
View File
@@ -63,7 +63,7 @@ use frame_support::{
};
use sp_core::TypeId;
use sp_io::hashing::blake2_256;
use sp_runtime::traits::{Dispatchable, TrailingZeroInput};
use sp_runtime::traits::{BadOrigin, Dispatchable, TrailingZeroInput};
use sp_std::prelude::*;
pub use weights::WeightInfo;
@@ -203,7 +203,12 @@ pub mod pallet {
origin: OriginFor<T>,
calls: Vec<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo {
let is_root = ensure_signed_or_root(origin.clone())?.is_none();
// Do not allow the `None` origin.
if ensure_none(origin.clone()).is_ok() {
return Err(BadOrigin.into())
}
let is_root = ensure_root(origin.clone()).is_ok();
let calls_len = calls.len();
ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::<T>::TooManyCalls);
@@ -319,7 +324,12 @@ pub mod pallet {
origin: OriginFor<T>,
calls: Vec<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo {
let is_root = ensure_signed_or_root(origin.clone())?.is_none();
// Do not allow the `None` origin.
if ensure_none(origin.clone()).is_ok() {
return Err(BadOrigin.into())
}
let is_root = ensure_root(origin.clone()).is_ok();
let calls_len = calls.len();
ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::<T>::TooManyCalls);
@@ -426,7 +436,12 @@ pub mod pallet {
origin: OriginFor<T>,
calls: Vec<<T as Config>::RuntimeCall>,
) -> DispatchResultWithPostInfo {
let is_root = ensure_signed_or_root(origin.clone())?.is_none();
// Do not allow the `None` origin.
if ensure_none(origin.clone()).is_ok() {
return Err(BadOrigin.into())
}
let is_root = ensure_root(origin.clone()).is_ok();
let calls_len = calls.len();
ensure!(calls_len <= Self::batched_calls_limit() as usize, Error::<T>::TooManyCalls);