-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Introduce frame::system::Error::InvalidOrigin #4422
Conversation
e81a2c0
to
3e29a08
Compare
@@ -134,28 +134,6 @@ impl< | |||
} | |||
} | |||
|
|||
/// An error type that indicates that the origin is invalid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the trait should stay here and we introduce the BadOrigin
type directly here.
We already have some inherent errors that are declared by decl_error!
. I would add a new one BadOrigin
that implements From<BadOrigin>
that is defined in this file here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some upcoming changes in my mind for the error stuff, that would conflict in the way it is implemented currently.
@@ -168,7 +168,7 @@ decl_module! { | |||
/// # </weight> | |||
#[weight = SimpleDispatchInfo::FixedOperational(100_000)] | |||
fn reject_proposal(origin, #[compact] proposal_id: ProposalIndex) { | |||
T::RejectOrigin::ensure_origin(origin).map_err(|e| Into::<&str>::into(e))?; | |||
T::RejectOrigin::ensure_origin(origin).map_err(|e| e.as_str())?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why does it need to be .as_str()
? can't the error be returned back directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ensure_origin
returns system::Error
which needs to be converted to treasury::Error
accordingly to work, so it can't be returned directly.
Superseded by: #4449 |
Key points:
InvalidOrigin
has been added toframe::system::Error
.EnsureOrigin
trait has been moved fromprimitives/runtime/src/traits.rs
toframe::system
.Closes #4409.