@@ -231,6 +231,9 @@ pub mod pallet {
231
231
/// Default vote strategy of this collective.
232
232
type DefaultVote : DefaultVote ;
233
233
234
+ /// The provider for the list of Foundation accounts
235
+ type FoundationAccountsProvider : Get < Vec < Self :: AccountId > > ;
236
+
234
237
/// Weight information for extrinsics in this pallet.
235
238
type WeightInfo : WeightInfo ;
236
239
}
@@ -360,14 +363,16 @@ pub mod pallet {
360
363
/// The close call was made too early, before the end of the voting.
361
364
TooEarly ,
362
365
/// 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 ,
365
368
/// There can only be a maximum of `MaxProposals` active proposals.
366
369
TooManyProposals ,
367
370
/// The given weight bound for the proposal was too low.
368
371
WrongProposalWeight ,
369
372
/// The given length bound for the proposal was too low.
370
373
WrongProposalLength ,
374
+ /// Requires foundation account or root
375
+ NotFoundationAccountOrRoot ,
371
376
}
372
377
373
378
// Note that councillor operations are assigned to the operational class.
@@ -676,15 +681,15 @@ pub mod pallet {
676
681
proposal_weight_bound : Weight ,
677
682
#[ pallet:: compact] length_bound : u32 ,
678
683
) -> DispatchResultWithPostInfo {
679
- let _ = ensure_signed ( origin) ?;
684
+ let caller = ensure_signed ( origin) ?;
680
685
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)
682
687
}
683
688
684
689
/// Disapprove a proposal, close, and remove it from the system, regardless of its current
685
690
/// state.
686
691
///
687
- /// Must be called by the Root origin.
692
+ /// Must be called by the Root origin or a foundation account .
688
693
///
689
694
/// Parameters:
690
695
/// * `proposal_hash`: The hash of the proposal that should be disapproved.
@@ -701,7 +706,12 @@ pub mod pallet {
701
706
origin : OriginFor < T > ,
702
707
proposal_hash : T :: Hash ,
703
708
) -> 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
+ }
705
715
let proposal_count = Self :: do_disapprove_proposal ( proposal_hash) ;
706
716
Ok ( Some ( T :: WeightInfo :: disapprove_proposal ( proposal_count) ) . into ( ) )
707
717
}
@@ -856,6 +866,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
856
866
857
867
/// Close a vote that is either approved, disapproved or whose voting period has ended.
858
868
pub fn do_close (
869
+ caller : T :: AccountId ,
859
870
proposal_hash : T :: Hash ,
860
871
index : ProposalIndex ,
861
872
proposal_weight_bound : Weight ,
@@ -870,9 +881,10 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
870
881
Self :: proposal_proposed_time ( & proposal_hash) . unwrap_or_default ( ) ;
871
882
// Only allow actual closing of the proposal after the voting period has ended.
872
883
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
876
888
) ;
877
889
878
890
let mut no_votes = voting. nays . len ( ) as MemberCount ;
0 commit comments