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>
  • Loading branch information
3 people authored and grishasobol committed Mar 28, 2022
1 parent 0ea53a5 commit acba51a
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 @@ -539,6 +539,10 @@ pub mod pallet {
},
/// A proposal_hash has been blacklisted permanently.
Blacklisted { proposal_hash: T::Hash },
/// An account has voted in a referendum
Voted { voter: T::AccountId, ref_index: ReferendumIndex, vote: AccountVote<BalanceOf<T>> },
/// An account has secconded a proposal
Seconded { seconder: T::AccountId, prop_index: PropIndex },
}

#[pallet::error]
Expand Down Expand Up @@ -677,8 +681,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 { seconder: who, prop_index: proposal });
Ok(())
}

Expand Down Expand Up @@ -1378,6 +1383,7 @@ impl<T: Config> Pallet<T> {
votes.insert(i, (ref_index, vote));
},
}
Self::deposit_event(Event::<T>::Voted { voter: 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 acba51a

Please sign in to comment.