pub fn assert_can_execute_transaction(
        &self,
        proposal_transaction_data: &ProposalTransactionV2,
        current_unix_timestamp: UnixTimestamp,
    ) -> Result<(), ProgramError> {
        match self.state {
            ProposalState::Succeeded
            | ProposalState::Executing
            | ProposalState::ExecutingWithErrors => {}
            ProposalState::Draft
            | ProposalState::SigningOff
            | ProposalState::Completed
            | ProposalState::Voting
            | ProposalState::Cancelled
            | ProposalState::Defeated => {
                return Err(GovernanceError::InvalidStateCannotExecuteTransaction.into())
            }
        }

        if self.options[proposal_transaction_data.option_index as usize].vote_result
            != OptionVoteResult::Succeeded
        {
            return Err(GovernanceError::CannotExecuteDefeatedOption.into());
        }

        if self
            .voting_completed_at
            .unwrap()
            .checked_add(proposal_transaction_data.hold_up_time as i64)
            .unwrap()
            >= current_unix_timestamp
        {
            return Err(GovernanceError::CannotExecuteTransactionWithinHoldUpTime.into());
        }

        if proposal_transaction_data.executed_at.is_some() {
            return Err(GovernanceError::TransactionAlreadyExecuted.into());
        }

        Ok(())
    }
/// Checks if Instructions can be executed for the Proposal in the given state
Checks if Instructions can be executed for the Proposal in the given state
Checks if Instructions can be executed for the Proposal in the given state
pub fn assert_can_execute_transaction(
        &self,
        proposal_transaction_data: &ProposalTransactionV2,
        current_unix_timestamp: UnixTimestamp,
    ) -> Result<(), ProgramError> {
        match self.state {
            ProposalState::Succeeded
            | ProposalState::Executing
            | ProposalState::ExecutingWithErrors => {}
            ProposalState::Draft
            | ProposalState::SigningOff
            | ProposalState::Completed
            | ProposalState::Voting
            | ProposalState::Cancelled
            | ProposalState::Defeated => {
                return Err(GovernanceError::InvalidStateCannotExecuteTransaction.into())
            }
        }
        if self.options[proposal_transaction_data.option_index as usize].vote_result
            != OptionVoteResult::Succeeded
        {
            return Err(GovernanceError::CannotExecuteDefeatedOption.into());
        }
        if self
            .voting_completed_at
            .unwrap()
            .checked_add(proposal_transaction_data.hold_up_time as i64)
            .unwrap()
            >= current_unix_timestamp
        {
            return Err(GovernanceError::CannotExecuteTransactionWithinHoldUpTime.into());
        }
        if proposal_transaction_data.executed_at.is_some() {
            return Err(GovernanceError::TransactionAlreadyExecuted.into());
        }
        Ok(())
    }
pub fn assert_can_execute_transaction ( & self , proposal_transaction_data : & ProposalTransactionV2 , current_unix_timestamp : UnixTimestamp , ) -> Result < ( ) , ProgramError > { match self . state { ProposalState :: Succeeded | ProposalState :: Executing | ProposalState :: ExecutingWithErrors => { } ProposalState :: Draft | ProposalState :: SigningOff | ProposalState :: Completed | ProposalState :: Voting | ProposalState :: Cancelled | ProposalState :: Defeated => { return Err ( GovernanceError :: InvalidStateCannotExecuteTransaction . into ( ) ) } } if self . options [ proposal_transaction_data . option_index as usize ] . vote_result != OptionVoteResult :: Succeeded { return Err ( GovernanceError :: CannotExecuteDefeatedOption . into ( ) ) ; } if self . voting_completed_at . unwrap ( ) . checked_add ( proposal_transaction_data . hold_up_time as i64 ) . unwrap ( ) >= current_unix_timestamp { return Err ( GovernanceError :: CannotExecuteTransactionWithinHoldUpTime . into ( ) ) ; } if proposal_transaction_data . executed_at . is_some ( ) { return Err ( GovernanceError :: TransactionAlreadyExecuted . into ( ) ) ; } Ok ( ( ) ) }
Checks if Instructions can be executed for the Proposal in the given state
Checks if Instructions can be executed for the Proposal in the given state
&self
proposal_transaction_data
&ProposalTransactionV2
current_unix_timestamp
UnixTimestamp
&self
proposal_transaction_data
&ProposalTransactionV2
current_unix_timestamp
UnixTimestamp