Skip to content

Commit

Permalink
Add vote and seconded events to Democracy pallet. (paritytech#10352)
Browse files Browse the repository at this point in the history
* add the events

* spec_version

* Update bin/node/runtime/src/lib.rs

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>

Co-authored-by: Alan Sapede <alan.sapede@gmail.com>
Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
(cherry picked from commit 270fac3)
  • Loading branch information
JoshOrndorff committed Dec 1, 2021
1 parent 0c516a2 commit 5cb7cb1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion frame/democracy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,10 @@ pub mod pallet {
PreimageReaped(T::Hash, T::AccountId, BalanceOf<T>, T::AccountId),
/// A proposal \[hash\] has been blacklisted permanently.
Blacklisted(T::Hash),
/// An account has voted in a referendum
Voted(T::AccountId, ReferendumIndex, AccountVote<BalanceOf<T>>),
/// An account has secconded a proposal
Seconded(T::AccountId, PropIndex),
}

#[pallet::error]
Expand Down Expand Up @@ -687,8 +691,9 @@ pub mod pallet {
ensure!(seconds <= seconds_upper_bound, Error::<T>::WrongUpperBound);
let mut deposit = Self::deposit_of(proposal).ok_or(Error::<T>::ProposalMissing)?;
T::Currency::reserve(&who, deposit.1)?;
deposit.0.push(who);
deposit.0.push(who.clone());
<DepositOf<T>>::insert(proposal, deposit);
Self::deposit_event(Event::<T>::Seconded(who, proposal));
Ok(())
}

Expand Down Expand Up @@ -1383,6 +1388,7 @@ impl<T: Config> Pallet<T> {
votes.insert(i, (ref_index, vote));
},
}
Self::deposit_event(Event::<T>::Voted(who.clone(), ref_index, vote));
// Shouldn't be possible to fail, but we handle it gracefully.
status.tally.add(vote).ok_or(ArithmeticError::Overflow)?;
if let Some(approve) = vote.as_standard() {
Expand Down

0 comments on commit 5cb7cb1

Please sign in to comment.