mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-24 11:21:08 +00:00
Make public is_passing and ReferendumStatus (#12667)
* init * clean * remove manual getter for ReferendumStatus in favor of changing pub crate to pub for ReferendumStatus DecidingStatus Deposit types * rm status getters because fields are pub now
This commit is contained in:
@@ -701,6 +701,31 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns whether the referendum is passing.
|
||||
/// Referendum must be ongoing and its track must exist.
|
||||
pub fn is_referendum_passing(ref_index: ReferendumIndex) -> Result<bool, DispatchError> {
|
||||
let info = ReferendumInfoFor::<T, I>::get(ref_index).ok_or(Error::<T, I>::BadReferendum)?;
|
||||
match info {
|
||||
ReferendumInfo::Ongoing(status) => {
|
||||
let track = Self::track(status.track).ok_or(Error::<T, I>::NoTrack)?;
|
||||
let elapsed = if let Some(deciding) = status.deciding {
|
||||
frame_system::Pallet::<T>::block_number().saturating_sub(deciding.since)
|
||||
} else {
|
||||
Zero::zero()
|
||||
};
|
||||
Ok(Self::is_passing(
|
||||
&status.tally,
|
||||
elapsed,
|
||||
track.decision_period,
|
||||
&track.min_support,
|
||||
&track.min_approval,
|
||||
status.track,
|
||||
))
|
||||
},
|
||||
_ => Err(Error::<T, I>::NotOngoing.into()),
|
||||
}
|
||||
}
|
||||
|
||||
// Enqueue a proposal from a referendum which has presumably passed.
|
||||
fn schedule_enactment(
|
||||
index: ReferendumIndex,
|
||||
|
||||
Reference in New Issue
Block a user