Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update EnsureOriginWithArg
  • Loading branch information
muharem committed Jan 20, 2023
commit 441c24fa47d76ceee7f56ba1e209408014ce409b
21 changes: 5 additions & 16 deletions frame/support/src/traits/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub trait EnsureOrigin<OuterOrigin> {
fn try_origin(o: OuterOrigin) -> Result<Self::Success, OuterOrigin>;

/// Attempt to get an outer origin capable of passing `try_origin` check. May return `Err` if it
/// is impossible. Default implementation returns `Err`.
/// is impossible.
///
/// ** Should be used for benchmarking only!!! **
#[cfg(feature = "runtime-benchmarks")]
Expand Down Expand Up @@ -160,24 +160,13 @@ pub trait EnsureOriginWithArg<OuterOrigin, Argument> {
/// Perform the origin check, returning the origin value if unsuccessful. This allows chaining.
fn try_origin(o: OuterOrigin, a: &Argument) -> Result<Self::Success, OuterOrigin>;

/// Returns an outer origin capable of passing `try_origin` check.
///
/// NOTE: This should generally *NOT* be reimplemented. Instead implement
/// `try_successful_origin`.
///
/// ** Should be used for benchmarking only!!! **
#[cfg(feature = "runtime-benchmarks")]
fn successful_origin(a: &Argument) -> OuterOrigin {
Self::try_successful_origin(a).expect("No origin exists which can satisfy the guard")
}

/// Attept to get an outer origin capable of passing `try_origin` check. May return `Err` if it
/// is impossible. Default implementation just uses `successful_origin()`.
/// Attempt to get an outer origin capable of passing `try_origin` check. May return `Err` if it
/// is impossible.
///
/// ** Should be used for benchmarking only!!! **
#[cfg(feature = "runtime-benchmarks")]
fn try_successful_origin(a: &Argument) -> Result<OuterOrigin, ()> {
Ok(Self::successful_origin(a))
fn try_successful_origin() -> Result<OuterOrigin, ()> {
unimplemented!()
}
}

Expand Down