mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 15:47:58 +00:00
Introduce EnsureOrigin::try_successul_origin (#11558)
* Introduce `EnsureOrigin::try_successul_origin` * Formatting * Fixes * Add Morph * Fixes * Formatting
This commit is contained in:
@@ -66,6 +66,8 @@
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
use serde::Serialize;
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
use sp_runtime::traits::TrailingZeroInput;
|
||||
use sp_runtime::{
|
||||
generic,
|
||||
traits::{
|
||||
@@ -782,8 +784,8 @@ impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>, Acco
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> O {
|
||||
O::from(RawOrigin::Root)
|
||||
fn try_successful_origin() -> Result<O, ()> {
|
||||
Ok(O::from(RawOrigin::Root))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,8 +807,8 @@ impl<
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> O {
|
||||
O::from(RawOrigin::Root)
|
||||
fn try_successful_origin() -> Result<O, ()> {
|
||||
Ok(O::from(RawOrigin::Root))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -823,11 +825,10 @@ impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>, Acco
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> O {
|
||||
fn try_successful_origin() -> Result<O, ()> {
|
||||
let zero_account_id =
|
||||
AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
|
||||
.expect("infinite length input; no invalid inputs for type; qed");
|
||||
O::from(RawOrigin::Signed(zero_account_id))
|
||||
AccountId::decode(&mut TrailingZeroInput::zeroes()).map_err(|_| ())?;
|
||||
Ok(O::from(RawOrigin::Signed(zero_account_id)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -847,16 +848,15 @@ impl<
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> O {
|
||||
fn try_successful_origin() -> Result<O, ()> {
|
||||
let zero_account_id =
|
||||
AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes())
|
||||
.expect("infinite length input; no invalid inputs for type; qed");
|
||||
AccountId::decode(&mut TrailingZeroInput::zeroes()).map_err(|_| ())?;
|
||||
let members = Who::sorted_members();
|
||||
let first_member = match members.get(0) {
|
||||
Some(account) => account.clone(),
|
||||
None => zero_account_id,
|
||||
};
|
||||
O::from(RawOrigin::Signed(first_member))
|
||||
Ok(O::from(RawOrigin::Signed(first_member)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -873,8 +873,8 @@ impl<O: Into<Result<RawOrigin<AccountId>, O>> + From<RawOrigin<AccountId>>, Acco
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> O {
|
||||
O::from(RawOrigin::None)
|
||||
fn try_successful_origin() -> Result<O, ()> {
|
||||
Ok(O::from(RawOrigin::None))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -886,8 +886,8 @@ impl<O, T> EnsureOrigin<O> for EnsureNever<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
fn successful_origin() -> O {
|
||||
unimplemented!()
|
||||
fn try_successful_origin() -> Result<O, ()> {
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user