Skip to content

Commit cbe2bfa

Browse files
authored
Merge pull request #89 from mangata-finance/feature/governance-upgrade
Governance Upgrade MGX-380
2 parents 23c75b1 + 4f5c90c commit cbe2bfa

File tree

2 files changed

+470
-206
lines changed

2 files changed

+470
-206
lines changed

frame/collective-mangata/src/lib.rs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ pub mod pallet {
231231
/// Default vote strategy of this collective.
232232
type DefaultVote: DefaultVote;
233233

234+
/// The provider for the list of Foundation accounts
235+
type FoundationAccountsProvider: Get<Vec<Self::AccountId>>;
236+
234237
/// Weight information for extrinsics in this pallet.
235238
type WeightInfo: WeightInfo;
236239
}
@@ -360,14 +363,16 @@ pub mod pallet {
360363
/// The close call was made too early, before the end of the voting.
361364
TooEarly,
362365
/// To early to close the proposal, can only close ProposalCloseDelay blocks after proposal
363-
/// was proposed
364-
TooEarlyToClose,
366+
/// was proposed unless by a foundation account
367+
TooEarlyToCloseByNonFoundationAccount,
365368
/// There can only be a maximum of `MaxProposals` active proposals.
366369
TooManyProposals,
367370
/// The given weight bound for the proposal was too low.
368371
WrongProposalWeight,
369372
/// The given length bound for the proposal was too low.
370373
WrongProposalLength,
374+
/// Requires foundation account or root
375+
NotFoundationAccountOrRoot,
371376
}
372377

373378
// Note that councillor operations are assigned to the operational class.
@@ -676,15 +681,15 @@ pub mod pallet {
676681
proposal_weight_bound: Weight,
677682
#[pallet::compact] length_bound: u32,
678683
) -> DispatchResultWithPostInfo {
679-
let _ = ensure_signed(origin)?;
684+
let caller = ensure_signed(origin)?;
680685

681-
Self::do_close(proposal_hash, index, proposal_weight_bound, length_bound)
686+
Self::do_close(caller, proposal_hash, index, proposal_weight_bound, length_bound)
682687
}
683688

684689
/// Disapprove a proposal, close, and remove it from the system, regardless of its current
685690
/// state.
686691
///
687-
/// Must be called by the Root origin.
692+
/// Must be called by the Root origin or a foundation account.
688693
///
689694
/// Parameters:
690695
/// * `proposal_hash`: The hash of the proposal that should be disapproved.
@@ -701,7 +706,12 @@ pub mod pallet {
701706
origin: OriginFor<T>,
702707
proposal_hash: T::Hash,
703708
) -> DispatchResultWithPostInfo {
704-
ensure_root(origin)?;
709+
if let Some(caller) = ensure_signed_or_root(origin)? {
710+
ensure!(
711+
T::FoundationAccountsProvider::get().contains(&caller),
712+
Error::<T, I>::NotFoundationAccountOrRoot
713+
);
714+
}
705715
let proposal_count = Self::do_disapprove_proposal(proposal_hash);
706716
Ok(Some(T::WeightInfo::disapprove_proposal(proposal_count)).into())
707717
}
@@ -856,6 +866,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
856866

857867
/// Close a vote that is either approved, disapproved or whose voting period has ended.
858868
pub fn do_close(
869+
caller: T::AccountId,
859870
proposal_hash: T::Hash,
860871
index: ProposalIndex,
861872
proposal_weight_bound: Weight,
@@ -870,9 +881,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
870881
Self::proposal_proposed_time(&proposal_hash).unwrap_or_default();
871882
// Only allow actual closing of the proposal after the voting period has ended.
872883
ensure!(
873-
frame_system::Pallet::<T>::block_number() >=
874-
proposal_proposed_time.saturating_add(T::ProposalCloseDelay::get()),
875-
Error::<T, I>::TooEarlyToClose
884+
(frame_system::Pallet::<T>::block_number() >=
885+
proposal_proposed_time.saturating_add(T::ProposalCloseDelay::get())) ||
886+
(T::FoundationAccountsProvider::get().contains(&caller)),
887+
Error::<T, I>::TooEarlyToCloseByNonFoundationAccount
876888
);
877889

878890
let mut no_votes = voting.nays.len() as MemberCount;

0 commit comments

Comments
 (0)