Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include events for voting #4613

10 changes: 10 additions & 0 deletions prdoc/pr_4613.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
title: "pallet-conviction-voting: Include events for vote and remove vote"

doc:
- audience: Runtime User
description: |
Introduce event called `Voted: { who: T::AccountId, vote: AccountVote<BalanceOf<T, I>> }` and `VoteRemoved: { who: T::AccountId, vote: AccountVote<BalanceOf<T, I>> }`

crates:
- name: pallet-conviction-voting
bump: major
6 changes: 6 additions & 0 deletions substrate/frame/conviction-voting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ pub mod pallet {
Delegated(T::AccountId, T::AccountId),
/// An \[account\] has cancelled a previous delegation operation.
Undelegated(T::AccountId),
/// An account that has voted
Voted { who: T::AccountId, vote: AccountVote<BalanceOf<T, I>> },
/// A vote that been removed
VoteRemoved { who: T::AccountId, vote: AccountVote<BalanceOf<T, I>> },
}

#[pallet::error]
Expand Down Expand Up @@ -427,6 +431,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
// Extend the lock to `balance` (rather than setting it) since we don't know what
// other votes are in place.
Self::extend_lock(who, &class, vote.balance());
Self::deposit_event(Event::Voted { who: who.clone(), vote });
Ok(())
})
})
Expand Down Expand Up @@ -462,6 +467,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
if let Some(approve) = v.1.as_standard() {
tally.reduce(approve, *delegations);
}
Self::deposit_event(Event::VoteRemoved { who: who.clone(), vote: v.1 });
Ok(())
},
PollStatus::Completed(end, approved) => {
Expand Down
Loading