mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 14:01:06 +00:00
"OR gate" for EnsureOrigin (#6237)
* 'OR gate' for EnsureOrigin. * Formatting. * More formatting. * Add docstring; Update 'Success' type. * Bump runtime impl_version. * Fix successful_origin. * Add either into std feature list. * Update docs.
This commit is contained in:
@@ -78,7 +78,7 @@ use frame_support::{
|
||||
traits::{Currency, ReservableCurrency, OnUnbalanced, Get, BalanceStatus, EnsureOrigin},
|
||||
weights::Weight,
|
||||
};
|
||||
use frame_system::{self as system, ensure_signed, ensure_root};
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
|
||||
mod benchmarking;
|
||||
|
||||
@@ -635,9 +635,7 @@ decl_module! {
|
||||
/// # </weight>
|
||||
#[weight = weight_for::add_registrar::<T>(T::MaxRegistrars::get().into()) ]
|
||||
fn add_registrar(origin, account: T::AccountId) -> DispatchResultWithPostInfo {
|
||||
T::RegistrarOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
.or_else(ensure_root)?;
|
||||
T::RegistrarOrigin::ensure_origin(origin)?;
|
||||
|
||||
let (i, registrar_count) = <Registrars<T>>::try_mutate(
|
||||
|registrars| -> Result<(RegistrarIndex, usize), DispatchError> {
|
||||
@@ -1108,9 +1106,7 @@ decl_module! {
|
||||
T::MaxAdditionalFields::get().into(), // X
|
||||
)]
|
||||
fn kill_identity(origin, target: <T::Lookup as StaticLookup>::Source) -> DispatchResultWithPostInfo {
|
||||
T::ForceOrigin::try_origin(origin)
|
||||
.map(|_| ())
|
||||
.or_else(ensure_root)?;
|
||||
T::ForceOrigin::ensure_origin(origin)?;
|
||||
|
||||
// Figure out who we're meant to be clearing.
|
||||
let target = T::Lookup::lookup(target)?;
|
||||
@@ -1435,7 +1431,7 @@ mod tests {
|
||||
new_test_ext().execute_with(|| {
|
||||
assert_ok!(Identity::set_identity(Origin::signed(10), ten()));
|
||||
assert_ok!(Identity::set_subs(Origin::signed(10), vec![(20, Data::Raw(vec![40; 1]))]));
|
||||
assert_ok!(Identity::kill_identity(Origin::ROOT, 10));
|
||||
assert_ok!(Identity::kill_identity(Origin::signed(2), 10));
|
||||
assert_eq!(Balances::free_balance(10), 80);
|
||||
assert!(Identity::super_of(20).is_none());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user