Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
add as_origin
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc committed Jun 19, 2020
1 parent 5f1ee49 commit c62d29d
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions frame/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ use frame_support::{
},
weights::{
Weight, RuntimeDbWeight, DispatchInfo, PostDispatchInfo, DispatchClass,
extract_actual_weight,
extract_actual_weight, GetDispatchInfo,
},
dispatch::DispatchResultWithPostInfo,
};
Expand Down Expand Up @@ -157,10 +157,11 @@ pub trait Trait: 'static + Eq + Clone {
Into<Result<RawOrigin<Self::AccountId>, Self::Origin>>
+ From<RawOrigin<Self::AccountId>>
+ Clone
+ OriginTrait<Call = Self::Call>;
+ OriginTrait<Call = Self::Call>
+ Parameter;

/// The aggregated `Call` type.
type Call: Dispatchable + Debug;
type Call: Parameter + Dispatchable<Origin=Self::Origin, PostInfo=PostDispatchInfo> + Debug + GetDispatchInfo;

/// Account index (aka nonce) type. This stores the number of previous transactions associated
/// with a sender account.
Expand Down Expand Up @@ -740,6 +741,20 @@ decl_module! {
ensure!(account.data == T::AccountData::default(), Error::<T>::NonDefaultComposite);
Self::kill_account(&who);
}

/// Dispatches a function call with the provided origin.
///
/// The dispatch origin for this call must be _Root_.
///
/// # <weight>
/// - O(1).
/// - Weight of derivative `call` execution + 10,000.
/// # </weight>
#[weight = (call.get_dispatch_info().weight + 10_000, DispatchClass::Operational)]
pub fn as_orign(origin, real: T::Origin, call: Box<T::Call>) {
ensure_root(origin)?;
call.dispatch(real).map_err(|e| e.error)?;
}
}
}

Expand Down

0 comments on commit c62d29d

Please sign in to comment.