Skip to content
Snippets Groups Projects
Unverified Commit 2982bf3e authored by dharjeezy's avatar dharjeezy Committed by GitHub
Browse files

include events for voting (#4613)


closes https://github.com/paritytech/polkadot-sdk/issues/143

Polkadot address: 12GyGD3QhT4i2JJpNzvMf96sxxBLWymz4RdGCxRH5Rj5agKW

---------

Co-authored-by: default avatarMuharem <ismailov.m.h@gmail.com>
parent 82a30782
No related merge requests found
Pipeline #486141 waiting for manual action with stages
in 49 minutes and 23 seconds
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
...@@ -171,6 +171,10 @@ pub mod pallet { ...@@ -171,6 +171,10 @@ pub mod pallet {
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.
Undelegated(T::AccountId), 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] #[pallet::error]
...@@ -428,6 +432,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> { ...@@ -428,6 +432,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 // Extend the lock to `balance` (rather than setting it) since we don't know what
// other votes are in place. // other votes are in place.
Self::extend_lock(who, &class, vote.balance()); Self::extend_lock(who, &class, vote.balance());
Self::deposit_event(Event::Voted { who: who.clone(), vote });
Ok(()) Ok(())
}) })
}) })
...@@ -463,6 +468,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> { ...@@ -463,6 +468,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
if let Some(approve) = v.1.as_standard() { if let Some(approve) = v.1.as_standard() {
tally.reduce(approve, *delegations); tally.reduce(approve, *delegations);
} }
Self::deposit_event(Event::VoteRemoved { who: who.clone(), vote: v.1 });
Ok(()) Ok(())
}, },
PollStatus::Completed(end, approved) => { PollStatus::Completed(end, approved) => {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment