This repository was archived by the owner on Mar 11, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -462,6 +462,10 @@ pub enum GovernanceError {
462
462
///Invalid deposit Payer for ProposalDeposit
463
463
#[ error( "Invalid deposit Payer for ProposalDeposit" ) ]
464
464
InvalidDepositPayerForProposalDeposit , // 611
465
+
466
+ /// Invalid State: Proposal is not in final state
467
+ #[ error( "Invalid State: Proposal is not in final state" ) ]
468
+ InvalidStateNotFinal , // 612
465
469
}
466
470
467
471
impl PrintProgramError for GovernanceError {
Original file line number Diff line number Diff line change @@ -259,6 +259,23 @@ impl ProposalV2 {
259
259
Ok ( ( ) )
260
260
}
261
261
262
+ /// Checks the Proposal was finalized (no more state transition will happen)
263
+ pub fn assert_is_final_state ( & self ) -> Result < ( ) , ProgramError > {
264
+ match self . state {
265
+ ProposalState :: Completed
266
+ | ProposalState :: Cancelled
267
+ | ProposalState :: Defeated
268
+ | ProposalState :: Vetoed => Ok ( ( ) ) ,
269
+ ProposalState :: Executing
270
+ | ProposalState :: ExecutingWithErrors
271
+ | ProposalState :: SigningOff
272
+ | ProposalState :: Voting
273
+ | ProposalState :: Draft
274
+ // state transition bug: non executable proposals could be stuck in Succeeded state
275
+ | ProposalState :: Succeeded => Err ( GovernanceError :: InvalidStateNotFinal . into ( ) ) ,
276
+ }
277
+ }
278
+
262
279
/// Checks if Proposal can be voted on
263
280
pub fn assert_can_cast_vote (
264
281
& self ,
You can’t perform that action at this time.
0 commit comments