Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Add vote and seconded events to Democracy pallet. #10352

Merged
merged 4 commits into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// and set impl_version to 0. If only runtime
// implementation changes and behavior does not, then leave spec_version as
// is and increment impl_version.
spec_version: 268,
spec_version: 269,
gui1117 marked this conversation as resolved.
Show resolved Hide resolved
crystalin marked this conversation as resolved.
Show resolved Hide resolved
impl_version: 0,
apis: RUNTIME_API_VERSIONS,
transaction_version: 2,
Expand Down
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