EnsureOrigin is a frame abstraction - it should be in frame_support (#5521)

* EnsureOrigin is a frame abstraction - it should be in frame_support

* Fixes
This commit is contained in:
Gavin Wood
2020-04-04 12:58:05 +02:00
committed by GitHub
parent f0375a858f
commit 7c0fa83720
14 changed files with 48 additions and 45 deletions
+1 -19
View File
@@ -17,7 +17,7 @@
//! Primitives for the runtime modules.
use sp_std::prelude::*;
use sp_std::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}, fmt::Debug};
use sp_std::{self, marker::PhantomData, convert::{TryFrom, TryInto}, fmt::Debug};
use sp_io;
#[cfg(feature = "std")]
use std::fmt::Display;
@@ -147,24 +147,6 @@ impl From<BadOrigin> for &'static str {
}
}
/// Some sort of check on the origin is performed by this object.
pub trait EnsureOrigin<OuterOrigin> {
/// A return type.
type Success;
/// Perform the origin check.
fn ensure_origin(o: OuterOrigin) -> result::Result<Self::Success, BadOrigin> {
Self::try_origin(o).map_err(|_| BadOrigin)
}
/// Perform the origin check.
fn try_origin(o: OuterOrigin) -> result::Result<Self::Success, OuterOrigin>;
/// Returns an outer origin capable of passing `try_origin` check.
///
/// ** Should be used for benchmarking only!!! **
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin() -> OuterOrigin;
}
/// An error that indicates that a lookup failed.
#[derive(Encode, Decode, RuntimeDebug)]
pub struct LookupError;