Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
pallet-utility: Only disallow the None origin (#12351)
Browse files Browse the repository at this point in the history
  • Loading branch information
bkchr committed Sep 28, 2022
1 parent f12ef6c commit 1cca061
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions frame/utility/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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;

Expand Down Expand Up @@ -203,7 +203,12 @@ pub mod pallet {
origin: OriginFor<T>,
calls: Vec<<T as Config>::Call>,
) -> 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);

Expand Down Expand Up @@ -319,7 +324,12 @@ pub mod pallet {
origin: OriginFor<T>,
calls: Vec<<T as Config>::Call>,
) -> 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);

Expand Down Expand Up @@ -424,7 +434,12 @@ pub mod pallet {
origin: OriginFor<T>,
calls: Vec<<T as Config>::Call>,
) -> 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);

Expand Down

0 comments on commit 1cca061

Please sign in to comment.