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

include dispatch result in the Executed event #9315

Merged
4 commits merged into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions frame/democracy/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use frame_support::{
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime},
};
use frame_system::{RawOrigin, Pallet as System, self};
use sp_runtime::traits::{Bounded, One};
use sp_runtime::traits::{Bounded, One, BadOrigin};

use crate::Pallet as Democracy;

Expand Down Expand Up @@ -759,7 +759,7 @@ benchmarks! {
}: enact_proposal(RawOrigin::Root, proposal_hash, 0)
verify {
// Fails due to mismatched origin
assert_last_event::<T>(Event::<T>::Executed(0, false).into());
assert_last_event::<T>(Event::<T>::Executed(0, Err(BadOrigin.into())).into());
}

#[extra]
Expand Down
9 changes: 5 additions & 4 deletions frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -510,8 +510,8 @@ pub mod pallet {
NotPassed(ReferendumIndex),
/// A referendum has been cancelled. \[ref_index\]
Cancelled(ReferendumIndex),
/// A proposal has been enacted. \[ref_index, is_ok\]
Executed(ReferendumIndex, bool),
/// A proposal has been enacted. \[ref_index, result\]
Executed(ReferendumIndex, DispatchResult),
/// An account has delegated their vote to another account. \[who, target\]
Delegated(T::AccountId, T::AccountId),
/// An \[account\] has cancelled a previous delegation operation.
Expand Down Expand Up @@ -1652,8 +1652,9 @@ impl<T: Config> Pallet<T> {
debug_assert!(err_amount.is_zero());
Self::deposit_event(Event::<T>::PreimageUsed(proposal_hash, provider, deposit));

let ok = proposal.dispatch(frame_system::RawOrigin::Root.into()).is_ok();
Self::deposit_event(Event::<T>::Executed(index, ok));
let res = proposal.dispatch(frame_system::RawOrigin::Root.into())
.map(|_| ()).map_err(|e| e.error);
Self::deposit_event(Event::<T>::Executed(index, res));

Ok(())
} else {
Expand Down