@@ -367,23 +367,21 @@ pub mod pallet {
367367 /// Duplicate proposals not allowed
368368 DuplicateProposal ,
369369 /// Proposal must exist
370- ProposalMissing ,
371- /// Mismatched index
372- WrongIndex ,
370+ ProposalNotExists ,
371+ /// Index mismatched the proposal hash
372+ IndexMismatchProposalHash ,
373373 /// Duplicate vote ignored
374374 DuplicateVote ,
375- /// Members are already initialized.
376- AlreadyInitialized ,
377- /// The close call was made too early, before the end of the voting.
378- TooEarly ,
375+ /// The call to close the proposal was made too early, before the end of the voting
376+ TooEarlyToCloseProposal ,
379377 /// There can only be a maximum of `MaxProposals` active proposals.
380- TooManyProposals ,
381- /// The given weight bound for the proposal was too low.
382- WrongProposalWeight ,
383- /// The given length bound for the proposal was too low.
384- WrongProposalLength ,
378+ TooManyActiveProposals ,
379+ /// The given weight- bound for the proposal was too low.
380+ ProposalWeightLessThanDispatchCallWeight ,
381+ /// The given length- bound for the proposal was too low.
382+ ProposalLengthBoundLessThanProposalLength ,
385383 /// The given motion duration for the proposal was too low.
386- WrongDuration ,
384+ DurationLowerThanConfiguredMotionDuration ,
387385 }
388386
389387 // Note that councillor operations are assigned to the operational class.
@@ -489,7 +487,7 @@ pub mod pallet {
489487 let proposal_len = proposal. encoded_size ( ) ;
490488 ensure ! (
491489 proposal_len <= length_bound as usize ,
492- Error :: <T , I >:: WrongProposalLength
490+ Error :: <T , I >:: ProposalLengthBoundLessThanProposalLength
493491 ) ;
494492
495493 let proposal_hash = T :: Hashing :: hash_of ( & proposal) ;
@@ -544,7 +542,7 @@ pub mod pallet {
544542
545543 ensure ! (
546544 duration >= T :: MotionDuration :: get( ) ,
547- Error :: <T , I >:: WrongDuration
545+ Error :: <T , I >:: DurationLowerThanConfiguredMotionDuration
548546 ) ;
549547
550548 let threshold = ( T :: GetVotingMembers :: get_count ( ) / 2 ) + 1 ;
@@ -689,32 +687,6 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
689687 Self :: members ( ) . contains ( who)
690688 }
691689
692- /// Execute immediately when adding a new proposal.
693- pub fn do_propose_execute (
694- proposal : Box < <T as Config < I > >:: Proposal > ,
695- length_bound : MemberCount ,
696- ) -> Result < ( u32 , DispatchResultWithPostInfo ) , DispatchError > {
697- let proposal_len = proposal. encoded_size ( ) ;
698- ensure ! (
699- proposal_len <= length_bound as usize ,
700- Error :: <T , I >:: WrongProposalLength
701- ) ;
702-
703- let proposal_hash = T :: Hashing :: hash_of ( & proposal) ;
704- ensure ! (
705- !<ProposalOf <T , I >>:: contains_key( proposal_hash) ,
706- Error :: <T , I >:: DuplicateProposal
707- ) ;
708-
709- let seats = Self :: members ( ) . len ( ) as MemberCount ;
710- let result = proposal. dispatch ( RawOrigin :: Members ( 1 , seats) . into ( ) ) ;
711- Self :: deposit_event ( Event :: Executed {
712- proposal_hash,
713- result : result. map ( |_| ( ) ) . map_err ( |e| e. error ) ,
714- } ) ;
715- Ok ( ( proposal_len as u32 , result) )
716- }
717-
718690 /// Add a new proposal to be voted.
719691 pub fn do_propose_proposed (
720692 who : T :: AccountId ,
@@ -726,7 +698,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
726698 let proposal_len = proposal. encoded_size ( ) ;
727699 ensure ! (
728700 proposal_len <= length_bound as usize ,
729- Error :: <T , I >:: WrongProposalLength
701+ Error :: <T , I >:: ProposalLengthBoundLessThanProposalLength
730702 ) ;
731703
732704 let proposal_hash = T :: Hashing :: hash_of ( & proposal) ;
@@ -739,7 +711,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
739711 <Proposals < T , I > >:: try_mutate ( |proposals| -> Result < usize , DispatchError > {
740712 proposals
741713 . try_push ( proposal_hash)
742- . map_err ( |_| Error :: < T , I > :: TooManyProposals ) ?;
714+ . map_err ( |_| Error :: < T , I > :: TooManyActiveProposals ) ?;
743715 Ok ( proposals. len ( ) )
744716 } ) ?;
745717
@@ -775,8 +747,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
775747 index : ProposalIndex ,
776748 approve : bool ,
777749 ) -> Result < bool , DispatchError > {
778- let mut voting = Self :: voting ( proposal) . ok_or ( Error :: < T , I > :: ProposalMissing ) ?;
779- ensure ! ( voting. index == index, Error :: <T , I >:: WrongIndex ) ;
750+ let mut voting = Self :: voting ( proposal) . ok_or ( Error :: < T , I > :: ProposalNotExists ) ?;
751+ ensure ! (
752+ voting. index == index,
753+ Error :: <T , I >:: IndexMismatchProposalHash
754+ ) ;
780755
781756 let position_yes = voting. ayes . iter ( ) . position ( |a| a == & who) ;
782757 let position_no = voting. nays . iter ( ) . position ( |a| a == & who) ;
@@ -826,8 +801,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
826801 proposal_weight_bound : Weight ,
827802 length_bound : u32 ,
828803 ) -> DispatchResultWithPostInfo {
829- let voting = Self :: voting ( proposal_hash) . ok_or ( Error :: < T , I > :: ProposalMissing ) ?;
830- ensure ! ( voting. index == index, Error :: <T , I >:: WrongIndex ) ;
804+ let voting = Self :: voting ( proposal_hash) . ok_or ( Error :: < T , I > :: ProposalNotExists ) ?;
805+ ensure ! (
806+ voting. index == index,
807+ Error :: <T , I >:: IndexMismatchProposalHash
808+ ) ;
831809
832810 let mut no_votes = voting. nays . len ( ) as MemberCount ;
833811 let mut yes_votes = voting. ayes . len ( ) as MemberCount ;
@@ -876,7 +854,7 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
876854 // Only allow actual closing of the proposal after the voting period has ended.
877855 ensure ! (
878856 frame_system:: Pallet :: <T >:: block_number( ) >= voting. end,
879- Error :: <T , I >:: TooEarly
857+ Error :: <T , I >:: TooEarlyToCloseProposal
880858 ) ;
881859
882860 let prime_vote = Self :: prime ( ) . map ( |who| voting. ayes . iter ( ) . any ( |a| a == & who) ) ;
@@ -939,16 +917,16 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
939917 let key = ProposalOf :: < T , I > :: hashed_key_for ( hash) ;
940918 // read the length of the proposal storage entry directly
941919 let proposal_len =
942- storage:: read ( & key, & mut [ 0 ; 0 ] , 0 ) . ok_or ( Error :: < T , I > :: ProposalMissing ) ?;
920+ storage:: read ( & key, & mut [ 0 ; 0 ] , 0 ) . ok_or ( Error :: < T , I > :: ProposalNotExists ) ?;
943921 ensure ! (
944922 proposal_len <= length_bound,
945- Error :: <T , I >:: WrongProposalLength
923+ Error :: <T , I >:: ProposalLengthBoundLessThanProposalLength
946924 ) ;
947- let proposal = ProposalOf :: < T , I > :: get ( hash) . ok_or ( Error :: < T , I > :: ProposalMissing ) ?;
925+ let proposal = ProposalOf :: < T , I > :: get ( hash) . ok_or ( Error :: < T , I > :: ProposalNotExists ) ?;
948926 let proposal_weight = proposal. get_dispatch_info ( ) . weight ;
949927 ensure ! (
950928 proposal_weight. all_lte( weight_bound) ,
951- Error :: <T , I >:: WrongProposalWeight
929+ Error :: <T , I >:: ProposalWeightLessThanDispatchCallWeight
952930 ) ;
953931 Ok ( ( proposal, proposal_len as usize ) )
954932 }
@@ -1027,8 +1005,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
10271005 index : ProposalIndex ,
10281006 who : & T :: AccountId ,
10291007 ) -> Result < bool , DispatchError > {
1030- let voting = Self :: voting ( proposal) . ok_or ( Error :: < T , I > :: ProposalMissing ) ?;
1031- ensure ! ( voting. index == index, Error :: <T , I >:: WrongIndex ) ;
1008+ let voting = Self :: voting ( proposal) . ok_or ( Error :: < T , I > :: ProposalNotExists ) ?;
1009+ ensure ! (
1010+ voting. index == index,
1011+ Error :: <T , I >:: IndexMismatchProposalHash
1012+ ) ;
10321013
10331014 let position_yes = voting. ayes . iter ( ) . position ( |a| a == who) ;
10341015 let position_no = voting. nays . iter ( ) . position ( |a| a == who) ;
0 commit comments