include dispatch result in the Executed event (#9315)

* include dispatch result in the Executed event

* fix

* trigger CI
This commit is contained in:
Xiliang Chen
2021-07-21 02:40:11 +12:00
committed by GitHub
parent 2b282a9435
commit e17a014627
2 changed files with 7 additions and 6 deletions
@@ -25,7 +25,7 @@ use frame_support::{
traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime}, traits::{Currency, Get, EnsureOrigin, OnInitialize, UnfilteredDispatchable, schedule::DispatchTime},
}; };
use frame_system::{RawOrigin, Pallet as System, self}; 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; use crate::Pallet as Democracy;
@@ -759,7 +759,7 @@ benchmarks! {
}: enact_proposal(RawOrigin::Root, proposal_hash, 0) }: enact_proposal(RawOrigin::Root, proposal_hash, 0)
verify { verify {
// Fails due to mismatched origin // 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] #[extra]
+5 -4
View File
@@ -512,8 +512,8 @@ pub mod pallet {
NotPassed(ReferendumIndex), NotPassed(ReferendumIndex),
/// A referendum has been cancelled. \[ref_index\] /// A referendum has been cancelled. \[ref_index\]
Cancelled(ReferendumIndex), Cancelled(ReferendumIndex),
/// A proposal has been enacted. \[ref_index, is_ok\] /// A proposal has been enacted. \[ref_index, result\]
Executed(ReferendumIndex, bool), Executed(ReferendumIndex, DispatchResult),
/// An account has delegated their vote to another account. \[who, target\] /// An account has delegated their vote to another account. \[who, target\]
Delegated(T::AccountId, T::AccountId), Delegated(T::AccountId, T::AccountId),
/// An \[account\] has cancelled a previous delegation operation. /// An \[account\] has cancelled a previous delegation operation.
@@ -1654,8 +1654,9 @@ impl<T: Config> Pallet<T> {
debug_assert!(err_amount.is_zero()); debug_assert!(err_amount.is_zero());
Self::deposit_event(Event::<T>::PreimageUsed(proposal_hash, provider, deposit)); Self::deposit_event(Event::<T>::PreimageUsed(proposal_hash, provider, deposit));
let ok = proposal.dispatch(frame_system::RawOrigin::Root.into()).is_ok(); let res = proposal.dispatch(frame_system::RawOrigin::Root.into())
Self::deposit_event(Event::<T>::Executed(index, ok)); .map(|_| ()).map_err(|e| e.error);
Self::deposit_event(Event::<T>::Executed(index, res));
Ok(()) Ok(())
} else { } else {