Skip to content
Snippets Groups Projects
Unverified Commit d511ba03 authored by Xiliang Chen's avatar Xiliang Chen Committed by GitHub
Browse files

remove Default from Call (#126)

* remove Default from Call

* break line a bit
parent 2e054ce9
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ type CallOf<T> = <T as Trait>::Call;
pub trait Trait: frame_system::Trait {
type Event: From<Event<Self>> + Into<<Self as frame_system::Trait>::Event>;
type Call: Parameter + Default + Dispatchable<Origin = <Self as frame_system::Trait>::Origin> + GetDispatchInfo;
type Call: Parameter + Dispatchable<Origin = <Self as frame_system::Trait>::Origin> + GetDispatchInfo;
type MaxScheduleDispatchWeight: Get<Weight>;
}
......@@ -66,8 +66,10 @@ decl_error! {
decl_storage! {
trait Store for Module<T: Trait> as ScheduleUpdate {
pub NextId get(fn next_id): DispatchId;
pub DelayedNormalDispatches get(fn delayed_normal_dispatches): double_map hasher(twox_64_concat) T::BlockNumber, hasher(twox_64_concat) DispatchId => (Option<T::AccountId>, CallOf<T>, DispatchId);
pub DelayedOperationalDispatches get(fn delayed_operational_dispatches): double_map hasher(twox_64_concat) T::BlockNumber, hasher(twox_64_concat) DispatchId => (Option<T::AccountId>, CallOf<T>, DispatchId);
pub DelayedNormalDispatches get(fn delayed_normal_dispatches):
double_map hasher(twox_64_concat) T::BlockNumber, hasher(twox_64_concat) DispatchId => Option<(Option<T::AccountId>, CallOf<T>, DispatchId)>;
pub DelayedOperationalDispatches get(fn delayed_operational_dispatches):
double_map hasher(twox_64_concat) T::BlockNumber, hasher(twox_64_concat) DispatchId => Option<(Option<T::AccountId>, CallOf<T>, DispatchId)>;
}
}
......@@ -115,22 +117,16 @@ decl_module! {
pub fn cancel_deplayed_dispatch(origin, at: T::BlockNumber, id: DispatchId) {
let is_root = ensure_root(origin.clone()).is_ok();
if <DelayedNormalDispatches<T>>::contains_key(at, id) {
if let Some((who, _, _)) = <DelayedNormalDispatches<T>>::get(at, id) {
if !is_root {
let w = ensure_signed(origin)?;
let (who, _, _) = <DelayedNormalDispatches<T>>::get(at, id);
if Some(w) != who {
return Err(Error::<T>::NoPermission.into());
}
ensure!(Some(w) == who, Error::<T>::NoPermission);
}
<DelayedNormalDispatches<T>>::remove(at, id);
} else if <DelayedOperationalDispatches<T>>::contains_key(at, id) {
} else if let Some((who, _, _)) = <DelayedOperationalDispatches<T>>::get(at, id) {
if !is_root {
let w = ensure_signed(origin)?;
let (who, _, _) = <DelayedOperationalDispatches<T>>::get(at, id);
if Some(w) != who {
return Err(Error::<T>::NoPermission.into());
}
ensure!(Some(w) == who, Error::<T>::NoPermission);
}
<DelayedOperationalDispatches<T>>::remove(at, id);
} else {
......
......@@ -31,12 +31,6 @@ impl_outer_dispatch! {
}
}
impl Default for Call {
fn default() -> Call {
Default::default()
}
}
// Workaround for https://github.com/rust-lang/rust/issues/26925 . Remove when sorted.
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct Runtime;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment